@kyro-cms/core 0.12.62 → 0.12.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -4
- package/dist/{WebhookService-DgIx21X-.d.cts → WebhookService-B-jb55_P.d.cts} +1 -1
- package/dist/{WebhookService-CZf_na-J.d.ts → WebhookService-Bue85CZq.d.ts} +1 -1
- package/dist/api-handler-graphql.cjs +1 -1
- package/dist/api-handler-graphql.js +1 -1
- package/dist/api-handler-trpc.cjs +1 -1
- package/dist/api-handler-trpc.js +1 -1
- package/dist/api-handler.cjs +1 -1
- package/dist/api-handler.js +1 -1
- package/dist/{base-7vJMzr4V.d.ts → base-CTeNj4rw.d.ts} +1 -1
- package/dist/{base-DDEmdRqV.d.cts → base-CU2tjpsX.d.cts} +1 -1
- package/dist/chunk-3WSFG6DS.js +2 -0
- package/dist/chunk-4OMQURN7.js +3 -0
- package/dist/chunk-6424BWOB.cjs +120 -0
- package/dist/{chunk-JU3UAZRY.cjs → chunk-DFDL5JIO.cjs} +13 -13
- package/dist/{chunk-4FHWIGHO.cjs → chunk-ILSBJI77.cjs} +3 -3
- package/dist/chunk-QE7LORN4.js +121 -0
- package/dist/{chunk-26MOA3HJ.js → chunk-VZQWWZLY.js} +3 -3
- package/dist/chunk-W2XYBPEJ.js +133 -0
- package/dist/{chunk-LOP464VR.cjs → chunk-YJZTUT7I.cjs} +1 -1
- package/dist/chunk-ZQETJ4T4.cjs +2 -0
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/drizzle/index.cjs +1 -1
- package/dist/drizzle/index.d.cts +2 -2
- package/dist/drizzle/index.d.ts +2 -2
- package/dist/drizzle/index.js +1 -1
- package/dist/graphql/index.d.cts +2 -2
- package/dist/graphql/index.d.ts +2 -2
- package/dist/index-DowyndWK.d.ts +105 -0
- package/dist/index-HNBjfQpn.d.cts +105 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +8 -7
- package/dist/index.d.ts +8 -7
- package/dist/index.js +2 -2
- package/dist/mongodb/index.d.cts +2 -2
- package/dist/mongodb/index.d.ts +2 -2
- package/dist/rest/index.cjs +1 -1
- package/dist/rest/index.d.cts +3 -3
- package/dist/rest/index.d.ts +3 -3
- package/dist/rest/index.js +1 -1
- package/dist/templates/index.d.cts +1 -1
- package/dist/templates/index.d.ts +1 -1
- package/dist/trpc/index.d.cts +2 -2
- package/dist/trpc/index.d.ts +2 -2
- package/dist/{types-CYGXsNcJ.d.ts → types-COokblgr.d.ts} +181 -1
- package/dist/{types-DOKMyC3y.d.cts → types-ComJeXGL.d.cts} +181 -1
- package/package.json +2 -2
- package/dist/chunk-6QWX3DEB.cjs +0 -120
- package/dist/chunk-AMGJ5AFH.cjs +0 -1
- package/dist/chunk-QDBGBDCT.js +0 -2
- package/dist/chunk-RDFGJHEG.js +0 -2
- package/dist/chunk-RILJCH6H.js +0 -121
- package/dist/chunk-VJODUKKM.js +0 -133
- package/dist/index-BJ1rwHxk.d.cts +0 -284
- package/dist/index-BTjlptCL.d.ts +0 -284
package/dist/chunk-VJODUKKM.js
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
import {c,a as a$3,b,e,h}from'./chunk-JV4HJBXW.js';import {f,a as a$5}from'./chunk-637PTUHF.js';import {n,M as M$1,p,q,o,w as w$1,E,s,t,u,v}from'./chunk-HRAY65XH.js';import {a}from'./chunk-2HA6EKXX.js';import {ia,oa,fa,ma,$,ha,ca,pa,ra,J}from'./chunk-3NSZZCOJ.js';import {a as a$1,c as c$1,b as b$1,d}from'./chunk-SLMIYECU.js';import {a as a$2}from'./chunk-P6JITOFF.js';import {a as a$4}from'./chunk-VVVCCB6R.js';import {g}from'./chunk-Y2YAKDEQ.js';import {randomBytes}from'crypto';import {mkdir}from'fs/promises';import {resolve,dirname}from'path';import {createRequire}from'module';if (typeof window === "undefined") { const { createRequire } = await import(/* @vite-ignore */ 'module'); createRequire(import.meta.url); }
|
|
2
|
-
g();var x;function Ee(){return x||(x=createRequire("file:///")("node:sqlite").DatabaseSync,x)}function we(){return process.env.DB_TYPE==="postgres"?"postgres":"sqlite"}function de(){return randomBytes(16).toString("hex")}async function Ie(){let f$1=we();if(f$1==="sqlite"){let r=resolve(process.cwd(),"data","kyro.db");await mkdir(dirname(r),{recursive:true});let a=new(Ee())(r);return a.exec("PRAGMA journal_mode = WAL"),{db:a,dialect:f$1,genId:de}}let t=process.env.DATABASE_URL||"postgresql://postgres:postgres@localhost:5432/kyro_cms",i=parseInt(process.env.DB_POOL_MAX||"10",10),e=process.env.DB_SSL==="true",s=a(t,{max:i,ssl:e?"require":false,onnotice:()=>{}});return {db:f(s),dialect:f$1,genId:de}}async function $e(f,t){}async function xe(f){let{roles:t}=await import('./schema-YFMSJK2P.js');await f.insert(t).values({name:"super_admin",level:100,inherits:[],description:"Full system access across all tenants",isSystem:true}).onConflictDoNothing();}g();function w(f,t="postgres"){switch(f.type){case "text":case "email":case "password":case "color":case "icon":return t==="sqlite"?"text":"varchar";case "textarea":case "code":case "markdown":case "secret":return "text";case "number":return f.integer?"integer":"decimal";case "checkbox":return "boolean";case "date":return "timestamp";case "select":case "radio":return t==="sqlite"?"text":"varchar";case "richtext":case "json":case "array":case "group":case "blocks":case "row":case "collapsible":case "tabs":return "jsonb";case "relationship":return t==="sqlite"?"text":"varchar";case "upload":return "jsonb";default:return "jsonb"}}function De(f,t="postgres"){let i=f.slug.replace(/-/g,"_"),e=[];e.push(`export const ${i} = pgTable('${i}', {`),e.push(" id: uuid('id').primaryKey().defaultRandom(),");for(let s of f.fields){if(s.name==="id"||s.type==="password")continue;let n=w(s,t),r=s.required,a=` ${s.name}: pg.${n}('${s.name}')`;s.unique&&(a+=".unique()"),r||(a+=".nullable()"),s.defaultValue!==void 0&&(typeof s.defaultValue=="string"?a+=`.default('${s.defaultValue}')`:typeof s.defaultValue=="boolean"?a+=`.default(${s.defaultValue})`:a+=`.default(sql\`${JSON.stringify(s.defaultValue)}\`)`),a+=",",e.push(a);}return f.timestamps&&(e.push(" createdAt: pg.timestamp('created_at').defaultNow(),"),e.push(" updatedAt: pg.timestamp('updated_at').defaultNow(),")),e.push(` status: ${t==="sqlite"?"sqlite":"pg"}.varchar('status').default('draft'),`),e.push(` hasDraft: ${t==="sqlite"?"sqlite":"pg"}.boolean('hasDraft').default(false),`),e.push("});"),e.join(`
|
|
3
|
-
`)}function M(f,t){return Array.isArray(f)?f.map(i=>{if(!i||typeof i!="object")return i;let e=i.data?{...i.data}:void 0;if(!e)return i;let s=t.find(n=>n.slug===i.type||n.slug===i.slug);if(!s||!Array.isArray(s.fields))return i;for(let n of s.fields){if(n.name&&(n.type==="upload"||n.type==="image")&&e[n.name]){let r=e[n.name];Array.isArray(r)?e[n.name]=r.map(a=>typeof a=="string"?{id:a}:a):typeof r=="string"&&(e[n.name]={id:r});}if(n.type==="blocks"&&n.name&&e[n.name]){let r=n.blocks||[];e[n.name]=M(e[n.name],r);}}return {...i,data:e}}):f}g();function _(f){if(typeof f!="string")return f;let t=f.replace(/-/g,"").toLowerCase();return t.length===32?`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`:f}var P=class extends a$1{client;schema;_schemaEnsured=false;dialect;connectionString;versionsTableReady=false;rawClient;constructor(t){if(super(),this.schema=t.schema||{},t.connectionString){this.connectionString=t.connectionString;let i=t.connectionString.toLowerCase();i.startsWith("postgres://")||i.startsWith("postgresql://")?this.dialect="postgres":i.includes(".db")||i.includes("sqlite")||i.includes("file:")?this.dialect="sqlite":this.dialect=t.type||"postgres";}else this.rawClient=t.client,this.client=t.client,this.dialect=t.type||"sqlite";}prepareData(t,i){let e=super.prepareData(t,i);e.createdAt&&typeof e.createdAt=="string"&&(e.createdAt=new Date(e.createdAt)),e.updatedAt&&typeof e.updatedAt=="string"&&(e.updatedAt=new Date(e.updatedAt));for(let s of i.fields)if(s.type==="date"&&s.name){let n=e[s.name];n&&typeof n=="string"&&(e[s.name]=new Date(n));}for(let s of i.fields){let r=w(s,this.dialect)==="jsonb";if(s.type==="tabs"&&"tabs"in s&&s.name){let a=t[s.name];if(a&&typeof a=="object"){let o={};for(let[c,d]of Object.entries(a)){let u=s.tabs.flatMap(g=>g.fields).find(g=>g.name===c);(u?.type==="upload"||u?.type==="image"||u?.type==="list"||u?.type==="relationship-block")&&d?o[c]=Array.isArray(d)||typeof d=="object"?JSON.stringify(d):d:o[c]=d;}e[s.name]=this.dialect==="sqlite"||!r?JSON.stringify(o):o;}}else if(r&&s.name&&t[s.name]!==void 0&&t[s.name]!==null)e[s.name]=this.dialect==="sqlite"?JSON.stringify(t[s.name]):t[s.name];else if((s.type==="upload"||s.type==="image"||s.type==="list"||s.type==="relationship-block")&&s.name){let a=t[s.name];a!=null&&(e[s.name]=this.dialect==="sqlite"||!r?typeof a=="string"?a:JSON.stringify(a):a);}}for(let s of i.fields)if(s.name&&e[s.name]===""){let n=w(s,this.dialect);(n==="timestamp"||n==="jsonb"||n==="decimal"||n==="integer"||n==="numeric"||n==="boolean")&&(e[s.name]=null);}return e}async connect(){if(this.connectionString&&!this.client){if(this.dialect==="postgres"){let t,i;try{t=(await import('./src-QBADSZV4.js')).default,i=(await import('./postgres-js-WE3NBRFO.js')).drizzle;}catch{a$2(["postgres","drizzle-orm"]),t=(await import('./src-QBADSZV4.js')).default,i=(await import('./postgres-js-WE3NBRFO.js')).drizzle;}let e=t(this.connectionString,{onnotice:()=>{}});this.client=i(e,{schema:this.schema});}else if(this.dialect==="sqlite"){let t,i;try{t=(await import('better-sqlite3')).default,i=(await import('./better-sqlite3-B34RIU4C.js')).drizzle;}catch{a$2(["better-sqlite3","drizzle-orm"]),t=(await import('better-sqlite3')).default,i=(await import('./better-sqlite3-B34RIU4C.js')).drizzle;}let e=new t(this.connectionString.replace("file:",""));this.client=i(e,{schema:this.schema});}}if(this.rawClient&&typeof this.rawClient.prepare=="function"&&typeof this.client?.select!="function"){let{drizzle:t}=await import('./d1-HPB6B253.js');this.client=t(this.rawClient,{schema:this.schema});}this.connected=true;}async init(t,i=[]){if(await super.init(t,i),(this.connectionString&&!this.client||this.rawClient&&typeof this.client?.select!="function")&&await this.connect(),this.client&&!this._schemaEnsured){for(let s of t){let n=this.getTableName(s.slug);this.schema[n]||(this.schema[n]=this.createTableFromConfig(s));}await this.ensureCollectionTables(t);let e=i.map(s=>({slug:`_globals_${s.slug}`,fields:s.fields,label:s.label}));for(let s of e){let n=this.getTableName(s.slug);this.schema[n]||(this.schema[n]=this.createTableFromConfig(s,true)),this.collections.has(s.slug)||this.collections.set(s.slug,s);}await this.ensureCollectionTables(e),this._schemaEnsured=true;}}createTableFromConfig(t,i=false){let e$1=this.getTableName(t.slug),s={id:i?ia("id").primaryKey():oa("id").primaryKey().defaultRandom()};for(let n of t.fields){if(!n.name||n.name==="id"||n.type==="password")continue;let r=w(n,this.dialect),a=n.name.replace(/-/g,"_"),o=a.replace(/([A-Z])/g,"_$1").toLowerCase(),c$1;if(this.dialect==="sqlite")switch(r){case "varchar":case "text":c$1=c(o);break;case "integer":c$1=a$3(o);break;case "decimal":case "numeric":c$1=b(o);break;case "boolean":c$1=a$3(o,{mode:"boolean"});break;case "timestamp":c$1=c(o);break;case "jsonb":c$1=c(o);break;default:c$1=c(o);}else switch(r){case "varchar":c$1=pa(o,{length:255});break;case "integer":c$1=ca(o);break;case "decimal":c$1=ha(o);break;case "boolean":c$1=$(o);break;case "timestamp":c$1=ma(o);break;case "jsonb":c$1=fa(o);break;default:c$1=ia(o);}n.required||(c$1=c$1.default(null)),s[a]=c$1;}return s.createdAt||(s.createdAt=this.dialect==="sqlite"?c("created_at").default(new Date().toISOString()):ma("created_at").defaultNow()),s.updatedAt||(s.updatedAt=this.dialect==="sqlite"?c("updated_at").default(new Date().toISOString()):ma("updated_at").defaultNow()),e$1!=="users"&&e$1!=="audit_logs"&&(s.status||(s.status=this.dialect==="sqlite"?c("status").default("draft"):pa("status",{length:20}).default("draft")),s.hasDraft||(s.hasDraft=this.dialect==="sqlite"?a$3("hasDraft",{mode:"boolean"}).default(false):$("hasDraft").default(false))),this.dialect==="sqlite"?e(e$1,s):ra(e$1,s)}async ensureCollectionTables(t){let i=[];for(let e of t){let s=e.slug.startsWith("_globals_"),n=this.getTableName(e.slug),r=this.generateCreateColumns(e),a=e.fields.some(u=>u.name==="createdAt"),o=e.fields.some(u=>u.name==="updatedAt"),c=e.fields.some(u=>u.name==="status"),d=e.fields.some(u=>u.name==="hasDraft");if(this.dialect==="postgres"){let u=s?'"id" TEXT PRIMARY KEY':'"id" UUID PRIMARY KEY DEFAULT gen_random_uuid()';i.push(`
|
|
4
|
-
CREATE TABLE IF NOT EXISTS "${n}" (
|
|
5
|
-
${u},
|
|
6
|
-
${r}
|
|
7
|
-
${a?"":'"created_at" TIMESTAMP NOT NULL DEFAULT NOW(),'}
|
|
8
|
-
${o?"":'"updated_at" TIMESTAMP NOT NULL DEFAULT NOW(),'}
|
|
9
|
-
${c?"":`"status" VARCHAR(20) DEFAULT 'draft',`}
|
|
10
|
-
${d?"":'"hasDraft" BOOLEAN DEFAULT false'}
|
|
11
|
-
)
|
|
12
|
-
`);}else i.push(`
|
|
13
|
-
CREATE TABLE IF NOT EXISTS "${n}" (
|
|
14
|
-
"id" TEXT PRIMARY KEY,
|
|
15
|
-
${r}
|
|
16
|
-
${a?"":`"created_at" TEXT NOT NULL DEFAULT (datetime('now')),`}
|
|
17
|
-
${o?"":`"updated_at" TEXT NOT NULL DEFAULT (datetime('now')),`}
|
|
18
|
-
${c?"":`"status" TEXT DEFAULT 'draft',`}
|
|
19
|
-
${d?"":'"hasDraft" INTEGER DEFAULT 0'}
|
|
20
|
-
)
|
|
21
|
-
`);}if(i.length>0)if(this.dialect==="postgres")await this.executeRaw(J.raw(i.join(`;
|
|
22
|
-
`)));else for(let e of i)await this.executeRaw(J.raw(e));for(let e of t){let s=this.getTableName(e.slug);s==="users"||s==="audit_logs"||await this.syncTableColumns(e,s);}}getColumnSqlDefinition(t,i){let e=w(t,i),s=t.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),n=this.columnSqlType(e,i);return `"${s}" ${n} DEFAULT NULL`}columnSqlType(t,i){if(i==="sqlite")switch(t){case "varchar":return "TEXT";case "text":return "TEXT";case "integer":return "INTEGER";case "decimal":case "numeric":return "NUMERIC";case "boolean":return "INTEGER";case "timestamp":return "TEXT";case "jsonb":return "TEXT";default:return "TEXT"}switch(t){case "varchar":return "VARCHAR(255)";case "text":return "TEXT";case "integer":return "INTEGER";case "decimal":case "numeric":return "DECIMAL";case "boolean":return "BOOLEAN";case "timestamp":return "TIMESTAMP";case "jsonb":return "JSONB";default:return "TEXT"}}getExpectedColumnDefs(t,i){let e={},s=t.slug.startsWith("_globals_"),n=t.fields.some(c=>c.name==="createdAt"),r=t.fields.some(c=>c.name==="updatedAt"),a=t.fields.some(c=>c.name==="status"),o=t.fields.some(c=>c.name==="hasDraft");this.dialect==="postgres"?(e.id=s?'"id" TEXT PRIMARY KEY':'"id" UUID PRIMARY KEY DEFAULT gen_random_uuid()',n||(e.created_at='"created_at" TIMESTAMP DEFAULT NULL'),r||(e.updated_at='"updated_at" TIMESTAMP DEFAULT NULL'),a||(e.status='"status" VARCHAR(20) DEFAULT NULL'),o||(e.hasDraft='"hasDraft" BOOLEAN DEFAULT NULL')):(e.id='"id" TEXT PRIMARY KEY',n||(e.created_at='"created_at" TEXT DEFAULT NULL'),r||(e.updated_at='"updated_at" TEXT DEFAULT NULL'),a||(e.status='"status" TEXT DEFAULT NULL'),o||(e.hasDraft='"hasDraft" INTEGER DEFAULT NULL'));for(let c of t.fields){if(!c.name||c.name==="id")continue;let d=this.getColumnSqlDefinition(c,this.dialect),u=c.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase();e[u]=d;}return e}async syncTableColumns(t,i){let e;try{if(this.dialect==="postgres"){let r=await this.executeRaw(J`SELECT column_name, data_type, character_maximum_length FROM information_schema.columns WHERE table_name = ${i}`);e=new Map(r.map(a=>[a.column_name,{type:a.data_type,maxLen:a.character_maximum_length}]));}else {let r=await this.executeRaw(J`PRAGMA table_info("${J.raw(i)}")`);e=new Map(r.map(a=>[a.name,{type:a.type,maxLen:null}]));}}catch{return}let s=this.getExpectedColumnDefs(t,i),n=Object.keys(s).filter(r=>!e.has(r));if(n.length>0){let r=n.map(a=>`ALTER TABLE "${i}" ADD COLUMN ${s[a]}`);await this.executeRaw(J.raw(r.join(`;
|
|
23
|
-
`)));}if(this.dialect==="postgres")for(let r of t.fields){if(!r.name||r.name==="id")continue;let a=w(r,this.dialect),o=r.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),c=e.get(o);!c||c.type!=="character varying"||(a==="text"?await this.executeRaw(J.raw(`ALTER TABLE "${i}" ALTER COLUMN "${o}" TYPE TEXT`)):a==="jsonb"&&(await this.executeRaw(J.raw(`ALTER TABLE "${i}" ALTER COLUMN "${o}" DROP DEFAULT`)),await this.executeRaw(J.raw(`ALTER TABLE "${i}" ALTER COLUMN "${o}" TYPE JSONB USING (CASE WHEN "${o}" IS NULL THEN NULL WHEN "${o}"::text ~ '^\\s*\\{' THEN "${o}"::jsonb ELSE jsonb_build_object('id', "${o}"::text) END)`))));}}generateCreateColumns(t){let i=[];for(let e of t.fields){if(!e.name||e.name==="id")continue;let s=w(e,this.dialect),n=e.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase(),r=e.required?"NOT NULL":"DEFAULT NULL",a;if(this.dialect==="sqlite")switch(s){case "varchar":case "text":a=`TEXT ${r}`;break;case "integer":a=`INTEGER ${r}`;break;case "decimal":case "numeric":a=`NUMERIC ${r}`;break;case "boolean":a=`INTEGER ${r}`;break;case "timestamp":a=`TEXT ${r}`;break;case "jsonb":a=`TEXT ${r}`;break;default:a=`TEXT ${r}`;}else switch(s){case "varchar":a=`VARCHAR(255) ${r}`;break;case "integer":a=`INTEGER ${r}`;break;case "decimal":a=`DECIMAL ${r}`;break;case "boolean":a=`BOOLEAN ${r}`;break;case "timestamp":a=`TIMESTAMP ${r}`;break;case "jsonb":a=`JSONB ${r}`;break;default:a=`TEXT ${r}`;}i.push(`"${n}" ${a}`);}return i.join(`,
|
|
24
|
-
`)+(i.length>0?",":"")}async disconnect(){this.connected=false;}async find(t){let{collection:i,where:e={},sort:s,limit:n$1=10,page:r=1,tenantId:a,select:o,draft:c}=t,d$1=this.getCollection(i),u=this.getTable(i),m={...e};this.tenantContext&&d$1.tenantScoped&&(m=c$1({where:m},i,this.tenantContext,b$1).where||{});let g=this.buildWhereClause(m,d$1,u,a),y=d$1.fields.find(h=>h.name==="status"),p$1=y?.type==="select"&&Array.isArray(y.options)&&y.options.some(h=>h.value==="published");!c&&u.status&&p$1&&g.push(n(u.status,"published"));let b=this.parseSort(s),N=!c&&u.status&&p$1?{...m,status:"published"}:m,pe=await this.count({collection:i,where:N,tenantId:a}),he=(r-1)*n$1,j=[];try{let h=u[b.field]||u.createdAt||u.id,C=b.direction==="asc"?h:M$1(h),A=this.client.select().from(u);g.length>0&&(A=A.where(p(...g))),j=await A.orderBy(C).limit(n$1).offset(he);}catch(h){console.error("[DrizzleAdapter] Query error:",h);}let R=j.map(h=>this.processResult(h,d$1));return this.tenantContext&&!this.tenantContext.isSuperAdmin&&(R=R.filter(h=>d(h,i,this.tenantContext,b$1))),c&&(R=await Promise.all(R.map(async h=>{let C=await this.executeRaw(J`
|
|
25
|
-
SELECT * FROM kyro_versions
|
|
26
|
-
WHERE collection_slug = ${i}
|
|
27
|
-
AND document_id = ${h.id}
|
|
28
|
-
ORDER BY created_at DESC
|
|
29
|
-
LIMIT 1
|
|
30
|
-
`);if(C.length>0){let A=C[0],me=typeof A.data=="string"?JSON.parse(A.data):A.data;return {...h,...me,status:h.status,_hasUnpublishedChanges:A.status==="draft"}}return h}))),{docs:R,...this.calculatePagination(r,n$1,pe)}}async findByID(t){let{collection:i,id:e,tenantId:s,draft:n$1}=t,r=this.getCollection(i),a=this.getTable(i),o=this.dialect==="postgres"&&typeof e=="string"?_(e):e;if(this.tenantContext&&r.tenantScoped){let p={id:o,tenantId:this.tenantContext.tenantId};if(!d(p,i,this.tenantContext,b$1))return null}let c=[n(a.id,o)];s&&a.tenantId&&c.push(n(a.tenantId,s));let d$1=r.fields.find(p=>p.name==="status"),u=d$1?.type==="select"&&Array.isArray(d$1.options)&&d$1.options.some(p=>p.value==="published");!n$1&&a.status&&u&&c.push(n(a.status,"published"));let m=c.length>1?p(...c):c[0],g=await this.client.select().from(a).where(m);if(g.length===0)return null;let y=this.processResult(g[0],r);if(n$1){let p=await this.executeRaw(J`
|
|
31
|
-
SELECT * FROM kyro_versions
|
|
32
|
-
WHERE collection_slug = ${i}
|
|
33
|
-
AND document_id = ${y.id}
|
|
34
|
-
ORDER BY created_at DESC
|
|
35
|
-
LIMIT 1
|
|
36
|
-
`);if(p.length>0){let b=p[0],N=typeof b.data=="string"?JSON.parse(b.data):b.data;y={...y,...N,status:y.status,_hasUnpublishedChanges:b.status==="draft"};}}return y}async create(t){let{collection:i,data:e,tenantId:s}=t,n=this.getCollection(i),r=this.getTable(i),a=this.prepareData(e,n);s&&n.tenantScoped&&(a.tenantId=s);let o=await this.client.insert(r).values(a).returning();return this.processResult(o[0],n)}async update(t){let{collection:i,id:e,data:s,tenantId:n$1}=t,r=this.getCollection(i),a=this.getTable(i),o=this.prepareData(s,r),c=this.dialect==="postgres"&&typeof e=="string"?_(e):e,d=[n(a.id,c)];n$1&&a.tenantId&&d.push(n(a.tenantId,n$1));let u=await this.client.update(a).set(o).where(p(...d)).returning();if(u.length===0)throw new Error(`Document not found: ${i}/${e}`);return this.processResult(u[0],r)}async delete(t){let{collection:i,id:e,tenantId:s}=t,n$1=this.getCollection(i),r=this.getTable(i),a=this.dialect==="postgres"&&typeof e=="string"?_(e):e,o=[n(r.id,a)];s&&r.tenantId&&o.push(n(r.tenantId,s));let c=await this.client.delete(r).where(p(...o)).returning();if(c.length===0)throw new Error(`Document not found: ${i}/${e}`);return this.processResult(c[0],n$1)}async count(t){let{collection:i,where:e={},tenantId:s}=t,n=this.getCollection(i),r=this.getTable(i),a=this.buildWhereClause(e,n,r,s);try{let o=this.client.select({count:J`count(*)`}).from(r);a.length>0&&(o=o.where(p(...a)));let c=await o;return Number(c[0]?.count||0)}catch{return 0}}async findOne(t){let{collection:i,where:e={},tenantId:s,draft:n$1}=t;if(i.startsWith("_globals_")){let a=i.replace("_globals_",""),o=this.globals.get(a);if(!o)throw new Error(`Global "${a}" not found`);let c=this.getTable(i),d=this.client.select().from(c),u=o.fields.find(p=>p.name==="status"),m=u?.type==="select"&&Array.isArray(u.options)&&u.options.some(p=>p.value==="published");!n$1&&c.status&&m&&(d=d.where(n(c.status,"published")));let g=await d.limit(1);if(g.length===0)return null;let y=this.processResult(g[0],o);if(n$1){let p=await this.executeRaw(J`
|
|
37
|
-
SELECT * FROM kyro_versions
|
|
38
|
-
WHERE collection_slug = ${i}
|
|
39
|
-
AND document_id = ${a}
|
|
40
|
-
ORDER BY created_at DESC
|
|
41
|
-
LIMIT 1
|
|
42
|
-
`);if(p.length>0){let b=p[0],N=typeof b.data=="string"?JSON.parse(b.data):b.data;y={...y,...N,status:y.status,_hasUnpublishedChanges:b.status==="draft"};}}return y}return (await this.find({...t,limit:1})).docs[0]||null}async findVersions(t){await this.ensureVersionsTable();let{collection:i,documentId:e,limit:s=10,page:n=1,tenantId:r}=t,a=(n-1)*s,o=this.getCollection(i),c=await this.executeRaw(J`
|
|
43
|
-
SELECT count(*) as count
|
|
44
|
-
FROM kyro_versions
|
|
45
|
-
WHERE collection_slug = ${i}
|
|
46
|
-
AND document_id = ${e}
|
|
47
|
-
AND autosave = 0
|
|
48
|
-
${r&&o.tenantScoped?J`AND tenant_id = ${r}`:J``}
|
|
49
|
-
`),d=parseInt(c[0]?.count||"0");return {docs:(await this.executeRaw(J`
|
|
50
|
-
SELECT *
|
|
51
|
-
FROM kyro_versions
|
|
52
|
-
WHERE collection_slug = ${i}
|
|
53
|
-
AND document_id = ${e}
|
|
54
|
-
AND autosave = 0
|
|
55
|
-
${r&&o.tenantScoped?J`AND tenant_id = ${r}`:J``}
|
|
56
|
-
ORDER BY created_at DESC
|
|
57
|
-
LIMIT ${s}
|
|
58
|
-
OFFSET ${a}
|
|
59
|
-
`)).map(m=>({...m,data:typeof m.data=="string"?JSON.parse(m.data):m.data})),...this.calculatePagination(n,s,d)}}async findVersionByID(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection),e=await this.executeRaw(J`
|
|
60
|
-
SELECT * FROM kyro_versions
|
|
61
|
-
WHERE id = ${t.versionId}
|
|
62
|
-
AND collection_slug = ${t.collection}
|
|
63
|
-
${t.tenantId&&i.tenantScoped?J`AND tenant_id = ${t.tenantId}`:J``}
|
|
64
|
-
LIMIT 1
|
|
65
|
-
`);if(e.length===0)return null;let s=e[0];return {...s,data:typeof s.data=="string"?JSON.parse(s.data):s.data}}async createVersion(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection),e=new Date().toISOString();if(t.autosave){let n=await this.executeRaw(J`
|
|
66
|
-
SELECT * FROM kyro_versions
|
|
67
|
-
WHERE collection_slug = ${t.collection}
|
|
68
|
-
AND document_id = ${t.documentId}
|
|
69
|
-
AND autosave = 1
|
|
70
|
-
${t.tenantId&&i.tenantScoped?J`AND tenant_id = ${t.tenantId}`:J``}
|
|
71
|
-
LIMIT 1
|
|
72
|
-
`);if(n.length>0)return await this.executeRaw(J`
|
|
73
|
-
UPDATE kyro_versions
|
|
74
|
-
SET data = ${JSON.stringify(t.data)},
|
|
75
|
-
status = ${t.status},
|
|
76
|
-
updated_at = ${e}
|
|
77
|
-
WHERE id = ${n[0].id}
|
|
78
|
-
`),this.findVersionByID({collection:t.collection,versionId:n[0].id,tenantId:t.tenantId})}let s=Math.random().toString(36).substring(2,15);if(await this.executeRaw(J`
|
|
79
|
-
INSERT INTO kyro_versions (
|
|
80
|
-
id, collection_slug, document_id, tenant_id, data, status, autosave, created_by, change_description, created_at, updated_at
|
|
81
|
-
) VALUES (
|
|
82
|
-
${s}, ${t.collection}, ${t.documentId}, ${t.tenantId&&i.tenantScoped?t.tenantId:null},
|
|
83
|
-
${JSON.stringify(t.data)}, ${t.status}, ${t.autosave?1:0}, ${t.createdBy||null},
|
|
84
|
-
${t.changeDescription||null}, ${e}, ${e}
|
|
85
|
-
)
|
|
86
|
-
`),!t.autosave){let n=this.getCollection(t.collection);n.versions?.maxPerDoc&&await this.deleteVersions({collection:t.collection,documentId:t.documentId,keepLatest:n.versions.maxPerDoc,tenantId:t.tenantId});}return this.findVersionByID({collection:t.collection,versionId:s,tenantId:t.tenantId})}async updateLatestVersion(t){return this.createVersion({...t,autosave:true})}async deleteVersions(t){await this.ensureVersionsTable();let i=this.getCollection(t.collection);if(t.keepLatest){let s=(await this.executeRaw(J`
|
|
87
|
-
SELECT id FROM kyro_versions
|
|
88
|
-
WHERE collection_slug = ${t.collection}
|
|
89
|
-
AND document_id = ${t.documentId}
|
|
90
|
-
AND autosave = 0
|
|
91
|
-
${t.tenantId&&i.tenantScoped?J`AND tenant_id = ${t.tenantId}`:J``}
|
|
92
|
-
ORDER BY created_at DESC
|
|
93
|
-
LIMIT ${t.keepLatest}
|
|
94
|
-
`)).map(n=>n.id);s.length>0&&await this.executeRaw(J`
|
|
95
|
-
DELETE FROM kyro_versions
|
|
96
|
-
WHERE collection_slug = ${t.collection}
|
|
97
|
-
AND document_id = ${t.documentId}
|
|
98
|
-
AND autosave = 0
|
|
99
|
-
AND id NOT IN (${J.join(s.map(n=>J`${n}`),J`, `)})
|
|
100
|
-
`);}else await this.executeRaw(J`
|
|
101
|
-
DELETE FROM kyro_versions
|
|
102
|
-
WHERE collection_slug = ${t.collection}
|
|
103
|
-
AND document_id = ${t.documentId}
|
|
104
|
-
${t.tenantId&&i.tenantScoped?J`AND tenant_id = ${t.tenantId}`:J``}
|
|
105
|
-
`);}getTable(t){let i=this.getTableName(t),e=this.schema[i];if(!e)throw new Error(`Table "${i}" not found in schema`);return e}buildWhereClause(t$1,i,e,s$1){let n$1=[];s$1&&i.tenantScoped&&e.tenantId&&n$1.push(n(e.tenantId,s$1));for(let[r,a]of Object.entries(t$1))if(r==="id"&&this.dialect==="postgres"&&(typeof a=="string"?a=_(a):a&&typeof a=="object"&&(a.equals!==void 0&&typeof a.equals=="string"&&(a={...a,equals:_(a.equals)}),a.in&&Array.isArray(a.in)&&(a={...a,in:a.in.map(o=>typeof o=="string"?_(o):o)}))),r==="AND"&&Array.isArray(a)){let o=a.map(c=>this.buildWhereClause(c,i,e)).flat().filter(Boolean);o.length>0&&n$1.push(p(...o));}else if(r==="OR"&&Array.isArray(a)){let o=a.map(c=>this.buildWhereClause(c,i,e)).flat().filter(Boolean);o.length>0&&n$1.push(q(...o));}else if(typeof a=="object"&&a!==null&&!Array.isArray(a)){let o$1=e[r];if(!o$1)continue;a.equals!==void 0&&n$1.push(n(o$1,a.equals)),a.not_equals!==void 0&&n$1.push(o(o$1,a.not_equals)),a.in&&Array.isArray(a.in)&&n$1.push(w$1(o$1,a.in)),a.like!==void 0&&n$1.push(E(o$1,a.like)),a.contains!==void 0&&n$1.push(E(o$1,`%${a.contains}%`)),a.greater_than!==void 0&&n$1.push(s(o$1,a.greater_than)),a.greater_than_equal!==void 0&&n$1.push(t(o$1,a.greater_than_equal)),a.less_than!==void 0&&n$1.push(u(o$1,a.less_than)),a.less_than_equal!==void 0&&n$1.push(v(o$1,a.less_than_equal));}else {let o=e[r];o&&n$1.push(n(o,a));}return n$1}processResult(t,i){if(!t)return null;let e={...t};for(let s of Object.keys(e))/^\d+$/.test(s)&&delete e[s];t.id&&(e.id=String(t.id));for(let s of i.fields){if(!s.name)continue;let n=s.name.replace(/-/g,"_").replace(/([A-Z])/g,"_$1").toLowerCase();n!==s.name&&e[n]!==void 0&&e[s.name]===void 0&&(e[s.name]=e[n],delete e[n]);}for(let s of i.fields){if(["json","richtext","array","group","blocks","upload","image","list","relationship-block"].includes(s.type)){let n=s;if(e[n.name]&&typeof e[n.name]=="string")try{let r=JSON.parse(e[n.name]);e[n.name]=r;}catch{}if(s.type==="blocks"&&e[n.name]&&Array.isArray(e[n.name])){let r=n.blocks||[];e[n.name]=M(e[n.name],r);}}if(s.type==="tabs"&&"tabs"in s&&s.name){if(typeof e[s.name]=="object"&&e[s.name]!==null&&!Array.isArray(e[s.name])){for(let r of s.tabs)for(let a of r.fields)if((a.type==="upload"||a.type==="image")&&a.name){let o=e[s.name][a.name];if(typeof o=="string")try{let c=JSON.parse(o);e[s.name][a.name]=Array.isArray(c)?c.map(d=>d&&typeof d=="object"&&typeof d.id=="string"?d.id:String(d||"")):typeof c.id=="string"?c.id:String(c.id||"");}catch{}else o&&typeof o=="object"&&(e[s.name][a.name]=Array.isArray(o)?o.map(c=>c&&typeof c=="object"&&typeof c.id=="string"?c.id:String(c||"")):typeof o.id=="string"?o.id:String(o.id||""));}continue}if(typeof e[s.name]=="string")try{let r=JSON.parse(e[s.name]);if(typeof r=="object"&&r!==null){e[s.name]=r;continue}}catch{}let n={};for(let r of s.tabs)for(let a of r.fields)if(a.name&&e[a.name]!==void 0){let o=e[a.name];if(["json","richtext","array","group","blocks","upload","image","list","relationship-block"].includes(a.type)){if(o&&typeof o=="string")try{o=JSON.parse(o);}catch{}(a.type==="upload"||a.type==="image")&&o&&typeof o=="object"&&(o=Array.isArray(o)?o.map(c=>c&&typeof c=="object"&&typeof c.id=="string"?c.id:String(c||"")):typeof o.id=="string"?o.id:String(o.id||""));}n[a.name]=o,delete e[a.name];}e[s.name]=n;}}return e.createdAt&&(e.createdAt=new Date(e.createdAt).toISOString()),e.updatedAt&&(e.updatedAt=new Date(e.updatedAt).toISOString()),a$4(e)}async ensureVersionsTable(){if(this.versionsTableReady)return;let t;this.dialect==="sqlite"?t=`
|
|
106
|
-
CREATE TABLE IF NOT EXISTS kyro_versions (
|
|
107
|
-
id text PRIMARY KEY,
|
|
108
|
-
collection_slug text NOT NULL,
|
|
109
|
-
document_id text NOT NULL,
|
|
110
|
-
tenant_id text,
|
|
111
|
-
data text NOT NULL,
|
|
112
|
-
status text NOT NULL DEFAULT 'draft',
|
|
113
|
-
autosave integer NOT NULL DEFAULT 0,
|
|
114
|
-
created_by text,
|
|
115
|
-
change_description text,
|
|
116
|
-
created_at text DEFAULT (datetime('now')),
|
|
117
|
-
updated_at text DEFAULT (datetime('now'))
|
|
118
|
-
)
|
|
119
|
-
`:t=`
|
|
120
|
-
CREATE TABLE IF NOT EXISTS kyro_versions (
|
|
121
|
-
id text PRIMARY KEY,
|
|
122
|
-
collection_slug text NOT NULL,
|
|
123
|
-
document_id text NOT NULL,
|
|
124
|
-
tenant_id text,
|
|
125
|
-
data text NOT NULL,
|
|
126
|
-
status text NOT NULL,
|
|
127
|
-
autosave integer NOT NULL DEFAULT 0,
|
|
128
|
-
created_by text,
|
|
129
|
-
change_description text,
|
|
130
|
-
created_at text NOT NULL,
|
|
131
|
-
updated_at text NOT NULL
|
|
132
|
-
)
|
|
133
|
-
`,await this.executeRaw(J.raw(t));try{this.dialect==="postgres"?await this.executeRaw(J.raw("ALTER TABLE kyro_versions ADD COLUMN IF NOT EXISTS autosave integer NOT NULL DEFAULT 0")):await this.executeRaw(J.raw("ALTER TABLE kyro_versions ADD COLUMN autosave integer NOT NULL DEFAULT 0"));}catch{}this.versionsTableReady=true;}async execute(t){return this.executeRaw(t)}async executeRaw(t){let i="",e=[];if(typeof t=="string")i=t;else if(t&&(t.queryChunks||t.decoder))if(this.dialect==="postgres"){let n=new a$5().sqlToQuery(t);i=n.sql,e=n.params;}else {let n=new h().sqlToQuery(t);i=n.sql,e=n.params;}else if(t&&typeof t.toSQL=="function"){let n=t.toSQL();i=n.sql,e=n.params||[];}else i=String(t);let s=this.rawClient||this.client;if(s?.prepare&&typeof s.prepare=="function"){let n=s.prepare(i);return (e.length>0?await n.bind(...e).all():await n.all()).results||[]}if(typeof this.client?.execute=="function"){let n=await this.client.execute(t);return Array.isArray(n)?n:Array.isArray(n?.rows)?n.rows:Array.isArray(n?.[0])?n[0]:[]}return []}};function We(f){return new P(f)}export{de as a,Ie as b,$e as c,xe as d,w as e,De as f,P as g,We as h};
|
|
@@ -1,284 +0,0 @@
|
|
|
1
|
-
import { C as CollectionConfig, G as GlobalConfig, j as KyroPlugin } from './types-DOKMyC3y.cjs';
|
|
2
|
-
import { F as Field } from './types-euTszc-1.cjs';
|
|
3
|
-
import { ZodTypeAny } from 'zod';
|
|
4
|
-
|
|
5
|
-
interface S3CompatibleConfig {
|
|
6
|
-
bucket?: string;
|
|
7
|
-
region?: string;
|
|
8
|
-
accessKeyId?: string;
|
|
9
|
-
secretAccessKey?: string;
|
|
10
|
-
endpoint?: string;
|
|
11
|
-
cdnUrl?: string;
|
|
12
|
-
prefix?: string;
|
|
13
|
-
}
|
|
14
|
-
interface R2Config {
|
|
15
|
-
accountId?: string;
|
|
16
|
-
accessKeyId?: string;
|
|
17
|
-
secretAccessKey?: string;
|
|
18
|
-
bucket?: string;
|
|
19
|
-
cdnUrl?: string;
|
|
20
|
-
prefix?: string;
|
|
21
|
-
publicDevUrl?: string;
|
|
22
|
-
}
|
|
23
|
-
interface GCSConfig {
|
|
24
|
-
bucket?: string;
|
|
25
|
-
projectId?: string;
|
|
26
|
-
clientEmail?: string;
|
|
27
|
-
privateKey?: string;
|
|
28
|
-
cdnUrl?: string;
|
|
29
|
-
prefix?: string;
|
|
30
|
-
}
|
|
31
|
-
interface BackblazeConfig {
|
|
32
|
-
bucket?: string;
|
|
33
|
-
accountId?: string;
|
|
34
|
-
applicationKeyId?: string;
|
|
35
|
-
applicationKey?: string;
|
|
36
|
-
cdnUrl?: string;
|
|
37
|
-
prefix?: string;
|
|
38
|
-
}
|
|
39
|
-
interface BunnyConfig {
|
|
40
|
-
storageZone?: string;
|
|
41
|
-
apiKey?: string;
|
|
42
|
-
cdnUrl?: string;
|
|
43
|
-
prefix?: string;
|
|
44
|
-
}
|
|
45
|
-
interface FTPConfig {
|
|
46
|
-
host?: string;
|
|
47
|
-
port?: number;
|
|
48
|
-
user?: string;
|
|
49
|
-
password?: string;
|
|
50
|
-
secure?: boolean;
|
|
51
|
-
baseUrl?: string;
|
|
52
|
-
prefix?: string;
|
|
53
|
-
}
|
|
54
|
-
interface StorageConfig {
|
|
55
|
-
type: string;
|
|
56
|
-
s3: S3CompatibleConfig;
|
|
57
|
-
r2: R2Config;
|
|
58
|
-
gcs: GCSConfig;
|
|
59
|
-
digitalocean: S3CompatibleConfig;
|
|
60
|
-
backblaze: BackblazeConfig;
|
|
61
|
-
wasabi: S3CompatibleConfig;
|
|
62
|
-
bunny: BunnyConfig;
|
|
63
|
-
ftp: FTPConfig;
|
|
64
|
-
cloudinary: {
|
|
65
|
-
cloudName?: string;
|
|
66
|
-
apiKey?: string;
|
|
67
|
-
apiSecret?: string;
|
|
68
|
-
folder?: string;
|
|
69
|
-
};
|
|
70
|
-
imgix: {
|
|
71
|
-
domain?: string;
|
|
72
|
-
signKey?: string;
|
|
73
|
-
};
|
|
74
|
-
local: {
|
|
75
|
-
uploadDir?: string;
|
|
76
|
-
baseUrl?: string;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
interface EmailConfig {
|
|
80
|
-
provider?: string;
|
|
81
|
-
host?: string;
|
|
82
|
-
port?: number;
|
|
83
|
-
secure?: boolean;
|
|
84
|
-
user?: string;
|
|
85
|
-
pass?: string;
|
|
86
|
-
from?: string;
|
|
87
|
-
fromName?: string;
|
|
88
|
-
replyTo?: string;
|
|
89
|
-
}
|
|
90
|
-
declare class ConfigService {
|
|
91
|
-
private db;
|
|
92
|
-
private cache;
|
|
93
|
-
private loaded;
|
|
94
|
-
private static readonly SENSITIVE_KEYS;
|
|
95
|
-
constructor(db: any);
|
|
96
|
-
/**
|
|
97
|
-
* Initialize the service by loading all settings from the database
|
|
98
|
-
*/
|
|
99
|
-
load(): Promise<void>;
|
|
100
|
-
private ensureSettingsTable;
|
|
101
|
-
/**
|
|
102
|
-
* Load settings from the _globals_storage-settings table (SQLite fallback)
|
|
103
|
-
* Maps nested global structure to flat key-value cache
|
|
104
|
-
*/
|
|
105
|
-
private loadFromGlobals;
|
|
106
|
-
/**
|
|
107
|
-
* Get a settings value with environment fallback
|
|
108
|
-
*/
|
|
109
|
-
get(key: string, envKey?: string, defaultValue?: string): string | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* Get storage configuration
|
|
112
|
-
*/
|
|
113
|
-
getStorageConfig(): StorageConfig;
|
|
114
|
-
/**
|
|
115
|
-
* Get email configuration
|
|
116
|
-
*/
|
|
117
|
-
getEmailConfig(): EmailConfig;
|
|
118
|
-
/**
|
|
119
|
-
* Mask sensitive values for display
|
|
120
|
-
*/
|
|
121
|
-
maskSensitive(key: string, value: string | undefined): string | undefined;
|
|
122
|
-
/**
|
|
123
|
-
* Update a setting in the database
|
|
124
|
-
*/
|
|
125
|
-
set(key: string, value: string, description?: string): Promise<void>;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
interface UploadOptions {
|
|
129
|
-
folder?: string;
|
|
130
|
-
filename?: string;
|
|
131
|
-
mimeType?: string;
|
|
132
|
-
metadata?: Record<string, unknown>;
|
|
133
|
-
}
|
|
134
|
-
interface UploadedFile {
|
|
135
|
-
id: string;
|
|
136
|
-
filename: string;
|
|
137
|
-
originalName: string;
|
|
138
|
-
mimeType: string;
|
|
139
|
-
size: number;
|
|
140
|
-
url: string;
|
|
141
|
-
thumbnailUrl?: string;
|
|
142
|
-
width?: number;
|
|
143
|
-
height?: number;
|
|
144
|
-
folder?: string;
|
|
145
|
-
provider: string;
|
|
146
|
-
metadata?: Record<string, unknown>;
|
|
147
|
-
createdAt: string;
|
|
148
|
-
}
|
|
149
|
-
interface ImageTransforms {
|
|
150
|
-
width?: number;
|
|
151
|
-
height?: number;
|
|
152
|
-
fit?: "clip" | "crop" | "fill" | "fillmax" | "scale" | "max" | "min";
|
|
153
|
-
format?: "webp" | "avif" | "jpeg" | "jpg" | "png" | "gif";
|
|
154
|
-
quality?: number;
|
|
155
|
-
blur?: number;
|
|
156
|
-
sharpen?: number;
|
|
157
|
-
/** Crop region as percentages (0-100) of the original image */
|
|
158
|
-
cropX?: number;
|
|
159
|
-
cropY?: number;
|
|
160
|
-
cropWidth?: number;
|
|
161
|
-
cropHeight?: number;
|
|
162
|
-
}
|
|
163
|
-
interface StorageProvider {
|
|
164
|
-
name: string;
|
|
165
|
-
displayName: string;
|
|
166
|
-
supportsDynamicResize: boolean;
|
|
167
|
-
upload(file: File, options?: UploadOptions): Promise<UploadedFile>;
|
|
168
|
-
uploadFromUrl(url: string, options?: UploadOptions): Promise<UploadedFile>;
|
|
169
|
-
delete(url: string): Promise<void>;
|
|
170
|
-
rename(oldUrl: string, newKey: string): Promise<string>;
|
|
171
|
-
getImageUrl(url: string, transforms?: ImageTransforms): string;
|
|
172
|
-
generateThumbnail(file: UploadedFile, size: {
|
|
173
|
-
width: number;
|
|
174
|
-
height: number;
|
|
175
|
-
}): Promise<string>;
|
|
176
|
-
list(prefix?: string): Promise<UploadedFile[]>;
|
|
177
|
-
exists(url: string): Promise<boolean>;
|
|
178
|
-
createFolder?(folder: string): Promise<void>;
|
|
179
|
-
deleteFolder?(folder: string): Promise<void>;
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
declare function resolveProvider(configService: ConfigService): Promise<StorageProvider>;
|
|
183
|
-
|
|
184
|
-
interface StorageProviderRegistration {
|
|
185
|
-
type: string;
|
|
186
|
-
displayName: string;
|
|
187
|
-
pluginName?: string;
|
|
188
|
-
configFields: Field[];
|
|
189
|
-
configKey?: string;
|
|
190
|
-
extractConfig: (storageConfig: StorageConfig, configKey: string) => any;
|
|
191
|
-
extractRawConfig: (config: any) => any;
|
|
192
|
-
factory: (config: any) => StorageProvider;
|
|
193
|
-
}
|
|
194
|
-
declare class StorageProviderRegistry {
|
|
195
|
-
private providers;
|
|
196
|
-
private providerToPlugin;
|
|
197
|
-
private disabledPlugins;
|
|
198
|
-
constructor();
|
|
199
|
-
private registerLocal;
|
|
200
|
-
private registerImgix;
|
|
201
|
-
private registerBunny;
|
|
202
|
-
private registerCloudflareR2;
|
|
203
|
-
private registerCloudflareS3;
|
|
204
|
-
register(registration: StorageProviderRegistration): void;
|
|
205
|
-
unregister(type: string): void;
|
|
206
|
-
get(type: string): StorageProviderRegistration | undefined;
|
|
207
|
-
getAll(): StorageProviderRegistration[];
|
|
208
|
-
getAllAvailable(isPluginEnabled?: (name: string) => boolean): StorageProviderRegistration[];
|
|
209
|
-
has(type: string): boolean;
|
|
210
|
-
resolve(type: string, storageConfig: StorageConfig): Promise<StorageProvider>;
|
|
211
|
-
resolveWithConfig(type: string, config: any): Promise<StorageProvider>;
|
|
212
|
-
getProviderPluginName(type: string): string | undefined;
|
|
213
|
-
getAllPluginNames(): string[];
|
|
214
|
-
setPluginEnabled(name: string, enabled: boolean): void;
|
|
215
|
-
isPluginEnabled(name: string): boolean;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
declare class Registry {
|
|
219
|
-
storageProviders: StorageProviderRegistry;
|
|
220
|
-
private collections;
|
|
221
|
-
private globals;
|
|
222
|
-
private plugins;
|
|
223
|
-
private schemaCache;
|
|
224
|
-
private initialized;
|
|
225
|
-
addCollection(config: CollectionConfig): void;
|
|
226
|
-
addCollections(configs: CollectionConfig[]): void;
|
|
227
|
-
getCollection(slug: string): CollectionConfig | undefined;
|
|
228
|
-
getCollections(): CollectionConfig[];
|
|
229
|
-
getCollectionSlugs(): string[];
|
|
230
|
-
hasCollection(slug: string): boolean;
|
|
231
|
-
removeCollection(slug: string): boolean;
|
|
232
|
-
addGlobal(config: GlobalConfig): void;
|
|
233
|
-
/**
|
|
234
|
-
* Add a global after the registry is already initialized.
|
|
235
|
-
* Only for internal use (e.g. storage settings form built at startup).
|
|
236
|
-
*/
|
|
237
|
-
addGlobalPostInit(config: GlobalConfig): void;
|
|
238
|
-
private _addGlobalUnsafe;
|
|
239
|
-
addGlobals(configs: GlobalConfig[]): void;
|
|
240
|
-
getGlobal(slug: string): GlobalConfig | undefined;
|
|
241
|
-
getGlobals(): GlobalConfig[];
|
|
242
|
-
getGlobalSlugs(): string[];
|
|
243
|
-
hasGlobal(slug: string): boolean;
|
|
244
|
-
removeGlobal(slug: string): boolean;
|
|
245
|
-
addPlugin(plugin: KyroPlugin): void;
|
|
246
|
-
getPlugins(): KyroPlugin[];
|
|
247
|
-
getZodSchema(slug: string): ZodTypeAny;
|
|
248
|
-
getCreateZodSchema(slug: string): ZodTypeAny;
|
|
249
|
-
getUpdateZodSchema(slug: string): ZodTypeAny;
|
|
250
|
-
getWhereZodSchema(slug: string): ZodTypeAny;
|
|
251
|
-
getFieldZodSchema(field: Field): ZodTypeAny;
|
|
252
|
-
private clearSchemaCache;
|
|
253
|
-
private applyFieldDefaults;
|
|
254
|
-
getFields(slug: string): Field[];
|
|
255
|
-
getFieldMap(slug: string): Map<string, Field>;
|
|
256
|
-
getVisibleFields(slug: string): Field[];
|
|
257
|
-
validate(): void;
|
|
258
|
-
init(kyroInstance?: any): Promise<void>;
|
|
259
|
-
isInitialized(): boolean;
|
|
260
|
-
getPaginationDefaults(slug: string): {
|
|
261
|
-
defaultLimit: number;
|
|
262
|
-
limits: number[];
|
|
263
|
-
};
|
|
264
|
-
getDefaultSort(slug: string): string;
|
|
265
|
-
getDefaultColumns(slug: string): string[];
|
|
266
|
-
getAdminTitle(slug: string): string;
|
|
267
|
-
getAdminLabel(slug: string): string;
|
|
268
|
-
getAdminGroup(slug: string): string | undefined;
|
|
269
|
-
getStats(): {
|
|
270
|
-
collections: number;
|
|
271
|
-
globals: number;
|
|
272
|
-
plugins: number;
|
|
273
|
-
fields: number;
|
|
274
|
-
};
|
|
275
|
-
toJSON(): {
|
|
276
|
-
collections: CollectionConfig[];
|
|
277
|
-
globals: GlobalConfig[];
|
|
278
|
-
};
|
|
279
|
-
}
|
|
280
|
-
declare function getRegistry(): Registry;
|
|
281
|
-
declare function resetRegistry(): void;
|
|
282
|
-
declare function createRegistry(): Registry;
|
|
283
|
-
|
|
284
|
-
export { ConfigService as C, type EmailConfig as E, Registry as R, type StorageProvider as S, type StorageConfig as a, resolveProvider as b, createRegistry as c, getRegistry as g, resetRegistry as r };
|