@stacksjs/actions 0.70.44 → 0.70.53
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/LICENSE.md +21 -0
- package/dist/action.d.ts +104 -17
- package/dist/blog.d.ts +12 -0
- package/dist/build/frontend-static.d.ts +16 -0
- package/dist/chunk-00qp27jy.js +93 -0
- package/dist/{chunk-jd1yzkq5.js → chunk-23thftnv.js} +1 -1
- package/dist/chunk-4qzb8g3z.js +3 -0
- package/dist/chunk-5dfz9en9.js +920 -0
- package/dist/{chunk-3beht8ja.js → chunk-5hwp0frq.js} +1 -1
- package/dist/{chunk-aw6d8zr3.js → chunk-5pwpk005.js} +2 -2
- package/dist/chunk-604jy79b.js +5 -0
- package/dist/{chunk-wnrgcx3d.js → chunk-63swek9d.js} +2 -2
- package/dist/chunk-67am4dae.js +688 -0
- package/dist/{chunk-gt77jmb5.js → chunk-8gbewxns.js} +1 -1
- package/dist/chunk-8r76qydb.js +240 -0
- package/dist/{chunk-schcaf73.js → chunk-9x17v4x2.js} +2 -2
- package/dist/chunk-aazd6qpv.js +3 -0
- package/dist/{chunk-n2fd1d0m.js → chunk-ag4fy7cx.js} +1 -1
- package/dist/{chunk-2qchdrf9.js → chunk-badehrwa.js} +1 -1
- package/dist/chunk-dbz9dp2h.js +3 -0
- package/dist/{chunk-v0wnrnaa.js → chunk-e8505qz8.js} +2 -2
- package/dist/chunk-jv7ry09n.js +3 -0
- package/dist/{chunk-w418anbq.js → chunk-jve1p4dz.js} +2 -2
- package/dist/chunk-mcwfmqzb.js +283 -0
- package/dist/chunk-n24m8prb.js +3 -0
- package/dist/{chunk-h93n2j40.js → chunk-nm9h5rye.js} +2 -2
- package/dist/{chunk-60qjz7zb.js → chunk-ny1racy0.js} +2 -2
- package/dist/{chunk-2gh7kgpc.js → chunk-p601xr03.js} +1 -1
- package/dist/{chunk-x471rxrn.js → chunk-pqnzp7x8.js} +2 -2
- package/dist/chunk-rj1cbghx.js +17 -0
- package/dist/chunk-rzhs51h1.js +3 -0
- package/dist/{chunk-7bpdkc40.js → chunk-sp5cjdhd.js} +213 -76
- package/dist/chunk-tqax3gbq.js +16 -0
- package/dist/{chunk-c8qt2xst.js → chunk-vsj8ns4p.js} +1 -1
- package/dist/{chunk-rdajkt2s.js → chunk-x8nrbsk1.js} +2 -2
- package/dist/dev/dashboard-utils.d.ts +19 -1
- package/dist/dev/migrate-watcher.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/make.d.ts +19 -0
- package/dist/queue/dlq-purge.d.ts +1 -0
- package/dist/queue/dlq-retry.d.ts +1 -0
- package/dist/queue/dlq.d.ts +1 -0
- package/dist/queue/list.d.ts +1 -0
- package/dist/queue/pause.d.ts +1 -0
- package/dist/queue/quarantine.d.ts +1 -0
- package/dist/queue/resume.d.ts +1 -0
- package/dist/queue/unquarantine.d.ts +1 -0
- package/dist/src/action.js +1 -1
- package/dist/src/actions.js +1 -1
- package/dist/src/add.js +1 -1
- package/dist/src/ai/request-model-access.js +1 -1
- package/dist/src/auth/setup.js +82 -24
- package/dist/src/blog.js +102 -0
- package/dist/src/build/core.js +1 -1
- package/dist/src/build/frontend-static.js +9 -0
- package/dist/src/build/views.js +1 -1
- package/dist/src/build.js +1 -1
- package/dist/src/commit.js +1 -1
- package/dist/src/database/seed.js +1 -1
- package/dist/src/deploy/index.js +38 -45
- package/dist/src/dev/api.js +4 -4
- package/dist/src/dev/dashboard-globals.js +1 -1
- package/dist/src/dev/dashboard-utils.js +1 -1
- package/dist/src/dev/dashboard.js +6 -6
- package/dist/src/dev/docs.js +1 -1
- package/dist/src/dev/index.js +1 -1
- package/dist/src/dev/migrate-watcher.js +2 -0
- package/dist/src/dev/views.js +1 -1
- package/dist/src/discover-packages.js +1 -1
- package/dist/src/examples.js +1 -1
- package/dist/src/generate/component-meta.js +1 -1
- package/dist/src/generate/env-files.js +1 -1
- package/dist/src/generate/ide-helpers.js +1 -1
- package/dist/src/generate/index.js +1 -1
- package/dist/src/generate/lib-entries.js +1 -1
- package/dist/src/generate/vscode-custom-data.js +1 -1
- package/dist/src/helpers/component-meta.js +1 -1
- package/dist/src/helpers/index.js +1 -1
- package/dist/src/helpers/lib-entries.js +1 -1
- package/dist/src/helpers/package-json.js +1 -1
- package/dist/src/helpers/utils.js +1 -1
- package/dist/src/helpers/vscode-custom-data.js +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/key-generate.js +1 -1
- package/dist/src/make-command.js +1 -1
- package/dist/src/make-job.js +1 -1
- package/dist/src/make-policy.js +1 -1
- package/dist/src/make-resource.js +1 -1
- package/dist/src/make.js +1 -1
- package/dist/src/migrate/fresh.js +1 -1
- package/dist/src/orm/base.js +1 -1
- package/dist/src/queue/dlq-purge.js +2 -0
- package/dist/src/queue/dlq-retry.js +2 -0
- package/dist/src/queue/dlq.js +5 -0
- package/dist/src/queue/failed.js +4 -4
- package/dist/src/queue/list.js +5 -0
- package/dist/src/queue/pause.js +2 -0
- package/dist/src/queue/quarantine.js +3 -0
- package/dist/src/queue/resume.js +2 -0
- package/dist/src/queue/unquarantine.js +2 -0
- package/dist/src/release.js +1 -1
- package/dist/src/run-action.js +1 -1
- package/dist/src/scaffold-crud.js +1 -1
- package/dist/src/serve/api.js +1 -1
- package/dist/src/setup/index.js +1 -1
- package/dist/src/setup/ssl.js +1 -1
- package/dist/src/stacks.js +1 -1
- package/dist/src/templates.js +1 -1
- package/dist/src/types.js +1 -1
- package/dist/src/upgrade/dependencies.js +1 -1
- package/dist/src/upgrade/framework-utils.js +1 -1
- package/dist/src/upgrade/framework.js +5 -5
- package/dist/src/upgrade/index.js +1 -1
- package/dist/src/upgrade.js +1 -1
- package/dist/upgrade/framework-utils.d.ts +48 -0
- package/package.json +18 -18
- package/dist/chunk-2kaj93p5.js +0 -3
- package/dist/chunk-3086k7zk.js +0 -184
- package/dist/chunk-67y94dzt.js +0 -658
- package/dist/chunk-6x1m5rkr.js +0 -17
- package/dist/chunk-96b7fcmd.js +0 -3
- package/dist/chunk-d4srk6ma.js +0 -3
- package/dist/chunk-kzhgexj4.js +0 -3
- package/dist/chunk-n1y0gpv6.js +0 -3
- package/dist/chunk-n2x7v39b.js +0 -5
- package/dist/chunk-tc935b45.js +0 -93
- package/dist/chunk-wv5yb5wb.js +0 -101
package/dist/chunk-6x1m5rkr.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{aa as R}from"./chunk-3086k7zk.js";import{Ya as L}from"./chunk-n1y0gpv6.js";import{gb as b}from"./chunk-96b7fcmd.js";import J from"process";import{italic as X,runCommand as V}from"@stacksjs/cli";import{ExitCode as Y}from"@stacksjs/types";import{localUrl as j}from"@stacksjs/config";import{Action as P}from"@stacksjs/enums";import{handleError as W}from"@stacksjs/error-handling";import{log as B}from"@stacksjs/logging";import{frameworkPath as D,path as Z,resolve as U}from"@stacksjs/path";import{createFolder as _,doesFolderExist as K,writeTextFile as w}from"@stacksjs/storage";import{template as f}from"@stacksjs/strings";var M=!1;function Iq(z){M=Boolean(z)}function Jq(){return M}function x(z,...q){return f(R[z],...q)}async function A(z,q){if(M){let G=q.split(`
|
|
3
|
-
`),H=G.slice(0,60).map((I)=>` ${I}`).join(`
|
|
4
|
-
`),Q=G.length>60?`
|
|
5
|
-
${X(`\u2026 ${G.length-60} more lines elided`)}`:"";B.info(`[dry-run] would write ${z} (${G.length} lines)`),J.stdout.write(`${H}${Q}
|
|
6
|
-
|
|
7
|
-
`);return}await w({path:z,data:q})}async function $(z,q,...G){await A(z,x(q,...G))}async function T(z){if(z.component)await u(z);if(z.database)y(z);if(z.function)await h(z);if(z.language)await g(z);if(z.middleware)await r(z);if(z.notification)await F(z);if(z.page)await N(z);if(z.stack)await m(z)}async function Qq(z){return await T(z)}async function Xq(z){try{let q=z.name;B.info("Creating your action..."),await C(z),B.success(`Created ${X(q)} action`)}catch(q){B.error("There was an error creating your action",q),J.exit(Y.FatalError)}}async function u(z){try{let q=z.name;B.info("Creating your component..."),await E(z),B.success(`Created ${X(q)} component`)}catch(q){B.error("There was an error creating your component",q),J.exit(Y.FatalError)}}async function C(z){let q=z.name,G=z,H=Boolean(G.withValidation||z["with-validation"]),Q=Boolean(G.withAuth||z["with-auth"]),I=H&&Q?"actionWithBoth":H?"actionWithValidation":Q?"actionWithAuth":"action";await $(Z.userActionsPath(q),I,q)}async function E(z){let q=z.name;await $(Z.userComponentsPath(`${q}.vue`),"component",q)}function y(z){try{let q=z.name;B.info(`Creating your ${X(q)} database...`),O(z),B.success(`Created ${X(q)} database`)}catch(q){B.error("There was an error creating your database",q),J.exit(Y.FatalError)}}function O(z){B.debug("createDatabase options",z)}function Yq(z){try{let q=z.name;B.info(`Creating your ${X(q)} factory...`),O(z),B.success(`Created ${X(q)} factory`)}catch(q){B.error("There was an error creating your factory",q),J.exit(Y.FatalError)}}async function Zq(z){let q=z.name||"MyFactory",G=q.endsWith("Factory")?q:`${q}Factory`;try{let{path:H}=await import("@stacksjs/path"),I=`${H.userDatabasePath("factories")}/${G}.ts`;if(await Bun.file(I).exists()){B.warn(`Factory ${G} already exists at ${I}`);return}let S=q.replace(/Factory$/,""),v=`import type { ${S}Model } from '@stacksjs/orm'
|
|
8
|
-
|
|
9
|
-
export function ${G}(): Partial<${S}Model> {
|
|
10
|
-
return {
|
|
11
|
-
// Define your factory attributes here
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default ${G}
|
|
16
|
-
`;await A(I,v),B.success(`Created factory: ${I}`)}catch(H){throw B.error(`Failed to create factory ${G}`,H),H}}async function F(z){try{let q=z.name;B.info(`Creating your ${X(q)} notification...`),await l(z),B.success(`Created ${X(q)} notification`)}catch(q){B.error("There was an error creating your notification",q),J.exit(Y.FatalError)}}async function N(z){try{let q=z.name;B.info("Creating your page..."),await k(z),B.success(`Created ${q} page`)}catch(q){B.error("There was an error creating your page",q),J.exit(Y.FatalError)}}async function k(z){let q=z.name;await $(Z.userViewsPath(`${q}.vue`),"page",q)}async function h(z){try{let q=z.name;B.info("Creating your function..."),await d(z),B.success(`Created ${q} function`)}catch(q){B.error("There was an error creating your function",q),J.exit(Y.FatalError)}}async function d(z){let q=z.name;await $(Z.userFunctionsPath(`${q}.ts`),"function",q)}async function g(z){try{let q=z.name;B.info("Creating your translation file..."),await c(z),B.success(`Created ${q} translation file`)}catch(q){B.error("There was an error creating your language.",q),J.exit(Y.FatalError)}}async function c(z){let q=z.name;await $(Z.resourcesPath(`lang/${q}.yml`),"language",q)}async function m(z){try{let q=z.name;B.info(`Creating your ${q} stack...`);let G=U(J.cwd(),q);if(K(G))B.error(`Directory "${q}" already exists`),J.exit(Y.FatalError);await _(G);let H=["app/Actions","app/Models","config","database/migrations","resources/views","resources/components","resources/functions","routes","public"];for(let I of H)await _(U(G,I));let Q=q.replace(/^@[^/]+\//,"").replace(/-stack$/,"");await $(U(G,"package.json"),"stackPackageJson",q,Q),B.success(`Successfully scaffolded your "${q}" stack`),B.info(""),B.info(` cd ${q}`),B.info(" # Add your models, actions, views, etc."),B.info(" # Then publish: bun publish"),B.info(""),B.info(" Users install it with:"),B.info(` buddy stack:install ${q}`)}catch(q){B.error("There was an error creating your stack",q),J.exit(Y.FatalError)}}async function l(z){let q=z.name;try{let G="EmailOptions";if(!K("notifications"))await _("./notifications");if(z.chat)G="ChatOptions";if(z.sms)G="SMSOptions";return await $(Z.userNotificationsPath(`${q}.ts`),"notification",G),!0}catch(G){return W("Error creating notification",G),!1}}async function $q(z){let q=z.name,G="dummy-name";if(!q[0])throw Error("options.name is required and cannot be empty");let H=q[0].toUpperCase()+q.slice(1),Q=D(`database/migrations/${H}.ts`);try{await $(Q,"migration","dummy-name"),B.success(`Successfully created your migration file at stacks/database/migrations/${H}.ts`)}catch(I){B.error(I)}}async function Uq(){await L(P.QueueTable)}async function _q(){let z=await j();B.info("Creating SSL certificate..."),await V(`tlsx ${z}`,{cwd:Z.storagePath("keys")}),B.success("Certificate created"),B.info("Installing SSL certificate..."),await V("tlsx -install",{cwd:Z.storagePath("keys")}),B.success("Certificate installed")}async function Mq(z){let q=z.name;if(!q[0])throw Error("options.name is required and cannot be empty");let G=q[0].toUpperCase()+q.slice(1),H=G.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,"").replace(/([^s])$/,"$1s"),Q=Z.userModelsPath(`${G}.ts`);try{await $(Q,"model",G,H),B.success(`Model created: ${X(`app/Models/${G}.ts`)}`)}catch(I){B.error(I)}}async function r(z){let q=z.name;await $(Z.userMiddlewarePath(`${q}.ts`),"middleware",q)}
|
|
17
|
-
export{Iq as C,Jq as D,T as E,Qq as F,Xq as G,u as H,C as I,E as J,y as K,O as L,Yq as M,Zq as N,F as O,N as P,k as Q,h as R,d as S,g as T,c as U,m as V,l as W,$q as X,Uq as Y,_q as Z,Mq as _,r as $};
|
package/dist/chunk-96b7fcmd.js
DELETED
package/dist/chunk-d4srk6ma.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
class K{name;description;rate;tries;backoff;enabled;path;method;validations;requestFile;handle;model;constructor({name:w,description:y,validations:z,handle:A,rate:B,tries:C,backoff:D,enabled:G,path:H,method:I,requestFile:J,model:j}){if(this.name=w,this.description=y,this.validations=z,this.rate=B,this.tries=C,this.backoff=D,this.enabled=G,this.path=H,this.method=I,this.handle=A,this.requestFile=J,j&&typeof j==="object"&&"name"in j)this.model=j.name;else if(typeof j==="string")this.model=j}}
|
|
3
|
-
export{K as Xa};
|
package/dist/chunk-kzhgexj4.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
var{Glob:U}=globalThis.Bun;var B={user:"person.fill",team:"person.2.fill",subscriber:"envelope.open.fill",subscriberemail:"envelope.fill",post:"doc.text.fill",page:"doc.fill",product:"cube.box.fill",productvariant:"cube.fill",productunit:"scalemass.fill",order:"list.clipboard.fill",orderitem:"list.bullet.clipboard.fill",customer:"person.crop.circle.fill",payment:"creditcard.fill",paymentmethod:"creditcard.and.123",paymentproduct:"creditcard.fill",paymenttransaction:"creditcard.fill",category:"tag.fill",tag:"tag",comment:"bubble.left.fill",author:"person.text.rectangle.fill",notification:"bell.fill",job:"briefcase.fill",log:"list.bullet.rectangle.portrait.fill",campaign:"megaphone.fill",review:"star.fill",coupon:"ticket.fill",giftcard:"giftcard.fill",cart:"cart.fill",cartitem:"cart.badge.plus",taxrate:"percent",transaction:"arrow.left.arrow.right.circle.fill",subscription:"repeat.circle.fill",emaillist:"envelope.badge.person.crop",socialpost:"bubble.left.and.bubble.right.fill",manufacturer:"building.2.fill",shippingmethod:"shippingbox.fill",shippingzone:"map.fill",shippingrate:"dollarsign.circle.fill",deliveryroute:"map.fill",driver:"car.fill",digitaldelivery:"arrow.down.doc.fill",licensekey:"key.fill",loyaltypoint:"star.circle.fill",loyaltyreward:"gift.fill",printdevice:"printer.fill",receipt:"doc.text.fill",waitlistproduct:"clock.fill",waitlistrestaurant:"clock.badge.checkmark.fill",websocket:"antenna.radiowaves.left.and.right",default:"tablecells.fill"},V=new Set(["activity","request","error","failedjob"]),z=new Set(["user","team","subscriber","post","page","product","order","customer","payment","coupon","category","tag","comment","author","notification","job","campaign","review","gift-card"]),Y={user:"data",team:"data",subscriber:"data",activity:"data",campaign:"marketing",emaillist:"marketing",socialpost:"marketing",subscriberemail:"marketing",comment:"content",tag:"content",paymentmethod:"commerce",paymentproduct:"commerce",paymenttransaction:"commerce",subscription:"commerce",deployment:"system",error:"system",failedjob:"system",job:"system",log:"system",notification:"system",release:"system",request:"system"};function E(j){return j.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,"")}function G(j){return B[j.toLowerCase()]||B.default||"database"}function W(j,J,k){if(k)return k;let F=j.includes("/")?(j.split("/")[0]??"").toLowerCase():"";if(F==="commerce")return"commerce";if(F==="content")return"content";if(F==="realtime")return"system";return Y[J.replace(/-/g,"")]??"data"}async function H(j,J,k,F){try{let K=new U("**/*.ts");for await(let Q of K.scan({cwd:j})){if(Q.includes("README")||Q.includes(".d.ts"))continue;let X=Q.replace(/\.ts$/,"").split("/").pop()||"",$=X.toLowerCase();if(X&&!J.has($)&&!V.has($)){J.add($);let Z=E(X);k.push({name:X,icon:G(X),id:Z,category:W(Q,Z,F)})}}}catch{}}async function A(j,J){let k=[],F=new Set;return await Promise.all([H(j,F,k,"userland"),H(J,F,k)]),k.sort((K,Q)=>K.name.localeCompare(Q.name))}function S(j){return j.map((J)=>({id:J.id,name:J.name,icon:J.icon,hasDedicatedPage:z.has(J.id),category:J.category??"data"}))}async function _(j){try{return Bun.serve({port:j,fetch:()=>new Response}).stop(!0),!0}catch{return!1}}async function T(j,J=20){for(let k=0;k<J;k++){let F=j+k;if(await _(F))return F}return j}async function x(j,J=500){let k=Date.now();while(Date.now()-k<J){try{let F=await fetch(`http://localhost:${j}/`,{method:"HEAD"});if(F.ok||F.status===404)return!0}catch{}await new Promise((F)=>setTimeout(F,25))}return!1}function q(j,J,k,F){return J.filter((K)=>(K.category??"data")===k).filter((K)=>!z.has(K.id)&&!F.has(K.id)).map((K)=>({id:`model-${K.id}`,label:K.name,icon:K.icon,url:`${j}/models/${K.id}`}))}function L(j,J,k={}){let F={library:k.library??!0,content:k.content??!0,commerce:k.commerce??!0,marketing:k.marketing??!0,analytics:k.analytics??!0,management:k.management??!0,utilities:k.utilities??!0},K={dashboard:k.data?.dashboard??!0,activity:k.data?.activity??!0,users:k.data?.users??!0,teams:k.data?.teams??!0,subscribers:k.data?.subscribers??!0,allModels:k.data?.allModels??!0},Q=[];if(Q.push({id:"home",title:"Home",items:[{id:"home",label:"Dashboard",icon:"house.fill",url:`${j}/`},{id:"dependencies",label:"Dependencies",icon:"shippingbox.fill",url:`${j}/dependencies`},{id:"health",label:"Health",icon:"heart.text.square.fill",url:`${j}/health`}]}),F.library)Q.push({id:"library",title:"Library",items:[{id:"functions",label:"Functions",icon:"function",url:`${j}/functions`},{id:"packages",label:"Packages",icon:"shippingbox.fill",url:`${j}/packages`}]});if(F.content)Q.push({id:"content",title:"Content",items:[{id:"content-dashboard",label:"Dashboard",icon:"gauge.with.dots.needle.33percent",url:`${j}/content/dashboard`},{id:"files",label:"Files",icon:"folder.fill",url:`${j}/content/files`},{id:"pages",label:"Pages",icon:"doc.fill",url:`${j}/content/pages`},{id:"posts",label:"Posts",icon:"text.bubble.fill",url:`${j}/content/posts`},{id:"categories",label:"Categories",icon:"tag.fill",url:`${j}/content/categories`},{id:"tags",label:"Tags",icon:"tag",url:`${j}/content/tags`},{id:"comments",label:"Comments",icon:"bubble.left.fill",url:`${j}/content/comments`},{id:"authors",label:"Authors",icon:"person.text.rectangle.fill",url:`${j}/content/authors`},{id:"seo",label:"SEO",icon:"magnifyingglass",url:`${j}/content/seo`},...q(j,J,"content",new Set(["page","post","category","tag","comment","author"]))]});Q.push({id:"app",title:"App",items:[{id:"deployments",label:"Deployments",icon:"rocket.fill",url:`${j}/deployments`},{id:"requests",label:"Requests",icon:"arrow.left.arrow.right",url:`${j}/requests`},{id:"realtime",label:"Realtime",icon:"link",url:`${j}/realtime`},{id:"actions",label:"Actions",icon:"bolt.fill",url:`${j}/actions`},{id:"commands",label:"Commands",icon:"terminal.fill",url:`${j}/commands`},{id:"queue",label:"Queue",icon:"list.bullet.rectangle.fill",url:`${j}/queue`},{id:"jobs",label:"Jobs",icon:"briefcase.fill",url:`${j}/jobs`},{id:"inbox",label:"Inbox",icon:"tray.full.fill",url:`${j}/inbox`},{id:"queries",label:"Queries",icon:"magnifyingglass.circle.fill",url:`${j}/queries`},{id:"notifications",label:"Notifications",icon:"bell.fill",url:`${j}/notifications/dashboard`},...q(j,J,"system",new Set)]});let X=[];if(K.dashboard)X.push({id:"data-dashboard",label:"Dashboard",icon:"gauge.with.dots.needle.33percent",url:`${j}/data/dashboard`});if(K.activity)X.push({id:"activity",label:"Activity",icon:"waveform.path.ecg",url:`${j}/data/activity`});if(K.users)X.push({id:"users",label:"Users",icon:"person.crop.circle.fill",url:`${j}/data/users`});if(K.teams)X.push({id:"teams",label:"Teams",icon:"person.3.fill",url:`${j}/data/teams`});if(K.subscribers)X.push({id:"subscribers",label:"Subscribers",icon:"envelope.fill",url:`${j}/data/subscribers`});if(K.allModels)X.push({id:"data-models",label:"All Models",icon:"square.grid.2x2.fill",url:`${j}/models`});let $=J.filter((Z)=>Z.category==="userland"||Z.category==="data"||Z.category===void 0).filter((Z)=>!z.has(Z.id)).map((Z)=>({id:`model-${Z.id}`,label:Z.name,icon:Z.icon,url:`${j}/models/${Z.id}`}));if(Q.push({id:"data",title:"Data",items:[...X,...$]}),F.commerce)Q.push({id:"commerce",title:"Commerce",items:[{id:"commerce-dashboard",label:"Dashboard",icon:"gauge.with.dots.needle.33percent",url:`${j}/commerce/dashboard`},{id:"customers",label:"Customers",icon:"person.crop.circle.fill",url:`${j}/commerce/customers`},{id:"orders",label:"Orders",icon:"list.clipboard.fill",url:`${j}/commerce/orders`},{id:"products",label:"Products",icon:"cube.box.fill",url:`${j}/commerce/products`},{id:"coupons",label:"Coupons",icon:"ticket.fill",url:`${j}/commerce/coupons`},{id:"gift-cards",label:"Gift Cards",icon:"giftcard.fill",url:`${j}/commerce/gift-cards`},{id:"payments",label:"Payments",icon:"creditcard.fill",url:`${j}/commerce/payments`},{id:"delivery",label:"Delivery",icon:"truck.box.fill",url:`${j}/commerce/delivery`},{id:"taxes",label:"Taxes",icon:"percent",url:`${j}/commerce/taxes`},...q(j,J,"commerce",new Set(["customer","order","product","coupon","gift-card","payment","review","category"]))]});if(F.marketing)Q.push({id:"marketing",title:"Marketing",items:[{id:"lists",label:"Lists",icon:"list.bullet",url:`${j}/marketing/lists`},{id:"social-posts",label:"Social Posts",icon:"clock.fill",url:`${j}/marketing/social-posts`},{id:"campaigns",label:"Campaigns",icon:"megaphone.fill",url:`${j}/marketing/campaigns`},{id:"marketing-reviews",label:"Reviews",icon:"star.fill",url:`${j}/marketing/reviews`},...q(j,J,"marketing",new Set(["campaign"]))]});if(F.analytics)Q.push({id:"analytics",title:"Analytics",items:[{id:"analytics-web",label:"Web",icon:"globe",url:`${j}/analytics/web`},{id:"analytics-blog",label:"Blog",icon:"doc.text.fill",url:`${j}/analytics/blog`},{id:"analytics-commerce",label:"Commerce",icon:"cart.fill",url:`${j}/analytics/commerce/web`},{id:"analytics-marketing",label:"Marketing",icon:"megaphone.fill",url:`${j}/analytics/marketing`}]});if(F.management)Q.push({id:"management",title:"Management",items:[{id:"cloud",label:"Cloud",icon:"cloud.fill",url:`${j}/cloud`},{id:"servers",label:"Servers",icon:"server.rack",url:`${j}/servers`},{id:"serverless",label:"Serverless",icon:"bolt.horizontal.circle.fill",url:`${j}/serverless`},{id:"dns",label:"DNS",icon:"network",url:`${j}/dns`},{id:"mailboxes",label:"Mailboxes",icon:"tray.full.fill",url:`${j}/mailboxes`},{id:"logs",label:"Logs",icon:"list.bullet.rectangle.portrait.fill",url:`${j}/logs`}]});if(F.utilities)Q.push({id:"utilities",title:"Utilities",items:[{id:"buddy",label:"AI Buddy",icon:"bubble.left.and.bubble.right.fill",url:`${j}/buddy`},{id:"environment",label:"Environment",icon:"key.fill",url:`${j}/environment`},{id:"access-tokens",label:"Access Tokens",icon:"key.horizontal.fill",url:`${j}/access-tokens`},{id:"settings",label:"Settings",icon:"gear",url:`${j}/settings/billing`}]});return{sections:Q,minWidth:200,maxWidth:280}}function O(j){return`http://localhost:${j}/?native-sidebar=1`}
|
|
3
|
-
export{B as sa,V as ta,z as ua,E as va,G as wa,H as xa,A as ya,S as za,_ as Aa,T as Ba,x as Ca,L as Da,O as Ea};
|
package/dist/chunk-n1y0gpv6.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{fb as r,gb as M}from"./chunk-96b7fcmd.js";var o={};r(o,{runActions:()=>i,runAction:()=>n,hasAction:()=>y});import{existsSync as c}from"fs";import T from"process";import{buddyOptions as v,runCommand as s,runCommands as e}from"@stacksjs/cli";import{err as O}from"@stacksjs/error-handling";import{log as I}from"@stacksjs/logging";import*as H from"@stacksjs/path";async function a(z){let J=[];J.push(H.actionsPath(`src/${z}.ts`));try{let V=import.meta.resolve("@stacksjs/actions/package.json");if(V){let Y=new URL(V).pathname,K=Y.slice(0,Y.lastIndexOf("/"));J.push(`${K}/dist/src/${z}.js`),J.push(`${K}/src/${z}.ts`)}}catch{}for(let V of J)if(await Bun.file(V).exists())return V;return null}async function n(z,J){if(I.debug(`[action] Running: ${z}`),z==="dev/views")try{let Z=H.projectPath("pantry");if(!T.env.NODE_PATH?.includes(Z))T.env.NODE_PATH=T.env.NODE_PATH?`${Z}:${T.env.NODE_PATH}`:Z,M("module").Module._initPaths?.();let R=H.projectPath("serve.ts");if(await Bun.file(R).exists())await import(R);else{let N=Number(T.env.PORT)||3000,_=`http://127.0.0.1:${Number(T.env.PORT_API)||3008}`,D;try{({serve:D}=await import(H.projectPath("pantry/bun-plugin-stx/dist/serve.js")))}catch{({serve:D}=await import("./chunk-wv5yb5wb.js"))}let b;try{let G=H.projectPath("pantry/@stacksjs/stx/dist/index.js");if(await Bun.file(G).exists())b=await import(G)}catch{}let j="auth-token";try{let{config:G}=await import("@stacksjs/config");j=G?.auth?.defaultTokenName??j}catch{}let{AsyncLocalStorage:h}=await import("async_hooks"),w=new h;globalThis.requestContext={cookie(G){return w.getStore()?.cookies?.[G]??null},url(){return w.getStore()?.url??""}};let u=(G)=>{let Q={},U=G.headers.get("cookie")||"";if(!U)return Q;for(let B of U.split(";")){let E=B.trim(),$=E.indexOf("=");if($===-1)continue;let L=E.slice(0,$).trim(),x=E.slice($+1).trim();if(!L)continue;try{Q[L]=decodeURIComponent(x)}catch{Q[L]=x}}return Q},l=async(G)=>{let Q=new URL(G.url),U=`${_}${Q.pathname}${Q.search}`,B=new Headers(G.headers);B.delete("host"),B.delete("content-length"),B.set("x-forwarded-host",Q.host),B.set("x-forwarded-proto",Q.protocol.replace(":",""));let E=G.method==="GET"||G.method==="HEAD"?void 0:await G.arrayBuffer(),$=await fetch(U,{method:G.method,headers:B,body:E,redirect:"manual"}),L=new Headers($.headers);return L.delete("content-length"),L.delete("content-encoding"),new Response($.body,{status:$.status,statusText:$.statusText,headers:L})},P=async(G)=>{for(let Q of G)try{if(await Bun.file(H.projectPath(Q)).exists())return Q}catch{}return G[0]},d=await P(["resources/views/layouts","resources/layouts"]),p=await P(["resources/views/components","resources/components"]);await D({patterns:["resources/views","storage/framework/defaults/resources/views"],port:N,componentsDir:"storage/framework/defaults/resources/components",layoutsDir:d,partialsDir:p,fallbackPartialsDir:"resources/views",quiet:!0,...b&&{stxModule:b},auth:{cookieName:j,redirectTo:"/login"},onRequest:async(G)=>{if(new URL(G.url).pathname.startsWith("/api/"))return l(G);return w.enterWith({cookies:u(G),url:G.url}),null}})}return{ok:!0,value:{}}}catch(Z){return O(`Failed to start dev server: ${Z}`)}if(!(z.includes("/")||["dev","build","install","upgrade","migrate"].some((Z)=>z.startsWith(Z)))){let Z=new Bun.Glob("**/*.{ts,js}"),R={cwd:H.userActionsPath(),onlyFiles:!0,absolute:!0},F=[],N=H.userActionsPath();for await(let X of Z.scan(R)){if(X.replace(`${N}/`,"").replace(/\.(ts|js)$/,"")===z||X.endsWith(`${z}.ts`)||X.endsWith(`${z}.js`))return I.debug(`[action] Resolved: ${z} \u2192 ${X}`),await(await import(X)).default.handle(void 0);F.push(X)}for(let X of F)try{let _=await import(X);if(_.name===z)return I.debug(`[action] Resolved: ${z} \u2192 ${X}`),await _.handle()}catch(_){}}let Y=await a(z);if(!Y)return O(`Action '${z}' not found in storage/framework/core/actions/src or @stacksjs/actions`);I.debug(`[action] Resolved: ${z} \u2192 ${Y}`);let K=z.startsWith("dev/"),W=K?"--watch":"",k=K?"":v(J)||"",f=`bun ${W} ${Y} ${k}`.trimEnd(),C=H.projectPath("pantry"),A=T.env.NODE_PATH,m=A?`${C}:${A}`:C,S=J?.verbose||K&&!J?.quiet,q={cwd:J?.cwd||H.projectPath(),...J,stdout:S?"inherit":void 0,stderr:S?"inherit":void 0,env:{...J?.env,NODE_PATH:m}},g=await s(f,q);return I.debug(`[action] Completed: ${z}`),g}async function i(z,J){if(!z.length)return O("No actions were specified");for(let W of z)if(!y(W))return O(`The specified action "${W}" does not exist`);let V=v(J)||"",Y={cwd:J?.cwd||H.projectPath(),...J},K=z.map((W)=>`bun ${H.relativeActionsPath(`src/${W}.ts`)} ${V}`);return await e(K,Y)}function y(z){let J=[`${z}.ts`,`${z}`,`Dashboard/${z}.ts`,`Dashboard/${z}`,`Buddy/${z}.ts`,`Buddy/${z}`],V=[`src/${z}.ts`,`src/${z}`,`${z}.ts`,`${z}`];return[...J.map((K)=>H.userActionsPath(K)),...V.map((K)=>H.actionsPath(K))].some((K)=>c(K))}
|
|
3
|
-
export{n as Ya,i as Za,y as _a,o as $a};
|
package/dist/chunk-n2x7v39b.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import"./chunk-96b7fcmd.js";var q={type:"aws",useLoadBalancer:!0,app:{name:"app-server-1",domain:"stacksjs.com",region:"us-east-1",type:"app",size:"t3.micro",diskSize:20,serverOS:"ubuntu-20-lts-x86_64",bunVersion:"1.1.26",database:"sqlite",databaseName:"stacks"},app2:{name:"app-server-2",domain:"stacksjs.com",instanceType:"t3.micro",userData:`#!/bin/bash
|
|
3
|
-
echo "Hello World from App Server 2!" > /tmp/test.txt
|
|
4
|
-
chown ubuntu:ubuntu /tmp/test.txt
|
|
5
|
-
`},web:{name:"web-server",domain:"ow3.org",region:"us-east-1",type:"web",size:"t3.micro",diskSize:20,serverOS:"ubuntu-20-lts-x86_64",bunVersion:"1.1.26"},cache:{name:"cache-server",domain:"stacksjs.com",region:"us-east-1",type:"cache",size:"t3.micro",diskSize:20,serverOS:"ubuntu-20-lts-x86_64",bunVersion:"1.1.26"}};import{env as m}from"@stacksjs/env";var C={project:{name:"stacks",slug:"stacks",region:"us-east-1"},mode:"server",environments:{production:{type:"production",region:"us-east-1",variables:{NODE_ENV:"production",LOG_LEVEL:"info"}},staging:{type:"staging",region:"us-east-1",variables:{NODE_ENV:"staging",LOG_LEVEL:"debug"}},development:{type:"development",region:"us-east-1",variables:{NODE_ENV:"development",LOG_LEVEL:"debug"}}},infrastructure:{compute:{instances:1,size:"small",disk:{size:20,type:"ssd",encrypted:!0}},servers:{app:q.app},containers:{api:{cpu:512,memory:1024,port:3000,healthCheck:"/health",desiredCount:2,autoScaling:{min:1,max:10,targetCpuUtilization:70,targetMemoryUtilization:80}}},loadBalancer:{enabled:!0,type:"application",healthCheck:{path:"/health",interval:30,healthyThreshold:2,unhealthyThreshold:5}},ssl:{enabled:!0,provider:"acm",domains:m.SSL_DOMAINS?.split(",")||["stacksjs.com","www.stacksjs.com"],redirectHttp:!0,letsEncrypt:{email:m.LETSENCRYPT_EMAIL||"admin@stacksjs.com",staging:!1,autoRenew:!0}},dns:{domain:m.APP_DOMAIN||"stacksjs.com",hostedZoneId:m.AWS_HOSTED_ZONE_ID||"Z01455702Q7952O6RCY37"},storage:{public:{public:!0,encryption:!0,versioning:!0,website:{indexDocument:"index.html",errorDocument:"index.html"}},private:{encryption:!0,versioning:!0},docs:{public:!0,encryption:!0,versioning:!0,path:"/docs",pathRewriteStyle:"flat",website:{indexDocument:"index.html",errorDocument:"404.html"}},blog:{public:!0,encryption:!0,versioning:!0,path:"/blog",website:{indexDocument:"index.html",errorDocument:"404.html"}},logs:{encryption:!0,versioning:!1},backups:{encryption:!0,versioning:!0},email:{public:!1,encryption:!0,versioning:!1}},functions:{},queues:{jobs:{visibilityTimeout:120,deadLetterQueue:!0,maxReceiveCount:3}},databases:{},cdn:{},monitoring:{}},sites:{main:{root:"/var/www/app",path:"/",domain:m.APP_DOMAIN||"stacksjs.com"}}},w={},E=w;export{C as tsCloud,E as default};
|
package/dist/chunk-tc935b45.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
// @bun
|
|
2
|
-
import{gb as L}from"./chunk-96b7fcmd.js";import C from"process";import{log as D}from"@stacksjs/cli";async function S(){try{return(await import("./chunk-n2x7v39b.js")).tsCloud||null}catch{return null}}async function N(){let G=await S();return{name:G?.project?.name||"stacks",region:G?.project?.region||"us-east-1"}}async function b(G){try{let{AWSClient:Q}=await import("@stacksjs/ts-cloud"),J=new Q,_=new URLSearchParams({Action:"GetCallerIdentity",Version:"2011-06-15"}),K=await J.request({service:"sts",region:G,method:"POST",path:"/",body:_.toString()}),j=String(K).match(/<Account>(\d+)<\/Account>/);if(j&&j[1])return j[1];return C.env.AWS_ACCOUNT_ID||""}catch(Q){return C.env.AWS_ACCOUNT_ID||""}}async function f(G){let{environment:Q}=G,J=await S();if(!J)throw Error("Cloud configuration not found. Ensure config/cloud.ts exports tsCloud.");let{InfrastructureGenerator:_}=await import("@stacksjs/ts-cloud"),j=new _({config:J,environment:Q}).generate().getBuilder().build();return JSON.stringify(j)}function v(G){let Q={green:"\x1B[32m",yellow:"\x1B[33m",red:"\x1B[31m",cyan:"\x1B[36m",gray:"\x1B[90m",reset:"\x1B[0m"};if(G.includes("COMPLETE")&&!G.includes("ROLLBACK"))return`${Q.green}${G}${Q.reset}`;if(G.includes("IN_PROGRESS"))return`${Q.yellow}${G}${Q.reset}`;if(G.includes("FAILED")||G.includes("ROLLBACK"))return`${Q.red}${G}${Q.reset}`;if(G.includes("DELETE"))return`${Q.gray}${G}${Q.reset}`;return G}async function p(G){let{region:Q,domain:J,sslDomains:_,hostedZoneId:K,albDnsName:j,stackName:Y}=G;console.log(""),console.log("Setting up SSL certificate...");try{let{Route53Client:$,ACMClient:w,AWSClient:F}=await import("@stacksjs/ts-cloud"),M=new $(Q),V=new w(Q),W=new F;console.log(` Requesting SSL certificate for ${J}...`);let P=await V.requestCertificate({DomainName:_[0]??J,SubjectAlternativeNames:_.length>1?_.slice(1):void 0,ValidationMethod:"DNS"});console.log(` Certificate ARN: ${P.CertificateArn}`),await new Promise((R)=>setTimeout(R,5000));let U=await V.describeCertificate({CertificateArn:P.CertificateArn});console.log(" Adding DNS validation records...");for(let R of U.DomainValidationOptions||[])if(R.ResourceRecord)await M.changeResourceRecordSets({HostedZoneId:K,ChangeBatch:{Changes:[{Action:"UPSERT",ResourceRecordSet:{Name:R.ResourceRecord.Name,Type:"CNAME",TTL:300,ResourceRecords:[{Value:R.ResourceRecord.Value}]}}]}});console.log("\u2713 Validation records added"),console.log(" Waiting for certificate validation (this may take 1-5 minutes)...");for(let R=0;R<30;R++){let Z=await V.describeCertificate({CertificateArn:P.CertificateArn});if(Z.Status==="ISSUED"){console.log("\u2713 Certificate issued!");let{AWSCloudFormationClient:A}=await import("@stacksjs/ts-cloud"),B=await new A(Q).listStackResources(Y),I=B.StackResourceSummaries.find((O)=>O.LogicalResourceId==="ApplicationLoadBalancer")?.PhysicalResourceId,X=B.StackResourceSummaries.find((O)=>O.LogicalResourceId==="ECSTargetGroup")?.PhysicalResourceId||B.StackResourceSummaries.find((O)=>O.LogicalResourceId==="WebTargetGroup")?.PhysicalResourceId;if(I&&X){console.log(" Creating HTTPS listener...");let O=new URLSearchParams({Action:"CreateListener",LoadBalancerArn:I,Protocol:"HTTPS",Port:"443","Certificates.member.1.CertificateArn":P.CertificateArn,"DefaultActions.member.1.Type":"forward","DefaultActions.member.1.TargetGroupArn":X,Version:"2015-12-01"});await W.request({service:"elasticloadbalancing",region:Q,method:"POST",path:"/",body:O.toString()}),console.log("\u2713 HTTPS listener created!"),console.log(" Configuring HTTP to HTTPS redirect...");let h=new URLSearchParams({Action:"DescribeListeners",LoadBalancerArn:I,Version:"2015-12-01"}),H=await W.request({service:"elasticloadbalancing",region:Q,method:"POST",path:"/",body:h.toString()}),x=H?.DescribeListenersResponse?.DescribeListenersResult?.Listeners?.member||H?.DescribeListenersResult?.Listeners?.member,T=(Array.isArray(x)?x:x?[x]:[]).find((y)=>y.Port==="80"||y.Port===80);if(T){let y=new URLSearchParams({Action:"ModifyListener",ListenerArn:T.ListenerArn,"DefaultActions.member.1.Type":"redirect","DefaultActions.member.1.RedirectConfig.Protocol":"HTTPS","DefaultActions.member.1.RedirectConfig.Port":"443","DefaultActions.member.1.RedirectConfig.StatusCode":"HTTP_301",Version:"2015-12-01"});await W.request({service:"elasticloadbalancing",region:Q,method:"POST",path:"/",body:y.toString()}),console.log("\u2713 HTTP to HTTPS redirect configured!")}}let z=B.StackResourceSummaries.find((O)=>O.LogicalResourceId==="CloudFrontDistribution")?.PhysicalResourceId;if(z){console.log(" Updating CloudFront distribution with SSL certificate...");let O=await W.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${z}/config`}),h=O._headers?.etag||O._headers?.ETag,H=O.DistributionConfig;if(H&&h){H.Aliases={Quantity:_.length,Items:_},H.ViewerCertificate={ACMCertificateArn:P.CertificateArn,SSLSupportMethod:"sni-only",MinimumProtocolVersion:"TLSv1.2_2021",CloudFrontDefaultCertificate:!1};let x=`<?xml version="1.0" encoding="UTF-8"?>
|
|
3
|
-
<DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
|
|
4
|
-
<CallerReference>${H.CallerReference}</CallerReference>
|
|
5
|
-
<Aliases>
|
|
6
|
-
<Quantity>${_.length}</Quantity>
|
|
7
|
-
<Items>
|
|
8
|
-
${_.map((q)=>` <CNAME>${q}</CNAME>`).join(`
|
|
9
|
-
`)}
|
|
10
|
-
</Items>
|
|
11
|
-
</Aliases>
|
|
12
|
-
<DefaultRootObject>${H.DefaultRootObject||"index.html"}</DefaultRootObject>
|
|
13
|
-
<Origins>
|
|
14
|
-
<Quantity>${H.Origins?.Quantity||0}</Quantity>
|
|
15
|
-
<Items>
|
|
16
|
-
${(H.Origins?.Items||[]).map((q)=>` <Origin>
|
|
17
|
-
<Id>${q.Id}</Id>
|
|
18
|
-
<DomainName>${q.DomainName}</DomainName>
|
|
19
|
-
${q.OriginPath?`<OriginPath>${q.OriginPath}</OriginPath>`:"<OriginPath></OriginPath>"}
|
|
20
|
-
${q.S3OriginConfig?`<S3OriginConfig><OriginAccessIdentity>${q.S3OriginConfig.OriginAccessIdentity||""}</OriginAccessIdentity></S3OriginConfig>`:""}
|
|
21
|
-
${q.CustomOriginConfig?`<CustomOriginConfig>
|
|
22
|
-
<HTTPPort>${q.CustomOriginConfig.HTTPPort}</HTTPPort>
|
|
23
|
-
<HTTPSPort>${q.CustomOriginConfig.HTTPSPort}</HTTPSPort>
|
|
24
|
-
<OriginProtocolPolicy>${q.CustomOriginConfig.OriginProtocolPolicy}</OriginProtocolPolicy>
|
|
25
|
-
<OriginSslProtocols><Quantity>${q.CustomOriginConfig.OriginSslProtocols?.Quantity||1}</Quantity><Items>${(q.CustomOriginConfig.OriginSslProtocols?.Items||["TLSv1.2"]).map((T)=>`<SslProtocol>${T}</SslProtocol>`).join("")}</Items></OriginSslProtocols>
|
|
26
|
-
</CustomOriginConfig>`:""}
|
|
27
|
-
${q.OriginAccessControlId?`<OriginAccessControlId>${q.OriginAccessControlId}</OriginAccessControlId>`:""}
|
|
28
|
-
<ConnectionAttempts>${q.ConnectionAttempts||3}</ConnectionAttempts>
|
|
29
|
-
<ConnectionTimeout>${q.ConnectionTimeout||10}</ConnectionTimeout>
|
|
30
|
-
</Origin>`).join(`
|
|
31
|
-
`)}
|
|
32
|
-
</Items>
|
|
33
|
-
</Origins>
|
|
34
|
-
<DefaultCacheBehavior>
|
|
35
|
-
<TargetOriginId>${H.DefaultCacheBehavior?.TargetOriginId}</TargetOriginId>
|
|
36
|
-
<ViewerProtocolPolicy>${H.DefaultCacheBehavior?.ViewerProtocolPolicy||"redirect-to-https"}</ViewerProtocolPolicy>
|
|
37
|
-
<AllowedMethods>
|
|
38
|
-
<Quantity>${H.DefaultCacheBehavior?.AllowedMethods?.Quantity||3}</Quantity>
|
|
39
|
-
<Items>${(H.DefaultCacheBehavior?.AllowedMethods?.Items||["GET","HEAD","OPTIONS"]).map((q)=>`<Method>${q}</Method>`).join("")}</Items>
|
|
40
|
-
<CachedMethods>
|
|
41
|
-
<Quantity>${H.DefaultCacheBehavior?.AllowedMethods?.CachedMethods?.Quantity||2}</Quantity>
|
|
42
|
-
<Items>${(H.DefaultCacheBehavior?.AllowedMethods?.CachedMethods?.Items||["GET","HEAD"]).map((q)=>`<Method>${q}</Method>`).join("")}</Items>
|
|
43
|
-
</CachedMethods>
|
|
44
|
-
</AllowedMethods>
|
|
45
|
-
<Compress>${H.DefaultCacheBehavior?.Compress!==!1}</Compress>
|
|
46
|
-
<CachePolicyId>${H.DefaultCacheBehavior?.CachePolicyId||"658327ea-f89d-4fab-a63d-7e88639e58f6"}</CachePolicyId>
|
|
47
|
-
${H.DefaultCacheBehavior?.OriginRequestPolicyId?`<OriginRequestPolicyId>${H.DefaultCacheBehavior.OriginRequestPolicyId}</OriginRequestPolicyId>`:""}
|
|
48
|
-
</DefaultCacheBehavior>
|
|
49
|
-
<CacheBehaviors>
|
|
50
|
-
<Quantity>${H.CacheBehaviors?.Quantity||0}</Quantity>
|
|
51
|
-
${H.CacheBehaviors?.Quantity>0?`<Items>
|
|
52
|
-
${(H.CacheBehaviors?.Items||[]).map((q)=>` <CacheBehavior>
|
|
53
|
-
<PathPattern>${q.PathPattern}</PathPattern>
|
|
54
|
-
<TargetOriginId>${q.TargetOriginId}</TargetOriginId>
|
|
55
|
-
<ViewerProtocolPolicy>${q.ViewerProtocolPolicy}</ViewerProtocolPolicy>
|
|
56
|
-
<AllowedMethods>
|
|
57
|
-
<Quantity>${q.AllowedMethods?.Quantity||3}</Quantity>
|
|
58
|
-
<Items>${(q.AllowedMethods?.Items||["GET","HEAD","OPTIONS"]).map((T)=>`<Method>${T}</Method>`).join("")}</Items>
|
|
59
|
-
<CachedMethods>
|
|
60
|
-
<Quantity>${q.AllowedMethods?.CachedMethods?.Quantity||2}</Quantity>
|
|
61
|
-
<Items>${(q.AllowedMethods?.CachedMethods?.Items||["GET","HEAD"]).map((T)=>`<Method>${T}</Method>`).join("")}</Items>
|
|
62
|
-
</CachedMethods>
|
|
63
|
-
</AllowedMethods>
|
|
64
|
-
<Compress>${q.Compress!==!1}</Compress>
|
|
65
|
-
<CachePolicyId>${q.CachePolicyId}</CachePolicyId>
|
|
66
|
-
${q.OriginRequestPolicyId?`<OriginRequestPolicyId>${q.OriginRequestPolicyId}</OriginRequestPolicyId>`:""}
|
|
67
|
-
</CacheBehavior>`).join(`
|
|
68
|
-
`)}
|
|
69
|
-
</Items>`:""}
|
|
70
|
-
</CacheBehaviors>
|
|
71
|
-
<CustomErrorResponses>
|
|
72
|
-
<Quantity>${H.CustomErrorResponses?.Quantity||0}</Quantity>
|
|
73
|
-
${H.CustomErrorResponses?.Quantity>0?`<Items>
|
|
74
|
-
${(H.CustomErrorResponses?.Items||[]).map((q)=>` <CustomErrorResponse>
|
|
75
|
-
<ErrorCode>${q.ErrorCode}</ErrorCode>
|
|
76
|
-
<ResponsePagePath>${q.ResponsePagePath}</ResponsePagePath>
|
|
77
|
-
<ResponseCode>${q.ResponseCode}</ResponseCode>
|
|
78
|
-
<ErrorCachingMinTTL>${q.ErrorCachingMinTTL}</ErrorCachingMinTTL>
|
|
79
|
-
</CustomErrorResponse>`).join(`
|
|
80
|
-
`)}
|
|
81
|
-
</Items>`:""}
|
|
82
|
-
</CustomErrorResponses>
|
|
83
|
-
<Comment>${H.Comment||""}</Comment>
|
|
84
|
-
<PriceClass>${H.PriceClass||"PriceClass_100"}</PriceClass>
|
|
85
|
-
<Enabled>${H.Enabled!==!1}</Enabled>
|
|
86
|
-
<ViewerCertificate>
|
|
87
|
-
<ACMCertificateArn>${P.CertificateArn}</ACMCertificateArn>
|
|
88
|
-
<SSLSupportMethod>sni-only</SSLSupportMethod>
|
|
89
|
-
<MinimumProtocolVersion>TLSv1.2_2021</MinimumProtocolVersion>
|
|
90
|
-
</ViewerCertificate>
|
|
91
|
-
<HttpVersion>${H.HttpVersion||"http2and3"}</HttpVersion>
|
|
92
|
-
<IsIPV6Enabled>${H.IsIPV6Enabled!==!1}</IsIPV6Enabled>
|
|
93
|
-
</DistributionConfig>`;await W.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${z}/config`,headers:{"Content-Type":"application/xml","If-Match":h},body:x}),console.log("\u2713 CloudFront distribution updated with SSL certificate!")}}console.log(""),console.log(`\u2713 SSL setup complete! https://${J} should be accessible shortly.`),console.log("");return}if(Z.Status==="FAILED"){console.log("\u2717 Certificate validation failed!");return}await new Promise((A)=>setTimeout(A,1e4))}console.log("\u26A0 Certificate validation timed out. Please check AWS Console.")}catch($){console.log(`\u2717 DNS/SSL setup failed: ${$.message}`),console.log(" You can manually set up DNS and SSL using ./buddy cloud:ssl")}}async function g(G){let{environment:Q,region:J,waitForCompletion:_=!0,verbose:K=!1}=G,Y=(await N()).name,$=`${Y}-cloud`;if(K)console.log(`Deploying ${$} to ${J}...`);try{let{AWSCloudFormationClient:w}=await import("@stacksjs/ts-cloud"),F=new w(J),M=await S(),V=M?.infrastructure?.compute?.mode||M?.mode||"server";if(K)console.log(`Generating CloudFormation template (${V} mode)...`);let W=await f({environment:Q,projectName:Y}),P=51200,U;if(Buffer.byteLength(W,"utf-8")>P){if(K)console.log(`Template exceeds inline limit (${Buffer.byteLength(W,"utf-8")} bytes), uploading to S3...`);let{S3Client:X,AWSClient:z}=await import("@stacksjs/ts-cloud"),O=new X(J),h=new z,H=`${Y}-cf-templates-${J}`;try{await h.request({service:"s3",region:J,method:"HEAD",path:`/${H}`,bucket:H})}catch{let q=J==="us-east-1"?"":`<CreateBucketConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><LocationConstraint>${J}</LocationConstraint></CreateBucketConfiguration>`;await h.request({service:"s3",region:J,method:"PUT",path:`/${H}`,bucket:H,body:q||void 0})}let x=`${$}/template-${Date.now()}.json`;if(await O.putObject({bucket:H,key:x,body:W,contentType:"application/json"}),U=`https://${H}.s3.${J}.amazonaws.com/${x}`,K)console.log(`Template uploaded to: ${U}`)}let R=U?{templateUrl:U}:{templateBody:W},Z=!1,A=!1;try{let X=(await F.describeStacks({stackName:$})).Stacks?.[0];if(X&&X.StackStatus){if(K)console.log(`Current status: ${v(X.StackStatus)}`);if(Z=!0,A=!0,X.StackStatus.endsWith("_IN_PROGRESS")){console.log(`Stack is busy (${X.StackStatus}). Waiting for current operation to finish...`);let z=X.StackStatus.startsWith("DELETE")?"stack-delete-complete":X.StackStatus.startsWith("CREATE")?"stack-create-complete":"stack-update-complete";try{await F.waitForStack($,z)}catch{}try{let O=(await F.describeStacks({stackName:$})).Stacks?.[0];if(!O||!O.StackStatus)Z=!1,A=!1;else{if(K)console.log(`Stack settled to: ${v(O.StackStatus)}`);X.StackStatus=O.StackStatus}}catch{Z=!1,A=!1}}if(X.StackStatus==="UPDATE_ROLLBACK_COMPLETE")console.log("Stack rolled back from a previous update. Re-deploying...");else if(X.StackStatus==="DELETE_COMPLETE")Z=!1,A=!1;else if(X.StackStatus==="ROLLBACK_COMPLETE"||X.StackStatus==="ROLLBACK_FAILED"||X.StackStatus==="CREATE_FAILED"){console.log(`Stack is in ${X.StackStatus} state. Deleting before recreating...`),await F.deleteStack($),await F.waitForStack($,"stack-delete-complete"),console.log("Cleaning up retained resources...");try{let{S3Client:z}=await import("@stacksjs/ts-cloud"),O=new z(J),h=await b(J),H=`${Y}-${Q}-assets-${h}`,x=`${Y}-${Q}-frontend-${h}`;if(K)console.log(` Checking bucket: ${H}`);try{await O.emptyAndDeleteBucket(H),console.log(`\u2713 Deleted retained bucket: ${H}`)}catch(q){if(!q.message?.includes("NoSuchBucket")&&!q.message?.includes("does not exist"))console.log(`\u26A0 Could not delete assets bucket: ${q.message}`);else if(K)console.log(" No retained assets bucket to clean up")}if(K)console.log(` Checking bucket: ${x}`);try{await O.emptyAndDeleteBucket(x),console.log(`\u2713 Deleted retained bucket: ${x}`)}catch(q){if(!q.message?.includes("NoSuchBucket")&&!q.message?.includes("does not exist"))console.log(`\u26A0 Could not delete frontend bucket: ${q.message}`);else if(K)console.log(" No retained frontend bucket to clean up")}}catch(z){console.log(`\u26A0 Cleanup error: ${z.message}`)}Z=!1,A=!1}}}catch{Z=!1}if(Z){console.log("Updating stack..."),console.log("");try{let X=U?{templateURL:U}:{templateBody:W};if(await F.updateStack({stackName:$,...X,capabilities:["CAPABILITY_IAM","CAPABILITY_NAMED_IAM"],tags:[{Key:"Environment",Value:Q},{Key:"Project",Value:Y},{Key:"ManagedBy",Value:"stacks"}]}),_)console.log(` ${"Resource".padEnd(35)} ${"Type".padEnd(30)} Status`),console.log(" "+"\u2500".repeat(85)),await F.waitForStack($,"stack-update-complete"),console.log("")}catch(X){if(X.message?.includes("No updates are to be performed"))console.log("\u2713 Stack is up to date (no changes)");else throw X}}else{console.log("Checking for retained resources...");try{let{S3Client:O}=await import("@stacksjs/ts-cloud"),h=new O(J),H=await b(J),x=`${Y}-${Q}-assets-${H}`,q=`${Y}-${Q}-frontend-${H}`;if(K)console.log(` Checking bucket: ${x}`);try{await h.emptyAndDeleteBucket(x),console.log(`\u2713 Cleaned up existing bucket: ${x}`)}catch(T){if(!T.message?.includes("NoSuchBucket")&&!T.message?.includes("does not exist"))console.log(`\u26A0 Could not delete assets bucket: ${T.message}`);else if(K)console.log(" No existing assets bucket to clean up")}if(K)console.log(` Checking bucket: ${q}`);try{await h.emptyAndDeleteBucket(q),console.log(`\u2713 Cleaned up existing bucket: ${q}`)}catch(T){if(!T.message?.includes("NoSuchBucket")&&!T.message?.includes("does not exist"))console.log(`\u26A0 Could not delete frontend bucket: ${T.message}`);else if(K)console.log(" No existing frontend bucket to clean up")}}catch(O){console.log(`\u26A0 Pre-deployment cleanup error: ${O.message}`)}console.log("Creating stack..."),console.log("");let X=U?{templateURL:U}:{templateBody:W},z=await F.createStack({stackName:$,...X,capabilities:["CAPABILITY_IAM","CAPABILITY_NAMED_IAM"],tags:[{Key:"Environment",Value:Q},{Key:"Project",Value:Y},{Key:"ManagedBy",Value:"stacks"}],onFailure:"ROLLBACK",timeoutInMinutes:30});if(K)console.log(`Stack ID: ${z}`);if(_)console.log(` ${"Resource".padEnd(35)} ${"Type".padEnd(30)} Status`),console.log(" "+"\u2500".repeat(85)),await F.waitForStack($,"stack-create-complete"),console.log("")}let E=M?.infrastructure?.dns?.domain||"stacksjs.com",B=M?.infrastructure?.ssl||{enabled:!0,domains:[]},I=B.domains||[E,`www.${E}`];try{let X=(await F.describeStacks({stackName:$})).Stacks?.[0];if(X&&X.StackStatus){let z={};for(let O of X.Outputs||[])if(O.OutputKey&&O.OutputValue)z[O.OutputKey]=O.OutputValue;if(console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(""),console.log(" \u2713 Infrastructure deployed successfully"),console.log(""),console.log(` Stack: ${$}`),console.log(` Status: ${X.StackStatus}`),console.log(` Domain: https://${E}`),z.LoadBalancerDNS)console.log(` Load Balancer: ${z.LoadBalancerDNS}`);if(z.WebServerPublicIP)console.log(` Server IP: ${z.WebServerPublicIP}`);if(z.AssetsBucketName&&K)console.log(` Assets: ${z.AssetsBucketName}`);if(console.log(""),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(""),B.enabled&&M?.infrastructure?.dns?.hostedZoneId&&z.LoadBalancerDNS)await p({region:J,domain:E,sslDomains:I,hostedZoneId:M.infrastructure.dns.hostedZoneId,albDnsName:z.LoadBalancerDNS,stackName:$});else if(!B.certificateArn&&K)console.log(" Next steps:"),console.log(" 1. DNS records need to be updated to point to the ALB"),console.log(" 2. SSL certificate needs to be requested and attached"),console.log(` Run: ./buddy cloud:ssl to set up SSL for ${E}`),console.log("")}}catch{}}catch(w){throw console.error(`Stack deployment failed: ${w.message}`),w}}async function m(G){let{environment:Q,region:J,buildDir:_}=G,j=(await N()).name;D.info(`Deploying frontend from ${_} to ${Q} in ${J}...`);try{let{S3Client:Y,AWSCloudFormationClient:$}=await import("@stacksjs/ts-cloud"),w=new Y(J),F=new $(J),M=`${j}-cloud`,W=(await F.describeStacks({stackName:M})).Stacks?.[0]?.Outputs?.find((P)=>P.OutputKey==="AssetsBucketName")?.OutputValue;if(!W)throw Error("Assets bucket not found in stack outputs");D.info(`Syncing ${_} to s3://${W}/...`),await w.sync({source:_,bucket:W,delete:!0,cacheControl:"max-age=31536000"}),D.success("Frontend deployment completed!")}catch(Y){throw D.error(`Frontend deployment failed: ${Y.message}`),Y}}async function l(G){let{environment:Q,region:J}=G,j=`${(await N()).name}-cloud`,{AWSCloudFormationClient:Y}=await import("@stacksjs/ts-cloud"),$=new Y(J);try{let w=(await $.describeStacks({stackName:j})).Stacks?.[0];if(!w||!w.StackStatus)return{status:"NOT_FOUND",outputs:{}};let F={};for(let M of w.Outputs||[])if(M.OutputKey&&M.OutputValue)F[M.OutputKey]=M.OutputValue;return{status:w.StackStatus,outputs:F}}catch{return{status:"NOT_FOUND",outputs:{}}}}async function u(G){let{environment:Q,region:J,verbose:_}=G,K=await N(),Y=`${K.name}-cloud`;console.log(`Undeploying ${Y} from ${J}...`),console.log("");try{let{AWSCloudFormationClient:$,AWSClient:w}=await import("@stacksjs/ts-cloud"),F=new $(J),M=!1;try{let V=(await F.describeStacks({stackName:Y})).Stacks?.[0];if(V&&V.StackStatus){if(console.log(`Current status: ${v(V.StackStatus)}`),M=!0,V.StackStatus.endsWith("_IN_PROGRESS")){console.log(`Waiting for current operation (${V.StackStatus}) to finish...`);let W=V.StackStatus.startsWith("DELETE")?"stack-delete-complete":V.StackStatus.startsWith("CREATE")?"stack-create-complete":"stack-update-complete";try{await F.waitForStack(Y,W)}catch{}try{let P=(await F.describeStacks({stackName:Y})).Stacks?.[0];if(!P||!P.StackStatus||P.StackStatus==="DELETE_COMPLETE"){console.log("Stack was already deleted during the in-progress operation.");return}}catch{console.log("Stack was already deleted during the in-progress operation.");return}}if(V.StackStatus==="DELETE_COMPLETE")M=!1}}catch{M=!1}if(!M){console.log(`Stack ${Y} does not exist. Nothing to undeploy.`);return}if(_)console.log("Checking for resources to clean up before deletion...");try{let V=new w,{AWSCloudFormationClient:W}=await import("@stacksjs/ts-cloud"),Z=((await new W(J).listStackResources(Y)).StackResourceSummaries||[]).find((A)=>A.LogicalResourceId==="ApplicationLoadBalancer");if(Z?.PhysicalResourceId){let E={Action:"DescribeListeners",LoadBalancerArn:Z.PhysicalResourceId,Version:"2015-12-01"},B=await V.request({service:"elasticloadbalancing",region:J,method:"POST",path:"/",body:new URLSearchParams(E).toString()}),I=B?.DescribeListenersResult?.Listeners?.member||B?.DescribeListenersResponse?.DescribeListenersResult?.Listeners?.member,X=Array.isArray(I)?I:I?[I]:[],z=0;for(let O of X)if(O.Protocol==="HTTPS"){if(_)console.log(` Removing HTTPS listener on port ${O.Port}...`);let h={Action:"DeleteListener",ListenerArn:O.ListenerArn,Version:"2015-12-01"};await V.request({service:"elasticloadbalancing",region:J,method:"POST",path:"/",body:new URLSearchParams(h).toString()}),z++}if(z>0&&_)console.log(`\u2713 Cleaned up ${z} HTTPS listener(s)`),await new Promise((O)=>setTimeout(O,2000))}}catch(V){if(_)console.log(`Warning: ${V.message}`)}console.log("Deleting stack..."),console.log(""),await F.deleteStack(Y),console.log(` ${"Resource".padEnd(35)} ${"Type".padEnd(30)} Status`),console.log(" "+"\u2500".repeat(85)),await F.waitForStack(Y,"stack-delete-complete");try{let{S3Client:V}=await import("@stacksjs/ts-cloud"),W=new V(J),P=await b(J),U=`${K.name}-${Q}-assets-${P}`,R=`${K.name}-${Q}-frontend-${P}`;console.log("Cleaning up retained buckets...");try{await W.emptyAndDeleteBucket(U),console.log("\u2713 Assets bucket deleted successfully")}catch(Z){if(!Z.message?.includes("NoSuchBucket")&&!Z.message?.includes("does not exist"))console.log(`\u26A0 Could not delete assets bucket: ${Z.message}`);else console.log("\u2713 No retained assets bucket to clean up")}try{await W.emptyAndDeleteBucket(R),console.log("\u2713 Frontend bucket deleted successfully")}catch(Z){if(!Z.message?.includes("NoSuchBucket")&&!Z.message?.includes("does not exist"))console.log(`\u26A0 Could not delete frontend bucket: ${Z.message}`);else console.log("\u2713 No retained frontend bucket to clean up")}}catch(V){console.log(`\u26A0 Cleanup error: ${V.message}`)}console.log(""),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log(""),console.log(" \u2713 Infrastructure removed successfully"),console.log(""),console.log(` Stack: ${Y}`),console.log(` Environment: ${Q}`),console.log(` Region: ${J}`),console.log(""),console.log("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550"),console.log("")}catch($){let w=String($.message||$);if(w.includes("does not exist")){console.log(""),console.log("\u2713 Stack already deleted or does not exist.");return}if($.code==="DELETE_FAILED"||w.includes("DELETE_FAILED")){console.log(""),console.log("Some resources could not be deleted automatically"),console.log("Identifying resources to retain...");let{AWSCloudFormationClient:F}=await import("@stacksjs/ts-cloud"),M=new F(J);try{let P=((await M.listStackResources(Y)).StackResourceSummaries||[]).filter((U)=>U.ResourceStatus==="DELETE_FAILED").map((U)=>U.LogicalResourceId);if(P.length>0){console.log(`Retaining ${P.length} resource(s):`),P.forEach((Z)=>console.log(` - ${Z}`)),console.log(""),console.log("Retrying deletion with retained resources..."),await M.deleteStack(Y,void 0,P);let{AWSCloudFormationClient:U}=await import("@stacksjs/ts-cloud");await new U(J).waitForStack(Y,"stack-delete-complete"),console.log(""),console.log("\u2713 Stack removed (with retained resources)"),console.log(""),console.log("Note: Some resources were retained and may need manual cleanup."),console.log("Run `./buddy cloud:cleanup` to clean up remaining resources.");return}}catch(V){if(String(V.message||V).includes("does not exist")){console.log(""),console.log("\u2713 Stack deleted successfully!");return}throw V}}throw console.error(`Stack deletion failed: ${$.message}`),$}}export{u as undeployStack,l as getDeploymentStatus,g as deployStack,m as deployFrontend};
|