hono-crud 0.5.2 → 0.5.3

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/CHANGELOG.md CHANGED
@@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
21
21
  %b
22
22
  %b
23
23
  %b
24
+ %b
24
25
  ## [0.1.0] - 2025-01-29
25
26
 
26
27
  ### Added
@@ -58,3 +59,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
58
59
  [0.5.0]: https://github.com/kshdotdev/hono-crud/compare/v0.4.4...v0.5.0
59
60
  [0.5.1]: https://github.com/kshdotdev/hono-crud/compare/v0.5.0...v0.5.1
60
61
  [0.5.2]: https://github.com/kshdotdev/hono-crud/compare/v0.5.1...v0.5.2
62
+ [0.5.3]: https://github.com/kshdotdev/hono-crud/compare/v0.5.2...v0.5.3
@@ -1,13 +1,13 @@
1
1
  import { Table, SQL, Column } from 'drizzle-orm';
2
- import { M as MetaInput, I as IncludeOptions, F as FilterCondition, f as RelationConfig, N as NestedUpdateInput, g as NestedWriteResult, L as ListFilters, P as PaginatedResult, h as AggregateOptions, i as AggregateResult, S as SearchOptions, j as SearchResult } from '../../types-5BBVU0EY.js';
2
+ import { M as MetaInput, I as IncludeOptions, l as FilterCondition, f as RelationConfig, N as NestedUpdateInput, g as NestedWriteResult, L as ListFilters, P as PaginatedResult, h as AggregateOptions, i as AggregateResult, S as SearchOptions, j as SearchResult } from '../../types-T4ThpPOK.js';
3
3
  import { Env } from 'hono';
4
- import { a as CreateEndpoint, M as ModelObject, R as ReadEndpoint, U as UpdateEndpoint, D as DeleteEndpoint, L as ListEndpoint, b as RestoreEndpoint, B as BatchCreateEndpoint, c as BatchDeleteEndpoint, d as BatchRestoreEndpoint, e as BatchUpdateEndpoint, f as BatchUpdateItem, A as AggregateEndpoint, g as BatchUpsertEndpoint, h as UpsertEndpoint, E as ExportEndpoint, I as ImportEndpoint, S as SearchEndpoint, V as VersionCompareEndpoint, i as VersionHistoryEndpoint, j as VersionReadEndpoint, k as VersionRollbackEndpoint } from '../../import-BHD2B1u8.js';
5
- import { A as AdapterBundle } from '../../index-BNIzQvcO.js';
4
+ import { a as CreateEndpoint, M as ModelObject, R as ReadEndpoint, U as UpdateEndpoint, D as DeleteEndpoint, L as ListEndpoint, b as RestoreEndpoint, B as BatchCreateEndpoint, c as BatchDeleteEndpoint, d as BatchRestoreEndpoint, e as BatchUpdateEndpoint, f as BatchUpdateItem, A as AggregateEndpoint, g as BatchUpsertEndpoint, h as UpsertEndpoint, E as ExportEndpoint, I as ImportEndpoint, S as SearchEndpoint, V as VersionCompareEndpoint, i as VersionHistoryEndpoint, j as VersionReadEndpoint, k as VersionRollbackEndpoint } from '../../import-Co7vvjkO.js';
5
+ import { A as AdapterBundle } from '../../index-COXyTPal.js';
6
6
  import { z } from 'zod';
7
7
  import '../../types-B5wq2iKZ.js';
8
8
  import '../../types-BAcN7U0B.js';
9
9
  import '@hono/zod-openapi';
10
- import '../../route-BmtmmHSO.js';
10
+ import '../../route-CSScNXhr.js';
11
11
  import 'hono/utils/http-status';
12
12
  import '../../audit/index.js';
13
13
  import '../../registry-PNJjvSvm.js';
@@ -647,19 +647,23 @@ declare abstract class DrizzleImportEndpoint<E extends Env = Env, M extends Meta
647
647
  * Return type of createDrizzleCrud factory function.
648
648
  * Provides type-safe base classes for all CRUD operations.
649
649
  */
650
- interface DrizzleCrudClasses<M extends MetaInput> {
651
- Create: typeof DrizzleCreateEndpoint<Env, M>;
652
- Read: typeof DrizzleReadEndpoint<Env, M>;
653
- Update: typeof DrizzleUpdateEndpoint<Env, M>;
654
- Delete: typeof DrizzleDeleteEndpoint<Env, M>;
655
- List: typeof DrizzleListEndpoint<Env, M>;
656
- Restore: typeof DrizzleRestoreEndpoint<Env, M>;
657
- Upsert: typeof DrizzleUpsertEndpoint<Env, M>;
658
- BatchCreate: typeof DrizzleBatchCreateEndpoint<Env, M>;
659
- BatchUpdate: typeof DrizzleBatchUpdateEndpoint<Env, M>;
660
- BatchDelete: typeof DrizzleBatchDeleteEndpoint<Env, M>;
661
- BatchRestore: typeof DrizzleBatchRestoreEndpoint<Env, M>;
662
- BatchUpsert: typeof DrizzleBatchUpsertEndpoint<Env, M>;
650
+ type ConfiguredDrizzleEndpoint<TEndpoint, M extends MetaInput> = new () => TEndpoint & {
651
+ _meta: M;
652
+ db: DrizzleDatabaseConstraint;
653
+ };
654
+ interface DrizzleCrudClasses<M extends MetaInput, E extends Env = Env> {
655
+ Create: ConfiguredDrizzleEndpoint<DrizzleCreateEndpoint<E, M>, M>;
656
+ Read: ConfiguredDrizzleEndpoint<DrizzleReadEndpoint<E, M>, M>;
657
+ Update: ConfiguredDrizzleEndpoint<DrizzleUpdateEndpoint<E, M>, M>;
658
+ Delete: ConfiguredDrizzleEndpoint<DrizzleDeleteEndpoint<E, M>, M>;
659
+ List: ConfiguredDrizzleEndpoint<DrizzleListEndpoint<E, M>, M>;
660
+ Restore: ConfiguredDrizzleEndpoint<DrizzleRestoreEndpoint<E, M>, M>;
661
+ Upsert: ConfiguredDrizzleEndpoint<DrizzleUpsertEndpoint<E, M>, M>;
662
+ BatchCreate: ConfiguredDrizzleEndpoint<DrizzleBatchCreateEndpoint<E, M>, M>;
663
+ BatchUpdate: ConfiguredDrizzleEndpoint<DrizzleBatchUpdateEndpoint<E, M>, M>;
664
+ BatchDelete: ConfiguredDrizzleEndpoint<DrizzleBatchDeleteEndpoint<E, M>, M>;
665
+ BatchRestore: ConfiguredDrizzleEndpoint<DrizzleBatchRestoreEndpoint<E, M>, M>;
666
+ BatchUpsert: ConfiguredDrizzleEndpoint<DrizzleBatchUpsertEndpoint<E, M>, M>;
663
667
  }
664
668
  /**
665
669
  * Creates a set of Drizzle CRUD endpoint base classes with db and meta pre-configured.
@@ -688,7 +692,7 @@ interface DrizzleCrudClasses<M extends MetaInput> {
688
692
  * }
689
693
  * ```
690
694
  */
691
- declare function createDrizzleCrud<M extends MetaInput>(db: DrizzleDatabaseConstraint, meta: M): DrizzleCrudClasses<M>;
695
+ declare function createDrizzleCrud<M extends MetaInput, E extends Env = Env>(db: DrizzleDatabaseConstraint, meta: M): DrizzleCrudClasses<M, E>;
692
696
  /**
693
697
  * Drizzle adapter bundle for use with defineEndpoints.
694
698
  *
@@ -1,4 +1,4 @@
1
- import {k,l,m as m$1,n,o,p,r,s,t,u,q as q$1,v as v$1,w,x,y as y$1,z as z$1,A,B as B$1,J,K,T,U as U$1}from'../../chunk-Q4FF5JVS.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-W4FHI5YI.js';import'../../chunk-HAUN4LQO.js';import'../../chunk-NIWM7GOK.js';import'../../chunk-RFT77JBK.js';import'../../chunk-FC56WWPB.js';import'../../chunk-GBQQ3YQX.js';import'../../chunk-QRXEQTNE.js';import'../../chunk-QXFY6NYI.js';import {b}from'../../chunk-DMGP7QDL.js';import'../../chunk-MDHMZPXK.js';import'../../chunk-VJRDAVID.js';import {getTableColumns,eq,inArray,between,isNull,isNotNull,ilike,like,notInArray,lte,lt as lt$1,gte,gt as gt$1,ne,and,sql,or,desc,asc}from'drizzle-orm';import {z}from'zod';function L(l){return l}function f(l){if(!l.model.table)throw new Error(`Model ${l.model.tableName} does not have a table reference`);return l.model.table}function m(l,e){let o=getTableColumns(l),n=o[e];if(!n)throw new Error(`Column '${e}' not found in table. Available columns: ${Object.keys(o).join(", ")}`);return n}async function Te(l,e,o,n){if(!n.table)return e;let t=n.table;switch(n.type){case "hasOne":{let r=n.localKey||"id",s=e[r];if(s==null)return e;let a=m(t,n.foreignKey),i=await l.select().from(t).where(eq(a,s)).limit(1);return {...e,[o]:i[0]||null}}case "hasMany":{let r=n.localKey||"id",s=e[r];if(s==null)return {...e,[o]:[]};let a=m(t,n.foreignKey),i=await l.select().from(t).where(eq(a,s));return {...e,[o]:i}}case "belongsTo":{let r=e[n.foreignKey];if(r==null)return {...e,[o]:null};let s=m(t,n.localKey||"id"),a=await l.select().from(t).where(eq(s,r)).limit(1);return {...e,[o]:a[0]||null}}default:return e}}async function ee(l,e,o,n){if(!n?.relations?.length||!o.model.relations)return e;let t={...e};for(let r of n.relations){let s=o.model.relations[r];s&&(t=await Te(l,t,r,s));}return t}async function v(l,e,o,n){if(!e.length||!n?.relations?.length||!o.model.relations)return e;let t=e.map(r=>({...r}));for(let r of n.relations){let s=o.model.relations[r];if(!s||!s.table)continue;let a=s.table;switch(s.type){case "hasOne":case "hasMany":{let i=s.localKey||"id",u=[...new Set(t.map(p=>p[i]).filter(p=>p!=null))];if(u.length===0){t=t.map(p=>({...p,[r]:s.type==="hasMany"?[]:null}));continue}let c=m(a,s.foreignKey),d=await l.select().from(a).where(inArray(c,u)),g=new Map;for(let p of d){let b=p[s.foreignKey];g.has(b)||g.set(b,[]),g.get(b).push(p);}t=t.map(p=>{let b=p[i],D=g.get(b)||[];return {...p,[r]:s.type==="hasMany"?D:D[0]||null}});break}case "belongsTo":{let i=s.localKey||"id",u=[...new Set(t.map(p=>p[s.foreignKey]).filter(p=>p!=null))];if(u.length===0){t=t.map(p=>({...p,[r]:null}));continue}let c=m(a,i),d=await l.select().from(a).where(inArray(c,u)),g=new Map;for(let p of d){let b=p[i];g.set(b,p);}t=t.map(p=>{let b=p[s.foreignKey];return {...p,[r]:g.get(b)||null}});break}}}return t}function E(l,e){let o=m(l,e.field);switch(e.operator){case "eq":return eq(o,e.value);case "ne":return ne(o,e.value);case "gt":return gt$1(o,e.value);case "gte":return gte(o,e.value);case "lt":return lt$1(o,e.value);case "lte":return lte(o,e.value);case "in":return inArray(o,e.value);case "nin":return notInArray(o,e.value);case "like":return like(o,e.value);case "ilike":return ilike(o,e.value);case "null":return e.value?isNull(o):isNotNull(o);case "between":{let[n,t]=e.value;return between(o,n,t)}default:return}}function y(l){let e=l;if(e._tx)return e._tx;if(e.db)return e.db;let o=e.context?.get?.("db");if(o)return o;throw new Error(`Database not configured. Either:
1
+ import {k,l,m as m$1,n,o,p,r,s,t,u,q as q$1,v,w,x as x$1,y,z as z$1,A,B as B$1,J,K,T,U as U$1}from'../../chunk-Q4FF5JVS.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-W4FHI5YI.js';import'../../chunk-HAUN4LQO.js';import'../../chunk-NIWM7GOK.js';import'../../chunk-RFT77JBK.js';import'../../chunk-FC56WWPB.js';import'../../chunk-GBQQ3YQX.js';import'../../chunk-QRXEQTNE.js';import'../../chunk-QXFY6NYI.js';import {b}from'../../chunk-DMGP7QDL.js';import'../../chunk-MDHMZPXK.js';import'../../chunk-VJRDAVID.js';import {getTableColumns,eq,inArray,between,isNull,isNotNull,ilike,like,notInArray,lte,lt as lt$1,gte,gt as gt$1,ne,and,sql,or,desc,asc}from'drizzle-orm';import {z}from'zod';function L(l){return l}function f(l){if(!l.model.table)throw new Error(`Model ${l.model.tableName} does not have a table reference`);return l.model.table}function m(l,e){let o=getTableColumns(l),n=o[e];if(!n)throw new Error(`Column '${e}' not found in table. Available columns: ${Object.keys(o).join(", ")}`);return n}async function Te(l,e,o,n){if(!n.table)return e;let t=n.table;switch(n.type){case "hasOne":{let r=n.localKey||"id",s=e[r];if(s==null)return e;let a=m(t,n.foreignKey),i=await l.select().from(t).where(eq(a,s)).limit(1);return {...e,[o]:i[0]||null}}case "hasMany":{let r=n.localKey||"id",s=e[r];if(s==null)return {...e,[o]:[]};let a=m(t,n.foreignKey),i=await l.select().from(t).where(eq(a,s));return {...e,[o]:i}}case "belongsTo":{let r=e[n.foreignKey];if(r==null)return {...e,[o]:null};let s=m(t,n.localKey||"id"),a=await l.select().from(t).where(eq(s,r)).limit(1);return {...e,[o]:a[0]||null}}default:return e}}async function ee(l,e,o,n){if(!n?.relations?.length||!o.model.relations)return e;let t={...e};for(let r of n.relations){let s=o.model.relations[r];s&&(t=await Te(l,t,r,s));}return t}async function O(l,e,o,n){if(!e.length||!n?.relations?.length||!o.model.relations)return e;let t=e.map(r=>({...r}));for(let r of n.relations){let s=o.model.relations[r];if(!s||!s.table)continue;let a=s.table;switch(s.type){case "hasOne":case "hasMany":{let i=s.localKey||"id",u=[...new Set(t.map(p=>p[i]).filter(p=>p!=null))];if(u.length===0){t=t.map(p=>({...p,[r]:s.type==="hasMany"?[]:null}));continue}let d=m(a,s.foreignKey),c=await l.select().from(a).where(inArray(d,u)),g=new Map;for(let p of c){let b=p[s.foreignKey];g.has(b)||g.set(b,[]),g.get(b).push(p);}t=t.map(p=>{let b=p[i],y=g.get(b)||[];return {...p,[r]:s.type==="hasMany"?y:y[0]||null}});break}case "belongsTo":{let i=s.localKey||"id",u=[...new Set(t.map(p=>p[s.foreignKey]).filter(p=>p!=null))];if(u.length===0){t=t.map(p=>({...p,[r]:null}));continue}let d=m(a,i),c=await l.select().from(a).where(inArray(d,u)),g=new Map;for(let p of c){let b=p[i];g.set(b,p);}t=t.map(p=>{let b=p[s.foreignKey];return {...p,[r]:g.get(b)||null}});break}}}return t}function x(l,e){let o=m(l,e.field);switch(e.operator){case "eq":return eq(o,e.value);case "ne":return ne(o,e.value);case "gt":return gt$1(o,e.value);case "gte":return gte(o,e.value);case "lt":return lt$1(o,e.value);case "lte":return lte(o,e.value);case "in":return inArray(o,e.value);case "nin":return notInArray(o,e.value);case "like":return like(o,e.value);case "ilike":return ilike(o,e.value);case "null":return e.value?isNull(o):isNotNull(o);case "between":{let[n,t]=e.value;return between(o,n,t)}default:return}}function D(l){let e=l;if(e._tx)return e._tx;if(e.db)return e.db;let o=e.context?.get?.("db");if(o)return o;throw new Error(`Database not configured. Either:
2
2
  1. Set db property: db = myDb;
3
3
  2. Use middleware: c.set("db", myDb);
4
- 3. Use factory: createDrizzleCrud(db, meta)`)}var S=class extends k{db;useTransaction=false;_tx;getDb(){return y(this)}getTable(){return f(this._meta)}getRelatedTable(e){return e.table}async create(e,o){let n=o??this.getDb(),t=this.getTable(),r=this._meta.model.primaryKeys[0],s={...e,[r]:e[r]||crypto.randomUUID()};return (await n.insert(t).values(s).returning())[0]}async createNested(e,o,n,t,r){let s=r??this.getDb(),a=this.getRelatedTable(n);if(!a)return b().warn(`Related table not found for ${o}. Add 'table' to the relation config.`),[];let i=Array.isArray(t)?t:[t],u=[];for(let c of i){if(typeof c!="object"||c===null)continue;let d={...c,id:crypto.randomUUID(),[n.foreignKey]:e},g=await s.insert(a).values(d).returning();g[0]&&u.push(g[0]);}return u}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}},_=class extends l{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async read(e,o,n){let t=this.getTable(),r=this.getColumn(this.lookupField),s=this.getSoftDeleteConfig(),a=[eq(r,e)];if(o)for(let[c,d]of Object.entries(o))a.push(eq(this.getColumn(c),d));s.enabled&&a.push(isNull(this.getColumn(s.field)));let i=await this.getDb().select().from(t).where(and(...a)).limit(1);return i[0]?await ee(this.getDb(),i[0],this._meta,n):null}},I=class extends m$1{db;useTransaction=false;_tx;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}getRelatedTable(e){return e.table}async findExisting(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[c,d]of Object.entries(o))i.push(eq(this.getColumn(c),d));return a.enabled&&i.push(isNull(this.getColumn(a.field))),(await t.select().from(r).where(and(...i)).limit(1))[0]||null}async update(e,o,n,t){let r=t??this.getDb(),s=this.getTable(),a=this.getColumn(this.lookupField),i=this.getSoftDeleteConfig(),u=[eq(a,e)];if(n)for(let[d,g]of Object.entries(n))u.push(eq(this.getColumn(d),g));return i.enabled&&u.push(isNull(this.getColumn(i.field))),(await r.update(s).set(o).where(and(...u)).returning())[0]||null}async processNestedWrites(e,o,n,t,r){let s=r??this.getDb(),a=this.getRelatedTable(n);if(!a)return b().warn(`Related table not found for ${o}. Add 'table' to the relation config.`),{created:[],updated:[],deleted:[],connected:[],disconnected:[]};let i={created:[],updated:[],deleted:[],connected:[],disconnected:[]},u=m(a,n.foreignKey),c=m(a,"id");if(t.create){let d=Array.isArray(t.create)?t.create:[t.create];for(let g of d){if(typeof g!="object"||g===null)continue;let p={...g,id:crypto.randomUUID(),[n.foreignKey]:e},b=await s.insert(a).values(p).returning();b[0]&&i.created.push(b[0]);}}if(t.update)for(let d of t.update){if(!d.id||!(await s.select().from(a).where(and(eq(c,d.id),eq(u,e))).limit(1))[0])continue;let{id:p,...b}=d,D=await s.update(a).set(b).where(eq(c,p)).returning();D[0]&&i.updated.push(D[0]);}if(t.delete)for(let d of t.delete)(await s.delete(a).where(and(eq(c,d),eq(u,e))).returning())[0]&&i.deleted.push(d);if(t.connect)for(let d of t.connect)(await s.update(a).set({[n.foreignKey]:e}).where(eq(c,d)).returning())[0]&&i.connected.push(d);if(t.disconnect)for(let d of t.disconnect)(await s.update(a).set({[n.foreignKey]:null}).where(and(eq(c,d),eq(u,e))).returning())[0]&&i.disconnected.push(d);return i}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}},P=class extends n{db;useTransaction=false;_tx;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}getRelatedTable(e){return e.table}async findForDelete(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[c,d]of Object.entries(o))i.push(eq(this.getColumn(c),d));return a.enabled&&i.push(isNull(this.getColumn(a.field))),(await t.select().from(r).where(and(...i)).limit(1))[0]||null}async delete(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[u,c]of Object.entries(o))i.push(eq(this.getColumn(u),c));return a.enabled&&i.push(isNull(this.getColumn(a.field))),a.enabled?(await t.update(r).set({[a.field]:new Date}).where(and(...i)).returning())[0]||null:(await t.delete(r).where(and(...i)).returning())[0]||null}async countRelated(e,o,n,t){let r=t??this.getDb(),s=this.getRelatedTable(n);if(!s)return 0;let a=m(s,n.foreignKey),i=await r.select({count:sql`count(*)`}).from(s).where(eq(a,e));return Number(i[0]?.count)||0}async deleteRelated(e,o,n,t){let r=t??this.getDb(),s=this.getRelatedTable(n);if(!s)return 0;let a=m(s,n.foreignKey);return (await r.delete(s).where(eq(a,e)).returning()).length}async nullifyRelated(e,o,n,t){let r=t??this.getDb(),s=this.getRelatedTable(n);if(!s)return 0;let a=m(s,n.foreignKey);return (await r.update(s).set({[n.foreignKey]:null}).where(eq(a,e)).returning()).length}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}},U=class extends o{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async list(e){let o=this.getTable(),n=[],t=this.getSoftDeleteConfig();if(t.enabled){let z=this.getColumn(t.field);e.options.onlyDeleted?n.push(isNotNull(z)):e.options.withDeleted||n.push(isNull(z));}for(let z of e.filters){let R=E(o,z);R&&n.push(R);}if(e.options.search&&this.searchFields.length>0){let z=this.searchFields.map(R=>{let H=this.getColumn(R);return sql`LOWER(${H}) LIKE LOWER(${`%${e.options.search}%`})`});n.push(or(...z));}let r=n.length>0?and(...n):void 0,s=this.getDb(),a=await s.select({count:sql`count(*)`}).from(o).where(r),i=Number(a[0]?.count)||0,u=s.select().from(o).where(r);if(e.options.order_by){let z=this.getColumn(e.options.order_by),R=e.options.order_by_direction==="desc"?desc:asc;u=u.orderBy(R(z));}let c=e.options.page||1,d=e.options.per_page||this.defaultPerPage;u=u.limit(d).offset((c-1)*d);let g=await u,p={relations:e.options.include||[]},b=await v(this.getDb(),g,this._meta,p),D=Math.ceil(i/d);return {result:b,result_info:{page:c,per_page:d,total_count:i,total_pages:D,has_next_page:c<D,has_prev_page:c>1}}}},B=class extends p{db;useTransaction=false;_tx;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async restore(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[c,d]of Object.entries(o))i.push(eq(this.getColumn(c),d));return i.push(isNotNull(this.getColumn(a.field))),(await t.update(r).set({[a.field]:null}).where(and(...i)).returning())[0]||null}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}};var Q=class extends r{db;getDb(){return y(this)}getTable(){return f(this._meta)}async batchCreate(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t=e.map(s=>({...s,[n]:s[n]||crypto.randomUUID()}));return await this.getDb().insert(o).values(t).returning()}},N=class extends s{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async batchUpdate(e){let o=this.getTable(),n=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[],s=[];for(let a of e){let i=[eq(n,a.id)];t.enabled&&i.push(isNull(this.getColumn(t.field)));let u=await this.getDb().update(o).set(a.data).where(and(...i)).returning();u[0]?r.push(u[0]):s.push(a.id);}return {updated:r,notFound:s}}},F=class extends t{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async batchDelete(e){let o=this.getTable(),n=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[inArray(n,e)];t.enabled&&r.push(isNull(this.getColumn(t.field)));let s;t.enabled?s=await this.getDb().update(o).set({[t.field]:new Date}).where(and(...r)).returning():s=await this.getDb().delete(o).where(and(...r)).returning();let a=s,i=new Set(a.map(c=>String(c[this.lookupField]))),u=e.filter(c=>!i.has(c));return {deleted:a,notFound:u}}},$=class extends u{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async batchRestore(e){let o=this.getTable(),n=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[inArray(n,e),isNotNull(this.getColumn(t.field))],a=await this.getDb().update(o).set({[t.field]:null}).where(and(...r)).returning(),i=new Set(a.map(c=>String(c[this.lookupField]))),u=e.filter(c=>!i.has(c));return {restored:a,notFound:u}}};var q=class extends q$1{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async findExisting(e){let o=this.getTable(),n=this.getUpsertKeys(),t=this.getSoftDeleteConfig(),r=[];for(let a of n){let i=e[a];i!==void 0&&r.push(eq(this.getColumn(a),i));}return t.enabled&&r.push(isNull(this.getColumn(t.field))),r.length===0?null:(await this.getDb().select().from(o).where(and(...r)).limit(1))[0]||null}async create(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t={...e,[n]:e[n]||crypto.randomUUID()};return (await this.getDb().insert(o).values(t).returning())[0]}async update(e,o){let n=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(n).set(o).where(eq(this.getColumn(t),r)).returning())[0]}async nativeUpsert(e,o){let n=this.getTable(),t=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s=this.getSoftDeleteConfig(),a={...e,[r]:e[r]||crypto.randomUUID()},i={};for(let[d,g]of Object.entries(e))!t.includes(d)&&d!==r&&(this.createOnlyFields?.includes(d)||(i[d]=g));let u=t.map(d=>this.getColumn(d)),c;s.enabled&&(c=isNull(this.getColumn(s.field)));try{return {data:(await this.getDb().insert(n).values(a).onConflictDoUpdate({target:u,set:Object.keys(i).length>0?i:{[r]:sql`${this.getColumn(r)}`},where:c}).returning())[0],created:!1}}catch(d){if(d instanceof Error&&d.message.includes("onConflictDoUpdate"))try{return {data:(await this.getDb().insert(n).values(a).onDuplicateKeyUpdate({set:Object.keys(i).length>0?i:{[r]:sql`${this.getColumn(r)}`}}).returning())[0],created:!1}}catch{return this.performStandardUpsert(e,o)}throw d}}},W=class extends v$1{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async findExisting(e){let o=this.getTable(),n=this.getUpsertKeys(),t=[];for(let s of n){let a=e[s];a!==void 0&&t.push(eq(this.getColumn(s),a));}return t.length===0?null:(await this.getDb().select().from(o).where(and(...t)).limit(1))[0]||null}async create(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t={...e,[n]:e[n]||crypto.randomUUID()};return (await this.getDb().insert(o).values(t).returning())[0]}async update(e,o){let n=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(n).set(o).where(eq(this.getColumn(t),r)).returning())[0]}async nativeBatchUpsert(e,o){if(e.length===0)return {items:[],createdCount:0,updatedCount:0,totalCount:0};let n=this.getTable(),t=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s=e.map(c=>({...c,[r]:c[r]||crypto.randomUUID()})),a={},i=e[0];for(let c of Object.keys(i))!t.includes(c)&&c!==r&&(this.createOnlyFields?.includes(c)||(a[c]=sql`excluded.${sql.identifier(c)}`));let u=t.map(c=>this.getColumn(c));try{let d=await this.getDb().insert(n).values(s).onConflictDoUpdate({target:u,set:Object.keys(a).length>0?a:{[r]:sql`${this.getColumn(r)}`}}).returning();return {items:d.map((g,p)=>({data:g,created:!1,index:p})),createdCount:0,updatedCount:d.length,totalCount:d.length}}catch(c){if(c instanceof Error&&c.message.includes("onConflictDoUpdate"))try{let g=await this.getDb().insert(n).values(s).onDuplicateKeyUpdate({set:Object.keys(a).length>0?a:{[r]:sql`${this.getColumn(r)}`}}).returning();return {items:g.map((p,b)=>({data:p,created:!1,index:b})),createdCount:0,updatedCount:g.length,totalCount:g.length}}catch{return this.performStandardBatchUpsert(e,o)}throw c}}},ke=class extends w{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async recordExists(e){let o=this.getTable(),n=await this.getDb().select({count:sql`count(*)`}).from(o).where(eq(this.getColumn("id"),e));return Number(n[0]?.count)>0}},ve=class extends x{},Oe=class extends y$1{},je=class extends z$1{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async rollback(e,o,n){let t=this.getTable(),r=this.getVersioningConfig().field;return (await this.getDb().update(t).set({...o,[r]:n}).where(eq(this.getColumn("id"),e)).returning())[0]}},Se=class extends A{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async aggregate(e){let o=this.getTable(),n=[],t=this.getSoftDeleteConfig();if(t.enabled){let{query:a}=await this.getValidatedData();a?.withDeleted===true||a?.withDeleted==="true"||n.push(isNull(this.getColumn(t.field)));}if(e.filters)for(let[a,i]of Object.entries(e.filters))if(typeof i=="object"&&i!==null)for(let[u,c]of Object.entries(i)){let d=E(o,{field:a,operator:u,value:c});d&&n.push(d);}else n.push(eq(this.getColumn(a),i));let r=n.length>0?and(...n):void 0,s=await this.getDb().select().from(o).where(r);return B$1(s,e)}},_e=class extends J{db;getDb(){return y(this)}useNativeSearch=false;vectorColumn;vectorConfig="english";getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async search(e,o){let n=this.getTable(),t=[],r=this.getSoftDeleteConfig();r.enabled&&(o.options.onlyDeleted?t.push(isNotNull(this.getColumn(r.field))):o.options.withDeleted||t.push(isNull(this.getColumn(r.field))));for(let w of o.filters){let C=E(n,w);C&&t.push(C);}let s=this.getSearchableFields(),a=e.fields||Object.keys(s);if(this.useNativeSearch&&this.vectorColumn){let w=this.getColumn(this.vectorColumn),C=e.mode==="phrase"?sql`phraseto_tsquery(${this.vectorConfig}, ${e.query})`:e.mode==="all"?sql`plainto_tsquery(${this.vectorConfig}, ${e.query})`:sql`to_tsquery(${this.vectorConfig}, ${e.query.split(/\s+/).join(" | ")})`;t.push(sql`${w} @@ ${C}`);}else {let w=a.map(C=>{try{let Qe=this.getColumn(C);return sql`LOWER(CAST(${Qe} AS TEXT)) LIKE LOWER(${`%${e.query}%`})`}catch{return}}).filter(C=>C!==void 0);w.length>0&&(e.mode==="all"?t.push(and(...w)):t.push(or(...w)));}let i=t.length>0?and(...t):void 0,u=await this.getDb().select({count:sql`count(*)`}).from(n).where(i),c=Number(u[0]?.count)||0,d=this.getDb().select().from(n).where(i);if(o.options.order_by){let w=this.getColumn(o.options.order_by),C=o.options.order_by_direction==="desc"?desc:asc;d=d.orderBy(C(w));}let g=o.options.page||1,p=o.options.per_page||this.defaultPerPage;d=d.limit(p).offset((g-1)*p);let b=await d,D=K(b,e,s),z={relations:o.options.include||[]},R=D.map(w=>w.item),H=await v(this.getDb(),R,this._meta,z);return {items:D.map((w,C)=>({...w,item:H[C]})),totalCount:c}}},Ie=class extends T{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async list(e){let o=this.getTable(),n=[],t=this.getSoftDeleteConfig();if(t.enabled){let D=this.getColumn(t.field);e.options.onlyDeleted?n.push(isNotNull(D)):e.options.withDeleted||n.push(isNull(D));}for(let D of e.filters){let z=E(o,D);z&&n.push(z);}if(e.options.search&&this.searchFields.length>0){let D=this.searchFields.map(z=>{let R=this.getColumn(z);return sql`LOWER(${R}) LIKE LOWER(${`%${e.options.search}%`})`});n.push(or(...D));}let r=n.length>0?and(...n):void 0,s=await this.getDb().select({count:sql`count(*)`}).from(o).where(r),a=Number(s[0]?.count)||0,i=this.getDb().select().from(o).where(r);if(e.options.order_by){let D=this.getColumn(e.options.order_by),z=e.options.order_by_direction==="desc"?desc:asc;i=i.orderBy(z(D));}let u=e.options.page||1,c=e.options.per_page||this.defaultPerPage;i=i.limit(c).offset((u-1)*c);let d=await i,g={relations:e.options.include||[]},p=await v(this.getDb(),d,this._meta,g),b=Math.ceil(a/c);return {result:p,result_info:{page:u,per_page:c,total_count:a,total_pages:b,has_next_page:u<b,has_prev_page:u>1}}}},Pe=class extends U$1{db;getDb(){return y(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async findExisting(e){let o=this.getTable(),n=this.getUpsertKeys(),t=this.getSoftDeleteConfig(),r=[];for(let a of n){let i=e[a];i!==void 0&&r.push(eq(this.getColumn(a),i));}return t.enabled&&r.push(isNull(this.getColumn(t.field))),r.length===0?null:(await this.getDb().select().from(o).where(and(...r)).limit(1))[0]||null}async create(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t={...e,[n]:e[n]||crypto.randomUUID()};return (await this.getDb().insert(o).values(t).returning())[0]}async update(e,o){let n=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(n).set(o).where(eq(this.getColumn(t),r)).returning())[0]}};function Ht(l,e){return {Create:class extends S{_meta=e;db=l},Read:class extends _{_meta=e;db=l},Update:class extends I{_meta=e;db=l},Delete:class extends P{_meta=e;db=l},List:class extends U{_meta=e;db=l},Restore:class extends B{_meta=e;db=l},Upsert:class extends q{_meta=e;db=l},BatchCreate:class extends Q{_meta=e;db=l},BatchUpdate:class extends N{_meta=e;db=l},BatchDelete:class extends F{_meta=e;db=l},BatchRestore:class extends ${_meta=e;db=l},BatchUpsert:class extends W{_meta=e;db=l}}}var Jt={CreateEndpoint:S,ListEndpoint:U,ReadEndpoint:_,UpdateEndpoint:I,DeleteEndpoint:P};var X=null,Be=false,V=null;async function G(){if(Be){if(V)throw V;return X}Be=true;try{return X=await import('drizzle-zod'),X}catch{throw V=new Error("drizzle-zod is not installed. Please install it: npm install drizzle-zod"),V}}async function at(l,e){return (await G()).createSelectSchema(l,e)}async function it(l,e){return (await G()).createInsertSchema(l,e)}async function lt(l,e){let o=await G();return o.createUpdateSchema?o.createUpdateSchema(l,e):o.createInsertSchema(l,e).partial()}async function ct(l,e){let o=await G(),n=e?.coerceDates!==false,t=n?gt(l):new Set,r=o.createSelectSchema(l,e?.selectRefine),s=o.createInsertSchema(l,e?.insertRefine),a;return o.createUpdateSchema?a=o.createUpdateSchema(l,e?.updateRefine):a=o.createInsertSchema(l,e?.updateRefine).partial(),n&&t.size>0&&(s=Ze(s,t),a=Ze(a,t)),{select:r,insert:s,update:a}}function dt(){return X!==null}var ut=z.preprocess(l=>{if(l instanceof Date)return l;if(typeof l=="string"){let e=new Date(l);if(!isNaN(e.getTime()))return e}return l},z.date()),pt=z.preprocess(l=>{if(l==null)return null;if(l instanceof Date)return l;if(typeof l=="string"){let e=new Date(l);if(!isNaN(e.getTime()))return e}return l},z.date().nullable());function gt(l){let e=new Set,o=l;for(let[n,t]of Object.entries(o)){if(n==="_"||n==="$inferInsert"||n==="$inferSelect")continue;let r=t;if(!r||typeof r!="object")continue;let s=String(r.dataType??"").toLowerCase(),a=String(r.columnType??"").toLowerCase(),i=r.config,u=String(i?.dataType??"").toLowerCase();(s.includes("timestamp")||s.includes("date")||s.includes("datetime")||a.includes("pgtimestamp")||a.includes("pgdate")||a.includes("mysqltimestamp")||a.includes("mysqldate")||a.includes("sqlitetimestamp")||u.includes("timestamp")||u.includes("date"))&&e.add(n);}return e}function Ze(l,e){if(e.size===0)return l;let o=l.shape,n={};for(let[t,r]of Object.entries(o))if(e.has(t)){let s=r.isOptional?.()??false,a=r.isNullable?.()??false,i=ut;(a||s)&&(i=pt),s&&(i=i.optional()),n[t]=i;}else n[t]=r;return z.object(n)}export{Jt as DrizzleAdapters,Se as DrizzleAggregateEndpoint,Q as DrizzleBatchCreateEndpoint,F as DrizzleBatchDeleteEndpoint,$ as DrizzleBatchRestoreEndpoint,N as DrizzleBatchUpdateEndpoint,W as DrizzleBatchUpsertEndpoint,S as DrizzleCreateEndpoint,P as DrizzleDeleteEndpoint,Ie as DrizzleExportEndpoint,Pe as DrizzleImportEndpoint,U as DrizzleListEndpoint,_ as DrizzleReadEndpoint,B as DrizzleRestoreEndpoint,_e as DrizzleSearchEndpoint,I as DrizzleUpdateEndpoint,q as DrizzleUpsertEndpoint,Oe as DrizzleVersionCompareEndpoint,ke as DrizzleVersionHistoryEndpoint,ve as DrizzleVersionReadEndpoint,je as DrizzleVersionRollbackEndpoint,v as batchLoadDrizzleRelations,E as buildWhereCondition,L as cast,Ht as createDrizzleCrud,ct as createDrizzleSchemas,it as createInsertSchema,at as createSelectSchema,lt as createUpdateSchema,m as getColumn,f as getTable,dt as isDrizzleZodAvailable,Te as loadDrizzleRelation,ee as loadDrizzleRelations};
4
+ 3. Use factory: createDrizzleCrud(db, meta)`)}var S=class extends k{db;useTransaction=false;_tx;getDb(){return D(this)}getTable(){return f(this._meta)}getRelatedTable(e){return e.table}async create(e,o){let n=o??this.getDb(),t=this.getTable(),r=this._meta.model.primaryKeys[0],s={...e,[r]:e[r]||crypto.randomUUID()};return (await n.insert(t).values(s).returning())[0]}async createNested(e,o,n,t,r){let s=r??this.getDb(),a=this.getRelatedTable(n);if(!a)return b().warn(`Related table not found for ${o}. Add 'table' to the relation config.`),[];let i=Array.isArray(t)?t:[t],u=[];for(let d of i){if(typeof d!="object"||d===null)continue;let c={...d,id:crypto.randomUUID(),[n.foreignKey]:e},g=await s.insert(a).values(c).returning();g[0]&&u.push(g[0]);}return u}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}},_=class extends l{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async read(e,o,n){let t=this.getTable(),r=this.getColumn(this.lookupField),s=this.getSoftDeleteConfig(),a=[eq(r,e)];if(o)for(let[d,c]of Object.entries(o))a.push(eq(this.getColumn(d),c));s.enabled&&a.push(isNull(this.getColumn(s.field)));let i=await this.getDb().select().from(t).where(and(...a)).limit(1);return i[0]?await ee(this.getDb(),i[0],this._meta,n):null}},I=class extends m$1{db;useTransaction=false;_tx;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}getRelatedTable(e){return e.table}async findExisting(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[d,c]of Object.entries(o))i.push(eq(this.getColumn(d),c));return a.enabled&&i.push(isNull(this.getColumn(a.field))),(await t.select().from(r).where(and(...i)).limit(1))[0]||null}async update(e,o,n,t){let r=t??this.getDb(),s=this.getTable(),a=this.getColumn(this.lookupField),i=this.getSoftDeleteConfig(),u=[eq(a,e)];if(n)for(let[c,g]of Object.entries(n))u.push(eq(this.getColumn(c),g));return i.enabled&&u.push(isNull(this.getColumn(i.field))),(await r.update(s).set(o).where(and(...u)).returning())[0]||null}async processNestedWrites(e,o,n,t,r){let s=r??this.getDb(),a=this.getRelatedTable(n);if(!a)return b().warn(`Related table not found for ${o}. Add 'table' to the relation config.`),{created:[],updated:[],deleted:[],connected:[],disconnected:[]};let i={created:[],updated:[],deleted:[],connected:[],disconnected:[]},u=m(a,n.foreignKey),d=m(a,"id");if(t.create){let c=Array.isArray(t.create)?t.create:[t.create];for(let g of c){if(typeof g!="object"||g===null)continue;let p={...g,id:crypto.randomUUID(),[n.foreignKey]:e},b=await s.insert(a).values(p).returning();b[0]&&i.created.push(b[0]);}}if(t.update)for(let c of t.update){if(!c.id||!(await s.select().from(a).where(and(eq(d,c.id),eq(u,e))).limit(1))[0])continue;let{id:p,...b}=c,y=await s.update(a).set(b).where(eq(d,p)).returning();y[0]&&i.updated.push(y[0]);}if(t.delete)for(let c of t.delete)(await s.delete(a).where(and(eq(d,c),eq(u,e))).returning())[0]&&i.deleted.push(c);if(t.connect)for(let c of t.connect)(await s.update(a).set({[n.foreignKey]:e}).where(eq(d,c)).returning())[0]&&i.connected.push(c);if(t.disconnect)for(let c of t.disconnect)(await s.update(a).set({[n.foreignKey]:null}).where(and(eq(d,c),eq(u,e))).returning())[0]&&i.disconnected.push(c);return i}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}},P=class extends n{db;useTransaction=false;_tx;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}getRelatedTable(e){return e.table}async findForDelete(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[d,c]of Object.entries(o))i.push(eq(this.getColumn(d),c));return a.enabled&&i.push(isNull(this.getColumn(a.field))),(await t.select().from(r).where(and(...i)).limit(1))[0]||null}async delete(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[u,d]of Object.entries(o))i.push(eq(this.getColumn(u),d));return a.enabled&&i.push(isNull(this.getColumn(a.field))),a.enabled?(await t.update(r).set({[a.field]:new Date}).where(and(...i)).returning())[0]||null:(await t.delete(r).where(and(...i)).returning())[0]||null}async countRelated(e,o,n,t){let r=t??this.getDb(),s=this.getRelatedTable(n);if(!s)return 0;let a=m(s,n.foreignKey),i=await r.select({count:sql`count(*)`}).from(s).where(eq(a,e));return Number(i[0]?.count)||0}async deleteRelated(e,o,n,t){let r=t??this.getDb(),s=this.getRelatedTable(n);if(!s)return 0;let a=m(s,n.foreignKey);return (await r.delete(s).where(eq(a,e)).returning()).length}async nullifyRelated(e,o,n,t){let r=t??this.getDb(),s=this.getRelatedTable(n);if(!s)return 0;let a=m(s,n.foreignKey);return (await r.update(s).set({[n.foreignKey]:null}).where(eq(a,e)).returning()).length}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}},U=class extends o{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async list(e){let o=this.getTable(),n=[],t=this.getSoftDeleteConfig();if(t.enabled){let z=this.getColumn(t.field);e.options.onlyDeleted?n.push(isNotNull(z)):e.options.withDeleted||n.push(isNull(z));}for(let z of e.filters){let R=x(o,z);R&&n.push(R);}if(e.options.search&&this.searchFields.length>0){let z=this.searchFields.map(R=>{let H=this.getColumn(R);return sql`LOWER(${H}) LIKE LOWER(${`%${e.options.search}%`})`});n.push(or(...z));}let r=n.length>0?and(...n):void 0,s=this.getDb(),a=await s.select({count:sql`count(*)`}).from(o).where(r),i=Number(a[0]?.count)||0,u=s.select().from(o).where(r);if(e.options.order_by){let z=this.getColumn(e.options.order_by),R=e.options.order_by_direction==="desc"?desc:asc;u=u.orderBy(R(z));}let d=e.options.page||1,c=e.options.per_page||this.defaultPerPage;u=u.limit(c).offset((d-1)*c);let g=await u,p={relations:e.options.include||[]},b=await O(this.getDb(),g,this._meta,p),y=Math.ceil(i/c);return {result:b,result_info:{page:d,per_page:c,total_count:i,total_pages:y,has_next_page:d<y,has_prev_page:d>1}}}},B=class extends p{db;useTransaction=false;_tx;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async restore(e,o,n){let t=n??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),i=[eq(s,e)];if(o)for(let[d,c]of Object.entries(o))i.push(eq(this.getColumn(d),c));return i.push(isNotNull(this.getColumn(a.field))),(await t.update(r).set({[a.field]:null}).where(and(...i)).returning())[0]||null}async handle(){return this.useTransaction?this.getDb().transaction(async e=>{this._tx=e;try{return await super.handle()}finally{this._tx=void 0;}}):super.handle()}};var Q=class extends r{db;getDb(){return D(this)}getTable(){return f(this._meta)}async batchCreate(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t=e.map(s=>({...s,[n]:s[n]||crypto.randomUUID()}));return await this.getDb().insert(o).values(t).returning()}},N=class extends s{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async batchUpdate(e){let o=this.getTable(),n=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[],s=[];for(let a of e){let i=[eq(n,a.id)];t.enabled&&i.push(isNull(this.getColumn(t.field)));let u=await this.getDb().update(o).set(a.data).where(and(...i)).returning();u[0]?r.push(u[0]):s.push(a.id);}return {updated:r,notFound:s}}},F=class extends t{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async batchDelete(e){let o=this.getTable(),n=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[inArray(n,e)];t.enabled&&r.push(isNull(this.getColumn(t.field)));let s;t.enabled?s=await this.getDb().update(o).set({[t.field]:new Date}).where(and(...r)).returning():s=await this.getDb().delete(o).where(and(...r)).returning();let a=s,i=new Set(a.map(d=>String(d[this.lookupField]))),u=e.filter(d=>!i.has(d));return {deleted:a,notFound:u}}},$=class extends u{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async batchRestore(e){let o=this.getTable(),n=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[inArray(n,e),isNotNull(this.getColumn(t.field))],a=await this.getDb().update(o).set({[t.field]:null}).where(and(...r)).returning(),i=new Set(a.map(d=>String(d[this.lookupField]))),u=e.filter(d=>!i.has(d));return {restored:a,notFound:u}}};var q=class extends q$1{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async findExisting(e){let o=this.getTable(),n=this.getUpsertKeys(),t=this.getSoftDeleteConfig(),r=[];for(let a of n){let i=e[a];i!==void 0&&r.push(eq(this.getColumn(a),i));}return t.enabled&&r.push(isNull(this.getColumn(t.field))),r.length===0?null:(await this.getDb().select().from(o).where(and(...r)).limit(1))[0]||null}async create(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t={...e,[n]:e[n]||crypto.randomUUID()};return (await this.getDb().insert(o).values(t).returning())[0]}async update(e,o){let n=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(n).set(o).where(eq(this.getColumn(t),r)).returning())[0]}async nativeUpsert(e,o){let n=this.getTable(),t=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s=this.getSoftDeleteConfig(),a={...e,[r]:e[r]||crypto.randomUUID()},i={};for(let[c,g]of Object.entries(e))!t.includes(c)&&c!==r&&(this.createOnlyFields?.includes(c)||(i[c]=g));let u=t.map(c=>this.getColumn(c)),d;s.enabled&&(d=isNull(this.getColumn(s.field)));try{return {data:(await this.getDb().insert(n).values(a).onConflictDoUpdate({target:u,set:Object.keys(i).length>0?i:{[r]:sql`${this.getColumn(r)}`},where:d}).returning())[0],created:!1}}catch(c){if(c instanceof Error&&c.message.includes("onConflictDoUpdate"))try{return {data:(await this.getDb().insert(n).values(a).onDuplicateKeyUpdate({set:Object.keys(i).length>0?i:{[r]:sql`${this.getColumn(r)}`}}).returning())[0],created:!1}}catch{return this.performStandardUpsert(e,o)}throw c}}},W=class extends v{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async findExisting(e){let o=this.getTable(),n=this.getUpsertKeys(),t=[];for(let s of n){let a=e[s];a!==void 0&&t.push(eq(this.getColumn(s),a));}return t.length===0?null:(await this.getDb().select().from(o).where(and(...t)).limit(1))[0]||null}async create(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t={...e,[n]:e[n]||crypto.randomUUID()};return (await this.getDb().insert(o).values(t).returning())[0]}async update(e,o){let n=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(n).set(o).where(eq(this.getColumn(t),r)).returning())[0]}async nativeBatchUpsert(e,o){if(e.length===0)return {items:[],createdCount:0,updatedCount:0,totalCount:0};let n=this.getTable(),t=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s=e.map(d=>({...d,[r]:d[r]||crypto.randomUUID()})),a={},i=e[0];for(let d of Object.keys(i))!t.includes(d)&&d!==r&&(this.createOnlyFields?.includes(d)||(a[d]=sql`excluded.${sql.identifier(d)}`));let u=t.map(d=>this.getColumn(d));try{let c=await this.getDb().insert(n).values(s).onConflictDoUpdate({target:u,set:Object.keys(a).length>0?a:{[r]:sql`${this.getColumn(r)}`}}).returning();return {items:c.map((g,p)=>({data:g,created:!1,index:p})),createdCount:0,updatedCount:c.length,totalCount:c.length}}catch(d){if(d instanceof Error&&d.message.includes("onConflictDoUpdate"))try{let g=await this.getDb().insert(n).values(s).onDuplicateKeyUpdate({set:Object.keys(a).length>0?a:{[r]:sql`${this.getColumn(r)}`}}).returning();return {items:g.map((p,b)=>({data:p,created:!1,index:b})),createdCount:0,updatedCount:g.length,totalCount:g.length}}catch{return this.performStandardBatchUpsert(e,o)}throw d}}},ke=class extends w{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async recordExists(e){let o=this.getTable(),n=await this.getDb().select({count:sql`count(*)`}).from(o).where(eq(this.getColumn("id"),e));return Number(n[0]?.count)>0}},Oe=class extends x$1{},ve=class extends y{},je=class extends z$1{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async rollback(e,o,n){let t=this.getTable(),r=this.getVersioningConfig().field;return (await this.getDb().update(t).set({...o,[r]:n}).where(eq(this.getColumn("id"),e)).returning())[0]}},Se=class extends A{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async aggregate(e){let o=this.getTable(),n=[],t=this.getSoftDeleteConfig();if(t.enabled){let{query:a}=await this.getValidatedData();a?.withDeleted===true||a?.withDeleted==="true"||n.push(isNull(this.getColumn(t.field)));}if(e.filters)for(let[a,i]of Object.entries(e.filters))if(typeof i=="object"&&i!==null)for(let[u,d]of Object.entries(i)){let c=x(o,{field:a,operator:u,value:d});c&&n.push(c);}else n.push(eq(this.getColumn(a),i));let r=n.length>0?and(...n):void 0,s=await this.getDb().select().from(o).where(r);return B$1(s,e)}},_e=class extends J{db;getDb(){return D(this)}useNativeSearch=false;vectorColumn;vectorConfig="english";getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async search(e,o){let n=this.getTable(),t=[],r=this.getSoftDeleteConfig();r.enabled&&(o.options.onlyDeleted?t.push(isNotNull(this.getColumn(r.field))):o.options.withDeleted||t.push(isNull(this.getColumn(r.field))));for(let w of o.filters){let C=x(n,w);C&&t.push(C);}let s=this.getSearchableFields(),a=e.fields||Object.keys(s);if(this.useNativeSearch&&this.vectorColumn){let w=this.getColumn(this.vectorColumn),C=e.mode==="phrase"?sql`phraseto_tsquery(${this.vectorConfig}, ${e.query})`:e.mode==="all"?sql`plainto_tsquery(${this.vectorConfig}, ${e.query})`:sql`to_tsquery(${this.vectorConfig}, ${e.query.split(/\s+/).join(" | ")})`;t.push(sql`${w} @@ ${C}`);}else {let w=a.map(C=>{try{let Qe=this.getColumn(C);return sql`LOWER(CAST(${Qe} AS TEXT)) LIKE LOWER(${`%${e.query}%`})`}catch{return}}).filter(C=>C!==void 0);w.length>0&&(e.mode==="all"?t.push(and(...w)):t.push(or(...w)));}let i=t.length>0?and(...t):void 0,u=await this.getDb().select({count:sql`count(*)`}).from(n).where(i),d=Number(u[0]?.count)||0,c=this.getDb().select().from(n).where(i);if(o.options.order_by){let w=this.getColumn(o.options.order_by),C=o.options.order_by_direction==="desc"?desc:asc;c=c.orderBy(C(w));}let g=o.options.page||1,p=o.options.per_page||this.defaultPerPage;c=c.limit(p).offset((g-1)*p);let b=await c,y=K(b,e,s),z={relations:o.options.include||[]},R=y.map(w=>w.item),H=await O(this.getDb(),R,this._meta,z);return {items:y.map((w,C)=>({...w,item:H[C]})),totalCount:d}}},Ie=class extends T{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async list(e){let o=this.getTable(),n=[],t=this.getSoftDeleteConfig();if(t.enabled){let y=this.getColumn(t.field);e.options.onlyDeleted?n.push(isNotNull(y)):e.options.withDeleted||n.push(isNull(y));}for(let y of e.filters){let z=x(o,y);z&&n.push(z);}if(e.options.search&&this.searchFields.length>0){let y=this.searchFields.map(z=>{let R=this.getColumn(z);return sql`LOWER(${R}) LIKE LOWER(${`%${e.options.search}%`})`});n.push(or(...y));}let r=n.length>0?and(...n):void 0,s=await this.getDb().select({count:sql`count(*)`}).from(o).where(r),a=Number(s[0]?.count)||0,i=this.getDb().select().from(o).where(r);if(e.options.order_by){let y=this.getColumn(e.options.order_by),z=e.options.order_by_direction==="desc"?desc:asc;i=i.orderBy(z(y));}let u=e.options.page||1,d=e.options.per_page||this.defaultPerPage;i=i.limit(d).offset((u-1)*d);let c=await i,g={relations:e.options.include||[]},p=await O(this.getDb(),c,this._meta,g),b=Math.ceil(a/d);return {result:p,result_info:{page:u,per_page:d,total_count:a,total_pages:b,has_next_page:u<b,has_prev_page:u>1}}}},Pe=class extends U$1{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return m(this.getTable(),e)}async findExisting(e){let o=this.getTable(),n=this.getUpsertKeys(),t=this.getSoftDeleteConfig(),r=[];for(let a of n){let i=e[a];i!==void 0&&r.push(eq(this.getColumn(a),i));}return t.enabled&&r.push(isNull(this.getColumn(t.field))),r.length===0?null:(await this.getDb().select().from(o).where(and(...r)).limit(1))[0]||null}async create(e){let o=this.getTable(),n=this._meta.model.primaryKeys[0],t={...e,[n]:e[n]||crypto.randomUUID()};return (await this.getDb().insert(o).values(t).returning())[0]}async update(e,o){let n=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(n).set(o).where(eq(this.getColumn(t),r)).returning())[0]}};function Ht(l,e){return {Create:class extends S{_meta=e;db=l},Read:class extends _{_meta=e;db=l},Update:class extends I{_meta=e;db=l},Delete:class extends P{_meta=e;db=l},List:class extends U{_meta=e;db=l},Restore:class extends B{_meta=e;db=l},Upsert:class extends q{_meta=e;db=l},BatchCreate:class extends Q{_meta=e;db=l},BatchUpdate:class extends N{_meta=e;db=l},BatchDelete:class extends F{_meta=e;db=l},BatchRestore:class extends ${_meta=e;db=l},BatchUpsert:class extends W{_meta=e;db=l}}}var Jt={CreateEndpoint:S,ListEndpoint:U,ReadEndpoint:_,UpdateEndpoint:I,DeleteEndpoint:P};var X=null,Be=false,V=null;async function G(){if(Be){if(V)throw V;return X}Be=true;try{return X=await import('drizzle-zod'),X}catch{throw V=new Error("drizzle-zod is not installed. Please install it: npm install drizzle-zod"),V}}async function at(l,e){return (await G()).createSelectSchema(l,e)}async function it(l,e){return (await G()).createInsertSchema(l,e)}async function lt(l,e){let o=await G();return o.createUpdateSchema?o.createUpdateSchema(l,e):o.createInsertSchema(l,e).partial()}async function dt(l,e){let o=await G(),n=e?.coerceDates!==false,t=n?gt(l):new Set,r=o.createSelectSchema(l,e?.selectRefine),s=o.createInsertSchema(l,e?.insertRefine),a;return o.createUpdateSchema?a=o.createUpdateSchema(l,e?.updateRefine):a=o.createInsertSchema(l,e?.updateRefine).partial(),n&&t.size>0&&(s=Ze(s,t),a=Ze(a,t)),{select:r,insert:s,update:a}}function ct(){return X!==null}var ut=z.preprocess(l=>{if(l instanceof Date)return l;if(typeof l=="string"){let e=new Date(l);if(!isNaN(e.getTime()))return e}return l},z.date()),pt=z.preprocess(l=>{if(l==null)return null;if(l instanceof Date)return l;if(typeof l=="string"){let e=new Date(l);if(!isNaN(e.getTime()))return e}return l},z.date().nullable());function gt(l){let e=new Set,o=l;for(let[n,t]of Object.entries(o)){if(n==="_"||n==="$inferInsert"||n==="$inferSelect")continue;let r=t;if(!r||typeof r!="object")continue;let s=String(r.dataType??"").toLowerCase(),a=String(r.columnType??"").toLowerCase(),i=r.config,u=String(i?.dataType??"").toLowerCase();(s.includes("timestamp")||s.includes("date")||s.includes("datetime")||a.includes("pgtimestamp")||a.includes("pgdate")||a.includes("mysqltimestamp")||a.includes("mysqldate")||a.includes("sqlitetimestamp")||u.includes("timestamp")||u.includes("date"))&&e.add(n);}return e}function Ze(l,e){if(e.size===0)return l;let o=l.shape,n={};for(let[t,r]of Object.entries(o))if(e.has(t)){let s=r.isOptional?.()??false,a=r.isNullable?.()??false,i=ut;(a||s)&&(i=pt),s&&(i=i.optional()),n[t]=i;}else n[t]=r;return z.object(n)}export{Jt as DrizzleAdapters,Se as DrizzleAggregateEndpoint,Q as DrizzleBatchCreateEndpoint,F as DrizzleBatchDeleteEndpoint,$ as DrizzleBatchRestoreEndpoint,N as DrizzleBatchUpdateEndpoint,W as DrizzleBatchUpsertEndpoint,S as DrizzleCreateEndpoint,P as DrizzleDeleteEndpoint,Ie as DrizzleExportEndpoint,Pe as DrizzleImportEndpoint,U as DrizzleListEndpoint,_ as DrizzleReadEndpoint,B as DrizzleRestoreEndpoint,_e as DrizzleSearchEndpoint,I as DrizzleUpdateEndpoint,q as DrizzleUpsertEndpoint,ve as DrizzleVersionCompareEndpoint,ke as DrizzleVersionHistoryEndpoint,Oe as DrizzleVersionReadEndpoint,je as DrizzleVersionRollbackEndpoint,O as batchLoadDrizzleRelations,x as buildWhereCondition,L as cast,Ht as createDrizzleCrud,dt as createDrizzleSchemas,it as createInsertSchema,at as createSelectSchema,lt as createUpdateSchema,m as getColumn,f as getTable,ct as isDrizzleZodAvailable,Te as loadDrizzleRelation,ee as loadDrizzleRelations};
@@ -1,9 +1,9 @@
1
1
  import { Env } from 'hono';
2
- import { a as CreateEndpoint, M as ModelObject, D as DeleteEndpoint, L as ListEndpoint, R as ReadEndpoint, b as RestoreEndpoint, U as UpdateEndpoint, B as BatchCreateEndpoint, c as BatchDeleteEndpoint, d as BatchRestoreEndpoint, e as BatchUpdateEndpoint, f as BatchUpdateItem, g as BatchUpsertEndpoint, A as AggregateEndpoint, E as ExportEndpoint, I as ImportEndpoint, S as SearchEndpoint, h as UpsertEndpoint, V as VersionCompareEndpoint, i as VersionHistoryEndpoint, j as VersionReadEndpoint, k as VersionRollbackEndpoint } from '../../import-BHD2B1u8.js';
3
- import { M as MetaInput, f as RelationConfig, L as ListFilters, P as PaginatedResult, I as IncludeOptions, N as NestedUpdateInput, g as NestedWriteResult, h as AggregateOptions, i as AggregateResult, S as SearchOptions, j as SearchResult } from '../../types-5BBVU0EY.js';
4
- import { B as BulkPatchEndpoint, C as CloneEndpoint } from '../../bulk-patch-CoEduhTf.js';
2
+ import { a as CreateEndpoint, M as ModelObject, D as DeleteEndpoint, L as ListEndpoint, R as ReadEndpoint, b as RestoreEndpoint, U as UpdateEndpoint, B as BatchCreateEndpoint, c as BatchDeleteEndpoint, d as BatchRestoreEndpoint, e as BatchUpdateEndpoint, f as BatchUpdateItem, g as BatchUpsertEndpoint, A as AggregateEndpoint, E as ExportEndpoint, I as ImportEndpoint, S as SearchEndpoint, h as UpsertEndpoint, V as VersionCompareEndpoint, i as VersionHistoryEndpoint, j as VersionReadEndpoint, k as VersionRollbackEndpoint } from '../../import-Co7vvjkO.js';
3
+ import { M as MetaInput, f as RelationConfig, L as ListFilters, P as PaginatedResult, I as IncludeOptions, N as NestedUpdateInput, g as NestedWriteResult, h as AggregateOptions, i as AggregateResult, S as SearchOptions, j as SearchResult } from '../../types-T4ThpPOK.js';
4
+ import { B as BulkPatchEndpoint, C as CloneEndpoint } from '../../bulk-patch-Kg8XagOd.js';
5
5
  import 'zod';
6
- import '../../route-BmtmmHSO.js';
6
+ import '../../route-CSScNXhr.js';
7
7
  import 'hono/utils/http-status';
8
8
  import '../../audit/index.js';
9
9
  import '../../registry-PNJjvSvm.js';
@@ -1,8 +1,8 @@
1
1
  import { Env } from 'hono';
2
- import { a as CreateEndpoint, M as ModelObject, D as DeleteEndpoint, L as ListEndpoint, R as ReadEndpoint, U as UpdateEndpoint, B as BatchCreateEndpoint, c as BatchDeleteEndpoint, d as BatchRestoreEndpoint, e as BatchUpdateEndpoint, f as BatchUpdateItem, g as BatchUpsertEndpoint, b as RestoreEndpoint, A as AggregateEndpoint, E as ExportEndpoint, I as ImportEndpoint, S as SearchEndpoint, h as UpsertEndpoint, V as VersionCompareEndpoint, i as VersionHistoryEndpoint, j as VersionReadEndpoint, k as VersionRollbackEndpoint } from '../../import-BHD2B1u8.js';
3
- import { M as MetaInput, L as ListFilters, P as PaginatedResult, I as IncludeOptions, h as AggregateOptions, i as AggregateResult, k as AggregateField, S as SearchOptions, j as SearchResult } from '../../types-5BBVU0EY.js';
2
+ import { a as CreateEndpoint, M as ModelObject, D as DeleteEndpoint, L as ListEndpoint, R as ReadEndpoint, U as UpdateEndpoint, B as BatchCreateEndpoint, c as BatchDeleteEndpoint, d as BatchRestoreEndpoint, e as BatchUpdateEndpoint, f as BatchUpdateItem, g as BatchUpsertEndpoint, b as RestoreEndpoint, A as AggregateEndpoint, E as ExportEndpoint, I as ImportEndpoint, S as SearchEndpoint, h as UpsertEndpoint, V as VersionCompareEndpoint, i as VersionHistoryEndpoint, j as VersionReadEndpoint, k as VersionRollbackEndpoint } from '../../import-Co7vvjkO.js';
3
+ import { M as MetaInput, L as ListFilters, P as PaginatedResult, I as IncludeOptions, h as AggregateOptions, i as AggregateResult, k as AggregateField, S as SearchOptions, j as SearchResult } from '../../types-T4ThpPOK.js';
4
4
  import 'zod';
5
- import '../../route-BmtmmHSO.js';
5
+ import '../../route-CSScNXhr.js';
6
6
  import 'hono/utils/http-status';
7
7
  import '../../audit/index.js';
8
8
  import '../../registry-PNJjvSvm.js';
@@ -70,8 +70,8 @@ interface PrismaModelOperations {
70
70
  count: number;
71
71
  }>;
72
72
  }
73
- type PrismaClient = Record<string, PrismaModelOperations> & {
74
- $transaction: <T>(fn: (tx: PrismaClient) => Promise<T>) => Promise<T>;
73
+ type PrismaClient = object & {
74
+ $transaction?: <T>(fn: (tx: PrismaClient) => Promise<T>) => Promise<T>;
75
75
  };
76
76
  /**
77
77
  * Registers a custom table name to Prisma model name mapping.
@@ -1 +1 @@
1
- import {k as k$1,l,m,n,o,p,r,s,t,u,v as v$1,J,K,T,U,q,w,x,y as y$1,z,A,B}from'../../chunk-Q4FF5JVS.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-W4FHI5YI.js';import'../../chunk-HAUN4LQO.js';import'../../chunk-NIWM7GOK.js';import'../../chunk-RFT77JBK.js';import'../../chunk-FC56WWPB.js';import'../../chunk-GBQQ3YQX.js';import'../../chunk-QRXEQTNE.js';import'../../chunk-QXFY6NYI.js';import'../../chunk-DMGP7QDL.js';import'../../chunk-MDHMZPXK.js';import'../../chunk-VJRDAVID.js';var R,v;async function Oe(){if(R)return R;try{return R=(await import('pluralize')).default,R}catch{throw new Error('The "pluralize" package is required. Install it with: npm install pluralize')}}async function Re(){if(v)return v;try{return v=(await import('fastest-levenshtein')).distance,v}catch{throw new Error('The "fastest-levenshtein" package is required. Install it with: npm install fastest-levenshtein')}}async function E(i){return (await Oe()).singular(i)}async function C(i,t){return (await Re())(i,t)}function k(i){if(typeof i=="string"){if(/^-?\d+$/.test(i))return parseInt(i,10);if(/^-?\d+\.\d+$/.test(i))return parseFloat(i);if(i==="true")return true;if(i==="false")return false}return i}function I(i){let t={};for(let e of i){let o=k(e.value);switch(e.operator){case "eq":t[e.field]=o;break;case "ne":t[e.field]={not:o};break;case "gt":t[e.field]={gt:o};break;case "gte":t[e.field]={gte:o};break;case "lt":t[e.field]={lt:o};break;case "lte":t[e.field]={lte:o};break;case "in":{let n=Array.isArray(e.value)?e.value:[e.value];t[e.field]={in:n.map(k)};break}case "nin":{let n=Array.isArray(e.value)?e.value:[e.value];t[e.field]={notIn:n.map(k)};break}case "like":t[e.field]={contains:String(e.value).replace(/%/g,"")};break;case "ilike":t[e.field]={contains:String(e.value).replace(/%/g,""),mode:"insensitive"};break;case "null":t[e.field]=e.value?null:{not:null};break;case "between":{let[n,r]=e.value;t[e.field]={gte:k(n),lte:k(r)};break}}}return t}var ve=500,y=new Map;function ee(i,t){if(y.size>=ve){let e=y.keys().next().value;e!==void 0&&y.delete(e);}y.set(i,t);}var F=new Map;function te(i,t){F.set(i.toLowerCase(),t),y.delete(i);}function _e(i){for(let[t,e]of Object.entries(i))te(t,e);}function je(){F.clear(),y.clear();}async function h(i){let t=y.get(i);if(t)return t;let e=F.get(i.toLowerCase());if(e)return ee(i,e),e;let o=i.replace(/[-_](.)/g,(n,r)=>r.toUpperCase()).replace(/^./,n=>n.toLowerCase());return o=await E(o),ee(i,o),o}function Ee(i){let t=[];for(let e of Object.keys(i)){if(e.startsWith("$")||e.startsWith("_"))continue;let o=i[e];o&&typeof o=="object"&&"create"in o&&t.push(e);}return t}async function Ce(i,t,e=3){if(t.length===0)return [];let o=i.toLowerCase();return (await Promise.all(t.map(async r=>({name:r,distance:await C(o,r.toLowerCase())})))).filter(r=>r.distance<=Math.max(3,i.length/2)).sort((r,s)=>r.distance-s.distance).slice(0,e).map(r=>r.name)}async function f(i,t){let e=await h(t),o=i[e];if(!o||typeof o.create!="function"){let n=Ee(i),r=await Ce(e,n),s=`Model '${e}' not found in Prisma client. Table name: '${t}'. `;throw r.length>0&&(s+=`Did you mean: ${r.map(a=>`'${a}'`).join(", ")}? `),n.length>0&&n.length<=10&&(s+=`Available models: ${n.join(", ")}. `),s+=`You can register a custom mapping with: registerPrismaModelMapping('${t}', 'yourModelName')`,new Error(s)}return o}async function Ie(i,t,e,o){let n=await h(o.model),r=i[n];if(!r)return t;switch(o.type){case "hasOne":{let s=o.localKey||"id",a=t[s];if(a==null)return {...t,[e]:null};let l=await r.findFirst({where:{[o.foreignKey]:a}});return {...t,[e]:l||null}}case "hasMany":{let s=o.localKey||"id",a=t[s];if(a==null)return {...t,[e]:[]};let l=await r.findMany({where:{[o.foreignKey]:a}});return {...t,[e]:l}}case "belongsTo":{let s=t[o.foreignKey];if(s==null)return {...t,[e]:null};let a=o.localKey||"id",l=await r.findFirst({where:{[a]:s}});return {...t,[e]:l||null}}default:return t}}async function ne(i,t,e,o){if(!o?.relations?.length||!e.model.relations)return t;let n={...t};for(let r of o.relations){let s=e.model.relations[r];s&&(n=await Ie(i,n,r,s));}return n}async function P(i,t,e,o){if(!t.length||!o?.relations?.length||!e.model.relations)return t;let n=t.map(r=>({...r}));for(let r of o.relations){let s=e.model.relations[r];if(!s)continue;let a=await h(s.model),l=i[a];if(l)switch(s.type){case "hasOne":case "hasMany":{let u=s.localKey||"id",c=[...new Set(n.map(m=>m[u]).filter(m=>m!=null))];if(c.length===0){n=n.map(m=>({...m,[r]:s.type==="hasMany"?[]:null}));continue}let d=await l.findMany({where:{[s.foreignKey]:{in:c}}}),p=new Map;for(let m of d){let g=m[s.foreignKey];p.has(g)||p.set(g,[]),p.get(g).push(m);}n=n.map(m=>{let g=m[u],M=p.get(g)||[];return {...m,[r]:s.type==="hasMany"?M:M[0]||null}});break}case "belongsTo":{let u=s.localKey||"id",c=[...new Set(n.map(m=>m[s.foreignKey]).filter(m=>m!=null))];if(c.length===0){n=n.map(m=>({...m,[r]:null}));continue}let d=await l.findMany({where:{[u]:{in:c}}}),p=new Map;for(let m of d){let g=m[u];p.set(g,m);}n=n.map(m=>{let g=m[s.foreignKey];return {...m,[r]:p.get(g)||null}});break}}}return n}async function _(i){let{model:t,filters:e,searchFields:o=[],softDeleteConfig:n,defaultPerPage:r=20,additionalWhere:s={}}=i,a={...I(e.filters),...s};if(n?.enabled){let{withDeleted:g,onlyDeleted:M}=e.options;M?a[n.field]={not:null}:g||(a[n.field]=null);}if(e.options.search&&o.length>0){let g=o.map(M=>({[M]:{contains:e.options.search,mode:"insensitive"}}));a={...a,OR:g};}let l=await t.count({where:a}),u;e.options.order_by&&(u={[e.options.order_by]:e.options.order_by_direction||"asc"});let c=e.options.page||1,d=e.options.per_page||r,p=await t.findMany({where:a,orderBy:u,skip:(c-1)*d,take:d}),m=Math.ceil(l/d);return {records:p,where:a,totalCount:l,page:c,perPage:d,totalPages:m}}function j(i,t){return {result:i,result_info:{page:t.page,per_page:t.perPage,total_count:t.totalCount,total_pages:t.totalPages,has_next_page:t.page<t.totalPages,has_prev_page:t.page>1}}}var oe=class extends k$1{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}},re=class extends l{async getModel(){return f(this.prisma,this._meta.model.tableName)}async read(t,e,o){let n=await this.getModel(),r={[this.lookupField]:t,...e},s=await n.findFirst({where:r});return s?await ne(this.prisma,s,this._meta,o):null}},se=class extends m{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async update(t,e,o){let n=await this.getModel(),r={[this.lookupField]:t,...o},s=await n.findFirst({where:r});if(!s)return null;let a=this._meta.model.primaryKeys[0];return await n.update({where:{[a]:s[a]},data:e})}},ae=class extends n{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async findForDelete(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),r={[this.lookupField]:t,...e};return n.enabled&&(r[n.field]=null),await o.findFirst({where:r})}async delete(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),r={[this.lookupField]:t,...e};n.enabled&&(r[n.field]=null);let s=await o.findFirst({where:r});if(!s)return null;let a=this._meta.model.primaryKeys[0],l=s[a];return n.enabled?await o.update({where:{[a]:l},data:{[n.field]:new Date}}):await o.delete({where:{[a]:l}})}},ie=class extends o{async getModel(){return f(this.prisma,this._meta.model.tableName)}async list(t){let e=await _({model:await this.getModel(),filters:t,searchFields:this.searchFields,softDeleteConfig:this.getSoftDeleteConfig(),defaultPerPage:this.defaultPerPage}),o={relations:t.options.include||[]},n=await P(this.prisma,e.records,this._meta,o);return j(n,e)}};var le=class extends p{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async restore(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),r={[this.lookupField]:t,[n.field]:{not:null},...e},s=await o.findFirst({where:r});if(!s)return null;let a=this._meta.model.primaryKeys[0];return await o.update({where:{[a]:s[a]},data:{[n.field]:null}})}},de=class extends r{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchCreate(t){let e=this._meta.model.primaryKeys[0],o=t.map(r=>({...r,[e]:r[e]||crypto.randomUUID()})),n=[];return await this.prisma.$transaction(async r=>{let s=r[await h(this._meta.model.tableName)];for(let a of o){let l=await s.create({data:a});n.push(l);}}),n}},ce=class extends s{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchUpdate(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],r=[],s=[],a=t.map(d=>d.id),l={[this.lookupField]:{in:a}};o.enabled&&(l[o.field]=null);let u=await e.findMany({where:l}),c=new Map;for(let d of u){let p=d[this.lookupField];c.set(p,d);}for(let d of t){let p=c.get(d.id);if(!p){s.push(d.id);continue}let m=await e.update({where:{[n]:p[n]},data:d.data});r.push(m);}return {updated:r,notFound:s}}},ue=class extends t{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchDelete(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],r=[],s=[],a={[this.lookupField]:{in:t}};o.enabled&&(a[o.field]=null);let l=await e.findMany({where:a}),u=new Map;for(let c of l){let d=c[this.lookupField];u.set(d,c);}for(let c of t)u.has(c)||s.push(c);for(let c of t){let d=u.get(c);if(d)if(o.enabled){let p=await e.update({where:{[n]:d[n]},data:{[o.field]:new Date}});r.push(p);}else {let p=await e.delete({where:{[n]:d[n]}});r.push(p);}}return {deleted:r,notFound:s}}},me=class extends u{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchRestore(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],r=[],s=[],a={[this.lookupField]:{in:t},[o.field]:{not:null}},l=await e.findMany({where:a}),u=new Map;for(let c of l){let d=c[this.lookupField];u.set(d,c);}for(let c of t){let d=u.get(c);if(!d){s.push(c);continue}let p=await e.update({where:{[n]:d[n]},data:{[o.field]:null}});r.push(p);}return {restored:r,notFound:s}}},ge=class extends v$1{useTransaction=true;async getModel(){return f(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let s of o){let a=t[s];a!==void 0&&(n[s]=a);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:e})}async nativeBatchUpsert(t,e){if(t.length===0)return {items:[],createdCount:0,updatedCount:0,totalCount:0};let o=this.getUpsertKeys(),n=this._meta.model.primaryKeys[0],r=async l=>{let u=l[await h(this._meta.model.tableName)],c=[],d=[];for(let p=0;p<t.length;p++){let m=t[p];try{let g={};for(let w of o){let x=m[w];x!==void 0&&(g[w]=x);}let M={...m,[n]:m[n]||crypto.randomUUID()},b={};for(let[w,x]of Object.entries(m))!o.includes(w)&&w!==n&&(this.createOnlyFields?.includes(w)||(b[w]=x));let xe=await u.upsert({where:g,create:M,update:Object.keys(b).length>0?b:{}});c.push({data:xe,created:!1,index:p});}catch(g){if(this.continueOnError)d.push({index:p,error:g instanceof Error?g.message:String(g)});else throw g}}return {results:c,errors:d}},s;this.useTransaction?s=await this.prisma.$transaction(r):s=await r(this.prisma);let a={items:s.results,createdCount:0,updatedCount:s.results.length,totalCount:s.results.length};return s.errors.length>0&&(a.errors=s.errors),a}};var pe=class extends J{async getModel(){return f(this.prisma,this._meta.model.tableName)}buildSearchWhere(t,e){let o=I(e.filters),n=this.getSoftDeleteConfig();if(n.enabled){let{withDeleted:l,onlyDeleted:u}=e.options;u?o[n.field]={not:null}:l||(o[n.field]=null);}let r=this.getSearchableFields(),a=(t.fields||Object.keys(r)).map(l=>({[l]:{contains:t.query,mode:"insensitive"}}));return a.length>0&&(t.mode==="all"?o={...o,AND:a}:o={...o,OR:a}),o}async search(t,e){let o=await this.getModel(),n=this.buildSearchWhere(t,e),r=await o.count({where:n}),s=e.options.order_by?{[e.options.order_by]:e.options.order_by_direction||"asc"}:void 0,a=e.options.page||1,l=e.options.per_page||this.defaultPerPage,u=await o.findMany({where:n,orderBy:s,skip:(a-1)*l,take:l}),c=K(u,t,this.getSearchableFields()),d={relations:e.options.include||[]},p=c.map(M=>M.item),m=await P(this.prisma,p,this._meta,d);return {items:c.map((M,b)=>({...M,item:m[b]})),totalCount:r}}},fe=class extends T{async getModel(){return f(this.prisma,this._meta.model.tableName)}async list(t){let e=await _({model:await this.getModel(),filters:t,searchFields:this.searchFields,softDeleteConfig:this.getSoftDeleteConfig(),defaultPerPage:this.defaultPerPage}),o={relations:t.options.include||[]},n=await P(this.prisma,e.records,this._meta,o);return j(n,e)}},Me=class extends U{async getModel(){return f(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let s of o){let a=t[s];a!==void 0&&(n[s]=a);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:e})}},he=class extends q{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let s of o){let a=t[s];a!==void 0&&(n[s]=a);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:e})}async nativeUpsert(t,e){let o=await this.getModel(),n=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s={};for(let c of n){let d=t[c];d!==void 0&&(s[c]=d);}let a={...t,[r]:t[r]||crypto.randomUUID()},l={};for(let[c,d]of Object.entries(t))!n.includes(c)&&c!==r&&(this.createOnlyFields?.includes(c)||(l[c]=d));return {data:await o.upsert({where:s,create:a,update:Object.keys(l).length>0?l:{}}),created:false}}},we=class extends w{async getModel(){return f(this.prisma,this._meta.model.tableName)}async recordExists(t){return await(await this.getModel()).count({where:{[this.lookupField]:t}})>0}},ye=class extends x{},be=class extends y$1{},ke=class extends z{async getModel(){return f(this.prisma,this._meta.model.tableName)}async rollback(t,e,o){let n=await this.getModel(),r=this.getVersioningConfig().field,s=this._meta.model.primaryKeys[0],a=await n.findFirst({where:{[this.lookupField]:t}});if(!a)throw new Error(`Record not found: ${t}`);return await n.update({where:{[s]:a[s]},data:{...e,[r]:o}})}},Pe=class extends A{useNativeAggregation=true;async getModel(){return f(this.prisma,this._meta.model.tableName)}async buildAggregateWhere(t){let e={},o=this.getSoftDeleteConfig();if(o.enabled){let{query:n}=await this.getValidatedData();n?.withDeleted===true||n?.withDeleted==="true"||(e[o.field]=null);}if(t.filters)for(let[n,r]of Object.entries(t.filters))if(typeof r=="object"&&r!==null){let s={};for(let[a,l]of Object.entries(r))switch(a){case "eq":s.equals=l;break;case "ne":s.not=l;break;case "gt":s.gt=l;break;case "gte":s.gte=l;break;case "lt":s.lt=l;break;case "lte":s.lte=l;break;case "in":s.in=l;break;case "nin":s.notIn=l;break;default:s[a]=l;}e[n]=s;}else e[n]=r;return e}async aggregate(t){let e=await this.getModel(),o=await this.buildAggregateWhere(t);if(!this.useNativeAggregation||t.having){let n=await e.findMany({where:o});return B(n,t)}return t.groupBy?.length?this.aggregateWithGroupBy(e,o,t):this.aggregateSimple(e,o,t)}groupAggregationsByOperation(t){let e={sum:[],avg:[],min:[],max:[],count:[],countDistinct:[]};for(let o of t)switch(o.operation){case "sum":e.sum.push(o.field);break;case "avg":e.avg.push(o.field);break;case "min":e.min.push(o.field);break;case "max":e.max.push(o.field);break;case "count":e.count.push(o.field);break;case "countDistinct":e.countDistinct.push(o.field);break}return e}async aggregateSimple(t,e,o){let n={where:e},r={},s=this.groupAggregationsByOperation(o.aggregations);if(n._count=true,s.sum.length){n._sum={};for(let u of s.sum)n._sum[u]=true;}if(s.avg.length){n._avg={};for(let u of s.avg)n._avg[u]=true;}if(s.min.length){n._min={};for(let u of s.min)n._min[u]=true;}if(s.max.length){n._max={};for(let u of s.max)n._max[u]=true;}let a=await h(this._meta.model.tableName),l=this.prisma[a];try{let u=await l.aggregate(n);if(u._count!==void 0&&(r.count=typeof u._count=="object"?u._count._all??0:u._count),u._sum&&s.sum.length)for(let c of s.sum){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`sum${d}`]=u._sum[c]??0;}if(u._avg&&s.avg.length)for(let c of s.avg){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`avg${d}`]=u._avg[c]??0;}if(u._min&&s.min.length)for(let c of s.min){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`min${d}`]=u._min[c];}if(u._max&&s.max.length)for(let c of s.max){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`max${d}`]=u._max[c];}return {values:r,groups:[]}}catch{let c=await t.findMany({where:e});return B(c,o)}}async aggregateWithGroupBy(t,e,o){let n={by:o.groupBy,where:e},r=this.groupAggregationsByOperation(o.aggregations);if(n._count=true,r.sum.length){n._sum={};for(let l of r.sum)n._sum[l]=true;}if(r.avg.length){n._avg={};for(let l of r.avg)n._avg[l]=true;}if(r.min.length){n._min={};for(let l of r.min)n._min[l]=true;}if(r.max.length){n._max={};for(let l of r.max)n._max[l]=true;}let s=await h(this._meta.model.tableName),a=this.prisma[s];try{let u=(await a.groupBy(n)).map(d=>{let p={},m={};for(let g of o.groupBy)p[g]=d[g];if(m.count=typeof d._count=="object"?d._count._all??0:d._count??0,d._sum&&r.sum.length)for(let g of r.sum){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`sum${M}`]=d._sum[g]??0;}if(d._avg&&r.avg.length)for(let g of r.avg){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`avg${M}`]=d._avg[g]??0;}if(d._min&&r.min.length)for(let g of r.min){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`min${M}`]=d._min[g];}if(d._max&&r.max.length)for(let g of r.max){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`max${M}`]=d._max[g];}return {key:p,values:m}});return {values:{count:u.reduce((d,p)=>d+(p.values.count||0),0)},groups:u}}catch{let u=await t.findMany({where:e});return B(u,o)}}};export{Pe as PrismaAggregateEndpoint,de as PrismaBatchCreateEndpoint,ue as PrismaBatchDeleteEndpoint,me as PrismaBatchRestoreEndpoint,ce as PrismaBatchUpdateEndpoint,ge as PrismaBatchUpsertEndpoint,oe as PrismaCreateEndpoint,ae as PrismaDeleteEndpoint,fe as PrismaExportEndpoint,Me as PrismaImportEndpoint,ie as PrismaListEndpoint,re as PrismaReadEndpoint,le as PrismaRestoreEndpoint,pe as PrismaSearchEndpoint,se as PrismaUpdateEndpoint,he as PrismaUpsertEndpoint,be as PrismaVersionCompareEndpoint,we as PrismaVersionHistoryEndpoint,ye as PrismaVersionReadEndpoint,ke as PrismaVersionRollbackEndpoint,je as clearPrismaModelMappings,te as registerPrismaModelMapping,_e as registerPrismaModelMappings};
1
+ import {k as k$1,l,m,n,o,p,r,s,t,u,v as v$1,J,K as K$1,T,U,q,w as w$1,x as x$1,y,z,A,B}from'../../chunk-Q4FF5JVS.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-W4FHI5YI.js';import'../../chunk-HAUN4LQO.js';import'../../chunk-NIWM7GOK.js';import'../../chunk-RFT77JBK.js';import'../../chunk-FC56WWPB.js';import'../../chunk-GBQQ3YQX.js';import'../../chunk-QRXEQTNE.js';import'../../chunk-QXFY6NYI.js';import'../../chunk-DMGP7QDL.js';import'../../chunk-MDHMZPXK.js';import'../../chunk-VJRDAVID.js';var v,_;async function _e(){if(v)return v;try{return v=(await import('pluralize')).default,v}catch{throw new Error('The "pluralize" package is required. Install it with: npm install pluralize')}}async function je(){if(_)return _;try{return _=(await import('fastest-levenshtein')).distance,_}catch{throw new Error('The "fastest-levenshtein" package is required. Install it with: npm install fastest-levenshtein')}}async function C(a){return (await _e()).singular(a)}async function I(a,t){return (await je())(a,t)}function oe(a,t){return a[t]}function Ee(a){return typeof a=="object"&&a!==null&&"create"in a&&typeof a.create=="function"}function h(a,t){let e=oe(a,t);return Ee(e)?e:void 0}function F(a){if(typeof a.$transaction!="function")throw new Error("Prisma client does not support $transaction");return a.$transaction.bind(a)}function k(a){if(typeof a=="string"){if(/^-?\d+$/.test(a))return parseInt(a,10);if(/^-?\d+\.\d+$/.test(a))return parseFloat(a);if(a==="true")return true;if(a==="false")return false}return a}function K(a){let t={};for(let e of a){let o=k(e.value);switch(e.operator){case "eq":t[e.field]=o;break;case "ne":t[e.field]={not:o};break;case "gt":t[e.field]={gt:o};break;case "gte":t[e.field]={gte:o};break;case "lt":t[e.field]={lt:o};break;case "lte":t[e.field]={lte:o};break;case "in":{let n=Array.isArray(e.value)?e.value:[e.value];t[e.field]={in:n.map(k)};break}case "nin":{let n=Array.isArray(e.value)?e.value:[e.value];t[e.field]={notIn:n.map(k)};break}case "like":t[e.field]={contains:String(e.value).replace(/%/g,"")};break;case "ilike":t[e.field]={contains:String(e.value).replace(/%/g,""),mode:"insensitive"};break;case "null":t[e.field]=e.value?null:{not:null};break;case "between":{let[n,r]=e.value;t[e.field]={gte:k(n),lte:k(r)};break}}}return t}var Ce=500,b=new Map;function ne(a,t){if(b.size>=Ce){let e=b.keys().next().value;e!==void 0&&b.delete(e);}b.set(a,t);}var D=new Map;function re(a,t){D.set(a.toLowerCase(),t),b.delete(a);}function Ie(a){for(let[t,e]of Object.entries(a))re(t,e);}function Fe(){D.clear(),b.clear();}async function w(a){let t=b.get(a);if(t)return t;let e=D.get(a.toLowerCase());if(e)return ne(a,e),e;let o=a.replace(/[-_](.)/g,(n,r)=>r.toUpperCase()).replace(/^./,n=>n.toLowerCase());return o=await C(o),ne(a,o),o}function Ke(a){let t=[];for(let e of Object.keys(a)){if(e.startsWith("$")||e.startsWith("_"))continue;let o=oe(a,e);o&&typeof o=="object"&&"create"in o&&t.push(e);}return t}async function De(a,t,e=3){if(t.length===0)return [];let o=a.toLowerCase();return (await Promise.all(t.map(async r=>({name:r,distance:await I(o,r.toLowerCase())})))).filter(r=>r.distance<=Math.max(3,a.length/2)).sort((r,s)=>r.distance-s.distance).slice(0,e).map(r=>r.name)}async function f(a,t){let e=await w(t),o=h(a,e);if(!o){let n=Ke(a),r=await De(e,n),s=`Model '${e}' not found in Prisma client. Table name: '${t}'. `;throw r.length>0&&(s+=`Did you mean: ${r.map(i=>`'${i}'`).join(", ")}? `),n.length>0&&n.length<=10&&(s+=`Available models: ${n.join(", ")}. `),s+=`You can register a custom mapping with: registerPrismaModelMapping('${t}', 'yourModelName')`,new Error(s)}return o}async function Ae(a,t,e,o){let n=await w(o.model),r=h(a,n);if(!r)return t;switch(o.type){case "hasOne":{let s=o.localKey||"id",i=t[s];if(i==null)return {...t,[e]:null};let l=await r.findFirst({where:{[o.foreignKey]:i}});return {...t,[e]:l||null}}case "hasMany":{let s=o.localKey||"id",i=t[s];if(i==null)return {...t,[e]:[]};let l=await r.findMany({where:{[o.foreignKey]:i}});return {...t,[e]:l}}case "belongsTo":{let s=t[o.foreignKey];if(s==null)return {...t,[e]:null};let i=o.localKey||"id",l=await r.findFirst({where:{[i]:s}});return {...t,[e]:l||null}}default:return t}}async function se(a,t,e,o){if(!o?.relations?.length||!e.model.relations)return t;let n={...t};for(let r of o.relations){let s=e.model.relations[r];s&&(n=await Ae(a,n,r,s));}return n}async function x(a,t,e,o){if(!t.length||!o?.relations?.length||!e.model.relations)return t;let n=t.map(r=>({...r}));for(let r of o.relations){let s=e.model.relations[r];if(!s)continue;let i=await w(s.model),l=h(a,i);if(l)switch(s.type){case "hasOne":case "hasMany":{let u=s.localKey||"id",c=[...new Set(n.map(m=>m[u]).filter(m=>m!=null))];if(c.length===0){n=n.map(m=>({...m,[r]:s.type==="hasMany"?[]:null}));continue}let d=await l.findMany({where:{[s.foreignKey]:{in:c}}}),p=new Map;for(let m of d){let g=m[s.foreignKey];p.has(g)||p.set(g,[]),p.get(g).push(m);}n=n.map(m=>{let g=m[u],M=p.get(g)||[];return {...m,[r]:s.type==="hasMany"?M:M[0]||null}});break}case "belongsTo":{let u=s.localKey||"id",c=[...new Set(n.map(m=>m[s.foreignKey]).filter(m=>m!=null))];if(c.length===0){n=n.map(m=>({...m,[r]:null}));continue}let d=await l.findMany({where:{[u]:{in:c}}}),p=new Map;for(let m of d){let g=m[u];p.set(g,m);}n=n.map(m=>{let g=m[s.foreignKey];return {...m,[r]:p.get(g)||null}});break}}}return n}async function j(a){let{model:t,filters:e,searchFields:o=[],softDeleteConfig:n,defaultPerPage:r=20,additionalWhere:s={}}=a,i={...K(e.filters),...s};if(n?.enabled){let{withDeleted:g,onlyDeleted:M}=e.options;M?i[n.field]={not:null}:g||(i[n.field]=null);}if(e.options.search&&o.length>0){let g=o.map(M=>({[M]:{contains:e.options.search,mode:"insensitive"}}));i={...i,OR:g};}let l=await t.count({where:i}),u;e.options.order_by&&(u={[e.options.order_by]:e.options.order_by_direction||"asc"});let c=e.options.page||1,d=e.options.per_page||r,p=await t.findMany({where:i,orderBy:u,skip:(c-1)*d,take:d}),m=Math.ceil(l/d);return {records:p,where:i,totalCount:l,page:c,perPage:d,totalPages:m}}function E(a,t){return {result:a,result_info:{page:t.page,per_page:t.perPage,total_count:t.totalCount,total_pages:t.totalPages,has_next_page:t.page<t.totalPages,has_prev_page:t.page>1}}}var ae=class extends k$1{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}},ie=class extends l{async getModel(){return f(this.prisma,this._meta.model.tableName)}async read(t,e,o){let n=await this.getModel(),r={[this.lookupField]:t,...e},s=await n.findFirst({where:r});return s?await se(this.prisma,s,this._meta,o):null}},le=class extends m{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async update(t,e,o){let n=await this.getModel(),r={[this.lookupField]:t,...o},s=await n.findFirst({where:r});if(!s)return null;let i=this._meta.model.primaryKeys[0];return await n.update({where:{[i]:s[i]},data:e})}},de=class extends n{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async findForDelete(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),r={[this.lookupField]:t,...e};return n.enabled&&(r[n.field]=null),await o.findFirst({where:r})}async delete(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),r={[this.lookupField]:t,...e};n.enabled&&(r[n.field]=null);let s=await o.findFirst({where:r});if(!s)return null;let i=this._meta.model.primaryKeys[0],l=s[i];return n.enabled?await o.update({where:{[i]:l},data:{[n.field]:new Date}}):await o.delete({where:{[i]:l}})}},ce=class extends o{async getModel(){return f(this.prisma,this._meta.model.tableName)}async list(t){let e=await j({model:await this.getModel(),filters:t,searchFields:this.searchFields,softDeleteConfig:this.getSoftDeleteConfig(),defaultPerPage:this.defaultPerPage}),o={relations:t.options.include||[]},n=await x(this.prisma,e.records,this._meta,o);return E(n,e)}};var ue=class extends p{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async restore(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),r={[this.lookupField]:t,[n.field]:{not:null},...e},s=await o.findFirst({where:r});if(!s)return null;let i=this._meta.model.primaryKeys[0];return await o.update({where:{[i]:s[i]},data:{[n.field]:null}})}},me=class extends r{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchCreate(t){let e=this._meta.model.primaryKeys[0],o=t.map(r=>({...r,[e]:r[e]||crypto.randomUUID()})),n=[];return await F(this.prisma)(async r=>{let s=h(r,await w(this._meta.model.tableName));if(!s)throw new Error(`Model '${this._meta.model.tableName}' not found in Prisma transaction client`);for(let i of o){let l=await s.create({data:i});n.push(l);}}),n}},ge=class extends s{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchUpdate(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],r=[],s=[],i=t.map(d=>d.id),l={[this.lookupField]:{in:i}};o.enabled&&(l[o.field]=null);let u=await e.findMany({where:l}),c=new Map;for(let d of u){let p=d[this.lookupField];c.set(p,d);}for(let d of t){let p=c.get(d.id);if(!p){s.push(d.id);continue}let m=await e.update({where:{[n]:p[n]},data:d.data});r.push(m);}return {updated:r,notFound:s}}},pe=class extends t{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchDelete(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],r=[],s=[],i={[this.lookupField]:{in:t}};o.enabled&&(i[o.field]=null);let l=await e.findMany({where:i}),u=new Map;for(let c of l){let d=c[this.lookupField];u.set(d,c);}for(let c of t)u.has(c)||s.push(c);for(let c of t){let d=u.get(c);if(d)if(o.enabled){let p=await e.update({where:{[n]:d[n]},data:{[o.field]:new Date}});r.push(p);}else {let p=await e.delete({where:{[n]:d[n]}});r.push(p);}}return {deleted:r,notFound:s}}},fe=class extends u{async getModel(){return f(this.prisma,this._meta.model.tableName)}async batchRestore(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],r=[],s=[],i={[this.lookupField]:{in:t},[o.field]:{not:null}},l=await e.findMany({where:i}),u=new Map;for(let c of l){let d=c[this.lookupField];u.set(d,c);}for(let c of t){let d=u.get(c);if(!d){s.push(c);continue}let p=await e.update({where:{[n]:d[n]},data:{[o.field]:null}});r.push(p);}return {restored:r,notFound:s}}},Me=class extends v$1{useTransaction=true;async getModel(){return f(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let s of o){let i=t[s];i!==void 0&&(n[s]=i);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:e})}async nativeBatchUpsert(t,e){if(t.length===0)return {items:[],createdCount:0,updatedCount:0,totalCount:0};let o=this.getUpsertKeys(),n=this._meta.model.primaryKeys[0],r=async l=>{let u=h(l,await w(this._meta.model.tableName));if(!u)throw new Error(`Model '${this._meta.model.tableName}' not found in Prisma client`);let c=[],d=[];for(let p=0;p<t.length;p++){let m=t[p];try{let g={};for(let y of o){let O=m[y];O!==void 0&&(g[y]=O);}let M={...m,[n]:m[n]||crypto.randomUUID()},P={};for(let[y,O]of Object.entries(m))!o.includes(y)&&y!==n&&(this.createOnlyFields?.includes(y)||(P[y]=O));let ve=await u.upsert({where:g,create:M,update:Object.keys(P).length>0?P:{}});c.push({data:ve,created:!1,index:p});}catch(g){if(this.continueOnError)d.push({index:p,error:g instanceof Error?g.message:String(g)});else throw g}}return {results:c,errors:d}},s;this.useTransaction?s=await F(this.prisma)(r):s=await r(this.prisma);let i={items:s.results,createdCount:0,updatedCount:s.results.length,totalCount:s.results.length};return s.errors.length>0&&(i.errors=s.errors),i}};var he=class extends J{async getModel(){return f(this.prisma,this._meta.model.tableName)}buildSearchWhere(t,e){let o=K(e.filters),n=this.getSoftDeleteConfig();if(n.enabled){let{withDeleted:l,onlyDeleted:u}=e.options;u?o[n.field]={not:null}:l||(o[n.field]=null);}let r=this.getSearchableFields(),i=(t.fields||Object.keys(r)).map(l=>({[l]:{contains:t.query,mode:"insensitive"}}));return i.length>0&&(t.mode==="all"?o={...o,AND:i}:o={...o,OR:i}),o}async search(t,e){let o=await this.getModel(),n=this.buildSearchWhere(t,e),r=await o.count({where:n}),s=e.options.order_by?{[e.options.order_by]:e.options.order_by_direction||"asc"}:void 0,i=e.options.page||1,l=e.options.per_page||this.defaultPerPage,u=await o.findMany({where:n,orderBy:s,skip:(i-1)*l,take:l}),c=K$1(u,t,this.getSearchableFields()),d={relations:e.options.include||[]},p=c.map(M=>M.item),m=await x(this.prisma,p,this._meta,d);return {items:c.map((M,P)=>({...M,item:m[P]})),totalCount:r}}},we=class extends T{async getModel(){return f(this.prisma,this._meta.model.tableName)}async list(t){let e=await j({model:await this.getModel(),filters:t,searchFields:this.searchFields,softDeleteConfig:this.getSoftDeleteConfig(),defaultPerPage:this.defaultPerPage}),o={relations:t.options.include||[]},n=await x(this.prisma,e.records,this._meta,o);return E(n,e)}},ye=class extends U{async getModel(){return f(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let s of o){let i=t[s];i!==void 0&&(n[s]=i);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:e})}},be=class extends q{useTransaction=false;async getModel(){return f(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let s of o){let i=t[s];i!==void 0&&(n[s]=i);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this._meta.model.primaryKeys[0],n={...t,[o]:t[o]||crypto.randomUUID()};return await e.create({data:n})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:e})}async nativeUpsert(t,e){let o=await this.getModel(),n=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s={};for(let c of n){let d=t[c];d!==void 0&&(s[c]=d);}let i={...t,[r]:t[r]||crypto.randomUUID()},l={};for(let[c,d]of Object.entries(t))!n.includes(c)&&c!==r&&(this.createOnlyFields?.includes(c)||(l[c]=d));return {data:await o.upsert({where:s,create:i,update:Object.keys(l).length>0?l:{}}),created:false}}},Pe=class extends w$1{async getModel(){return f(this.prisma,this._meta.model.tableName)}async recordExists(t){return await(await this.getModel()).count({where:{[this.lookupField]:t}})>0}},ke=class extends x$1{},xe=class extends y{},Oe=class extends z{async getModel(){return f(this.prisma,this._meta.model.tableName)}async rollback(t,e,o){let n=await this.getModel(),r=this.getVersioningConfig().field,s=this._meta.model.primaryKeys[0],i=await n.findFirst({where:{[this.lookupField]:t}});if(!i)throw new Error(`Record not found: ${t}`);return await n.update({where:{[s]:i[s]},data:{...e,[r]:o}})}},Re=class extends A{useNativeAggregation=true;async getModel(){return f(this.prisma,this._meta.model.tableName)}async buildAggregateWhere(t){let e={},o=this.getSoftDeleteConfig();if(o.enabled){let{query:n}=await this.getValidatedData();n?.withDeleted===true||n?.withDeleted==="true"||(e[o.field]=null);}if(t.filters)for(let[n,r]of Object.entries(t.filters))if(typeof r=="object"&&r!==null){let s={};for(let[i,l]of Object.entries(r))switch(i){case "eq":s.equals=l;break;case "ne":s.not=l;break;case "gt":s.gt=l;break;case "gte":s.gte=l;break;case "lt":s.lt=l;break;case "lte":s.lte=l;break;case "in":s.in=l;break;case "nin":s.notIn=l;break;default:s[i]=l;}e[n]=s;}else e[n]=r;return e}async aggregate(t){let e=await this.getModel(),o=await this.buildAggregateWhere(t);if(!this.useNativeAggregation||t.having){let n=await e.findMany({where:o});return B(n,t)}return t.groupBy?.length?this.aggregateWithGroupBy(e,o,t):this.aggregateSimple(e,o,t)}groupAggregationsByOperation(t){let e={sum:[],avg:[],min:[],max:[],count:[],countDistinct:[]};for(let o of t)switch(o.operation){case "sum":e.sum.push(o.field);break;case "avg":e.avg.push(o.field);break;case "min":e.min.push(o.field);break;case "max":e.max.push(o.field);break;case "count":e.count.push(o.field);break;case "countDistinct":e.countDistinct.push(o.field);break}return e}async aggregateSimple(t,e,o){let n={where:e},r={},s=this.groupAggregationsByOperation(o.aggregations);if(n._count=true,s.sum.length){n._sum={};for(let u of s.sum)n._sum[u]=true;}if(s.avg.length){n._avg={};for(let u of s.avg)n._avg[u]=true;}if(s.min.length){n._min={};for(let u of s.min)n._min[u]=true;}if(s.max.length){n._max={};for(let u of s.max)n._max[u]=true;}let i=await w(this._meta.model.tableName),l=h(this.prisma,i);if(!l)throw new Error(`Model '${i}' not found in Prisma client`);try{let u=await l.aggregate(n);if(u._count!==void 0&&(r.count=typeof u._count=="object"?u._count._all??0:u._count),u._sum&&s.sum.length)for(let c of s.sum){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`sum${d}`]=u._sum[c]??0;}if(u._avg&&s.avg.length)for(let c of s.avg){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`avg${d}`]=u._avg[c]??0;}if(u._min&&s.min.length)for(let c of s.min){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`min${d}`]=u._min[c];}if(u._max&&s.max.length)for(let c of s.max){let d=c.charAt(0).toUpperCase()+c.slice(1);r[`max${d}`]=u._max[c];}return {values:r,groups:[]}}catch{let c=await t.findMany({where:e});return B(c,o)}}async aggregateWithGroupBy(t,e,o){let n={by:o.groupBy,where:e},r=this.groupAggregationsByOperation(o.aggregations);if(n._count=true,r.sum.length){n._sum={};for(let l of r.sum)n._sum[l]=true;}if(r.avg.length){n._avg={};for(let l of r.avg)n._avg[l]=true;}if(r.min.length){n._min={};for(let l of r.min)n._min[l]=true;}if(r.max.length){n._max={};for(let l of r.max)n._max[l]=true;}let s=await w(this._meta.model.tableName),i=h(this.prisma,s);if(!i)throw new Error(`Model '${s}' not found in Prisma client`);try{let u=(await i.groupBy(n)).map(d=>{let p={},m={};for(let g of o.groupBy)p[g]=d[g];if(m.count=typeof d._count=="object"?d._count._all??0:d._count??0,d._sum&&r.sum.length)for(let g of r.sum){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`sum${M}`]=d._sum[g]??0;}if(d._avg&&r.avg.length)for(let g of r.avg){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`avg${M}`]=d._avg[g]??0;}if(d._min&&r.min.length)for(let g of r.min){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`min${M}`]=d._min[g];}if(d._max&&r.max.length)for(let g of r.max){let M=g.charAt(0).toUpperCase()+g.slice(1);m[`max${M}`]=d._max[g];}return {key:p,values:m}});return {values:{count:u.reduce((d,p)=>d+(p.values.count||0),0)},groups:u}}catch{let u=await t.findMany({where:e});return B(u,o)}}};export{Re as PrismaAggregateEndpoint,me as PrismaBatchCreateEndpoint,pe as PrismaBatchDeleteEndpoint,fe as PrismaBatchRestoreEndpoint,ge as PrismaBatchUpdateEndpoint,Me as PrismaBatchUpsertEndpoint,ae as PrismaCreateEndpoint,de as PrismaDeleteEndpoint,we as PrismaExportEndpoint,ye as PrismaImportEndpoint,ce as PrismaListEndpoint,ie as PrismaReadEndpoint,ue as PrismaRestoreEndpoint,he as PrismaSearchEndpoint,le as PrismaUpdateEndpoint,be as PrismaUpsertEndpoint,xe as PrismaVersionCompareEndpoint,Pe as PrismaVersionHistoryEndpoint,ke as PrismaVersionReadEndpoint,Oe as PrismaVersionRollbackEndpoint,Fe as clearPrismaModelMappings,re as registerPrismaModelMapping,Ie as registerPrismaModelMappings};
@@ -1,5 +1,5 @@
1
1
  import { Context, Env } from 'hono';
2
- import { A as AuditConfig, a as AuditLogEntry, b as AuditAction } from '../types-5BBVU0EY.js';
2
+ import { A as AuditConfig, a as AuditLogEntry, b as AuditAction } from '../types-T4ThpPOK.js';
3
3
  import { S as StorageRegistry } from '../registry-PNJjvSvm.js';
4
4
  import '../types-B5wq2iKZ.js';
5
5
  import '../types-BAcN7U0B.js';
@@ -1,8 +1,8 @@
1
1
  import { A as AuthEnv, j as JWTConfig, h as JWTClaims, a as APIKeyConfig, b as APIKeyEntry, d as AuthConfig, G as Guard, g as AuthorizationCheck, O as OwnershipExtractor, f as AuthUser, E as EndpointAuthConfig, k as APIKeyStorage, c as APIKeyLookupResult } from '../types-Di38wHnA.js';
2
2
  export { e as AuthType, J as JWTAlgorithm, i as JWTClaimsSchema, P as PathPattern, V as ValidatedJWTClaims, p as parseJWTClaims, s as safeParseJWTClaims } from '../types-Di38wHnA.js';
3
3
  import { MiddlewareHandler, Context } from 'hono';
4
- import { M as MetaInput, O as OpenAPIRouteSchema, ap as Constructor } from '../types-5BBVU0EY.js';
5
- import { O as OpenAPIRoute } from '../route-BmtmmHSO.js';
4
+ import { M as MetaInput, O as OpenAPIRouteSchema, ap as Constructor } from '../types-T4ThpPOK.js';
5
+ import { O as OpenAPIRoute } from '../route-CSScNXhr.js';
6
6
  import 'zod';
7
7
  import '../types-B5wq2iKZ.js';
8
8
  import '../types-BAcN7U0B.js';
@@ -1,7 +1,7 @@
1
1
  import { ZodObject, ZodRawShape } from 'zod';
2
2
  import { Env } from 'hono';
3
- import { C as CrudEndpoint, M as ModelObject } from './import-BHD2B1u8.js';
4
- import { M as MetaInput, O as OpenAPIRouteSchema, H as HookMode, L as ListFilters } from './types-5BBVU0EY.js';
3
+ import { C as CrudEndpoint, M as ModelObject } from './import-Co7vvjkO.js';
4
+ import { M as MetaInput, O as OpenAPIRouteSchema, H as HookMode, L as ListFilters } from './types-T4ThpPOK.js';
5
5
 
6
6
  /**
7
7
  * Base endpoint for cloning/duplicating a resource.
@@ -1,8 +1,8 @@
1
1
  import { I as InvalidationPatternOptions, d as CacheKeyOptions, C as CacheStorage, b as CacheEntry, e as CacheSetOptions, f as CacheStats, a as CacheConfig, c as CacheInvalidationConfig } from '../types-BdRvpp1z.js';
2
2
  export { g as InvalidationStrategy } from '../types-BdRvpp1z.js';
3
3
  import { K as KVNamespace } from '../cloudflare-kv-types-ByUEHhBc.js';
4
- import { ap as Constructor } from '../types-5BBVU0EY.js';
5
- import { O as OpenAPIRoute } from '../route-BmtmmHSO.js';
4
+ import { ap as Constructor } from '../types-T4ThpPOK.js';
5
+ import { O as OpenAPIRoute } from '../route-CSScNXhr.js';
6
6
  import '../types-B5wq2iKZ.js';
7
7
  import '../types-BAcN7U0B.js';
8
8
  import 'zod';
@@ -1,7 +1,7 @@
1
1
  import { z, ZodObject, ZodRawShape } from 'zod';
2
2
  import { Env } from 'hono';
3
- import { M as MetaInput, X as NormalizedAuditConfig, _ as NormalizedVersioningConfig, Z as NormalizedSoftDeleteConfig, Y as NormalizedMultiTenantConfig, G as Model, t as FilterConfig, u as FilterOperator, L as ListFilters, H as HookMode, O as OpenAPIRouteSchema, f as RelationConfig, I as IncludeOptions, N as NestedUpdateInput, g as NestedWriteResult, C as CascadeAction, P as PaginatedResult, n as AggregateConfig, h as AggregateOptions, k as AggregateField, i as AggregateResult, l as SearchFieldConfig, m as SearchMode, S as SearchOptions, a5 as SearchResultItem, j as SearchResult } from './types-5BBVU0EY.js';
4
- import { O as OpenAPIRoute } from './route-BmtmmHSO.js';
3
+ import { M as MetaInput, X as NormalizedAuditConfig, _ as NormalizedVersioningConfig, Z as NormalizedSoftDeleteConfig, Y as NormalizedMultiTenantConfig, G as Model, F as FilterConfig, u as FilterOperator, L as ListFilters, H as HookMode, O as OpenAPIRouteSchema, f as RelationConfig, I as IncludeOptions, N as NestedUpdateInput, g as NestedWriteResult, C as CascadeAction, P as PaginatedResult, o as AggregateConfig, h as AggregateOptions, k as AggregateField, i as AggregateResult, m as SearchFieldConfig, n as SearchMode, S as SearchOptions, a5 as SearchResultItem, j as SearchResult } from './types-T4ThpPOK.js';
4
+ import { O as OpenAPIRoute } from './route-CSScNXhr.js';
5
5
  import { AuditLogger } from './audit/index.js';
6
6
  import { VersionManager } from './versioning/index.js';
7
7
  import { C as CrudEventType } from './types-BCsipBBX.js';
@@ -802,7 +802,7 @@ declare abstract class DeleteEndpoint<E extends Env = Env, M extends MetaInput =
802
802
  */
803
803
  declare abstract class ListEndpoint<E extends Env = Env, M extends MetaInput = MetaInput> extends CrudEndpoint<E, M> {
804
804
  protected filterFields: string[];
805
- protected filterConfig?: Record<string, Array<'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'like' | 'ilike' | 'null' | 'between'>>;
805
+ protected filterConfig?: FilterConfig;
806
806
  protected searchFields: string[];
807
807
  protected searchFieldName: string;
808
808
  /** Fields that can be used for sorting. Use with ?sort=fieldName */
@@ -2122,7 +2122,7 @@ declare abstract class SearchEndpoint<E extends Env = Env, M extends MetaInput =
2122
2122
  /** Fields that can be used for filtering */
2123
2123
  protected filterFields: string[];
2124
2124
  /** Filter configuration with allowed operators per field */
2125
- protected filterConfig?: Record<string, Array<'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte' | 'in' | 'nin' | 'like' | 'ilike' | 'null' | 'between'>>;
2125
+ protected filterConfig?: FilterConfig;
2126
2126
  /** Fields that can be used for sorting. Use with ?sort=fieldName */
2127
2127
  protected sortFields: string[];
2128
2128
  /** Default sort configuration */