@donotdev/core 0.0.14 → 0.0.16

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.
@@ -1,11 +1,11 @@
1
- var Y=(n,e)=>()=>(n&&(e=n(n=0)),e);function V(n,e=null){let t=R[n];if(!t)throw new Error(`Unknown pattern type: ${n}`);return e&&t.framework?{...t,framework:t.framework.map(s=>`${e}/${s}`)}:t}function Z(n){return q[n]||q.base}var U,R,q,K=Y(()=>{"use strict";P();U={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},R={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json"],framework:{eager:[`${U.SOURCE_EAGER}/*_*.json`],lazy:[`${U.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]},q={base:{absolute:!0,onlyFiles:!0,ignore:R.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...R.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...R.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:R.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:R.globalIgnore}}});import{Buffer as w}from"node:buffer";import{createRequire as pe}from"node:module";import{dirname as fe,resolve as _e}from"node:path";import y from"node:process";import{fileURLToPath as de}from"node:url";var he,F,A,P=Y(()=>{"use strict";he=pe(import.meta.url),F=de(import.meta.url),A=fe(F);typeof globalThis<"u"&&(globalThis.require=he,globalThis.__filename=F,globalThis.__dirname=A,globalThis.Buffer=w,globalThis.process=y,typeof global>"u"&&(globalThis.global=globalThis))});P();P();P();import W from"node:fs";import k from"node:path";import{fileURLToPath as me}from"node:url";var ge=me(import.meta.url),Te=k.dirname(ge);function X(){let n=y.cwd(),e=10;for(let t=0;t<e;t++){let s=k.join(n,"package.json");if(W.existsSync(s))try{let o=JSON.parse(W.readFileSync(s,"utf8")),r=o.workspaces&&Array.isArray(o.workspaces);if(r&&o.workspaces.some(c=>c==="packages/**"||c.startsWith("packages/"))&&(W.existsSync(k.join(n,"packages","core"))||W.existsSync(k.join(n,"packages","functions"))))return{type:"dndev",root:n};if(r&&o.workspaces.some(c=>c.includes("dndev/packages"))){let f=o.workspaces.find(d=>d.includes("dndev/packages")).replace(/\/packages.*$/,""),g=k.resolve(n,f);if(W.existsSync(k.join(g,"packages","core")))return{type:"dndev",root:g}}}catch{}let i=k.dirname(n);if(i===n)break;n=i}return{type:"npm",root:y.cwd()}}function ve(n){return n.type==="dndev"?n.root:null}function Q(n){let e={};if(n.type==="dndev"){let t=ve(n);t&&(e["@donotdev/types"]=k.join(t,"packages","core","types","src"),e["@donotdev/functions"]=k.join(t,"packages","functions","src"),e["@donotdev/utils"]=k.join(t,"packages","core","utils","src"),e["@donotdev/schemas"]=k.join(t,"packages","core","schemas","src"),e["@donotdev/core"]=k.join(t,"packages","core"))}return e}P();import{createRequire as ye}from"node:module";import{resolve as M,join as S,dirname as E,relative as J,normalize as Pe,sep as ee,extname as be}from"node:path";import{fileURLToPath as ke}from"node:url";import*as p from"node:fs";K();import we from"fast-glob";var _={getGlobOptionsFor:Z||void 0,SCAN_PATTERNS:R||void 0,getPatternsFor:V||void 0,I18N_PATHS:U||void 0},v={error:(n,e)=>{},warn:(n,e)=>{},info:n=>{}};function te(n,e){return n().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var re={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},B=class n{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return n._instance||(n._instance=new n(e)),n._instance}static _reset(){n._instance=null}constructor(e={}){if(n._instance)return n._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=y.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${y.cwd()}`)}this._appRoot=null,n._instance=this}normalizePath(e){if(!e)return"";try{return Pe(e).split(ee).join("/")}catch{return String(e).split(ee).join("/")}}getRelativePath(e){let t=this.getAppRoot(),s=J(t,e);return this.normalizePath(s)}getBasename(e){if(!e)return"";let s=this.normalizePath(e).split("/");return s[s.length-1]||""}getDirname(e){return e?this.normalizePath(E(e)):""}resolvePackage(e,t=null){try{let s=t||this.getAppRoot(),o=ye(S(s,"package.json")).resolve(e);return this.normalizePath(o)}catch{return null}}resolveFrameworkPackage(e,t=null){let s=this.resolvePackage(`${e}/package.json`,t);if(s)return this.getDirname(s);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let r=e.replace("@donotdev/",""),a=this.resolveRepoPath(`packages/${r}`);if(this.pathExists(a))return a;if(["auth","billing","crud","oauth"].includes(r)){let l=this.resolveRepoPath(`packages/features/${r}`);if(this.pathExists(l))return l}if(r==="firebase"){let l=this.resolveRepoPath(`packages/providers/${r}`);if(this.pathExists(l))return l}}let i=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(i))return i;let o=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(o)?o:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),s=M(t,e);return this.normalizePath(s)}resolveRepoPath(e){let t=this.getRepoRoot(),s=this.normalizePath(e),i=M(t,s);return this.normalizePath(i)}resolvePath(e,t){let s=this.normalizePath(t),i=this.normalizePath(e),o=M(s,i);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=p.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:be(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:s="auto",encoding:i="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return await p.promises.readFile(e);let r=await p.promises.readFile(e,i),a=this.stripBom(r);return o==="json"?JSON.parse(a):a}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}readSync(e,t={}){let{format:s="auto",encoding:i="utf8"}=t,o=this._detectFormat(e,s);try{if(o==="buffer")return p.readFileSync(e);let r=p.readFileSync(e,i),a=this.stripBom(r);return o==="json"?JSON.parse(a):a}catch(r){return this.options.debug&&v.warn(`Failed to read file: ${e}`,r),null}}async write(e,t,s={}){let{format:i="auto",overwrite:o=!1,dryRun:r=!1,verbose:a=!1}=s,l=this.normalizePath(e),h=this.normalizePath(E(l)),c=this.pathExists(l);if(c&&!o)return a&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{await p.promises.mkdir(h,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let f=this._detectFormat(e,i),g;w.isBuffer(t)?g=t:f==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return await te(async()=>(w.isBuffer(g)?await p.promises.writeFile(l,g):await p.promises.writeFile(l,g,"utf8"),a&&v.info(`${c?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,s={}){let{format:i="auto",overwrite:o=!1,dryRun:r=!1,verbose:a=!1}=s,l=this.normalizePath(e),h=this.normalizePath(E(l)),c=this.pathExists(l);if(c&&!o)return a&&v.info(`Skipping existing file: ${l}`),!1;if(r)return v.info(`[DRY RUN] Would write file: ${l}`),!0;try{p.mkdirSync(h,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let f=this._detectFormat(e,i),g;w.isBuffer(t)?g=t:f==="json"&&typeof t=="object"?g=JSON.stringify(t,null,2):g=String(t);try{return w.isBuffer(g)?p.writeFileSync(l,g):p.writeFileSync(l,g,"utf8"),a&&v.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(d){throw new Error(`Failed to write file: ${l}: ${d instanceof Error?d.message:String(d)}`)}}async copy(e,t,s={}){let{overwrite:i=!1,dryRun:o=!1,verbose:r=!1}=s,a=this.normalizePath(t),l=this.pathExists(a);if(l&&!i)return r&&v.info(`Skipping existing file: ${a}`),!1;if(o)return v.info(`[DRY RUN] Would copy file: ${a}`),!0;let h=this.normalizePath(E(a));try{await p.promises.mkdir(h,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return await te(async()=>(await p.promises.copyFile(e,a),r&&v.info(`${l?"Updated":"Created"} file: ${a}`),!0),`Failed to copy file from ${e} to ${a}`)}catch{return!1}}copySync(e,t,s={}){let{overwrite:i=!1,dryRun:o=!1,verbose:r=!1}=s,a=this.normalizePath(t),l=this.pathExists(a);if(l&&!i)return r&&v.info(`Skipping existing file: ${a}`),!1;if(o)return v.info(`[DRY RUN] Would copy file: ${a}`),!0;let h=this.normalizePath(E(a));try{p.mkdirSync(h,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return p.copyFileSync(e,a),r&&v.info(`${l?"Updated":"Created"} file: ${a}`),!0}catch{return!1}}pathExists(e,t=!1){try{return p.existsSync(e)}catch(s){return t||v.error(`Error checking path existence: ${e}`,s),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return p.existsSync(t)||p.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return p.readdirSync(e,t)}catch(s){return this.options.debug&&v.warn(`Failed to read directory: ${e}`,s),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return p.statSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to stat file: ${e}`,t),null}}lstatSync(e){try{return p.lstatSync(e)}catch(t){return this.options.debug&&v.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await p.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{p.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await p.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){p.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return p.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||y.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=S(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(M(e)),s=this.getAppRoot(),i=J(s,t),o=this.normalizePath(i);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,s={}){let i=this.normalizePath(S(e,t)),o=this.getAppRoot(),r=this.normalizePath(o),a=i.startsWith(r)?i.slice(r.length+1):i,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:_.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([a],{...l,...s})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=_.I18N_PATHS;if(!t)return null;let s=e.replace(t.SOURCE_ROOT+"/",""),i=this.resolveFrameworkPackage("@donotdev/core");if(!i)return null;let o=this.normalizePath(S(i,t.PUBLISHED_ROOT,s)),r=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(r),o}async _globWithNormalization(e,t){return(await we(e,t)).map(i=>{let o=typeof i=="string"?i:i.path;return this.normalizePath(o)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let s=[...e.framework,...e.consumer];for(let c of s)if(typeof c!="string"||c.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let i=this.getAppRoot(),o=_.getGlobOptionsFor?_.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},r=this.normalizePath(i),a=e.framework.map(c=>{let f=this.normalizePath(c);return f.startsWith(r)?f.slice(r.length+1):f}),l=e.consumer.map(c=>{let f=this.normalizePath(c);return f.startsWith(r)?f.slice(r.length+1):f}),h={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:i};try{let c=a.length>0?await this._globWithNormalization(a,h):[],f=await this._globWithNormalization(l,h);return{frameworkFiles:c,consumerFiles:f}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!_.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),s=this.getRepoRoot();if(e==="i18n"&&(!t||t===s))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${s}). Ensure configResolved hook has run before discovery.`);let i=_.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=i,h={eager:l.eager.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),lazy:l.lazy.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),framework:{eager:o?(l.framework?.eager||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean)),lazy:o?(l.framework?.lazy||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean))},all:[]};return h.all=[...h.eager,...h.lazy,...h.framework.eager,...h.framework.lazy],h}let r=i,a={framework:o?(r.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(r.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return a.all=[...a.consumer,...a.framework],a}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let t=this.resolvePackage("@donotdev/core/empty");if(t)return t;let s=E(ke(import.meta.url));return this.normalizePath(S(s,"../empty.js"))}_findRepoRoot(e){let t=this.normalizePath(e),s=0,i=this.options.maxLevels;for(;s<i;){let o=this.normalizePath(S(t,re.TOOLING)),r=this.normalizePath(S(t,re.CORE));if(this.pathExists(o)&&this.pathExists(r))return t;let a=S(t,"apps");if(this.pathExists(a)&&this.statSync(a)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(S(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(E(t))===t)return t;let h=this.normalizePath(E(t));if(h===t)break;t=h,s++}return this.normalizePath(e)}};function se(n={}){let{entry:e="src/index.ts",outDir:t="lib",minify:s=!1,sourcemap:i=!0,platform:o="firebase",workspace:r,bundleWorkspaceDeps:a=!1,importFramework:l=!1,external:h=!1,...c}=n,f=B.getInstance(),g=Q(r),d={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:t,outExtension:{".js":".js"},minify:s,sourcemap:i,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...c};a&&Object.keys(g).length>0&&(d.alias=Object.fromEntries(Object.entries(g).map(([b,u])=>[b,f.normalizePath(u)]))),d.mainFields=["module","main"],d.conditions=["import","module","node"];let ce=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],G=[];if(a)try{let b=r?.root||y.cwd(),u=y.cwd(),m=10;for(let x=0;x<m;x++){let H=f.normalizePath(`${u}/package.json`);if(f.pathExists(H)){let $=f.readSync(H,{format:"json"});if($&&Array.isArray($.workspaces)){b=f.normalizePath(u);for(let z of $.workspaces)z==="apps/*"||z==="functions"||!z.includes("*")&&!z.includes("/")&&G.push(z);break}}let L=f.getDirname(u);if(L===u)break;u=L}}catch{}let le={name:"external-node-modules",setup(b){b.onResolve({filter:/^firebase($|\/)/},u=>{if(u.path==="firebase-admin"||u.path.startsWith("firebase-admin/")||u.path==="firebase-functions"||u.path.startsWith("firebase-functions/"))return null;let m;if(r?.type==="dndev"&&r.root)m=f.normalizePath(`${r.root}/packages/core/config/functions/firebase-stub.js`);else{let x=import.meta.url,L=new URL(x).pathname.replace(/^\/([A-Z]:)/i,"$1"),$=f.getDirname(L);m=f.normalizePath(`${$}/firebase-stub.js`)}return{path:m}}),b.onResolve({filter:/.*/},u=>{if(u.kind==="entry-point")return null;if(u.path.match(/@donotdev\/functions\/.+/)&&a&&r?.type==="dndev"){let m=u.path.replace("@donotdev/functions/","");return{path:f.normalizePath(`${r.root}/packages/functions/src/${m}/index.ts`)}}if(u.path==="@donotdev/utils")return r?.type==="dndev"?{path:f.normalizePath(`${r.root}/packages/core/utils/src/server/index.ts`)}:b.resolve("@donotdev/utils/server",{kind:u.kind,resolveDir:u.resolveDir});if(u.path.match(/@donotdev\/utils\/.+/)&&r?.type==="dndev"){let m=u.path.replace("@donotdev/utils/","");return{path:f.normalizePath(`${r.root}/packages/core/utils/src/${m}/index.ts`)}}if(u.path==="@donotdev/schemas")return r?.type==="dndev"?{path:f.normalizePath(`${r.root}/packages/core/schemas/src/server/index.ts`)}:b.resolve("@donotdev/schemas/server",{kind:u.kind,resolveDir:u.resolveDir});if(u.path.match(/@donotdev\/schemas\/.+/)&&r?.type==="dndev"){let m=u.path.replace("@donotdev/schemas/","");return{path:f.normalizePath(`${r.root}/packages/core/schemas/src/${m}/index.ts`)}}if(u.path==="@donotdev/core")return r?.type==="dndev"?{path:f.normalizePath(`${r.root}/packages/core/server.ts`)}:b.resolve("@donotdev/core/server",{kind:u.kind,resolveDir:u.resolveDir});if(u.path.match(/@donotdev\/core\/.+/)&&a&&r?.type==="dndev"){let m=u.path.replace("@donotdev/core/","");return{path:f.normalizePath(`${r.root}/packages/core/${m}.ts`)}}if(u.path==="firebase-admin"||u.path.startsWith("firebase-admin/")||u.path==="firebase-functions"||u.path.startsWith("firebase-functions/"))return{path:u.path,external:!0};if(u.path.match(/@donotdev\/core\/.+/)&&a&&r?.type==="dndev"){let m=u.path.replace("@donotdev/core/","");return{path:f.normalizePath(`${r.root}/packages/core/${m}.ts`)}}if(u.path.startsWith("@donotdev/")||u.path==="valibot"||u.path.startsWith("valibot/"))return null;if(G.length>0){let m=u.path.split("/")[0];if(G.includes(m))return null}return u.path.startsWith(".")||u.path.startsWith("/")?null:{path:u.path,external:!0}})}};if(d.external=[...ce,"firebase-admin","firebase-functions"],d.plugins=[le,...d.plugins||[]],d.define={"process.env.NODE_ENV":JSON.stringify(y.env.NODE_ENV||"production"),...d.define||{}},l&&r.type==="dndev"){let b=r.root,u=f.normalizePath(`${b}/functions/lib`);d.alias={...d.alias,"@donotdev/functions":u}}return o==="framework"&&(d.entryPoints={"firebase/index":"src/firebase/index.ts","vercel/api/index":"src/vercel/api/index.ts","shared/index":"src/shared/index.ts"}),d}P();var oe=["create","get","list","listCard","update","delete"];function ne(n,e=0){let t=" ".repeat(e),s="";for(let[i,o]of Object.entries(n))if(o!=null)if(typeof o=="object"&&!Array.isArray(o))Object.keys(o).length===0?s+=`${t}${i}: {}
2
- `:s+=`${t}${i}:
3
- ${ne(o,e+1)}`;else if(Array.isArray(o))if(o.length===0)s+=`${t}${i}: []
4
- `;else{s+=`${t}${i}:
5
- `;for(let r of o)s+=`${t} - ${r}
6
- `}else s+=`${t}${i}: ${o}
7
- `;return s}function ie(n){let e=n.defaults||{},t=e.labels||{},s={};for(let[o,r]of Object.entries(n.functions||{})){let a={...t,...r.labels};r.category&&(a.category=r.category),s[o]={region:r.region||e.region||["us-central1"],platform:r.platform||e.platform||"gcfv2",entryPoint:r.entryPoint||o,labels:a},r.trigger==="http"?s[o].httpsTrigger={}:s[o].callableTrigger={}}if(n.crud?.entities)for(let o of n.crud.entities)for(let r of oe){let a=`${r}_${o}`;s[a]={region:e.region||["us-central1"],platform:e.platform||"gcfv2",callableTrigger:{},entryPoint:a,labels:{...t,category:"crud"}}}return`# Firebase Functions Configuration
1
+ var Y=(n,e)=>()=>(n&&(e=n(n=0)),e);function V(n,e=null){let t=R[n];if(!t)throw new Error(`Unknown pattern type: ${n}`);return e&&t.framework?{...t,framework:t.framework.map(r=>`${e}/${r}`)}:t}function Z(n){return q[n]||q.base}var U,R,q,K=Y(()=>{"use strict";P();U={SOURCE_ROOT:"packages/core/i18n",SOURCE_LOCALES:"packages/core/i18n/locales",SOURCE_EAGER:"packages/core/i18n/locales/eager",SOURCE_LAZY:"packages/core/i18n/locales/lazy",PUBLISHED_ROOT:"i18n",PUBLISHED_LOCALES:"i18n/locales",PUBLISHED_EAGER:"i18n/locales/eager",PUBLISHED_LAZY:"i18n/locales/lazy"},R={routes:{consumer:["src/**/*Page.tsx","src/pages/**/*Page.tsx"],exclude:["**/node_modules/**","**/dist/**","**/build/**","**/*.test.tsx","**/*.stories.tsx"],extensions:[".tsx"]},css:{consumer:["src/**/*.css"],themes:["src/**/*.css"],extensions:[".css",".scss",".sass"],framework:["packages/ui/src/**/*.css","packages/core/components/src/**/*.css","packages/core/templates/src/**/*.css"]},i18n:{eager:["src/locales/*_*.json"],lazy:["src/**/locales/*_*.json","!src/locales/*_*.json"],framework:{eager:[`${U.SOURCE_EAGER}/*_*.json`],lazy:[`${U.SOURCE_LAZY}/*_*.json`]},extensions:[".json"]},assets:{consumer:["public/**/*"],fallback:["manifest.json"],modern:["logo.svg","favicon.svg","apple-touch-icon.png","android-chrome-192x192.png","android-chrome-512x512.png"],patterns:["favicon.svg","favicon.ico","favicon-*.png","logo.svg","logo.png","logo.webp","logo.avif","apple-touch-icon*.png","android-chrome-*.png","manifest.json"],fonts:["fonts/**/*.woff2","fonts/**/*.woff","fonts/**/*.ttf"],framework:["packages/ui/assets/**/*"]},pwa:{consumer:["public/manifest.json","public/service-worker.js","public/sw.js","public/icon-192x192.png","public/icon-512x512.png","public/favicon.ico","public/favicon.svg","public/apple-touch-icon.png","public/logo.svg"],exclude:["**/node_modules/**","**/dist/**","**/build/**"],extensions:[".json",".js",".png",".svg",".ico"],framework:["packages/ui/assets/**/*"]},globalIgnore:["**/node_modules/**","**/dist/**","**/build/**","**/.git/**","**/coverage/**","**/test/**"]},q={base:{absolute:!0,onlyFiles:!0,ignore:R.globalIgnore},css:{absolute:!0,onlyFiles:!0,ignore:[...R.globalIgnore,"**/*.test.css"]},routes:{absolute:!0,onlyFiles:!0,ignore:[...R.globalIgnore,"**/*.test.tsx","**/*.stories.tsx"]},i18n:{absolute:!0,onlyFiles:!0,ignore:R.globalIgnore},assets:{absolute:!0,onlyFiles:!0,ignore:R.globalIgnore}}});import{Buffer as w}from"node:buffer";import{createRequire as pe}from"node:module";import{dirname as fe,resolve as _e}from"node:path";import y from"node:process";import{fileURLToPath as de}from"node:url";var he,F,A,P=Y(()=>{"use strict";he=pe(import.meta.url),F=de(import.meta.url),A=fe(F);typeof globalThis<"u"&&(globalThis.require=he,globalThis.__filename=F,globalThis.__dirname=A,globalThis.Buffer=w,globalThis.process=y,typeof global>"u"&&(globalThis.global=globalThis))});P();P();P();import W from"node:fs";import b from"node:path";import{fileURLToPath as me}from"node:url";var ge=me(import.meta.url),Ce=b.dirname(ge);function X(){let n=y.cwd(),e=10;for(let t=0;t<e;t++){let r=b.join(n,"package.json");if(W.existsSync(r))try{let o=JSON.parse(W.readFileSync(r,"utf8")),s=o.workspaces&&Array.isArray(o.workspaces);if(s&&o.workspaces.some(c=>c==="packages/**"||c.startsWith("packages/"))&&(W.existsSync(b.join(n,"packages","core"))||W.existsSync(b.join(n,"packages","functions"))))return{type:"dndev",root:n};if(s&&o.workspaces.some(c=>c.includes("dndev/packages"))){let f=o.workspaces.find(d=>d.includes("dndev/packages")).replace(/\/packages.*$/,""),m=b.resolve(n,f);if(W.existsSync(b.join(m,"packages","core")))return{type:"dndev",root:m}}}catch{}let i=b.dirname(n);if(i===n)break;n=i}return{type:"npm",root:y.cwd()}}function ve(n){return n.type==="dndev"?n.root:null}function Q(n){let e={};if(n.type==="dndev"){let t=ve(n);t&&(e["@donotdev/types"]=b.join(t,"packages","core","types","src"),e["@donotdev/functions"]=b.join(t,"packages","functions","src"),e["@donotdev/utils"]=b.join(t,"packages","core","utils","src"),e["@donotdev/schemas"]=b.join(t,"packages","core","schemas","src"),e["@donotdev/core"]=b.join(t,"packages","core"))}return e}P();import{createRequire as ye}from"node:module";import{resolve as B,join as x,dirname as E,relative as J,normalize as Pe,sep as ee,extname as be}from"node:path";import{fileURLToPath as ke}from"node:url";import*as p from"node:fs";K();import we from"fast-glob";var _={getGlobOptionsFor:Z||void 0,SCAN_PATTERNS:R||void 0,getPatternsFor:V||void 0,I18N_PATHS:U||void 0},g={error:(n,e)=>{},warn:(n,e)=>{},info:n=>{}};function te(n,e){return n().catch(t=>{throw new Error(`${e}: ${t instanceof Error?t.message:String(t)}`)})}var re={CLI:"packages/cli",COMPONENTS:"packages/core/components",CONFIG:"packages/core/config",CORE:"packages/core",CRUD:"packages/core/crud",FEATURES:"packages/features",HOOKS:"packages/core/hooks",I18N:"packages/core/i18n",SCHEMAS:"packages/core/schemas",STORES:"packages/core/stores",TEMPLATES:"packages/templates",TOOLING:"packages/tooling",TYPES:"packages/core/types",UI:"packages/ui",UTILS:"packages/core/utils",AUTH:"packages/features/auth",BILLING:"packages/features/billing",OAUTH:"packages/features/oauth",FIREBASE:"packages/providers/firebase",FUNCTIONS:"packages/functions"},M=class n{static _instance=null;options;_repoRoot;_appRoot=null;static getInstance(e={}){return n._instance||(n._instance=new n(e)),n._instance}static _reset(){n._instance=null}constructor(e={}){if(n._instance)return n._instance;this.options={maxLevels:e.maxLevels??10,customMarkers:e.customMarkers||[],cache:e.cache??!1,debug:e.debug??!1};try{let t=y.cwd();if(!t)throw new Error("PathResolver: process.cwd() returned undefined. This should never happen.");this._repoRoot=this._findRepoRoot(t)}catch(t){throw new Error(`PathResolver constructor failed: ${t instanceof Error?t.message:String(t)}. cwd: ${y.cwd()}`)}this._appRoot=null,n._instance=this}normalizePath(e){if(!e)return"";try{return Pe(e).split(ee).join("/")}catch{return String(e).split(ee).join("/")}}getRelativePath(e){let t=this.getAppRoot(),r=J(t,e);return this.normalizePath(r)}getBasename(e){if(!e)return"";let r=this.normalizePath(e).split("/");return r[r.length-1]||""}getDirname(e){return e?this.normalizePath(E(e)):""}resolvePackage(e,t=null){try{let r=t||this.getAppRoot(),o=ye(x(r,"package.json")).resolve(e);return this.normalizePath(o)}catch{return null}}resolveFrameworkPackage(e,t=null){let r=this.resolvePackage(`${e}/package.json`,t);if(r)return this.getDirname(r);if(this.isMonorepo()&&e.startsWith("@donotdev/")){let s=e.replace("@donotdev/",""),a=this.resolveRepoPath(`packages/${s}`);if(this.pathExists(a))return a;if(["auth","billing","crud","oauth"].includes(s)){let l=this.resolveRepoPath(`packages/features/${s}`);if(this.pathExists(l))return l}if(s==="firebase"){let l=this.resolveRepoPath(`packages/providers/${s}`);if(this.pathExists(l))return l}}let i=this.resolveAppPath(`node_modules/${e}`);if(this.pathExists(i))return i;let o=this.resolveRepoPath(`node_modules/${e}`);return this.pathExists(o)?o:null}resolvePackageAsset(e,t=null){return this.resolvePackage(e,t)}resolveAppPath(e){let t=this.getAppRoot(),r=B(t,e);return this.normalizePath(r)}resolveRepoPath(e){let t=this.getRepoRoot(),r=this.normalizePath(e),i=B(t,r);return this.normalizePath(i)}resolvePath(e,t){let r=this.normalizePath(t),i=this.normalizePath(e),o=B(r,i);return this.normalizePath(o)}createImportPath(e){return"./"+this.getRelativePath(e)}getFileInfo(e){try{let t=p.statSync(e);return{absolutePath:this.normalizePath(e),relativePath:this.getRelativePath(e),importPath:this.createImportPath(e),size:t.size,isFile:t.isFile(),isDirectory:t.isDirectory()}}catch{return null}}_detectFormat(e,t){return t&&t!=="auto"?t:be(e).toLowerCase()===".json"?"json":"text"}async read(e,t={}){let{format:r="auto",encoding:i="utf8"}=t,o=this._detectFormat(e,r);try{if(o==="buffer")return await p.promises.readFile(e);let s=await p.promises.readFile(e,i),a=this.stripBom(s);return o==="json"?JSON.parse(a):a}catch(s){return this.options.debug&&g.warn(`Failed to read file: ${e}`,s),null}}readSync(e,t={}){let{format:r="auto",encoding:i="utf8"}=t,o=this._detectFormat(e,r);try{if(o==="buffer")return p.readFileSync(e);let s=p.readFileSync(e,i),a=this.stripBom(s);return o==="json"?JSON.parse(a):a}catch(s){return this.options.debug&&g.warn(`Failed to read file: ${e}`,s),null}}async write(e,t,r={}){let{format:i="auto",overwrite:o=!1,dryRun:s=!1,verbose:a=!1}=r,l=this.normalizePath(e),h=this.normalizePath(E(l)),c=this.pathExists(l);if(c&&!o)return a&&g.info(`Skipping existing file: ${l}`),!1;if(s)return g.info(`[DRY RUN] Would write file: ${l}`),!0;try{await p.promises.mkdir(h,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let f=this._detectFormat(e,i),m;w.isBuffer(t)?m=t:f==="json"&&typeof t=="object"?m=JSON.stringify(t,null,2):m=String(t);try{return await te(async()=>(w.isBuffer(m)?await p.promises.writeFile(l,m):await p.promises.writeFile(l,m,"utf8"),a&&g.info(`${c?"Updated":"Created"} file: ${l}`),!0),`Failed to write file: ${l}`)}catch{return!1}}writeSync(e,t,r={}){let{format:i="auto",overwrite:o=!1,dryRun:s=!1,verbose:a=!1}=r,l=this.normalizePath(e),h=this.normalizePath(E(l)),c=this.pathExists(l);if(c&&!o)return a&&g.info(`Skipping existing file: ${l}`),!1;if(s)return g.info(`[DRY RUN] Would write file: ${l}`),!0;try{p.mkdirSync(h,{recursive:!0})}catch(d){if(d?.code!=="EEXIST")throw d}let f=this._detectFormat(e,i),m;w.isBuffer(t)?m=t:f==="json"&&typeof t=="object"?m=JSON.stringify(t,null,2):m=String(t);try{return w.isBuffer(m)?p.writeFileSync(l,m):p.writeFileSync(l,m,"utf8"),a&&g.info(`${c?"Updated":"Created"} file: ${l}`),!0}catch(d){throw new Error(`Failed to write file: ${l}: ${d instanceof Error?d.message:String(d)}`)}}async copy(e,t,r={}){let{overwrite:i=!1,dryRun:o=!1,verbose:s=!1}=r,a=this.normalizePath(t),l=this.pathExists(a);if(l&&!i)return s&&g.info(`Skipping existing file: ${a}`),!1;if(o)return g.info(`[DRY RUN] Would copy file: ${a}`),!0;let h=this.normalizePath(E(a));try{await p.promises.mkdir(h,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return await te(async()=>(await p.promises.copyFile(e,a),s&&g.info(`${l?"Updated":"Created"} file: ${a}`),!0),`Failed to copy file from ${e} to ${a}`)}catch{return!1}}copySync(e,t,r={}){let{overwrite:i=!1,dryRun:o=!1,verbose:s=!1}=r,a=this.normalizePath(t),l=this.pathExists(a);if(l&&!i)return s&&g.info(`Skipping existing file: ${a}`),!1;if(o)return g.info(`[DRY RUN] Would copy file: ${a}`),!0;let h=this.normalizePath(E(a));try{p.mkdirSync(h,{recursive:!0})}catch(c){if(c?.code!=="EEXIST")throw c}try{return p.copyFileSync(e,a),s&&g.info(`${l?"Updated":"Created"} file: ${a}`),!0}catch{return!1}}pathExists(e,t=!1){try{return p.existsSync(e)}catch(r){return t||g.error(`Error checking path existence: ${e}`,r),!1}}mkdir(e){try{let t=e.startsWith("/")||e.match(/^[A-Z]:/)?this.normalizePath(e):this.resolveAppPath(e);return p.existsSync(t)||p.mkdirSync(t,{recursive:!0}),!0}catch{return!1}}readdirSync(e,t){try{return p.readdirSync(e,t)}catch(r){return this.options.debug&&g.warn(`Failed to read directory: ${e}`,r),t&&typeof t=="object"&&"withFileTypes"in t&&t.withFileTypes?[]:[]}}statSync(e){try{return p.statSync(e)}catch(t){return this.options.debug&&g.warn(`Failed to stat file: ${e}`,t),null}}lstatSync(e){try{return p.lstatSync(e)}catch(t){return this.options.debug&&g.warn(`Failed to lstat file: ${e}`,t),null}}async ensureDir(e){try{await p.promises.mkdir(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}ensureDirSync(e){try{p.mkdirSync(e,{recursive:!0})}catch(t){if(t?.code!=="EEXIST")throw t}}async remove(e){await p.promises.rm(e,{recursive:!0,force:!0})}removeSync(e){p.rmSync(e,{recursive:!0,force:!0})}async readdir(e,t){return p.promises.readdir(e,t)}stripBom(e){return e.charCodeAt(0)===65279?e.slice(1):e}getRepoRoot(){return this._repoRoot||y.cwd()}getAppRoot(){return this._appRoot?this._appRoot:this._repoRoot}setAppRoot(e){if(!e)throw new Error("PathResolver.setAppRoot: root cannot be undefined or null");this._appRoot=this.normalizePath(e)}isMonorepo(){let e=x(this._repoRoot,"packages");return this.pathExists(e)}isWithinApp(e){let t=this.normalizePath(B(e)),r=this.getAppRoot(),i=J(r,t),o=this.normalizePath(i);return!o.startsWith("../")&&!o.startsWith("/")}async findFiles(e,t,r={}){let i=this.normalizePath(x(e,t)),o=this.getAppRoot(),s=this.normalizePath(o),a=i.startsWith(s)?i.slice(s.length+1):i,l={absolute:!0,onlyFiles:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:o,ignore:_.SCAN_PATTERNS?.globalIgnore||["**/node_modules/**","**/dist/**","**/build/**","**/.git/**"]};return await this._globWithNormalization([a],{...l,...r})}clearCache(){}async _resolveFrameworkI18nPattern(e){let t=_.I18N_PATHS;if(!t)return null;let r=e.replace(t.SOURCE_ROOT+"/",""),i=this.resolveFrameworkPackage("@donotdev/core");if(!i)return null;let o=this.normalizePath(x(i,t.PUBLISHED_ROOT,r)),s=o.replace(/\/[^/]*\*.*$/,"");return this.pathExists(s),o}async _globWithNormalization(e,t){return(await we(e,t)).map(i=>{let o=typeof i=="string"?i:i.path;return this.normalizePath(o)})}async resolveFiles(e,t="css"){if(!e||typeof e!="object")return{frameworkFiles:[],consumerFiles:[]};if(t==="i18n")return{frameworkFiles:[],consumerFiles:[]};if(Array.isArray(e.framework)||(e.framework=[]),!Array.isArray(e.consumer))return{frameworkFiles:[],consumerFiles:[]};let r=[...e.framework,...e.consumer];for(let c of r)if(typeof c!="string"||c.trim()==="")return{frameworkFiles:[],consumerFiles:[]};let i=this.getAppRoot(),o=_.getGlobOptionsFor?_.getGlobOptionsFor(t):{ignore:["**/node_modules/**","**/dist/**","**/build/**"]},s=this.normalizePath(i),a=e.framework.map(c=>{let f=this.normalizePath(c);return f.startsWith(s)?f.slice(s.length+1):f}),l=e.consumer.map(c=>{let f=this.normalizePath(c);return f.startsWith(s)?f.slice(s.length+1):f}),h={...o,onlyFiles:!0,absolute:!0,braceExpansion:!0,extglob:!0,globstar:!0,cwd:i};try{let c=a.length>0?await this._globWithNormalization(a,h):[],f=await this._globWithNormalization(l,h);return{frameworkFiles:c,consumerFiles:f}}catch{return this.options.debug,{frameworkFiles:[],consumerFiles:[]}}}async resolvePatterns(e){if(!_.getPatternsFor)return{framework:[],consumer:[],all:[]};let t=this.getAppRoot(),r=this.getRepoRoot();if(e==="i18n"&&(!t||t===r))throw new Error(`Cannot resolve i18n patterns: appRoot not set (appRoot: ${t}, repoRoot: ${r}). Ensure configResolved hook has run before discovery.`);let i=_.getPatternsFor(e),o=this.isMonorepo();if(e==="i18n"){let l=i,h={eager:l.eager.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),lazy:l.lazy.map(c=>c.startsWith("!")?"!"+this.resolveAppPath(c.slice(1)):this.resolveAppPath(c)),framework:{eager:o?(l.framework?.eager||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.eager||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean)),lazy:o?(l.framework?.lazy||[]).map(c=>this.resolveRepoPath(c)).filter(Boolean):await Promise.all((l.framework?.lazy||[]).map(c=>this._resolveFrameworkI18nPattern(c))).then(c=>c.filter(Boolean))},all:[]};return h.all=[...h.eager,...h.lazy,...h.framework.eager,...h.framework.lazy],h}let s=i,a={framework:o?(s.framework||[]).map(l=>this.resolveRepoPath(l)).filter(Boolean):[],consumer:(s.consumer||[]).map(l=>this.resolveAppPath(l)),all:[]};return a.all=[...a.consumer,...a.framework],a}getEmptyModulePath(e=!1){if(e)return"@donotdev/core/empty";let t=this.resolvePackage("@donotdev/core/empty");if(t)return t;let r=E(ke(import.meta.url));return this.normalizePath(x(r,"../empty.js"))}_findRepoRoot(e){let t=this.normalizePath(e),r=0,i=this.options.maxLevels;for(;r<i;){let o=this.normalizePath(x(t,re.TOOLING)),s=this.normalizePath(x(t,re.CORE));if(this.pathExists(o)&&this.pathExists(s))return t;let a=x(t,"apps");if(this.pathExists(a)&&this.statSync(a)?.isDirectory())return this.normalizePath(t);let l=this.normalizePath(x(t,"package.json"));if(this.pathExists(l)&&this.normalizePath(E(t))===t)return t;let h=this.normalizePath(E(t));if(h===t)break;t=h,r++}return this.normalizePath(e)}};function se(n={}){let{entry:e="src/index.ts",outDir:t="lib",minify:r=!1,sourcemap:i=!0,platform:o="firebase",workspace:s,bundleWorkspaceDeps:a=!1,importFramework:l=!1,external:h=!1,...c}=n,f=M.getInstance(),m=Q(s),d={entryPoints:[e],bundle:!0,platform:"node",target:"node20",format:"esm",outdir:t,outExtension:{".js":".js"},minify:r,sourcemap:i,metafile:!0,logLevel:"info",loader:{".ts":"ts",".tsx":"tsx",".css":"empty"},keepNames:!0,treeShaking:!0,...c};a&&Object.keys(m).length>0&&(d.alias=Object.fromEntries(Object.entries(m).map(([k,u])=>[k,f.normalizePath(u)]))),d.mainFields=["module","main"],d.conditions=["import","module","node"];let ce=["fs","path","crypto","util","stream","events","buffer","url","querystring","http","https","zlib","os","child_process","assert","constants","domain","punycode","string_decoder","timers","tty","vm","worker_threads","perf_hooks","async_hooks"],G=[];if(a)try{let k=s?.root||y.cwd(),u=y.cwd(),v=10;for(let S=0;S<v;S++){let H=f.normalizePath(`${u}/package.json`);if(f.pathExists(H)){let z=f.readSync(H,{format:"json"});if(z&&Array.isArray(z.workspaces)){k=f.normalizePath(u);for(let $ of z.workspaces)$==="apps/*"||$==="functions"||!$.includes("*")&&!$.includes("/")&&G.push($);break}}let L=f.getDirname(u);if(L===u)break;u=L}}catch{}let le={name:"external-node-modules",setup(k){k.onResolve({filter:/^firebase($|\/)/},u=>{if(u.path==="firebase-admin"||u.path.startsWith("firebase-admin/")||u.path==="firebase-functions"||u.path.startsWith("firebase-functions/"))return null;let v;if(s?.type==="dndev"&&s.root)v=f.normalizePath(`${s.root}/packages/core/config/functions/firebase-stub.js`);else{let S=import.meta.url,L=new URL(S).pathname.replace(/^\/([A-Z]:)/i,"$1"),z=f.getDirname(L);v=f.normalizePath(`${z}/firebase-stub.js`)}return{path:v}}),k.onResolve({filter:/.*/},u=>{if(u.kind==="entry-point")return null;if(u.path.match(/@donotdev\/functions\/.+/)&&a&&s?.type==="dndev"){let v=u.path.replace("@donotdev/functions/","");return{path:f.normalizePath(`${s.root}/packages/functions/src/${v}/index.ts`)}}if(u.path==="@donotdev/utils")return s?.type==="dndev"?{path:f.normalizePath(`${s.root}/packages/core/utils/src/server/index.ts`)}:k.resolve("@donotdev/utils/server",{kind:u.kind,resolveDir:u.resolveDir});if(u.path.match(/@donotdev\/utils\/.+/)&&s?.type==="dndev"){let v=u.path.replace("@donotdev/utils/","");return{path:f.normalizePath(`${s.root}/packages/core/utils/src/${v}/index.ts`)}}if(u.path==="@donotdev/core")return s?.type==="dndev"?{path:f.normalizePath(`${s.root}/packages/core/server.ts`)}:k.resolve("@donotdev/core/server",{kind:u.kind,resolveDir:u.resolveDir});if(u.path.match(/@donotdev\/core\/.+/)&&a&&s?.type==="dndev"){let v=u.path.replace("@donotdev/core/","");return{path:f.normalizePath(`${s.root}/packages/core/${v}.ts`)}}if(u.path==="firebase-admin"||u.path.startsWith("firebase-admin/")||u.path==="firebase-functions"||u.path.startsWith("firebase-functions/"))return{path:u.path,external:!0};if(u.path.match(/@donotdev\/core\/.+/)&&a&&s?.type==="dndev"){let v=u.path.replace("@donotdev/core/","");return{path:f.normalizePath(`${s.root}/packages/core/${v}.ts`)}}if(u.path.startsWith("@donotdev/")||u.path==="valibot"||u.path.startsWith("valibot/"))return null;if(G.length>0){let v=u.path.split("/")[0];if(G.includes(v))return null}return u.path.startsWith(".")||u.path.startsWith("/")?null:{path:u.path,external:!0}})}};if(d.external=[...ce,"firebase-admin","firebase-functions"],d.plugins=[le,...d.plugins||[]],d.define={"process.env.NODE_ENV":JSON.stringify(y.env.NODE_ENV||"production"),...d.define||{}},l&&s.type==="dndev"){let k=s.root,u=f.normalizePath(`${k}/functions/lib`);d.alias={...d.alias,"@donotdev/functions":u}}return o==="framework"&&(d.entryPoints={"firebase/index":"src/firebase/index.ts","vercel/api/index":"src/vercel/api/index.ts","shared/index":"src/shared/index.ts"}),d}P();var oe=["create","get","list","listCard","update","delete"];function ne(n,e=0){let t=" ".repeat(e),r="";for(let[i,o]of Object.entries(n))if(o!=null)if(typeof o=="object"&&!Array.isArray(o))Object.keys(o).length===0?r+=`${t}${i}: {}
2
+ `:r+=`${t}${i}:
3
+ ${ne(o,e+1)}`;else if(Array.isArray(o))if(o.length===0)r+=`${t}${i}: []
4
+ `;else{r+=`${t}${i}:
5
+ `;for(let s of o)r+=`${t} - ${s}
6
+ `}else r+=`${t}${i}: ${o}
7
+ `;return r}function ie(n){let e=n.defaults||{},t=e.labels||{},r={};for(let[o,s]of Object.entries(n.functions||{})){let a={...t,...s.labels};s.category&&(a.category=s.category),r[o]={region:s.region||e.region||["us-central1"],platform:s.platform||e.platform||"gcfv2",entryPoint:s.entryPoint||o,labels:a},s.trigger==="http"?r[o].httpsTrigger={}:r[o].callableTrigger={}}if(n.crud?.entities)for(let o of n.crud.entities)for(let s of oe){let a=`${s}_${o}`;r[a]={region:e.region||["us-central1"],platform:e.platform||"gcfv2",callableTrigger:{},entryPoint:a,labels:{...t,category:"crud"}}}return`# Firebase Functions Configuration
8
8
  # Generated by @donotdev/core/functions - DO NOT EDIT MANUALLY
9
9
  # Generated at: ${new Date().toISOString()}
10
10
 
11
- `+ne({endpoints:s,specVersion:"v1alpha1",requiredAPIs:[]})}function xe(n){let e=Object.keys(n.functions||{}),t=[];if(n.crud?.entities)for(let s of n.crud.entities)for(let i of oe)t.push(`${i}_${s}`);return{yaml:ie(n),functions:[...e,...t],staticFunctions:e,crudFunctions:t}}function ae(n={}){let{entry:e="src/index.ts",outDir:t="lib",minify:s=!1,sourcemap:i=!0,platform:o="firebase",...r}=n,a=X();return se({entry:e,outDir:t,minify:s,sourcemap:i,platform:o,workspace:a,...r})}function et(n={}){return ae({...n,platform:"framework",bundleWorkspaceDeps:!0})}function tt(n={}){return ae({...n,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0})}export{tt as createAppFunctionsConfig,ae as createFunctionsEsbuildConfig,et as createRootFunctionsConfig,ie as generateFunctionsYaml,xe as generateFunctionsYamlWithInfo};
11
+ `+ne({endpoints:r,specVersion:"v1alpha1",requiredAPIs:[]})}function xe(n){let e=Object.keys(n.functions||{}),t=[];if(n.crud?.entities)for(let r of n.crud.entities)for(let i of oe)t.push(`${i}_${r}`);return{yaml:ie(n),functions:[...e,...t],staticFunctions:e,crudFunctions:t}}function ae(n={}){let{entry:e="src/index.ts",outDir:t="lib",minify:r=!1,sourcemap:i=!0,platform:o="firebase",...s}=n,a=X();return se({entry:e,outDir:t,minify:r,sourcemap:i,platform:o,workspace:a,...s})}function et(n={}){return ae({...n,platform:"framework",bundleWorkspaceDeps:!0})}function tt(n={}){return ae({...n,platform:"firebase",bundleWorkspaceDeps:!0,importFramework:!0})}export{tt as createAppFunctionsConfig,ae as createFunctionsEsbuildConfig,et as createRootFunctionsConfig,ie as generateFunctionsYaml,xe as generateFunctionsYamlWithInfo};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/core",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE.md",
@@ -57,7 +57,7 @@
57
57
  ],
58
58
  "sideEffects": false,
59
59
  "peerDependencies": {
60
- "@donotdev/components": "^0.0.12",
60
+ "@donotdev/components": "^0.0.13",
61
61
  "@sentry/react": "^10.33.0",
62
62
  "lucide-react": "^0.562.0",
63
63
  "react": "^19.2.3",