@kyro-cms/core 0.12.34 → 0.12.36

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 +1 @@
1
- 'use strict';var chunkTMKROUQA_cjs=require('./chunk-TMKROUQA.cjs');require('./chunk-4KFXG5ZB.cjs'),require('./chunk-4XZABBHF.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-ZUVP4UK7.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-2YRM7CZZ.cjs'),require('./chunk-5K4YG5DA.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-ILEZ3NYX.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-FUWPXR6W.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-3Q2WUG63.cjs'),require('./chunk-QCA3AP3M.cjs'),require('./chunk-FHJJKFAU.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-G7SSHELM.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');function n(e){return new Response(e.body,e)}var p={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};function r(){return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}async function o(){try{return (await chunkTMKROUQA_cjs.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.graphqlEnabled??p.graphqlEnabled}catch{return true}}var l=async e=>{if(await chunkTMKROUQA_cjs.b(),!await o())return r();let t=await chunkTMKROUQA_cjs.a.getGraphQL().fetch(e.request,e.locals);return n(t)},u=async e=>{if(await chunkTMKROUQA_cjs.b(),!await o())return r();let t=await chunkTMKROUQA_cjs.a.getGraphQL().fetch(e.request,e.locals);return n(t)};exports.GET=u;exports.POST=l;
1
+ 'use strict';var chunkKKIBNWRL_cjs=require('./chunk-KKIBNWRL.cjs');require('./chunk-4KFXG5ZB.cjs'),require('./chunk-QBJT7XLN.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-ZUVP4UK7.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-2YRM7CZZ.cjs'),require('./chunk-5K4YG5DA.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-ILEZ3NYX.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-FUWPXR6W.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-3Q2WUG63.cjs'),require('./chunk-QCA3AP3M.cjs'),require('./chunk-FHJJKFAU.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-G7SSHELM.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');function n(e){return new Response(e.body,e)}var p={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};function r(){return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}async function o(){try{return (await chunkKKIBNWRL_cjs.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.graphqlEnabled??p.graphqlEnabled}catch{return true}}var l=async e=>{if(await chunkKKIBNWRL_cjs.b(),!await o())return r();let t=await chunkKKIBNWRL_cjs.a.getGraphQL().fetch(e.request,e.locals);return n(t)},u=async e=>{if(await chunkKKIBNWRL_cjs.b(),!await o())return r();let t=await chunkKKIBNWRL_cjs.a.getGraphQL().fetch(e.request,e.locals);return n(t)};exports.GET=u;exports.POST=l;
@@ -1 +1 @@
1
- import {b,a}from'./chunk-7R5IPQ5F.js';import'./chunk-DZMIMB5W.js';import'./chunk-6MSPBK3W.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-LHW4R367.js';import'./chunk-PP7W5UKL.js';import'./chunk-4DJYAD4L.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-FVZ5RFLO.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-5KSRMBEO.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-VGQ4VUG6.js';import'./chunk-6ROHVUXF.js';import'./chunk-5KOQYQEE.js';import'./chunk-6SPPR5JZ.js';import'./chunk-4RMFCTWH.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';function n(e){return new Response(e.body,e)}var p={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};function r(){return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}async function o(){try{return (await a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.graphqlEnabled??p.graphqlEnabled}catch{return true}}var l=async e=>{if(await b(),!await o())return r();let t=await a.getGraphQL().fetch(e.request,e.locals);return n(t)},u=async e=>{if(await b(),!await o())return r();let t=await a.getGraphQL().fetch(e.request,e.locals);return n(t)};export{u as GET,l as POST};
1
+ import {b,a}from'./chunk-LCXPMPBU.js';import'./chunk-DZMIMB5W.js';import'./chunk-7MBZYLME.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-LHW4R367.js';import'./chunk-PP7W5UKL.js';import'./chunk-4DJYAD4L.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-FVZ5RFLO.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-5KSRMBEO.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-VGQ4VUG6.js';import'./chunk-6ROHVUXF.js';import'./chunk-5KOQYQEE.js';import'./chunk-6SPPR5JZ.js';import'./chunk-4RMFCTWH.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';function n(e){return new Response(e.body,e)}var p={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};function r(){return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}async function o(){try{return (await a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.graphqlEnabled??p.graphqlEnabled}catch{return true}}var l=async e=>{if(await b(),!await o())return r();let t=await a.getGraphQL().fetch(e.request,e.locals);return n(t)},u=async e=>{if(await b(),!await o())return r();let t=await a.getGraphQL().fetch(e.request,e.locals);return n(t)};export{u as GET,l as POST};
@@ -1 +1 @@
1
- 'use strict';var chunkTMKROUQA_cjs=require('./chunk-TMKROUQA.cjs');require('./chunk-4KFXG5ZB.cjs'),require('./chunk-4XZABBHF.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-ZUVP4UK7.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-2YRM7CZZ.cjs'),require('./chunk-5K4YG5DA.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-ILEZ3NYX.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-FUWPXR6W.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-3Q2WUG63.cjs'),require('./chunk-QCA3AP3M.cjs'),require('./chunk-FHJJKFAU.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-G7SSHELM.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');function n(){return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}var r={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function s(){try{return (await chunkTMKROUQA_cjs.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.trpcEnabled??r.trpcEnabled}catch{return true}}var i=async e=>(await chunkTMKROUQA_cjs.b(),await s()?chunkTMKROUQA_cjs.a.getTRPC().fetch(e.request,e.locals):n());exports.ALL=i;
1
+ 'use strict';var chunkKKIBNWRL_cjs=require('./chunk-KKIBNWRL.cjs');require('./chunk-4KFXG5ZB.cjs'),require('./chunk-QBJT7XLN.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-ZUVP4UK7.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-2YRM7CZZ.cjs'),require('./chunk-5K4YG5DA.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-ILEZ3NYX.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-FUWPXR6W.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-3Q2WUG63.cjs'),require('./chunk-QCA3AP3M.cjs'),require('./chunk-FHJJKFAU.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-G7SSHELM.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');function n(){return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}var r={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function s(){try{return (await chunkKKIBNWRL_cjs.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.trpcEnabled??r.trpcEnabled}catch{return true}}var i=async e=>(await chunkKKIBNWRL_cjs.b(),await s()?chunkKKIBNWRL_cjs.a.getTRPC().fetch(e.request,e.locals):n());exports.ALL=i;
@@ -1 +1 @@
1
- import {b,a}from'./chunk-7R5IPQ5F.js';import'./chunk-DZMIMB5W.js';import'./chunk-6MSPBK3W.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-LHW4R367.js';import'./chunk-PP7W5UKL.js';import'./chunk-4DJYAD4L.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-FVZ5RFLO.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-5KSRMBEO.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-VGQ4VUG6.js';import'./chunk-6ROHVUXF.js';import'./chunk-5KOQYQEE.js';import'./chunk-6SPPR5JZ.js';import'./chunk-4RMFCTWH.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';function n(){return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}var r={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function s(){try{return (await a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.trpcEnabled??r.trpcEnabled}catch{return true}}var i=async e=>(await b(),await s()?a.getTRPC().fetch(e.request,e.locals):n());export{i as ALL};
1
+ import {b,a}from'./chunk-LCXPMPBU.js';import'./chunk-DZMIMB5W.js';import'./chunk-7MBZYLME.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-LHW4R367.js';import'./chunk-PP7W5UKL.js';import'./chunk-4DJYAD4L.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-FVZ5RFLO.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-5KSRMBEO.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-VGQ4VUG6.js';import'./chunk-6ROHVUXF.js';import'./chunk-5KOQYQEE.js';import'./chunk-6SPPR5JZ.js';import'./chunk-4RMFCTWH.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';function n(){return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}})}var r={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function s(){try{return (await a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.trpcEnabled??r.trpcEnabled}catch{return true}}var i=async e=>(await b(),await s()?a.getTRPC().fetch(e.request,e.locals):n());export{i as ALL};
@@ -1 +1 @@
1
- 'use strict';var chunkTMKROUQA_cjs=require('./chunk-TMKROUQA.cjs');require('./chunk-4KFXG5ZB.cjs'),require('./chunk-4XZABBHF.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-ZUVP4UK7.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-2YRM7CZZ.cjs'),require('./chunk-5K4YG5DA.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-ILEZ3NYX.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-FUWPXR6W.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-3Q2WUG63.cjs'),require('./chunk-QCA3AP3M.cjs'),require('./chunk-FHJJKFAU.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-G7SSHELM.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');Object.defineProperty(exports,"ALL",{enumerable:true,get:function(){return chunkTMKROUQA_cjs.c}});Object.defineProperty(exports,"kyroInstance",{enumerable:true,get:function(){return chunkTMKROUQA_cjs.a}});Object.defineProperty(exports,"warmKyroInstance",{enumerable:true,get:function(){return chunkTMKROUQA_cjs.b}});
1
+ 'use strict';var chunkKKIBNWRL_cjs=require('./chunk-KKIBNWRL.cjs');require('./chunk-4KFXG5ZB.cjs'),require('./chunk-QBJT7XLN.cjs'),require('./chunk-65G73T7Z.cjs'),require('./chunk-KD7LUCFY.cjs'),require('./chunk-ZUVP4UK7.cjs'),require('./chunk-HS2KNFAB.cjs'),require('./chunk-2YRM7CZZ.cjs'),require('./chunk-5K4YG5DA.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-GO34AOBZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-HVXO3OFB.cjs'),require('./chunk-ILEZ3NYX.cjs'),require('./chunk-NY47CFVP.cjs'),require('./chunk-G3J2EU5D.cjs'),require('./chunk-4ORJMSJU.cjs'),require('./chunk-FUWPXR6W.cjs'),require('./chunk-GYQMNXXW.cjs'),require('./chunk-MIOMMB23.cjs'),require('./chunk-3Q2WUG63.cjs'),require('./chunk-QCA3AP3M.cjs'),require('./chunk-FHJJKFAU.cjs'),require('./chunk-D5P2IPGX.cjs'),require('./chunk-G7SSHELM.cjs'),require('./chunk-Q3Q7BJVQ.cjs'),require('./chunk-AHSFSERC.cjs');Object.defineProperty(exports,"ALL",{enumerable:true,get:function(){return chunkKKIBNWRL_cjs.c}});Object.defineProperty(exports,"kyroInstance",{enumerable:true,get:function(){return chunkKKIBNWRL_cjs.a}});Object.defineProperty(exports,"warmKyroInstance",{enumerable:true,get:function(){return chunkKKIBNWRL_cjs.b}});
@@ -1 +1 @@
1
- export{c as ALL,a as kyroInstance,b as warmKyroInstance}from'./chunk-7R5IPQ5F.js';import'./chunk-DZMIMB5W.js';import'./chunk-6MSPBK3W.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-LHW4R367.js';import'./chunk-PP7W5UKL.js';import'./chunk-4DJYAD4L.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-FVZ5RFLO.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-5KSRMBEO.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-VGQ4VUG6.js';import'./chunk-6ROHVUXF.js';import'./chunk-5KOQYQEE.js';import'./chunk-6SPPR5JZ.js';import'./chunk-4RMFCTWH.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';
1
+ export{c as ALL,a as kyroInstance,b as warmKyroInstance}from'./chunk-LCXPMPBU.js';import'./chunk-DZMIMB5W.js';import'./chunk-7MBZYLME.js';import'./chunk-NZ35PV5R.js';import'./chunk-5SEHX7ON.js';import'./chunk-LHW4R367.js';import'./chunk-PP7W5UKL.js';import'./chunk-4DJYAD4L.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IETGL7WJ.js';import'./chunk-IKOXCJYO.js';import'./chunk-NRLIGDYF.js';import'./chunk-FVZ5RFLO.js';import'./chunk-HLSB2MCK.js';import'./chunk-GKYEJ2UF.js';import'./chunk-PP5S2UBV.js';import'./chunk-5KSRMBEO.js';import'./chunk-RHCWCG3O.js';import'./chunk-OG7CNQGU.js';import'./chunk-VGQ4VUG6.js';import'./chunk-6ROHVUXF.js';import'./chunk-5KOQYQEE.js';import'./chunk-6SPPR5JZ.js';import'./chunk-4RMFCTWH.js';import'./chunk-KDNYHLD2.js';import'./chunk-5J6HXUF6.js';
@@ -0,0 +1 @@
1
+ 'use strict';var chunkQBJT7XLN_cjs=require('./chunk-QBJT7XLN.cjs');require('./chunk-5K4YG5DA.cjs'),require('./chunk-WIZ6C5QZ.cjs'),require('./chunk-HOP4D5XZ.cjs'),require('./chunk-AHSFSERC.cjs');Object.defineProperty(exports,"autoBootstrap",{enumerable:true,get:function(){return chunkQBJT7XLN_cjs.d}});Object.defineProperty(exports,"bootstrapAdmin",{enumerable:true,get:function(){return chunkQBJT7XLN_cjs.a}});Object.defineProperty(exports,"bootstrapWithRetry",{enumerable:true,get:function(){return chunkQBJT7XLN_cjs.e}});Object.defineProperty(exports,"checkBootstrapRequired",{enumerable:true,get:function(){return chunkQBJT7XLN_cjs.b}});Object.defineProperty(exports,"getBootstrapFromEnv",{enumerable:true,get:function(){return chunkQBJT7XLN_cjs.c}});
@@ -1 +1 @@
1
- export{d as autoBootstrap,a as bootstrapAdmin,e as bootstrapWithRetry,b as checkBootstrapRequired,c as getBootstrapFromEnv}from'./chunk-6MSPBK3W.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IKOXCJYO.js';import'./chunk-5J6HXUF6.js';
1
+ export{d as autoBootstrap,a as bootstrapAdmin,e as bootstrapWithRetry,b as checkBootstrapRequired,c as getBootstrapFromEnv}from'./chunk-7MBZYLME.js';import'./chunk-6J27P5D6.js';import'./chunk-K6WUOU6P.js';import'./chunk-IKOXCJYO.js';import'./chunk-5J6HXUF6.js';
@@ -0,0 +1 @@
1
+ import {l,k}from'./chunk-6J27P5D6.js';import {a}from'./chunk-IKOXCJYO.js';async function f(r){let{adminEmail:e,adminPassword:t,adminRole:o="super_admin",tenantId:i,emailConfig:a$1,sendWelcomeEmail:c=false}=r,s=r.authAdapter||new a({path:r.authDbPath||"./data/auth.db"});try{await s.connect?.();}catch{return {success:false,error:"Failed to connect to auth storage"}}let l$1=new l().validate(t);if(!l$1.valid)return await s.disconnect?.(),{success:false,error:`Invalid password: ${l$1.errors.join(", ")}`};if(await s.findUserByEmail(e))return await s.disconnect?.(),{success:false,error:"Admin user already exists"};try{let n=await s.createUser({name:"Super Admin",email:e,password:t,role:o||"admin",tenantId:i});if(await s.updateUser?.(n.id,{emailVerified:!0}),c&&a$1){let u=new k(a$1),A=u.getTemplates().welcome(e.split("@")[0]);await u.send({to:e,...A});}return await s.disconnect?.(),{success:!0,user:n}}catch(n){return await s.disconnect?.(),{success:false,error:n instanceof Error?n.message:"Failed to create admin user"}}}async function y(r,e){return !await r.findUserByEmail(e)}function w(){let r=process.env.KYRO_ADMIN_EMAIL,e=process.env.KYRO_ADMIN_PASSWORD;return !r||!e?null:{authDbPath:process.env.KYRO_AUTH_DB_PATH||"./data/auth.db",adminEmail:r,adminPassword:e,adminRole:process.env.KYRO_ADMIN_ROLE||"super_admin",tenantId:process.env.KYRO_ADMIN_TENANT_ID,emailConfig:process.env.SMTP_HOST?{provider:"smtp",smtp:{host:process.env.SMTP_HOST,port:parseInt(process.env.SMTP_PORT||"587",10),secure:process.env.SMTP_SECURE==="true",auth:{user:process.env.SMTP_USER||"",pass:process.env.SMTP_PASS||""}},from:process.env.SMTP_FROM||"noreply@example.com",fromName:process.env.SMTP_FROM_NAME}:void 0,sendWelcomeEmail:process.env.KYRO_ADMIN_SEND_WELCOME==="true"}}async function T(r){let e=w();if(!e)return null;r&&(e.authAdapter=r);try{if(await e.authAdapter?.connect?.(),await e.authAdapter?.findUserByEmail(e.adminEmail))return await e.authAdapter?.disconnect?.(),{success:!1,error:"Admin user already exists"}}catch{}let t=await f(e);return t.success||console.error(`Bootstrap failed: ${t.error}`),t}async function v(r,e=3,t=2e3){let o="";for(let i=0;i<e;i++){let a=await f(r);if(a.success||(o=a.error||"Unknown error",o.includes("already exists")))return a;i<e-1&&await new Promise(c=>setTimeout(c,t));}return {success:false,error:`Failed after ${e} retries: ${o}`}}export{f as a,y as b,w as c,T as d,v as e};
@@ -1,4 +1,4 @@
1
- import i from'path';import u from'fs';var l=o=>{let s=new URL(".",import.meta.url).pathname,e=i.resolve(s,`${o}.ts`),n=i.resolve(s,`${o}.js`);return u.existsSync(e)?e:n},g=l("api-handler"),b=l("api-handler-graphql"),y=l("api-handler-trpc");function _(o={}){let{configPath:s="./kyro.config.ts",apiPath:e="/api",adminPath:n="/admin",admin:x=true,enableGraphQL:c=false,enableTRPC:p=false,enableWebSocket:h=false}=o;return {name:"@kyro-cms/core",hooks:{"astro:config:setup":async({config:m,updateConfig:d,injectRoute:a,logger:r})=>{if(r.info(`Setting up Kyro CMS (API: ${e}, Admin: ${n})`),e===n)throw new Error(`Kyro CMS: apiPath and adminPath cannot be the same ("${e}")`);let f=i.resolve(m.root.pathname,s),S=f;u.existsSync(f)||r.warn(`Kyro config file not found at ${s}. The API will fail to boot if collections are needed.`),d({security:{checkOrigin:false},vite:{ssr:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},build:{rollupOptions:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]}},optimizeDeps:{exclude:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},server:{watch:{ignored:["**/*.db","**/*.db-journal","**/data/**"]}},plugins:[{name:"use-sync-external-store-shim-fix",enforce:"pre",resolveId(t){if(t==="use-sync-external-store/shim"||t==="use-sync-external-store/shim/index.js")return "\0virtual:use-sync-external-store-shim";if(t==="use-sync-external-store/shim/with-selector"||t==="use-sync-external-store/shim/with-selector.js")return "\0virtual:use-sync-external-store-shim-with-selector"},load(t){if(t==="\0virtual:use-sync-external-store-shim")return 'export { useSyncExternalStore } from "react";';if(t==="\0virtual:use-sync-external-store-shim-with-selector")return `
1
+ import i from'path';import f from'fs';var l=o=>{let s=new URL(".",import.meta.url).pathname,e=i.resolve(s,`${o}.ts`),n=i.resolve(s,`${o}.js`);return f.existsSync(e)?e:n},b=l("api-handler"),g=l("api-handler-graphql"),y=l("api-handler-trpc");function _(o={}){let{configPath:s="./kyro.config.ts",apiPath:e="/api",adminPath:n="/admin",admin:x=true,enableGraphQL:c=false,enableTRPC:p=false,enableWebSocket:h=false}=o;return {name:"@kyro-cms/core",hooks:{"astro:config:setup":async({config:m,updateConfig:d,injectRoute:a,logger:r})=>{if(r.info(`Setting up Kyro CMS (API: ${e}, Admin: ${n})`),e===n)throw new Error(`Kyro CMS: apiPath and adminPath cannot be the same ("${e}")`);let u=i.resolve(m.root.pathname,s),S=u;f.existsSync(u)||r.warn(`Kyro config file not found at ${s}. The API will fail to boot if collections are needed.`),d({security:{checkOrigin:false},vite:{ssr:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},build:{rollupOptions:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]}},optimizeDeps:{exclude:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},server:{watch:{ignored:["**/*.db","**/*.db-*","**/data/**","**/public/uploads/**","**/.kyro/**"]}},plugins:[{name:"use-sync-external-store-shim-fix",enforce:"pre",resolveId(t){if(t==="use-sync-external-store/shim"||t==="use-sync-external-store/shim/index.js")return "\0virtual:use-sync-external-store-shim";if(t==="use-sync-external-store/shim/with-selector"||t==="use-sync-external-store/shim/with-selector.js")return "\0virtual:use-sync-external-store-shim-with-selector"},load(t){if(t==="\0virtual:use-sync-external-store-shim")return 'export { useSyncExternalStore } from "react";';if(t==="\0virtual:use-sync-external-store-shim-with-selector")return `
2
2
  import { useSyncExternalStore, useMemo } from "react";
3
3
  export function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
4
4
  const memoizedSelector = useMemo(() => {
@@ -17,4 +17,4 @@ export function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServ
17
17
  const getServerSelection = getServerSnapshot != null ? () => memoizedSelector(getServerSnapshot()) : undefined;
18
18
  return useSyncExternalStore(subscribe, getSelection, getServerSelection);
19
19
  }
20
- `}}],resolve:{alias:{"kyro:config":S}},define:{__KYRO_API_PATH__:JSON.stringify(e),__KYRO_ADMIN_PATH__:JSON.stringify(n),__KYRO_ENABLE_GRAPHQL__:JSON.stringify(c),__KYRO_ENABLE_TRPC__:JSON.stringify(p),__KYRO_ENABLE_WS__:JSON.stringify(h)}}}),a({pattern:`${e}/[...path]`,entrypoint:g}),c&&(a({pattern:`${e}/graphql`,entrypoint:b}),r.info(`GraphQL endpoint enabled at ${e}/graphql`)),p&&(a({pattern:`${e}/trpc/[...path]`,entrypoint:y}),r.info(`tRPC endpoint enabled at ${e}/trpc`)),h&&r.info("WebSocket support enabled (auto-starts at first request)");}}}}export{_ as a};
20
+ `}}],resolve:{alias:{"kyro:config":S}},define:{__KYRO_API_PATH__:JSON.stringify(e),__KYRO_ADMIN_PATH__:JSON.stringify(n),__KYRO_ENABLE_GRAPHQL__:JSON.stringify(c),__KYRO_ENABLE_TRPC__:JSON.stringify(p),__KYRO_ENABLE_WS__:JSON.stringify(h)}}}),a({pattern:`${e}/[...path]`,entrypoint:b}),c&&(a({pattern:`${e}/graphql`,entrypoint:g}),r.info(`GraphQL endpoint enabled at ${e}/graphql`)),p&&(a({pattern:`${e}/trpc/[...path]`,entrypoint:y}),r.info(`tRPC endpoint enabled at ${e}/trpc`)),h&&r.info("WebSocket support enabled (auto-starts at first request)");}}}}export{_ as a};
@@ -1 +1 @@
1
- 'use strict';var chunk4KFXG5ZB_cjs=require('./chunk-4KFXG5ZB.cjs'),chunk4XZABBHF_cjs=require('./chunk-4XZABBHF.cjs'),chunk2YRM7CZZ_cjs=require('./chunk-2YRM7CZZ.cjs'),chunkHOP4D5XZ_cjs=require('./chunk-HOP4D5XZ.cjs'),chunkFUWPXR6W_cjs=require('./chunk-FUWPXR6W.cjs'),chunkGYQMNXXW_cjs=require('./chunk-GYQMNXXW.cjs'),chunk3Q2WUG63_cjs=require('./chunk-3Q2WUG63.cjs'),chunkQCA3AP3M_cjs=require('./chunk-QCA3AP3M.cjs'),A=require('kyro:config');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var A__default=/*#__PURE__*/_interopDefault(A);exports.a=null;var n=null;async function b(){if(!exports.a){if(globalThis.__KYRO_INSTANCE__)try{await globalThis.__KYRO_INSTANCE__.shutdown();}catch{}try{let t=A__default.default.default||A__default.default;exports.a=chunk4KFXG5ZB_cjs.z(t),await exports.a.init(),await exports.a.loadSettings();let e=exports.a.db,a;if(e instanceof chunkFUWPXR6W_cjs.c)e.dialect==="postgres"?a=new chunkGYQMNXXW_cjs.a({db:e.client}):e.dialect==="sqlite"&&(a=new chunk2YRM7CZZ_cjs.r({db:e.client}));else if(e instanceof chunk4KFXG5ZB_cjs.A){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";a=new chunkHOP4D5XZ_cjs.a({path:s});}else e instanceof chunk3Q2WUG63_cjs.a&&(a=new chunkQCA3AP3M_cjs.a({db:e.db}));a?.connect&&await a.connect(),(await chunk4XZABBHF_cjs.d(a))?.success,typeof exports.a.startWebSocket=="function"&&exports.a.startWebSocket().catch(s=>{console.error("[Kyro] WebSocket auto-start failed:",s);}),globalThis.__KYRO_INSTANCE__=exports.a;}catch(t){throw exports.a=null,n=null,console.error("[Kyro API] Init failed, will retry:",t),t}}}async function D(){n||(n=b()),await n;}var w={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function g(t){try{return (await exports.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.[t]??w[t]??!0}catch{return true}}var q=async t=>{let e=null;try{e=t.locals?.cfContext?.env||process.env;}catch{e=process.env;}if(e?.DB&&(globalThis.DB=e.DB),e?.STORAGE_BUCKET&&(globalThis.STORAGE_BUCKET=e.STORAGE_BUCKET),!exports.a){n||(n=b());try{await Promise.race([n,new Promise((c,o)=>setTimeout(()=>o(new Error("Initialization timeout")),3e4))]);}catch{return new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}}let i=new URL(t.request.url).pathname,s=__KYRO_API_PATH__;if(i===`${s}/graphql`&&typeof exports.a.getGraphQL=="function"){if(!await g("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await exports.a.getGraphQL().fetch(t.request,t.locals);return new Response(o.body,o)}if(i.startsWith(`${s}/trpc/`)&&typeof exports.a.getTRPC=="function"){if(!await g("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await exports.a.getTRPC().fetch(t.request,t.locals);return new Response(o.body,o)}return exports.a.getREST().fetch(t.request,t.locals)};exports.b=D;exports.c=q;
1
+ 'use strict';var chunk4KFXG5ZB_cjs=require('./chunk-4KFXG5ZB.cjs'),chunkQBJT7XLN_cjs=require('./chunk-QBJT7XLN.cjs'),chunk2YRM7CZZ_cjs=require('./chunk-2YRM7CZZ.cjs'),chunkHOP4D5XZ_cjs=require('./chunk-HOP4D5XZ.cjs'),chunkFUWPXR6W_cjs=require('./chunk-FUWPXR6W.cjs'),chunkGYQMNXXW_cjs=require('./chunk-GYQMNXXW.cjs'),chunk3Q2WUG63_cjs=require('./chunk-3Q2WUG63.cjs'),chunkQCA3AP3M_cjs=require('./chunk-QCA3AP3M.cjs'),A=require('kyro:config');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var A__default=/*#__PURE__*/_interopDefault(A);exports.a=null;var n=null;async function b(){if(!exports.a){if(globalThis.__KYRO_INSTANCE__)try{await globalThis.__KYRO_INSTANCE__.shutdown();}catch{}try{let t=A__default.default.default||A__default.default;exports.a=chunk4KFXG5ZB_cjs.z(t),await exports.a.init(),await exports.a.loadSettings();let e=exports.a.db,a;if(e instanceof chunkFUWPXR6W_cjs.c)e.dialect==="postgres"?a=new chunkGYQMNXXW_cjs.a({db:e.client}):e.dialect==="sqlite"&&(a=new chunk2YRM7CZZ_cjs.r({db:e.client}));else if(e instanceof chunk4KFXG5ZB_cjs.A){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";a=new chunkHOP4D5XZ_cjs.a({path:s});}else e instanceof chunk3Q2WUG63_cjs.a&&(a=new chunkQCA3AP3M_cjs.a({db:e.db}));a?.connect&&await a.connect(),(await chunkQBJT7XLN_cjs.d(a))?.success,typeof exports.a.startWebSocket=="function"&&exports.a.startWebSocket().catch(s=>{console.error("[Kyro] WebSocket auto-start failed:",s);}),globalThis.__KYRO_INSTANCE__=exports.a;}catch(t){throw exports.a=null,n=null,console.error("[Kyro API] Init failed, will retry:",t),t}}}async function D(){n||(n=b()),await n;}var w={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function g(t){try{return (await exports.a.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.[t]??w[t]??!0}catch{return true}}var q=async t=>{let e=null;try{e=t.locals?.cfContext?.env||process.env;}catch{e=process.env;}if(e?.DB&&(globalThis.DB=e.DB),e?.STORAGE_BUCKET&&(globalThis.STORAGE_BUCKET=e.STORAGE_BUCKET),!exports.a){n||(n=b());try{await Promise.race([n,new Promise((c,o)=>setTimeout(()=>o(new Error("Initialization timeout")),3e4))]);}catch{return new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}}let i=new URL(t.request.url).pathname,s=__KYRO_API_PATH__;if(i===`${s}/graphql`&&typeof exports.a.getGraphQL=="function"){if(!await g("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await exports.a.getGraphQL().fetch(t.request,t.locals);return new Response(o.body,o)}if(i.startsWith(`${s}/trpc/`)&&typeof exports.a.getTRPC=="function"){if(!await g("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await exports.a.getTRPC().fetch(t.request,t.locals);return new Response(o.body,o)}return exports.a.getREST().fetch(t.request,t.locals)};exports.b=D;exports.c=q;
@@ -1 +1 @@
1
- import {z,A as A$1}from'./chunk-DZMIMB5W.js';import {d}from'./chunk-6MSPBK3W.js';import {r as r$1}from'./chunk-4DJYAD4L.js';import {a as a$1}from'./chunk-IKOXCJYO.js';import {c}from'./chunk-5KSRMBEO.js';import {a}from'./chunk-RHCWCG3O.js';import {a as a$2}from'./chunk-VGQ4VUG6.js';import {a as a$3}from'./chunk-6ROHVUXF.js';import A from'kyro:config';var r=null,n=null;async function b(){if(!r){if(globalThis.__KYRO_INSTANCE__)try{await globalThis.__KYRO_INSTANCE__.shutdown();}catch{}try{let t=A.default||A;r=z(t),await r.init(),await r.loadSettings();let e=r.db,a$4;if(e instanceof c)e.dialect==="postgres"?a$4=new a({db:e.client}):e.dialect==="sqlite"&&(a$4=new r$1({db:e.client}));else if(e instanceof A$1){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";a$4=new a$1({path:s});}else e instanceof a$2&&(a$4=new a$3({db:e.db}));a$4?.connect&&await a$4.connect(),(await d(a$4))?.success,typeof r.startWebSocket=="function"&&r.startWebSocket().catch(s=>{console.error("[Kyro] WebSocket auto-start failed:",s);}),globalThis.__KYRO_INSTANCE__=r;}catch(t){throw r=null,n=null,console.error("[Kyro API] Init failed, will retry:",t),t}}}async function D(){n||(n=b()),await n;}var w={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function g(t){try{return (await r.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.[t]??w[t]??!0}catch{return true}}var q=async t=>{let e=null;try{e=t.locals?.cfContext?.env||process.env;}catch{e=process.env;}if(e?.DB&&(globalThis.DB=e.DB),e?.STORAGE_BUCKET&&(globalThis.STORAGE_BUCKET=e.STORAGE_BUCKET),!r){n||(n=b());try{await Promise.race([n,new Promise((c,o)=>setTimeout(()=>o(new Error("Initialization timeout")),3e4))]);}catch{return new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}}let i=new URL(t.request.url).pathname,s=__KYRO_API_PATH__;if(i===`${s}/graphql`&&typeof r.getGraphQL=="function"){if(!await g("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await r.getGraphQL().fetch(t.request,t.locals);return new Response(o.body,o)}if(i.startsWith(`${s}/trpc/`)&&typeof r.getTRPC=="function"){if(!await g("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await r.getTRPC().fetch(t.request,t.locals);return new Response(o.body,o)}return r.getREST().fetch(t.request,t.locals)};export{r as a,D as b,q as c};
1
+ import {z,A as A$1}from'./chunk-DZMIMB5W.js';import {d}from'./chunk-7MBZYLME.js';import {r as r$1}from'./chunk-4DJYAD4L.js';import {a as a$1}from'./chunk-IKOXCJYO.js';import {c}from'./chunk-5KSRMBEO.js';import {a}from'./chunk-RHCWCG3O.js';import {a as a$2}from'./chunk-VGQ4VUG6.js';import {a as a$3}from'./chunk-6ROHVUXF.js';import A from'kyro:config';var r=null,n=null;async function b(){if(!r){if(globalThis.__KYRO_INSTANCE__)try{await globalThis.__KYRO_INSTANCE__.shutdown();}catch{}try{let t=A.default||A;r=z(t),await r.init(),await r.loadSettings();let e=r.db,a$4;if(e instanceof c)e.dialect==="postgres"?a$4=new a({db:e.client}):e.dialect==="sqlite"&&(a$4=new r$1({db:e.client}));else if(e instanceof A$1){let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";a$4=new a$1({path:s});}else e instanceof a$2&&(a$4=new a$3({db:e.db}));a$4?.connect&&await a$4.connect(),(await d(a$4))?.success,typeof r.startWebSocket=="function"&&r.startWebSocket().catch(s=>{console.error("[Kyro] WebSocket auto-start failed:",s);}),globalThis.__KYRO_INSTANCE__=r;}catch(t){throw r=null,n=null,console.error("[Kyro API] Init failed, will retry:",t),t}}}async function D(){n||(n=b()),await n;}var w={graphqlEnabled:false,trpcEnabled:false,wsEnabled:false,requireAuth:false};async function g(t){try{return (await r.db.findOne({collection:"_globals_access-settings",where:{},draft:!0}))?.apiAccess?.[t]??w[t]??!0}catch{return true}}var q=async t=>{let e=null;try{e=t.locals?.cfContext?.env||process.env;}catch{e=process.env;}if(e?.DB&&(globalThis.DB=e.DB),e?.STORAGE_BUCKET&&(globalThis.STORAGE_BUCKET=e.STORAGE_BUCKET),!r){n||(n=b());try{await Promise.race([n,new Promise((c,o)=>setTimeout(()=>o(new Error("Initialization timeout")),3e4))]);}catch{return new Response(JSON.stringify({error:"Service Unavailable",message:"Kyro CMS is still starting up. Please try again in a moment."}),{status:503,headers:{"Content-Type":"application/json","Retry-After":"5"}})}}let i=new URL(t.request.url).pathname,s=__KYRO_API_PATH__;if(i===`${s}/graphql`&&typeof r.getGraphQL=="function"){if(!await g("graphqlEnabled"))return new Response(JSON.stringify({error:"GraphQL is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await r.getGraphQL().fetch(t.request,t.locals);return new Response(o.body,o)}if(i.startsWith(`${s}/trpc/`)&&typeof r.getTRPC=="function"){if(!await g("trpcEnabled"))return new Response(JSON.stringify({error:"tRPC is disabled"}),{status:503,headers:{"Content-Type":"application/json"}});let o=await r.getTRPC().fetch(t.request,t.locals);return new Response(o.body,o)}return r.getREST().fetch(t.request,t.locals)};export{r as a,D as b,q as c};
@@ -0,0 +1 @@
1
+ 'use strict';var chunk5K4YG5DA_cjs=require('./chunk-5K4YG5DA.cjs'),chunkHOP4D5XZ_cjs=require('./chunk-HOP4D5XZ.cjs');async function f(r){let{adminEmail:e,adminPassword:t,adminRole:o="super_admin",tenantId:i,emailConfig:a,sendWelcomeEmail:c=false}=r,s=r.authAdapter||new chunkHOP4D5XZ_cjs.a({path:r.authDbPath||"./data/auth.db"});try{await s.connect?.();}catch{return {success:false,error:"Failed to connect to auth storage"}}let l=new chunk5K4YG5DA_cjs.l().validate(t);if(!l.valid)return await s.disconnect?.(),{success:false,error:`Invalid password: ${l.errors.join(", ")}`};if(await s.findUserByEmail(e))return await s.disconnect?.(),{success:false,error:"Admin user already exists"};try{let n=await s.createUser({name:"Super Admin",email:e,password:t,role:o||"admin",tenantId:i});if(await s.updateUser?.(n.id,{emailVerified:!0}),c&&a){let u=new chunk5K4YG5DA_cjs.k(a),A=u.getTemplates().welcome(e.split("@")[0]);await u.send({to:e,...A});}return await s.disconnect?.(),{success:!0,user:n}}catch(n){return await s.disconnect?.(),{success:false,error:n instanceof Error?n.message:"Failed to create admin user"}}}async function y(r,e){return !await r.findUserByEmail(e)}function w(){let r=process.env.KYRO_ADMIN_EMAIL,e=process.env.KYRO_ADMIN_PASSWORD;return !r||!e?null:{authDbPath:process.env.KYRO_AUTH_DB_PATH||"./data/auth.db",adminEmail:r,adminPassword:e,adminRole:process.env.KYRO_ADMIN_ROLE||"super_admin",tenantId:process.env.KYRO_ADMIN_TENANT_ID,emailConfig:process.env.SMTP_HOST?{provider:"smtp",smtp:{host:process.env.SMTP_HOST,port:parseInt(process.env.SMTP_PORT||"587",10),secure:process.env.SMTP_SECURE==="true",auth:{user:process.env.SMTP_USER||"",pass:process.env.SMTP_PASS||""}},from:process.env.SMTP_FROM||"noreply@example.com",fromName:process.env.SMTP_FROM_NAME}:void 0,sendWelcomeEmail:process.env.KYRO_ADMIN_SEND_WELCOME==="true"}}async function T(r){let e=w();if(!e)return null;r&&(e.authAdapter=r);try{if(await e.authAdapter?.connect?.(),await e.authAdapter?.findUserByEmail(e.adminEmail))return await e.authAdapter?.disconnect?.(),{success:!1,error:"Admin user already exists"}}catch{}let t=await f(e);return t.success||console.error(`Bootstrap failed: ${t.error}`),t}async function v(r,e=3,t=2e3){let o="";for(let i=0;i<e;i++){let a=await f(r);if(a.success||(o=a.error||"Unknown error",o.includes("already exists")))return a;i<e-1&&await new Promise(c=>setTimeout(c,t));}return {success:false,error:`Failed after ${e} retries: ${o}`}}exports.a=f;exports.b=y;exports.c=w;exports.d=T;exports.e=v;
@@ -1,4 +1,4 @@
1
- 'use strict';var i=require('path'),u=require('fs');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var i__default=/*#__PURE__*/_interopDefault(i);var u__default=/*#__PURE__*/_interopDefault(u);var l=o=>{let s=new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-C2AS7MZJ.cjs', document.baseURI).href))).pathname,e=i__default.default.resolve(s,`${o}.ts`),n=i__default.default.resolve(s,`${o}.js`);return u__default.default.existsSync(e)?e:n},g=l("api-handler"),b=l("api-handler-graphql"),y=l("api-handler-trpc");function _(o={}){let{configPath:s="./kyro.config.ts",apiPath:e="/api",adminPath:n="/admin",admin:x=true,enableGraphQL:c=false,enableTRPC:p=false,enableWebSocket:h=false}=o;return {name:"@kyro-cms/core",hooks:{"astro:config:setup":async({config:m,updateConfig:d,injectRoute:a,logger:r})=>{if(r.info(`Setting up Kyro CMS (API: ${e}, Admin: ${n})`),e===n)throw new Error(`Kyro CMS: apiPath and adminPath cannot be the same ("${e}")`);let f=i__default.default.resolve(m.root.pathname,s),S=f;u__default.default.existsSync(f)||r.warn(`Kyro config file not found at ${s}. The API will fail to boot if collections are needed.`),d({security:{checkOrigin:false},vite:{ssr:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},build:{rollupOptions:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]}},optimizeDeps:{exclude:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},server:{watch:{ignored:["**/*.db","**/*.db-journal","**/data/**"]}},plugins:[{name:"use-sync-external-store-shim-fix",enforce:"pre",resolveId(t){if(t==="use-sync-external-store/shim"||t==="use-sync-external-store/shim/index.js")return "\0virtual:use-sync-external-store-shim";if(t==="use-sync-external-store/shim/with-selector"||t==="use-sync-external-store/shim/with-selector.js")return "\0virtual:use-sync-external-store-shim-with-selector"},load(t){if(t==="\0virtual:use-sync-external-store-shim")return 'export { useSyncExternalStore } from "react";';if(t==="\0virtual:use-sync-external-store-shim-with-selector")return `
1
+ 'use strict';var i=require('path'),f=require('fs');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var i__default=/*#__PURE__*/_interopDefault(i);var f__default=/*#__PURE__*/_interopDefault(f);var l=o=>{let s=new URL(".",(typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-WNVWRRWE.cjs', document.baseURI).href))).pathname,e=i__default.default.resolve(s,`${o}.ts`),n=i__default.default.resolve(s,`${o}.js`);return f__default.default.existsSync(e)?e:n},b=l("api-handler"),g=l("api-handler-graphql"),y=l("api-handler-trpc");function _(o={}){let{configPath:s="./kyro.config.ts",apiPath:e="/api",adminPath:n="/admin",admin:x=true,enableGraphQL:c=false,enableTRPC:p=false,enableWebSocket:h=false}=o;return {name:"@kyro-cms/core",hooks:{"astro:config:setup":async({config:m,updateConfig:d,injectRoute:a,logger:r})=>{if(r.info(`Setting up Kyro CMS (API: ${e}, Admin: ${n})`),e===n)throw new Error(`Kyro CMS: apiPath and adminPath cannot be the same ("${e}")`);let u=i__default.default.resolve(m.root.pathname,s),S=u;f__default.default.existsSync(u)||r.warn(`Kyro config file not found at ${s}. The API will fail to boot if collections are needed.`),d({security:{checkOrigin:false},vite:{ssr:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},build:{rollupOptions:{external:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]}},optimizeDeps:{exclude:["better-sqlite3","pg","mongodb","ioredis","sharp","ssh2","cpu-features","ssh2-sftp-client","nodemailer","jsonwebtoken","@mapbox/node-pre-gyp","mock-aws-s3","aws-sdk","nock"]},server:{watch:{ignored:["**/*.db","**/*.db-*","**/data/**","**/public/uploads/**","**/.kyro/**"]}},plugins:[{name:"use-sync-external-store-shim-fix",enforce:"pre",resolveId(t){if(t==="use-sync-external-store/shim"||t==="use-sync-external-store/shim/index.js")return "\0virtual:use-sync-external-store-shim";if(t==="use-sync-external-store/shim/with-selector"||t==="use-sync-external-store/shim/with-selector.js")return "\0virtual:use-sync-external-store-shim-with-selector"},load(t){if(t==="\0virtual:use-sync-external-store-shim")return 'export { useSyncExternalStore } from "react";';if(t==="\0virtual:use-sync-external-store-shim-with-selector")return `
2
2
  import { useSyncExternalStore, useMemo } from "react";
3
3
  export function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
4
4
  const memoizedSelector = useMemo(() => {
@@ -17,4 +17,4 @@ export function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServ
17
17
  const getServerSelection = getServerSnapshot != null ? () => memoizedSelector(getServerSnapshot()) : undefined;
18
18
  return useSyncExternalStore(subscribe, getSelection, getServerSelection);
19
19
  }
20
- `}}],resolve:{alias:{"kyro:config":S}},define:{__KYRO_API_PATH__:JSON.stringify(e),__KYRO_ADMIN_PATH__:JSON.stringify(n),__KYRO_ENABLE_GRAPHQL__:JSON.stringify(c),__KYRO_ENABLE_TRPC__:JSON.stringify(p),__KYRO_ENABLE_WS__:JSON.stringify(h)}}}),a({pattern:`${e}/[...path]`,entrypoint:g}),c&&(a({pattern:`${e}/graphql`,entrypoint:b}),r.info(`GraphQL endpoint enabled at ${e}/graphql`)),p&&(a({pattern:`${e}/trpc/[...path]`,entrypoint:y}),r.info(`tRPC endpoint enabled at ${e}/trpc`)),h&&r.info("WebSocket support enabled (auto-starts at first request)");}}}}exports.a=_;
20
+ `}}],resolve:{alias:{"kyro:config":S}},define:{__KYRO_API_PATH__:JSON.stringify(e),__KYRO_ADMIN_PATH__:JSON.stringify(n),__KYRO_ENABLE_GRAPHQL__:JSON.stringify(c),__KYRO_ENABLE_TRPC__:JSON.stringify(p),__KYRO_ENABLE_WS__:JSON.stringify(h)}}}),a({pattern:`${e}/[...path]`,entrypoint:b}),c&&(a({pattern:`${e}/graphql`,entrypoint:g}),r.info(`GraphQL endpoint enabled at ${e}/graphql`)),p&&(a({pattern:`${e}/trpc/[...path]`,entrypoint:y}),r.info(`tRPC endpoint enabled at ${e}/trpc`)),h&&r.info("WebSocket support enabled (auto-starts at first request)");}}}}exports.a=_;
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';require('../chunk-AHSFSERC.cjs');var commander=require('commander'),x=require('fs'),_=require('path'),url=require('url'),glob=require('glob'),child_process=require('child_process'),q=require('readline/promises'),process$1=require('process'),F=require('crypto'),o=require('chalk');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var x__default=/*#__PURE__*/_interopDefault(x);var ___default=/*#__PURE__*/_interopDefault(_);var q__namespace=/*#__PURE__*/_interopNamespace(q);var F__default=/*#__PURE__*/_interopDefault(F);var o__default=/*#__PURE__*/_interopDefault(o);function R(e){switch(e.type){case "text":case "email":case "password":case "textarea":case "color":case "code":case "markdown":case "date":case "richtext":case "json":return e.hasMany?"string[]":"string";case "number":return e.hasMany?"number[]":"number";case "checkbox":return "boolean";case "select":case "radio":if(e.options){let t=e.options.map(n=>`'${n.value}'`).join(" | ");return e.hasMany?`(${t})[]`:t}return e.hasMany?"string[]":"string";case "relationship":if(Array.isArray(e.relationTo)){if(e.relationTo.includes("*"))return e.hasMany?"any[]":"any";let t=e.relationTo.map(n=>`${C(n)} | string`).join(" | ");return e.hasMany?`(${t})[]`:`(${t})`}let r=e.relationTo||"unknown";return r==="*"?e.hasMany?"any[]":"any":e.hasMany?`(${C(r)} | string)[]`:`${C(r)} | string`;case "upload":return e.hasMany?"(Media | string)[]":"Media | string";case "array":return e.fields&&e.fields.length>0?`Array<{
3
- ${e.fields.filter(n=>n.name).map(n=>{let s=R(n);return ` ${n.name}${n.required?"":"?"}: ${s};`}).join(`
2
+ 'use strict';require('../chunk-AHSFSERC.cjs');var commander=require('commander'),R=require('fs'),k=require('path'),url=require('url'),glob=require('glob'),child_process=require('child_process'),J=require('prompts'),q=require('crypto'),n=require('chalk');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var R__default=/*#__PURE__*/_interopDefault(R);var k__default=/*#__PURE__*/_interopDefault(k);var J__default=/*#__PURE__*/_interopDefault(J);var q__default=/*#__PURE__*/_interopDefault(q);var n__default=/*#__PURE__*/_interopDefault(n);function x(e){switch(e.type){case "text":case "email":case "password":case "textarea":case "color":case "code":case "markdown":case "date":case "richtext":case "json":return e.hasMany?"string[]":"string";case "number":return e.hasMany?"number[]":"number";case "checkbox":return "boolean";case "select":case "radio":if(e.options){let t=e.options.map(o=>`'${o.value}'`).join(" | ");return e.hasMany?`(${t})[]`:t}return e.hasMany?"string[]":"string";case "relationship":if(Array.isArray(e.relationTo)){if(e.relationTo.includes("*"))return e.hasMany?"any[]":"any";let t=e.relationTo.map(o=>`${C(o)} | string`).join(" | ");return e.hasMany?`(${t})[]`:`(${t})`}let r=e.relationTo||"unknown";return r==="*"?e.hasMany?"any[]":"any":e.hasMany?`(${C(r)} | string)[]`:`${C(r)} | string`;case "upload":return e.hasMany?"(Media | string)[]":"Media | string";case "array":return e.fields&&e.fields.length>0?`Array<{
3
+ ${e.fields.filter(o=>o.name).map(o=>{let s=x(o);return ` ${o.name}${o.required?"":"?"}: ${s};`}).join(`
4
4
  `)}
5
5
  }>`:"Record<string, any>[]";case "group":return e.fields&&e.fields.length>0?`{
6
- ${e.fields.filter(n=>n.name).map(n=>{let s=R(n);return ` ${n.name}${n.required?"":"?"}: ${s};`}).join(`
6
+ ${e.fields.filter(o=>o.name).map(o=>{let s=x(o);return ` ${o.name}${o.required?"":"?"}: ${s};`}).join(`
7
7
  `)}
8
- }`:"Record<string, any>";case "blocks":return "Block[]";default:return "any"}}function C(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/-([a-z])/g,(r,t)=>t.toUpperCase())}function N(e){return e.replace(/-([a-z])/g,(r,t)=>t.toUpperCase())}function Y(e){let r=C(e.slug),t=e.fields.filter(n=>n.name).map(n=>{let s=R(n);return ` ${n.name}${n.required?"":"?"}: ${s};`});return t.unshift(" id: string;"),t.push(" createdAt: string;"),t.push(" updatedAt: string;"),`export interface ${r} {
8
+ }`:"Record<string, any>";case "blocks":return "Block[]";default:return "any"}}function C(e){return e.charAt(0).toUpperCase()+e.slice(1).replace(/-([a-z])/g,(r,t)=>t.toUpperCase())}function N(e){return e.replace(/-([a-z])/g,(r,t)=>t.toUpperCase())}function H(e){let r=C(e.slug),t=e.fields.filter(o=>o.name).map(o=>{let s=x(o);return ` ${o.name}${o.required?"":"?"}: ${s};`});return t.unshift(" id: string;"),t.push(" createdAt: string;"),t.push(" updatedAt: string;"),`export interface ${r} {
9
9
  ${t.join(`
10
10
  `)}
11
- }`}function K(e){let r=e.map(a=>Y(a)),t=`// ============================================================================
11
+ }`}function O(e){let r=e.map(a=>H(a)),t=`// ============================================================================
12
12
  // Auto-generated by kyro generate
13
13
  // ============================================================================
14
14
 
@@ -31,7 +31,7 @@ export interface Block {
31
31
  [key: string]: any;
32
32
  }
33
33
 
34
- `,n=r.join(`
34
+ `,o=r.join(`
35
35
 
36
36
  `),s=`
37
37
 
@@ -122,7 +122,7 @@ export function createClient(config: { url: string; token?: string }): KyroClien
122
122
  // Client implementation would be here
123
123
  throw new Error('Not implemented');
124
124
  }
125
- `;return t+n+s}async function G(e,r){let t=`${e.replace(/\/+$/,"")}/api/__schema`,n=await fetch(t,{headers:{Authorization:`ApiKey ${r}`}});if(!n.ok){let s=await n.text();throw new Error(`Schema fetch failed (${n.status}): ${s}`)}return n.json()}function Q(e){let r=`// ============================================================================
125
+ `;return t+o+s}async function Y(e,r){let t=`${e.replace(/\/+$/,"")}/api/__schema`,o=await fetch(t,{headers:{Authorization:`ApiKey ${r}`}});if(!o.ok){let s=await o.text();throw new Error(`Schema fetch failed (${o.status}): ${s}`)}return o.json()}function G(e){let r=`// ============================================================================
126
126
  // Auto-generated by kyro generate --api
127
127
  // ============================================================================
128
128
 
@@ -145,7 +145,7 @@ export interface Block {
145
145
  [key: string]: any;
146
146
  }
147
147
 
148
- `;for(let t of e){let n=C(t.slug),s=t.fields.filter(a=>a.name).map(a=>{let c=R(a);return ` ${a.name}${a.required?"":"?"}: ${c};`});s.unshift(" id: string;"),s.push(" createdAt: string;"),s.push(" updatedAt: string;"),r+=`export interface ${n} {
148
+ `;for(let t of e){let o=C(t.slug),s=t.fields.filter(a=>a.name).map(a=>{let c=x(a);return ` ${a.name}${a.required?"":"?"}: ${c};`});s.unshift(" id: string;"),s.push(" createdAt: string;"),s.push(" updatedAt: string;"),r+=`export interface ${o} {
149
149
  ${s.join(`
150
150
  `)}
151
151
  }
@@ -189,38 +189,32 @@ export function createKyroClient(opts: KyroClientOptions) {
189
189
  }
190
190
 
191
191
  return {
192
- ${e.map(t=>{let n=C(t.slug);return ` ${N(t.slug)}: {
192
+ ${e.map(t=>{let o=C(t.slug);return ` ${N(t.slug)}: {
193
193
  find: (args?: { where?: Record<string, any>; sort?: string; limit?: number; page?: number; draft?: boolean }) =>
194
- request<{ docs: ${n}[]; totalDocs: number; page: number; totalPages: number; hasNextPage: boolean; hasPrevPage: boolean }>(\`/${t.slug}\${args ? "?" + qs(args) : ""}\`),
194
+ request<{ docs: ${o}[]; totalDocs: number; page: number; totalPages: number; hasNextPage: boolean; hasPrevPage: boolean }>(\`/${t.slug}\${args ? "?" + qs(args) : ""}\`),
195
195
  findByID: (id: string, args?: { draft?: boolean }) =>
196
- request<${n}>(\`/${t.slug}/\${id}\${args ? "?" + qs(args) : ""}\`),
196
+ request<${o}>(\`/${t.slug}/\${id}\${args ? "?" + qs(args) : ""}\`),
197
197
  findBySlug: (slug: string, args?: { draft?: boolean }) =>
198
- request<{ docs: ${n}[] }>(\`/${t.slug}?where=\${encodeURIComponent(JSON.stringify({ slug: { equals: slug } }))}\`),
199
- create: (data: Partial<${n}>) =>
200
- request<{ doc: ${n}; message?: string }>(\`/${t.slug}\`, { method: "POST", body: JSON.stringify(data) }),
201
- update: (id: string, data: Partial<${n}>, args?: { baseUpdatedAt?: string }) =>
202
- request<{ doc: ${n}; message?: string }>(\`/${t.slug}/\${id}\`, { method: "PATCH", body: JSON.stringify({ ...data, ...args }) }),
198
+ request<{ docs: ${o}[] }>(\`/${t.slug}?where=\${encodeURIComponent(JSON.stringify({ slug: { equals: slug } }))}\`),
199
+ create: (data: Partial<${o}>) =>
200
+ request<{ doc: ${o}; message?: string }>(\`/${t.slug}\`, { method: "POST", body: JSON.stringify(data) }),
201
+ update: (id: string, data: Partial<${o}>, args?: { baseUpdatedAt?: string }) =>
202
+ request<{ doc: ${o}; message?: string }>(\`/${t.slug}/\${id}\`, { method: "PATCH", body: JSON.stringify({ ...data, ...args }) }),
203
203
  delete: (id: string) =>
204
- request<{ doc: ${n}; message: string }>(\`/${t.slug}/\${id}\`, { method: "DELETE" }),
204
+ request<{ doc: ${o}; message: string }>(\`/${t.slug}/\${id}\`, { method: "DELETE" }),
205
205
  count: (args?: { where?: Record<string, any> }) =>
206
206
  request<{ totalDocs: number }>(\`/${t.slug}/count\${args ? "?" + qs(args) : ""}\`),
207
207
  },`}).join(`
208
208
  `)}
209
209
  };
210
210
  }
211
- `,r}function U(){return new commander.Command("generate").description("Generate TypeScript types from collection configs").option("-c, --config <path>","Path to config file or directory","./src/kyro").option("-o, --output <path>","Output file path","./src/types/kyro.d.ts").option("-w, --watch","Watch for changes and regenerate").option("--url <url>","URL of a running Kyro CMS instance (enables remote mode)").option("--api-key <key>","API key for authentication (required with --url)").action(async r=>{if(r.url){r.url||(console.error("\u274C --url is required when using --api"),process.exit(1)),r.apiKey||(console.error("\u274C --api-key is required when using --api"),process.exit(1));let s=_.resolve(r.output);try{let a=await G(r.url,r.apiKey),c=Q(a),d=_.join(s,"..");x.existsSync(d)||x.mkdirSync(d,{recursive:!0}),x.writeFileSync(s,c);}catch(a){console.error("\u274C Error:",a.message),process.exit(1);}return}let t=_.resolve(r.config),n=_.resolve(r.output);try{let s=await glob.glob(`${t}/**/*.{ts,js}`);s.length===0&&(console.error("\u274C No config files found at:",t),process.exit(1));let a=[];for(let l of s)try{let p=await import(l),f=Object.values(p).filter(m=>m&&m.slug&&m.fields);a.push(...f);}catch{console.warn(`\u26A0\uFE0F Could not parse: ${l}`);}a.length===0&&(console.error("\u274C No valid collection configs found"),process.exit(1));let c=K(a),d=_.join(n,"..");if(x.existsSync(d)||x.mkdirSync(d,{recursive:!0}),x.writeFileSync(n,c),r.watch){let{watch:l}=await import('fs');l(t,{recursive:!0},async(p,f)=>{let m=[];for(let S of s)try{let y=await import(S+`?t=${Date.now()}`),w=Object.values(y).filter(h=>h&&h.slug&&h.fields);m.push(...w);}catch{}let A=K(m);x.writeFileSync(n,A);});}}catch(s){console.error("\u274C Error:",s.message),process.exit(1);}})}function ee(e=3){return F__default.default.randomBytes(e).toString("hex")}function te(){return F__default.default.randomBytes(12).toString("base64").replace(/[^a-zA-Z0-9]/g,"").slice(0,16)}function j(){let e=new commander.Command("deploy").description("Deploy Kyro CMS");return e.command("cloudflare").description("Deploy to Cloudflare Workers with Assets").option("-d, --database <type>","Database type (d1|postgres)").option("-u, --database-url <url>","PostgreSQL connection string").option("-n, --name <name>","Cloudflare project name").option("-b, --r2-bucket <name>","R2 storage bucket name").option("-e, --email <email>","Initial Super Admin email").option("-p, --password <password>","Initial Super Admin password").option("-y, --non-interactive","Skip all prompts and use defaults").action(async r=>{console.log(o__default.default.cyan("==============================================================================")),console.log(o__default.default.bold("\u{1F680} Kyro CMS Cloudflare Deployment (Workers)")),console.log(o__default.default.cyan(`==============================================================================
212
- `));let t=ee(),n=te(),{database:s,databaseUrl:a,name:c,r2Bucket:d,email:l,password:p,nonInteractive:f}=r,m=`kyro-postgres-hd-${t}`;if(a&&!s&&(s="postgres"),!f&&process.stdout.isTTY){let i=q__namespace.createInterface({input:process$1.stdin,output:process$1.stdout});console.log(o__default.default.yellow.bold("\u{1F4CB} Setup Configuration")),console.log(o__default.default.dim(`Answer the prompts below to configure your deployment.
213
- `)),s||(console.log(o__default.default.cyan("\u250C\u2500 ")+o__default.default.bold("Select Database Infrastructure")),console.log(o__default.default.cyan("\u2502")+o__default.default.green.bold(" 1 ")+"Native Cloudflare D1 "+o__default.default.dim("\u2014 serverless SQLite, auto-provisioned ")+o__default.default.dim("\u2190 default")),console.log(o__default.default.cyan("\u2502")+o__default.default.dim(" 2 ")+"PostgreSQL "+o__default.default.dim("\u2014 via Cloudflare Hyperdrive")),console.log(o__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),s=(await i.question(o__default.default.magenta(" \u203A ")+"Enter number (default: 1): ")).trim()==="2"?"postgres":"d1"),s==="postgres"&&!a&&(console.log(o__default.default.cyan(`
214
- \u250C\u2500 `)+o__default.default.bold("PostgreSQL Connection URL")),console.log(o__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),a=await i.question(o__default.default.magenta(" \u203A ")+"postgresql://user:pass@host/db: ")),c||(console.log(o__default.default.cyan(`
215
- \u250C\u2500 `)+o__default.default.bold("Cloudflare Project Name")),console.log(o__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),c=(await i.question(o__default.default.magenta(" \u203A ")+o__default.default.dim(`(default: kyro-app-${t}): `))).trim()||`kyro-app-${t}`),d||(console.log(o__default.default.cyan(`
216
- \u250C\u2500 `)+o__default.default.bold("Cloudflare R2 Bucket Name")),console.log(o__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),d=(await i.question(o__default.default.magenta(" \u203A ")+o__default.default.dim(`(default: kyro-media-${t}): `))).trim()||`kyro-media-${t}`),l||(console.log(o__default.default.cyan(`
217
- \u250C\u2500 `)+o__default.default.bold("Initial Super Admin Email")),console.log(o__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),l=(await i.question(o__default.default.magenta(" \u203A ")+o__default.default.dim("(default: admin@kyro-cms.com): "))).trim()||"admin@kyro-cms.com"),p||(console.log(o__default.default.cyan(`
218
- \u250C\u2500 `)+o__default.default.bold("Initial Super Admin Password")),console.log(o__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")),p=(await i.question(o__default.default.magenta(" \u203A ")+o__default.default.dim("(default: auto-generate secure password): "))).trim()||n),i.close();}c=c||`kyro-app-${t}`,d=d||`kyro-media-${t}`,l=l||"admin@kyro-cms.com",p=p||n,s=s||"d1",console.log(o__default.default.cyan(`
219
- \u2699\uFE0F Configuration Summary:`)),console.log(` \u2022 Target Hosting: ${o__default.default.bold("Cloudflare Workers with Assets")}`),console.log(` \u2022 Database Mode : ${o__default.default.bold(s)}`),console.log(` \u2022 Project Name : ${o__default.default.bold(c)}`),console.log(` \u2022 R2 Bucket Name: ${o__default.default.bold(d)}`),console.log(` \u2022 Admin Email : ${o__default.default.bold(l)}`);let S=x__default.default.existsSync(___default.default.join(process.cwd(),"pnpm-lock.yaml"))?"pnpm":"npm",y=`${S} dlx wrangler`;console.log(`
220
- \u{1F50D} Checking Cloudflare Wrangler authentication...`);try{child_process.execSync(`${y} whoami`,{stdio:"ignore"}),console.log(o__default.default.green("\u2705 Cloudflare Wrangler Authenticated."));}catch{console.log(o__default.default.red("\u274C Cloudflare Wrangler authentication required.")),console.log(` Run ${o__default.default.bold(`${y} login`)} or set the ${o__default.default.bold("CLOUDFLARE_API_TOKEN")} env var.`),process.exit(1);}let w="",h="";if(s==="postgres"){a||(console.log(o__default.default.red("\u274C postgres mode requires a database URL.")),process.exit(1)),console.log(`
221
- \u26A1 Provisioning Cloudflare Hyperdrive (${m})...`);try{let i=child_process.execSync(`${y} hyperdrive list --json`,{stdio:"pipe"}).toString(),b=JSON.parse(i.slice(i.indexOf("["))).find(D=>D.name===m);b&&(h=b.id||b.uuid);}catch{}if(!h)try{let i=child_process.execSync(`${y} hyperdrive create "${m}" --connection-string="${a}" --json`,{stdio:"pipe"}).toString(),u=JSON.parse(i.slice(i.indexOf("{")));h=u.id||u.uuid;}catch{}console.log(o__default.default.green(`\u2705 Hyperdrive Provisioned (ID: ${h||"auto"})`));}else {let i=`${c}-d1`;console.log(`
222
- \u{1F5C2}\uFE0F Selecting or creating D1 database (${i})...`);try{let b=child_process.execSync(`${y} d1 create "${i}"`,{stdio:"pipe"}).toString().match(/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/i);b&&(w=b[1]);}catch{try{let b=child_process.execSync(`${y} d1 list --json`,{stdio:"pipe"}).toString(),k=JSON.parse(b).find(z=>z.name===i);k&&(w=k.id||k.uuid);}catch{}}console.log(o__default.default.green(`\u2705 Using D1 database: ${i} (ID: ${w})`));}console.log(`
223
- \u{1F5C4}\uFE0F Provisioning R2 Bucket '${d}'...`);try{child_process.execSync(`${y} r2 bucket create "${d}"`,{stdio:"ignore"});}catch{console.log(`\u2139\uFE0F Bucket '${d}' already exists.`);}try{child_process.execSync(`echo "y" | ${y} r2 bucket dev-url enable "${d}"`,{stdio:"ignore"});}catch{}console.log(`
211
+ `,r}function K(){return new commander.Command("generate").description("Generate TypeScript types from collection configs").option("-c, --config <path>","Path to config file or directory","./src/kyro").option("-o, --output <path>","Output file path","./src/types/kyro.d.ts").option("-w, --watch","Watch for changes and regenerate").option("--url <url>","URL of a running Kyro CMS instance (enables remote mode)").option("--api-key <key>","API key for authentication (required with --url)").action(async r=>{if(r.url){r.url||(console.error("\u274C --url is required when using --api"),process.exit(1)),r.apiKey||(console.error("\u274C --api-key is required when using --api"),process.exit(1));let s=k.resolve(r.output);try{let a=await Y(r.url,r.apiKey),c=G(a),p=k.join(s,"..");R.existsSync(p)||R.mkdirSync(p,{recursive:!0}),R.writeFileSync(s,c);}catch(a){console.error("\u274C Error:",a.message),process.exit(1);}return}let t=k.resolve(r.config),o=k.resolve(r.output);try{let s=await glob.glob(`${t}/**/*.{ts,js}`);s.length===0&&(console.error("\u274C No config files found at:",t),process.exit(1));let a=[];for(let d of s)try{let m=await import(d),f=Object.values(m).filter(u=>u&&u.slug&&u.fields);a.push(...f);}catch{console.warn(`\u26A0\uFE0F Could not parse: ${d}`);}a.length===0&&(console.error("\u274C No valid collection configs found"),process.exit(1));let c=O(a),p=k.join(o,"..");if(R.existsSync(p)||R.mkdirSync(p,{recursive:!0}),R.writeFileSync(o,c),r.watch){let{watch:d}=await import('fs');d(t,{recursive:!0},async(m,f)=>{let u=[];for(let S of s)try{let y=await import(S+`?t=${Date.now()}`),w=Object.values(y).filter(h=>h&&h.slug&&h.fields);u.push(...w);}catch{}let A=O(u);R.writeFileSync(o,A);});}}catch(s){console.error("\u274C Error:",s.message),process.exit(1);}})}function V(e=3){return q__default.default.randomBytes(e).toString("hex")}function Z(){return q__default.default.randomBytes(12).toString("base64").replace(/[^a-zA-Z0-9]/g,"").slice(0,16)}function F(){let e=new commander.Command("deploy").description("Deploy Kyro CMS");return e.command("cloudflare").description("Deploy to Cloudflare Workers with Assets").option("-d, --database <type>","Database type (d1|postgres)").option("-u, --database-url <url>","PostgreSQL connection string").option("-n, --name <name>","Cloudflare project name").option("-b, --r2-bucket <name>","R2 storage bucket name").option("-e, --email <email>","Initial Super Admin email").option("-p, --password <password>","Initial Super Admin password").option("-y, --non-interactive","Skip all prompts and use defaults").action(async r=>{console.log(n__default.default.cyan("==============================================================================")),console.log(n__default.default.bold("\u{1F680} Kyro CMS Cloudflare Deployment (Workers)")),console.log(n__default.default.cyan(`==============================================================================
212
+ `));let t=V(),o=Z(),{database:s,databaseUrl:a,name:c,r2Bucket:p,email:d,password:m,nonInteractive:f}=r,u=`kyro-postgres-hd-${t}`;if(a&&!s&&(s="postgres"),!f&&process.stdout.isTTY){console.log(n__default.default.yellow.bold("\u{1F4CB} Setup Configuration")),console.log(n__default.default.dim("Answer the prompts below to configure your deployment.\\n"));let i=[];s||i.push({type:"select",name:"database",message:n__default.default.cyan("\u250C\u2500 ")+n__default.default.bold("Select Database Infrastructure")+"\\n"+n__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")+"\\n"+n__default.default.magenta(" \u203A "),choices:[{title:"Native Cloudflare D1 (serverless SQLite, auto-provisioned)",value:"d1"},{title:"PostgreSQL (via Cloudflare Hyperdrive)",value:"postgres"}],initial:0}),s==="postgres"&&!a&&i.push({type:"text",name:"databaseUrl",message:n__default.default.cyan("\\n\u250C\u2500 ")+n__default.default.bold("PostgreSQL Connection URL")+"\\n"+n__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")+"\\n"+n__default.default.magenta(" \u203A ")}),c||i.push({type:"text",name:"name",message:n__default.default.cyan("\\n\u250C\u2500 ")+n__default.default.bold("Cloudflare Project Name")+"\\n"+n__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")+"\\n"+n__default.default.magenta(" \u203A ")+n__default.default.dim(`(default: kyro-app-${t})`),initial:`kyro-app-${t}`}),p||i.push({type:"text",name:"r2Bucket",message:n__default.default.cyan("\\n\u250C\u2500 ")+n__default.default.bold("Cloudflare R2 Bucket Name")+"\\n"+n__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")+"\\n"+n__default.default.magenta(" \u203A ")+n__default.default.dim(`(default: kyro-media-${t})`),initial:`kyro-media-${t}`}),d||i.push({type:"text",name:"email",message:n__default.default.cyan("\\n\u250C\u2500 ")+n__default.default.bold("Initial Super Admin Email")+"\\n"+n__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")+"\\n"+n__default.default.magenta(" \u203A ")+n__default.default.dim("(default: admin@kyro-cms.com)"),initial:"admin@kyro-cms.com"}),m||i.push({type:"text",name:"password",message:n__default.default.cyan("\\n\u250C\u2500 ")+n__default.default.bold("Initial Super Admin Password")+"\\n"+n__default.default.cyan("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500")+"\\n"+n__default.default.magenta(" \u203A ")+n__default.default.dim("(default: auto-generate secure password)")});let l=await J__default.default(i);l.database&&(s=l.database),l.databaseUrl&&(a=l.databaseUrl),l.name&&(c=l.name),l.r2Bucket&&(p=l.r2Bucket),l.email&&(d=l.email),l.password&&(m=l.password);}c=c||`kyro-app-${t}`,p=p||`kyro-media-${t}`,d=d||"admin@kyro-cms.com",m=m||o,s=s||"d1",console.log(n__default.default.cyan(`
213
+ \u2699\uFE0F Configuration Summary:`)),console.log(` \u2022 Target Hosting: ${n__default.default.bold("Cloudflare Workers with Assets")}`),console.log(` \u2022 Database Mode : ${n__default.default.bold(s)}`),console.log(` \u2022 Project Name : ${n__default.default.bold(c)}`),console.log(` \u2022 R2 Bucket Name: ${n__default.default.bold(p)}`),console.log(` \u2022 Admin Email : ${n__default.default.bold(d)}`);let S=R__default.default.existsSync(k__default.default.join(process.cwd(),"pnpm-lock.yaml"))?"pnpm":"npm",y=`${S} dlx wrangler`;console.log(`
214
+ \u{1F50D} Checking Cloudflare Wrangler authentication...`);try{child_process.execSync(`${y} whoami`,{stdio:"ignore"}),console.log(n__default.default.green("\u2705 Cloudflare Wrangler Authenticated."));}catch{console.log(n__default.default.red("\u274C Cloudflare Wrangler authentication required.")),console.log(` Run ${n__default.default.bold(`${y} login`)} or set the ${n__default.default.bold("CLOUDFLARE_API_TOKEN")} env var.`),process.exit(1);}let w="",h="";if(s==="postgres"){a||(console.log(n__default.default.red("\u274C postgres mode requires a database URL.")),process.exit(1)),console.log(`
215
+ \u26A1 Provisioning Cloudflare Hyperdrive (${u})...`);try{let i=child_process.execSync(`${y} hyperdrive list --json`,{stdio:"pipe"}).toString(),b=JSON.parse(i.slice(i.indexOf("["))).find(D=>D.name===u);b&&(h=b.id||b.uuid);}catch{}if(!h)try{let i=child_process.execSync(`${y} hyperdrive create "${u}" --connection-string="${a}" --json`,{stdio:"pipe"}).toString(),l=JSON.parse(i.slice(i.indexOf("{")));h=l.id||l.uuid;}catch{}console.log(n__default.default.green(`\u2705 Hyperdrive Provisioned (ID: ${h||"auto"})`));}else {let i=`${c}-d1`;console.log(`
216
+ \u{1F5C2}\uFE0F Selecting or creating D1 database (${i})...`);try{let b=child_process.execSync(`${y} d1 create "${i}"`,{stdio:"pipe"}).toString().match(/([a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/i);b&&(w=b[1]);}catch{try{let b=child_process.execSync(`${y} d1 list --json`,{stdio:"pipe"}).toString(),_=JSON.parse(b).find(W=>W.name===i);_&&(w=_.id||_.uuid);}catch{}}console.log(n__default.default.green(`\u2705 Using D1 database: ${i} (ID: ${w})`));}console.log(`
217
+ \u{1F5C4}\uFE0F Provisioning R2 Bucket '${p}'...`);try{child_process.execSync(`${y} r2 bucket create "${p}"`,{stdio:"ignore"});}catch{console.log(`\u2139\uFE0F Bucket '${p}' already exists.`);}try{child_process.execSync(`echo "y" | ${y} r2 bucket dev-url enable "${p}"`,{stdio:"ignore"});}catch{}console.log(`
224
218
  \u2699\uFE0F Generating wrangler.toml...`);let E=`name = "${c}"
225
219
  compatibility_date = "2026-01-01"
226
220
  compatibility_flags = ["nodejs_compat"]
@@ -236,9 +230,9 @@ database_id = "${w}"
236
230
  `,E+=`
237
231
  [[r2_buckets]]
238
232
  binding = "STORAGE_BUCKET"
239
- bucket_name = "${d}"
240
- `,x__default.default.writeFileSync(___default.default.join(process.cwd(),"wrangler.toml"),E,"utf8"),console.log(`
241
- \u{1F5C3}\uFE0F Running schema migrations & seeding super admin...`);let W=`import bcrypt from 'bcryptjs'; console.log(bcrypt.hashSync('${p}', 10));`,I="";try{I=child_process.execSync(`node -e "${W}"`,{stdio:"pipe"}).toString().trim();}catch{}if(s==="postgres"){try{child_process.execSync(`DATABASE_URL="${a}" npx drizzle-kit push --force`,{stdio:"ignore"});}catch{}let i=`
233
+ bucket_name = "${p}"
234
+ `,R__default.default.writeFileSync(k__default.default.join(process.cwd(),"wrangler.toml"),E,"utf8"),console.log(`
235
+ \u{1F5C3}\uFE0F Running schema migrations & seeding super admin...`);let B=`import bcrypt from 'bcryptjs'; console.log(bcrypt.hashSync('${m}', 10));`,I="";try{I=child_process.execSync(`node -e "${B}"`,{stdio:"pipe"}).toString().trim();}catch{}if(s==="postgres"){try{child_process.execSync(`DATABASE_URL="${a}" npx drizzle-kit push --force`,{stdio:"ignore"});}catch{}let i=`
242
236
  import postgres from 'postgres';
243
237
  import bcrypt from 'bcryptjs';
244
238
  const sql = postgres(process.env.DATABASE_URL || '${a}');
@@ -246,10 +240,10 @@ bucket_name = "${d}"
246
240
  try {
247
241
  await sql\`CREATE TABLE IF NOT EXISTS users (id UUID PRIMARY KEY DEFAULT gen_random_uuid(), email VARCHAR(255) NOT NULL, password_hash VARCHAR(255), role VARCHAR(50) DEFAULT 'customer', email_verified BOOLEAN DEFAULT true, created_at TIMESTAMP DEFAULT NOW(), updated_at TIMESTAMP DEFAULT NOW())\`;
248
242
  await sql\`CREATE UNIQUE INDEX IF NOT EXISTS users_email_idx ON users (email)\`;
249
- const existing = await sql\`SELECT id FROM users WHERE email = '${l}'\`;
243
+ const existing = await sql\`SELECT id FROM users WHERE email = '${d}'\`;
250
244
  if (existing.length === 0) {
251
- const hash = bcrypt.hashSync('${p}', 10);
252
- await sql\`INSERT INTO users (email, password_hash, role, email_verified) VALUES ('${l}', \\\${hash}, 'super_admin', true)\`;
245
+ const hash = bcrypt.hashSync('${m}', 10);
246
+ await sql\`INSERT INTO users (email, password_hash, role, email_verified) VALUES ('${d}', \\\${hash}, 'super_admin', true)\`;
253
247
  console.log(' \u2705 PostgreSQL Super Admin Configured');
254
248
  }
255
249
  } catch (e) {
@@ -283,13 +277,13 @@ bucket_name = "${d}"
283
277
  created_at TEXT DEFAULT CURRENT_TIMESTAMP
284
278
  );
285
279
  INSERT OR IGNORE INTO users (id, email, password_hash, role, email_verified)
286
- VALUES ('admin-super-1', '${l}', '${I}', 'super_admin', 1);
287
- `;try{child_process.execSync(`${y} d1 execute "${c}-d1" --remote --command="${i.replace(/\n/g," ")}"`,{stdio:"ignore"}),console.log(o__default.default.green(" \u2705 D1 Schema Migrated & Super Admin Configured."));}catch{}}console.log(`
288
- \u{1F6E0}\uFE0F Building for Cloudflare...`);try{child_process.execSync(`${S} run build`,{stdio:"inherit"});}catch{console.log(o__default.default.red(`
280
+ VALUES ('admin-super-1', '${d}', '${I}', 'super_admin', 1);
281
+ `;try{child_process.execSync(`${y} d1 execute "${c}-d1" --remote --command="${i.replace(/\n/g," ")}"`,{stdio:"ignore"}),console.log(n__default.default.green(" \u2705 D1 Schema Migrated & Super Admin Configured."));}catch{}}console.log(`
282
+ \u{1F6E0}\uFE0F Building for Cloudflare...`);try{child_process.execSync(`${S} run build`,{stdio:"inherit"});}catch{console.log(n__default.default.red(`
289
283
  \u274C Build Failed. Check the output above.`)),process.exit(1);}console.log(`
290
- \u2601\uFE0F Deploying to Cloudflare Workers...`),x__default.default.existsSync(___default.default.join(process.cwd(),".wrangler"))&&x__default.default.rmSync(___default.default.join(process.cwd(),".wrangler"),{recursive:true,force:true});try{child_process.execSync(`${y} deploy`,{stdio:"inherit"}),console.log(o__default.default.cyan(`
291
- ==============================================================================`)),console.log(o__default.default.green.bold("\u{1F389} Kyro CMS Deployment Successful!")),console.log(o__default.default.cyan("==============================================================================")),console.log(`
292
- Super Admin Credentials:`),console.log(` \u2022 Email : ${o__default.default.bold(l)}`),console.log(` \u2022 Password: ${o__default.default.bold(p)}`),console.log(`
284
+ \u2601\uFE0F Deploying to Cloudflare Workers...`),R__default.default.existsSync(k__default.default.join(process.cwd(),".wrangler"))&&R__default.default.rmSync(k__default.default.join(process.cwd(),".wrangler"),{recursive:true,force:true});try{child_process.execSync(`${y} deploy`,{stdio:"inherit"}),console.log(n__default.default.cyan(`
285
+ ==============================================================================`)),console.log(n__default.default.green.bold("\u{1F389} Kyro CMS Deployment Successful!")),console.log(n__default.default.cyan("==============================================================================")),console.log(`
286
+ Super Admin Credentials:`),console.log(` \u2022 Email : ${n__default.default.bold(d)}`),console.log(` \u2022 Password: ${n__default.default.bold(m)}`),console.log(`
293
287
  Save these credentials! This is the only time the password is displayed.
294
- `);}catch{console.log(o__default.default.cyan(`
295
- ==============================================================================`)),console.log(o__default.default.red.bold("\u274C Kyro CMS Cloudflare Deployment Failed!")),console.log(o__default.default.cyan("==============================================================================")),console.log("Inspect the Wrangler output above for error details."),process.exit(1);}}),e}var ie=url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),ce=_.dirname(ie),B="0.1.0";try{B=JSON.parse(x.readFileSync(_.join(ce,"../../package.json"),"utf-8")).version;}catch{}var T=new commander.Command;T.name("kyro").description("Kyro CMS - Astro-native headless CMS").version(B);T.command("dev").description("Start Kyro CMS development server").option("-p, --port <port>","Port to run on","4321").option("-h, --host <host>","Host to bind to","localhost").action(async e=>{let{exec:r}=await import('child_process'),t=r(`astro dev --port ${e.port} --host ${e.host}`,{env:{...process.env,NODE_NO_WARNINGS:"1"}});t.stdout?.on("data",n=>process.stdout.write(n)),t.stderr?.on("data",n=>process.stderr.write(n)),process.on("SIGINT",()=>{t.kill("SIGINT"),process.exit(0);}),process.on("SIGTERM",()=>{t.kill("SIGTERM"),process.exit(0);});});T.addCommand(U());T.addCommand(j());var $=T.command("db").description("Database management commands");$.command("generate").description("Generate migrations from schema").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit generate",(r,t,n)=>{r&&(console.error("\u274C Generation failed:",r.message),process.exit(1));});});$.command("migrate").description("Run database migrations").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit migrate",(r,t,n)=>{r&&(console.error("\u274C Migration failed:",r.message),process.exit(1));});});$.command("push").description("Push schema to database (development)").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit push",(r,t,n)=>{r&&(console.error("\u274C Push failed:",r.message),process.exit(1));});});$.command("seed").description("Seed database with initial data").action(async()=>{let{exec:e}=await import('child_process');e("npx tsx src/database/drizzle/seed.ts",(r,t,n)=>{r&&(console.error("\u274C Seeding failed:",r.message),process.exit(1));});});$.command("studio").description("Open Drizzle Studio").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit studio",(r,t,n)=>{r&&(console.error("\u274C Studio failed:",r.message),process.exit(1));});});var le=T.command("auth").description("Authentication management commands");le.command("bootstrap").description("Create initial admin user").option("-e, --email <email>","Admin email",process.env.KYRO_ADMIN_EMAIL).option("-p, --password <password>","Admin password",process.env.KYRO_ADMIN_PASSWORD).option("-r, --role <role>","Admin role",process.env.KYRO_ADMIN_ROLE||"admin").action(async e=>{(!e.email||!e.password)&&(console.error("\u274C Email and password are required. Set KYRO_ADMIN_EMAIL and KYRO_ADMIN_PASSWORD env vars or use -e and -p options."),process.exit(1));try{let{bootstrapAdmin:r}=await import('../bootstrap-ETJ6QNGR.cjs'),t=process.env.DATABASE_URL||"",n=t.toLowerCase().startsWith("postgres://")||t.toLowerCase().startsWith("postgresql://"),s=t.toLowerCase().startsWith("mongodb://")||t.toLowerCase().startsWith("mongodb+srv://"),a=!t||t.includes(".db")||t.includes("sqlite")||t.includes("file:"),c;if(n){let{PostgresAuthAdapter:l}=await import('../postgres-auth-adapter-JKDYYULH.cjs'),{drizzle:p}=await import('drizzle-orm/postgres-js'),{default:f}=await import('postgres'),m=f(t,{max:1,onnotice:()=>{}}),A=p(m);c=new l({db:A});}else if(s){let{MongoDBAuthAdapter:l}=await import('../mongo-auth-adapter-JVE5M3S4.cjs'),p=await import('mongodb'),f=new p.MongoClient(t);await f.connect();let m=f.db();c=new l({db:m});}else {let{SQLiteAuthAdapter:l}=await import('../sqlite-adapter-PLD57WOH.cjs'),p=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";c=new l({path:p});}c.connect&&await c.connect();let d=await r({authAdapter:c,adminEmail:e.email,adminPassword:e.password,adminRole:e.role});c.disconnect&&await c.disconnect(),d.success||(console.error("\u274C Failed to create admin:",d.error),process.exit(1));}catch(r){console.error("\u274C Bootstrap failed:",r),process.exit(1);}});T.command("health").description("Check system health").action(async()=>{let e=process.env.DATABASE_URL||"",r=e.toLowerCase().startsWith("postgres://")||e.toLowerCase().startsWith("postgresql://"),t=e.toLowerCase().startsWith("mongodb://")||e.toLowerCase().startsWith("mongodb+srv://"),n=!e||e.includes(".db")||e.includes("sqlite")||e.includes("file:");if(r)try{let{default:s}=await import('postgres'),a=s(e,{max:1,onnotice:()=>{}});await a.unsafe("SELECT 1"),await a.end();}catch{}else if(t)try{let s=await import('mongodb'),a=new s.MongoClient(e);await a.connect(),await a.db().admin().ping(),await a.close();}catch{}else if(n)try{let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db",{existsSync:a}=await import('fs');a(s);}catch{}});T.parse();process.argv.slice(2).length||T.outputHelp();
288
+ `);}catch{console.log(n__default.default.cyan(`
289
+ ==============================================================================`)),console.log(n__default.default.red.bold("\u274C Kyro CMS Cloudflare Deployment Failed!")),console.log(n__default.default.cyan("==============================================================================")),console.log("Inspect the Wrangler output above for error details."),process.exit(1);}}),e}var se=url.fileURLToPath((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href))),ae=k.dirname(se),j="0.1.0";try{j=JSON.parse(R.readFileSync(k.join(ae,"../../package.json"),"utf-8")).version;}catch{}var T=new commander.Command;T.name("kyro").description("Kyro CMS - Astro-native headless CMS").version(j);T.command("dev").description("Start Kyro CMS development server").option("-p, --port <port>","Port to run on","4321").option("-h, --host <host>","Host to bind to","localhost").action(async e=>{let{exec:r}=await import('child_process'),t=r(`astro dev --port ${e.port} --host ${e.host}`,{env:{...process.env,NODE_NO_WARNINGS:"1"}});t.stdout?.on("data",o=>process.stdout.write(o)),t.stderr?.on("data",o=>process.stderr.write(o)),process.on("SIGINT",()=>{t.kill("SIGINT"),process.exit(0);}),process.on("SIGTERM",()=>{t.kill("SIGTERM"),process.exit(0);});});T.addCommand(K());T.addCommand(F());var $=T.command("db").description("Database management commands");$.command("generate").description("Generate migrations from schema").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit generate",(r,t,o)=>{r&&(console.error("\u274C Generation failed:",r.message),process.exit(1));});});$.command("migrate").description("Run database migrations").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit migrate",(r,t,o)=>{r&&(console.error("\u274C Migration failed:",r.message),process.exit(1));});});$.command("push").description("Push schema to database (development)").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit push",(r,t,o)=>{r&&(console.error("\u274C Push failed:",r.message),process.exit(1));});});$.command("seed").description("Seed database with initial data").action(async()=>{let{exec:e}=await import('child_process');e("npx tsx src/database/drizzle/seed.ts",(r,t,o)=>{r&&(console.error("\u274C Seeding failed:",r.message),process.exit(1));});});$.command("studio").description("Open Drizzle Studio").action(async()=>{let{exec:e}=await import('child_process');e("npx drizzle-kit studio",(r,t,o)=>{r&&(console.error("\u274C Studio failed:",r.message),process.exit(1));});});var ie=T.command("auth").description("Authentication management commands");ie.command("bootstrap").description("Create initial admin user").option("-e, --email <email>","Admin email",process.env.KYRO_ADMIN_EMAIL).option("-p, --password <password>","Admin password",process.env.KYRO_ADMIN_PASSWORD).option("-r, --role <role>","Admin role",process.env.KYRO_ADMIN_ROLE||"admin").action(async e=>{(!e.email||!e.password)&&(console.error("\u274C Email and password are required. Set KYRO_ADMIN_EMAIL and KYRO_ADMIN_PASSWORD env vars or use -e and -p options."),process.exit(1));try{let{bootstrapAdmin:r}=await import('../bootstrap-BGO2NFKB.cjs'),t=process.env.DATABASE_URL||"",o=t.toLowerCase().startsWith("postgres://")||t.toLowerCase().startsWith("postgresql://"),s=t.toLowerCase().startsWith("mongodb://")||t.toLowerCase().startsWith("mongodb+srv://"),a=!t||t.includes(".db")||t.includes("sqlite")||t.includes("file:"),c;if(o){let{PostgresAuthAdapter:d}=await import('../postgres-auth-adapter-JKDYYULH.cjs'),{drizzle:m}=await import('drizzle-orm/postgres-js'),{default:f}=await import('postgres'),u=f(t,{max:1,onnotice:()=>{}}),A=m(u);c=new d({db:A});}else if(s){let{MongoDBAuthAdapter:d}=await import('../mongo-auth-adapter-JVE5M3S4.cjs'),m=await import('mongodb'),f=new m.MongoClient(t);await f.connect();let u=f.db();c=new d({db:u});}else {let{SQLiteAuthAdapter:d}=await import('../sqlite-adapter-PLD57WOH.cjs'),m=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db";c=new d({path:m});}c.connect&&await c.connect();let p=await r({authAdapter:c,adminEmail:e.email,adminPassword:e.password,adminRole:e.role});c.disconnect&&await c.disconnect(),p.success||(console.error("\u274C Failed to create admin:",p.error),process.exit(1));}catch(r){console.error("\u274C Bootstrap failed:",r),process.exit(1);}});T.command("health").description("Check system health").action(async()=>{let e=process.env.DATABASE_URL||"",r=e.toLowerCase().startsWith("postgres://")||e.toLowerCase().startsWith("postgresql://"),t=e.toLowerCase().startsWith("mongodb://")||e.toLowerCase().startsWith("mongodb+srv://"),o=!e||e.includes(".db")||e.includes("sqlite")||e.includes("file:");if(r)try{let{default:s}=await import('postgres'),a=s(e,{max:1,onnotice:()=>{}});await a.unsafe("SELECT 1"),await a.end();}catch{}else if(t)try{let s=await import('mongodb'),a=new s.MongoClient(e);await a.connect(),await a.db().admin().ping(),await a.close();}catch{}else if(o)try{let s=process.env.KYRO_AUTH_DB_PATH||"./data/auth.db",{existsSync:a}=await import('fs');a(s);}catch{}});T.parse();process.argv.slice(2).length||T.outputHelp();