@stacksjs/config 0.70.45 → 0.70.54
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/dist/index.js +5 -2
- package/dist/src/features.d.ts +11 -10
- package/package.json +3 -3
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Open Web Foundation
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
2
|
+
var L=import.meta.require;import{commandsPath as D,projectPath as S,userDatabasePath as O}from"@stacksjs/path";var q={awsRegion:"us-east-1",timezone:"UTC",noReplyEmail:"no-reply@stacksjs.com",fallbackDomain:"stacks.localhost"};function _(){try{let x=S("package.json"),z=(L(x).name??"").trim();if(!z)return{name:"Stacks",url:"stacks.localhost"};let G=z.replace(/^@[^/]+\//,"").toLowerCase();return{name:G.replace(/[-_]+/g," ").replace(/(^|\s)\w/g,(Z)=>Z.toUpperCase()),url:`${G}.localhost`}}catch{return{name:"Stacks",url:"stacks.localhost"}}}var F=_(),M={ai:{deploy:!1,models:["anthropic.claude-sonnet-4-20250514-v1:0","anthropic.claude-haiku-4-20250514-v1:0","anthropic.claude-3-5-sonnet-20241022-v2:0","amazon.titan-embed-text-v2:0","amazon.titan-text-premier-v1:0","amazon.titan-image-generator-v2:0","meta.llama3-1-70b-instruct-v1:0","meta.llama3-1-8b-instruct-v1:0"]},auth:{username:"email",password:"password",defaultTokenName:"auth-token",tokenExpiry:3600000,refreshTokenExpiry:2592000000,defaultAbilities:["*"]},realtime:{driver:"pusher"},analytics:{driver:void 0},app:{name:F.name,description:"A Stacks application.",env:"local",url:F.url,debug:!0,key:"",timezone:q.timezone,locale:"en",fallbackLocale:"en",cipher:"AES-256-CBC",docMode:!1,redirectUrls:[],maintenanceMode:!1,comingSoonMode:!1,comingSoonSecret:""},cli:{name:"My Custom CLI",command:"my-custom-cli",description:"Stacks is a full-stack framework for TypeScript.",source:D(),deploy:!1},cache:{driver:"memory",prefix:"stx",ttl:3600,maxKeys:-1,useClones:!0,drivers:{redis:{host:"localhost",port:6379,username:"",password:"",database:0,tls:!1},memory:{maxKeys:-1,checkPeriod:600,deleteOnExpire:!0}}},cloud:{infrastructure:{type:"serverless",driver:"aws",environments:["production","staging","development"],firewall:{enabled:!0,countryCodes:[],ipAddresses:[],queryString:[],httpHeaders:[],rateLimitPerMinute:1000,useIpReputationLists:!0,useKnownBadInputsRuleSet:!0},cdn:{allowedMethods:"GET_HEAD",cachedMethods:"GET_HEAD",minTtl:0,defaultTtl:86400,maxTtl:31536000,compress:!0,priceClass:"PriceClass_All",originShieldRegion:q.awsRegion,cookieBehavior:"none",allowList:{cookies:[],headers:[],queryStrings:[]},realtimeLogs:{enabled:!0,samplingRate:2}},fileSystem:!1,storage:{}},sites:{root:"",path:""}},dashboard:{sections:{library:{enabled:!0},content:{enabled:!0},commerce:{enabled:!0},marketing:{enabled:!0},analytics:{enabled:!0},management:{enabled:!0},utilities:{enabled:!0}}},database:{default:"sqlite",logging:!1,connections:{sqlite:{database:O("stacks.sqlite"),prefix:""}},migrations:"migrations",migrationLocks:"migration_locks"},dns:{driver:"aws",a:[],aaaa:[],cname:[],mx:[],txt:[]},docs:{lang:"en-US",title:"Stacks",description:"Rapid application, cloud & library framework.",lastUpdated:!0,deploy:!1,themeConfig:{editLink:{pattern:"https://github.com/stacksjs/stacks/edit/main/docs/docs/:path",text:"Edit this page on GitHub"},footer:{message:"Released under the MIT License.",copyright:"Copyright \xA9 2024-present Stacks.js, Inc."}}},email:{from:{name:"Stacks",address:q.noReplyEmail},mailboxes:[],server:{enabled:!0,scan:!0}},errors:{messages:{string:"The {{ field }} field must be a string",email:"The {{ field }} field must be a valid email address",regex:"The {{ field }} field format is invalid",url:"The {{ field }} field must be a valid URL",activeUrl:"The {{ field }} field must be a valid URL",alpha:"The {{ field }} field must contain only letters",alphaNumeric:"The {{ field }} field must contain only letters and numbers","min(":"The {{ field }} field must have at least {{ min }} characters",maxLength:"The {{ field }} field must not be greater than {{ max }} characters",fixedLength:"The {{ field }} field must be {{ size }} characters long",confirmed:"The {{ field }} field and {{ otherField }} field must be the same",endsWith:"The {{ field }} field must end with {{ substring }}",startsWith:"The {{ field }} field must start with {{ substring }}",sameAs:"The {{ field }} field and {{ otherField }} field must be the same",notSameAs:"The {{ field }} field and {{ otherField }} field must be different",in:"The selected {{ field }} is invalid",notIn:"The selected {{ field }} is invalid",ipAddress:"The {{ field }} field must be a valid IP address",uuid:"The {{ field }} field must be a valid UUID",ascii:"The {{ field }} field must only contain ASCII characters",creditCard:"The {{ field }} field must be a valid {{ providersList }} card number",hexCode:"The {{ field }} field must be a valid hex color code",iban:"The {{ field }} field must be a valid IBAN number",jwt:"The {{ field }} field must be a valid JWT token",coordinates:"The {{ field }} field must contain latitude and longitude coordinates",mobile:"The {{ field }} field must be a valid mobile phone number",passport:"The {{ field }} field must be a valid passport number",postalCode:"The {{ field }} field must be a valid postal code",boolean:"The value must be a boolean",number:"The {{ field }} field must be a number",min:"The {{ field }} field must be at least {{ min }}",max:"The {{ field }} field must not be greater than {{ max }}",range:"The {{ field }} field must be between {{ min }} and {{ max }}",positive:"The {{ field }} field must be positive",negative:"The {{ field }} field must be negative",decimal:"The {{ field }} field must have {{ digits }} decimal places",withoutDecimals:"The {{ field }} field must not have decimal places",date:"The {{ field }} field must be a datetime value","date.equals":"The {{ field }} field must be a date equal to {{ expectedValue }}","date.after":"The {{ field }} field must be a date after {{ expectedValue }}","date.before":"The {{ field }} field must be a date before {{ expectedValue }}","date.afterOrEqual":"The {{ field }} field must be a date after or equal to {{ expectedValue }}","date.beforeOrEqual":"The {{ field }} field must be a date before or equal to {{ expectedValue }}","date.sameAs":"The {{ field }} field and {{ otherField }} field must be the same","date.notSameAs":"The {{ field }} field and {{ otherField }} field must be different","date.afterField":"The {{ field }} field must be a date after {{ otherField }}",accepted:"The {{ field }} field must be accepted",enum:"The selected {{ field }} is invalid",literal:"The {{ field }} field must be {{ expectedValue }}",object:"The {{ field }} field must be an object",record:"The {{ field }} field must be an object","record.min(":"The {{ field }} field must have at least {{ min }} items","record.maxLength":"The {{ field }} field must not have more than {{ max }} items","record.fixedLength":"The {{ field }} field must contain {{ size }} items",array:"The {{ field }} field must be an array","array.min(":"The {{ field }} field must have at least {{ min }} items","array.maxLength":"The {{ field }} field must not have more than {{ max }} items","array.fixedLength":"The {{ field }} field must contain {{ size }} items",notEmpty:"The {{ field }} field must not be empty",distinct:"The {{ field }} field has duplicate values",tuple:"The {{ field }} field must be an array",union:"Invalid value provided for {{ field }} field",unionGroup:"Invalid value provided for {{ field }} field",unionOfTypes:"Invalid value provided for {{ field }} field"}},git:{hooks:{"pre-commit":"lint-staged"},scopes:["","ci","deps","dx","release","docs","test","core","actions","arrays","auth","build","cache","cli","cloud","collections","config","database","datetime","docs","errors","git","lint","x-ray","modules","notifications","objects","path","realtime","router","buddy","security","server","storage","strings","tests","types","ui","utils"],messages:{type:"Select the type of change that you're committing:",scope:"Select the SCOPE of this change (optional):",customScope:"Select the SCOPE of this change:",subject:`Write a SHORT, IMPERATIVE tense description of the change:
|
|
3
3
|
`,body:`Provide a LONGER description of the change (optional). Use "|" to break new line:
|
|
4
4
|
`,breaking:`List any BREAKING CHANGES (optional). Use "|" to break new line:
|
|
5
5
|
`,footerPrefixesSelect:"Select the ISSUES type of the change list by this change (optional):",customFooterPrefixes:"Input ISSUES prefix:",footer:`List any ISSUES by this change. E.g.: #31, #34:
|
|
6
|
-
`,confirmCommit:"Are you sure you want to proceed with the commit above?"},types:[{value:"feat",name:"feat: \u2728 A new feature",emoji:":sparkles:"},{value:"fix",name:"fix: \uD83D\uDC1B A bug fix",emoji:":bug:"},{value:"docs",name:"docs: \uD83D\uDCDD Documentation only changes",emoji:":memo:"},{value:"style",name:"style: \uD83D\uDC84 Changes that do not affect the meaning of the code",emoji:":lipstick:"},{value:"refactor",name:"refactor: \u267B\uFE0F A code change that neither fixes a bug nor adds a feature",emoji:":recycle:"},{value:"perf",name:"perf: \u26A1\uFE0F A code change that improves performance",emoji:":zap:"},{value:"test",name:"test: \u2705 Adding missing tests or adjusting existing tests",emoji:":white_check_mark:"},{value:"build",name:"build: \uD83D\uDCE6\uFE0F Changes that affect the build system or external dependencies",emoji:":package:"},{value:"ci",name:"ci: \uD83C\uDFA1 Changes to our CI configuration files and scripts",emoji:":ferris_wheel:"},{value:"chore",name:"chore: \uD83D\uDD28 Other changes that don't modify src or test files",emoji:":hammer:"},{value:"revert",name:"revert: \u23EA\uFE0F Reverts a previous commit",emoji:":rewind:"}]},hashing:{driver:"bcrypt",bcrypt:{rounds:12},argon2:{memory:65536,time:2}},library:{name:"hello-world",owner:"@stacksjs",repository:"stacksjs/stacks",license:"MIT",author:"",contributors:[],defaultLanguage:"en",webComponents:{name:"hello-world-elements",description:"Your framework agnostic web component library description.",keywords:["custom-elements","web-components","library","framework-agnostic","typescript","javascript"],tags:[{name:["HelloWorld","AppHelloWorld"],description:"The Hello World custom element, built via this framework.",attributes:[{name:"greeting",description:"The greeting."}]}]},functions:{name:"hello-world-fx",description:"Your function library description.",keywords:["functions","composables","library","typescript","javascript"],shouldGenerateSourcemap:!1,files:["counter","dark"]}},logging:{logsPath:"storage/logs/stacks.log",deploymentsPath:"storage/logs/deployments.log"},notification:{default:"email"},payment:{driver:"stripe"},ports:{frontend:3000,backend:3001,admin:3002,library:3003,desktop:3004,email:3005,docs:3006,inspect:3007,api:3008,systemTray:3009,database:3010},queue:{default:"sync",connections:{sync:{driver:"sync"},database:{driver:"database",table:"jobs",queue:"default",retryAfter:90},redis:{driver:"redis",queue:"default",retryAfter:90},sqs:{driver:"sqs",key:"",secret:"",prefix:"",suffix:"",queue:"default",region:j.awsRegion}}},saas:{plans:[{productName:"Stacks Hobby",description:"All the Stacks features.",pricing:[{key:"stacks_hobby_monthly",price:3900,interval:"month",currency:"usd"},{key:"stacks_hobby_yearly",price:37900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}},{productName:"Stacks Pro",description:"All the Stacks features, including being able to invite team members.",pricing:[{key:"stacks_pro_monthly",price:5900,interval:"month",currency:"usd"},{key:"stacks_pro_yearly",price:57900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}}],webhook:{endpoint:"/webhooks/stripe",secret:""},currencies:["usd"],coupons:[{code:"SUMMER2024",amountOff:500,duration:"once"}],products:[{name:"Stacks Pro",description:"All the Stacks features.",images:["url_to_image"]}]},searchEngine:{driver:"opensearch"},security:{firewall:{enabled:!0,countryCodes:[],ipAddresses:[],queryString:[],httpHeaders:[],rateLimitPerMinute:1000,useIpReputationLists:!0,useKnownBadInputsRuleSet:!0}},services:{aws:{accountId:"",appId:"",apiKey:"",region:j.awsRegion},algolia:{appId:"",apiKey:""},meilisearch:{appId:"",apiKey:""},stripe:{appId:"",apiKey:""}},filesystems:{driver:"s3"},team:{name:"",members:{}},ui:{shortcuts:[["btn","inline-flex items-center px-4 py-2 ml-2 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-pointer"]],safelist:"prose prose-sm m-auto text-left",trigger:":stx:",classPrefix:"stx-",reset:"tailwind",icons:["hugeicons"],fonts:{email:{title:"Mona",text:"Hubot"},desktop:{title:"Mona",text:"Hubot"},mobile:{title:"Mona",text:"Hubot"},web:{title:"Mona",text:"Hubot"}}}};var k=process.env.SKIP_CONFIG_LOADING==="true",y=Symbol.for("@stacksjs/config:overrides"),b=Symbol.for("@stacksjs/config:overridesReady");function E(){return{ai:{},analytics:{},app:{name:process.env.APP_NAME||"Stacks",env:process.env.APP_ENV||"production"},cache:{},cli:{},cloud:{},dashboard:{},database:{},dns:{},realtime:{},email:{},errors:{},git:{},hashing:{},library:{},logging:{},notification:{},queue:{},payment:{},ports:{},saas:{},searchEngine:{},security:{},services:{},filesystems:{},team:{},ui:{}}}var F=globalThis,m=F[y],I=m??(()=>{let x=E();return F[y]=x,x})(),h=[["ai","~/config/ai"],["analytics","~/config/analytics"],["app","~/config/app"],["cache","~/config/cache"],["cli","~/config/cli"],["cloud","~/config/cloud"],["dashboard","~/config/dashboard"],["database","~/config/database"],["dns","~/config/dns"],["email","~/config/email"],["errors","~/config/errors"],["git","~/config/git"],["hashing","~/config/hashing"],["library","~/config/library"],["logging","~/config/logging"],["notification","~/config/notification"],["payment","~/config/payment"],["ports","~/config/ports"],["queue","~/config/queue"],["realtime","~/config/realtime"],["saas","~/config/saas"],["searchEngine","~/config/search-engine"],["security","~/config/security"],["services","~/config/services"],["filesystems","~/config/filesystems"],["team","~/config/team"],["ui","~/config/ui"]],d=F[b],M=d??(()=>{let x=k?Promise.resolve(I):Promise.all(h.map(async([X,z])=>{try{let G=await import(z);if(G?.default!==void 0)I[X]=G.default}catch(G){let Z=G?.code,Q=G?.message??String(G);if(!(Z==="ERR_MODULE_NOT_FOUND"||Z==="MODULE_NOT_FOUND"||/Cannot find module/i.test(Q)))console.warn(`[config] Failed to load ${String(X)} config from ${z}: ${Q}`)}})).then(()=>I);return F[b]=x,x})();async function wx(x={}){let X=x.domain??N.app.url??"stacks",z=x.type??"frontend",G=x.localhost??!1,Z=x.https,Q=x.network,J=X.replace(/\.[^.]+$/,".localhost");async function $(S){let{createLocalTunnel:D}=await import("@stacksjs/tunnel");return D(S)}switch(z){case"frontend":if(Q)return await $(N.ports?.frontend||3000);if(G)return`http://localhost:${N.ports?.frontend}`;break;case"backend":if(Q)return await $(N.ports?.backend||3001);if(G)return`http://localhost:${N.ports?.backend}`;J=`api.${J}`;break;case"admin":if(Q)return await $(N.ports?.admin||3002);if(G)return`http://localhost:${N.ports?.admin}`;J=`admin.${J}`;break;case"library":if(Q)return await $(N.ports?.library||3003);if(G)return`http://localhost:${N.ports?.library}`;J=`libs.${J}`;break;case"email":if(Q)return await $(N.ports?.email||3005);if(G)return`http://localhost:${N.ports?.email}`;J=`email.${J}`;break;case"desktop":if(Q)return await $(N.ports?.desktop||3004);if(G)return`http://localhost:${N.ports?.desktop}`;J=`desktop.${J}`;break;case"docs":if(Q)return await $(N.ports?.docs||3006);if(G)return`http://localhost:${N.ports?.docs}`;J=`docs.${J}`;break;case"inspect":if(Q)return await $(N.ports?.inspect||3007);if(G)return`http://localhost:${N.ports?.inspect}`;J=`inspect.${J}`;break;default:if(G)return`http://localhost:${N.ports?.frontend}`}if(Z)return`https://${J}`;return`http://${J}`}function _x(x){return x}function Ox(x){return x}function Rx(x){return x}function kx(x){return x}function Ex(x){return x}function mx(x){return x}function hx(x){return x}function dx(x){return x}function px(x){return x}function vx(x){return x}function tx(x){return x}function ux(x){return x}function sx(x){return x}function rx(x){return x}function lx(x){return x}function fx(x){return x}function ax(x){return x}function gx(x){return x}function cx(x){return x}function ex(x){return x}function ix(x){return x}function nx(x){return x}function ox(x){return x}function xN(x){return x}function NN(x){return x}function XN(x){return x}function A(x){let X=I[x];if(X!==void 0&&(typeof X!=="object"||Object.keys(X).length>0))return X;return W[x]}var p=function(){},N=new Proxy(p,{get(x,X){return A(X)},has(x,X){return X in I||X in W},ownKeys(){return Array.from(new Set([...Object.keys(I),...Object.keys(W)]))},getOwnPropertyDescriptor(x,X){if(typeof X!=="string")return;if(!(X in I)&&!(X in W))return;return{enumerable:!0,configurable:!0,writable:!0,value:A(X)}},isExtensible(){return!0},preventExtensions(){return!1}});async function QN(){return await M,N}var H=Symbol.for("@stacksjs/config:databaseReady"),L=globalThis;async function ZN(){await M;let x=Date.now()+5000;while(!L[H]&&Date.now()<x)await new Promise((X)=>setTimeout(X,25));if(!L[H])console.warn("[config] awaitDatabaseConfig() timed out \u2014 database driver did not signal readiness within 5s");return N}function $N(){L[H]=!0}function IN(){return N}var{ai:v,analytics:t,app:u,auth:s,realtime:r,cache:l,cloud:f,cli:a,dashboard:g,database:c,dns:e,docs:i,email:n,errors:o,git:xx,hashing:Nx,library:Xx,logging:zx,notification:Gx,payment:Jx,ports:Qx,queue:Zx,security:$x,saas:Ix,searchEngine:jx,services:qx,filesystems:Bx,team:Ux,ui:Wx}=N;M.then(()=>{v=N.ai,t=N.analytics,u=N.app,s=N.auth,r=N.realtime,l=N.cache,f=N.cloud,a=N.cli,g=N.dashboard,c=N.database,e=N.dns,i=N.docs,n=N.email,o=N.errors,xx=N.git,Nx=N.hashing,Xx=N.library,zx=N.logging,Gx=N.notification,Jx=N.payment,Qx=N.ports,Zx=N.queue,$x=N.security,Ix=N.saas,jx=N.searchEngine,qx=N.services,Bx=N.filesystems,Ux=N.team,Wx=N.ui}).catch(()=>{});function jN(){let x=N.app?.env;if(x==="local"||x==="development")return"dev";if(x==="staging")return"stage";if(x==="production")return"prod";if(!x)throw Error("Couldn't determine app environment");return x}function Fx(x){return typeof x==="object"&&x!==null&&!Array.isArray(x)}function Mx(x,X){return(z,G)=>{if(z==null)return[];if(typeof z!=="number"||!Number.isInteger(z))return[{path:G,message:`expected integer, got ${typeof z} (${JSON.stringify(z)})`}];if(z<x||z>X)return[{path:G,message:`expected integer in [${x}, ${X}], got ${z}`}];return[]}}function q(x){return(X,z)=>{if(X==null)return[];if(typeof X!=="string"||!x.includes(X))return[{path:z,message:`expected one of [${x.join(", ")}], got ${JSON.stringify(X)}`}];return[]}}function K(){return(x,X)=>{if(x==null)return[];return typeof x==="string"?[]:[{path:X,message:`expected string, got ${typeof x}`}]}}function Vx(){return(x,X)=>{if(x==null)return[];return typeof x==="boolean"?[]:[{path:X,message:`expected boolean, got ${typeof x}`}]}}var B=Mx(1,65535),Hx={app:{rules:{name:K(),env:q(["local","development","staging","production","test"]),debug:Vx(),url:K()}},ports:{rules:{frontend:B,api:B,admin:B,docs:B,systemTray:B,desktop:B}},database:{rules:{default:q(["sqlite","mysql","postgres","dynamodb"])}},cache:{rules:{driver:q(["memory","redis"])}},queue:{rules:{default:q(["sync","database","redis"])}},logging:{rules:{level:q(["trace","debug","info","warn","error","fatal"])}},email:{rules:{default:q(["ses","sendgrid","mailgun","mailtrap","smtp","log"])}}};function P(x){let X=[];for(let[z,G]of Object.entries(Hx)){let Z=x[z];if(Z==null)continue;if(!Fx(Z)){X.push({path:z,message:`expected object, got ${typeof Z}`});continue}for(let[Q,J]of Object.entries(G.rules)){let $=Z[Q];X.push(...J($,`${z}.${Q}`))}}return X}function Lx(x){let X=P(x);if(X.length===0)return!0;console.warn("[config] Configuration issues detected:");for(let z of X)console.warn(` \u2022 ${z.path}: ${z.message}`);return!1}var U=new Map;function C(){return N.features??{}}function T(x){if(U.has(x))return U.get(x);let X=C()[x];if(X===void 0||X===null)return!1;if(typeof X==="boolean")return X;if(typeof X==="object"){if(X.enabled===!1)return!1;if(Array.isArray(X.env)&&X.env.length>0){let z=(N.app?.env??"").toString();if(!X.env.includes(z))return!1}return X.enabled!==void 0?X.enabled:!0}return!1}function Tx(x){U.set(x,!0)}function Yx(x){U.set(x,!1)}function yx(x){U.delete(x)}function bx(){let x={};for(let X of Object.keys(C()))x[X]=T(X);for(let X of U.keys())x[X]=T(X);return x}export{P as validateConfig,Wx as ui,Ux as team,qx as services,$x as security,jx as searchEngine,Ix as saas,yx as resetFeature,Lx as reportConfigIssues,r as realtime,Zx as queue,Qx as ports,Jx as payment,M as overridesReady,I as overrides,Gx as notification,$N as markDatabaseReady,zx as logging,wx as localUrl,bx as listFeatures,Xx as library,Nx as hashing,xx as git,IN as getConfig,Bx as filesystems,T as feature,o as errors,Tx as enableFeature,n as email,i as docs,e as dns,Yx as disableFeature,jN as determineAppEnv,xN as defineUi,nx as defineStorage,_x as defineStacksConfig,ix as defineSms,ex as defineServices,cx as defineSecurity,gx as defineSearchEngine,ax as defineQueue,fx as definePayment,lx as defineNotification,NN as defineModel,rx as defineLibrary,sx as defineHashing,ux as defineGit,ox as defineFilesystems,XN as defineEvents,vx as defineEmailConfig,tx as defineEmail,px as defineDns,dx as defineDependencies,hx as defineDatabase,mx as defineCli,Ex as defineChat,kx as defineCdn,Rx as defineCache,Ox as defineApp,W as defaults,c as database,g as dashboard,N as config,f as cloud,a as cli,l as cache,ZN as awaitDatabaseConfig,QN as awaitConfig,s as auth,u as app,t as analytics,v as ai,j as FRAMEWORK_DEFAULTS};
|
|
6
|
+
`,confirmCommit:"Are you sure you want to proceed with the commit above?"},types:[{value:"feat",name:"feat: \u2728 A new feature",emoji:":sparkles:"},{value:"fix",name:"fix: \uD83D\uDC1B A bug fix",emoji:":bug:"},{value:"docs",name:"docs: \uD83D\uDCDD Documentation only changes",emoji:":memo:"},{value:"style",name:"style: \uD83D\uDC84 Changes that do not affect the meaning of the code",emoji:":lipstick:"},{value:"refactor",name:"refactor: \u267B\uFE0F A code change that neither fixes a bug nor adds a feature",emoji:":recycle:"},{value:"perf",name:"perf: \u26A1\uFE0F A code change that improves performance",emoji:":zap:"},{value:"test",name:"test: \u2705 Adding missing tests or adjusting existing tests",emoji:":white_check_mark:"},{value:"build",name:"build: \uD83D\uDCE6\uFE0F Changes that affect the build system or external dependencies",emoji:":package:"},{value:"ci",name:"ci: \uD83C\uDFA1 Changes to our CI configuration files and scripts",emoji:":ferris_wheel:"},{value:"chore",name:"chore: \uD83D\uDD28 Other changes that don't modify src or test files",emoji:":hammer:"},{value:"revert",name:"revert: \u23EA\uFE0F Reverts a previous commit",emoji:":rewind:"}]},hashing:{driver:"bcrypt",bcrypt:{rounds:12},argon2:{memory:65536,time:2}},library:{name:"hello-world",owner:"@stacksjs",repository:"stacksjs/stacks",license:"MIT",author:"",contributors:[],defaultLanguage:"en",webComponents:{name:"hello-world-elements",description:"Your framework agnostic web component library description.",keywords:["custom-elements","web-components","library","framework-agnostic","typescript","javascript"],tags:[{name:["HelloWorld","AppHelloWorld"],description:"The Hello World custom element, built via this framework.",attributes:[{name:"greeting",description:"The greeting."}]}]},functions:{name:"hello-world-fx",description:"Your function library description.",keywords:["functions","composables","library","typescript","javascript"],shouldGenerateSourcemap:!1,files:["counter","dark"]}},logging:{logsPath:"storage/logs/stacks.log",deploymentsPath:"storage/logs/deployments.log"},notification:{default:"email"},payment:{driver:"stripe"},ports:{frontend:3000,backend:3001,admin:3002,library:3003,desktop:3004,email:3005,docs:3006,inspect:3007,api:3008,systemTray:3009,database:3010},queue:{default:"sync",connections:{sync:{driver:"sync"},database:{driver:"database",table:"jobs",queue:"default",retryAfter:90},redis:{driver:"redis",queue:"default",retryAfter:90},sqs:{driver:"sqs",key:"",secret:"",prefix:"",suffix:"",queue:"default",region:q.awsRegion}}},saas:{plans:[{productName:"Stacks Hobby",description:"All the Stacks features.",pricing:[{key:"stacks_hobby_monthly",price:3900,interval:"month",currency:"usd"},{key:"stacks_hobby_yearly",price:37900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}},{productName:"Stacks Pro",description:"All the Stacks features, including being able to invite team members.",pricing:[{key:"stacks_pro_monthly",price:5900,interval:"month",currency:"usd"},{key:"stacks_pro_yearly",price:57900,interval:"year",currency:"usd"}],metadata:{createdBy:"admin",version:"1.0.0"}}],webhook:{endpoint:"/webhooks/stripe",secret:""},currencies:["usd"],coupons:[{code:"SUMMER2024",amountOff:500,duration:"once"}],products:[{name:"Stacks Pro",description:"All the Stacks features.",images:["url_to_image"]}]},searchEngine:{driver:"opensearch"},security:{firewall:{enabled:!0,countryCodes:[],ipAddresses:[],queryString:[],httpHeaders:[],rateLimitPerMinute:1000,useIpReputationLists:!0,useKnownBadInputsRuleSet:!0}},services:{aws:{accountId:"",appId:"",apiKey:"",region:q.awsRegion},algolia:{appId:"",apiKey:""},meilisearch:{appId:"",apiKey:""},stripe:{appId:"",apiKey:""}},filesystems:{driver:"s3"},team:{name:"",members:{}},ui:{shortcuts:[["btn","inline-flex items-center px-4 py-2 ml-2 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-pointer"]],safelist:"prose prose-sm m-auto text-left",trigger:":stx:",classPrefix:"stx-",reset:"tailwind",icons:["hugeicons"],fonts:{email:{title:"Mona",text:"Hubot"},desktop:{title:"Mona",text:"Hubot"},mobile:{title:"Mona",text:"Hubot"},web:{title:"Mona",text:"Hubot"}}}};function R(x){return typeof x==="object"&&x!==null&&!Array.isArray(x)}function k(x,X){return(z,G)=>{if(z==null)return[];let Q=null;if(typeof z==="number"&&Number.isInteger(z))Q=z;else if(typeof z==="string"&&/^-?\d+$/.test(z))Q=Number.parseInt(z,10);if(Q===null)return[{path:G,message:`expected integer, got ${typeof z} (${JSON.stringify(z)})`}];if(Q<x||Q>X)return[{path:G,message:`expected integer in [${x}, ${X}], got ${Q}`}];return[]}}function I(x){return(X,z)=>{if(X==null)return[];if(typeof X!=="string"||!x.includes(X))return[{path:z,message:`expected one of [${x.join(", ")}], got ${JSON.stringify(X)}`}];return[]}}function w(){return(x,X)=>{if(x==null)return[];return typeof x==="string"?[]:[{path:X,message:`expected string, got ${typeof x}`}]}}function E(){return(x,X)=>{if(x==null)return[];return typeof x==="boolean"?[]:[{path:X,message:`expected boolean, got ${typeof x}`}]}}var B=k(1,65535),m={app:{rules:{name:w(),env:I(["local","development","staging","production","test"]),debug:E(),url:w()}},ports:{rules:{frontend:B,api:B,admin:B,docs:B,systemTray:B,desktop:B}},database:{rules:{default:I(["sqlite","mysql","singlestore","postgres","dynamodb"])}},cache:{rules:{driver:I(["memory","redis","singlestore"])}},queue:{rules:{default:I(["sync","database","redis"])}},logging:{rules:{level:I(["trace","debug","info","warn","error","fatal"])}},email:{rules:{default:I(["ses","sendgrid","mailgun","mailtrap","smtp","log","capture"])}}};function V(x){let X=[];for(let[z,G]of Object.entries(m)){let Q=x[z];if(Q==null)continue;if(!R(Q)){X.push({path:z,message:`expected object, got ${typeof Q}`});continue}for(let[Z,J]of Object.entries(G.rules)){let $=Q[Z];X.push(...J($,`${z}.${Z}`))}}return X}function h(x){let X=V(x);if(X.length===0)return!0;console.warn("[config] Configuration issues detected:");for(let z of X)console.warn(` \u2022 ${z.path}: ${z.message}`);return!1}var p=process.env.SKIP_CONFIG_LOADING==="true",d=process.env.SKIP_CONFIG_VALIDATION==="true",K=Symbol.for("@stacksjs/config:overrides"),P=Symbol.for("@stacksjs/config:overridesReady");function v(){return{ai:{},analytics:{},app:{name:process.env.APP_NAME||"Stacks",env:process.env.APP_ENV||"production"},auth:{},cache:{},cli:{},cloud:{},cms:{},commerce:{},dashboard:{},database:{},dns:{},realtime:{},email:{},errors:{},git:{},hashing:{},library:{},logging:{},marketing:{},monitoring:{},notification:{},queue:{},payment:{},ports:{},saas:{},searchEngine:{},security:{},services:{},filesystems:{},team:{},ui:{}}}var H=globalThis,t=H[K],j=t??(()=>{let x=v();return H[K]=x,x})(),r=[["ai","~/config/ai"],["analytics","~/config/analytics"],["app","~/config/app"],["auth","~/config/auth"],["cache","~/config/cache"],["cli","~/config/cli"],["cloud","~/config/cloud"],["cms","~/config/cms"],["commerce","~/config/commerce"],["dashboard","~/config/dashboard"],["database","~/config/database"],["dns","~/config/dns"],["email","~/config/email"],["errors","~/config/errors"],["git","~/config/git"],["hashing","~/config/hashing"],["library","~/config/library"],["logging","~/config/logging"],["marketing","~/config/marketing"],["monitoring","~/config/monitoring"],["notification","~/config/notification"],["payment","~/config/payment"],["ports","~/config/ports"],["queue","~/config/queue"],["realtime","~/config/realtime"],["saas","~/config/saas"],["searchEngine","~/config/search-engine"],["security","~/config/security"],["services","~/config/services"],["filesystems","~/config/filesystems"],["team","~/config/team"],["ui","~/config/ui"]],u=H[P],U=u??(()=>{let x=p?Promise.resolve(j):Promise.all(r.map(async([X,z])=>{try{let G=await import(z);if(G?.default!==void 0)j[X]=G.default}catch(G){let Q=G?.code,Z=G?.message??String(G);if(!(Q==="ERR_MODULE_NOT_FOUND"||Q==="MODULE_NOT_FOUND"||/Cannot find module/i.test(Z)))console.warn(`[config] Failed to load ${String(X)} config from ${z}: ${Z}`)}})).then(()=>{if(!d){let X=V(j);if(X.length>0){console.error("[config] Configuration issues detected:");for(let G of X)console.error(` \u2022 ${G.path}: ${G.message}`);let z=X.map((G)=>` \u2022 ${G.path}: ${G.message}`).join(`
|
|
7
|
+
`);throw Error(`[config] ${X.length} configuration issue(s) detected at boot:
|
|
8
|
+
${z}
|
|
9
|
+
Set SKIP_CONFIG_VALIDATION=true to bypass (e.g. when running migrations against partial config).`)}}return j});return H[P]=x,x})();async function Ex(x={}){let X=x.domain??N.app.url??"stacks",z=x.type??"frontend",G=x.localhost??!1,Q=x.https,Z=x.network,J=X.replace(/\.[^.]+$/,".localhost");async function $(C){let{createLocalTunnel:A}=await import("@stacksjs/tunnel");return A(C)}switch(z){case"frontend":if(Z)return await $(N.ports?.frontend||3000);if(G)return`http://localhost:${N.ports?.frontend}`;break;case"backend":if(Z)return await $(N.ports?.backend||3001);if(G)return`http://localhost:${N.ports?.backend}`;J=`api.${J}`;break;case"admin":if(Z)return await $(N.ports?.admin||3002);if(G)return`http://localhost:${N.ports?.admin}`;J=`admin.${J}`;break;case"library":if(Z)return await $(N.ports?.library||3003);if(G)return`http://localhost:${N.ports?.library}`;J=`libs.${J}`;break;case"email":if(Z)return await $(N.ports?.email||3005);if(G)return`http://localhost:${N.ports?.email}`;J=`email.${J}`;break;case"desktop":if(Z)return await $(N.ports?.desktop||3004);if(G)return`http://localhost:${N.ports?.desktop}`;J=`desktop.${J}`;break;case"docs":if(Z)return await $(N.ports?.docs||3006);if(G)return`http://localhost:${N.ports?.docs}`;J=`docs.${J}`;break;case"inspect":if(Z)return await $(N.ports?.inspect||3007);if(G)return`http://localhost:${N.ports?.inspect}`;J=`inspect.${J}`;break;default:if(G)return`http://localhost:${N.ports?.frontend}`}if(Q)return`https://${J}`;return`http://${J}`}function mx(x){return x}function hx(x){return x}function px(x){return x}function dx(x){return x}function vx(x){return x}function tx(x){return x}function rx(x){return x}function ux(x){return x}function sx(x){return x}function lx(x){return x}function fx(x){return x}function gx(x){return x}function ax(x){return x}function cx(x){return x}function ex(x){return x}function ix(x){return x}function nx(x){return x}function ox(x){return x}function xN(x){return x}function NN(x){return x}function XN(x){return x}function zN(x){return x}function GN(x){return x}function JN(x){return x}function QN(x){return x}function ZN(x){return x}function b(x){let X=j[x];if(X!==void 0&&(typeof X!=="object"||Object.keys(X).length>0))return X;return M[x]}var s=function(){},N=new Proxy(s,{get(x,X){return b(X)},has(x,X){return X in j||X in M},ownKeys(){return Array.from(new Set([...Object.keys(j),...Object.keys(M)]))},getOwnPropertyDescriptor(x,X){if(typeof X!=="string")return;if(!(X in j)&&!(X in M))return;return{enumerable:!0,configurable:!0,writable:!0,value:b(X)}},isExtensible(){return!0},preventExtensions(){return!1}});async function IN(){return await U,N}var Y=Symbol.for("@stacksjs/config:databaseReady"),T=globalThis;async function BN(){await U;let x=Date.now()+5000;while(!T[Y]&&Date.now()<x)await new Promise((X)=>setTimeout(X,25));if(!T[Y])console.warn("[config] awaitDatabaseConfig() timed out \u2014 database driver did not signal readiness within 5s");return N}function WN(){T[Y]=!0}function MN(){return N}var{ai:l,analytics:f,app:g,auth:a,realtime:c,cache:e,cloud:i,cli:n,dashboard:o,database:xx,dns:Nx,docs:Xx,email:zx,errors:Gx,git:Jx,hashing:Qx,library:Zx,logging:$x,notification:jx,payment:qx,ports:Ix,queue:Bx,security:Wx,saas:Mx,searchEngine:Vx,services:Hx,filesystems:Ux,team:Lx,ui:Yx}=N;U.then(()=>{l=N.ai,f=N.analytics,g=N.app,a=N.auth,c=N.realtime,e=N.cache,i=N.cloud,n=N.cli,o=N.dashboard,xx=N.database,Nx=N.dns,Xx=N.docs,zx=N.email,Gx=N.errors,Jx=N.git,Qx=N.hashing,Zx=N.library,$x=N.logging,jx=N.notification,qx=N.payment,Ix=N.ports,Bx=N.queue,Wx=N.security,Mx=N.saas,Vx=N.searchEngine,Hx=N.services,Ux=N.filesystems,Lx=N.team,Yx=N.ui}).catch(()=>{});function VN(){let x=N.app?.env;if(x==="local"||x==="development")return"dev";if(x==="staging")return"stage";if(x==="production")return"prod";if(!x)throw Error("Couldn't determine app environment");return x}var Tx=["auth","marketing","cms","commerce","dashboard","monitoring","realtime","queue"],yx={dashboard:!0},W=new Map;function Fx(x){let X=N[x];return X&&typeof X==="object"?X:void 0}function y(x){if(W.has(x))return W.get(x);let X=Fx(x);if(X){let z=X.enabled;if(z===!1)return!1;if(Array.isArray(X.env)&&X.env.length>0){let G=(N.app?.env??"").toString();if(!X.env.includes(G))return!1}if(z!==void 0)return!!z;return!0}return yx[x]??!1}function wx(x){W.set(x,!0)}function Kx(x){W.set(x,!1)}function Px(x){W.delete(x)}function bx(){let x={};for(let X of Tx)x[X]=y(X);for(let X of W.keys())x[X]=y(X);return x}export{V as validateConfig,Yx as ui,Lx as team,Hx as services,Wx as security,Vx as searchEngine,Mx as saas,Px as resetFeature,h as reportConfigIssues,c as realtime,Bx as queue,Ix as ports,qx as payment,U as overridesReady,j as overrides,jx as notification,WN as markDatabaseReady,$x as logging,Ex as localUrl,bx as listFeatures,Zx as library,Qx as hashing,Jx as git,MN as getConfig,Ux as filesystems,y as feature,Gx as errors,wx as enableFeature,zx as email,Xx as docs,Nx as dns,Kx as disableFeature,VN as determineAppEnv,JN as defineUi,zN as defineStorage,mx as defineStacksConfig,XN as defineSms,NN as defineServices,xN as defineSecurity,ox as defineSearchEngine,nx as defineQueue,ix as definePayment,ex as defineNotification,QN as defineModel,cx as defineLibrary,ax as defineHashing,gx as defineGit,GN as defineFilesystems,ZN as defineEvents,lx as defineEmailConfig,fx as defineEmail,sx as defineDns,ux as defineDependencies,rx as defineDatabase,tx as defineCli,vx as defineChat,dx as defineCdn,px as defineCache,hx as defineApp,M as defaults,xx as database,o as dashboard,N as config,i as cloud,n as cli,e as cache,BN as awaitDatabaseConfig,IN as awaitConfig,a as auth,g as app,f as analytics,l as ai,q as FRAMEWORK_DEFAULTS};
|
package/dist/src/features.d.ts
CHANGED
|
@@ -3,16 +3,15 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Resolution order (first match wins):
|
|
5
5
|
* 1. Runtime override via `enableFeature` / `disableFeature`
|
|
6
|
-
* 2.
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* 3.
|
|
10
|
-
* 4. Missing → `false`
|
|
6
|
+
* 2. `config.<name>.enabled` — boolean or omitted
|
|
7
|
+
* - Optional `config.<name>.env: string[]` narrows the flag to specific
|
|
8
|
+
* deploy targets (compared against `config.app.env`)
|
|
9
|
+
* 3. Per-feature framework default (only `dashboard` defaults true)
|
|
11
10
|
*
|
|
12
11
|
* @example
|
|
13
12
|
* ```ts
|
|
14
|
-
* if (feature('
|
|
15
|
-
*
|
|
13
|
+
* if (feature('commerce')) {
|
|
14
|
+
* await loadCommerceRoutes()
|
|
16
15
|
* }
|
|
17
16
|
* ```
|
|
18
17
|
*/
|
|
@@ -31,8 +30,10 @@ export declare function disableFeature(name: string): void;
|
|
|
31
30
|
*/
|
|
32
31
|
export declare function resetFeature(name: string): void;
|
|
33
32
|
/**
|
|
34
|
-
* Snapshot of the live flag set — useful for `/__features` debug
|
|
35
|
-
*
|
|
33
|
+
* Snapshot of the live flag set — useful for `/__features` debug endpoints
|
|
34
|
+
* and CLI commands that print the active configuration. Iterates the known
|
|
35
|
+
* framework features plus any runtime overrides for ad-hoc flags.
|
|
36
36
|
*/
|
|
37
37
|
export declare function listFeatures(): Record<string, boolean>;
|
|
38
|
-
|
|
38
|
+
export type StacksFeature = | 'auth' | 'marketing' | 'cms' | 'commerce'
|
|
39
|
+
| 'dashboard' | 'monitoring' | 'realtime' | 'queue';
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.70.
|
|
4
|
+
"version": "0.70.54",
|
|
5
5
|
"description": "The Stacks config helper methods.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": [
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"ts-pantry": "^0.8.16"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@stacksjs/alias": "
|
|
50
|
+
"@stacksjs/alias": "0.70.54",
|
|
51
51
|
"better-dx": "^0.2.12",
|
|
52
|
-
"@stacksjs/types": "
|
|
52
|
+
"@stacksjs/types": "0.70.54",
|
|
53
53
|
"bunfig": "^0.15.11"
|
|
54
54
|
}
|
|
55
55
|
}
|