@stacksjs/ts-cloud 0.16.22 → 0.16.24
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.
- package/dist/aws/client.d.ts +9 -0
- package/dist/aws/elasticache.d.ts +11 -9
- package/dist/aws/index.js +1 -1
- package/dist/bin/chunk-0cwbg3pf.js +1 -0
- package/dist/bin/{chunk-636jsmnz.js → chunk-0md2h0an.js} +6 -6
- package/dist/bin/chunk-0ytk5g2t.js +1 -0
- package/dist/bin/chunk-19tmmwmt.js +1 -0
- package/dist/bin/chunk-1fde3e2c.js +1 -0
- package/dist/bin/{chunk-5bsknbr7.js → chunk-1j9vy88a.js} +1 -1
- package/dist/bin/{chunk-c04dygzg.js → chunk-257sygzm.js} +5 -5
- package/dist/bin/{chunk-7xr71hnt.js → chunk-2q27v6vz.js} +2 -2
- package/dist/bin/chunk-3b8a3knq.js +1 -0
- package/dist/bin/{chunk-k97ms0bs.js → chunk-3jjggqfj.js} +5 -5
- package/dist/bin/{chunk-m51vpvr6.js → chunk-4sq6cvz5.js} +3 -3
- package/dist/bin/chunk-4y20ry45.js +1 -0
- package/dist/bin/{chunk-hmnaen1z.js → chunk-5kc8s9gp.js} +1 -1
- package/dist/bin/{chunk-8wnkx3jf.js → chunk-5x59x4qw.js} +2 -2
- package/dist/bin/chunk-6aj3h8yk.js +1 -0
- package/dist/bin/{chunk-95v6ry1x.js → chunk-6eesa8d1.js} +5 -5
- package/dist/bin/{chunk-a0me5fed.js → chunk-6nm91cfw.js} +2 -2
- package/dist/bin/{chunk-3425j97b.js → chunk-7412q5cz.js} +2 -2
- package/dist/bin/chunk-78w3bn85.js +1 -0
- package/dist/bin/{chunk-ardzx4dw.js → chunk-8e7n357e.js} +128 -128
- package/dist/bin/{chunk-jp23ed1q.js → chunk-8knkt6sd.js} +1 -1
- package/dist/bin/{chunk-2gd8kqzq.js → chunk-9464wvf2.js} +5 -5
- package/dist/bin/{chunk-k6apknm8.js → chunk-988qv730.js} +5 -5
- package/dist/bin/chunk-9b6af1sj.js +1 -0
- package/dist/bin/{chunk-87f5d9qj.js → chunk-9e7pqhj1.js} +1 -1
- package/dist/bin/chunk-a07jfqvs.js +1 -0
- package/dist/bin/chunk-a3rq51az.js +2 -0
- package/dist/bin/chunk-apw5bbjg.js +1 -0
- package/dist/bin/{chunk-v980gs11.js → chunk-ax41jhq7.js} +2 -2
- package/dist/bin/{chunk-12q8xrct.js → chunk-c35qm7as.js} +5 -5
- package/dist/bin/{chunk-330kytpm.js → chunk-d1psxeqj.js} +2 -2
- package/dist/bin/{chunk-qqqx70g6.js → chunk-f0fpp4mk.js} +2 -2
- package/dist/bin/chunk-fpy7nv5g.js +1 -0
- package/dist/bin/chunk-fq4nxfec.js +1 -0
- package/dist/bin/chunk-ghe1nawv.js +1 -0
- package/dist/bin/{chunk-n8dsby4k.js → chunk-hez48c69.js} +1 -1
- package/dist/bin/{chunk-wqydambz.js → chunk-hjv1k8s9.js} +16 -16
- package/dist/bin/chunk-hwqvx1zb.js +1 -0
- package/dist/bin/{chunk-24njmb7d.js → chunk-jdfbahjb.js} +110 -110
- package/dist/bin/chunk-jwdcx0mm.js +1 -0
- package/dist/bin/chunk-k9mzq7z9.js +1 -0
- package/dist/bin/chunk-kf1p7s61.js +1 -0
- package/dist/bin/{chunk-n7hmjzgd.js → chunk-m2gwzksz.js} +1 -1
- package/dist/bin/chunk-mh172wt8.js +1 -0
- package/dist/bin/{chunk-and7khsv.js → chunk-prj5b597.js} +2 -2
- package/dist/bin/chunk-q3xwh0r8.js +6 -0
- package/dist/bin/chunk-q8crt80d.js +1 -0
- package/dist/bin/chunk-r3hkc2s3.js +1 -0
- package/dist/bin/{chunk-7kj8f72p.js → chunk-rpfvv7hw.js} +1 -1
- package/dist/bin/{chunk-mz2jbtcs.js → chunk-wfa8j3wg.js} +3 -3
- package/dist/bin/{chunk-rm59bcnw.js → chunk-wffaqgcc.js} +62 -62
- package/dist/bin/chunk-wg20x65t.js +34 -0
- package/dist/{chunk-dv1jkay7.js → bin/chunk-wsedynyb.js} +7 -7
- package/dist/bin/chunk-xb82bmgf.js +1 -0
- package/dist/bin/{chunk-8agf66wn.js → chunk-xh5jcv64.js} +3 -3
- package/dist/bin/{chunk-v5bjbyve.js → chunk-xss6yj73.js} +2 -2
- package/dist/bin/chunk-xxgybh3b.js +1 -0
- package/dist/bin/{chunk-vskhr9qy.js → chunk-y6rgvb7r.js} +2 -2
- package/dist/bin/chunk-z5ycwy38.js +2 -0
- package/dist/bin/chunk-zq02x716.js +1 -0
- package/dist/bin/cli.js +335 -335
- package/dist/bin/dashboard-server.js +1 -1
- package/dist/chunk-1ba6keyk.js +1 -0
- package/dist/{chunk-3zzm5f28.js → chunk-3x9g48ey.js} +26 -26
- package/dist/chunk-4rkjhvgw.js +114 -0
- package/dist/{chunk-9s24pbbc.js → chunk-65yh2h1e.js} +1 -1
- package/dist/{chunk-x60w04y3.js → chunk-6e5j40n9.js} +2 -2
- package/dist/{chunk-5dz6bzdj.js → chunk-97trx8p9.js} +2 -2
- package/dist/{chunk-mgg0psgc.js → chunk-9ca1yafd.js} +2 -2
- package/dist/{chunk-jt49qs0f.js → chunk-bzbryxfm.js} +2 -2
- package/dist/{chunk-pffebjr8.js → chunk-d8w90gsb.js} +36 -36
- package/dist/{chunk-w4s3rswa.js → chunk-dm6kyz6e.js} +2 -2
- package/dist/chunk-e3axmek0.js +1 -0
- package/dist/chunk-e4z4tfh6.js +1 -0
- package/dist/{chunk-2dextjqf.js → chunk-e7m70ex1.js} +2 -2
- package/dist/{chunk-ezgpamw6.js → chunk-gvybjt7y.js} +1 -1
- package/dist/{bin/chunk-09d5qe73.js → chunk-h85wqdvr.js} +7 -7
- package/dist/{chunk-3jkc3s8c.js → chunk-hzbyj0xd.js} +19 -19
- package/dist/{chunk-9p89msvs.js → chunk-jrrw3ezm.js} +5 -5
- package/dist/{chunk-ms4dnha2.js → chunk-mv7hne2c.js} +1 -1
- package/dist/chunk-qa6jjv3m.js +1 -0
- package/dist/{chunk-pcns0kz4.js → chunk-qfqh21rq.js} +5 -5
- package/dist/{chunk-2ap78e1s.js → chunk-qrchr75r.js} +4 -4
- package/dist/{chunk-khatwx29.js → chunk-rgq7m90a.js} +99 -99
- package/dist/chunk-rnjgde95.js +1 -0
- package/dist/{chunk-pwywwdq2.js → chunk-rr1qjxyj.js} +1 -1
- package/dist/chunk-t4ynyk8k.js +34 -0
- package/dist/{chunk-kpyhx96m.js → chunk-v7y50hhf.js} +110 -110
- package/dist/chunk-vtm83crj.js +709 -0
- package/dist/chunk-wrpnnrdf.js +6 -0
- package/dist/{chunk-np8vgbv0.js → chunk-x9bpm5s1.js} +3 -3
- package/dist/{chunk-cfrv8110.js → chunk-zv85cpt2.js} +4 -4
- package/dist/deploy/index.js +1 -1
- package/dist/dns/index.js +1 -1
- package/dist/drivers/index.js +1 -1
- package/dist/index.js +78 -78
- package/dist/operations/index.js +1 -1
- package/dist/protection/index.js +1 -1
- package/dist/spend/index.js +1 -1
- package/dist/ui/404.html +1 -1
- package/dist/ui/accept-invitation.html +1 -1
- package/dist/ui/access-denied.html +1 -1
- package/dist/ui/account/automation.html +6 -6
- package/dist/ui/account/security.html +2 -2
- package/dist/ui/applications/compose.html +6 -6
- package/dist/ui/applications/new.html +2 -2
- package/dist/ui/data/backups.html +6 -6
- package/dist/ui/data/services.html +6 -6
- package/dist/ui/data/volumes.html +6 -6
- package/dist/ui/index.html +6 -6
- package/dist/ui/infrastructure/topology.html +6 -6
- package/dist/ui/integrations.html +1 -1
- package/dist/ui/operations/alerts.html +6 -6
- package/dist/ui/operations/configuration.html +6 -6
- package/dist/ui/operations/jobs.html +6 -6
- package/dist/ui/operations/maintenance.html +5 -5
- package/dist/ui/operations/observability.html +6 -6
- package/dist/ui/operations/previews.html +6 -6
- package/dist/ui/operations/queue.html +6 -6
- package/dist/ui/operations/regions.html +6 -6
- package/dist/ui/operations/releases.html +6 -6
- package/dist/ui/operations/spend.html +6 -6
- package/dist/ui/operations/workloads.html +6 -6
- package/dist/ui/security.html +1 -1
- package/dist/ui/server/actions.html +6 -6
- package/dist/ui/server/activity.html +1 -1
- package/dist/ui/server/capacity.html +5 -5
- package/dist/ui/server/database.html +5 -5
- package/dist/ui/server/deployments.html +5 -5
- package/dist/ui/server/diagnostics.html +2 -2
- package/dist/ui/server/firewall.html +6 -6
- package/dist/ui/server/fleet.html +6 -6
- package/dist/ui/server/logs.html +6 -6
- package/dist/ui/server/metrics.html +5 -5
- package/dist/ui/server/security.html +2 -2
- package/dist/ui/server/services.html +2 -2
- package/dist/ui/server/sites.html +6 -6
- package/dist/ui/server/ssh-keys.html +6 -6
- package/dist/ui/server/team.html +6 -6
- package/dist/ui/server/terminal.html +2 -2
- package/dist/ui/serverless/alarms.html +6 -6
- package/dist/ui/serverless/assets.html +2 -2
- package/dist/ui/serverless/cost.html +2 -2
- package/dist/ui/serverless/data.html +6 -6
- package/dist/ui/serverless/deployments.html +2 -2
- package/dist/ui/serverless/firewall.html +2 -2
- package/dist/ui/serverless/functions.html +6 -6
- package/dist/ui/serverless/logs.html +6 -6
- package/dist/ui/serverless/metrics.html +1 -1
- package/dist/ui/serverless/queues.html +5 -5
- package/dist/ui/serverless/secrets.html +6 -6
- package/dist/ui/serverless/traces.html +6 -6
- package/dist/ui/serverless.html +5 -5
- package/package.json +3 -3
- package/dist/bin/chunk-0cefbrxg.js +0 -1
- package/dist/bin/chunk-1srmd473.js +0 -1
- package/dist/bin/chunk-27ka240w.js +0 -1
- package/dist/bin/chunk-3bq69jqk.js +0 -1
- package/dist/bin/chunk-4pysr1ky.js +0 -1
- package/dist/bin/chunk-56zfvf7e.js +0 -1
- package/dist/bin/chunk-59nav625.js +0 -1
- package/dist/bin/chunk-8fjzcr2w.js +0 -1
- package/dist/bin/chunk-9fq0bezb.js +0 -1
- package/dist/bin/chunk-9wpy7r9f.js +0 -1
- package/dist/bin/chunk-eetz9jgy.js +0 -1
- package/dist/bin/chunk-eg6156wp.js +0 -1
- package/dist/bin/chunk-ezpz96kp.js +0 -1
- package/dist/bin/chunk-f2qpsrrj.js +0 -1
- package/dist/bin/chunk-f3sbq7pw.js +0 -2
- package/dist/bin/chunk-gmabk4qn.js +0 -1
- package/dist/bin/chunk-kr51h4gk.js +0 -1
- package/dist/bin/chunk-mbqwrs7a.js +0 -6
- package/dist/bin/chunk-nx8gpr90.js +0 -34
- package/dist/bin/chunk-q62ggp3g.js +0 -1
- package/dist/bin/chunk-q957s44c.js +0 -1
- package/dist/bin/chunk-rm6qnyce.js +0 -2
- package/dist/bin/chunk-rxehseyz.js +0 -1
- package/dist/bin/chunk-tfz7djw9.js +0 -1
- package/dist/bin/chunk-tr8901hb.js +0 -1
- package/dist/bin/chunk-vqb80dyg.js +0 -1
- package/dist/bin/chunk-wysyyysg.js +0 -1
- package/dist/bin/chunk-xfs7rscr.js +0 -1
- package/dist/chunk-2fa9cdyf.js +0 -1
- package/dist/chunk-6d5e10md.js +0 -1
- package/dist/chunk-9gypn8w9.js +0 -1
- package/dist/chunk-badb5mf3.js +0 -34
- package/dist/chunk-j6a577hr.js +0 -1
- package/dist/chunk-kw852q5m.js +0 -709
- package/dist/chunk-p0b08g9f.js +0 -114
- package/dist/chunk-whdbz3h8.js +0 -1
- package/dist/chunk-y6k0vwfn.js +0 -6
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import{Ft,u}from"./chunk-q3xwh0r8.js";import{g}from"./chunk-2q27v6vz.js";import{U}from"./chunk-5kc8s9gp.js";import{_}from"./chunk-a3rq51az.js";import{mi}from"./chunk-z5ycwy38.js";function R(e,t){let r=[`Action=${e}`,"Version=2010-05-08"];for(let[a,i]of Object.entries(t)){if(i===void 0||i===null)continue;if(Array.isArray(i))i.forEach((n,o)=>{if(typeof n==="object"&&n!==null)for(let[m,l]of Object.entries(n))r.push(`${a}.member.${o+1}.${m}=${encodeURIComponent(String(l))}`);else r.push(`${a}.member.${o+1}=${encodeURIComponent(String(n))}`)});else if(typeof i==="object"){for(let[n,o]of Object.entries(i))if(o!==void 0&&o!==null)r.push(`${a}.${n}=${encodeURIComponent(String(o))}`)}else r.push(`${a}=${encodeURIComponent(String(i))}`)}return r.join("&")}var f=new Ft({ignoreAttributes:!0,parseTagValue:!1,trimValues:!0});function S(e){if(typeof e!=="string"||!e.trim())return{};return f.parse(e)}function s(e,t){let r=[e];while(r.length>0){let a=[];for(let i of r){if(!i||typeof i!=="object")continue;if(Array.isArray(i)){a.push(...i);continue}if(t in i){let n=i[t];return typeof n==="string"?n:void 0}a.push(...Object.values(i))}r=a}return}function c(e,t,r){let a=[e];while(a.length>0){let i=[];for(let n of a){if(!n||typeof n!=="object")continue;if(Array.isArray(n)){i.push(...n);continue}if(t in n){let o=n[t]?.[r];return o===void 0||o===null?[]:Array.isArray(o)?o:[o]}i.push(...Object.values(n))}a=i}return[]}class Z{client;region;constructor(e="us-east-1",t){this.client=new u(void 0,{profile:t}),this.region=e}async request(e,t={}){let r=R(e,t),a=await this.client.request({service:"iam",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:r,rawResponse:!0});return S(a)}async createUser(e){let t=await this.request("CreateUser",e);return this.parseUser(t)}async getUser(e={}){let t=await this.request("GetUser",e);return this.parseUser(t)}async listUsers(e={}){let t=await this.request("ListUsers",e),r=this.parseUsers(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{Users:r,IsTruncated:a,Marker:i}}async updateUser(e){await this.request("UpdateUser",e)}async deleteUser(e){await this.request("DeleteUser",e)}parseUser(e){return{UserName:s(e,"UserName")||"",UserId:s(e,"UserId")||"",Arn:s(e,"Arn")||"",Path:s(e,"Path"),CreateDate:s(e,"CreateDate"),PasswordLastUsed:s(e,"PasswordLastUsed")}}parseUsers(e){return c(e,"Users","member").map((r)=>({UserName:s(r,"UserName")||"",UserId:s(r,"UserId")||"",Arn:s(r,"Arn")||"",Path:s(r,"Path"),CreateDate:s(r,"CreateDate"),PasswordLastUsed:s(r,"PasswordLastUsed")}))}async createGroup(e){let t=await this.request("CreateGroup",e);return this.parseGroup(t)}async getGroup(e){let t=await this.request("GetGroup",e),r=this.parseGroup(t),a=this.parseUsers(t),i=s(t,"IsTruncated")==="true",n=s(t,"Marker");return{Group:r,Users:a,IsTruncated:i,Marker:n}}async listGroups(e={}){let t=await this.request("ListGroups",e),r=this.parseGroups(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{Groups:r,IsTruncated:a,Marker:i}}async updateGroup(e){await this.request("UpdateGroup",e)}async deleteGroup(e){await this.request("DeleteGroup",e)}async addUserToGroup(e){await this.request("AddUserToGroup",e)}async removeUserFromGroup(e){await this.request("RemoveUserFromGroup",e)}async listGroupsForUser(e){let t=await this.request("ListGroupsForUser",e),r=this.parseGroups(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{Groups:r,IsTruncated:a,Marker:i}}parseGroup(e){return{GroupName:s(e,"GroupName")||"",GroupId:s(e,"GroupId")||"",Arn:s(e,"Arn")||"",Path:s(e,"Path"),CreateDate:s(e,"CreateDate")}}parseGroups(e){return c(e,"Groups","member").map((r)=>({GroupName:s(r,"GroupName")||"",GroupId:s(r,"GroupId")||"",Arn:s(r,"Arn")||"",Path:s(r,"Path"),CreateDate:s(r,"CreateDate")}))}async createRole(e){let t=await this.request("CreateRole",e);return this.parseRole(t)}async getRole(e){let t=await this.request("GetRole",e);return this.parseRole(t)}async listRoles(e={}){let t=await this.request("ListRoles",e),r=this.parseRoles(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{Roles:r,IsTruncated:a,Marker:i}}async updateRole(e){await this.request("UpdateRole",e)}async updateRoleDescription(e){let t=await this.request("UpdateRoleDescription",e);return this.parseRole(t)}async updateAssumeRolePolicy(e){await this.request("UpdateAssumeRolePolicy",e)}async deleteRole(e){await this.request("DeleteRole",e)}async tagRole(e){await this.request("TagRole",e)}async untagRole(e){await this.request("UntagRole",e)}async listRoleTags(e){let t=await this.request("ListRoleTags",e),r=this.parseTags(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{Tags:r,IsTruncated:a,Marker:i}}parseRole(e){return{RoleName:s(e,"RoleName")||"",RoleId:s(e,"RoleId")||"",Arn:s(e,"Arn")||"",Path:s(e,"Path"),CreateDate:s(e,"CreateDate"),AssumeRolePolicyDocument:s(e,"AssumeRolePolicyDocument"),Description:s(e,"Description"),MaxSessionDuration:s(e,"MaxSessionDuration")?Number.parseInt(s(e,"MaxSessionDuration"),10):void 0}}parseRoles(e){return c(e,"Roles","member").map((r)=>({RoleName:s(r,"RoleName")||"",RoleId:s(r,"RoleId")||"",Arn:s(r,"Arn")||"",Path:s(r,"Path"),CreateDate:s(r,"CreateDate"),AssumeRolePolicyDocument:s(r,"AssumeRolePolicyDocument"),Description:s(r,"Description"),MaxSessionDuration:s(r,"MaxSessionDuration")?Number.parseInt(s(r,"MaxSessionDuration"),10):void 0}))}parseTags(e){return c(e,"Tags","member").map((r)=>({Key:s(r,"Key")||"",Value:s(r,"Value")||""}))}async createPolicy(e){let t=await this.request("CreatePolicy",e);return this.parsePolicy(t)}async getPolicy(e){let t=await this.request("GetPolicy",e);return this.parsePolicy(t)}async getPolicyVersion(e){let t=await this.request("GetPolicyVersion",e);return{VersionId:s(t,"VersionId")||"",IsDefaultVersion:s(t,"IsDefaultVersion")==="true",CreateDate:s(t,"CreateDate"),Document:s(t,"Document")}}async listPolicies(e={}){let t=await this.request("ListPolicies",e),r=this.parsePolicies(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{Policies:r,IsTruncated:a,Marker:i}}async listPolicyVersions(e){let t=await this.request("ListPolicyVersions",e),r=this.parsePolicyVersions(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{Versions:r,IsTruncated:a,Marker:i}}async createPolicyVersion(e){let t=await this.request("CreatePolicyVersion",e);return{VersionId:s(t,"VersionId")||"",IsDefaultVersion:s(t,"IsDefaultVersion")==="true",CreateDate:s(t,"CreateDate")}}async deletePolicyVersion(e){await this.request("DeletePolicyVersion",e)}async setDefaultPolicyVersion(e){await this.request("SetDefaultPolicyVersion",e)}async deletePolicy(e){await this.request("DeletePolicy",e)}async attachUserPolicy(e){await this.request("AttachUserPolicy",e)}async detachUserPolicy(e){await this.request("DetachUserPolicy",e)}async attachGroupPolicy(e){await this.request("AttachGroupPolicy",e)}async detachGroupPolicy(e){await this.request("DetachGroupPolicy",e)}async attachRolePolicy(e){await this.request("AttachRolePolicy",e)}async detachRolePolicy(e){await this.request("DetachRolePolicy",e)}async listAttachedUserPolicies(e){let t=await this.request("ListAttachedUserPolicies",e),r=this.parseAttachedPolicies(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{AttachedPolicies:r,IsTruncated:a,Marker:i}}async listAttachedGroupPolicies(e){let t=await this.request("ListAttachedGroupPolicies",e),r=this.parseAttachedPolicies(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{AttachedPolicies:r,IsTruncated:a,Marker:i}}async listAttachedRolePolicies(e){let t=await this.request("ListAttachedRolePolicies",e),r=this.parseAttachedPolicies(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{AttachedPolicies:r,IsTruncated:a,Marker:i}}parsePolicy(e){return{PolicyName:s(e,"PolicyName")||"",PolicyId:s(e,"PolicyId")||"",Arn:s(e,"Arn")||"",Path:s(e,"Path"),DefaultVersionId:s(e,"DefaultVersionId"),AttachmentCount:s(e,"AttachmentCount")?Number.parseInt(s(e,"AttachmentCount"),10):void 0,PermissionsBoundaryUsageCount:s(e,"PermissionsBoundaryUsageCount")?Number.parseInt(s(e,"PermissionsBoundaryUsageCount"),10):void 0,IsAttachable:s(e,"IsAttachable")==="true",Description:s(e,"Description"),CreateDate:s(e,"CreateDate"),UpdateDate:s(e,"UpdateDate")}}parsePolicies(e){return c(e,"Policies","member").map((r)=>({PolicyName:s(r,"PolicyName")||"",PolicyId:s(r,"PolicyId")||"",Arn:s(r,"Arn")||"",Path:s(r,"Path"),DefaultVersionId:s(r,"DefaultVersionId"),AttachmentCount:s(r,"AttachmentCount")?Number.parseInt(s(r,"AttachmentCount"),10):void 0,PermissionsBoundaryUsageCount:s(r,"PermissionsBoundaryUsageCount")?Number.parseInt(s(r,"PermissionsBoundaryUsageCount"),10):void 0,IsAttachable:s(r,"IsAttachable")==="true",Description:s(r,"Description"),CreateDate:s(r,"CreateDate"),UpdateDate:s(r,"UpdateDate")}))}parsePolicyVersions(e){return c(e,"Versions","member").map((r)=>({VersionId:s(r,"VersionId")||"",IsDefaultVersion:s(r,"IsDefaultVersion")==="true",CreateDate:s(r,"CreateDate")}))}parseAttachedPolicies(e){return c(e,"AttachedPolicies","member").map((r)=>({PolicyName:s(r,"PolicyName")||"",PolicyArn:s(r,"PolicyArn")||""}))}async putUserPolicy(e){await this.request("PutUserPolicy",e)}async getUserPolicy(e){let t=await this.request("GetUserPolicy",e);return{UserName:s(t,"UserName")||"",PolicyName:s(t,"PolicyName")||"",PolicyDocument:decodeURIComponent(s(t,"PolicyDocument")||"")}}async deleteUserPolicy(e){await this.request("DeleteUserPolicy",e)}async listUserPolicies(e){let t=await this.request("ListUserPolicies",e),r=c(t,"PolicyNames","member"),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{PolicyNames:r,IsTruncated:a,Marker:i}}async putGroupPolicy(e){await this.request("PutGroupPolicy",e)}async getGroupPolicy(e){let t=await this.request("GetGroupPolicy",e);return{GroupName:s(t,"GroupName")||"",PolicyName:s(t,"PolicyName")||"",PolicyDocument:decodeURIComponent(s(t,"PolicyDocument")||"")}}async deleteGroupPolicy(e){await this.request("DeleteGroupPolicy",e)}async listGroupPolicies(e){let t=await this.request("ListGroupPolicies",e),r=c(t,"PolicyNames","member"),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{PolicyNames:r,IsTruncated:a,Marker:i}}async putRolePolicy(e){await this.request("PutRolePolicy",e)}async getRolePolicy(e){let t=await this.request("GetRolePolicy",e);return{RoleName:s(t,"RoleName")||"",PolicyName:s(t,"PolicyName")||"",PolicyDocument:decodeURIComponent(s(t,"PolicyDocument")||"")}}async deleteRolePolicy(e){await this.request("DeleteRolePolicy",e)}async listRolePolicies(e){let t=await this.request("ListRolePolicies",e),r=c(t,"PolicyNames","member"),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{PolicyNames:r,IsTruncated:a,Marker:i}}async createAccessKey(e={}){let t=await this.request("CreateAccessKey",e);if(typeof t==="object"){let r=t?.CreateAccessKeyResult?.AccessKey||t?.AccessKey;if(r)return{AccessKey:{UserName:r.UserName||"",AccessKeyId:r.AccessKeyId||"",Status:r.Status||"Active",SecretAccessKey:r.SecretAccessKey||"",CreateDate:r.CreateDate}}}return{AccessKey:{UserName:s(t,"UserName")||"",AccessKeyId:s(t,"AccessKeyId")||"",Status:s(t,"Status")||"Active",SecretAccessKey:s(t,"SecretAccessKey")||"",CreateDate:s(t,"CreateDate")}}}async listAccessKeys(e={}){let t=await this.request("ListAccessKeys",e),r=this.parseAccessKeys(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{AccessKeyMetadata:r,IsTruncated:a,Marker:i}}async updateAccessKey(e){await this.request("UpdateAccessKey",e)}async deleteAccessKey(e){await this.request("DeleteAccessKey",e)}async getAccessKeyLastUsed(e){let t=await this.request("GetAccessKeyLastUsed",e);return{UserName:s(t,"UserName")||"",AccessKeyLastUsed:{LastUsedDate:s(t,"LastUsedDate"),ServiceName:s(t,"ServiceName"),Region:s(t,"Region")}}}parseAccessKeys(e){return c(e,"AccessKeyMetadata","member").map((r)=>({UserName:s(r,"UserName"),AccessKeyId:s(r,"AccessKeyId")||"",Status:s(r,"Status")||"Active",CreateDate:s(r,"CreateDate")}))}async createInstanceProfile(e){let t=await this.request("CreateInstanceProfile",e);return this.parseInstanceProfile(t)}async getInstanceProfile(e){let t=await this.request("GetInstanceProfile",e);return this.parseInstanceProfile(t)}async listInstanceProfiles(e={}){let t=await this.request("ListInstanceProfiles",e),r=this.parseInstanceProfiles(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{InstanceProfiles:r,IsTruncated:a,Marker:i}}async listInstanceProfilesForRole(e){let t=await this.request("ListInstanceProfilesForRole",e),r=this.parseInstanceProfiles(t),a=s(t,"IsTruncated")==="true",i=s(t,"Marker");return{InstanceProfiles:r,IsTruncated:a,Marker:i}}async addRoleToInstanceProfile(e){await this.request("AddRoleToInstanceProfile",e)}async removeRoleFromInstanceProfile(e){await this.request("RemoveRoleFromInstanceProfile",e)}async deleteInstanceProfile(e){await this.request("DeleteInstanceProfile",e)}parseInstanceProfile(e){return{InstanceProfileName:s(e,"InstanceProfileName")||"",InstanceProfileId:s(e,"InstanceProfileId")||"",Arn:s(e,"Arn")||"",Path:s(e,"Path"),CreateDate:s(e,"CreateDate")}}parseInstanceProfiles(e){return c(e,"InstanceProfiles","member").map((r)=>({InstanceProfileName:s(r,"InstanceProfileName")||"",InstanceProfileId:s(r,"InstanceProfileId")||"",Arn:s(r,"Arn")||"",Path:s(r,"Path"),CreateDate:s(r,"CreateDate")}))}async getAccountPasswordPolicy(){let e=await this.request("GetAccountPasswordPolicy");return{MinimumPasswordLength:s(e,"MinimumPasswordLength")?Number.parseInt(s(e,"MinimumPasswordLength"),10):void 0,RequireSymbols:s(e,"RequireSymbols")==="true",RequireNumbers:s(e,"RequireNumbers")==="true",RequireUppercaseCharacters:s(e,"RequireUppercaseCharacters")==="true",RequireLowercaseCharacters:s(e,"RequireLowercaseCharacters")==="true",AllowUsersToChangePassword:s(e,"AllowUsersToChangePassword")==="true",ExpirePasswords:s(e,"ExpirePasswords")==="true",MaxPasswordAge:s(e,"MaxPasswordAge")?Number.parseInt(s(e,"MaxPasswordAge"),10):void 0,PasswordReusePrevention:s(e,"PasswordReusePrevention")?Number.parseInt(s(e,"PasswordReusePrevention"),10):void 0,HardExpiry:s(e,"HardExpiry")==="true"}}async updateAccountPasswordPolicy(e){await this.request("UpdateAccountPasswordPolicy",e)}async deleteAccountPasswordPolicy(){await this.request("DeleteAccountPasswordPolicy")}async getAccountSummary(){let e=await this.request("GetAccountSummary"),t={},r=c(e,"SummaryMap","entry");for(let a of r){let i=s(a,"key"),n=s(a,"value");if(i&&n)t[i]=Number.parseInt(n,10)}return t}async listAccountAliases(){let e=await this.request("ListAccountAliases"),t=c(e,"AccountAliases","member"),r=s(e,"IsTruncated")==="true",a=s(e,"Marker");return{AccountAliases:t,IsTruncated:r,Marker:a}}async createAccountAlias(e){await this.request("CreateAccountAlias",e)}async deleteAccountAlias(e){await this.request("DeleteAccountAlias",e)}async simulatePrincipalPolicy(e){let t=await this.request("SimulatePrincipalPolicy",e);return this.parseSimulationResults(t)}parseSimulationResults(e){let r=c(e,"EvaluationResults","member").map((n)=>{let m=c(n,"MatchedStatements","member").map((l)=>({SourcePolicyId:s(l,"SourcePolicyId"),SourcePolicyType:s(l,"SourcePolicyType")}));return{EvalActionName:s(n,"EvalActionName")||"",EvalResourceName:s(n,"EvalResourceName"),EvalDecision:s(n,"EvalDecision")||"",MatchedStatements:m.length>0?m:void 0}}),a=s(e,"IsTruncated")==="true",i=s(e,"Marker");return{EvaluationResults:r,IsTruncated:a,Marker:i}}}class be{client;region;constructor(e="us-east-1",t){this.region=e,this.client=new u(t)}async createEmailIdentity(e){return await this.client.request({service:"email",region:this.region,method:"POST",path:"/v2/email/identities",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async getEmailIdentity(e){let t=await this.client.request({service:"email",region:this.region,method:"GET",path:`/v2/email/identities/${encodeURIComponent(e)}`,headers:{"Content-Type":"application/json"}});return{IdentityType:t.IdentityType,IdentityName:e,SendingEnabled:t.VerifiedForSendingStatus,VerificationStatus:t.VerificationStatus,DkimAttributes:t.DkimAttributes,MailFromAttributes:t.MailFromAttributes}}async putEmailIdentityMailFromAttributes(e,t){await this.client.request({service:"email",region:this.region,method:"PUT",path:`/v2/email/identities/${encodeURIComponent(e)}/mail-from`,headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})}async listEmailIdentities(e){let t="/v2/email/identities",r=[];if(e?.PageSize)r.push(`PageSize=${e.PageSize}`);if(e?.NextToken)r.push(`NextToken=${encodeURIComponent(e.NextToken)}`);if(r.length>0)t+=`?${r.join("&")}`;let a=await this.client.request({service:"email",region:this.region,method:"GET",path:t,headers:{"Content-Type":"application/json"}});return{EmailIdentities:a.EmailIdentities,NextToken:a.NextToken}}async deleteEmailIdentity(e){await this.client.request({service:"email",region:this.region,method:"DELETE",path:`/v2/email/identities/${encodeURIComponent(e)}`,headers:{"Content-Type":"application/json"}})}async putEmailIdentityDkimAttributes(e){await this.client.request({service:"email",region:this.region,method:"PUT",path:`/v2/email/identities/${encodeURIComponent(e.EmailIdentity)}/dkim`,headers:{"Content-Type":"application/json"},body:JSON.stringify({SigningEnabled:e.SigningEnabled})})}async sendEmail(e){return{MessageId:(await this.client.request({service:"email",region:this.region,method:"POST",path:"/v2/email/outbound-emails",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).MessageId}}async sendBulkEmail(e){return{BulkEmailEntryResults:(await this.client.request({service:"email",region:this.region,method:"POST",path:"/v2/email/outbound-bulk-emails",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).BulkEmailEntryResults}}async createEmailTemplate(e){await this.client.request({service:"email",region:this.region,method:"POST",path:"/v2/email/templates",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}async getEmailTemplate(e){return await this.client.request({service:"email",region:this.region,method:"GET",path:`/v2/email/templates/${encodeURIComponent(e)}`,headers:{"Content-Type":"application/json"}})}async deleteEmailTemplate(e){await this.client.request({service:"email",region:this.region,method:"DELETE",path:`/v2/email/templates/${encodeURIComponent(e)}`,headers:{"Content-Type":"application/json"}})}async listEmailTemplates(e){let t="/v2/email/templates",r=[];if(e?.PageSize)r.push(`PageSize=${e.PageSize}`);if(e?.NextToken)r.push(`NextToken=${encodeURIComponent(e.NextToken)}`);if(r.length>0)t+=`?${r.join("&")}`;return await this.client.request({service:"email",region:this.region,method:"GET",path:t,headers:{"Content-Type":"application/json"}})}async getSendStatistics(){let e=await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"Action=GetSendStatistics&Version=2010-12-01"}),t=_(e,"GetSendStatistics")?.SendDataPoints?.member;return{SendDataPoints:t==null?[]:Array.isArray(t)?t:[t]}}async getSendQuota(){let e=await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:"Action=GetSendQuota&Version=2010-12-01"}),t=_(e,"GetSendQuota"),r=(a)=>a==null||a===""?void 0:Number(a);return{Max24HourSend:r(t?.Max24HourSend),MaxSendRate:r(t?.MaxSendRate),SentLast24Hours:r(t?.SentLast24Hours)}}async verifyDomain(e){let t=await this.createEmailIdentity({EmailIdentity:e});return{dkimTokens:t.DkimAttributes?.Tokens,verificationStatus:t.DkimAttributes?.Status}}async sendSimpleEmail(e){let t=Array.isArray(e.to)?e.to:[e.to],r=e.replyTo?Array.isArray(e.replyTo)?e.replyTo:[e.replyTo]:void 0,a={};if(e.text)a.Text={Data:e.text};if(e.html)a.Html={Data:e.html};return this.sendEmail({FromEmailAddress:e.from,Destination:{ToAddresses:t},Content:{Simple:{Subject:{Data:e.subject},Body:a}},ReplyToAddresses:r})}async sendTemplatedEmail(e){let t=Array.isArray(e.to)?e.to:[e.to],r=e.replyTo?Array.isArray(e.replyTo)?e.replyTo:[e.replyTo]:void 0;return this.sendEmail({FromEmailAddress:e.from,Destination:{ToAddresses:t},Content:{Template:{TemplateName:e.templateName,TemplateData:JSON.stringify(e.templateData)}},ReplyToAddresses:r})}async getDkimRecords(e){let t=await this.getEmailIdentity(e);if(!t.DkimAttributes?.Tokens)return[];return t.DkimAttributes.Tokens.map((r)=>({name:`${r}._domainkey.${e}`,type:"CNAME",value:`${r}.dkim.amazonses.com`}))}async isDomainVerified(e){try{let t=await this.getEmailIdentity(e);return t.VerificationStatus==="SUCCESS"&&t.SendingEnabled===!0}catch{return!1}}async waitForDomainVerification(e,t=60,r=30000){for(let a=0;a<t;a++){if(await this.isDomainVerified(e))return!0;await new Promise((n)=>setTimeout(n,r))}return!1}buildFormBody(e){return Object.entries(e).filter(([,r])=>r!==void 0).map(([r,a])=>`${encodeURIComponent(r)}=${encodeURIComponent(a)}`).join("&")}async createReceiptRuleSet(e){await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody({Action:"CreateReceiptRuleSet",Version:"2010-12-01",RuleSetName:e})})}async deleteReceiptRuleSet(e){await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody({Action:"DeleteReceiptRuleSet",Version:"2010-12-01",RuleSetName:e})})}async setActiveReceiptRuleSet(e){await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody({Action:"SetActiveReceiptRuleSet",Version:"2010-12-01",RuleSetName:e})})}async listReceiptRuleSets(e){let t={Action:"ListReceiptRuleSets",Version:"2010-12-01"};if(e)t.NextToken=e;let r=await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody(t)}),a=r?.ListReceiptRuleSetsResponse?.ListReceiptRuleSetsResult||r?.ListReceiptRuleSetsResult,i=a?.RuleSets?.member;return{RuleSets:Array.isArray(i)?i:i?[i]:[],NextToken:a?.NextToken}}async describeReceiptRuleSet(e){let t=await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody({Action:"DescribeReceiptRuleSet",Version:"2010-12-01",RuleSetName:e})}),r=t?.DescribeReceiptRuleSetResponse?.DescribeReceiptRuleSetResult||t?.DescribeReceiptRuleSetResult,a=r?.Rules?.member;return{Metadata:r?.Metadata,Rules:Array.isArray(a)?a:a?[a]:[]}}async createReceiptRule(e){let t={Action:"CreateReceiptRule",Version:"2010-12-01",RuleSetName:e.RuleSetName,"Rule.Name":e.Rule.Name,"Rule.Enabled":e.Rule.Enabled!==!1?"true":"false"};if(e.Rule.TlsPolicy)t["Rule.TlsPolicy"]=e.Rule.TlsPolicy;if(e.Rule.ScanEnabled!==void 0)t["Rule.ScanEnabled"]=e.Rule.ScanEnabled?"true":"false";if(e.After)t.After=e.After;if(e.Rule.Recipients)e.Rule.Recipients.forEach((r,a)=>{t[`Rule.Recipients.member.${a+1}`]=r});e.Rule.Actions.forEach((r,a)=>{let i=a+1;if(r.S3Action){if(t[`Rule.Actions.member.${i}.S3Action.BucketName`]=r.S3Action.BucketName,r.S3Action.ObjectKeyPrefix)t[`Rule.Actions.member.${i}.S3Action.ObjectKeyPrefix`]=r.S3Action.ObjectKeyPrefix;if(r.S3Action.KmsKeyArn)t[`Rule.Actions.member.${i}.S3Action.KmsKeyArn`]=r.S3Action.KmsKeyArn}if(r.LambdaAction)t[`Rule.Actions.member.${i}.LambdaAction.FunctionArn`]=r.LambdaAction.FunctionArn,t[`Rule.Actions.member.${i}.LambdaAction.InvocationType`]=r.LambdaAction.InvocationType||"Event";if(r.SNSAction){if(t[`Rule.Actions.member.${i}.SNSAction.TopicArn`]=r.SNSAction.TopicArn,r.SNSAction.Encoding)t[`Rule.Actions.member.${i}.SNSAction.Encoding`]=r.SNSAction.Encoding}if(r.StopAction){if(t[`Rule.Actions.member.${i}.StopAction.Scope`]=r.StopAction.Scope,r.StopAction.TopicArn)t[`Rule.Actions.member.${i}.StopAction.TopicArn`]=r.StopAction.TopicArn}}),await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody(t)})}async deleteReceiptRule(e,t){await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody({Action:"DeleteReceiptRule",Version:"2010-12-01",RuleSetName:e,RuleName:t})})}async receiptRuleSetExists(e){try{return await this.describeReceiptRuleSet(e),!0}catch(t){if(t.code==="RuleSetDoesNotExist"||t.statusCode===400)return!1;throw t}}async getActiveReceiptRuleSet(){let e=await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody({Action:"DescribeActiveReceiptRuleSet",Version:"2010-12-01"})}),t=e?.DescribeActiveReceiptRuleSetResponse?.DescribeActiveReceiptRuleSetResult||e?.DescribeActiveReceiptRuleSetResult;if(!t?.Metadata)return null;let r=t?.Rules?.member;return{Metadata:t?.Metadata,Rules:Array.isArray(r)?r:r?[r]:[]}}async updateReceiptRule(e){let t={Action:"UpdateReceiptRule",Version:"2010-12-01",RuleSetName:e.RuleSetName,"Rule.Name":e.Rule.Name};if(e.Rule.Enabled!==void 0)t["Rule.Enabled"]=e.Rule.Enabled?"true":"false";if(e.Rule.TlsPolicy)t["Rule.TlsPolicy"]=e.Rule.TlsPolicy;if(e.Rule.ScanEnabled!==void 0)t["Rule.ScanEnabled"]=e.Rule.ScanEnabled?"true":"false";if(e.Rule.Recipients)e.Rule.Recipients.forEach((r,a)=>{t[`Rule.Recipients.member.${a+1}`]=r});e.Rule.Actions.forEach((r,a)=>{let i=a+1;if(r.S3Action){if(t[`Rule.Actions.member.${i}.S3Action.BucketName`]=r.S3Action.BucketName,r.S3Action.ObjectKeyPrefix)t[`Rule.Actions.member.${i}.S3Action.ObjectKeyPrefix`]=r.S3Action.ObjectKeyPrefix;if(r.S3Action.KmsKeyArn)t[`Rule.Actions.member.${i}.S3Action.KmsKeyArn`]=r.S3Action.KmsKeyArn}if(r.LambdaAction)t[`Rule.Actions.member.${i}.LambdaAction.FunctionArn`]=r.LambdaAction.FunctionArn,t[`Rule.Actions.member.${i}.LambdaAction.InvocationType`]=r.LambdaAction.InvocationType||"Event";if(r.SNSAction){if(t[`Rule.Actions.member.${i}.SNSAction.TopicArn`]=r.SNSAction.TopicArn,r.SNSAction.Encoding)t[`Rule.Actions.member.${i}.SNSAction.Encoding`]=r.SNSAction.Encoding}if(r.StopAction){if(t[`Rule.Actions.member.${i}.StopAction.Scope`]=r.StopAction.Scope,r.StopAction.TopicArn)t[`Rule.Actions.member.${i}.StopAction.TopicArn`]=r.StopAction.TopicArn}}),await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody(t)})}async sendRawEmail(e){let t=Buffer.from(e.rawMessage).toString("base64"),r={Action:"SendRawEmail",Version:"2010-12-01",Source:e.source,"RawMessage.Data":t};e.destinations.forEach((n,o)=>{r[`Destinations.member.${o+1}`]=n});let a=await this.client.request({service:"ses",region:this.region,method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:this.buildFormBody(r)});return{MessageId:(a?.SendRawEmailResponse?.SendRawEmailResult||a?.SendRawEmailResult)?.MessageId}}async getSuppressedDestination(e){try{return(await this.client.request({service:"ses",region:this.region,method:"GET",path:`/v2/email/suppression/addresses/${encodeURIComponent(e)}`}))?.SuppressedDestination||null}catch(t){if(t.message?.includes("404")||t.message?.includes("NotFoundException"))return null;throw t}}async deleteSuppressedDestination(e){await this.client.request({service:"ses",region:this.region,method:"DELETE",path:`/v2/email/suppression/addresses/${encodeURIComponent(e)}`})}}class pc{ses;s3;iam;route53;region;domain;defaultFrom;constructor(e={}){this.region=e.region||"us-east-1",this.domain=e.domain,this.defaultFrom=e.defaultFrom,this.ses=new be(this.region),this.s3=new g(this.region),this.iam=new Z(this.region),this.route53=new U(this.region)}async send(e){let t=e.from||this.defaultFrom;if(!t)throw Error("From address is required. Set defaultFrom in constructor or provide from in options.");let r=e.fromName?`${e.fromName} <${t}>`:t,a=Array.isArray(e.to)?e.to:[e.to];if(!e.attachments||e.attachments.length===0)return{messageId:(await this.ses.sendSimpleEmail({from:r,to:a,subject:e.subject,text:e.text,html:e.html,replyTo:e.replyTo})).MessageId||""};let i=this.buildRawEmail(e,r,a);return{messageId:(await this.ses.sendEmail({FromEmailAddress:r,Destination:{ToAddresses:a,CcAddresses:e.cc?Array.isArray(e.cc)?e.cc:[e.cc]:void 0,BccAddresses:e.bcc?Array.isArray(e.bcc)?e.bcc:[e.bcc]:void 0},Content:{Raw:{Data:Buffer.from(i).toString("base64")}}})).MessageId||""}}async sendTemplate(e){let t=e.from||this.defaultFrom;if(!t)throw Error("From address is required");let r=e.fromName?`${e.fromName} <${t}>`:t;return{messageId:(await this.ses.sendTemplatedEmail({from:r,to:e.to,templateName:e.templateName,templateData:e.templateData,replyTo:e.replyTo})).MessageId||""}}async sendBulk(e){let t=e.from||this.defaultFrom;if(!t)throw Error("From address is required");let r=e.recipients.map((i)=>({Destination:{ToAddresses:Array.isArray(i.to)?i.to:[i.to]},ReplacementEmailContent:i.templateData?{ReplacementTemplate:{ReplacementTemplateData:JSON.stringify(i.templateData)}}:void 0}));return{results:(await this.ses.sendBulkEmail({FromEmailAddress:t,BulkEmailEntries:r,DefaultContent:{Template:{TemplateName:e.templateName,TemplateData:JSON.stringify(e.defaultTemplateData)}}})).BulkEmailEntryResults?.map((i)=>({status:i.Status||"UNKNOWN",messageId:i.MessageId,error:i.Error}))||[]}}async setupDomain(e){let t;try{t=await this.ses.getEmailIdentity(e)}catch{let a=await this.ses.createEmailIdentity({EmailIdentity:e});t={VerificationStatus:a.DkimAttributes?.Status,DkimAttributes:a.DkimAttributes,SendingEnabled:a.VerifiedForSendingStatus}}try{await this.ses.putEmailIdentityDkimAttributes({EmailIdentity:e,SigningEnabled:!0})}catch{}try{await this.ses.putEmailIdentityMailFromAttributes(e,{MailFromDomain:`mail.${e}`,BehaviorOnMxFailure:"USE_DEFAULT_VALUE"})}catch{}let r=await this.ses.getDkimRecords(e);return{domainVerified:t.SendingEnabled===!0,dkimStatus:t.DkimAttributes?.Status||"UNKNOWN",dkimTokens:t.DkimAttributes?.Tokens,mailFromStatus:t.MailFromAttributes?.MailFromDomainStatus}}async getDnsRecords(e){let t=[],r=await this.ses.getDkimRecords(e);for(let a of r)t.push({type:a.type,name:a.name,value:a.value,ttl:1800});return t.push({type:"MX",name:e,value:`inbound-smtp.${this.region}.amazonaws.com`,priority:10,ttl:3600}),t.push({type:"MX",name:`mail.${e}`,value:`feedback-smtp.${this.region}.amazonses.com`,priority:10,ttl:3600}),t.push({type:"TXT",name:`mail.${e}`,value:"v=spf1 include:amazonses.com ~all",ttl:3600}),t.push({type:"TXT",name:`_dmarc.${e}`,value:`v=DMARC1;p=quarantine;pct=25;rua=mailto:dmarcreports@${e}`,ttl:3600}),t}async isDomainReady(e){try{let t=await this.ses.getEmailIdentity(e);return t.SendingEnabled===!0&&t.DkimAttributes?.Status==="SUCCESS"}catch{return!1}}async setupReceiving(e){let t={Version:"2012-10-17",Statement:[{Sid:"AllowSESPuts",Effect:"Allow",Principal:{Service:"ses.amazonaws.com"},Action:"s3:PutObject",Resource:`arn:aws:s3:::${e.bucketName}/*`,Condition:{StringEquals:{"AWS:SourceAccount":e.accountId}}}]};await this.s3.putBucketPolicy(e.bucketName,t);try{await this.ses.createReceiptRuleSet(e.ruleSetName)}catch(a){if(!a.message?.includes("already exists")&&a.code!=="AlreadyExists")throw a}let r=[{S3Action:{BucketName:e.bucketName,ObjectKeyPrefix:e.prefix||"inbox/"}}];if(e.lambdaArn)r.push({LambdaAction:{FunctionArn:e.lambdaArn,InvocationType:"Event"}});try{await this.ses.createReceiptRule({RuleSetName:e.ruleSetName,Rule:{Name:e.ruleName,Enabled:!0,TlsPolicy:"Optional",Recipients:e.recipients||[e.domain],ScanEnabled:e.scanEnabled!==!1,Actions:r}})}catch(a){if(a.message?.includes("already exists"))await this.ses.deleteReceiptRule(e.ruleSetName,e.ruleName),await this.ses.createReceiptRule({RuleSetName:e.ruleSetName,Rule:{Name:e.ruleName,Enabled:!0,TlsPolicy:"Optional",Recipients:e.recipients||[e.domain],ScanEnabled:e.scanEnabled!==!1,Actions:r}});else throw a}await this.ses.setActiveReceiptRuleSet(e.ruleSetName)}async getIncomingEmails(e){return(await this.s3.list({bucket:e.bucket,prefix:e.prefix||"incoming/",maxKeys:e.maxResults||100})).map((r)=>({key:r.Key||"",lastModified:r.LastModified||"",size:r.Size||0}))}async readEmail(e){return await this.s3.getObject(e.bucket,e.key)}async createSmtpCredentials(e){let t=`ses-smtp-${e.username.replace(/[^a-zA-Z0-9]/g,"-")}`,{AWSClient:r}=await import("./chunk-hwqvx1zb.js"),a=new r,i=(d,y)=>{let P={Action:d,Version:"2010-05-08",...y};return Object.entries(P).map(([A,h])=>`${encodeURIComponent(A)}=${encodeURIComponent(h)}`).join("&")};try{await a.request({service:"iam",region:"us-east-1",method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i("CreateUser",{UserName:t})})}catch(d){if(!d.message?.includes("EntityAlreadyExists"))throw d}let n={Version:"2012-10-17",Statement:[{Effect:"Allow",Action:"ses:SendRawEmail",Resource:"*",Condition:{StringLike:{"ses:FromAddress":`*@${e.domain}`}}}]},o=`ses-smtp-policy-${e.domain.replace(/\./g,"-")}`;try{await a.request({service:"iam",region:"us-east-1",method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i("PutUserPolicy",{UserName:t,PolicyName:o,PolicyDocument:JSON.stringify(n)})})}catch{}let l=(await a.request({service:"iam",region:"us-east-1",method:"POST",path:"/",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:i("CreateAccessKey",{UserName:t})}))?.CreateAccessKeyResult?.AccessKey;if(!l?.AccessKeyId||!l?.SecretAccessKey)throw Error("Failed to create access key");let p=this.deriveSmtpPassword(l.SecretAccessKey);return{username:l.AccessKeyId,password:p,server:`email-smtp.${this.region}.amazonaws.com`,port:587}}deriveSmtpPassword(e){let t=mi("node:crypto"),r="SendRawEmail",a=Buffer.from([4]),i=t.createHmac("sha256",`AWS4${e}`).update("11111111").digest();return i=t.createHmac("sha256",i).update(this.region).digest(),i=t.createHmac("sha256",i).update("ses").digest(),i=t.createHmac("sha256",i).update("aws4_request").digest(),i=t.createHmac("sha256",i).update("SendRawEmail").digest(),Buffer.concat([a,i]).toString("base64")}async createTemplate(e){await this.ses.createEmailTemplate({TemplateName:e.name,TemplateContent:{Subject:e.subject,Text:e.text,Html:e.html}})}async getTemplate(e){try{let t=await this.ses.getEmailTemplate(e);return{name:t.TemplateName||e,subject:t.TemplateContent?.Subject,text:t.TemplateContent?.Text,html:t.TemplateContent?.Html}}catch{return null}}async deleteTemplate(e){await this.ses.deleteEmailTemplate(e)}async listTemplates(){return(await this.ses.listEmailTemplates()).TemplatesMetadata?.map((t)=>({name:t.TemplateName||"",createdAt:t.CreatedTimestamp}))||[]}async deploy(e){let t=`${e.appName}-${e.environment}-email-rules`,r=`${e.appName}-inbound-email`,a=e.storage?.bucketName||`${e.appName}-${e.environment}-email`,i=await this.setupDomain(e.domain);if(!(await this.s3.listBuckets()).Buckets?.some((l)=>l.Name===a))await this.s3.createBucket(a);await this.setupReceiving({domain:e.domain,ruleSetName:t,ruleName:r,bucketName:a,prefix:e.storage?.prefix||"inbox/",accountId:e.accountId,recipients:e.catchAll?[e.domain]:e.mailboxes,scanEnabled:!0});let m=await this.getDnsRecords(e.domain);return{success:!0,domainVerified:i.domainVerified,dkimStatus:i.dkimStatus,receiptRuleSet:t,storageBucket:a,dnsRecords:m}}async undeploy(e){let t=`${e.appName}-${e.environment}-email-rules`,r=`${e.appName}-inbound-email`,a=`${e.appName}-${e.environment}-email`;try{await this.ses.deleteReceiptRule(t,r)}catch{}try{await this.ses.deleteReceiptRuleSet(t)}catch{}if(e.deleteBucket)try{await this.s3.emptyAndDeleteBucket(a)}catch{}}async getSendingStats(){let e=await this.ses.getSendQuota();return{sentLast24Hours:e.SentLast24Hours||0,maxSendRate:e.MaxSendRate||0,max24HourSend:e.Max24HourSend||0}}buildRawEmail(e,t,r){let a=`----=_Part_${Date.now()}_${Math.random().toString(36).substring(2)}`,i="";if(i+=`From: ${t}\r
|
|
2
|
+
`,i+=`To: ${r.join(", ")}\r
|
|
3
|
+
`,e.cc){let n=Array.isArray(e.cc)?e.cc:[e.cc];i+=`Cc: ${n.join(", ")}\r
|
|
4
|
+
`}if(i+=`Subject: ${e.subject}\r
|
|
5
|
+
`,i+=`MIME-Version: 1.0\r
|
|
6
|
+
`,i+=`Content-Type: multipart/mixed; boundary="${a}"\r
|
|
7
|
+
`,i+=`\r
|
|
8
|
+
`,e.text||e.html)if(i+=`--${a}\r
|
|
9
|
+
`,e.html&&e.text){let n=`----=_Alt_${Date.now()}`;i+=`Content-Type: multipart/alternative; boundary="${n}"\r
|
|
10
|
+
`,i+=`\r
|
|
11
|
+
`,i+=`--${n}\r
|
|
12
|
+
`,i+=`Content-Type: text/plain; charset="UTF-8"\r
|
|
13
|
+
`,i+=`\r
|
|
14
|
+
`,i+=`${e.text}\r
|
|
15
|
+
`,i+=`--${n}\r
|
|
16
|
+
`,i+=`Content-Type: text/html; charset="UTF-8"\r
|
|
17
|
+
`,i+=`\r
|
|
18
|
+
`,i+=`${e.html}\r
|
|
19
|
+
`,i+=`--${n}--\r
|
|
20
|
+
`}else if(e.html)i+=`Content-Type: text/html; charset="UTF-8"\r
|
|
21
|
+
`,i+=`\r
|
|
22
|
+
`,i+=`${e.html}\r
|
|
23
|
+
`;else i+=`Content-Type: text/plain; charset="UTF-8"\r
|
|
24
|
+
`,i+=`\r
|
|
25
|
+
`,i+=`${e.text}\r
|
|
26
|
+
`;if(e.attachments)for(let n of e.attachments)i+=`--${a}\r
|
|
27
|
+
`,i+=`Content-Type: ${n.contentType||"application/octet-stream"}; name="${n.filename}"\r
|
|
28
|
+
`,i+=`Content-Transfer-Encoding: base64\r
|
|
29
|
+
`,i+=`Content-Disposition: attachment; filename="${n.filename}"\r
|
|
30
|
+
`,i+=`\r
|
|
31
|
+
`,i+=`${n.content}\r
|
|
32
|
+
`;return i+=`--${a}--\r
|
|
33
|
+
`,i}}var hp=new pc;
|
|
34
|
+
export{Z,be,pc,hp};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var
|
|
1
|
+
var Sd={newConnectionsPerSecond:50,concurrentPerSource:100,synPerSecond:2000,burst:100,icmpPerSecond:5,banSeconds:600};function h(e){return{...Sd,...e.thresholds}}var _=/^(?:\d{1,3}\.){3}\d{1,3}(?:\/\d{1,2})?$|^[0-9a-f:]+(?:\/\d{1,3})?$/i;function Yi(e){if(!_.test(e))return!1;let[t,n]=e.split("/");if(t.includes(":"))return n==null||Number(n)>=0&&Number(n)<=128;let s=t.split(".");if(s.length!==4||s.some((a)=>Number(a)>255||a===""))return!1;return n==null||Number(n)>=0&&Number(n)<=32}function f(e){return[...new Set((e??[]).map((t)=>t.trim()).filter(Yi))]}function y(e){let t=(e??[80,443]).filter((n)=>Number.isInteger(n)&&n>=1&&n<=65535);return[...new Set(t)].sort((n,s)=>n-s)}function bd(e={}){let t=h(e);return{"net.ipv4.tcp_syncookies":"1","net.ipv4.tcp_max_syn_backlog":String(Math.max(4096,t.synPerSecond*4)),"net.ipv4.tcp_synack_retries":"2","net.ipv4.tcp_abort_on_overflow":"1","net.ipv4.tcp_fin_timeout":"15","net.ipv4.tcp_keepalive_time":"300","net.ipv4.tcp_keepalive_intvl":"30","net.ipv4.tcp_keepalive_probes":"3","net.core.somaxconn":"4096","net.core.netdev_max_backlog":"16384","net.ipv4.conf.all.rp_filter":"1","net.ipv4.conf.default.rp_filter":"1","net.ipv4.conf.all.accept_source_route":"0","net.ipv4.conf.all.accept_redirects":"0","net.ipv4.conf.all.send_redirects":"0","net.ipv6.conf.all.accept_redirects":"0","net.ipv6.conf.all.accept_source_route":"0","net.ipv4.icmp_echo_ignore_broadcasts":"1","net.ipv4.icmp_ignore_bogus_error_responses":"1","net.netfilter.nf_conntrack_max":"262144","net.netfilter.nf_conntrack_tcp_timeout_established":"3600"}}function vd(e={}){let t=["# Managed by ts-cloud. Edits are overwritten on the next deploy.","# Network hardening against L3/L4 floods.",""];for(let[n,s]of Object.entries(bd(e)))t.push(`${n} = ${s}`);return`${t.join(`
|
|
2
2
|
`)}
|
|
3
|
-
`}function
|
|
4
|
-
`)}function
|
|
3
|
+
`}function Td(e={}){let t=h(e),n=y(e.ports),s=f(e.allowlist),a=f(e.blocklist),l=e.monitorOnly?"counter":"counter drop",i=e.originProtection?.enabled?f(e.originProtection.cdnRanges):[],c=s.filter((r)=>!r.includes(":")),p=s.filter((r)=>r.includes(":")),u=a.filter((r)=>!r.includes(":")),o=["#!/usr/sbin/nft -f","# Managed by ts-cloud. Edits are overwritten on the next deploy.","","table inet ts_cloud_ddos","delete table inet ts_cloud_ddos","","table inet ts_cloud_ddos {"," # Sources that tripped a limit, with a timeout so a ban self-expires.",` set banned4 { type ipv4_addr; flags timeout; timeout ${t.banSeconds}s; }`,` set banned6 { type ipv6_addr; flags timeout; timeout ${t.banSeconds}s; }`];if(c.length>0)o.push(` set allow4 { type ipv4_addr; flags interval; elements = { ${c.join(", ")} } }`);if(p.length>0)o.push(` set allow6 { type ipv6_addr; flags interval; elements = { ${p.join(", ")} } }`);if(u.length>0)o.push(` set block4 { type ipv4_addr; flags interval; elements = { ${u.join(", ")} } }`);if(i.length>0)o.push(` set cdn4 { type ipv4_addr; flags interval; elements = { ${i.filter((r)=>!r.includes(":")).join(", ")} } }`);if(o.push(""," chain input {"," type filter hook input priority -150; policy accept;",""," # Established traffic is already paid for; never re-inspect it."," ct state established,related accept"," iif lo accept",""," # Invalid packets are never legitimate and are cheap to drop early."," ct state invalid counter drop"),c.length>0)o.push(" ip saddr @allow4 accept");if(p.length>0)o.push(" ip6 saddr @allow6 accept");if(u.length>0)o.push(" ip saddr @block4 counter drop");if(o.push(" ip saddr @banned4 counter drop"," ip6 saddr @banned6 counter drop",""),o.push(" # Nonsense TCP flag combinations: scanners and stack fingerprinting."," tcp flags & (fin|syn) == (fin|syn) counter drop"," tcp flags & (syn|rst) == (syn|rst) counter drop"," tcp flags & (fin|rst) == (fin|rst) counter drop"," tcp flags & (fin|ack) == fin counter drop"," tcp flags & (syn|fin|ack|rst|psh|urg) == 0x0 counter drop",""," # Ping stays usable, ping floods do not.",` ip protocol icmp icmp type echo-request limit rate ${t.icmpPerSecond}/second burst ${t.burst} packets accept`," ip protocol icmp icmp type echo-request counter drop",""),n.length>0){let r=n.join(", ");if(o.push(" # Platform-wide SYN ceiling. Above it the kernel falls back to cookies.",` tcp dport { ${r} } ct state new limit rate ${t.synPerSecond}/second burst ${t.burst} packets accept`,""," # Per-source new-connection rate. This is what stops one host hammering.",` tcp dport { ${r} } ct state new meter conn_rate4 { ip saddr limit rate over ${t.newConnectionsPerSecond}/second burst ${t.burst} packets } add @banned4 { ip saddr } ${l}`,` tcp dport { ${r} } ct state new meter conn_rate6 { ip6 saddr limit rate over ${t.newConnectionsPerSecond}/second burst ${t.burst} packets } add @banned6 { ip6 saddr } ${l}`,""," # Concurrency ceiling per source: the slow-loris defence.",` tcp dport { ${r} } ct state new meter conn_count4 { ip saddr ct count over ${t.concurrentPerSource} } ${l}`,` tcp dport { ${r} } ct state new meter conn_count6 { ip6 saddr ct count over ${t.concurrentPerSource} } ${l}`,""),i.length>0)o.push(" # Origin protection: reject traffic that skipped the CDN and came"," # straight to the box, which is how an attacker bypasses the edge.",` tcp dport { ${r} } ip saddr != @cdn4 counter drop`,"")}return o.push(" }","}",""),o.join(`
|
|
4
|
+
`)}function yr(e={}){return`#!/usr/bin/env bash
|
|
5
5
|
# Managed by ts-cloud. Installs L3/L4 flood mitigation.
|
|
6
6
|
set -euo pipefail
|
|
7
7
|
|
|
@@ -13,11 +13,11 @@ fi
|
|
|
13
13
|
|
|
14
14
|
install -d -m 0755 /etc/ts-cloud /etc/nftables.d
|
|
15
15
|
cat > /etc/sysctl.d/90-ts-cloud-ddos.conf <<'SYSCTL_EOF'
|
|
16
|
-
${
|
|
16
|
+
${vd(e)}SYSCTL_EOF
|
|
17
17
|
sysctl --system >/dev/null
|
|
18
18
|
|
|
19
19
|
cat > /etc/nftables.d/ts-cloud-ddos.nft.new <<'NFT_EOF'
|
|
20
|
-
${
|
|
20
|
+
${Td(e)}NFT_EOF
|
|
21
21
|
|
|
22
22
|
# Syntax-check before applying: a bad ruleset would leave the box unprotected.
|
|
23
23
|
if ! nft -c -f /etc/nftables.d/ts-cloud-ddos.nft.new; then
|
|
@@ -40,5 +40,5 @@ include "/etc/nftables.d/ts-cloud-ddos.nft"
|
|
|
40
40
|
fi
|
|
41
41
|
systemctl enable nftables >/dev/null 2>&1 || true
|
|
42
42
|
echo "ts-cloud: L3/L4 mitigation active"
|
|
43
|
-
`}var b=["off","monitor","rate_limit","challenge","lockdown"];function
|
|
44
|
-
export{
|
|
43
|
+
`}var b=["off","monitor","rate_limit","challenge","lockdown"];function cp(e,t=[]){let n=[],s=Math.max(1,e.baselineRequestsPerSecond),a=e.requestsPerSecond/s,l=0,i=(g,v)=>{n.push(v),l=Math.max(l,b.indexOf(g))},c=a>=3;if(c)i("monitor",`Traffic is ${a.toFixed(1)}x the baseline.`);let p=e.topSourceShare>=0.25,u=e.errorRate>=0.25,o=(e.suspiciousAgentShare??0)>=0.5,r=e.uniqueSources>0&&e.requestsPerSecond/e.uniqueSources>=50;if(c&&p)i("rate_limit",`One source accounts for ${(e.topSourceShare*100).toFixed(0)}% of traffic.`);if(c&&r)i("rate_limit","Request rate per unique source is far above what a browser produces.");if(c&&u)i("challenge",`Error rate is ${(e.errorRate*100).toFixed(0)}% under load.`);if(c&&o)i("challenge","Most requests carry no recognisable browser agent.");if(a>=20&&(p||u||o||r))i("lockdown",`Traffic is ${a.toFixed(0)}x the baseline with attack-shaped characteristics.`);if(!c&&e.topSourceShare>=0.6&&e.requestsPerSecond>s)i("rate_limit","A single source dominates traffic without an overall surge.");let d=b[l],m={off:1,monitor:1,rate_limit:0.5,challenge:0.25,lockdown:0.1}[d];return{level:d,reasons:n,rateLimitFactor:m,challengeEnabled:d==="challenge"||d==="lockdown",staticOnly:d==="lockdown",banCandidates:d==="off"||d==="monitor"?[]:f(t)}}function Zi(e,t){return Math.max(1,Math.floor(e*t.rateLimitFactor))}
|
|
44
|
+
export{Sd,Yi,bd,vd,Td,yr,cp,Zi};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j}from"./chunk-rpfvv7hw.js";import"./chunk-q3xwh0r8.js";export{j as SQSClient};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{Ne,Ys,Co,pa,ln,Lo,ma,ga,va,Ta}from"./chunk-24njmb7d.js";import{n,r,a,e,p,i,ye}from"./chunk-k97ms0bs.js";import{u}from"./chunk-mbqwrs7a.js";import{v}from"./chunk-87f5d9qj.js";import{R}from"./chunk-5bsknbr7.js";import{g}from"./chunk-7xr71hnt.js";import{existsSync as de,readdirSync as me,readFileSync as pe,statSync as fe}from"node:fs";import{join as ne,relative as Se}from"node:path";class W{client;region;constructor(t="us-east-1",s){this.region=t,this.client=new u}async createSecret(t){let s={Name:t.Name};if(t.Description)s.Description=t.Description;if(t.KmsKeyId)s.KmsKeyId=t.KmsKeyId;if(t.SecretBinary)s.SecretBinary=t.SecretBinary;if(t.SecretString)s.SecretString=t.SecretString;if(t.Tags&&t.Tags.length>0)s.Tags=t.Tags;if(t.AddReplicaRegions&&t.AddReplicaRegions.length>0)s.AddReplicaRegions=t.AddReplicaRegions;if(t.ForceOverwriteReplicaSecret!==void 0)s.ForceOverwriteReplicaSecret=t.ForceOverwriteReplicaSecret;s.ClientRequestToken=t.ClientRequestToken||crypto.randomUUID();let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.CreateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId,ReplicationStatus:o.ReplicationStatus}}async updateSecret(t){let s={SecretId:t.SecretId,ClientRequestToken:t.ClientRequestToken||crypto.randomUUID()};if(t.Description)s.Description=t.Description;if(t.KmsKeyId)s.KmsKeyId=t.KmsKeyId;if(t.SecretBinary)s.SecretBinary=t.SecretBinary;if(t.SecretString)s.SecretString=t.SecretString;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.UpdateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId}}async putSecretValue(t){let s={SecretId:t.SecretId};if(t.SecretBinary)s.SecretBinary=t.SecretBinary;if(t.SecretString)s.SecretString=t.SecretString;if(t.VersionStages&&t.VersionStages.length>0)s.VersionStages=t.VersionStages;s.ClientRequestToken=t.ClientRequestToken||crypto.randomUUID();let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.PutSecretValue","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId,VersionStages:o.VersionStages}}async getSecretValue(t){let s={SecretId:t.SecretId};if(t.VersionId)s.VersionId=t.VersionId;if(t.VersionStage)s.VersionStage=t.VersionStage;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.GetSecretValue","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId,SecretBinary:o.SecretBinary,SecretString:o.SecretString,VersionStages:o.VersionStages,CreatedDate:o.CreatedDate}}async describeSecret(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DescribeSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return this.parseSecret(o)}async listSecrets(t){let s={};if(t?.MaxResults)s.MaxResults=t.MaxResults;if(t?.NextToken)s.NextToken=t.NextToken;if(t?.Filters&&t.Filters.length>0)s.Filters=t.Filters;if(t?.SortOrder)s.SortOrder=t.SortOrder;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.ListSecrets","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{SecretList:o.SecretList?.map((c)=>this.parseSecret(c)),NextToken:o.NextToken}}async deleteSecret(t){let s={SecretId:t.SecretId};if(t.RecoveryWindowInDays!==void 0)s.RecoveryWindowInDays=t.RecoveryWindowInDays;if(t.ForceDeleteWithoutRecovery!==void 0)s.ForceDeleteWithoutRecovery=t.ForceDeleteWithoutRecovery;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DeleteSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,DeletionDate:o.DeletionDate}}async restoreSecret(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.RestoreSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async rotateSecret(t){let s={SecretId:t.SecretId};if(t.ClientRequestToken)s.ClientRequestToken=t.ClientRequestToken;if(t.RotationLambdaARN)s.RotationLambdaARN=t.RotationLambdaARN;if(t.RotationRules)s.RotationRules=t.RotationRules;if(t.RotateImmediately!==void 0)s.RotateImmediately=t.RotateImmediately;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.RotateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId}}async cancelRotateSecret(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.CancelRotateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async getResourcePolicy(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.GetResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,ResourcePolicy:o.ResourcePolicy}}async putResourcePolicy(t){let s={SecretId:t.SecretId,ResourcePolicy:t.ResourcePolicy};if(t.BlockPublicPolicy!==void 0)s.BlockPublicPolicy=t.BlockPublicPolicy;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.PutResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async deleteResourcePolicy(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DeleteResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async tagResource(t){let s={SecretId:t.SecretId,Tags:t.Tags};await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.TagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)})}async untagResource(t){let s={SecretId:t.SecretId,TagKeys:t.TagKeys};await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.UntagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)})}async setString(t,s,o){try{let c=await this.putSecretValue({SecretId:t,SecretString:s});return{ARN:c.ARN,VersionId:c.VersionId}}catch(c){if(c.code==="ResourceNotFoundException"){let l=await this.createSecret({Name:t,SecretString:s,Description:o?.description,KmsKeyId:o?.kmsKeyId,Tags:o?.tags});return{ARN:l.ARN,VersionId:l.VersionId}}throw c}}async setJson(t,s,o){return this.setString(t,JSON.stringify(s),o)}async getString(t){return(await this.getSecretValue({SecretId:t})).SecretString}async getJson(t){let s=await this.getString(t);if(s)return JSON.parse(s);return}async listAll(){let t=[],s;do{let o=await this.listSecrets({NextToken:s});if(o.SecretList)t.push(...o.SecretList);s=o.NextToken}while(s);return t}parseSecret(t){return{ARN:t.ARN,Name:t.Name,Description:t.Description,KmsKeyId:t.KmsKeyId,RotationEnabled:t.RotationEnabled,RotationLambdaARN:t.RotationLambdaARN,RotationRules:t.RotationRules,LastRotatedDate:t.LastRotatedDate,LastChangedDate:t.LastChangedDate,LastAccessedDate:t.LastAccessedDate,DeletedDate:t.DeletedDate,NextRotationDate:t.NextRotationDate,Tags:t.Tags,SecretVersionsToStages:t.SecretVersionsToStages,CreatedDate:t.CreatedDate,PrimaryRegion:t.PrimaryRegion}}}function E(t,s){let o=t.environments?.[s]?.app;if(!o)throw Error(`No serverless app configured for environment '${s}'. Add environments.${s}.app to your config.`);let c=t.project.slug,l=t.environments?.[s]?.region||t.project.region||"us-east-1";return{app:o,slug:c,region:l,stackName:Ne(t,s),artifactBucket:Ys(c,s),assetsBucket:Co(c,s)}}function ht(t,s){let o=E(t,s),c=`${o.slug}-${s}`;return{region:o.region,slug:o.slug,stackName:o.stackName,functions:{http:`${c}-http`,queue:`${c}-queue`,cli:`${c}-cli`}}}async function L(t,s=8){let o;for(let c=0;c<s;c++)try{return await t()}catch(l){let d=l?.code||l?.name||"",m=String(l?.message||"");if(d==="ResourceConflictException"||/update is in progress|currently in the following state/i.test(m)){o=l,await new Promise((f)=>setTimeout(f,3000));continue}throw l}throw o}var ie=(t,s)=>`releases/${t}/${s}/current.json`;async function G(t,s,o,c){try{return await t.getObjectJson(s,ie(o,c))}catch{return null}}async function ae(t,s,o,c,l){await t.putObjectJson(s,ie(o,c),l)}async function Re(t,s){if(!t.secrets)return{};let o=new W(s),c={},l=Array.isArray(t.secrets)?t.secrets.map((d)=>({envName:d.split("/").pop().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),secretId:d})):Object.entries(t.secrets).map(([d,m])=>({envName:d,secretId:m}));if(Array.isArray(t.secrets)){let d=new Map;for(let{envName:f,secretId:S}of l)d.set(f,[...d.get(f)??[],S]);let m=[...d.entries()].filter(([,f])=>f.length>1);if(m.length){let f=m.map(([S,h])=>`${S} ← ${h.join(", ")}`).join("; ");throw Error(`serverless secrets: multiple secrets map to the same env var (${f}). Use the map form { ENV_NAME: 'secret/id' } to disambiguate.`)}}for(let{envName:d,secretId:m}of l){let S=(await o.getSecretValue({SecretId:m})).SecretString??"";try{let h=JSON.parse(S);if(h&&typeof h==="object"&&!Array.isArray(h)){for(let[C,w]of Object.entries(h))c[C]=String(w);continue}}catch{}c[d]=S}return c}function Ed(t,s){let o={},c=s.DbProxyEndpoint||s.DbEndpoint;if(c)o.DB_CONNECTION="mysql",o.DB_HOST=c,o.DB_PORT="3306",o.DB_DATABASE=o.DB_DATABASE||"app";if(s.CacheEndpoint){if(o.REDIS_HOST=s.CacheEndpoint,o.REDIS_PORT="6379",t.cache?.driver==="elasticache")o.CACHE_STORE="redis",o.CACHE_DRIVER="redis",o.SESSION_DRIVER="redis"}return o}function vs(t,s,o,c,l,d,m,f={}){let S=t.kind==="php"?va({cacheDriver:t.cache?.driver==="elasticache"?"redis":"dynamodb"}):{};return{TSCLOUD_LAMBDA_MODE:c,TSCLOUD_ENV:o,MAINTENANCE_MODE:"0",...t.octane?{TSCLOUD_OCTANE:"1"}:{},...t.serveAssets?{TSCLOUD_SERVE_ASSETS:"1"}:{},...t.redirectRobotsTxt===!1?{TSCLOUD_REDIRECT_ROBOTS_TXT:"0"}:{},...S,...f,...s.app.cache?.driver!=="elasticache"?{TSCLOUD_CACHE_TABLE:`${s.slug}-${o}-cache`}:{},...m?{TSCLOUD_QUEUE:m,SQS_QUEUE:m}:{},...d?{ASSET_URL:d}:{},...t.env??{},...l}}function he(t){let s=t.slice(t.lastIndexOf(".")).toLowerCase();return{".html":"text/html",".css":"text/css",".js":"text/javascript",".mjs":"text/javascript",".json":"application/json",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".txt":"text/plain",".map":"application/json"}[s]??"application/octet-stream"}function*oe(t){for(let s of me(t)){let o=ne(t,s);if(fe(o).isDirectory())yield*oe(o);else yield o}}async function ve(t,s,o,c,l=!1){let d=0;for(let m of oe(o)){let f=Se(o,m).replace(/\\/g,"/");if(!l&&f.split("/").some((S)=>S.startsWith(".")))continue;await t.putObject({bucket:s,key:`${c}/${f}`,body:pe(m),contentType:he(m),cacheControl:"public, max-age=31536000, immutable"}),d++}return d}function lo(t,s){let o=Object.entries(s).reduce((c,[l,d])=>c+Buffer.byteLength(`${l}=${d}`,"utf8"),0);if(o>4096){let c=Object.entries(s).map(([l,d])=>[l,Buffer.byteLength(`${l}=${d}`,"utf8")]).sort((l,d)=>d[1]-l[1]).slice(0,5).map(([l,d])=>`${l} (${d}B)`).join(", ");throw Error(`${t}: environment variables total ${o}B, over AWS's 4096B limit (${o-4096}B too large). Largest: ${c}. Move large/secret values out of env — store them in Secrets Manager and fetch at cold start.`)}}async function U(t,s,o,c){lo(s,o),await L(()=>t.updateFunctionConfiguration({FunctionName:s,Environment:{Variables:o}})),await t.waitForFunctionActive(s,120);let l=c.kind==="image"?{FunctionName:s,ImageUri:c.imageUri}:{FunctionName:s,S3Bucket:c.bucket,S3Key:c.key};await L(()=>t.updateFunctionCode(l)),await t.waitForFunctionActive(s,120)}async function X(t,s){let c=(await L(()=>t.publishVersion({FunctionName:s}))).Version;if(!c)throw Error(`publishVersion returned no version for ${s}`);return await L(()=>t.updateAlias({FunctionName:s,Name:"live",FunctionVersion:c})),c}async function ap(t,s,o={}){let c=E(t,s),{app:l,slug:d,region:m,stackName:f,artifactBucket:S}=c,h=o.projectRoot??process.cwd();i(`Deploying serverless app: ${d} (${s})`),e(`Stack: ${f}`),e(`Region: ${m}`);let C=new g(m),w=new v(m),b=new R(m),P=l.kind==="php",O=l.packaging==="image",N=Lo(l),B,I,k,Y,z=[];if(O&&N.usesLayer&&N.layerKind!=="php")throw Error(`packaging: 'image' currently supports PHP and managed Node runtimes. ${N.kind}${N.kind==="node"?` ${N.version}`:""} uses a custom runtime — `+"use the default zip packaging (the runtime layer is built + attached automatically).");if(O){p("Building + pushing container image");let{buildAndPushServerlessImage:y}=await import("./chunk-27ka240w.js"),A=await y({app:l,projectRoot:h,region:m,repository:`${d}-${s}`,skipBuild:o.skipBuild,onStep:(D)=>e(` ${D}`)});B=A.handlers,I={kind:"image",imageUri:A.imageUri},k=A.tag,z.push({ParameterKey:"ImageUri",ParameterValue:A.imageUri})}else{p("Packaging application");let y=P?Ta({projectRoot:h,app:l,skipBuild:o.skipBuild,onStep:(x)=>e(` ${x}`)}):await ln({projectRoot:h,app:l,skipBuild:o.skipBuild,onStep:(x)=>e(` ${x}`)}),A=pa(d,s,y.sha256);if(e(`Artifact: ${y.sha256.slice(0,12)} (${(y.zip.length/1024).toFixed(0)} KB)`),B=y.handlers,k=y.sha256,N.usesLayer){let x=N.layerEnvVar?process.env[N.layerEnvVar]:void 0;if(Y=l.layers??(x?[x]:void 0),!Y?.length){let ge=N.layerKind==="php"?"serverless:build-php-layer":N.layerKind==="bun"?"serverless:build-bun-layer":"serverless:build-node-layer";throw Error(`${N.kind} apps on provided.al2023 need a runtime layer. Set environments.<env>.app.layers or the ${N.layerEnvVar} env var (build one with \`cloud ${ge}\`)${N.kind==="node"?", or use a managed Node version (18/20/22)":""}.`)}}if(!await C.bucketExists(S))p(`Creating artifact bucket ${S}`),await C.createBucket(S);if(await C.headObject(S,A).then((x)=>x!==null).catch(()=>!1))e("Artifact already uploaded — reusing");else p("Uploading artifact"),await C.putObject({bucket:S,key:A,body:y.zip,contentType:"application/zip"});I={kind:"zip",bucket:S,key:A},z.push({ParameterKey:"ArtifactBucket",ParameterValue:S},{ParameterKey:"ArtifactKey",ParameterValue:A})}let T=ga({config:t,environment:s,app:l,handlers:B,runtimeLayers:Y}),te=JSON.stringify(T.template),re=["CAPABILITY_NAMED_IAM"],K=await w.describeStacks({stackName:f}).then((y)=>y.Stacks[0]?.StackStatus).catch(()=>{return}),M=K!==void 0;if(K&&/DELETE_IN_PROGRESS/.test(K))p("Waiting for an in-progress stack delete to finish"),await w.waitForStack(f,"stack-delete-complete").catch(()=>{}),M=!1;else if(K&&/(?:ROLLBACK_COMPLETE|REVIEW_IN_PROGRESS|CREATE_FAILED)/.test(K))p(`Deleting unusable stack (status ${K}) before recreate`),await w.deleteStack(f),await w.waitForStack(f,"stack-delete-complete").catch(()=>{}),M=!1;p(M?"Updating infrastructure stack":"Creating infrastructure stack");try{if(M)await w.updateStack({stackName:f,templateBody:te,parameters:z,capabilities:re}),await w.waitForStack(f,"stack-update-complete");else await w.createStack({stackName:f,templateBody:te,parameters:z,capabilities:re,onFailure:"DELETE"}),await w.waitForStack(f,"stack-create-complete")}catch(y){if(/No updates are to be performed/i.test(String(y?.message)))e("No infrastructure changes");else throw y}let Q=await w.getStackOutputs(f).catch(()=>({})),F;if(l.assets){let y=ne(h,l.assets);if(de(y)){let A=l.assetDomain||Q.AssetsCdnDomain;F=A?`https://${A}/${k}`:void 0,p(`Syncing assets from ${l.assets}`);let D=await ve(C,c.assetsBucket,y,k,l.dotFilesAsAssets);e(`Uploaded ${D} asset(s)${F?` → ${F}`:""}`)}else a(`Assets directory not found: ${y}`)}p("Resolving secrets");let _=await Re(l,m);if(l.database?.connection==="aurora-serverless")try{let A=await new W(m).getSecretValue({SecretId:`${d}/${s}/db`}),D=JSON.parse(A.SecretString??"{}");if(D.username)_.DB_USERNAME=D.username;if(D.password)_.DB_PASSWORD=D.password}catch(y){a(`Could not resolve Aurora DB credentials: ${y.message}`)}if(!await C.bucketExists(S))await C.createBucket(S);let J=await G(C,S,d,s),q={},Z=T.queueNames[0],ee=Ed(l,Q);if(p("Activating functions"),q.http=vs(l,c,s,"http",_,F,Z,ee),await U(b,T.functionNames.http,q.http,I),q.cli=vs(l,c,s,"cli",_,F,Z,ee),await U(b,T.functionNames.cli,q.cli,I),T.queueNames.length)q.queue=vs(l,c,s,"queue",_,F,Z,ee),await U(b,T.functionNames.queue,q.queue,I);let se=(l.provisionedConcurrency??0)>0,H={};if(se){if(p("Publishing versions + flipping live alias"),H.http=await X(b,T.functionNames.http),H.cli=await X(b,T.functionNames.cli),T.queueNames.length)H.queue=await X(b,T.functionNames.queue)}if(await ae(C,S,d,s,{sha:k,code:I,previousSha:J?.sha,previousCode:J?.code,previousFunctionEnv:J?.functionEnv,...se?{functionVersions:H,previousFunctionVersions:J?.functionVersions}:{},functionEnv:q,functionNames:{http:T.functionNames.http,cli:T.functionNames.cli,...T.queueNames.length?{queue:T.functionNames.queue}:{}},assetUrl:F,timestamp:new Date().toISOString()}),!o.skipDeployHooks&&l.deploy?.length){p("Running deploy hooks");for(let y of l.deploy){e(` deploy: ${y}`);let A=await b.invoke({FunctionName:T.functionNames.cli,InvocationType:"RequestResponse",Payload:{command:y},LogType:"Tail"});if(A.FunctionError)throw r("Deploy hook failed — the new build is ALREADY LIVE."),e(` Roll back with: cloud serverless:rollback --env ${s}`),Error(`Deploy hook failed (${y}): ${A.Payload}`)}}let j=Q.HttpApiEndpoint;if(!o.skipHealthCheck&&j){p("Health check");try{let y=await fetch(j,{method:"GET"});e(`GET ${j} → ${y.status}`)}catch(y){a(`Health check could not reach ${j}: ${y.message}`)}}ye(["Serverless deploy complete","",j?`URL: ${j}`:"",`Stack: ${f}`,`Build: ${k.slice(0,12)}`].filter(Boolean).join(`
|
|
2
|
-
`),"green")}async function
|
|
3
|
-
export{
|
|
1
|
+
import{De,ea,Io,ga,dn,Uo,fa,ha,Ea,wa}from"./chunk-jdfbahjb.js";import{n,r,a,e,p,i,Se}from"./chunk-3jjggqfj.js";import{u}from"./chunk-q3xwh0r8.js";import{v}from"./chunk-9e7pqhj1.js";import{R}from"./chunk-1j9vy88a.js";import{g}from"./chunk-2q27v6vz.js";import{existsSync as de,readdirSync as me,readFileSync as pe,statSync as fe}from"node:fs";import{join as ne,relative as ye}from"node:path";class G{client;region;constructor(t="us-east-1",s){this.region=t,this.client=new u}async createSecret(t){let s={Name:t.Name};if(t.Description)s.Description=t.Description;if(t.KmsKeyId)s.KmsKeyId=t.KmsKeyId;if(t.SecretBinary)s.SecretBinary=t.SecretBinary;if(t.SecretString)s.SecretString=t.SecretString;if(t.Tags&&t.Tags.length>0)s.Tags=t.Tags;if(t.AddReplicaRegions&&t.AddReplicaRegions.length>0)s.AddReplicaRegions=t.AddReplicaRegions;if(t.ForceOverwriteReplicaSecret!==void 0)s.ForceOverwriteReplicaSecret=t.ForceOverwriteReplicaSecret;s.ClientRequestToken=t.ClientRequestToken||crypto.randomUUID();let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.CreateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId,ReplicationStatus:o.ReplicationStatus}}async updateSecret(t){let s={SecretId:t.SecretId,ClientRequestToken:t.ClientRequestToken||crypto.randomUUID()};if(t.Description)s.Description=t.Description;if(t.KmsKeyId)s.KmsKeyId=t.KmsKeyId;if(t.SecretBinary)s.SecretBinary=t.SecretBinary;if(t.SecretString)s.SecretString=t.SecretString;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.UpdateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId}}async putSecretValue(t){let s={SecretId:t.SecretId};if(t.SecretBinary)s.SecretBinary=t.SecretBinary;if(t.SecretString)s.SecretString=t.SecretString;if(t.VersionStages&&t.VersionStages.length>0)s.VersionStages=t.VersionStages;s.ClientRequestToken=t.ClientRequestToken||crypto.randomUUID();let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.PutSecretValue","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId,VersionStages:o.VersionStages}}async getSecretValue(t){let s={SecretId:t.SecretId};if(t.VersionId)s.VersionId=t.VersionId;if(t.VersionStage)s.VersionStage=t.VersionStage;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.GetSecretValue","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId,SecretBinary:o.SecretBinary,SecretString:o.SecretString,VersionStages:o.VersionStages,CreatedDate:o.CreatedDate}}async describeSecret(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DescribeSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return this.parseSecret(o)}async listSecrets(t){let s={};if(t?.MaxResults)s.MaxResults=t.MaxResults;if(t?.NextToken)s.NextToken=t.NextToken;if(t?.Filters&&t.Filters.length>0)s.Filters=t.Filters;if(t?.SortOrder)s.SortOrder=t.SortOrder;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.ListSecrets","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{SecretList:o.SecretList?.map((c)=>this.parseSecret(c)),NextToken:o.NextToken}}async deleteSecret(t){let s={SecretId:t.SecretId};if(t.RecoveryWindowInDays!==void 0)s.RecoveryWindowInDays=t.RecoveryWindowInDays;if(t.ForceDeleteWithoutRecovery!==void 0)s.ForceDeleteWithoutRecovery=t.ForceDeleteWithoutRecovery;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DeleteSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,DeletionDate:o.DeletionDate}}async restoreSecret(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.RestoreSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async rotateSecret(t){let s={SecretId:t.SecretId};if(t.ClientRequestToken)s.ClientRequestToken=t.ClientRequestToken;if(t.RotationLambdaARN)s.RotationLambdaARN=t.RotationLambdaARN;if(t.RotationRules)s.RotationRules=t.RotationRules;if(t.RotateImmediately!==void 0)s.RotateImmediately=t.RotateImmediately;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.RotateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,VersionId:o.VersionId}}async cancelRotateSecret(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.CancelRotateSecret","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async getResourcePolicy(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.GetResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name,ResourcePolicy:o.ResourcePolicy}}async putResourcePolicy(t){let s={SecretId:t.SecretId,ResourcePolicy:t.ResourcePolicy};if(t.BlockPublicPolicy!==void 0)s.BlockPublicPolicy=t.BlockPublicPolicy;let o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.PutResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async deleteResourcePolicy(t){let s={SecretId:t},o=await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.DeleteResourcePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)});return{ARN:o.ARN,Name:o.Name}}async tagResource(t){let s={SecretId:t.SecretId,Tags:t.Tags};await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.TagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)})}async untagResource(t){let s={SecretId:t.SecretId,TagKeys:t.TagKeys};await this.client.request({service:"secretsmanager",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"secretsmanager.UntagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(s)})}async setString(t,s,o){try{let c=await this.putSecretValue({SecretId:t,SecretString:s});return{ARN:c.ARN,VersionId:c.VersionId}}catch(c){if(c.code==="ResourceNotFoundException"){let l=await this.createSecret({Name:t,SecretString:s,Description:o?.description,KmsKeyId:o?.kmsKeyId,Tags:o?.tags});return{ARN:l.ARN,VersionId:l.VersionId}}throw c}}async setJson(t,s,o){return this.setString(t,JSON.stringify(s),o)}async getString(t){return(await this.getSecretValue({SecretId:t})).SecretString}async getJson(t){let s=await this.getString(t);if(s)return JSON.parse(s);return}async listAll(){let t=[],s;do{let o=await this.listSecrets({NextToken:s});if(o.SecretList)t.push(...o.SecretList);s=o.NextToken}while(s);return t}parseSecret(t){return{ARN:t.ARN,Name:t.Name,Description:t.Description,KmsKeyId:t.KmsKeyId,RotationEnabled:t.RotationEnabled,RotationLambdaARN:t.RotationLambdaARN,RotationRules:t.RotationRules,LastRotatedDate:t.LastRotatedDate,LastChangedDate:t.LastChangedDate,LastAccessedDate:t.LastAccessedDate,DeletedDate:t.DeletedDate,NextRotationDate:t.NextRotationDate,Tags:t.Tags,SecretVersionsToStages:t.SecretVersionsToStages,CreatedDate:t.CreatedDate,PrimaryRegion:t.PrimaryRegion}}}function E(t,s){let o=t.environments?.[s]?.app;if(!o)throw Error(`No serverless app configured for environment '${s}'. Add environments.${s}.app to your config.`);let c=t.project.slug,l=t.environments?.[s]?.region||t.project.region||"us-east-1";return{app:o,slug:c,region:l,stackName:De(t,s),artifactBucket:ea(c,s),assetsBucket:Io(c,s)}}function yt(t,s){let o=E(t,s),c=`${o.slug}-${s}`;return{region:o.region,slug:o.slug,stackName:o.stackName,functions:{http:`${c}-http`,queue:`${c}-queue`,cli:`${c}-cli`}}}async function L(t,s=8){let o;for(let c=0;c<s;c++)try{return await t()}catch(l){let d=l?.code||l?.name||"",m=String(l?.message||"");if(d==="ResourceConflictException"||/update is in progress|currently in the following state/i.test(m)){o=l,await new Promise((f)=>setTimeout(f,3000));continue}throw l}throw o}var ie=(t,s)=>`releases/${t}/${s}/current.json`;async function X(t,s,o,c){try{return await t.getObjectJson(s,ie(o,c))}catch{return null}}async function ae(t,s,o,c,l){await t.putObjectJson(s,ie(o,c),l)}async function Re(t,s){if(!t.secrets)return{};let o=new G(s),c={},l=Array.isArray(t.secrets)?t.secrets.map((d)=>({envName:d.split("/").pop().toUpperCase().replace(/[^A-Z0-9_]/g,"_"),secretId:d})):Object.entries(t.secrets).map(([d,m])=>({envName:d,secretId:m}));if(Array.isArray(t.secrets)){let d=new Map;for(let{envName:f,secretId:S}of l)d.set(f,[...d.get(f)??[],S]);let m=[...d.entries()].filter(([,f])=>f.length>1);if(m.length){let f=m.map(([S,h])=>`${S} ← ${h.join(", ")}`).join("; ");throw Error(`serverless secrets: multiple secrets map to the same env var (${f}). Use the map form { ENV_NAME: 'secret/id' } to disambiguate.`)}}for(let{envName:d,secretId:m}of l){let S=(await o.getSecretValue({SecretId:m})).SecretString??"";try{let h=JSON.parse(S);if(h&&typeof h==="object"&&!Array.isArray(h)){for(let[C,w]of Object.entries(h))c[C]=String(w);continue}}catch{}c[d]=S}return c}function Cd(t,s){let o={},c=s.DbProxyEndpoint||s.DbEndpoint;if(c)o.DB_CONNECTION="mysql",o.DB_HOST=c,o.DB_PORT="3306",o.DB_DATABASE=o.DB_DATABASE||"app";if(s.CacheEndpoint){if(o.REDIS_HOST=s.CacheEndpoint,o.REDIS_PORT="6379",t.cache?.driver==="elasticache")o.CACHE_STORE="redis",o.CACHE_DRIVER="redis",o.SESSION_DRIVER="redis"}return o}function Es(t,s,o,c,l,d,m,f={}){let S=t.kind==="php"?Ea({cacheDriver:t.cache?.driver==="elasticache"?"redis":"dynamodb"}):{};return{TSCLOUD_LAMBDA_MODE:c,TSCLOUD_ENV:o,MAINTENANCE_MODE:"0",...t.octane?{TSCLOUD_OCTANE:"1"}:{},...t.serveAssets?{TSCLOUD_SERVE_ASSETS:"1"}:{},...t.redirectRobotsTxt===!1?{TSCLOUD_REDIRECT_ROBOTS_TXT:"0"}:{},...S,...f,...s.app.cache?.driver!=="elasticache"?{TSCLOUD_CACHE_TABLE:`${s.slug}-${o}-cache`}:{},...m?{TSCLOUD_QUEUE:m,SQS_QUEUE:m}:{},...d?{ASSET_URL:d}:{},...t.env??{},...l}}function he(t){let s=t.slice(t.lastIndexOf(".")).toLowerCase();return{".html":"text/html",".css":"text/css",".js":"text/javascript",".mjs":"text/javascript",".json":"application/json",".svg":"image/svg+xml",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".webp":"image/webp",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".txt":"text/plain",".map":"application/json"}[s]??"application/octet-stream"}function*oe(t){for(let s of me(t)){let o=ne(t,s);if(fe(o).isDirectory())yield*oe(o);else yield o}}async function ve(t,s,o,c,l=!1){let d=0;for(let m of oe(o)){let f=ye(o,m).replace(/\\/g,"/");if(!l&&f.split("/").some((S)=>S.startsWith(".")))continue;await t.putObject({bucket:s,key:`${c}/${f}`,body:pe(m),contentType:he(m),cacheControl:"public, max-age=31536000, immutable"}),d++}return d}function uo(t,s){let o=Object.entries(s).reduce((c,[l,d])=>c+Buffer.byteLength(`${l}=${d}`,"utf8"),0);if(o>4096){let c=Object.entries(s).map(([l,d])=>[l,Buffer.byteLength(`${l}=${d}`,"utf8")]).sort((l,d)=>d[1]-l[1]).slice(0,5).map(([l,d])=>`${l} (${d}B)`).join(", ");throw Error(`${t}: environment variables total ${o}B, over AWS's 4096B limit (${o-4096}B too large). Largest: ${c}. Move large/secret values out of env — store them in Secrets Manager and fetch at cold start.`)}}async function U(t,s,o,c){uo(s,o),await L(()=>t.updateFunctionConfiguration({FunctionName:s,Environment:{Variables:o}})),await t.waitForFunctionActive(s,120);let l=c.kind==="image"?{FunctionName:s,ImageUri:c.imageUri}:{FunctionName:s,S3Bucket:c.bucket,S3Key:c.key};await L(()=>t.updateFunctionCode(l)),await t.waitForFunctionActive(s,120)}async function W(t,s){let c=(await L(()=>t.publishVersion({FunctionName:s}))).Version;if(!c)throw Error(`publishVersion returned no version for ${s}`);return await L(()=>t.updateAlias({FunctionName:s,Name:"live",FunctionVersion:c})),c}async function lp(t,s,o={}){let c=E(t,s),{app:l,slug:d,region:m,stackName:f,artifactBucket:S}=c,h=o.projectRoot??process.cwd();i(`Deploying serverless app: ${d} (${s})`),e(`Stack: ${f}`),e(`Region: ${m}`);let C=new g(m),w=new v(m),b=new R(m),P=l.kind==="php",O=l.packaging==="image",N=Uo(l),B,I,k,Y,z=[];if(O&&N.usesLayer&&N.layerKind!=="php")throw Error(`packaging: 'image' currently supports PHP and managed Node runtimes. ${N.kind}${N.kind==="node"?` ${N.version}`:""} uses a custom runtime — `+"use the default zip packaging (the runtime layer is built + attached automatically).");if(O){p("Building + pushing container image");let{buildAndPushServerlessImage:y}=await import("./chunk-xxgybh3b.js"),A=await y({app:l,projectRoot:h,region:m,repository:`${d}-${s}`,skipBuild:o.skipBuild,onStep:(D)=>e(` ${D}`)});B=A.handlers,I={kind:"image",imageUri:A.imageUri},k=A.tag,z.push({ParameterKey:"ImageUri",ParameterValue:A.imageUri})}else{p("Packaging application");let y=P?wa({projectRoot:h,app:l,skipBuild:o.skipBuild,onStep:(x)=>e(` ${x}`)}):await dn({projectRoot:h,app:l,skipBuild:o.skipBuild,onStep:(x)=>e(` ${x}`)}),A=ga(d,s,y.sha256);if(e(`Artifact: ${y.sha256.slice(0,12)} (${(y.zip.length/1024).toFixed(0)} KB)`),B=y.handlers,k=y.sha256,N.usesLayer){let x=N.layerEnvVar?process.env[N.layerEnvVar]:void 0;if(Y=l.layers??(x?[x]:void 0),!Y?.length){let ge=N.layerKind==="php"?"serverless:build-php-layer":N.layerKind==="bun"?"serverless:build-bun-layer":"serverless:build-node-layer";throw Error(`${N.kind} apps on provided.al2023 need a runtime layer. Set environments.<env>.app.layers or the ${N.layerEnvVar} env var (build one with \`cloud ${ge}\`)${N.kind==="node"?", or use a managed Node version (18/20/22)":""}.`)}}if(!await C.bucketExists(S))p(`Creating artifact bucket ${S}`),await C.createBucket(S);if(await C.headObject(S,A).then((x)=>x!==null).catch(()=>!1))e("Artifact already uploaded — reusing");else p("Uploading artifact"),await C.putObject({bucket:S,key:A,body:y.zip,contentType:"application/zip"});I={kind:"zip",bucket:S,key:A},z.push({ParameterKey:"ArtifactBucket",ParameterValue:S},{ParameterKey:"ArtifactKey",ParameterValue:A})}let T=ha({config:t,environment:s,app:l,handlers:B,runtimeLayers:Y}),te=JSON.stringify(T.template),re=["CAPABILITY_NAMED_IAM"],K=await w.describeStacks({stackName:f}).then((y)=>y.Stacks[0]?.StackStatus).catch(()=>{return}),M=K!==void 0;if(K&&/DELETE_IN_PROGRESS/.test(K))p("Waiting for an in-progress stack delete to finish"),await w.waitForStack(f,"stack-delete-complete").catch(()=>{}),M=!1;else if(K&&/(?:ROLLBACK_COMPLETE|REVIEW_IN_PROGRESS|CREATE_FAILED)/.test(K))p(`Deleting unusable stack (status ${K}) before recreate`),await w.deleteStack(f),await w.waitForStack(f,"stack-delete-complete").catch(()=>{}),M=!1;p(M?"Updating infrastructure stack":"Creating infrastructure stack");try{if(M)await w.updateStack({stackName:f,templateBody:te,parameters:z,capabilities:re}),await w.waitForStack(f,"stack-update-complete");else await w.createStack({stackName:f,templateBody:te,parameters:z,capabilities:re,onFailure:"DELETE"}),await w.waitForStack(f,"stack-create-complete")}catch(y){if(/No updates are to be performed/i.test(String(y?.message)))e("No infrastructure changes");else throw y}let Q=await w.getStackOutputs(f).catch(()=>({})),F;if(l.assets){let y=ne(h,l.assets);if(de(y)){let A=l.assetDomain||Q.AssetsCdnDomain;F=A?`https://${A}/${k}`:void 0,p(`Syncing assets from ${l.assets}`);let D=await ve(C,c.assetsBucket,y,k,l.dotFilesAsAssets);e(`Uploaded ${D} asset(s)${F?` → ${F}`:""}`)}else a(`Assets directory not found: ${y}`)}p("Resolving secrets");let _=await Re(l,m);if(l.database?.connection==="aurora-serverless")try{let A=await new G(m).getSecretValue({SecretId:`${d}/${s}/db`}),D=JSON.parse(A.SecretString??"{}");if(D.username)_.DB_USERNAME=D.username;if(D.password)_.DB_PASSWORD=D.password}catch(y){a(`Could not resolve Aurora DB credentials: ${y.message}`)}if(!await C.bucketExists(S))await C.createBucket(S);let J=await X(C,S,d,s),q={},Z=T.queueNames[0],ee=Cd(l,Q);if(p("Activating functions"),q.http=Es(l,c,s,"http",_,F,Z,ee),await U(b,T.functionNames.http,q.http,I),q.cli=Es(l,c,s,"cli",_,F,Z,ee),await U(b,T.functionNames.cli,q.cli,I),T.queueNames.length)q.queue=Es(l,c,s,"queue",_,F,Z,ee),await U(b,T.functionNames.queue,q.queue,I);let se=(l.provisionedConcurrency??0)>0,H={};if(se){if(p("Publishing versions + flipping live alias"),H.http=await W(b,T.functionNames.http),H.cli=await W(b,T.functionNames.cli),T.queueNames.length)H.queue=await W(b,T.functionNames.queue)}if(await ae(C,S,d,s,{sha:k,code:I,previousSha:J?.sha,previousCode:J?.code,previousFunctionEnv:J?.functionEnv,...se?{functionVersions:H,previousFunctionVersions:J?.functionVersions}:{},functionEnv:q,functionNames:{http:T.functionNames.http,cli:T.functionNames.cli,...T.queueNames.length?{queue:T.functionNames.queue}:{}},assetUrl:F,timestamp:new Date().toISOString()}),!o.skipDeployHooks&&l.deploy?.length){p("Running deploy hooks");for(let y of l.deploy){e(` deploy: ${y}`);let A=await b.invoke({FunctionName:T.functionNames.cli,InvocationType:"RequestResponse",Payload:{command:y},LogType:"Tail"});if(A.FunctionError)throw r("Deploy hook failed — the new build is ALREADY LIVE."),e(` Roll back with: cloud serverless:rollback --env ${s}`),Error(`Deploy hook failed (${y}): ${A.Payload}`)}}let j=Q.HttpApiEndpoint;if(!o.skipHealthCheck&&j){p("Health check");try{let y=await fetch(j,{method:"GET"});e(`GET ${j} → ${y.status}`)}catch(y){a(`Health check could not reach ${j}: ${y.message}`)}}Se(["Serverless deploy complete","",j?`URL: ${j}`:"",`Stack: ${f}`,`Build: ${k.slice(0,12)}`].filter(Boolean).join(`
|
|
2
|
+
`),"green")}async function ws(t,s){let o=E(t,s),c=new g(o.region),l=new R(o.region),d=await X(c,o.artifactBucket,o.slug,s);if(!d)throw Error("No previous release to redeploy. Run a full deploy first.");i(`Redeploying ${o.slug} (${s}) — build ${d.sha.slice(0,12)}`);for(let[m,f]of Object.entries(d.functionNames)){if(!f)continue;p(`Re-activating ${m} (${f})`),await U(l,f,d.functionEnv[m]??{},d.code);let S=d.functionVersions?.[m];if(S)await L(()=>l.updateAlias({FunctionName:f,Name:"live",FunctionVersion:S}))}n("Redeploy complete")}async function Cs(t,s){let o=E(t,s),c=new g(o.region),l=new R(o.region),d=await X(c,o.artifactBucket,o.slug,s);if(!d?.previousCode)throw Error("No previous release to roll back to.");i(`Rolling back ${o.slug} (${s}) → ${d.previousSha?.slice(0,12)}`);for(let[m,f]of Object.entries(d.functionNames)){if(!f)continue;p(`Restoring ${m} (${f})`);let S=d.previousFunctionEnv?.[m]??d.functionEnv[m]??{};await U(l,f,S,d.previousCode);let h=d.previousFunctionVersions?.[m];if(h)await L(()=>l.updateAlias({FunctionName:f,Name:"live",FunctionVersion:h}))}await ae(c,o.artifactBucket,o.slug,s,{...d,sha:d.previousSha??d.sha,code:d.previousCode,functionEnv:d.previousFunctionEnv??d.functionEnv,functionVersions:d.previousFunctionVersions??d.functionVersions,previousSha:void 0,previousCode:void 0,previousFunctionEnv:void 0,previousFunctionVersions:void 0,timestamp:new Date().toISOString()}),n("Rollback complete")}async function po(t,s,o,c){let l=E(t,s),d=new R(l.region),m=`${l.slug}-${s}-http`,S={...(await d.getFunction(m)).Configuration?.Environment?.Variables??{}};if(S.MAINTENANCE_MODE=o?"1":"0",o&&c)S.MAINTENANCE_BYPASS_SECRET=c;if(!o)delete S.MAINTENANCE_BYPASS_SECRET;if(await L(()=>d.updateFunctionConfiguration({FunctionName:m,Environment:{Variables:S}})),(l.app.provisionedConcurrency??0)>0)await d.waitForFunctionActive(m,120),await W(d,m);n(o?"Application is now in maintenance mode (503)":"Application is live")}async function Mt(t,s,o){let c=E(t,s),l=new R(c.region),d=`${c.slug}-${s}-cli`,m=await l.invoke({FunctionName:d,InvocationType:"RequestResponse",Payload:{command:o},LogType:"Tail"});if(m.FunctionError)throw Error(`Command failed: ${m.Payload}`);return m.Payload??""}var ce=(t,s)=>`commands/${t}/${s}/history.json`,Ne=50;async function le(t,s,o,c){try{return(await t.getObjectJson(s,ce(o,c)))?.records??[]}catch{return[]}}async function dp(t,s,o){let c=E(t,s),l=new R(c.region),d=`${c.slug}-${s}-cli`,m=await l.invoke({FunctionName:d,InvocationType:"RequestResponse",Payload:{command:o},LogType:"Tail"}),f=m.Payload??"",S=m.FunctionError?"error":"ok",h=-1;try{let C=new g(c.region);if(await C.bucketExists(c.artifactBucket)){let w=await le(C,c.artifactBucket,c.slug,s);h=w.reduce((b,P)=>Math.max(b,P.id),0)+1,w.push({id:h,command:o,timestamp:new Date().toISOString(),status:S,output:f.slice(0,4000)}),await C.putObjectJson(c.artifactBucket,ce(c.slug,s),{records:w.slice(-Ne)})}}catch{}if(m.FunctionError)throw Error(`Command failed${h>0?` (#${h})`:""}: ${f}`);return{id:h,status:S,output:f}}async function Ad(t,s){let o=E(t,s),c=new g(o.region);return le(c,o.artifactBucket,o.slug,s)}async function up(t,s,o){let c=await Ad(t,s);if(!c.length)return;return o==null?c[c.length-1]:c.find((l)=>l.id===o)}async function pp(t,s,o){let c=Buffer.from(o,"utf-8").toString("base64");return Mt(t,s,`tscloud:db-query --sql-base64=${c}`)}async function V(t,s){let o=E(t,s),c=new v(o.region),l=new R(o.region),d=new g(o.region),m="not deployed",f={};try{let{Stacks:O}=await c.describeStacks({stackName:o.stackName});m=O?.[0]?.StackStatus??m;for(let N of O?.[0]?.Outputs??[])if(N.OutputKey)f[N.OutputKey]=N.OutputValue??""}catch{}let S=fa(o.app,o.slug,s),h=o.app.provisionedConcurrency??0,C=["http","cli",...S.length?["queue"]:[]],w=`${o.slug}-${s}`,b=[];for(let O of C){let N=`${w}-${O}`,B={mode:O,name:N,version:"$LATEST"};if(h>0){let I=await l.getAlias(N,"live").catch(()=>null);if(I?.FunctionVersion){B.version=I.FunctionVersion;let k=await l.getProvisionedConcurrencyConfig(N,"live").catch(()=>null);if(k)B.provisioned={status:k.Status??"-",allocated:k.AllocatedProvisionedConcurrentExecutions??0,requested:k.RequestedProvisionedConcurrentExecutions??0}}}b.push(B)}let P=await X(d,o.artifactBucket,o.slug,s).catch(()=>null);return{slug:o.slug,environment:s,region:o.region,stackStatus:m,endpoint:f.HttpApiEndpoint,assetUrl:P?.assetUrl,scheduler:o.app.scheduler??"on",queues:S,provisionedConcurrency:h,functions:b,lastRelease:P?{sha:P.sha,timestamp:P.timestamp}:void 0}}function ue(t,s){return`${t}-${s}-db`}async function As(t,s,o,c){let l=E(t,s);if(l.app.database?.connection!=="aurora-serverless")throw Error("No Aurora Serverless v2 database is configured for this environment.");let{RDSClient:d}=await import("./chunk-kf1p7s61.js"),m=new d(l.region),f=ue(l.slug,s);p(`Scaling ${f} → ${o}–${c} ACUs`),await m.modifyDBCluster({DBClusterIdentifier:f,ServerlessV2ScalingConfiguration:{MinCapacity:o,MaxCapacity:c},ApplyImmediately:!0}),n(`Scaling applied to ${f} (takes effect shortly).`)}async function mp(t,s,o){let c=E(t,s);if(c.app.database?.connection!=="aurora-serverless")throw Error("No Aurora Serverless v2 database is configured for this environment.");if(!o.toTime&&!o.latest)throw Error("Specify a restore point: --to <ISO timestamp> or --latest.");let{RDSClient:l}=await import("./chunk-kf1p7s61.js"),d=new l(c.region),m=ue(c.slug,s),f=o.latest?"latest":o.toTime.toISOString().replace(/[^0-9]/g,"").slice(0,14),S=o.target??`${m}-restore-${f}`;p(`Restoring ${m} → new cluster ${S} (${o.latest?"latest restorable time":o.toTime.toISOString()})`),await d.restoreDBClusterToPointInTime({DBClusterIdentifier:S,SourceDBClusterIdentifier:m,RestoreToTime:o.toTime,UseLatestRestorableTime:o.latest}),p("Waiting for the restored cluster to be ready");for(let h=0;h<120;h++){let{DBClusters:C}=await d.describeDBClusters({DBClusterIdentifier:S}),w=C?.[0]?.Status;if(w&&w!=="creating")break;await new Promise((b)=>setTimeout(b,15000))}return p("Adding a writer instance"),await d.createDBInstance({DBInstanceIdentifier:`${S}-1`,DBClusterIdentifier:S,Engine:"aurora-mysql",DBInstanceClass:"db.serverless"}),n(`Restore complete → cluster ${S} with writer ${S}-1. Point an env's database at it once available.`),S}
|
|
3
|
+
export{G,yt,Cd,Es,uo,lp,ws,Cs,po,Mt,dp,Ad,up,pp,V,As,mp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var M=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"routing",label:"Routing"},{index:4,id:"apps",label:"Applications"},{index:5,id:"runtime",label:"Background runtime"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],N=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"entry",label:"Entry points"},{index:4,id:"compute",label:"Compute"},{index:5,id:"messaging",label:"Messaging & pooling"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],P=[{match:/^redis/,kind:"cache",label:"Redis"},{match:/^(?:mysql|mariadb)/,kind:"database",label:"MySQL"},{match:/^postgres/,kind:"database",label:"PostgreSQL"},{match:/^meilisearch/,kind:"database",label:"Meilisearch"},{match:/^vitess|^vtgate/,kind:"database",label:"Vitess"},{match:/^memcached/,kind:"cache",label:"Memcached"}],j=/^(?:rpx-gateway|nginx|caddy|traefik|haproxy)$/;function e(n,u=""){let a=n==null?"":String(n).trim();return a&&a!=="-"&&a!=="—"?a:u}function F(n){return Array.isArray(n)?n.length:0}function h(n){let u=e(n).toLowerCase();if(!u)return"unknown";if(["running","live","active","available","success","ok","healthy","enabled"].includes(u))return"ok";if(["failed","stopped","unreachable","error","critical","disabled"].includes(u))return"bad";if(["configured","creating","pending","degraded","shadowed","warn","unknown"].includes(u))return"warn";return"warn"}function r(n,u,a){if(a.has(u.source)&&a.has(u.target))n.push(u)}function qr(n,u={}){let a=[],o=[],q=[],f=n.server??{},c=Array.isArray(n.sites)?n.sites:[],L=Array.isArray(n.services)?n.services:[],k=Array.isArray(n.workers)?n.workers:[],m=n.security??{},C=!!n._serverReachable&&!n.metricsUnavailable,T="box";if(!C)q.push("The compute box could not be probed, so live service state is missing; the shape comes from your cloud config.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let i=[...new Set(c.map((t)=>e(t.domain)||e(t.route).split("/")[0]).filter((t)=>t&&t!=="internal"&&t!=="loopback"))],E=Array.isArray(m.tlsCertificates)?m.tlsCertificates:[],g=E.filter((t)=>Number(t?.daysRemaining??999)<21).length;a.push({id:"dns",label:i.length===1?i[0]:"Public domains",kind:"dns",layer:1,status:g?"warn":i.length?"ok":"unknown",sub:i.length>1?`${i.length} domains`:"DNS & certificates",facts:[{label:"Domains",value:i.length?i.slice(0,6).join(", "):"none resolved"},{label:"Certificates",value:E.length?`${E.length} issued`:"none reported"},...g?[{label:"Expiring",value:`${g} within 21 days`}]:[]],href:"/server/security",external:!0});let v=m.firewall??{},w=Array.isArray(m.ports)?m.ports:[];a.push({id:"firewall",label:"Host firewall",kind:"firewall",layer:2,status:h(v.status),sub:e(v.summary,"Inbound filtering"),facts:[{label:"State",value:e(v.status,"unknown")},{label:"Open ports",value:w.length?w.map((t)=>e(t.listen)).join(", "):"not reported"}],href:"/server/firewall",group:"box"});let y=L.find((t)=>j.test(e(t.name)));a.push({id:"proxy",label:e(y?.name,"Reverse proxy"),kind:"proxy",layer:3,status:y?h(y.status):"unknown",sub:"TLS termination & routing",facts:[{label:"Service",value:e(y?.name,"not detected")},{label:"State",value:e(y?.status,C?"not running":"not probed")},{label:"Routes",value:`${c.length} site${c.length===1?"":"s"}`}],href:"/server/services",group:"box"});for(let t of c){let d=`site:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"site",layer:4,status:h(t.status),sub:e(t.runtime,"runtime"),facts:[{label:"Route",value:e(t.route,"internal")},{label:"Runtime",value:e(t.runtime,"unknown")},{label:"Delivery",value:e(t.deploy,"unknown")},{label:"TLS",value:e(t.tls,"unknown")},...t.responseMs!=null?[{label:"Response",value:`${Math.round(Number(t.responseMs))} ms`}]:[],...t.httpStatus!=null?[{label:"HTTP",value:String(t.httpStatus)}]:[]],href:"/server/sites",group:"box"})}for(let t of k){let d=`worker:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"worker",layer:5,status:h(t.status),sub:`${Number(t.processes??1)} process${Number(t.processes??1)===1?"":"es"}`,facts:[{label:"Processes",value:String(t.processes??1)},{label:"State",value:e(t.status,"unknown")},...e(t.site)?[{label:"Site",value:e(t.site)}]:[]],href:"/operations/jobs",group:"box"})}let A=n.serverScheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:5,status:"ok",sub:"Cron dispatch",facts:[{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs",group:"box"});let l=L.map((t)=>{let d=e(t.name),s=P.find((p)=>p.match.test(d));return s?{service:t,name:d,...s}:null}).filter((t)=>!!t);for(let t of l)a.push({id:`data:${t.name}`,label:t.label,kind:t.kind,layer:6,status:h(t.service.status),sub:t.name,facts:[{label:"Unit",value:t.name},{label:"State",value:e(t.service.status,"unknown")}],href:"/data/services",group:"box"});let x=n.backup??{};if(x.enabled)a.push({id:"backup",label:"Backups",kind:"backup",layer:7,status:"ok",sub:e(x.destination,"destination"),facts:[{label:"Destination",value:e(x.destination,"unknown")},{label:"Schedule",value:e(x.schedule,"unknown")},{label:"Retention",value:`${x.retention??0} copies`},{label:"Last run",value:e(x.last,"unknown")}],href:"/data/backups"});let b=new Set(a.map((t)=>t.id));r(o,{source:"internet",target:"dns",flow:"request",label:"https"},b),r(o,{source:"dns",target:"firewall",flow:"request",label:"443/80"},b),r(o,{source:"firewall",target:"proxy",flow:"request"},b);for(let t of c){let d=`site:${e(t.name)}`;r(o,{source:"proxy",target:d,flow:"request",label:e(t.path)||void 0,status:h(t.status)},b)}for(let t of k){let d=`worker:${e(t.name)}`,s=`site:${e(t.site)}`;if(b.has(s))r(o,{source:s,target:d,flow:"async",label:"queue"},b);else r(o,{source:"proxy",target:d,flow:"async",label:"queue"},b)}for(let t of k)r(o,{source:"scheduler",target:`worker:${e(t.name)}`,flow:"async",label:"dispatch"},b);let D=[...c.map((t)=>`site:${e(t.name)}`),...k.map((t)=>`worker:${e(t.name)}`)];for(let t of l)for(let d of D)r(o,{source:d,target:`data:${t.name}`,flow:"data",label:"localhost"},b);if(l.length&&D.length)q.push("Data-service edges show co-location on the box: every process on it can reach localhost. They are not a declared per-site binding.");for(let t of l)r(o,{source:`data:${t.name}`,target:"backup",flow:"backup",label:"snapshot"},b);for(let t of c)r(o,{source:`site:${e(t.name)}`,target:"backup",flow:"backup"},b);return{mode:"server",project:e(u.project)||e(n.project?.name)||e(f.name,"project"),environment:e(u.environment)||e(n.environment,"production"),provider:e(f.provider,"unknown"),region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:M,groups:[{id:"box",label:e(f.name,"App server"),sub:[e(f.provider),e(f.region),e(f.ip)].filter(Boolean).join(" · ")}],nodes:a,links:o,notes:q}}function _a(n,u={}){let a=[],o=[],q=[],f=n.app??{},c=Array.isArray(n.functions)?n.functions:[],L=Array.isArray(n.queues)?n.queues:[],k=n.metrics??{};if(!c.length)q.push("No Lambda functions were read for this environment, so the compute layer is empty rather than assumed.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let m=e(f.url),C=m.replace(/^https?:\/\//,"").split("/")[0];a.push({id:"dns",label:C||"Application domain",kind:"dns",layer:1,status:C?"ok":"unknown",sub:"DNS & certificates",facts:[{label:"Endpoint",value:m||"not resolved"}],external:!0});let T=n.waf;if(T)a.push({id:"waf",label:"WAF",kind:"waf",layer:2,status:h(T.status??"active"),sub:e(T.scope,"Managed rules"),facts:[{label:"Web ACL",value:e(T.name,"unnamed")},...T.blocked!=null?[{label:"Blocked (24h)",value:String(T.blocked)}]:[],{label:"Rules",value:String(F(n.wafRules))}],href:"/serverless/firewall"});let i=n.assetsInfo;if(i)a.push({id:"cdn",label:"Asset CDN",kind:"cdn",layer:2,status:"ok",sub:e(i.cdn,"CloudFront"),facts:[{label:"Distribution",value:e(i.cdn,"unknown")},{label:"Custom domain",value:e(i.customDomain,"none")}],href:"/serverless/assets"}),a.push({id:"assets",label:"Asset bucket",kind:"storage",layer:6,status:"ok",sub:e(i.bucket,"S3"),facts:[{label:"Bucket",value:e(i.bucket,"unknown")},...i.files?[{label:"Objects",value:String(i.files)}]:[],...i.sizeMb?[{label:"Size",value:`${i.sizeMb} MB`}]:[]],href:"/serverless/assets"});let E=c.find((s)=>e(s.key).startsWith("http"));a.push({id:"gateway",label:"HTTP entry point",kind:"gateway",layer:3,status:E?"ok":"unknown",sub:"Function URL / API Gateway",facts:[{label:"Endpoint",value:m||"not resolved"},{label:"Invocations (24h)",value:String(k.invocations??0)},...k.errorRatePct!=null?[{label:"Error rate",value:`${k.errorRatePct}%`}]:[]],href:"/serverless/metrics"});for(let s of c){let p=`fn:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.errors??0),R=Number(s.invocations??0);a.push({id:p,label:e(s.key,e(s.name)),kind:"function",layer:4,status:S>0?R&&S/R>0.02?"bad":"warn":R?"ok":"idle",sub:e(s.runtime,"lambda"),facts:[{label:"Function",value:e(s.name)},{label:"Memory",value:`${s.memory??0} MB`},{label:"Timeout",value:`${s.timeout??0}s`},{label:"Invocations (24h)",value:String(R)},{label:"Errors (24h)",value:String(S)},{label:"p95",value:`${s.p95??0} ms`},...s.provisioned?[{label:"Provisioned",value:e(s.provisioned)}]:[]],href:"/serverless/functions"})}for(let s of L){let p=`queue:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.dlq??0);a.push({id:p,label:e(s.name),kind:"queue",layer:5,status:S>0?"bad":Number(s.visible??0)>0?"warn":"ok",sub:"SQS",facts:[{label:"Visible",value:String(s.visible??0)},{label:"In flight",value:String(s.inFlight??0)},{label:"Processed (24h)",value:String(s.processed??0)},{label:"Dead letter",value:String(S)}],href:"/serverless/queues"})}let g=n.aurora;if(g)a.push({id:"database",label:"Aurora Serverless",kind:"database",layer:6,status:h(g.status),sub:e(g.engine,"aurora"),facts:[{label:"Cluster",value:e(g.id,"unknown")},{label:"Capacity",value:`${g.currentAcu??0} ACU (${g.minAcu??0}–${g.maxAcu??0})`},{label:"Connections",value:String(g.connections??0)}],href:"/serverless/data"});let v=n.proxy;if(v)a.push({id:"rds-proxy",label:"RDS Proxy",kind:"database",layer:5,status:h(v.status),sub:"Connection pooling",facts:[{label:"Proxy",value:e(v.name,"unknown")},{label:"Endpoint",value:e(v.endpoint,"unknown")},{label:"Pooled",value:String(v.pooledConns??0)}],href:"/serverless/data"});let w=n.redis;if(w)a.push({id:"cache",label:"ElastiCache",kind:"cache",layer:6,status:h(w.status),sub:e(w.node,"redis"),facts:[{label:"Group",value:e(w.id,"unknown")},{label:"Hit rate",value:`${w.hitRate??0}%`}],href:"/serverless/data"});let y=n.efs;if(y)a.push({id:"efs",label:"EFS",kind:"filesystem",layer:6,status:h(y.status),sub:e(y.mount,"/mnt/local"),facts:[{label:"File system",value:e(y.id,"unknown")},{label:"Mount",value:e(y.mount,"unknown")},{label:"Size",value:`${y.sizeMb??0} MB`}],href:"/data/volumes"});let A=n.scheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:3,status:"ok",sub:e(A.expression,"rate(1 minute)"),facts:[{label:"Expression",value:e(A.expression,"unknown")},{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs"});let l=new Set(a.map((s)=>s.id)),x=l.has("waf")?"waf":"gateway";r(o,{source:"internet",target:"dns",flow:"request",label:"https"},l),r(o,{source:"dns",target:x,flow:"request"},l),r(o,{source:"dns",target:"cdn",flow:"request",label:"assets"},l),r(o,{source:"waf",target:"gateway",flow:"request",label:"allowed"},l),r(o,{source:"cdn",target:"assets",flow:"data",label:"origin"},l);let b=c.filter((s)=>e(s.key).startsWith("http")),D=c.filter((s)=>e(s.key).startsWith("queue")),t=c.filter((s)=>e(s.key).startsWith("cli"));for(let s of b)r(o,{source:"gateway",target:`fn:${e(s.name)}`,flow:"request",label:"invoke"},l);for(let s of t)r(o,{source:"scheduler",target:`fn:${e(s.name)}`,flow:"async",label:"schedule"},l);for(let s of L){for(let p of b)r(o,{source:`fn:${e(p.name)}`,target:`queue:${e(s.name)}`,flow:"async",label:"publish"},l);for(let p of D)r(o,{source:`queue:${e(s.name)}`,target:`fn:${e(p.name)}`,flow:"async",label:"consume"},l)}let d=["rds-proxy","database","cache","efs","assets"];for(let s of c){let p=`fn:${e(s.name)}`;if(l.has("rds-proxy"))r(o,{source:p,target:"rds-proxy",flow:"data",label:"pooled"},l);else r(o,{source:p,target:"database",flow:"data",label:"sql"},l);for(let S of d.filter((R)=>R!=="rds-proxy"&&R!=="database"))r(o,{source:p,target:S,flow:"data"},l)}return r(o,{source:"rds-proxy",target:"database",flow:"data",label:"sql"},l),{mode:"serverless",project:e(u.project)||e(f.name,"application"),environment:e(u.environment)||e(f.env,"production"),provider:"aws",region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:N,groups:[],nodes:a,links:o,notes:q}}
|
|
2
|
-
export{
|
|
1
|
+
var M=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"routing",label:"Routing"},{index:4,id:"apps",label:"Applications"},{index:5,id:"runtime",label:"Background runtime"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],N=[{index:0,id:"clients",label:"Clients"},{index:1,id:"dns",label:"DNS & TLS"},{index:2,id:"edge",label:"Edge"},{index:3,id:"entry",label:"Entry points"},{index:4,id:"compute",label:"Compute"},{index:5,id:"messaging",label:"Messaging & pooling"},{index:6,id:"data",label:"Data services"},{index:7,id:"durability",label:"Durability"}],P=[{match:/^redis/,kind:"cache",label:"Redis"},{match:/^(?:mysql|mariadb)/,kind:"database",label:"MySQL"},{match:/^postgres/,kind:"database",label:"PostgreSQL"},{match:/^meilisearch/,kind:"database",label:"Meilisearch"},{match:/^vitess|^vtgate/,kind:"database",label:"Vitess"},{match:/^memcached/,kind:"cache",label:"Memcached"}],j=/^(?:rpx-gateway|nginx|caddy|traefik|haproxy)$/;function e(n,u=""){let a=n==null?"":String(n).trim();return a&&a!=="-"&&a!=="—"?a:u}function F(n){return Array.isArray(n)?n.length:0}function h(n){let u=e(n).toLowerCase();if(!u)return"unknown";if(["running","live","active","available","success","ok","healthy","enabled"].includes(u))return"ok";if(["failed","stopped","unreachable","error","critical","disabled"].includes(u))return"bad";if(["configured","creating","pending","degraded","shadowed","warn","unknown"].includes(u))return"warn";return"warn"}function r(n,u,a){if(a.has(u.source)&&a.has(u.target))n.push(u)}function Wr(n,u={}){let a=[],o=[],q=[],f=n.server??{},c=Array.isArray(n.sites)?n.sites:[],L=Array.isArray(n.services)?n.services:[],k=Array.isArray(n.workers)?n.workers:[],m=n.security??{},C=!!n._serverReachable&&!n.metricsUnavailable,T="box";if(!C)q.push("The compute box could not be probed, so live service state is missing; the shape comes from your cloud config.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let i=[...new Set(c.map((t)=>e(t.domain)||e(t.route).split("/")[0]).filter((t)=>t&&t!=="internal"&&t!=="loopback"))],E=Array.isArray(m.tlsCertificates)?m.tlsCertificates:[],g=E.filter((t)=>Number(t?.daysRemaining??999)<21).length;a.push({id:"dns",label:i.length===1?i[0]:"Public domains",kind:"dns",layer:1,status:g?"warn":i.length?"ok":"unknown",sub:i.length>1?`${i.length} domains`:"DNS & certificates",facts:[{label:"Domains",value:i.length?i.slice(0,6).join(", "):"none resolved"},{label:"Certificates",value:E.length?`${E.length} issued`:"none reported"},...g?[{label:"Expiring",value:`${g} within 21 days`}]:[]],href:"/server/security",external:!0});let v=m.firewall??{},w=Array.isArray(m.ports)?m.ports:[];a.push({id:"firewall",label:"Host firewall",kind:"firewall",layer:2,status:h(v.status),sub:e(v.summary,"Inbound filtering"),facts:[{label:"State",value:e(v.status,"unknown")},{label:"Open ports",value:w.length?w.map((t)=>e(t.listen)).join(", "):"not reported"}],href:"/server/firewall",group:"box"});let y=L.find((t)=>j.test(e(t.name)));a.push({id:"proxy",label:e(y?.name,"Reverse proxy"),kind:"proxy",layer:3,status:y?h(y.status):"unknown",sub:"TLS termination & routing",facts:[{label:"Service",value:e(y?.name,"not detected")},{label:"State",value:e(y?.status,C?"not running":"not probed")},{label:"Routes",value:`${c.length} site${c.length===1?"":"s"}`}],href:"/server/services",group:"box"});for(let t of c){let d=`site:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"site",layer:4,status:h(t.status),sub:e(t.runtime,"runtime"),facts:[{label:"Route",value:e(t.route,"internal")},{label:"Runtime",value:e(t.runtime,"unknown")},{label:"Delivery",value:e(t.deploy,"unknown")},{label:"TLS",value:e(t.tls,"unknown")},...t.responseMs!=null?[{label:"Response",value:`${Math.round(Number(t.responseMs))} ms`}]:[],...t.httpStatus!=null?[{label:"HTTP",value:String(t.httpStatus)}]:[]],href:"/server/sites",group:"box"})}for(let t of k){let d=`worker:${e(t.name)}`;if(!e(t.name))continue;a.push({id:d,label:e(t.name),kind:"worker",layer:5,status:h(t.status),sub:`${Number(t.processes??1)} process${Number(t.processes??1)===1?"":"es"}`,facts:[{label:"Processes",value:String(t.processes??1)},{label:"State",value:e(t.status,"unknown")},...e(t.site)?[{label:"Site",value:e(t.site)}]:[]],href:"/operations/jobs",group:"box"})}let A=n.serverScheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:5,status:"ok",sub:"Cron dispatch",facts:[{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs",group:"box"});let l=L.map((t)=>{let d=e(t.name),s=P.find((p)=>p.match.test(d));return s?{service:t,name:d,...s}:null}).filter((t)=>!!t);for(let t of l)a.push({id:`data:${t.name}`,label:t.label,kind:t.kind,layer:6,status:h(t.service.status),sub:t.name,facts:[{label:"Unit",value:t.name},{label:"State",value:e(t.service.status,"unknown")}],href:"/data/services",group:"box"});let x=n.backup??{};if(x.enabled)a.push({id:"backup",label:"Backups",kind:"backup",layer:7,status:"ok",sub:e(x.destination,"destination"),facts:[{label:"Destination",value:e(x.destination,"unknown")},{label:"Schedule",value:e(x.schedule,"unknown")},{label:"Retention",value:`${x.retention??0} copies`},{label:"Last run",value:e(x.last,"unknown")}],href:"/data/backups"});let b=new Set(a.map((t)=>t.id));r(o,{source:"internet",target:"dns",flow:"request",label:"https"},b),r(o,{source:"dns",target:"firewall",flow:"request",label:"443/80"},b),r(o,{source:"firewall",target:"proxy",flow:"request"},b);for(let t of c){let d=`site:${e(t.name)}`;r(o,{source:"proxy",target:d,flow:"request",label:e(t.path)||void 0,status:h(t.status)},b)}for(let t of k){let d=`worker:${e(t.name)}`,s=`site:${e(t.site)}`;if(b.has(s))r(o,{source:s,target:d,flow:"async",label:"queue"},b);else r(o,{source:"proxy",target:d,flow:"async",label:"queue"},b)}for(let t of k)r(o,{source:"scheduler",target:`worker:${e(t.name)}`,flow:"async",label:"dispatch"},b);let D=[...c.map((t)=>`site:${e(t.name)}`),...k.map((t)=>`worker:${e(t.name)}`)];for(let t of l)for(let d of D)r(o,{source:d,target:`data:${t.name}`,flow:"data",label:"localhost"},b);if(l.length&&D.length)q.push("Data-service edges show co-location on the box: every process on it can reach localhost. They are not a declared per-site binding.");for(let t of l)r(o,{source:`data:${t.name}`,target:"backup",flow:"backup",label:"snapshot"},b);for(let t of c)r(o,{source:`site:${e(t.name)}`,target:"backup",flow:"backup"},b);return{mode:"server",project:e(u.project)||e(n.project?.name)||e(f.name,"project"),environment:e(u.environment)||e(n.environment,"production"),provider:e(f.provider,"unknown"),region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:M,groups:[{id:"box",label:e(f.name,"App server"),sub:[e(f.provider),e(f.region),e(f.ip)].filter(Boolean).join(" · ")}],nodes:a,links:o,notes:q}}function $a(n,u={}){let a=[],o=[],q=[],f=n.app??{},c=Array.isArray(n.functions)?n.functions:[],L=Array.isArray(n.queues)?n.queues:[],k=n.metrics??{};if(!c.length)q.push("No Lambda functions were read for this environment, so the compute layer is empty rather than assumed.");a.push({id:"internet",label:"Internet",kind:"internet",layer:0,status:"ok",sub:"Public traffic",facts:[],external:!0});let m=e(f.url),C=m.replace(/^https?:\/\//,"").split("/")[0];a.push({id:"dns",label:C||"Application domain",kind:"dns",layer:1,status:C?"ok":"unknown",sub:"DNS & certificates",facts:[{label:"Endpoint",value:m||"not resolved"}],external:!0});let T=n.waf;if(T)a.push({id:"waf",label:"WAF",kind:"waf",layer:2,status:h(T.status??"active"),sub:e(T.scope,"Managed rules"),facts:[{label:"Web ACL",value:e(T.name,"unnamed")},...T.blocked!=null?[{label:"Blocked (24h)",value:String(T.blocked)}]:[],{label:"Rules",value:String(F(n.wafRules))}],href:"/serverless/firewall"});let i=n.assetsInfo;if(i)a.push({id:"cdn",label:"Asset CDN",kind:"cdn",layer:2,status:"ok",sub:e(i.cdn,"CloudFront"),facts:[{label:"Distribution",value:e(i.cdn,"unknown")},{label:"Custom domain",value:e(i.customDomain,"none")}],href:"/serverless/assets"}),a.push({id:"assets",label:"Asset bucket",kind:"storage",layer:6,status:"ok",sub:e(i.bucket,"S3"),facts:[{label:"Bucket",value:e(i.bucket,"unknown")},...i.files?[{label:"Objects",value:String(i.files)}]:[],...i.sizeMb?[{label:"Size",value:`${i.sizeMb} MB`}]:[]],href:"/serverless/assets"});let E=c.find((s)=>e(s.key).startsWith("http"));a.push({id:"gateway",label:"HTTP entry point",kind:"gateway",layer:3,status:E?"ok":"unknown",sub:"Function URL / API Gateway",facts:[{label:"Endpoint",value:m||"not resolved"},{label:"Invocations (24h)",value:String(k.invocations??0)},...k.errorRatePct!=null?[{label:"Error rate",value:`${k.errorRatePct}%`}]:[]],href:"/serverless/metrics"});for(let s of c){let p=`fn:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.errors??0),R=Number(s.invocations??0);a.push({id:p,label:e(s.key,e(s.name)),kind:"function",layer:4,status:S>0?R&&S/R>0.02?"bad":"warn":R?"ok":"idle",sub:e(s.runtime,"lambda"),facts:[{label:"Function",value:e(s.name)},{label:"Memory",value:`${s.memory??0} MB`},{label:"Timeout",value:`${s.timeout??0}s`},{label:"Invocations (24h)",value:String(R)},{label:"Errors (24h)",value:String(S)},{label:"p95",value:`${s.p95??0} ms`},...s.provisioned?[{label:"Provisioned",value:e(s.provisioned)}]:[]],href:"/serverless/functions"})}for(let s of L){let p=`queue:${e(s.name)}`;if(!e(s.name))continue;let S=Number(s.dlq??0);a.push({id:p,label:e(s.name),kind:"queue",layer:5,status:S>0?"bad":Number(s.visible??0)>0?"warn":"ok",sub:"SQS",facts:[{label:"Visible",value:String(s.visible??0)},{label:"In flight",value:String(s.inFlight??0)},{label:"Processed (24h)",value:String(s.processed??0)},{label:"Dead letter",value:String(S)}],href:"/serverless/queues"})}let g=n.aurora;if(g)a.push({id:"database",label:"Aurora Serverless",kind:"database",layer:6,status:h(g.status),sub:e(g.engine,"aurora"),facts:[{label:"Cluster",value:e(g.id,"unknown")},{label:"Capacity",value:`${g.currentAcu??0} ACU (${g.minAcu??0}–${g.maxAcu??0})`},{label:"Connections",value:String(g.connections??0)}],href:"/serverless/data"});let v=n.proxy;if(v)a.push({id:"rds-proxy",label:"RDS Proxy",kind:"database",layer:5,status:h(v.status),sub:"Connection pooling",facts:[{label:"Proxy",value:e(v.name,"unknown")},{label:"Endpoint",value:e(v.endpoint,"unknown")},{label:"Pooled",value:String(v.pooledConns??0)}],href:"/serverless/data"});let w=n.redis;if(w)a.push({id:"cache",label:"ElastiCache",kind:"cache",layer:6,status:h(w.status),sub:e(w.node,"redis"),facts:[{label:"Group",value:e(w.id,"unknown")},{label:"Hit rate",value:`${w.hitRate??0}%`}],href:"/serverless/data"});let y=n.efs;if(y)a.push({id:"efs",label:"EFS",kind:"filesystem",layer:6,status:h(y.status),sub:e(y.mount,"/mnt/local"),facts:[{label:"File system",value:e(y.id,"unknown")},{label:"Mount",value:e(y.mount,"unknown")},{label:"Size",value:`${y.sizeMb??0} MB`}],href:"/data/volumes"});let A=n.scheduler??{};if(A.enabled)a.push({id:"scheduler",label:"Scheduler",kind:"scheduler",layer:3,status:"ok",sub:e(A.expression,"rate(1 minute)"),facts:[{label:"Expression",value:e(A.expression,"unknown")},{label:"Last run",value:e(A.lastRun,"unknown")}],href:"/operations/jobs"});let l=new Set(a.map((s)=>s.id)),x=l.has("waf")?"waf":"gateway";r(o,{source:"internet",target:"dns",flow:"request",label:"https"},l),r(o,{source:"dns",target:x,flow:"request"},l),r(o,{source:"dns",target:"cdn",flow:"request",label:"assets"},l),r(o,{source:"waf",target:"gateway",flow:"request",label:"allowed"},l),r(o,{source:"cdn",target:"assets",flow:"data",label:"origin"},l);let b=c.filter((s)=>e(s.key).startsWith("http")),D=c.filter((s)=>e(s.key).startsWith("queue")),t=c.filter((s)=>e(s.key).startsWith("cli"));for(let s of b)r(o,{source:"gateway",target:`fn:${e(s.name)}`,flow:"request",label:"invoke"},l);for(let s of t)r(o,{source:"scheduler",target:`fn:${e(s.name)}`,flow:"async",label:"schedule"},l);for(let s of L){for(let p of b)r(o,{source:`fn:${e(p.name)}`,target:`queue:${e(s.name)}`,flow:"async",label:"publish"},l);for(let p of D)r(o,{source:`queue:${e(s.name)}`,target:`fn:${e(p.name)}`,flow:"async",label:"consume"},l)}let d=["rds-proxy","database","cache","efs","assets"];for(let s of c){let p=`fn:${e(s.name)}`;if(l.has("rds-proxy"))r(o,{source:p,target:"rds-proxy",flow:"data",label:"pooled"},l);else r(o,{source:p,target:"database",flow:"data",label:"sql"},l);for(let S of d.filter((R)=>R!=="rds-proxy"&&R!=="database"))r(o,{source:p,target:S,flow:"data"},l)}return r(o,{source:"rds-proxy",target:"database",flow:"data",label:"sql"},l),{mode:"serverless",project:e(u.project)||e(f.name,"application"),environment:e(u.environment)||e(f.env,"production"),provider:"aws",region:e(f.region,"unknown"),generatedAt:new Date().toISOString(),layers:N,groups:[],nodes:a,links:o,notes:q}}
|
|
2
|
+
export{Wr,$a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Fu}from"./chunk-d1psxeqj.js";import"./chunk-y6rgvb7r.js";import"./chunk-3jjggqfj.js";import"./chunk-q3xwh0r8.js";import"./chunk-jdfbahjb.js";export{Fu as buildAndPushServerlessImage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{u}from"./chunk-
|
|
2
|
-
export{
|
|
1
|
+
import{u}from"./chunk-q3xwh0r8.js";class ht{client;region;constructor(e="us-east-1",r){this.region=e,this.client=new u(void 0,{profile:r})}async createRepository(e){let r={repositoryName:e.repositoryName};if(e.imageTagMutability)r.imageTagMutability=e.imageTagMutability;if(e.imageScanningConfiguration)r.imageScanningConfiguration=e.imageScanningConfiguration;if(e.encryptionConfiguration)r.encryptionConfiguration=e.encryptionConfiguration;if(e.tags&&e.tags.length>0)r.tags=e.tags;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.CreateRepository","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repository:t.repository?this.parseRepository(t.repository):void 0}}async describeRepositories(e){let r={};if(e?.repositoryNames&&e.repositoryNames.length>0)r.repositoryNames=e.repositoryNames;if(e?.registryId)r.registryId=e.registryId;if(e?.maxResults)r.maxResults=e.maxResults;if(e?.nextToken)r.nextToken=e.nextToken;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DescribeRepositories","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repositories:t.repositories?.map((i)=>this.parseRepository(i)),nextToken:t.nextToken}}async getAuthorizationToken(e){let r={};if(e&&e.length>0)r.registryIds=e;return{authorizationData:(await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetAuthorizationToken","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})).authorizationData?.map((i)=>({authorizationToken:i.authorizationToken,expiresAt:i.expiresAt,proxyEndpoint:i.proxyEndpoint}))}}async deleteRepository(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;if(e.force!==void 0)r.force=e.force;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DeleteRepository","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{repository:t.repository?this.parseRepository(t.repository):void 0}}async describeImages(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;if(e.imageIds&&e.imageIds.length>0)r.imageIds=e.imageIds;if(e.filter)r.filter=e.filter;if(e.maxResults)r.maxResults=e.maxResults;if(e.nextToken)r.nextToken=e.nextToken;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.DescribeImages","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{imageDetails:t.imageDetails?.map((i)=>this.parseImageDetail(i)),nextToken:t.nextToken}}async batchDeleteImage(e){let r={repositoryName:e.repositoryName,imageIds:e.imageIds};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.BatchDeleteImage","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{imageIds:t.imageIds,failures:t.failures}}async putLifecyclePolicy(e){let r={repositoryName:e.repositoryName,lifecyclePolicyText:e.lifecyclePolicyText};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.PutLifecyclePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,lifecyclePolicyText:t.lifecyclePolicyText}}async getLifecyclePolicy(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetLifecyclePolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,lifecyclePolicyText:t.lifecyclePolicyText,lastEvaluatedAt:t.lastEvaluatedAt}}async setRepositoryPolicy(e){let r={repositoryName:e.repositoryName,policyText:e.policyText};if(e.registryId)r.registryId=e.registryId;if(e.force!==void 0)r.force=e.force;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.SetRepositoryPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,policyText:t.policyText}}async getRepositoryPolicy(e){let r={repositoryName:e.repositoryName};if(e.registryId)r.registryId=e.registryId;let t=await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.GetRepositoryPolicy","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)});return{registryId:t.registryId,repositoryName:t.repositoryName,policyText:t.policyText}}async tagResource(e){let r={resourceArn:e.resourceArn,tags:e.tags};await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.TagResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})}async listTagsForResource(e){let r={resourceArn:e};return{tags:(await this.client.request({service:"ecr",region:this.region,method:"POST",path:"/",headers:{"X-Amz-Target":"AmazonEC2ContainerRegistry_V20150921.ListTagsForResource","Content-Type":"application/x-amz-json-1.1"},body:JSON.stringify(r)})).tags}}createLifecyclePolicyText(e){return JSON.stringify({rules:e.map((r)=>({rulePriority:r.rulePriority,description:r.description,selection:r.selection,action:r.action}))})}async getDockerLoginCommand(){let e=await this.getAuthorizationToken();if(!e.authorizationData?.[0])throw Error("Failed to get authorization token");let r=e.authorizationData[0],t=r.authorizationToken||"",i=r.proxyEndpoint||"";return`echo "${Buffer.from(t,"base64").toString("utf8").split(":")[1]}" | docker login --username AWS --password-stdin ${i}`}getRegistryUri(e){return`${e}.dkr.ecr.${this.region}.amazonaws.com`}parseRepository(e){return{repositoryArn:e.repositoryArn,registryId:e.registryId,repositoryName:e.repositoryName,repositoryUri:e.repositoryUri,createdAt:e.createdAt,imageTagMutability:e.imageTagMutability,imageScanningConfiguration:e.imageScanningConfiguration,encryptionConfiguration:e.encryptionConfiguration}}parseImageDetail(e){return{registryId:e.registryId,repositoryName:e.repositoryName,imageDigest:e.imageDigest,imageTags:e.imageTags,imageSizeInBytes:e.imageSizeInBytes,imagePushedAt:e.imagePushedAt,imageScanStatus:e.imageScanStatus,imageScanFindingsSummary:e.imageScanFindingsSummary}}}
|
|
2
|
+
export{ht};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{es}from"./chunk-7412q5cz.js";export{es as encodeDashboardPayload};
|