@stacksjs/actions 0.70.44 → 0.70.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/dist/{chunk-6x1m5rkr.js → chunk-4fz2qb8b.js} +1 -1
  2. package/dist/{chunk-wv5yb5wb.js → chunk-4p0rjazd.js} +2 -2
  3. package/dist/{chunk-tc935b45.js → chunk-77pta9ww.js} +1 -1
  4. package/dist/{chunk-aw6d8zr3.js → chunk-cqedfbaf.js} +1 -1
  5. package/dist/{chunk-h93n2j40.js → chunk-d5yxdz7e.js} +1 -1
  6. package/dist/{chunk-60qjz7zb.js → chunk-h0hfqr1p.js} +1 -1
  7. package/dist/{chunk-67y94dzt.js → chunk-h5rff0v9.js} +1 -1
  8. package/dist/chunk-jbvvb45k.js +3 -0
  9. package/dist/chunk-kr2k0h74.js +16 -0
  10. package/dist/chunk-s03z9zn3.js +920 -0
  11. package/dist/{chunk-n1y0gpv6.js → chunk-sxp97zys.js} +1 -1
  12. package/dist/{chunk-7bpdkc40.js → chunk-tzx3h4r8.js} +1 -1
  13. package/dist/{chunk-n2x7v39b.js → chunk-vek18p55.js} +1 -1
  14. package/dist/{chunk-wnrgcx3d.js → chunk-yh15ydty.js} +1 -1
  15. package/dist/{chunk-x471rxrn.js → chunk-yvva7qsg.js} +1 -1
  16. package/dist/{chunk-rdajkt2s.js → chunk-zaw01rqz.js} +1 -1
  17. package/dist/{chunk-schcaf73.js → chunk-zbhjh5sz.js} +1 -1
  18. package/dist/src/action.js +1 -1
  19. package/dist/src/actions.js +1 -1
  20. package/dist/src/add.js +1 -1
  21. package/dist/src/ai/request-model-access.js +1 -1
  22. package/dist/src/build.js +1 -1
  23. package/dist/src/commit.js +1 -1
  24. package/dist/src/deploy/index.js +2 -2
  25. package/dist/src/dev/api.js +1 -1
  26. package/dist/src/dev/dashboard-globals.js +1 -1
  27. package/dist/src/dev/dashboard-utils.js +1 -1
  28. package/dist/src/dev/dashboard.js +4 -4
  29. package/dist/src/dev/index.js +1 -1
  30. package/dist/src/dev/views.js +1 -1
  31. package/dist/src/discover-packages.js +1 -1
  32. package/dist/src/examples.js +1 -1
  33. package/dist/src/generate/component-meta.js +1 -1
  34. package/dist/src/generate/env-files.js +1 -1
  35. package/dist/src/generate/ide-helpers.js +1 -1
  36. package/dist/src/generate/index.js +1 -1
  37. package/dist/src/generate/lib-entries.js +1 -1
  38. package/dist/src/generate/vscode-custom-data.js +1 -1
  39. package/dist/src/helpers/component-meta.js +1 -1
  40. package/dist/src/helpers/index.js +1 -1
  41. package/dist/src/helpers/lib-entries.js +1 -1
  42. package/dist/src/helpers/package-json.js +1 -1
  43. package/dist/src/helpers/utils.js +1 -1
  44. package/dist/src/helpers/vscode-custom-data.js +1 -1
  45. package/dist/src/index.js +1 -1
  46. package/dist/src/make-command.js +1 -1
  47. package/dist/src/make-job.js +1 -1
  48. package/dist/src/make-policy.js +1 -1
  49. package/dist/src/make-resource.js +1 -1
  50. package/dist/src/make.js +1 -1
  51. package/dist/src/orm/base.js +1 -1
  52. package/dist/src/release.js +1 -1
  53. package/dist/src/run-action.js +1 -1
  54. package/dist/src/scaffold-crud.js +1 -1
  55. package/dist/src/setup/index.js +1 -1
  56. package/dist/src/setup/ssl.js +1 -1
  57. package/dist/src/stacks.js +1 -1
  58. package/dist/src/templates.js +1 -1
  59. package/dist/src/types.js +1 -1
  60. package/dist/src/upgrade/dependencies.js +1 -1
  61. package/dist/src/upgrade/framework-utils.js +1 -1
  62. package/dist/src/upgrade/framework.js +1 -1
  63. package/dist/src/upgrade/index.js +1 -1
  64. package/dist/src/upgrade.js +1 -1
  65. package/package.json +16 -16
  66. package/dist/chunk-96b7fcmd.js +0 -3
@@ -1,3 +1,3 @@
1
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))}
2
+ import{hb as r,ib as M}from"./chunk-jbvvb45k.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-4p0rjazd.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
3
  export{n as Ya,i as Za,y as _a,o as $a};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"./chunk-xg9xscqz.js";import"./chunk-96b7fcmd.js";import U from"fs";import Z from"path";import Q from"fs";import j from"path";import F from"path";import D from"fs";import L from"path";import T from"fs";import H from"path";function S(G,B){let I=["// Auto-generated by STX - do not edit",'declare module "stx/routes" {'," interface RouteMap {"];for(let J of G){let K=[];for(let V of J.params){let X=J.pattern.includes(`:${V}*`)?"string[]":"string";K.push(`${V}: ${X}`)}let O=K.join("; ");I.push(` '${J.pattern}': { ${O} }`)}I.push(" }","}",""),Q.mkdirSync(B,{recursive:!0}),Q.writeFileSync(j.join(B,"route-types.d.ts"),I.join(`
2
+ import"./chunk-xg9xscqz.js";import"./chunk-jbvvb45k.js";import U from"fs";import Z from"path";import Q from"fs";import j from"path";import F from"path";import D from"fs";import L from"path";import T from"fs";import H from"path";function S(G,B){let I=["// Auto-generated by STX - do not edit",'declare module "stx/routes" {'," interface RouteMap {"];for(let J of G){let K=[];for(let V of J.params){let X=J.pattern.includes(`:${V}*`)?"string[]":"string";K.push(`${V}: ${X}`)}let O=K.join("; ");I.push(` '${J.pattern}': { ${O} }`)}I.push(" }","}",""),Q.mkdirSync(B,{recursive:!0}),Q.writeFileSync(j.join(B,"route-types.d.ts"),I.join(`
3
3
  `))}function b(G,B,I){let J=process.cwd(),K=j.relative(J,I),O=["components","layouts","partials"],V=G.filter((W)=>!O.some((Y)=>W.pattern.startsWith(`/${Y}/`)||W.pattern===`/${Y}`)),X=["// Auto-generated by stx \u2014 do not edit",`// Source: ${K||"pages"}/`,"","export const routes = ["];for(let W of V){let Y=j.relative(J,W.filePath).replace(/\\/g,"/"),M=JSON.stringify(W.params),R=W.layout?`, layout: '${j.relative(J,W.layout).replace(/\\/g,"/")}'`:"";X.push(` { pattern: '${W.pattern}', filePath: '${Y}', isDynamic: ${W.isDynamic}, params: ${M}${R} },`)}X.push("] as const",""),X.push("export type RouteName = typeof routes[number]['pattern']",""),Q.mkdirSync(B,{recursive:!0}),Q.writeFileSync(j.join(B,"routes.ts"),X.join(`
4
4
  `))}function v(G,B){let J=F.relative(B,G).replace(/\.(stx|md)$/,"");if(J=J.split(F.sep).join("/"),J==="index")return"/";if(J.endsWith("/index"))J=J.slice(0,-6);return J=J.replace(/\[\[([^\]]+)\]\]/g,":$1?"),J=J.replace(/\[([^\]]+)\]/g,":$1"),J=J.replace(/:\.\.\.([^/]+)/g,":$1*"),`/${J}`}function w(G){let B=[],I=G.replace(/[.+^${}()|[\]\\]/g,"\\$&");return I=I.replace(/\/:([^/]+)\?/g,(J,K)=>{return B.push(K),"(?:/([^/]+))?"}),I=I.replace(/:([^/]+)\*/g,(J,K)=>{return B.push(K),"(.+)"}),I=I.replace(/:([^/]+)/g,(J,K)=>{return B.push(K),"([^/]+)"}),I=`^${I}$`,{regex:new RegExp(I),params:B}}function m(G,B){let I=G===""?"/":G;for(let J of B){let K=I.match(J.regex);if(K){let O={};return J.params.forEach((V,X)=>{O[V]=K[X+1]}),{route:J,params:O}}}return null}function P(G,B){let I=[],J=L.dirname(G);while(J.startsWith(B)||J===B){let K=L.join(J,"_layout.stx");if(D.existsSync(K))I.unshift(K);if(J===B)break;J=L.dirname(J)}return I}function N(G,B){let I=[];if(!U.existsSync(G))return I;let J=U.readdirSync(G,{withFileTypes:!0});for(let K of J){let O=Z.join(G,K.name);if(K.isDirectory()){if(K.name.startsWith("."))continue;I.push(...N(O,B))}else if(K.isFile()){let V=Z.extname(K.name);if(B.includes(V)){if(K.name.startsWith("_")&&K.name!=="_layout.stx")continue;if(K.name==="_layout.stx")continue;I.push(O)}}}return I}class C{routes;pagesDir;config;constructor(G,B={}){this.config=B,this.pagesDir=Z.resolve(G,B.pagesDir||"pages");let I=B.extensions||[".stx"],J=N(this.pagesDir,I);this.routes=J.map((O)=>{let V=v(O,this.pagesDir),{regex:X,params:W}=w(V),Y=B.layouts!==!1?P(O,this.pagesDir):[];return{pattern:V,regex:X,params:W,filePath:O,isDynamic:W.length>0,layout:Y.length>0?Y[Y.length-1]:void 0}}),this.routes.sort((O,V)=>{if(!O.isDynamic&&V.isDynamic)return-1;if(O.isDynamic&&!V.isDynamic)return 1;let X=O.pattern.split("/").length,W=V.pattern.split("/").length;if(X!==W)return W-X;return O.pattern.localeCompare(V.pattern)});let K=Z.join(G,".stx");S(this.routes,K),b(this.routes,K,this.pagesDir)}match(G){let B=G===""?"/":G;for(let I of this.routes){let J=B.match(I.regex);if(J){let K={};return I.params.forEach((O,V)=>{K[O]=J[V+1]}),{route:I,params:K}}}return null}resolve(G,B){let I=this.routes.find((K)=>K.pattern===G||K.filePath.includes(G));if(!I)return"#not-found";let J=I.pattern;if(B)for(let[K,O]of Object.entries(B))J=J.replace(`:${K}`,encodeURIComponent(O));return J}addRoute(G){this.routes.push(G),this.routes.sort((B,I)=>{if(!B.isDynamic&&I.isDynamic)return-1;if(B.isDynamic&&!I.isDynamic)return 1;return B.pattern.localeCompare(I.pattern)})}getLayout(G){return G.layout??null}}function i(G,B){return new C(G,B)}function o(G,B){let I=[`${B}.stx`,"error.stx"];for(let J of I){let K=Z.join(G,J);if(U.existsSync(K))return K}return null}function t(G,B){return G.map((I)=>{let J=Z.relative(B,I.filePath),K=I.isDynamic?" (dynamic)":"";return`${I.pattern} \u2192 ${J}${K}`})}var $={},_="";function r(G){_=G.replace(/\/$/,"")}function a(G,B,I={}){$[G]={path:B,name:G,params:I}}function e(G){for(let[B,I]of Object.entries(G))if(typeof I==="string")$[B]={path:I,name:B};else $[B]={...I,name:B}}function BB(G,B={},I=!1){let J=$[G];if(!J)return console.warn(`Route [${G}] not defined.`),"#undefined-route";let K={...J.params,...B},O=J.path;O=O.replace(/:(\w+)/g,(X,W)=>{let Y=K[W];if(Y===void 0)return console.warn(`Missing parameter [${W}] for route [${G}].`),`:${W}`;return delete K[W],encodeURIComponent(String(Y))});let V=Object.entries(K);if(V.length>0){let X=V.map(([W,Y])=>`${encodeURIComponent(W)}=${encodeURIComponent(String(Y))}`).join("&");O+=(O.includes("?")?"&":"?")+X}return I&&_?`${_}${O}`:O}function GB(){for(let G of Object.keys($))delete $[G];_=""}function KB(G,B={}){return{type:"redirect",path:G,options:{replace:B.replace??!1,external:B.external??!1,redirectCode:B.redirectCode??302}}}function OB(G){return{type:"abort",error:typeof G==="string"?{statusCode:500,message:G}:G}}function VB(G,B={}){return{handler:G,mode:B.mode??"universal"}}function z(G){let B={};if(!G)return B;let I=G.split(";");for(let J of I){let[K,...O]=J.split("=");if(K){let V=K.trim(),X=O.join("=").trim();if(V)B[V]=decodeURIComponent(X)}}return B}function E(G,B,I={}){let J=`${encodeURIComponent(G)}=${encodeURIComponent(B)}`;if(I.expires){let K=typeof I.expires==="number"?new Date(Date.now()+I.expires*1000):I.expires;J+=`; Expires=${K.toUTCString()}`}if(I.path)J+=`; Path=${I.path}`;if(I.domain)J+=`; Domain=${I.domain}`;if(I.secure)J+="; Secure";if(I.httpOnly)J+="; HttpOnly";if(I.sameSite)J+=`; SameSite=${I.sameSite}`;return J}function k(G,B){let I=G.headers.get("cookie")||"",J=z(I);return{get(K){return J[K]},set(K,O,V={}){J[K]=O,B.append("Set-Cookie",E(K,O,V))},delete(K){delete J[K],B.append("Set-Cookie",E(K,"",{expires:new Date(0),path:"/"}))},getAll(){return{...J}}}}function x(){return{get(G){if(typeof document>"u")return;return z(document.cookie)[G]},set(G,B,I={}){if(typeof document>"u")return;document.cookie=E(G,B,I)},delete(G){if(typeof document>"u")return;document.cookie=E(G,"",{expires:new Date(0),path:"/"})},getAll(){if(typeof document>"u")return{};return z(document.cookie)}}}function y(){let G=typeof window<"u"&&typeof window.localStorage<"u";return{get(B){if(!G)return null;try{return window.localStorage.getItem(B)}catch{return null}},set(B,I){if(!G)return;try{window.localStorage.setItem(B,I)}catch{}},remove(B){if(!G)return;try{window.localStorage.removeItem(B)}catch{}},isAvailable(){return G}}}var A=new Map;function q(G,B){A.set(G,B)}function f(G){return A.get(G)}function WB(G){return A.has(G)}function XB(){A.clear()}function YB(){return Array.from(A.keys())}async function ZB(G,B="middleware"){let I=H.resolve(G,B);if(!T.existsSync(I))return;let J=T.readdirSync(I);for(let K of J){if(!K.endsWith(".ts")&&!K.endsWith(".js"))continue;if(K.includes(".test.")||K.includes(".spec."))continue;let O=K.replace(/\.(ts|js)$/,""),V=H.join(I,K);try{let W=(await import(V)).default;if(W&&typeof W.handler==="function")q(O,W);else if(typeof W==="function")q(O,{handler:W,mode:"universal"})}catch(X){console.warn(`Failed to load middleware '${O}' from ${V}:`,X)}}}function g(G){let B={};if(!G)return B;let I=new URLSearchParams(G);for(let[J,K]of I)B[J]=K;return B}function $B(G,B,I,J=""){return{path:G,params:B,query:g(J),fullPath:J?`${G}?${J}`:G,meta:I}}function jB(G,B,I){let J=typeof window>"u",K=!J,O=new Headers;return{to:G,from:B,isClient:K,isServer:J,cookies:J&&I?k(I,O):x(),storage:y(),state:{},request:I,responseHeaders:O}}async function AB(G,B){let I=Array.isArray(G)?G:[G],J=B.isServer;for(let K of I){let O=f(K);if(!O){console.warn(`Middleware '${K}' not found`);continue}if(O.mode==="server"&&!J)continue;if(O.mode==="client"&&J)continue;try{let V=await O.handler(B);if(V){if(V.type==="redirect")return{passed:!1,redirect:V,state:B.state,responseHeaders:B.responseHeaders};if(V.type==="abort")return{passed:!1,abort:V,state:B.state,responseHeaders:B.responseHeaders}}}catch(V){return console.error(`Error in middleware '${K}':`,V),{passed:!1,abort:{type:"abort",error:{statusCode:500,message:V instanceof Error?V.message:"Middleware error"}},state:B.state,responseHeaders:B.responseHeaders}}}return{passed:!0,state:B.state,responseHeaders:B.responseHeaders}}function QB(){return`
5
5
  ;(function(){
@@ -1,5 +1,5 @@
1
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
2
+ import"./chunk-jbvvb45k.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
3
  echo "Hello World from App Server 2!" > /tmp/test.txt
4
4
  chown ubuntu:ubuntu /tmp/test.txt
5
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};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{gb as G}from"./chunk-96b7fcmd.js";import{log as x}from"@stacksjs/logging";import*as z from"@stacksjs/path";import{doesExist as H,writeFile as I}from"@stacksjs/storage";async function O(q){let j=q.name;if(!j)return x.error("Resource name is required"),!1;let v=j.endsWith("Resource")?j:`${j}Resource`,A=q.model||v.replace("Resource",""),F=q.collection?K(v,A):J(v,A),B=z.appPath("Resources");if(!H(B)){let{mkdirSync:w}=await import("@stacksjs/storage");w(B,{recursive:!0})}let E=z.appPath(`Resources/${v}.ts`);try{return await I(E,F),x.success(`Created resource: ${E}`),!0}catch(w){return x.error(`Failed to create resource: ${w.message}`),!1}}function J(q,j){return`import type { Request } from '@stacksjs/router'
2
+ import{ib as G}from"./chunk-jbvvb45k.js";import{log as x}from"@stacksjs/logging";import*as z from"@stacksjs/path";import{doesExist as H,writeFile as I}from"@stacksjs/storage";async function O(q){let j=q.name;if(!j)return x.error("Resource name is required"),!1;let v=j.endsWith("Resource")?j:`${j}Resource`,A=q.model||v.replace("Resource",""),F=q.collection?K(v,A):J(v,A),B=z.appPath("Resources");if(!H(B)){let{mkdirSync:w}=await import("@stacksjs/storage");w(B,{recursive:!0})}let E=z.appPath(`Resources/${v}.ts`);try{return await I(E,F),x.success(`Created resource: ${E}`),!0}catch(w){return x.error(`Failed to create resource: ${w.message}`),!1}}function J(q,j){return`import type { Request } from '@stacksjs/router'
3
3
  import { JsonResource } from '@stacksjs/api'
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{gb as H}from"./chunk-96b7fcmd.js";import{execSync as M,spawn as j}from"child_process";import Z from"fs";import E from"os";import $ from"path";import Y from"process";import{log as B}from"@stacksjs/cli";var q=Y.platform==="win32"?$.join(Y.env.windir||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts",X=$.join(E.homedir(),".stacks","ssl");function T(){return Y.stdin.isTTY===!0&&Y.stdout.isTTY===!0}function V(){return Y.env.SUDO_PASSWORD}function k(){return T()||!!V()}function F(z){try{let G=Z.readFileSync(q,"utf-8");return G.includes(`127.0.0.1 ${z}`)||G.includes(`::1 ${z}`)}catch{if(Y.platform!=="win32"){let G=V();if(G)try{let J=M(`echo '${G}' | sudo -S cat "${q}" 2>/dev/null`,{encoding:"utf-8"});return J.includes(`127.0.0.1 ${z}`)||J.includes(`::1 ${z}`)}catch{return!1}}return!1}}async function x(z,G){if(F(z)){if(G)B.info(`${z} already in hosts file`);return!0}let J=`
2
+ import{ib as H}from"./chunk-jbvvb45k.js";import{execSync as M,spawn as j}from"child_process";import Z from"fs";import E from"os";import $ from"path";import Y from"process";import{log as B}from"@stacksjs/cli";var q=Y.platform==="win32"?$.join(Y.env.windir||"C:\\Windows","System32","drivers","etc","hosts"):"/etc/hosts",X=$.join(E.homedir(),".stacks","ssl");function T(){return Y.stdin.isTTY===!0&&Y.stdout.isTTY===!0}function V(){return Y.env.SUDO_PASSWORD}function k(){return T()||!!V()}function F(z){try{let G=Z.readFileSync(q,"utf-8");return G.includes(`127.0.0.1 ${z}`)||G.includes(`::1 ${z}`)}catch{if(Y.platform!=="win32"){let G=V();if(G)try{let J=M(`echo '${G}' | sudo -S cat "${q}" 2>/dev/null`,{encoding:"utf-8"});return J.includes(`127.0.0.1 ${z}`)||J.includes(`::1 ${z}`)}catch{return!1}}return!1}}async function x(z,G){if(F(z)){if(G)B.info(`${z} already in hosts file`);return!0}let J=`
3
3
  # Added by Stacks
4
4
  127.0.0.1 ${z}
5
5
  ::1 ${z}
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{D as x}from"./chunk-6x1m5rkr.js";import{italic as I}from"@stacksjs/cli";import{log as W}from"@stacksjs/logging";import{path as Z}from"@stacksjs/path";import{writeTextFile as L}from"@stacksjs/storage";var P={str:"string",string:"string",varchar:"string",text:"text",longtext:"text",int:"number",integer:"number",number:"number",num:"number",bool:"boolean",boolean:"boolean",date:"date",datetime:"date",json:"json"};function U(G){if(!G)return[];let H=G.split(",").map((q)=>q.trim()).filter(Boolean),J=[];for(let q of H){let[K,O="string"]=q.split(":"),Q=K?.trim();if(!Q)continue;let B=P[O.trim().toLowerCase()]??"string";J.push({name:Q,type:B})}return J}function V(G){if(!G)return G;let H=G.toLowerCase();if(H.endsWith("s")||H.endsWith("x")||H.endsWith("z")||H.endsWith("ch")||H.endsWith("sh"))return`${G}es`;if(H.endsWith("y")&&!/[aeiou]y$/.test(H))return`${G.slice(0,-1)}ies`;return`${G}s`}function v(G){return G.replace(/(^|[-_\s])(\w)/g,(H,J,q)=>String(q).toUpperCase())}function X(G){return G.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function Y(G){if(G.length===0)return" title: { type: 'string', fillable: true, validation: { rule: schema.string().required() } },";return G.map((H)=>{let J=H.type,q=J==="number"?"schema.number()":J==="boolean"?"schema.boolean()":J==="date"?"schema.date()":J==="json"?"schema.object({})":"schema.string()",K=J==="number"?"number":J==="boolean"?"boolean":J==="date"?"date":J==="json"?"json":"string";return` ${H.name}: { type: '${K}', fillable: true, validation: { rule: ${q} } },`}).join(`
2
+ import{D as x}from"./chunk-4fz2qb8b.js";import{italic as I}from"@stacksjs/cli";import{log as W}from"@stacksjs/logging";import{path as Z}from"@stacksjs/path";import{writeTextFile as L}from"@stacksjs/storage";var P={str:"string",string:"string",varchar:"string",text:"text",longtext:"text",int:"number",integer:"number",number:"number",num:"number",bool:"boolean",boolean:"boolean",date:"date",datetime:"date",json:"json"};function U(G){if(!G)return[];let H=G.split(",").map((q)=>q.trim()).filter(Boolean),J=[];for(let q of H){let[K,O="string"]=q.split(":"),Q=K?.trim();if(!Q)continue;let B=P[O.trim().toLowerCase()]??"string";J.push({name:Q,type:B})}return J}function V(G){if(!G)return G;let H=G.toLowerCase();if(H.endsWith("s")||H.endsWith("x")||H.endsWith("z")||H.endsWith("ch")||H.endsWith("sh"))return`${G}es`;if(H.endsWith("y")&&!/[aeiou]y$/.test(H))return`${G.slice(0,-1)}ies`;return`${G}s`}function v(G){return G.replace(/(^|[-_\s])(\w)/g,(H,J,q)=>String(q).toUpperCase())}function X(G){return G.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[-\s]+/g,"_").toLowerCase()}function Y(G){if(G.length===0)return" title: { type: 'string', fillable: true, validation: { rule: schema.string().required() } },";return G.map((H)=>{let J=H.type,q=J==="number"?"schema.number()":J==="boolean"?"schema.boolean()":J==="date"?"schema.date()":J==="json"?"schema.object({})":"schema.string()",K=J==="number"?"number":J==="boolean"?"boolean":J==="date"?"date":J==="json"?"json":"string";return` ${H.name}: { type: '${K}', fillable: true, validation: { rule: ${q} } },`}).join(`
3
3
  `)}function _(G){if(G.length===0)return" .addColumn('title', 'varchar(255)', col => col.notNull())";return G.map((H)=>{switch(H.type){case"number":return` .addColumn('${H.name}', 'integer')`;case"boolean":return` .addColumn('${H.name}', 'boolean', col => col.defaultTo(false))`;case"text":return` .addColumn('${H.name}', 'text')`;case"date":return` .addColumn('${H.name}', 'timestamp')`;case"json":return` .addColumn('${H.name}', 'text')`;default:return` .addColumn('${H.name}', 'varchar(255)')`}}).join(`
4
4
  `)}function D(G,H,J){let q=v(G);switch(H){case"Index":return`import { Action } from '@stacksjs/actions'
5
5
  import ${q} from '~/app/Models/${q}'
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import{Ua as z}from"./chunk-v0wnrnaa.js";import{Ya as U}from"./chunk-n1y0gpv6.js";import{gb as O}from"./chunk-96b7fcmd.js";import*as Q from"fs";import R from"process";import{runCommand as b}from"@stacksjs/cli";import{Action as Y,NpmScript as H}from"@stacksjs/enums";import{log as B}from"@stacksjs/logging";import{frameworkPath as I,projectPath as K,storagePath as D}from"@stacksjs/path";import{ExitCode as X}from"@stacksjs/types";import{runNpmScript as M}from"@stacksjs/utils";async function T(q){if(q?.types)await W(q);else if(q?.entries)await V(q);else if(q?.webTypes)await v(q);else if(q?.customData)await y();else if(q?.ideHelpers)await E(q);else if(q?.componentMeta)await N();else if(q?.coreSymlink)await x();else if(q?.openApiSpec)await S()}function u(q){return T(q)}async function V(q){let F=await U(Y.GenerateLibraryEntries,{...q,cwd:K()});if(F.isErr)B.error("There was an error generating your library entry points",F.error),R.exit(X.FatalError);B.success("Library entry points generated successfully")}async function v(q){let F=await M(H.GenerateWebTypes,q);if(F.isErr)B.error("There was an error generating the web-types.json file.",F.error),R.exit(X.FatalError);B.success("Successfully generated the web-types.json file")}async function y(){let q=await z();if(q.isErr)B.error("There was an error generating the custom-elements.json file.",q.error),R.exit(X.FatalError);await U(Y.LintFix,{verbose:!0,cwd:K()}),B.success("Successfully generated the custom-elements.json file")}async function E(q){let F=await M(H.GenerateIdeHelpers,q);if(F.isErr)B.error("There was an error generating IDE helpers.",F.error),R.exit(X.FatalError);await U(Y.LintFix,{verbose:!0,cwd:K()}),B.success("Successfully generated IDE helpers")}async function N(){let q=await z();if(q.isErr)B.error("There was an error generating your component meta information.",q.error),R.exit(X.FatalError);await U(Y.LintFix,{verbose:!0,cwd:K()}),B.success("Successfully generated component meta information")}async function W(q){let F=await M(H.GenerateTypes,{cwd:I(),...q});if(F.isErr)throw B.error("There was an error generating your types.",F.error),F.error instanceof Error?F.error:Error(String(F.error));B.success("Types were generated successfully")}async function c(q){try{let G=`${I()}/package.json`,J=Q.existsSync(G)?Q.readFileSync(G,"utf-8"):"";if(!(J?JSON.parse(J):{})?.scripts?.["generate:types"]){B.warn("[generate:types --watch] no `generate:types` script in framework package.json \u2014 type regeneration disabled. dev:api will keep running, but type definitions won't auto-refresh on model/config changes.");return}}catch{}let F=[K("app/Models"),D("framework/defaults/app/Models"),K("config"),K("database/migrations")];B.info(`[generate:types --watch] watching ${F.length} directories`);let Z=null,_=!1,L=()=>{if(Z)clearTimeout(Z);Z=setTimeout(async()=>{if(_)return;_=!0;try{B.info("[generate:types --watch] change detected, regenerating\u2026"),await W(q),B.success("[generate:types --watch] types up to date")}catch(G){B.error("[generate:types --watch] regeneration failed:",G)}finally{_=!1}},200)},$=[];for(let G of F)try{if(!Q.existsSync(G))continue;let J=Q.watch(G,{recursive:!0},()=>L());$.push(J)}catch(J){B.warn(`[generate:types --watch] cannot watch ${G}: ${J}`)}if($.length===0){B.warn("[generate:types --watch] no directories to watch \u2014 exiting");return}await new Promise((G)=>{R.once("SIGINT",()=>{B.info("[generate:types --watch] stopping");for(let J of $)try{J.close()}catch{}G()})})}function g(){B.success("Successfully generated `./pantry.yaml` based on your config")}async function l(){}async function x(){await b(`ln -s ${I()} ${K(".stacks")}`)}async function S(){let{generateOpenApi:q}=await import("@stacksjs/api");await q(),B.success("Successfully generated Open API Spec")}
2
+ import{Ua as z}from"./chunk-v0wnrnaa.js";import{Ya as U}from"./chunk-sxp97zys.js";import{ib as O}from"./chunk-jbvvb45k.js";import*as Q from"fs";import R from"process";import{runCommand as b}from"@stacksjs/cli";import{Action as Y,NpmScript as H}from"@stacksjs/enums";import{log as B}from"@stacksjs/logging";import{frameworkPath as I,projectPath as K,storagePath as D}from"@stacksjs/path";import{ExitCode as X}from"@stacksjs/types";import{runNpmScript as M}from"@stacksjs/utils";async function T(q){if(q?.types)await W(q);else if(q?.entries)await V(q);else if(q?.webTypes)await v(q);else if(q?.customData)await y();else if(q?.ideHelpers)await E(q);else if(q?.componentMeta)await N();else if(q?.coreSymlink)await x();else if(q?.openApiSpec)await S()}function u(q){return T(q)}async function V(q){let F=await U(Y.GenerateLibraryEntries,{...q,cwd:K()});if(F.isErr)B.error("There was an error generating your library entry points",F.error),R.exit(X.FatalError);B.success("Library entry points generated successfully")}async function v(q){let F=await M(H.GenerateWebTypes,q);if(F.isErr)B.error("There was an error generating the web-types.json file.",F.error),R.exit(X.FatalError);B.success("Successfully generated the web-types.json file")}async function y(){let q=await z();if(q.isErr)B.error("There was an error generating the custom-elements.json file.",q.error),R.exit(X.FatalError);await U(Y.LintFix,{verbose:!0,cwd:K()}),B.success("Successfully generated the custom-elements.json file")}async function E(q){let F=await M(H.GenerateIdeHelpers,q);if(F.isErr)B.error("There was an error generating IDE helpers.",F.error),R.exit(X.FatalError);await U(Y.LintFix,{verbose:!0,cwd:K()}),B.success("Successfully generated IDE helpers")}async function N(){let q=await z();if(q.isErr)B.error("There was an error generating your component meta information.",q.error),R.exit(X.FatalError);await U(Y.LintFix,{verbose:!0,cwd:K()}),B.success("Successfully generated component meta information")}async function W(q){let F=await M(H.GenerateTypes,{cwd:I(),...q});if(F.isErr)throw B.error("There was an error generating your types.",F.error),F.error instanceof Error?F.error:Error(String(F.error));B.success("Types were generated successfully")}async function c(q){try{let G=`${I()}/package.json`,J=Q.existsSync(G)?Q.readFileSync(G,"utf-8"):"";if(!(J?JSON.parse(J):{})?.scripts?.["generate:types"]){B.warn("[generate:types --watch] no `generate:types` script in framework package.json \u2014 type regeneration disabled. dev:api will keep running, but type definitions won't auto-refresh on model/config changes.");return}}catch{}let F=[K("app/Models"),D("framework/defaults/app/Models"),K("config"),K("database/migrations")];B.info(`[generate:types --watch] watching ${F.length} directories`);let Z=null,_=!1,L=()=>{if(Z)clearTimeout(Z);Z=setTimeout(async()=>{if(_)return;_=!0;try{B.info("[generate:types --watch] change detected, regenerating\u2026"),await W(q),B.success("[generate:types --watch] types up to date")}catch(G){B.error("[generate:types --watch] regeneration failed:",G)}finally{_=!1}},200)},$=[];for(let G of F)try{if(!Q.existsSync(G))continue;let J=Q.watch(G,{recursive:!0},()=>L());$.push(J)}catch(J){B.warn(`[generate:types --watch] cannot watch ${G}: ${J}`)}if($.length===0){B.warn("[generate:types --watch] no directories to watch \u2014 exiting");return}await new Promise((G)=>{R.once("SIGINT",()=>{B.info("[generate:types --watch] stopping");for(let J of $)try{J.close()}catch{}G()})})}function g(){B.success("Successfully generated `./pantry.yaml` based on your config")}async function l(){}async function x(){await b(`ln -s ${I()} ${K(".stacks")}`)}async function S(){let{generateOpenApi:q}=await import("@stacksjs/api");await q(),B.success("Successfully generated Open API Spec")}
3
3
  export{T as Ha,u as Ia,V as Ja,v as Ka,y as La,E as Ma,N as Na,W as Oa,c as Pa,g as Qa,l as Ra,x as Sa,S as Ta};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Xa as a}from"../chunk-d4srk6ma.js";import"../chunk-96b7fcmd.js";export{a as Action};
2
+ import{Xa as a}from"../chunk-d4srk6ma.js";import"../chunk-jbvvb45k.js";export{a as Action};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{$a as o,Ya as a,Za as e,_a as f}from"../chunk-n1y0gpv6.js";import"../chunk-96b7fcmd.js";export{e as runActions,a as runAction,f as hasAction,o as actions};
2
+ import{$a as o,Ya as a,Za as e,_a as f}from"../chunk-sxp97zys.js";import"../chunk-jbvvb45k.js";export{e as runActions,a as runAction,f as hasAction,o as actions};
package/dist/src/add.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ab as a,bb as b,cb as c,db as d,eb as e}from"../chunk-jd1yzkq5.js";import"../chunk-96b7fcmd.js";export{a as invoke,e as installPackages,c as addTable,d as addCalendar,b as add};
2
+ import{ab as a,bb as b,cb as c,db as d,eb as e}from"../chunk-jd1yzkq5.js";import"../chunk-jbvvb45k.js";export{a as invoke,e as installPackages,c as addTable,d as addCalendar,b as add};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"../../chunk-96b7fcmd.js";import{requestModelAccess as e}from"@stacksjs/ai";async function o(){try{await e()}catch(r){console.error("Error requesting model access:",r)}}if(import.meta.main)o();
2
+ import"../../chunk-jbvvb45k.js";import{requestModelAccess as e}from"@stacksjs/ai";async function o(){try{await e()}catch(r){console.error("Error requesting model access:",r)}}if(import.meta.main)o();
package/dist/src/build.js CHANGED
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Oa as B}from"../chunk-schcaf73.js";import"../chunk-v0wnrnaa.js";import"../chunk-n2fd1d0m.js";import"../chunk-s735m9mg.js";import"../chunk-n1y0gpv6.js";import"../chunk-96b7fcmd.js";import{NpmScript as z}from"@stacksjs/enums";import{log as x}from"@stacksjs/logging";import{hasComponents as D,hasFunctions as G}from"@stacksjs/storage";import{runNpmScript as A}from"@stacksjs/utils";async function H(q){if(q.components)await I(q);else if(q.webComponents||q.elements)await E(q);else if(q.functions)await O(q);else if(q.docs)await K(q);else if(q.stacks)await M(q);await B()}async function W(q){return await H(q)}async function I(q){await A(z.GenerateEntries,q),await J(q),await E(q)}async function J(q){if(D())x.info("Building your component library..."),await A(z.BuildComponents,q),x.success("Your component library was built successfully");else x.warn("No components found."),x.info("Before you can build components,"),x.info("you need to have created some in the ./components folder.")}async function E(q){if(x.info("Building your component library for production use & npm/CDN distribution..."),D())await A(z.BuildWebComponents,q),x.success("Your Web Component library was built successfully");else x.info("No components found.")}async function K(q){x.info("Building the documentation site..."),await A(z.BuildDocs,q),x.success("Docs built successfully")}async function M(q){x.info("Building the Stacks Framework..."),await A(z.BuildStacks,q),x.success("Stacks built successfully")}async function O(q){if(G())x.info("Building your functions library for production usages..."),x.info("Production usages include: manual npm distribution and/or CDN distribution"),await A(z.BuildFunctions,q),x.success("Functions library built successfully");else x.info("No functions found")}export{E as webComponentLibrary,J as vueComponentLibrary,M as stacks,H as invoke,O as functionsLibrary,K as docs,I as componentLibraries,W as build};
2
+ import{Oa as B}from"../chunk-zbhjh5sz.js";import"../chunk-v0wnrnaa.js";import"../chunk-n2fd1d0m.js";import"../chunk-s735m9mg.js";import"../chunk-sxp97zys.js";import"../chunk-jbvvb45k.js";import{NpmScript as z}from"@stacksjs/enums";import{log as x}from"@stacksjs/logging";import{hasComponents as D,hasFunctions as G}from"@stacksjs/storage";import{runNpmScript as A}from"@stacksjs/utils";async function H(q){if(q.components)await I(q);else if(q.webComponents||q.elements)await E(q);else if(q.functions)await O(q);else if(q.docs)await K(q);else if(q.stacks)await M(q);await B()}async function W(q){return await H(q)}async function I(q){await A(z.GenerateEntries,q),await J(q),await E(q)}async function J(q){if(D())x.info("Building your component library..."),await A(z.BuildComponents,q),x.success("Your component library was built successfully");else x.warn("No components found."),x.info("Before you can build components,"),x.info("you need to have created some in the ./components folder.")}async function E(q){if(x.info("Building your component library for production use & npm/CDN distribution..."),D())await A(z.BuildWebComponents,q),x.success("Your Web Component library was built successfully");else x.info("No components found.")}async function K(q){x.info("Building the documentation site..."),await A(z.BuildDocs,q),x.success("Docs built successfully")}async function M(q){x.info("Building the Stacks Framework..."),await A(z.BuildStacks,q),x.success("Stacks built successfully")}async function O(q){if(G())x.info("Building your functions library for production usages..."),x.info("Production usages include: manual npm distribution and/or CDN distribution"),await A(z.BuildFunctions,q),x.success("Functions library built successfully");else x.info("No functions found")}export{E as webComponentLibrary,J as vueComponentLibrary,M as stacks,H as invoke,O as functionsLibrary,K as docs,I as componentLibraries,W as build};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Fa as a,Ga as b}from"../chunk-2gh7kgpc.js";import"../chunk-96b7fcmd.js";export{a as invoke,b as commit};
2
+ import{Fa as a,Ga as b}from"../chunk-2gh7kgpc.js";import"../chunk-jbvvb45k.js";export{a as invoke,b as commit};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{gb as W}from"../../chunk-96b7fcmd.js";import{existsSync as YJ,readFileSync as EJ,statSync as wJ}from"fs";import F from"process";import{runCommand as WJ,spinner as g}from"@stacksjs/cli";import{config as OJ}from"@stacksjs/config";import{path as V}from"@stacksjs/path";import{storage as FJ}from"@stacksjs/storage";import{ExitCode as NJ}from"@stacksjs/types";var z={debug:(...J)=>{if(F.argv.includes("--verbose")||F.argv.includes("-v"))console.log("\uD83D\uDD0D",...J)},success:(...J)=>console.log("\u2713",...J),error:(...J)=>console.error("\u2717",...J)},TJ="github.com/mail-os/mail",DJ=`${TJ}@0.1.0`,jJ="linux-x86_64",_J=["mail","mail-x86_64-linux","mail-x86_64-linux-gnu"],$=F.argv.includes("--verbose")||F.argv.includes("-v");async function xJ(J,U,K=8){let{existsSync:Q,readdirSync:T,statSync:C}=await import("fs"),{join:j,basename:d}=await import("path"),a=new Set(U),v=[];if(!Q(J))return v;function f(KJ,zJ){if(zJ>K)return;for(let UJ of T(KJ)){if(UJ===".git"||UJ==="node_modules")continue;let n=j(KJ,UJ),t=C(n);if(t.isDirectory())f(n,zJ+1);else if(t.isFile()&&a.has(d(n)))v.push(n)}}return f(J,0),v}async function AJ(J){let{readFileSync:U}=await import("fs"),K=U(J).slice(0,4);return K[0]===127&&K[1]===69&&K[2]===76&&K[3]===70}async function IJ(){let{existsSync:J}=await import("fs"),U=`${F.env.HOME}/Code/Tools/pantry/packages/ts-pantry/bin/cli.ts`;if(J(U))return{command:"bun",args:[U]};let K=V.projectPath("pantry/.bin/pantry");if(J(K))return{command:K,args:[]};let Q=`${F.env.HOME}/.local/share/pantry/global/bin/pantry`;if(J(Q))return{command:Q,args:[]};return{command:"pantry",args:[]}}async function fJ(){let{execFileSync:J}=await import("child_process"),U=V.projectPath("pantry"),K=await IJ();J(K.command,[...K.args,"install",DJ,"--install-dir",U,"--platform",jJ,"--quiet"],{cwd:V.projectPath(),stdio:$?"inherit":"pipe",env:F.env})}async function PJ(){let{existsSync:J}=await import("fs"),{join:U}=await import("path"),K=[V.projectPath("pantry"),`${F.env.HOME}/.local/share/pantry`],Q=[..._J.map((T)=>V.projectPath(`pantry/.bin/${T}`)),..._J.map((T)=>U(`${F.env.HOME}/.local/share/pantry/global/bin`,T))];for(let T of Q)if(J(T)&&await AJ(T))return T;for(let T of K){let C=await xJ(T,_J);for(let j of C)if(await AJ(j))return j}return null}var bJ={".html":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".eot":"application/vnd.ms-fontobject",".otf":"font/otf",".webp":"image/webp",".mp4":"video/mp4",".webm":"video/webm",".mp3":"audio/mpeg",".wav":"audio/wav",".pdf":"application/pdf",".xml":"application/xml",".txt":"text/plain"};function VJ(J){let U=J.lastIndexOf("."),K=U>=0?J.slice(U).toLowerCase():"";return bJ[K]||"application/octet-stream"}async function XJ(J,U,K="",Q=[".DS_Store"]){let{readdirSync:T,statSync:C}=await import("fs"),{join:j}=await import("path"),d=T(J);for(let a of d){if(Q.includes(a))continue;let v=j(J,a),f=K?`${K}/${a}`:a;if(C(v).isDirectory())await XJ(v,U,f,Q);else await U(v,f)}}async function hJ(){try{let{generateSignalsRuntime:J}=await import("@stacksjs/stx/signals");return`<script>
2
+ import{ib as W}from"../../chunk-jbvvb45k.js";import{existsSync as YJ,readFileSync as EJ,statSync as wJ}from"fs";import F from"process";import{runCommand as WJ,spinner as g}from"@stacksjs/cli";import{config as OJ}from"@stacksjs/config";import{path as V}from"@stacksjs/path";import{storage as FJ}from"@stacksjs/storage";import{ExitCode as NJ}from"@stacksjs/types";var z={debug:(...J)=>{if(F.argv.includes("--verbose")||F.argv.includes("-v"))console.log("\uD83D\uDD0D",...J)},success:(...J)=>console.log("\u2713",...J),error:(...J)=>console.error("\u2717",...J)},TJ="github.com/mail-os/mail",DJ=`${TJ}@0.1.0`,jJ="linux-x86_64",_J=["mail","mail-x86_64-linux","mail-x86_64-linux-gnu"],$=F.argv.includes("--verbose")||F.argv.includes("-v");async function xJ(J,U,K=8){let{existsSync:Q,readdirSync:T,statSync:C}=await import("fs"),{join:j,basename:d}=await import("path"),a=new Set(U),v=[];if(!Q(J))return v;function f(KJ,zJ){if(zJ>K)return;for(let UJ of T(KJ)){if(UJ===".git"||UJ==="node_modules")continue;let n=j(KJ,UJ),t=C(n);if(t.isDirectory())f(n,zJ+1);else if(t.isFile()&&a.has(d(n)))v.push(n)}}return f(J,0),v}async function AJ(J){let{readFileSync:U}=await import("fs"),K=U(J).slice(0,4);return K[0]===127&&K[1]===69&&K[2]===76&&K[3]===70}async function IJ(){let{existsSync:J}=await import("fs"),U=`${F.env.HOME}/Code/Tools/pantry/packages/ts-pantry/bin/cli.ts`;if(J(U))return{command:"bun",args:[U]};let K=V.projectPath("pantry/.bin/pantry");if(J(K))return{command:K,args:[]};let Q=`${F.env.HOME}/.local/share/pantry/global/bin/pantry`;if(J(Q))return{command:Q,args:[]};return{command:"pantry",args:[]}}async function fJ(){let{execFileSync:J}=await import("child_process"),U=V.projectPath("pantry"),K=await IJ();J(K.command,[...K.args,"install",DJ,"--install-dir",U,"--platform",jJ,"--quiet"],{cwd:V.projectPath(),stdio:$?"inherit":"pipe",env:F.env})}async function PJ(){let{existsSync:J}=await import("fs"),{join:U}=await import("path"),K=[V.projectPath("pantry"),`${F.env.HOME}/.local/share/pantry`],Q=[..._J.map((T)=>V.projectPath(`pantry/.bin/${T}`)),..._J.map((T)=>U(`${F.env.HOME}/.local/share/pantry/global/bin`,T))];for(let T of Q)if(J(T)&&await AJ(T))return T;for(let T of K){let C=await xJ(T,_J);for(let j of C)if(await AJ(j))return j}return null}var bJ={".html":"text/html",".css":"text/css",".js":"application/javascript",".json":"application/json",".png":"image/png",".jpg":"image/jpeg",".jpeg":"image/jpeg",".gif":"image/gif",".svg":"image/svg+xml",".ico":"image/x-icon",".woff":"font/woff",".woff2":"font/woff2",".ttf":"font/ttf",".eot":"application/vnd.ms-fontobject",".otf":"font/otf",".webp":"image/webp",".mp4":"video/mp4",".webm":"video/webm",".mp3":"audio/mpeg",".wav":"audio/wav",".pdf":"application/pdf",".xml":"application/xml",".txt":"text/plain"};function VJ(J){let U=J.lastIndexOf("."),K=U>=0?J.slice(U).toLowerCase():"";return bJ[K]||"application/octet-stream"}async function XJ(J,U,K="",Q=[".DS_Store"]){let{readdirSync:T,statSync:C}=await import("fs"),{join:j}=await import("path"),d=T(J);for(let a of d){if(Q.includes(a))continue;let v=j(J,a),f=K?`${K}/${a}`:a;if(C(v).isDirectory())await XJ(v,U,f,Q);else await U(v,f)}}async function hJ(){try{let{generateSignalsRuntime:J}=await import("@stacksjs/stx/signals");return`<script>
3
3
  ${J()}
4
4
  </script>`}catch{return console.warn("Could not load STX signals runtime"),""}}async function e(J,U="s3 operation"){for(let Q=0;Q<=3;Q++)try{return await J()}catch(T){if(Q>=3)throw T;let C=Math.min(500*2**Q+Math.random()*200,5000);if($)z.debug(` Retrying ${U} (attempt ${Q+2}/4) in ${Math.round(C)}ms...`);await new Promise((j)=>setTimeout(j,C))}throw Error(`${U} failed after 4 attempts`)}function RJ(J){if(!J)return[];return Array.isArray(J)?J:[J]}function MJ(J,U,K=""){if(U===null||U===void 0)return"";if(typeof U==="boolean")return`${K}<${J}>${U}</${J}>
5
5
  `;if(typeof U==="number"||typeof U==="string")return`${K}<${J}>${U}</${J}>
@@ -10,7 +10,7 @@ ${Q}${K}</${J}>
10
10
  <DistributionConfig xmlns="http://cloudfront.amazonaws.com/doc/2020-05-31/">
11
11
  ${Object.entries(J).filter(([U])=>!U.startsWith("@_")).map(([U,K])=>MJ(U,K," ")).join("")}</DistributionConfig>
12
12
  `}function LJ(J){let U=[...new Set(J)].filter((Q)=>Number.isFinite(Q)&&Q>0).sort((Q,T)=>Q-T);if(U.length===0)return"true";return`if command -v firewall-cmd >/dev/null 2>&1; then firewall-cmd --permanent ${U.map((Q)=>`--add-port=${Q}/tcp`).join(" ")} && firewall-cmd --reload; fi`}async function CJ(J,U,K){if(!U)return;if(((await J.describeSecurityGroups({GroupIds:[U]}))?.SecurityGroups?.[0]?.IpPermissions||[]).some((j)=>{return j.IpProtocol==="tcp"&&Number(j.FromPort)<=K&&Number(j.ToPort)>=K&&RJ(j.IpRanges).some((d)=>d.CidrIp==="0.0.0.0/0")}))return;try{await J.authorizeSecurityGroupIngress({GroupId:U,IpPermissions:[{IpProtocol:"tcp",FromPort:K,ToPort:K,IpRanges:[{CidrIp:"0.0.0.0/0",Description:`Stacks API port ${K}`}]}]})}catch(j){if(!String(j?.message||"").includes("InvalidPermission.Duplicate"))throw j}}async function SJ(J,U,K){if(!U)return;let Q=await J.request({service:"cloudfront",region:"us-east-1",method:"GET",path:`/2020-05-31/distribution/${U}/config`,returnHeaders:!0}),T=Q.headers?.etag||Q.headers?.ETag||"",C=Q.body?.DistributionConfig||Q.DistributionConfig||Q.body;if(!T||!C?.Origins?.Items)return;let d=RJ(C.Origins.Items.Origin).find((a)=>String(a.Id||"").includes("-api"));if(!d?.CustomOriginConfig)return;if(Number(d.CustomOriginConfig.HTTPPort)===K)return;d.CustomOriginConfig.HTTPPort=K,await J.request({service:"cloudfront",region:"us-east-1",method:"PUT",path:`/2020-05-31/distribution/${U}/config`,body:kJ(C),headers:{"Content-Type":"application/xml","If-Match":T}})}var BJ=g("Building framework...");BJ.start();await WJ("bun run build",{cwd:V.frameworkPath("core"),quiet:!1});BJ.succeed("Framework built");var GJ=V.projectPath("docs"),vJ=V.projectPath("dist/docs/.bunpress");if(FJ.hasFiles(GJ)){let J=g("Building documentation with BunPress...");J.start();try{let{rm:U}=await import("fs/promises"),K=`${F.env.HOME}/Code/Tools/bunpress/packages/bunpress/bin/cli.ts`,Q=V.projectPath("node_modules/@stacksjs/bunpress/dist/bin/cli.js"),T=await Bun.file(K).exists(),C=await Bun.file(Q).exists(),j=T?`bun ${K} build --dir ${GJ} --outdir ${V.projectPath("dist/docs")}`:C?`bun ${Q} build --dir ${GJ} --outdir ${V.projectPath("dist/docs")}`:"bunx @stacksjs/bunpress@0.1.5 build --dir ./docs --outdir ./dist/docs";await U(vJ,{recursive:!0,force:!0}),await WJ(j,{cwd:V.projectPath(),quiet:!$}),J.succeed(`Documentation built with BunPress${T?" (local checkout)":""}`)}catch(U){if(J.stop(),console.log(`\u26A0 Documentation build skipped: ${U.message}`),$)z.debug("To build docs manually: cd ~/Code/Tools/bunpress && bun packages/bunpress/bin/cli.ts build --dir /path/to/docs --outdir /path/to/dist/docs")}}else if($)z.debug("No docs directory found, skipping documentation build");var yJ=FJ.hasFiles(V.projectPath("dist/blog")),gJ=["CampmateScript-Regular.woff2","SequoiaSans-Regular.woff2","Switchback-Regular.woff2"].every((J)=>YJ(V.projectPath(`dist/blog/assets/fonts/nps/${J}`))),cJ=["topography.svg","park-ridge.svg"].every((J)=>YJ(V.projectPath(`dist/blog/assets/images/${J}`))),HJ=V.projectPath("dist/blog/index.html"),JJ=YJ(HJ)?EJ(HJ,"utf8"):"",dJ=JJ.length>0&&!JJ.includes("woff2-variations"),mJ=JJ.includes("--on-primary")&&JJ.includes("--newsletter-bg"),pJ=JJ.includes("topography.svg")&&JJ.includes("park-ridge.svg"),uJ=!JJ.includes("stamp-trail")&&!JJ.includes("blog-sign-tree.svg"),sJ=V.frameworkPath("core/cms/src/build.ts"),lJ=V.projectPath("config/blog.ts"),aJ=YJ(HJ)&&[sJ,lJ].filter((J)=>YJ(J)).every((J)=>wJ(HJ).mtimeMs>=wJ(J).mtimeMs);if(!yJ||!gJ||!cJ||!dJ||!mJ||!pJ||!uJ||!aJ){let J=g("Building blog...");J.start();try{let U=(await import(V.projectPath("config/blog"))).default,{buildBlogSite:K}=await import(V.frameworkPath("core/cms/src/build"));await K({config:U,outDir:V.projectPath("dist/blog")}),J.succeed("Blog built successfully")}catch(U){if(J.stop(),console.log(`\u26A0 Blog build skipped: ${U.message}`),$)z.debug(`Blog build error: ${U.stack}`)}}else if($)z.debug("Pre-built blog found at dist/blog, skipping build");if($)z.debug("Skipping views build (vite-config not configured)");var iJ=await import(V.projectPath("config/cloud")),oJ=iJ?.tsCloud?.mode||"server";if(oJ==="serverless"){let J=g("Building server...");J.start(),await WJ("bun build.ts",{cwd:V.frameworkPath("server"),quiet:!$}),J.succeed("Server built");let U=g("Packaging for deployment...");U.start(),await WJ("bun zip.ts",{cwd:V.corePath("cloud"),quiet:!$}),U.succeed("Package ready")}else if($)z.debug("Skipping server build and packaging (server mode)");if(!F.env.AWS_ACCESS_KEY_ID||!F.env.AWS_SECRET_ACCESS_KEY){let{existsSync:J,readFileSync:U}=await import("fs"),K=F.env.APP_ENV||F.env.NODE_ENV||"production",Q=[V.projectPath(`.env.${K}`),V.projectPath(".env")];for(let T of Q)if(J(T)){let C=U(T,"utf-8");for(let j of C.split(`
13
- `)){let d=j.trim();if(d.startsWith("#")||!d.includes("="))continue;let a=d.indexOf("="),v=d.slice(0,a).trim(),f=d.slice(a+1).trim();if(f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'"))f=f.slice(1,-1);if(v==="AWS_ACCESS_KEY_ID"&&f)F.env.AWS_ACCESS_KEY_ID=f;else if(v==="AWS_SECRET_ACCESS_KEY"&&f)F.env.AWS_SECRET_ACCESS_KEY=f;else if(v==="AWS_REGION"&&f&&!F.env.AWS_REGION)F.env.AWS_REGION=f;else if(v==="AWS_ACCOUNT_ID"&&f&&!F.env.AWS_ACCOUNT_ID)F.env.AWS_ACCOUNT_ID=f;else if(v.startsWith("MAIL_PASSWORD_")&&f&&!F.env[v])F.env[v]=f}if($)z.debug(`Loaded AWS credentials from ${T}`);break}}try{let{deployStack:J,deployFrontend:U}=await import("../../chunk-tc935b45.js"),K=F.env.APP_ENV||F.env.NODE_ENV||"production",Q=F.env.AWS_REGION||"us-east-1",T=await import(V.projectPath("config/cloud")),C=T?.tsCloud?.mode||"server",j=T?.tsCloud?.project?.name||T?.tsCloud?.project?.slug||"stacks";if(C==="serverless"){console.log(""),console.log("Serverless deployment mode detected"),console.log("Building and pushing container image..."),console.log("");let Y=F.env.AWS_ACCOUNT_ID||await d(Q);if(!Y||Y.length<10)throw Error(`Invalid AWS Account ID: "${Y||"(empty)"}"
13
+ `)){let d=j.trim();if(d.startsWith("#")||!d.includes("="))continue;let a=d.indexOf("="),v=d.slice(0,a).trim(),f=d.slice(a+1).trim();if(f.startsWith('"')&&f.endsWith('"')||f.startsWith("'")&&f.endsWith("'"))f=f.slice(1,-1);if(v==="AWS_ACCESS_KEY_ID"&&f)F.env.AWS_ACCESS_KEY_ID=f;else if(v==="AWS_SECRET_ACCESS_KEY"&&f)F.env.AWS_SECRET_ACCESS_KEY=f;else if(v==="AWS_REGION"&&f&&!F.env.AWS_REGION)F.env.AWS_REGION=f;else if(v==="AWS_ACCOUNT_ID"&&f&&!F.env.AWS_ACCOUNT_ID)F.env.AWS_ACCOUNT_ID=f;else if(v.startsWith("MAIL_PASSWORD_")&&f&&!F.env[v])F.env[v]=f}if($)z.debug(`Loaded AWS credentials from ${T}`);break}}try{let{deployStack:J,deployFrontend:U}=await import("../../chunk-77pta9ww.js"),K=F.env.APP_ENV||F.env.NODE_ENV||"production",Q=F.env.AWS_REGION||"us-east-1",T=await import(V.projectPath("config/cloud")),C=T?.tsCloud?.mode||"server",j=T?.tsCloud?.project?.name||T?.tsCloud?.project?.slug||"stacks";if(C==="serverless"){console.log(""),console.log("Serverless deployment mode detected"),console.log("Building and pushing container image..."),console.log("");let Y=F.env.AWS_ACCOUNT_ID||await d(Q);if(!Y||Y.length<10)throw Error(`Invalid AWS Account ID: "${Y||"(empty)"}"
14
14
  Set AWS_ACCOUNT_ID in your .env file or ensure valid AWS credentials are configured.`);let H=`${Y}.dkr.ecr.${Q}.amazonaws.com/${j}-${K}-api`,M=`${H}:latest`;if($)z.debug(`ECR repository: ${H}`);if($)z.debug("ECR credentials will be validated before push...");let O=g("Building Docker image...");O.start();try{let{exec:q}=await import("child_process"),{promisify:D}=await import("util"),B=D(q),A=`docker build --platform linux/amd64 -t ${M} -f Dockerfile .`,{stdout:w,stderr:E}=await B(A,{cwd:V.projectPath(),env:F.env,maxBuffer:10485760,timeout:900000});if($&&w)z.debug(w);if($&&E)z.debug(E);O.succeed(`Docker image built: ${M}`)}catch(q){if(O.fail("Docker build failed"),$)z.debug(`Docker build error: ${q.message}`);throw q}let X=g("Checking ECR repository...");X.start();try{let{ECRClient:q}=await import("@stacksjs/ts-cloud"),D=new q(Q),B=`${j}-${K}-api`;try{await D.describeRepositories({repositoryNames:[B]}),X.succeed(`ECR repository exists: ${B}`)}catch(A){if(A.code==="RepositoryNotFoundException"||A.message?.includes("RepositoryNotFoundException"))X.text=`Creating ECR repository: ${B}...`,await D.createRepository({repositoryName:B,imageScanningConfiguration:{scanOnPush:!0},imageTagMutability:"MUTABLE"}),X.succeed(`ECR repository created: ${B}`);else throw A}}catch(q){if(X.fail("ECR repository check failed"),$)z.debug(`ECR repository error: ${q.message}`);throw q}let N=g("Authenticating to ECR...");N.start();try{let{ECRClient:q}=await import("@stacksjs/ts-cloud"),A=(await new q(Q).getAuthorizationToken()).authorizationData?.[0];if(!A?.authorizationToken)throw Error("No authorization token received from ECR");let w=Buffer.from(A.authorizationToken,"base64").toString("utf-8"),E=w.indexOf(":");if(E===-1)throw Error("ECR authorization token has unexpected format (missing colon separator)");let R=w.slice(E+1),G=Bun.spawnSync(["docker","login","--username","AWS","--password-stdin",`${Y}.dkr.ecr.${Q}.amazonaws.com`],{stdin:new TextEncoder().encode(R),stdout:"pipe",stderr:"pipe"});if(G.exitCode!==0){let P=new TextDecoder().decode(G.stderr);throw Error(`Docker login failed: ${P}`)}N.succeed("Authenticated to ECR")}catch(q){if(N.fail("ECR authentication failed"),$)z.debug(`ECR auth error: ${q.message}`);throw q}console.log("");let S=g("Pushing image to ECR...");S.start();try{let{exec:q}=await import("child_process"),{promisify:D}=await import("util"),B=D(q),A=`docker push ${M}`;await B(A,{env:F.env}),S.succeed(`Image pushed: ${M}`)}catch(q){if(S.fail("Docker push failed"),$)z.debug(`Push error: ${q.message}`);throw q}console.log(""),console.log("Container image ready in ECR. CloudFormation will use this image."),console.log("")}else console.log(""),console.log("Server deployment mode detected"),console.log("Deploying EC2 infrastructure via CloudFormation..."),console.log("");async function d(Y){try{let{STSClient:H}=await import("@stacksjs/ts-cloud"),X=(await new H(Y).getCallerIdentity()).Account||F.env.AWS_ACCOUNT_ID||"";if($)z.debug(`Retrieved AWS Account ID: ${X||"(empty)"}`);return X}catch(H){if($)z.debug(`Failed to get AWS Account ID: ${H.message}`);return F.env.AWS_ACCOUNT_ID||""}}try{let Y=await import(V.projectPath("cloud/deploy-script"));if(typeof Y.beforeDeploy==="function")await Y.beforeDeploy({environment:K,region:Q})}catch(Y){if(Y.code==="ERR_MODULE_NOT_FOUND"||Y.code==="MODULE_NOT_FOUND"){if($)z.debug("No beforeDeploy hook found (cloud/deploy-script not found)")}else if(console.warn(`\u26A0 beforeDeploy hook failed: ${Y.message}`),$)z.debug(`beforeDeploy error stack: ${Y.stack}`)}await J({environment:K,region:Q,waitForCompletion:!0,verbose:$});try{let Y=await import(V.projectPath("cloud/deploy-script"));if(typeof Y.afterDeploy==="function"){let{CloudFormationClient:H}=await import("@stacksjs/ts-cloud"),M=new H(Q),O=`${j}-cloud`,X={};try{X=await M.getStackOutputs(O)}catch(N){if($)z.debug(`Failed to get stack outputs: ${N instanceof Error?N.message:String(N)}`)}await Y.afterDeploy({environment:K,region:Q,outputs:X})}}catch(Y){if(Y.code==="ERR_MODULE_NOT_FOUND"||Y.code==="MODULE_NOT_FOUND"){if($)z.debug("No afterDeploy hook found (cloud/deploy-script not found)")}else if(console.warn(`\u26A0 afterDeploy hook failed: ${Y.message}`),$)z.debug(`afterDeploy error stack: ${Y.stack}`)}let a=g("Running database migrations...");a.start();try{let{generateMigrations:Y,runDatabaseMigration:H}=await import("@stacksjs/database");await Y(),await H(),a.succeed("Database migrations completed")}catch(Y){if(a.stop(),console.log(`\u26A0 Database migrations skipped: ${Y.message}`),$)z.debug(`Migration error: ${Y.stack}`)}if(C==="server"){let Y=g("Retrieving server instance details...");Y.start();try{let{CloudFormationClient:O}=await import("@stacksjs/ts-cloud"),X=new O(Q),N=`${j}-cloud`,S=await X.getStackOutputs(N);Y.succeed("Server instances deployed"),console.log(""),console.log("Server instances:");for(let[q,D]of Object.entries(S)){if(q.endsWith("PublicIp"))console.log(` ${q}: ${D}`);if(q.endsWith("InstanceId"))console.log(` ${q}: ${D}`)}console.log("")}catch(O){if(Y.stop(),console.log(`\u26A0 Could not retrieve server details: ${O.message}`),$)z.debug(`Output retrieval error: ${O.stack}`)}let H=g("Deploying API server to EC2...");H.start();try{let{S3Client:O,CloudFormationClient:X,AWSClient:N}=await import("@stacksjs/ts-cloud"),{readFileSync:S,existsSync:q}=await import("fs"),{resolve:D}=await import("path"),B=new O(Q),A=new X(Q),w=new N,E=`${j}-cloud`,R=await A.getStackOutputs(E),G=R.FrontendBucketName,P=Number(OJ.ports?.api||3008),b;for(let[c,m]of Object.entries(R))if(c.endsWith("InstanceId")&&typeof m==="string"){b=m;break}let h;if(b){let{EC2Client:c}=await import("@stacksjs/ts-cloud"),m=new c(Q);h=(await m.describeInstances({Filters:[{Name:"instance-id",Values:[b]}]}))?.Reservations?.[0]?.Instances?.[0]?.SecurityGroups?.[0]?.GroupId,await CJ(m,h,P)}if(!b||!G){if(H.stop(),!b)console.log("\u26A0 No EC2 instance found in stack outputs, skipping server deploy");if(!G)console.log("\u26A0 No S3 bucket found for staging server artifacts")}else{let c=R.publicCloudFrontDistributionId||R.CloudFrontDistributionId;await SJ(w,c,P);let m=D(V.projectPath("node_modules/@stacksjs/ts-cloud/dist/index.js"));if(q(m)){let _=S(m);if(await e(()=>B.putObject({bucket:G,key:"_deploy/ts-cloud-dist.js",body:_,contentType:"application/javascript"}),"upload ts-cloud dist"),$)z.debug(" Uploaded ts-cloud dist to S3")}let p=`import { Database } from "bun:sqlite";
15
15
  import { SESClient } from "./ts-cloud-dist.js";
16
16
 
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{gb as w}from"../../chunk-96b7fcmd.js";import{existsSync as X}from"fs";import N from"process";import{parseOptions as D}from"@stacksjs/cli";import{config as G,overridesReady as O}from"@stacksjs/config";import{path as Y}from"@stacksjs/path";import{cors as W,route as J}from"@stacksjs/router";import{generateAutoImportFiles as Q,injectGlobalAutoImports as T}from"@stacksjs/server";var v=D();await O;var M=Number(N.env.PORT_API)||G.ports?.api||3008,U=Y.storagePath("framework/auto-imports/models.ts");if(!X(U))await Q();await T();try{let z=Y.appPath("Listener.ts");if(X(z)){let B=await import(z);if(typeof B.handleEvents==="function")await B.handleEvents()}}catch(z){let{log:B}=await import("@stacksjs/cli");B.warn(`[api:dev] failed to bootstrap event listeners \u2014 dispatched events will be ignored: ${z.message}`)}J.use(W().handle.bind(W()));var F=/^[a-zA-Z0-9._-]{8,128}$/;J.use(async(z,B)=>{let K=z?.headers?.get?.("x-request-id")||z?.headers?.get?.("X-Request-ID")||"",L=typeof K==="string"&&F.test(K)?K:crypto.randomUUID();z._requestId=L,z._startNs=N.hrtime.bigint();let C=await B();if(C&&C.status===404&&(C.headers.get("content-type")||"").includes("json"))try{let H=await C.clone().json();if(H&&(H.message==="Not Found"||H.error==="Not Found")){let Z=new URL(z.url),$={...H,path:Z.pathname,method:z.method,request_id:L},V=new Headers(C.headers);return V.set("X-Request-ID",L),new Response(JSON.stringify($),{status:404,headers:V})}}catch{}return C});await J.importRoutes();try{await J.serve({port:M,hostname:"127.0.0.1"}),console.log(`
2
+ import{ib as w}from"../../chunk-jbvvb45k.js";import{existsSync as X}from"fs";import N from"process";import{parseOptions as D}from"@stacksjs/cli";import{config as G,overridesReady as O}from"@stacksjs/config";import{path as Y}from"@stacksjs/path";import{cors as W,route as J}from"@stacksjs/router";import{generateAutoImportFiles as Q,injectGlobalAutoImports as T}from"@stacksjs/server";var v=D();await O;var M=Number(N.env.PORT_API)||G.ports?.api||3008,U=Y.storagePath("framework/auto-imports/models.ts");if(!X(U))await Q();await T();try{let z=Y.appPath("Listener.ts");if(X(z)){let B=await import(z);if(typeof B.handleEvents==="function")await B.handleEvents()}}catch(z){let{log:B}=await import("@stacksjs/cli");B.warn(`[api:dev] failed to bootstrap event listeners \u2014 dispatched events will be ignored: ${z.message}`)}J.use(W().handle.bind(W()));var F=/^[a-zA-Z0-9._-]{8,128}$/;J.use(async(z,B)=>{let K=z?.headers?.get?.("x-request-id")||z?.headers?.get?.("X-Request-ID")||"",L=typeof K==="string"&&F.test(K)?K:crypto.randomUUID();z._requestId=L,z._startNs=N.hrtime.bigint();let C=await B();if(C&&C.status===404&&(C.headers.get("content-type")||"").includes("json"))try{let H=await C.clone().json();if(H&&(H.message==="Not Found"||H.error==="Not Found")){let Z=new URL(z.url),$={...H,path:Z.pathname,method:z.method,request_id:L},V=new Headers(C.headers);return V.set("X-Request-ID",L),new Response(JSON.stringify($),{status:404,headers:V})}}catch{}return C});await J.importRoutes();try{await J.serve({port:M,hostname:"127.0.0.1"}),console.log(`
3
3
  \u279C API server ready: http://localhost:${M}
4
4
  `)}catch(z){if((z?.code||z?.errno)==="EADDRINUSE"||String(z?.message||"").includes("EADDRINUSE"))console.error(`
5
5
  [dev/api] Port ${M} is already in use. Kill the other process and re-run \`./buddy dev\`, or set PORT_API to another port.
@@ -1,3 +1,3 @@
1
1
  // @bun
2
- import"../../chunk-96b7fcmd.js";import{existsSync as $,readdirSync as U,statSync as k}from"fs";import{join as V}from"path";import w from"process";import{projectPath as W,storagePath as D}from"@stacksjs/path";var H=[D("framework/defaults/resources/functions/dashboard"),W("resources/functions"),W("app/Helpers")];async function F(q={}){let B=globalThis,C=[],G=0;for(let J of H){if(!$(J))continue;let K;try{K=U(J)}catch{continue}for(let A of K){let z=V(J,A),M;try{M=k(z)}catch{continue}if(M.isDirectory()){let O;try{O=U(z)}catch{continue}for(let Q of O){if(!X(Q))continue;let Z=V(z,Q),T=await Y(Z,B,q.verbose);G+=T.added,C.push(...T.collisions)}continue}if(!X(A))continue;let N=await Y(z,B,q.verbose);G+=N.added,C.push(...N.collisions)}}if(q.verbose)w.stdout.write(`[dashboard] hoisted ${G} helper globals`+(C.length>0?` (skipped ${C.length} collisions: ${C.slice(0,5).join(", ")}\u2026)`:"")+`
2
+ import"../../chunk-jbvvb45k.js";import{existsSync as $,readdirSync as U,statSync as k}from"fs";import{join as V}from"path";import w from"process";import{projectPath as W,storagePath as D}from"@stacksjs/path";var H=[D("framework/defaults/resources/functions/dashboard"),W("resources/functions"),W("app/Helpers")];async function F(q={}){let B=globalThis,C=[],G=0;for(let J of H){if(!$(J))continue;let K;try{K=U(J)}catch{continue}for(let A of K){let z=V(J,A),M;try{M=k(z)}catch{continue}if(M.isDirectory()){let O;try{O=U(z)}catch{continue}for(let Q of O){if(!X(Q))continue;let Z=V(z,Q),T=await Y(Z,B,q.verbose);G+=T.added,C.push(...T.collisions)}continue}if(!X(A))continue;let N=await Y(z,B,q.verbose);G+=N.added,C.push(...N.collisions)}}if(q.verbose)w.stdout.write(`[dashboard] hoisted ${G} helper globals`+(C.length>0?` (skipped ${C.length} collisions: ${C.slice(0,5).join(", ")}\u2026)`:"")+`
3
3
  `)}function X(q){if(!/\.(?:ts|tsx|js|mjs)$/.test(q))return!1;if(q.startsWith("_"))return!1;if(q.endsWith(".test.ts")||q.endsWith(".spec.ts"))return!1;if(q.endsWith(".d.ts"))return!1;return!0}async function Y(q,B,C){let G;try{G=await import(q)}catch{return{added:0,collisions:[]}}let J=[],K=0;for(let[A,z]of Object.entries(G)){if(A==="default"||A.startsWith("_"))continue;if(typeof z==="function"||z&&typeof z==="object"){if(B[A]===void 0)B[A]=z,K++;else if(B[A]!==z)J.push(A)}}return{added:K,collisions:J}}export{F as hoistDashboardGlobals};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Aa as i,Ba as j,Ca as k,Da as l,Ea as m,sa as a,ta as b,ua as c,va as d,wa as e,xa as f,ya as g,za as h}from"../../chunk-kzhgexj4.js";import"../../chunk-96b7fcmd.js";export{k as waitForServer,f as scanModelsDir,d as modelNameToId,i as isPortAvailable,a as iconMap,e as getModelIcon,j as findAvailablePort,b as excludeModels,g as discoverModels,c as dedicatedPages,l as buildSidebarConfig,h as buildManifest,m as buildDashboardUrl};
2
+ import{Aa as i,Ba as j,Ca as k,Da as l,Ea as m,sa as a,ta as b,ua as c,va as d,wa as e,xa as f,ya as g,za as h}from"../../chunk-kzhgexj4.js";import"../../chunk-jbvvb45k.js";export{k as waitForServer,f as scanModelsDir,d as modelNameToId,i as isPortAvailable,a as iconMap,e as getModelIcon,j as findAvailablePort,b as excludeModels,g as discoverModels,c as dedicatedPages,l as buildSidebarConfig,h as buildManifest,m as buildDashboardUrl};
@@ -1,8 +1,8 @@
1
1
  // @bun
2
- import{Ba as t,Ca as r,Da as o,ya as l,za as d}from"../../chunk-kzhgexj4.js";import{gb as U}from"../../chunk-96b7fcmd.js";import V from"process";import{existsSync as p,readFileSync as $E,writeFileSync as a}from"fs";import{bold as J,cyan as g,dim as _,green as f}from"@stacksjs/cli";import{projectPath as I,storagePath as S}from"@stacksjs/path";var c=V.argv.indexOf("--verbose"),A=c!==-1&&V.argv[c+1]!=="false",zE=Bun.nanoseconds(),s=console.log,GE=console.warn,h=[];console.log=(...X)=>{h.push(X.map(String).join(" "))};console.warn=(...X)=>{h.push(X.map(String).join(" "))};var q=S("framework/defaults/views/dashboard"),NE=I("resources/views/dashboard"),y=Number(V.env.PORT_ADMIN)||3002,R=await t(y),P=V.env.APP_URL||"",OE=P!==""&&P!=="localhost"&&!P.includes("localhost:"),n=OE?P.replace(/^https?:\/\//,""):null,C=n?`dashboard.${n}`:null,e=`${V.env.HOME}/.stacks/ssl`;function EE(){console.log=s,console.warn=(...X)=>{let N=X.map(String).join(" ");if(N.includes("[STX] DOM API violation")||N.includes("unsafe expression"))return;GE(...X)}}function F(X,N={}){let Y=new Headers(N.headers);return Y.set("content-type","application/json; charset=utf-8"),Y.set("cache-control","no-store"),new Response(JSON.stringify(X),{...N,headers:Y})}function WE(X){return X.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}async function L(X){if(X.method==="GET"||X.method==="HEAD")return{};let N=X.headers.get("content-type")||"";if(N.includes("application/json"))return await X.json().catch(()=>({}));if(N.includes("form")){let Y=await X.formData();return Object.fromEntries(Y.entries())}return{}}var KE={posts:["title","poster","content","excerpt","views","published_at","status","is_featured","author_id","created_at","updated_at"],pages:["title","template","views","published_at","conversions","author_id","created_at","updated_at"],authors:["name","email","user_id","created_at","updated_at"],categories:["name","description","slug","image_url","is_active","parent_category_id","display_order","created_at","updated_at"],tags:["name","slug","description","post_count","color","created_at","updated_at"],comments:["title","body","content","status","author_name","author_email","post_title","is_approved","approved_at","rejected_at","updated_at"]};function b(){let X=V.env.DB_DATABASE_PATH||"database/stacks.sqlite";return X.startsWith("/")?X:I(X)}function D(X){if(!/^[a-z_][a-z0-9_]*$/i.test(X))throw Error(`Invalid CMS database identifier: ${X}`);return`"${X.replace(/"/g,'""')}"`}function i(X,N){let Y=KE[X];if(!Y)throw Error(`Unsupported CMS table: ${X}`);return Object.fromEntries(Object.entries(N).filter(([z,O])=>Y.includes(z)&&O!==void 0))}async function HE(){if((V.env.DB_CONNECTION||"sqlite")!=="sqlite"||!p(b()))return;let{Database:X}=await import("bun:sqlite"),N=new X(b());async function Y(z,O){return N.query(`select * from ${D(z)} where id = ? limit 1`).get(O)}return{async all(z,O="created_at"){return N.query(`select * from ${D(z)} order by ${D(O)} desc`).all()},async insert(z,O){let W=i(z,O),K=Object.keys(W),H=K.map(()=>"?").join(", "),Z=`insert into ${D(z)} (${K.map(D).join(", ")}) values (${H})`,E=N.query(Z).run(...K.map(($)=>W[$]));return await Y(z,Number(E.lastInsertRowid))},async update(z,O,W){let K=i(z,W),H=Object.keys(K);if(H.length){let Z=H.map((E)=>`${D(E)} = ?`).join(", ");N.query(`update ${D(z)} set ${Z} where id = ?`).run(...H.map((E)=>K[E]),O)}return await Y(z,O)},async delete(z,O){N.query(`delete from ${D(z)} where id = ?`).run(O)},find:Y,close(){N.close()}}}async function _E(){let X=await HE();if(X)return X;let{db:N}=await import("@stacksjs/database");return{async all(Y,z="created_at"){let O=N.selectFrom(Y).selectAll();if(z)O=O.orderBy(z,"desc");return await O.execute()},async insert(Y,z){let O=await N.insertInto(Y).values(z).returningAll().executeTakeFirst();if(!O||O.id==null){let W=z.email?["email",z.email]:z.name?["name",z.name]:["title",z.title];O=await N.selectFrom(Y).selectAll().where(W[0],"=",W[1]).orderBy("id","desc").executeTakeFirst()}return O},async update(Y,z,O){return await N.updateTable(Y).set(O).where("id","=",z).execute(),await N.selectFrom(Y).selectAll().where("id","=",z).executeTakeFirst()},async delete(Y,z){await N.deleteFrom(Y).where("id","=",z).execute()},async find(Y,z){return await N.selectFrom(Y).selectAll().where("id","=",z).executeTakeFirst()}}}async function B(X,N,Y="created_at"){try{return await X.all(N,Y)}catch{return[]}}async function FE(X){let N=new URL(X.url);if(!N.pathname.startsWith("/api/dashboard/cms"))return null;let Y;try{Y=await _E();let O=N.pathname.replace(/^\/api\/dashboard\/cms\/?/,"").split("/").filter(Boolean),W=O[0]||"",K=O[1]?Number(O[1]):void 0,H=new Date().toISOString().slice(0,19).replace("T"," ");if(X.method==="GET"&&!W){let[Z,E,$,G,T,M]=await Promise.all([B(Y,"posts"),B(Y,"pages"),B(Y,"authors"),B(Y,"categories"),B(Y,"tags"),B(Y,"comments")]);return F({ok:!0,posts:Z,pages:E,authors:$,categories:G,tags:T,comments:M,stats:{posts:Z.length,publishedPosts:Z.filter((j)=>j.status==="published").length,draftPosts:Z.filter((j)=>j.status==="draft").length,pages:E.length,categories:G.length,tags:T.length,comments:M.length}})}if(W==="posts"){if(X.method==="POST"){let Z=await L(X),E=String(Z.title||"").trim();if(!E)return F({ok:!1,error:"Title is required"},{status:422});let $=await Y.insert("posts",{title:E,poster:String(Z.poster||""),content:String(Z.content||Z.body||""),excerpt:String(Z.excerpt||""),views:Number(Z.views||0),published_at:Z.status==="published"?H:Z.published_at||null,status:String(Z.status||"draft").toLowerCase(),is_featured:Z.is_featured?1:0,author_id:Z.author_id?Number(Z.author_id):null,created_at:H,updated_at:H});return F({ok:!0,post:$},{status:201})}if(X.method==="PATCH"&&K){let Z=await L(X),E={updated_at:H};for(let G of["title","poster","content","excerpt","status","published_at"])if(Z[G]!==void 0)E[G]=G==="status"?String(Z[G]).toLowerCase():Z[G];if(Z.views!==void 0)E.views=Number(Z.views);if(Z.is_featured!==void 0)E.is_featured=Z.is_featured?1:0;let $=await Y.update("posts",K,E);if(!$)return F({ok:!1,error:"Post not found"},{status:404});return F({ok:!0,post:$})}if(X.method==="DELETE"&&K)return await Y.delete("posts",K),F({ok:!0})}if(W==="tags"||W==="categories"){let Z=W;if(X.method==="POST"){let E=await L(X),$=String(E.name||"").trim();if(!$)return F({ok:!1,error:"Name is required"},{status:422});let G={name:$,slug:String(E.slug||WE($)),description:String(E.description||""),created_at:H,updated_at:H};if(W==="categories")G.is_active=E.is_active===void 0?!0:Boolean(E.is_active);if(W==="tags")G.post_count=Number(E.post_count||0),G.color=String(E.color||"");let T=await Y.insert(Z,G);return F({ok:!0,[W==="categories"?"category":"tag"]:T},{status:201})}if(X.method==="PATCH"&&K){let E=await L(X),$={updated_at:H};for(let T of["name","slug","description","color","image_url","parent_category_id"])if(E[T]!==void 0)$[T]=E[T];if(E.post_count!==void 0)$.post_count=Number(E.post_count);if(E.display_order!==void 0)$.display_order=Number(E.display_order);if(E.is_active!==void 0)$.is_active=E.is_active?1:0;let G=await Y.update(Z,K,$);if(!G)return F({ok:!1,error:`${W==="categories"?"Category":"Tag"} not found`},{status:404});return F({ok:!0,[W==="categories"?"category":"tag"]:G})}if(X.method==="DELETE"&&K)return await Y.delete(Z,K),F({ok:!0})}if(W==="pages"){if(X.method==="POST"){let Z=await L(X),E=String(Z.title||"").trim();if(!E)return F({ok:!1,error:"Title is required"},{status:422});let $=await Y.insert("pages",{title:E,template:String(Z.template||"default"),views:0,conversions:0,published_at:Z.status==="published"?H:null,author_id:Z.author_id?Number(Z.author_id):null,created_at:H,updated_at:H});return F({ok:!0,page:$},{status:201})}if(X.method==="PATCH"&&K){let Z=await L(X),E={updated_at:H};for(let G of["title","template","published_at"])if(Z[G]!==void 0)E[G]=Z[G];if(Z.views!==void 0)E.views=Number(Z.views);if(Z.conversions!==void 0)E.conversions=Number(Z.conversions);if(Z.author_id!==void 0)E.author_id=Z.author_id?Number(Z.author_id):null;let $=await Y.update("pages",K,E);if(!$)return F({ok:!1,error:"Page not found"},{status:404});return F({ok:!0,page:$})}if(X.method==="DELETE"&&K)return await Y.delete("pages",K),F({ok:!0})}if(W==="authors"){if(X.method==="POST"){let Z=await L(X),E=String(Z.name||"").trim(),$=String(Z.email||"").trim();if(!E||!$)return F({ok:!1,error:"Name and email are required"},{status:422});let G=await Y.insert("authors",{name:E,email:$,created_at:H,updated_at:H});return F({ok:!0,author:G},{status:201})}if(X.method==="PATCH"&&K){let Z=await L(X),E={updated_at:H};for(let G of["name","email"])if(Z[G]!==void 0)E[G]=Z[G];if(Z.user_id!==void 0)E.user_id=Z.user_id?Number(Z.user_id):null;let $=await Y.update("authors",K,E);if(!$)return F({ok:!1,error:"Author not found"},{status:404});return F({ok:!0,author:$})}if(X.method==="DELETE"&&K)return await Y.delete("authors",K),F({ok:!0})}if(W==="comments"){if(X.method==="PATCH"&&K){let Z=await L(X),E={updated_at:H};if(Z.content!==void 0)E.content=Z.content,E.body=Z.content;if(Z.body!==void 0)E.content=Z.body,E.body=Z.body;for(let G of["status","author_name","author_email","post_title"])if(Z[G]!==void 0)E[G]=Z[G];if(E.status==="approved")E.is_approved=1;if(E.status&&E.status!=="approved")E.is_approved=0;let $=await Y.update("comments",K,E);if(!$)return F({ok:!1,error:"Comment not found"},{status:404});return F({ok:!0,comment:$})}if(X.method==="DELETE"&&K)return await Y.delete("comments",K),F({ok:!0})}return F({ok:!1,error:"CMS endpoint not found"},{status:404})}catch(z){return F({ok:!1,error:z?.message||String(z)},{status:500})}finally{Y?.close?.()}}async function TE(){try{await import("@stacksjs/orm")}catch(E){if(A)console.warn("[dashboard] orm preload failed:",E?.message||E)}try{let{hoistDashboardGlobals:E}=await import("./dashboard-globals.js");await E({verbose:A})}catch(E){if(A)console.warn("[dashboard] globals preload failed:",E?.message||E)}let X;try{X=(await import("../../chunk-wv5yb5wb.js")).serve}catch{X=(await import(I("pantry/bun-plugin-stx/dist/serve.js"))).serve}let N;try{let E=I("pantry/@stacksjs/stx/dist/index.js");if(await Bun.file(E).exists())N=await import(E)}catch{}let{listConfigFiles:Y,readConfig:z,updateConfigKey:O}=await import(S("framework/defaults/resources/functions/dashboard/config-io.ts")),W={"/__deps/charts.js":S("framework/core/charts/dist/index.js")},K={...Object.fromEntries(Object.entries(W).map(([E,$])=>[E,async()=>{let G=Bun.file($);if(!await G.exists())return new Response(`// dependency dist missing: ${$}
3
- // rebuild with: cd ${$.replace(/\/dist\/[^/]+$/,"")} && bun build.ts`,{status:500,headers:{"content-type":"text/javascript; charset=utf-8"}});return new Response(G,{headers:{"content-type":"text/javascript; charset=utf-8","cache-control":"no-cache"}})}])),"/api/config/list":async()=>{try{return Response.json({ok:!0,files:Y()})}catch(E){return Response.json({ok:!1,error:E?.message},{status:500})}},"/api/config/read":async(E)=>{try{let G=new URL(E.url).searchParams.get("name")||"";if(!/^[\w-]+$/.test(G))return Response.json({ok:!1,error:"Invalid config name"},{status:400});let T=await z(G);if(!T)return Response.json({ok:!1,error:"Not found"},{status:404});return Response.json({ok:!0,name:G,fields:T.fields,values:T.values})}catch($){return Response.json({ok:!1,error:$?.message},{status:500})}},"/api/config/source":async(E)=>{try{let G=new URL(E.url).searchParams.get("name")||"";if(!/^[\w-]+$/.test(G))return Response.json({ok:!1,error:"Invalid config name"},{status:400});let T=await z(G);if(!T)return Response.json({ok:!1,error:"Not found"},{status:404});return new Response(T.source,{headers:{"content-type":"text/plain; charset=utf-8"}})}catch($){return Response.json({ok:!1,error:$?.message},{status:500})}},"/api/config/update":async(E)=>{if(E.method!=="POST")return Response.json({ok:!1,error:"Method not allowed"},{status:405});try{let $=await E.json(),G=$.file?.replace(/\.ts$/,"");if(!G||!/^[\w-]+$/.test(G))return Response.json({ok:!1,error:"Invalid file"},{status:400});let T=[];if(Array.isArray($.updates))for(let Q of $.updates){let x=Q.key??Q.path;if(typeof x==="string")T.push({key:x,value:Q.value})}else if($.key)T.push({key:$.key,value:$.value});if(T.length===0)return Response.json({ok:!1,error:"No updates supplied"},{status:400});let M=[];for(let Q of T)try{let x=await O(G,Q.key,H(Q.value));M.push({key:Q.key,ok:!0,newValue:x.newValue})}catch(x){M.push({key:Q.key,ok:!1,error:x?.message})}let j=M.every((Q)=>Q.ok);return Response.json({ok:j,file:G,results:M})}catch($){return Response.json({ok:!1,error:$?.message},{status:500})}}};function H(E){if(typeof E==="boolean"||typeof E==="number")return E;if(E==="true")return!0;if(E==="false")return!1;if(E===""||E==null)return"";if(typeof E==="string"&&/^-?\d+(?:\.\d+)?$/.test(E))return Number(E);return String(E)}X({patterns:[NE,q],port:R,componentsDir:S("framework/defaults/resources/components/Dashboard"),layoutsDir:q,partialsDir:q,quiet:!0,routes:K,onRequest:FE,auth:!1,...N&&{stxModule:N}}).catch((E)=>{EE(),console.error(`
2
+ import{Ba as t,Ca as r,Da as a,ya as l,za as d}from"../../chunk-kzhgexj4.js";import{ib as L}from"../../chunk-jbvvb45k.js";import V from"process";import{existsSync as w,readFileSync as zE,writeFileSync as o}from"fs";import{bold as k,cyan as f,dim as _,green as h}from"@stacksjs/cli";import{projectPath as A,storagePath as J}from"@stacksjs/path";var b=V.argv.indexOf("--verbose"),I=b!==-1&&V.argv[b+1]!=="false",GE=Bun.nanoseconds(),s=console.log,NE=console.warn,v=[];console.log=(...X)=>{v.push(X.map(String).join(" "))};console.warn=(...X)=>{v.push(X.map(String).join(" "))};var p=J("framework/defaults/views/dashboard"),OE=A("resources/views/dashboard"),y=Number(V.env.PORT_ADMIN)||3002,T=await t(y),g=V.env.APP_URL||"",WE=g!==""&&g!=="localhost"&&!g.includes("localhost:"),n=WE?g.replace(/^https?:\/\//,""):null,C=n?`dashboard.${n}`:null,e=`${V.env.HOME}/.stacks/ssl`;function EE(){console.log=s,console.warn=(...X)=>{let O=X.map(String).join(" ");if(O.includes("[STX] DOM API violation")||O.includes("unsafe expression"))return;NE(...X)}}function F(X,O={}){let Y=new Headers(O.headers);return Y.set("content-type","application/json; charset=utf-8"),Y.set("cache-control","no-store"),new Response(JSON.stringify(X),{...O,headers:Y})}function KE(X){return X.trim().toLowerCase().replace(/['"]/g,"").replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}async function D(X){if(X.method==="GET"||X.method==="HEAD")return{};let O=X.headers.get("content-type")||"";if(O.includes("application/json"))return await X.json().catch(()=>({}));if(O.includes("form")){let Y=await X.formData();return Object.fromEntries(Y.entries())}return{}}var ZE={posts:["title","poster","content","excerpt","views","published_at","status","is_featured","author_id","created_at","updated_at"],pages:["title","template","views","published_at","conversions","author_id","created_at","updated_at"],authors:["name","email","user_id","created_at","updated_at"],categories:["name","description","slug","image_url","is_active","parent_category_id","display_order","created_at","updated_at"],tags:["name","slug","description","post_count","color","created_at","updated_at"],comments:["title","body","content","status","author_name","author_email","post_title","is_approved","approved_at","rejected_at","updated_at"]};function c(){let X=V.env.DB_DATABASE_PATH||"database/stacks.sqlite";return X.startsWith("/")?X:A(X)}function U(X){if(!/^[a-z_][a-z0-9_]*$/i.test(X))throw Error(`Invalid CMS database identifier: ${X}`);return`"${X.replace(/"/g,'""')}"`}function i(X,O){let Y=ZE[X];if(!Y)throw Error(`Unsupported CMS table: ${X}`);return Object.fromEntries(Object.entries(O).filter(([G,W])=>Y.includes(G)&&W!==void 0))}async function HE(){if((V.env.DB_CONNECTION||"sqlite")!=="sqlite"||!w(c()))return;let{Database:X}=await import("bun:sqlite"),O=new X(c());async function Y(G,W){return O.query(`select * from ${U(G)} where id = ? limit 1`).get(W)}return{async all(G,W="created_at"){return O.query(`select * from ${U(G)} order by ${U(W)} desc`).all()},async insert(G,W){let K=i(G,W),Z=Object.keys(K),H=Z.map(()=>"?").join(", "),$=`insert into ${U(G)} (${Z.map(U).join(", ")}) values (${H})`,E=O.query($).run(...Z.map((z)=>K[z]));return await Y(G,Number(E.lastInsertRowid))},async update(G,W,K){let Z=i(G,K),H=Object.keys(Z);if(H.length){let $=H.map((E)=>`${U(E)} = ?`).join(", ");O.query(`update ${U(G)} set ${$} where id = ?`).run(...H.map((E)=>Z[E]),W)}return await Y(G,W)},async delete(G,W){O.query(`delete from ${U(G)} where id = ?`).run(W)},find:Y,close(){O.close()}}}async function _E(){let X=await HE();if(X)return X;let{db:O}=await import("@stacksjs/database");return{async all(Y,G="created_at"){let W=O.selectFrom(Y).selectAll();if(G)W=W.orderBy(G,"desc");return await W.execute()},async insert(Y,G){let W=await O.insertInto(Y).values(G).returningAll().executeTakeFirst();if(!W||W.id==null){let K=G.email?["email",G.email]:G.name?["name",G.name]:["title",G.title];W=await O.selectFrom(Y).selectAll().where(K[0],"=",K[1]).orderBy("id","desc").executeTakeFirst()}return W},async update(Y,G,W){return await O.updateTable(Y).set(W).where("id","=",G).execute(),await O.selectFrom(Y).selectAll().where("id","=",G).executeTakeFirst()},async delete(Y,G){await O.deleteFrom(Y).where("id","=",G).execute()},async find(Y,G){return await O.selectFrom(Y).selectAll().where("id","=",G).executeTakeFirst()}}}async function x(X,O,Y="created_at"){try{return await X.all(O,Y)}catch{return[]}}async function FE(X){let O=new URL(X.url);if(!O.pathname.startsWith("/api/dashboard/cms"))return null;let Y;try{Y=await _E();let W=O.pathname.replace(/^\/api\/dashboard\/cms\/?/,"").split("/").filter(Boolean),K=W[0]||"",Z=W[1]?Number(W[1]):void 0,H=new Date().toISOString().slice(0,19).replace("T"," ");if(X.method==="GET"&&!K){let[$,E,z,N,Q,R]=await Promise.all([x(Y,"posts"),x(Y,"pages"),x(Y,"authors"),x(Y,"categories"),x(Y,"tags"),x(Y,"comments")]);return F({ok:!0,posts:$,pages:E,authors:z,categories:N,tags:Q,comments:R,stats:{posts:$.length,publishedPosts:$.filter((j)=>j.status==="published").length,draftPosts:$.filter((j)=>j.status==="draft").length,pages:E.length,categories:N.length,tags:Q.length,comments:R.length}})}if(K==="posts"){if(X.method==="POST"){let $=await D(X),E=String($.title||"").trim();if(!E)return F({ok:!1,error:"Title is required"},{status:422});let z=await Y.insert("posts",{title:E,poster:String($.poster||""),content:String($.content||$.body||""),excerpt:String($.excerpt||""),views:Number($.views||0),published_at:$.status==="published"?H:$.published_at||null,status:String($.status||"draft").toLowerCase(),is_featured:$.is_featured?1:0,author_id:$.author_id?Number($.author_id):null,created_at:H,updated_at:H});return F({ok:!0,post:z},{status:201})}if(X.method==="PATCH"&&Z){let $=await D(X),E={updated_at:H};for(let N of["title","poster","content","excerpt","status","published_at"])if($[N]!==void 0)E[N]=N==="status"?String($[N]).toLowerCase():$[N];if($.views!==void 0)E.views=Number($.views);if($.is_featured!==void 0)E.is_featured=$.is_featured?1:0;let z=await Y.update("posts",Z,E);if(!z)return F({ok:!1,error:"Post not found"},{status:404});return F({ok:!0,post:z})}if(X.method==="DELETE"&&Z)return await Y.delete("posts",Z),F({ok:!0})}if(K==="tags"||K==="categories"){let $=K;if(X.method==="POST"){let E=await D(X),z=String(E.name||"").trim();if(!z)return F({ok:!1,error:"Name is required"},{status:422});let N={name:z,slug:String(E.slug||KE(z)),description:String(E.description||""),created_at:H,updated_at:H};if(K==="categories")N.is_active=E.is_active===void 0?!0:Boolean(E.is_active);if(K==="tags")N.post_count=Number(E.post_count||0),N.color=String(E.color||"");let Q=await Y.insert($,N);return F({ok:!0,[K==="categories"?"category":"tag"]:Q},{status:201})}if(X.method==="PATCH"&&Z){let E=await D(X),z={updated_at:H};for(let Q of["name","slug","description","color","image_url","parent_category_id"])if(E[Q]!==void 0)z[Q]=E[Q];if(E.post_count!==void 0)z.post_count=Number(E.post_count);if(E.display_order!==void 0)z.display_order=Number(E.display_order);if(E.is_active!==void 0)z.is_active=E.is_active?1:0;let N=await Y.update($,Z,z);if(!N)return F({ok:!1,error:`${K==="categories"?"Category":"Tag"} not found`},{status:404});return F({ok:!0,[K==="categories"?"category":"tag"]:N})}if(X.method==="DELETE"&&Z)return await Y.delete($,Z),F({ok:!0})}if(K==="pages"){if(X.method==="POST"){let $=await D(X),E=String($.title||"").trim();if(!E)return F({ok:!1,error:"Title is required"},{status:422});let z=await Y.insert("pages",{title:E,template:String($.template||"default"),views:0,conversions:0,published_at:$.status==="published"?H:null,author_id:$.author_id?Number($.author_id):null,created_at:H,updated_at:H});return F({ok:!0,page:z},{status:201})}if(X.method==="PATCH"&&Z){let $=await D(X),E={updated_at:H};for(let N of["title","template","published_at"])if($[N]!==void 0)E[N]=$[N];if($.views!==void 0)E.views=Number($.views);if($.conversions!==void 0)E.conversions=Number($.conversions);if($.author_id!==void 0)E.author_id=$.author_id?Number($.author_id):null;let z=await Y.update("pages",Z,E);if(!z)return F({ok:!1,error:"Page not found"},{status:404});return F({ok:!0,page:z})}if(X.method==="DELETE"&&Z)return await Y.delete("pages",Z),F({ok:!0})}if(K==="authors"){if(X.method==="POST"){let $=await D(X),E=String($.name||"").trim(),z=String($.email||"").trim();if(!E||!z)return F({ok:!1,error:"Name and email are required"},{status:422});let N=await Y.insert("authors",{name:E,email:z,created_at:H,updated_at:H});return F({ok:!0,author:N},{status:201})}if(X.method==="PATCH"&&Z){let $=await D(X),E={updated_at:H};for(let N of["name","email"])if($[N]!==void 0)E[N]=$[N];if($.user_id!==void 0)E.user_id=$.user_id?Number($.user_id):null;let z=await Y.update("authors",Z,E);if(!z)return F({ok:!1,error:"Author not found"},{status:404});return F({ok:!0,author:z})}if(X.method==="DELETE"&&Z)return await Y.delete("authors",Z),F({ok:!0})}if(K==="comments"){if(X.method==="PATCH"&&Z){let $=await D(X),E={updated_at:H};if($.content!==void 0)E.content=$.content,E.body=$.content;if($.body!==void 0)E.content=$.body,E.body=$.body;for(let N of["status","author_name","author_email","post_title"])if($[N]!==void 0)E[N]=$[N];if(E.status==="approved")E.is_approved=1;if(E.status&&E.status!=="approved")E.is_approved=0;let z=await Y.update("comments",Z,E);if(!z)return F({ok:!1,error:"Comment not found"},{status:404});return F({ok:!0,comment:z})}if(X.method==="DELETE"&&Z)return await Y.delete("comments",Z),F({ok:!0})}return F({ok:!1,error:"CMS endpoint not found"},{status:404})}catch(G){return F({ok:!1,error:G?.message||String(G)},{status:500})}finally{Y?.close?.()}}async function VE(){try{await import("@stacksjs/orm")}catch(E){if(I)console.warn("[dashboard] orm preload failed:",E?.message||E)}try{let{hoistDashboardGlobals:E}=await import("./dashboard-globals.js");await E({verbose:I})}catch(E){if(I)console.warn("[dashboard] globals preload failed:",E?.message||E)}let X;try{X=(await import("../../chunk-4p0rjazd.js")).serve}catch{X=(await import(A("pantry/bun-plugin-stx/dist/serve.js"))).serve}let O;try{let E=A("pantry/@stacksjs/stx/dist/index.js");if(await Bun.file(E).exists())O=await import(E)}catch{}let{listConfigFiles:Y,readConfig:G,updateConfigKey:W}=await import(J("framework/defaults/resources/functions/dashboard/config-io.ts")),K={"/__deps/charts.js":J("framework/core/charts/dist/index.js")},Z={...Object.fromEntries(Object.entries(K).map(([E,z])=>[E,async()=>{let N=Bun.file(z);if(!await N.exists())return new Response(`// dependency dist missing: ${z}
3
+ // rebuild with: cd ${z.replace(/\/dist\/[^/]+$/,"")} && bun build.ts`,{status:500,headers:{"content-type":"text/javascript; charset=utf-8"}});return new Response(N,{headers:{"content-type":"text/javascript; charset=utf-8","cache-control":"no-cache"}})}])),"/api/config/list":async()=>{try{return Response.json({ok:!0,files:Y()})}catch(E){return Response.json({ok:!1,error:E?.message},{status:500})}},"/api/config/read":async(E)=>{try{let N=new URL(E.url).searchParams.get("name")||"";if(!/^[\w-]+$/.test(N))return Response.json({ok:!1,error:"Invalid config name"},{status:400});let Q=await G(N);if(!Q)return Response.json({ok:!1,error:"Not found"},{status:404});return Response.json({ok:!0,name:N,fields:Q.fields,values:Q.values})}catch(z){return Response.json({ok:!1,error:z?.message},{status:500})}},"/api/config/source":async(E)=>{try{let N=new URL(E.url).searchParams.get("name")||"";if(!/^[\w-]+$/.test(N))return Response.json({ok:!1,error:"Invalid config name"},{status:400});let Q=await G(N);if(!Q)return Response.json({ok:!1,error:"Not found"},{status:404});return new Response(Q.source,{headers:{"content-type":"text/plain; charset=utf-8"}})}catch(z){return Response.json({ok:!1,error:z?.message},{status:500})}},"/api/config/update":async(E)=>{if(E.method!=="POST")return Response.json({ok:!1,error:"Method not allowed"},{status:405});try{let z=await E.json(),N=z.file?.replace(/\.ts$/,"");if(!N||!/^[\w-]+$/.test(N))return Response.json({ok:!1,error:"Invalid file"},{status:400});let Q=[];if(Array.isArray(z.updates))for(let M of z.updates){let S=M.key??M.path;if(typeof S==="string")Q.push({key:S,value:M.value})}else if(z.key)Q.push({key:z.key,value:z.value});if(Q.length===0)return Response.json({ok:!1,error:"No updates supplied"},{status:400});let R=[];for(let M of Q)try{let S=await W(N,M.key,H(M.value));R.push({key:M.key,ok:!0,newValue:S.newValue})}catch(S){R.push({key:M.key,ok:!1,error:S?.message})}let j=R.every((M)=>M.ok);return Response.json({ok:j,file:N,results:R})}catch(z){return Response.json({ok:!1,error:z?.message},{status:500})}}};function H(E){if(typeof E==="boolean"||typeof E==="number")return E;if(E==="true")return!0;if(E==="false")return!1;if(E===""||E==null)return"";if(typeof E==="string"&&/^-?\d+(?:\.\d+)?$/.test(E))return Number(E);return String(E)}X({patterns:[OE,p],port:T,componentsDir:J("framework/defaults/resources/components/Dashboard"),layoutsDir:p,partialsDir:p,quiet:!0,routes:Z,onRequest:FE,auth:!1,...O&&{stxModule:O}}).catch((E)=>{EE(),console.error(`
4
4
  Failed to start dashboard server: ${E?.message||E}
5
- `),V.exit(1)})}async function VE(){if(!C)return!1;if(V.env.STACKS_PROXY_MANAGED)return!1;try{let{startProxies:X}=await import("@stacksjs/rpx");return await X({proxies:[{from:`localhost:${R}`,to:C,cleanUrls:!1}],https:{basePath:e,validityDays:825},regenerateUntrustedCerts:!1,verbose:A}),!0}catch(X){if(A)s(` ${_(`Proxy: ${X}`)}`);return!1}}var QE=R+1;function k(X,N=200,Y={}){return new Response(JSON.stringify(X),{status:N,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type",...Y}})}function ME(){Bun.serve({port:QE,fetch:async(X)=>{if(X.method==="OPTIONS")return new Response(null,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}});if(new URL(X.url).pathname==="/api/config/update"&&X.method==="POST")try{let{file:Y,updates:z}=await X.json();if(!Y||Y.includes("..")||!Y.match(/^[\w.-]+\.ts$/))return k({error:"Invalid file name"},400);let O=I(`config/${Y}`),W=$E(O,"utf-8");for(let{path:K,value:H}of z){let E=K.split(".").pop().replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),$=new RegExp(`(${E}\\s*:\\s*)(?:'[^']*'|"[^"]*"|\\d+(?:\\.\\d+)?|true|false)`);if($.test(W)){let G=/^\d+(?:\.\d+)?$/.test(H),T=H==="true"||H==="false",M=H.replace(/'/g,"\\'").replace(/\$/g,"$$$$"),j=G||T?H:`'${M}'`;W=W.replace($,`$1${j}`)}}return a(O,W,"utf-8"),k({success:!0})}catch(Y){return k({error:Y.message},500)}return k({error:"Not found"},404)}})}ME();var[,u]=await Promise.all([TE(),l(I("app/Models"),S("framework/defaults/app/Models"))]);async function LE(){let X={library:!0,content:!0,commerce:!0,marketing:!0,analytics:!0,management:!0,utilities:!0,data:{dashboard:!0,activity:!0,users:!0,teams:!0,subscribers:!0,allModels:!0}};try{let Y=(await import(I("config/dashboard.ts"))).default?.sections??{},z=Y.data??{};return{library:Y.library?.enabled??!0,content:Y.content?.enabled??!0,commerce:Y.commerce?.enabled??!0,marketing:Y.marketing?.enabled??!0,analytics:Y.analytics?.enabled??!0,management:Y.management?.enabled??!0,utilities:Y.utilities?.enabled??!0,data:{dashboard:z.dashboard?.enabled??!0,activity:z.activity?.enabled??!0,users:z.users?.enabled??!0,teams:z.teams?.enabled??!0,subscribers:z.subscribers?.enabled??!0,allModels:z.allModels?.enabled??!0}}}catch{return X}}var XE=await LE(),RE=S("framework/defaults/views/dashboard/.discovered-models.json"),DE={models:d(u),sections:XE};a(RE,JSON.stringify(DE,null,2));var UE=await r(R);EE();var AE=!1;VE().then((X)=>{AE=X}).catch((X)=>{if(A)console.warn("[Dashboard] Reverse proxy failed:",X)});var m=C?`https://${C}`:null,v=`http://localhost:${R}`,IE=v,YE=o(IE,u,XE),ZE=`http://localhost:${R}/?native-sidebar=1`,jE=(Bun.nanoseconds()-zE)/1e6;console.log();console.log(` ${J(g("stacks dashboard"))}`);console.log();if(m)console.log(` ${f("\u279C")} ${J("Local")}: ${g(m)}`),console.log(` ${_("\u279C")} ${_("Origin")}: ${_(v)}`);else console.log(` ${f("\u279C")} ${J("Local")}: ${g(v)}`);console.log(` ${f("\u279C")} ${J("Window")}: ${_("Stacks Dashboard")} ${_("1400\xD7900")}`);console.log(` ${f("\u279C")} ${J("Models")}: ${_(`${u.length} discovered`)}`);if(R!==y)console.log(` ${_("\u279C")} ${_(`Port ${y} in use, using ${R}`)}`);if(!UE)console.log(` ${_("\u26A0")} ${_("Dev server may not be ready yet")}`);console.log();console.log(` ${_(`ready in ${jE.toFixed(0)} ms`)}`);if(A){if(console.log(),console.log(` ${_("\u279C")} ${_("Sidebar")}: ${_(`${YE.sections.length} sections, 240px`)}`),console.log(` ${_("\u279C")} ${_("URL")}: ${_(ZE)}`),C)console.log(` ${_("\u279C")} ${_("SSL")}: ${_(e)}`),console.log(` ${_("\u279C")} ${_("Proxy")}: ${_(`localhost:${R} \u2192 ${C}`)}`);if(h.length>0){console.log();for(let X of h)console.log(` ${_(X)}`)}}console.log();var w=null;try{({createApp:w}=await import("@stacksjs/ts-craft"))}catch{}if(w){let X=I("resources/assets/images/app-icon.png"),N=S("framework/defaults/resources/assets/images/app-icon.png"),Y=await Bun.file(X).exists()?X:await Bun.file(N).exists()?N:void 0,z=(()=>{let W=V.env.CRAFT_BIN;if(W&&p(W))return W;let K=`${V.env.HOME}/Documents/Projects/craft/packages/zig/zig-out/bin/craft`;if(p(K))return K;return})();if(!z)w=null;if(!w)console.log(` ${_("Native window unavailable. Set CRAFT_BIN to a craft binary, or open the URL above in a browser.")}
6
- `),await new Promise(()=>{});let O=w({url:ZE,quiet:!A,...z&&{craftPath:z},window:{title:"Stacks Dashboard",width:1400,height:900,titlebarHidden:!0,nativeSidebar:!0,sidebarWidth:240,sidebarConfig:YE,...Y&&{icon:Y}}});V.on("SIGINT",()=>{O.close(),V.exit(0)}),V.on("SIGTERM",()=>{O.close(),V.exit(0)});try{await O.show(),V.exit(0)}catch{let W=m||v;console.log(` ${_("Dashboard available at:")} ${g(W)}
5
+ `),V.exit(1)})}async function QE(){if(!C)return!1;if(V.env.STACKS_PROXY_MANAGED)return!1;try{let{startProxies:X}=await import("@stacksjs/rpx");return await X({proxies:[{from:`localhost:${T}`,to:C,cleanUrls:!1}],https:{basePath:e,validityDays:825},regenerateUntrustedCerts:!1,verbose:I}),!0}catch(X){if(I)s(` ${_(`Proxy: ${X}`)}`);return!1}}var ME=T+1;function P(X,O=200,Y={}){return new Response(JSON.stringify(X),{status:O,headers:{"Content-Type":"application/json","Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type",...Y}})}function LE(){Bun.serve({port:ME,fetch:async(X)=>{if(X.method==="OPTIONS")return new Response(null,{headers:{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Methods":"POST, OPTIONS","Access-Control-Allow-Headers":"Content-Type"}});if(new URL(X.url).pathname==="/api/config/update"&&X.method==="POST")try{let{file:Y,updates:G}=await X.json();if(!Y||Y.includes("..")||!Y.match(/^[\w.-]+\.ts$/))return P({error:"Invalid file name"},400);let W=A(`config/${Y}`),K=zE(W,"utf-8");for(let{path:Z,value:H}of G){let E=Z.split(".").pop().replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),z=new RegExp(`(${E}\\s*:\\s*)(?:'[^']*'|"[^"]*"|\\d+(?:\\.\\d+)?|true|false)`);if(z.test(K)){let N=/^\d+(?:\.\d+)?$/.test(H),Q=H==="true"||H==="false",R=H.replace(/'/g,"\\'").replace(/\$/g,"$$$$"),j=N||Q?H:`'${R}'`;K=K.replace(z,`$1${j}`)}}return o(W,K,"utf-8"),P({success:!0})}catch(Y){return P({error:Y.message},500)}return P({error:"Not found"},404)}})}LE();var[,u]=await Promise.all([VE(),l(A("app/Models"),J("framework/defaults/app/Models"))]);async function RE(){let X={library:!0,content:!0,commerce:!0,marketing:!0,analytics:!0,management:!0,utilities:!0,data:{dashboard:!0,activity:!0,users:!0,teams:!0,subscribers:!0,allModels:!0}};try{let Y=(await import(A("config/dashboard.ts"))).default?.sections??{},G=Y.data??{};return{library:Y.library?.enabled??!0,content:Y.content?.enabled??!0,commerce:Y.commerce?.enabled??!0,marketing:Y.marketing?.enabled??!0,analytics:Y.analytics?.enabled??!0,management:Y.management?.enabled??!0,utilities:Y.utilities?.enabled??!0,data:{dashboard:G.dashboard?.enabled??!0,activity:G.activity?.enabled??!0,users:G.users?.enabled??!0,teams:G.teams?.enabled??!0,subscribers:G.subscribers?.enabled??!0,allModels:G.allModels?.enabled??!0}}}catch{return X}}var XE=await RE(),DE=J("framework/defaults/views/dashboard/.discovered-models.json"),TE={models:d(u),sections:XE};o(DE,JSON.stringify(TE,null,2));var UE=await r(T);EE();var IE=!1;QE().then((X)=>{IE=X}).catch((X)=>{if(I)console.warn("[Dashboard] Reverse proxy failed:",X)});var m=C?`https://${C}`:null,q=`http://localhost:${T}`,AE=q,YE=a(AE,u,XE),$E=`http://localhost:${T}/?native-sidebar=1`,jE=(Bun.nanoseconds()-GE)/1e6;console.log();console.log(` ${k(f("stacks dashboard"))}`);console.log();if(m)console.log(` ${h("\u279C")} ${k("Local")}: ${f(m)}`),console.log(` ${_("\u279C")} ${_("Origin")}: ${_(q)}`);else console.log(` ${h("\u279C")} ${k("Local")}: ${f(q)}`);console.log(` ${h("\u279C")} ${k("Window")}: ${_("Stacks Dashboard")} ${_("1400\xD7900")}`);console.log(` ${h("\u279C")} ${k("Models")}: ${_(`${u.length} discovered`)}`);if(T!==y)console.log(` ${_("\u279C")} ${_(`Port ${y} in use, using ${T}`)}`);if(!UE)console.log(` ${_("\u26A0")} ${_("Dev server may not be ready yet")}`);console.log();console.log(` ${_(`ready in ${jE.toFixed(0)} ms`)}`);if(I){if(console.log(),console.log(` ${_("\u279C")} ${_("Sidebar")}: ${_(`${YE.sections.length} sections, 240px`)}`),console.log(` ${_("\u279C")} ${_("URL")}: ${_($E)}`),C)console.log(` ${_("\u279C")} ${_("SSL")}: ${_(e)}`),console.log(` ${_("\u279C")} ${_("Proxy")}: ${_(`localhost:${T} \u2192 ${C}`)}`);if(v.length>0){console.log();for(let X of v)console.log(` ${_(X)}`)}}console.log();var B=null;try{let X=V.env.HOME?`${V.env.HOME}/Code/Tools/craft/packages/typescript/src/index.ts`:void 0;({createApp:B}=X&&w(X)?await import(X):await import("../../chunk-s03z9zn3.js"))}catch{try{({createApp:B}=await import("@craft-native/craft"))}catch{try{({createApp:B}=await import("@stacksjs/ts-craft"))}catch{}}}if(B){let X=A("resources/assets/images/app-icon.png"),O=J("framework/defaults/resources/assets/images/app-icon.png"),Y=await Bun.file(X).exists()?X:await Bun.file(O).exists()?O:void 0,G=(()=>{let K=V.env.CRAFT_BIN;if(K&&w(K))return K;let Z=`${V.env.HOME}/Code/Tools/craft/craft`;if(w(Z))return Z;let H=`${V.env.HOME}/Code/Tools/craft/bin/craft`;if(w(H))return H;let $=`${V.env.HOME}/Code/Tools/craft/packages/zig/zig-out/bin/craft`;if(w($))return $;let E=`${V.env.HOME}/Documents/Projects/craft/packages/zig/zig-out/bin/craft`;if(w(E))return E;return})();if(!G)B=null;if(!B)console.log(` ${_("Native window unavailable. Set CRAFT_BIN to a craft binary, or open the URL above in a browser.")}
6
+ `),await new Promise(()=>{});let W=B({url:$E,quiet:!I,...G&&{craftPath:G},window:{title:"Stacks Dashboard",width:1400,height:900,titlebarHidden:!0,nativeSidebar:!0,sidebarWidth:240,sidebarConfig:YE,...Y&&{icon:Y}}});V.on("SIGINT",()=>{W.close(),V.exit(0)}),V.on("SIGTERM",()=>{W.close(),V.exit(0)});try{await W.show(),V.exit(0)}catch{let K=m||q;console.log(` ${_("Dashboard available at:")} ${f(K)}
7
7
  `),await new Promise(()=>{})}}else console.log(` ${_("Native window unavailable. Set CRAFT_BIN to a craft binary, or open the URL above in a browser.")}
8
8
  `),V.on("SIGINT",()=>V.exit(0)),V.on("SIGTERM",()=>V.exit(0)),await new Promise(()=>{});
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ia as a,ja as b,ka as c,la as d,ma as e,na as f,oa as g,pa as h,qa as i}from"../../chunk-60qjz7zb.js";import"../../chunk-s735m9mg.js";import"../../chunk-n1y0gpv6.js";import"../../chunk-96b7fcmd.js";export{g as runSystemTrayDevServer,b as runFrontendDevServer,i as runDocsDevServer,a as runDevServer,h as runDesktopDevServer,f as runDashboardDevServer,e as runComponentsDevServer,c as runBackendDevServer,d as runApiDevServer};
2
+ import{ia as a,ja as b,ka as c,la as d,ma as e,na as f,oa as g,pa as h,qa as i}from"../../chunk-h0hfqr1p.js";import"../../chunk-s735m9mg.js";import"../../chunk-sxp97zys.js";import"../../chunk-jbvvb45k.js";export{g as runSystemTrayDevServer,b as runFrontendDevServer,i as runDocsDevServer,a as runDevServer,h as runDesktopDevServer,f as runDashboardDevServer,e as runComponentsDevServer,c as runBackendDevServer,d as runApiDevServer};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{gb as $}from"../../chunk-96b7fcmd.js";import{AsyncLocalStorage as T}from"async_hooks";import{config as _}from"@stacksjs/config";import{projectPath as Q}from"@stacksjs/path";var U=Q("serve.ts");try{if(await Bun.file(U).exists())await import(U);else await W()}catch{await W()}var R=new T;globalThis.requestContext={cookie(z){return R.getStore()?.cookies?.[z]??null},url(){return R.getStore()?.url??""}};function A(z){let F={},H=z.headers.get("cookie")||"";if(!H)return F;for(let N of H.split(";")){let G=N.trim(),K=G.indexOf("=");if(K===-1)continue;let I=G.slice(0,K).trim(),J=G.slice(K+1).trim();if(!I)continue;try{F[I]=decodeURIComponent(J)}catch{F[I]=J}}return F}async function D(z,F){let H=new URL(z.url),N=`${F}${H.pathname}${H.search}`,G=new Headers(z.headers);G.delete("host"),G.delete("content-length"),G.set("x-forwarded-host",H.host),G.set("x-forwarded-proto",H.protocol.replace(":",""));let K=z.method==="GET"||z.method==="HEAD"?void 0:await z.arrayBuffer(),I=await fetch(N,{method:z.method,headers:G,body:K,redirect:"manual"}),J=new Headers(I.headers);return J.delete("content-length"),J.delete("content-encoding"),new Response(I.body,{status:I.status,statusText:I.statusText,headers:J})}async function W(){let z;try{({serve:z}=await import(Q("pantry/bun-plugin-stx/dist/serve.js")))}catch{({serve:z}=await import("../../chunk-wv5yb5wb.js"))}let F=await E(),H="resources/views",N="storage/framework/defaults/resources/views",G=await X(["resources/views/layouts","resources/layouts"])??"resources/views/layouts",K="storage/framework/defaults/resources/layouts",I=await X(["resources/views/components","resources/components"])??"resources/views/components",J=Number(process.env.PORT)||3000,Y=`http://127.0.0.1:${Number(process.env.PORT_API)||3008}`,Z=_?.auth?.defaultTokenName??"auth-token";await z({patterns:[H,N],port:J,componentsDir:"storage/framework/defaults/resources/components",layoutsDir:G,partialsDir:I,fallbackLayoutsDir:K,fallbackPartialsDir:N,quiet:!0,...F&&{stxModule:F},auth:{cookieName:Z,redirectTo:"/login"},onRequest:async(O)=>{if(new URL(O.url).pathname.startsWith("/api/"))return D(O,Y);return R.enterWith({cookies:A(O),url:O.url}),null}})}async function X(z){for(let F of z)try{if(await Bun.file(Q(F)).exists())return F}catch{}return null}async function E(){try{let z=Q("pantry/@stacksjs/stx/dist/index.js");if(await Bun.file(z).exists())return await import(z)}catch{}return}
2
+ import{ib as $}from"../../chunk-jbvvb45k.js";import{AsyncLocalStorage as T}from"async_hooks";import{config as _}from"@stacksjs/config";import{projectPath as Q}from"@stacksjs/path";var U=Q("serve.ts");try{if(await Bun.file(U).exists())await import(U);else await W()}catch{await W()}var R=new T;globalThis.requestContext={cookie(z){return R.getStore()?.cookies?.[z]??null},url(){return R.getStore()?.url??""}};function A(z){let F={},H=z.headers.get("cookie")||"";if(!H)return F;for(let N of H.split(";")){let G=N.trim(),K=G.indexOf("=");if(K===-1)continue;let I=G.slice(0,K).trim(),J=G.slice(K+1).trim();if(!I)continue;try{F[I]=decodeURIComponent(J)}catch{F[I]=J}}return F}async function D(z,F){let H=new URL(z.url),N=`${F}${H.pathname}${H.search}`,G=new Headers(z.headers);G.delete("host"),G.delete("content-length"),G.set("x-forwarded-host",H.host),G.set("x-forwarded-proto",H.protocol.replace(":",""));let K=z.method==="GET"||z.method==="HEAD"?void 0:await z.arrayBuffer(),I=await fetch(N,{method:z.method,headers:G,body:K,redirect:"manual"}),J=new Headers(I.headers);return J.delete("content-length"),J.delete("content-encoding"),new Response(I.body,{status:I.status,statusText:I.statusText,headers:J})}async function W(){let z;try{({serve:z}=await import(Q("pantry/bun-plugin-stx/dist/serve.js")))}catch{({serve:z}=await import("../../chunk-4p0rjazd.js"))}let F=await E(),H="resources/views",N="storage/framework/defaults/resources/views",G=await X(["resources/views/layouts","resources/layouts"])??"resources/views/layouts",K="storage/framework/defaults/resources/layouts",I=await X(["resources/views/components","resources/components"])??"resources/views/components",J=Number(process.env.PORT)||3000,Y=`http://127.0.0.1:${Number(process.env.PORT_API)||3008}`,Z=_?.auth?.defaultTokenName??"auth-token";await z({patterns:[H,N],port:J,componentsDir:"storage/framework/defaults/resources/components",layoutsDir:G,partialsDir:I,fallbackLayoutsDir:K,fallbackPartialsDir:N,quiet:!0,...F&&{stxModule:F},auth:{cookieName:Z,redirectTo:"/login"},onRequest:async(O)=>{if(new URL(O.url).pathname.startsWith("/api/"))return D(O,Y);return R.enterWith({cookies:A(O),url:O.url}),null}})}async function X(z){for(let F of z)try{if(await Bun.file(Q(F)).exists())return F}catch{}return null}async function E(){try{let z=Q("pantry/@stacksjs/stx/dist/index.js");if(await Bun.file(z).exists())return await import(z)}catch{}return}
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ra as a}from"../chunk-c8qt2xst.js";import"../chunk-96b7fcmd.js";export{a as discoverPackages};
2
+ import{ra as a}from"../chunk-c8qt2xst.js";import"../chunk-jbvvb45k.js";export{a as discoverPackages};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"../chunk-96b7fcmd.js";import D from"process";import{NpmScript as z}from"@stacksjs/enums";import{log as q}from"@stacksjs/logging";import{hasComponents as A}from"@stacksjs/storage";import{ExitCode as F}from"@stacksjs/types";import{runNpmScript as B}from"@stacksjs/utils";async function G(f){if(f.components||f.vue)await H(f);else if(f.webComponents||f.elements)await I(f);else q.error("An unsupported option was used. Please try again, check the documentation & report the issue, if needed.")}async function Q(f){return await G(f)}async function H(f){if(A())await B(z.ExampleVue,f),q.success("Your component library was built successfully");else q.info("No components found.")}async function I(f){if(A())q.info("Building your Web Component library..."),await B(z.BuildWebComponents,f),q.success("Your Web Component library was built successfully");else q.info("No components found."),D.exit(F.FatalError)}export{I as webComponentExample,G as invoke,Q as examples,H as componentExample};
2
+ import"../chunk-jbvvb45k.js";import D from"process";import{NpmScript as z}from"@stacksjs/enums";import{log as q}from"@stacksjs/logging";import{hasComponents as A}from"@stacksjs/storage";import{ExitCode as F}from"@stacksjs/types";import{runNpmScript as B}from"@stacksjs/utils";async function G(f){if(f.components||f.vue)await H(f);else if(f.webComponents||f.elements)await I(f);else q.error("An unsupported option was used. Please try again, check the documentation & report the issue, if needed.")}async function Q(f){return await G(f)}async function H(f){if(A())await B(z.ExampleVue,f),q.success("Your component library was built successfully");else q.info("No components found.")}async function I(f){if(A())q.info("Building your Web Component library..."),await B(z.BuildWebComponents,f),q.success("Your Web Component library was built successfully");else q.info("No components found."),D.exit(F.FatalError)}export{I as webComponentExample,G as invoke,Q as examples,H as componentExample};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{ga as d}from"../../chunk-aw6d8zr3.js";import"../../chunk-96b7fcmd.js";import{log as b}from"@stacksjs/logging";import{hasComponents as f}from"@stacksjs/storage";b.info("Generating component meta...");if(f())d();else b.info("No components found. Skipping component meta generation.");b.success("Generated component meta.");
3
+ import{ga as d}from"../../chunk-cqedfbaf.js";import"../../chunk-jbvvb45k.js";import{log as b}from"@stacksjs/logging";import{hasComponents as f}from"@stacksjs/storage";b.info("Generating component meta...");if(f())d();else b.info("No components found. Skipping component meta generation.");b.success("Generated component meta.");
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import"../../chunk-96b7fcmd.js";import{env as P,envEnum as R}from"@stacksjs/env";import{log as T}from"@stacksjs/logging";import{path as I}from"@stacksjs/path";import{storage as D}from"@stacksjs/storage";var O=["APP_NAME","APP_ENV","APP_KEY","APP_URL","APP_DOMAIN","APP_MAINTENANCE","APP_MAINTENANCE_SECRET","APP_COMING_SOON","APP_COMING_SOON_SECRET","APP_ROOT","DEBUG","PORT","PORT_BACKEND","PORT_ADMIN","PORT_LIBRARY","PORT_DESKTOP","PORT_EMAIL","PORT_DOCS","PORT_INSPECT","PORT_API","PORT_SYSTEM_TRAY","API_PREFIX","DOCS_PREFIX","DB_CONNECTION","DB_HOST","DB_PORT","DB_DATABASE","DB_DATABASE_PATH","DB_USERNAME","DB_PASSWORD","DB_PREFIX","DB_SCHEMA","DB_QUERY_LOGGING_ENABLED","DB_QUERY_LOGGING_SLOW_THRESHOLD","DB_QUERY_LOGGING_RETENTION_DAYS","DB_QUERY_LOGGING_PRUNE_FREQUENCY","DB_QUERY_LOGGING_ANALYSIS_ENABLED","DB_QUERY_LOGGING_ANALYZE_ALL","DB_QUERY_LOGGING_EXPLAIN_PLAN","DB_QUERY_LOGGING_SUGGESTIONS","DATABASE_URL","AWS_ACCOUNT_ID","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_DEFAULT_REGION","AWS_DEFAULT_PASSWORD","AWS_REGION","AWS_HOSTED_ZONE_ID","AWS_S3_BUCKET","AWS_S3_PREFIX","AWS_SES_REGION","MAIL_MAILER","MAIL_HOST","MAIL_PORT","MAIL_USERNAME","MAIL_PASSWORD","MAIL_ENCRYPTION","MAIL_FROM_NAME","MAIL_FROM_ADDRESS","MAIL_DOMAIN","MAIL_DRIVER","MAIL_SERVER_MODE","MAIL_SERVER_PATH","SEARCH_ENGINE_DRIVER","MEILISEARCH_HOST","MEILISEARCH_KEY","STRIPE_SECRET_KEY","STRIPE_PUBLISHABLE_KEY","FRONTEND_APP_ENV","FRONTEND_APP_URL","REALTIME_MODE","BROADCAST_DRIVER","BROADCAST_HOST","BROADCAST_PORT","BROADCAST_SCHEME","BROADCAST_APP_ID","BROADCAST_APP_KEY","BROADCAST_APP_SECRET","BROADCAST_CORS_ORIGIN","BROADCAST_DEBUG","BROADCAST_REDIS_ENABLED","BROADCAST_REDIS_PREFIX","BROADCAST_RATE_LIMIT_ENABLED","BROADCAST_METRICS_ENABLED","REDIS_HOST","REDIS_PORT","REDIS_PASSWORD","PUSHER_APP_ID","PUSHER_APP_KEY","PUSHER_APP_SECRET","PUSHER_APP_CLUSTER","PUSHER_APP_USE_TLS","SSL_DOMAINS","LETSENCRYPT_EMAIL","CONNECT_INSTANCE_ALIAS","PHONE_NOTIFY_EMAIL","PHONE_FORWARD_NUMBER","STORAGE_DRIVER","STORAGE_ROOT","STORAGE_PUBLIC_URL","QUEUE_DRIVER","AUTH_USERNAME_FIELD","AUTH_PASSWORD_FIELD","AUTH_TOKEN_EXPIRY","AUTH_TOKEN_ROTATION","AUTH_PASSWORD_RESET_EXPIRE","AUTH_PASSWORD_RESET_THROTTLE"];T.info("Generating type env files...");var N=`
2
+ import"../../chunk-jbvvb45k.js";import{env as P,envEnum as R}from"@stacksjs/env";import{log as T}from"@stacksjs/logging";import{path as I}from"@stacksjs/path";import{storage as D}from"@stacksjs/storage";var O=["APP_NAME","APP_ENV","APP_KEY","APP_URL","APP_DOMAIN","APP_MAINTENANCE","APP_MAINTENANCE_SECRET","APP_COMING_SOON","APP_COMING_SOON_SECRET","APP_ROOT","DEBUG","PORT","PORT_BACKEND","PORT_ADMIN","PORT_LIBRARY","PORT_DESKTOP","PORT_EMAIL","PORT_DOCS","PORT_INSPECT","PORT_API","PORT_SYSTEM_TRAY","API_PREFIX","DOCS_PREFIX","DB_CONNECTION","DB_HOST","DB_PORT","DB_DATABASE","DB_DATABASE_PATH","DB_USERNAME","DB_PASSWORD","DB_PREFIX","DB_SCHEMA","DB_QUERY_LOGGING_ENABLED","DB_QUERY_LOGGING_SLOW_THRESHOLD","DB_QUERY_LOGGING_RETENTION_DAYS","DB_QUERY_LOGGING_PRUNE_FREQUENCY","DB_QUERY_LOGGING_ANALYSIS_ENABLED","DB_QUERY_LOGGING_ANALYZE_ALL","DB_QUERY_LOGGING_EXPLAIN_PLAN","DB_QUERY_LOGGING_SUGGESTIONS","DATABASE_URL","AWS_ACCOUNT_ID","AWS_ACCESS_KEY_ID","AWS_SECRET_ACCESS_KEY","AWS_DEFAULT_REGION","AWS_DEFAULT_PASSWORD","AWS_REGION","AWS_HOSTED_ZONE_ID","AWS_S3_BUCKET","AWS_S3_PREFIX","AWS_SES_REGION","MAIL_MAILER","MAIL_HOST","MAIL_PORT","MAIL_USERNAME","MAIL_PASSWORD","MAIL_ENCRYPTION","MAIL_FROM_NAME","MAIL_FROM_ADDRESS","MAIL_DOMAIN","MAIL_DRIVER","MAIL_SERVER_MODE","MAIL_SERVER_PATH","SEARCH_ENGINE_DRIVER","MEILISEARCH_HOST","MEILISEARCH_KEY","STRIPE_SECRET_KEY","STRIPE_PUBLISHABLE_KEY","FRONTEND_APP_ENV","FRONTEND_APP_URL","REALTIME_MODE","BROADCAST_DRIVER","BROADCAST_HOST","BROADCAST_PORT","BROADCAST_SCHEME","BROADCAST_APP_ID","BROADCAST_APP_KEY","BROADCAST_APP_SECRET","BROADCAST_CORS_ORIGIN","BROADCAST_DEBUG","BROADCAST_REDIS_ENABLED","BROADCAST_REDIS_PREFIX","BROADCAST_RATE_LIMIT_ENABLED","BROADCAST_METRICS_ENABLED","REDIS_HOST","REDIS_PORT","REDIS_PASSWORD","PUSHER_APP_ID","PUSHER_APP_KEY","PUSHER_APP_SECRET","PUSHER_APP_CLUSTER","PUSHER_APP_USE_TLS","SSL_DOMAINS","LETSENCRYPT_EMAIL","CONNECT_INSTANCE_ALIAS","PHONE_NOTIFY_EMAIL","PHONE_FORWARD_NUMBER","STORAGE_DRIVER","STORAGE_ROOT","STORAGE_PUBLIC_URL","QUEUE_DRIVER","AUTH_USERNAME_FIELD","AUTH_PASSWORD_FIELD","AUTH_TOKEN_EXPIRY","AUTH_TOKEN_ROTATION","AUTH_PASSWORD_RESET_EXPIRE","AUTH_PASSWORD_RESET_THROTTLE"];T.info("Generating type env files...");var N=`
3
3
  // This file is auto-generated by Stacks. Do not edit this file manually.
4
4
  // If you want to change the environment variables, please edit the .env file.
5
5
  //
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{Ua as q,Va as x}from"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-96b7fcmd.js";import{log as z}from"@stacksjs/logging";import{hasComponents as A}from"@stacksjs/storage";if(A())await x(),await q();else z.info("No components found. Skipping IDE helper generation.");
3
+ import{Ua as q,Va as x}from"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-jbvvb45k.js";import{log as z}from"@stacksjs/logging";import{hasComponents as A}from"@stacksjs/storage";if(A())await x(),await q();else z.info("No components found. Skipping IDE helper generation.");
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ha as a,Ia as b,Ja as c,Ka as d,La as e,Ma as f,Na as g,Oa as h,Pa as i,Qa as j,Ra as k,Sa as l,Ta as m}from"../../chunk-schcaf73.js";import"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-s735m9mg.js";import"../../chunk-n1y0gpv6.js";import"../../chunk-96b7fcmd.js";export{i as watchTypes,a as invoke,d as generateWebTypes,e as generateVsCodeCustomData,h as generateTypes,k as generateSeeder,j as generatePantryConfig,m as generateOpenApiSpec,c as generateLibEntries,f as generateIdeHelpers,l as generateCoreSymlink,g as generateComponentMeta,b as generate};
2
+ import{Ha as a,Ia as b,Ja as c,Ka as d,La as e,Ma as f,Na as g,Oa as h,Pa as i,Qa as j,Ra as k,Sa as l,Ta as m}from"../../chunk-zbhjh5sz.js";import"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-s735m9mg.js";import"../../chunk-sxp97zys.js";import"../../chunk-jbvvb45k.js";export{i as watchTypes,a as invoke,d as generateWebTypes,e as generateVsCodeCustomData,h as generateTypes,k as generateSeeder,j as generatePantryConfig,m as generateOpenApiSpec,c as generateLibEntries,f as generateIdeHelpers,l as generateCoreSymlink,g as generateComponentMeta,b as generate};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{ba as i}from"../../chunk-w418anbq.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-96b7fcmd.js";import{library as o}from"@stacksjs/config";import{log as n}from"@stacksjs/logging";import{hasComponents as e,hasFunctions as t}from"@stacksjs/storage";async function r(){if(n.info("Generating library entry points..."),o.releaseable&&e())await i("web-components");else n.info("No components found. Skipping building component entry points.");if(o.releaseable&&t())await i("functions");else n.info("No functions found. Skipping building function entry point.")}await r();export{r as generateLibEntries};
3
+ import{ba as i}from"../../chunk-w418anbq.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-jbvvb45k.js";import{library as o}from"@stacksjs/config";import{log as n}from"@stacksjs/logging";import{hasComponents as e,hasFunctions as t}from"@stacksjs/storage";async function r(){if(n.info("Generating library entry points..."),o.releaseable&&e())await i("web-components");else n.info("No components found. Skipping building component entry points.");if(o.releaseable&&t())await i("functions");else n.info("No functions found. Skipping building function entry point.")}await r();export{r as generateLibEntries};
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{Ua as x}from"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-96b7fcmd.js";import{log as q}from"@stacksjs/logging";import{hasComponents as z}from"@stacksjs/storage";q.info("Generating VS Code custom data...");if(z())await x();else q.info("No components found. Skipping VS Code custom data generation.");q.success("Generated VS Code custom data.");
3
+ import{Ua as x}from"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-jbvvb45k.js";import{log as q}from"@stacksjs/logging";import{hasComponents as z}from"@stacksjs/storage";q.info("Generating VS Code custom data...");if(z())await x();else q.info("No components found. Skipping VS Code custom data generation.");q.success("Generated VS Code custom data.");
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ga as a,ha as b}from"../../chunk-aw6d8zr3.js";import"../../chunk-96b7fcmd.js";export{b as parseStxComponentMeta,a as generateComponentMeta};
2
+ import{ga as a,ha as b}from"../../chunk-cqedfbaf.js";import"../../chunk-jbvvb45k.js";export{b as parseStxComponentMeta,a as generateComponentMeta};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import"../../chunk-s735m9mg.js";import{Ya as a,Za as b,_a as c}from"../../chunk-n1y0gpv6.js";import"../../chunk-96b7fcmd.js";export{b as runActions,a as runAction,c as hasAction};
2
+ import"../../chunk-s735m9mg.js";import{Ya as a,Za as b,_a as c}from"../../chunk-sxp97zys.js";import"../../chunk-jbvvb45k.js";export{b as runActions,a as runAction,c as hasAction};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{ba as a,ca as b,da as c,ea as d,fa as e}from"../../chunk-w418anbq.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-96b7fcmd.js";export{a as generateLibEntry,e as generateEntryPointData,c as createWebComponentLibraryEntryPoint,b as createLibraryEntryPoint,d as createFunctionLibraryEntryPoint};
2
+ import{ba as a,ca as b,da as c,ea as d,fa as e}from"../../chunk-w418anbq.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-jbvvb45k.js";export{a as generateLibEntry,e as generateEntryPointData,c as createWebComponentLibraryEntryPoint,b as createLibraryEntryPoint,d as createFunctionLibraryEntryPoint};
@@ -1,5 +1,5 @@
1
1
  // @bun
2
- import{Wa as q}from"../../chunk-n2fd1d0m.js";import"../../chunk-96b7fcmd.js";import{log as G}from"@stacksjs/logging";import{packageJsonPath as I}from"@stacksjs/path";import{writeTextFile as K}from"@stacksjs/storage";async function R(v){let B,C,z,D,E,A;if(v==="web-components")B=q.webComponents?.name,C=q.webComponents?.description,z="components",D=q.webComponents?.keywords,E="web-components";else if(v==="functions")B=q.functions?.name,C=q.functions?.description,z="functions",D=q.functions?.keywords,E="functions";try{if(await K({path:I(v),data:`{
2
+ import{Wa as q}from"../../chunk-n2fd1d0m.js";import"../../chunk-jbvvb45k.js";import{log as G}from"@stacksjs/logging";import{packageJsonPath as I}from"@stacksjs/path";import{writeTextFile as K}from"@stacksjs/storage";async function R(v){let B,C,z,D,E,A;if(v==="web-components")B=q.webComponents?.name,C=q.webComponents?.description,z="components",D=q.webComponents?.keywords,E="web-components";else if(v==="functions")B=q.functions?.name,C=q.functions?.description,z="functions",D=q.functions?.keywords,E="functions";try{if(await K({path:I(v),data:`{
3
3
  "name": "${B}",
4
4
  "type": "module",
5
5
  "version": "",
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ya as a,Za as b,_a as c}from"../../chunk-n1y0gpv6.js";import"../../chunk-96b7fcmd.js";export{b as runActions,a as runAction,c as hasAction};
2
+ import{Ya as a,Za as b,_a as c}from"../../chunk-sxp97zys.js";import"../../chunk-jbvvb45k.js";export{b as runActions,a as runAction,c as hasAction};
@@ -1,2 +1,2 @@
1
1
  // @bun
2
- import{Ua as a,Va as b}from"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-96b7fcmd.js";export{b as generateWebTypes,a as generateVsCodeCustomData};
2
+ import{Ua as a,Va as b}from"../../chunk-v0wnrnaa.js";import"../../chunk-n2fd1d0m.js";import"../../chunk-jbvvb45k.js";export{b as generateWebTypes,a as generateVsCodeCustomData};