hono-crud 0.12.4 → 0.13.0

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
@@ -13,6 +13,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
13
13
  %b
14
14
  %b
15
15
  %b
16
+ %b
17
+ %b
16
18
  ## [0.8.0] — 2026-05-03
17
19
 
18
20
  ### Added
@@ -91,3 +93,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
91
93
  [0.12.2]: https://github.com/kshdotdev/hono-crud/compare/v0.12.1...v0.12.2
92
94
  [0.12.3]: https://github.com/kshdotdev/hono-crud/compare/v0.12.2...v0.12.3
93
95
  [0.12.4]: https://github.com/kshdotdev/hono-crud/compare/v0.12.3...v0.12.4
96
+ [0.12.5]: https://github.com/kshdotdev/hono-crud/compare/v0.12.4...v0.12.5
97
+ [0.13.0]: https://github.com/kshdotdev/hono-crud/compare/v0.12.5...v0.13.0
@@ -90,6 +90,16 @@ type DrizzleDatabase = DrizzleDatabaseConstraint;
90
90
  * @deprecated Pass your database type as a generic parameter instead
91
91
  */
92
92
  type DrizzleDB = DrizzleDatabaseConstraint;
93
+ /**
94
+ * Drizzle SQL dialect identifier used to branch dialect-specific behavior
95
+ * (e.g. native upsert syntax: `ON CONFLICT DO UPDATE` for sqlite/pg vs
96
+ * `ON DUPLICATE KEY UPDATE` for mysql).
97
+ *
98
+ * The default for {@link createDrizzleCrud} is `'sqlite'` (preserves
99
+ * pre-existing portable behavior). Set explicitly when targeting PostgreSQL
100
+ * or MySQL to enable the appropriate code paths.
101
+ */
102
+ type DrizzleDialect = 'sqlite' | 'pg' | 'mysql';
93
103
  /**
94
104
  * Type helper for defining Hono Env with database in Variables.
95
105
  * Use this when injecting the database via middleware.
@@ -445,6 +455,16 @@ declare abstract class DrizzleBatchRestoreEndpoint<E extends Env = Env, M extend
445
455
  declare abstract class DrizzleUpsertEndpoint<E extends Env = Env, M extends MetaInput = MetaInput> extends UpsertEndpoint<E, M> {
446
456
  /** Drizzle database instance. Can be undefined if using context injection. */
447
457
  db?: DrizzleDatabase;
458
+ /**
459
+ * SQL dialect of the underlying Drizzle database.
460
+ *
461
+ * Used to branch dialect-specific behavior — currently the native upsert
462
+ * path (`ON CONFLICT DO UPDATE` for sqlite/pg vs `ON DUPLICATE KEY UPDATE`
463
+ * for mysql). Set via {@link createDrizzleCrud}'s `options.dialect`, or
464
+ * override in your subclass. Defaults to `'sqlite'` for backward
465
+ * compatibility with pre-existing portable behavior.
466
+ */
467
+ protected dialect: DrizzleDialect;
448
468
  /** Gets the database instance from property or context. */
449
469
  protected getDb(): DrizzleDatabase;
450
470
  protected getTable(): Table;
@@ -460,7 +480,7 @@ declare abstract class DrizzleUpsertEndpoint<E extends Env = Env, M extends Meta
460
480
  * The `created` flag is set to `false` by default. If you need accurate create/update
461
481
  * tracking, use the standard upsert pattern (useNativeUpsert = false).
462
482
  */
463
- protected nativeUpsert(data: Partial<ModelObject<M['model']>>, tx?: unknown): Promise<{
483
+ protected nativeUpsert(data: Partial<ModelObject<M['model']>>, _tx?: unknown): Promise<{
464
484
  data: ModelObject<M['model']>;
465
485
  created: boolean;
466
486
  }>;
@@ -471,6 +491,11 @@ declare abstract class DrizzleUpsertEndpoint<E extends Env = Env, M extends Meta
471
491
  declare abstract class DrizzleBatchUpsertEndpoint<E extends Env = Env, M extends MetaInput = MetaInput> extends BatchUpsertEndpoint<E, M> {
472
492
  /** Drizzle database instance. Can be undefined if using context injection. */
473
493
  db?: DrizzleDatabase;
494
+ /**
495
+ * SQL dialect of the underlying Drizzle database. See
496
+ * {@link DrizzleUpsertEndpoint.dialect} for full semantics.
497
+ */
498
+ protected dialect: DrizzleDialect;
474
499
  /** Gets the database instance from property or context. */
475
500
  protected getDb(): DrizzleDatabase;
476
501
  protected getTable(): Table;
@@ -486,7 +511,7 @@ declare abstract class DrizzleBatchUpsertEndpoint<E extends Env = Env, M extends
486
511
  * All records are marked as `created: false`. If you need accurate tracking,
487
512
  * use the standard batch upsert pattern (useNativeUpsert = false).
488
513
  */
489
- protected nativeBatchUpsert(items: Partial<ModelObject<M['model']>>[], tx?: unknown): Promise<{
514
+ protected nativeBatchUpsert(items: Partial<ModelObject<M['model']>>[], _tx?: unknown): Promise<{
490
515
  items: Array<{
491
516
  data: ModelObject<M['model']>;
492
517
  created: boolean;
@@ -697,12 +722,31 @@ interface DrizzleCrudClasses<M extends MetaInput, E extends Env = Env> {
697
722
  BatchRestore: ConfiguredDrizzleEndpoint<DrizzleBatchRestoreEndpoint<E, M>, M>;
698
723
  BatchUpsert: ConfiguredDrizzleEndpoint<DrizzleBatchUpsertEndpoint<E, M>, M>;
699
724
  }
725
+ /**
726
+ * Options accepted by {@link createDrizzleCrud}.
727
+ */
728
+ interface CreateDrizzleCrudOptions {
729
+ /**
730
+ * SQL dialect of the Drizzle database. Used to branch dialect-specific
731
+ * behavior such as native upsert syntax (`ON CONFLICT DO UPDATE` for
732
+ * `'sqlite'`/`'pg'` vs `ON DUPLICATE KEY UPDATE` for `'mysql'`).
733
+ *
734
+ * Defaults to `'sqlite'`, which preserves the pre-existing portable
735
+ * behavior for callers that don't specify a dialect.
736
+ *
737
+ * @default 'sqlite'
738
+ */
739
+ dialect?: DrizzleDialect;
740
+ }
700
741
  /**
701
742
  * Creates a set of Drizzle CRUD endpoint base classes with db and meta pre-configured.
702
743
  * This is the cleanest pattern - no need to set `_meta` or `db` in your classes.
703
744
  *
704
745
  * @param db - Your Drizzle database instance
705
746
  * @param meta - The meta object (from defineMeta)
747
+ * @param options - Optional factory options. Pass `{ dialect: 'pg' | 'mysql' | 'sqlite' }`
748
+ * to enable dialect-specific code paths (e.g. native upsert syntax).
749
+ * Defaults to `{ dialect: 'sqlite' }`.
706
750
  * @returns Object with Create, Read, Update, Delete, List base classes
707
751
  *
708
752
  * @example
@@ -710,7 +754,7 @@ interface DrizzleCrudClasses<M extends MetaInput, E extends Env = Env> {
710
754
  * import { createDrizzleCrud } from 'hono-crud/adapters/drizzle';
711
755
  *
712
756
  * const projectMeta = defineMeta({ model: ProjectModel, fields: projectSchemas.insert });
713
- * const Project = createDrizzleCrud(db, projectMeta);
757
+ * const Project = createDrizzleCrud(db, projectMeta, { dialect: 'pg' });
714
758
  *
715
759
  * // Now define endpoints with minimal boilerplate:
716
760
  * class ProjectCreate extends Project.Create {
@@ -724,7 +768,7 @@ interface DrizzleCrudClasses<M extends MetaInput, E extends Env = Env> {
724
768
  * }
725
769
  * ```
726
770
  */
727
- declare function createDrizzleCrud<M extends MetaInput, E extends Env = Env>(db: DrizzleDatabaseConstraint, meta: M): DrizzleCrudClasses<M, E>;
771
+ declare function createDrizzleCrud<M extends MetaInput, E extends Env = Env>(db: DrizzleDatabaseConstraint, meta: M, options?: CreateDrizzleCrudOptions): DrizzleCrudClasses<M, E>;
728
772
 
729
773
  /**
730
774
  * Drizzle-Zod schema utilities.
@@ -903,4 +947,4 @@ declare function isDrizzleZodAvailable(): boolean;
903
947
  */
904
948
  declare const DrizzleAdapters: AdapterBundle;
905
949
 
906
- export { type Database, DrizzleAdapters, DrizzleAggregateEndpoint, DrizzleBatchCreateEndpoint, DrizzleBatchDeleteEndpoint, DrizzleBatchRestoreEndpoint, DrizzleBatchUpdateEndpoint, DrizzleBatchUpsertEndpoint, DrizzleCloneEndpoint, DrizzleCreateEndpoint, type DrizzleCrudClasses, type DrizzleDB, type DrizzleDatabase, type DrizzleDatabaseConstraint, DrizzleDeleteEndpoint, type DrizzleEnv, DrizzleExportEndpoint, DrizzleImportEndpoint, DrizzleListEndpoint, DrizzleReadEndpoint, DrizzleRestoreEndpoint, type DrizzleSchemas, DrizzleSearchEndpoint, DrizzleUpdateEndpoint, DrizzleUpsertEndpoint, DrizzleVersionCompareEndpoint, DrizzleVersionHistoryEndpoint, DrizzleVersionReadEndpoint, DrizzleVersionRollbackEndpoint, type QueryBuilder, batchLoadDrizzleRelations, buildWhereCondition, cast, createDrizzleCrud, createDrizzleSchemas, createInsertSchema, createSelectSchema, createUpdateSchema, getColumn, getTable, isDrizzleZodAvailable, loadDrizzleRelation, loadDrizzleRelations };
950
+ export { type CreateDrizzleCrudOptions, type Database, DrizzleAdapters, DrizzleAggregateEndpoint, DrizzleBatchCreateEndpoint, DrizzleBatchDeleteEndpoint, DrizzleBatchRestoreEndpoint, DrizzleBatchUpdateEndpoint, DrizzleBatchUpsertEndpoint, DrizzleCloneEndpoint, DrizzleCreateEndpoint, type DrizzleCrudClasses, type DrizzleDB, type DrizzleDatabase, type DrizzleDatabaseConstraint, DrizzleDeleteEndpoint, type DrizzleDialect, type DrizzleEnv, DrizzleExportEndpoint, DrizzleImportEndpoint, DrizzleListEndpoint, DrizzleReadEndpoint, DrizzleRestoreEndpoint, type DrizzleSchemas, DrizzleSearchEndpoint, DrizzleUpdateEndpoint, DrizzleUpsertEndpoint, DrizzleVersionCompareEndpoint, DrizzleVersionHistoryEndpoint, DrizzleVersionReadEndpoint, DrizzleVersionRollbackEndpoint, type QueryBuilder, batchLoadDrizzleRelations, buildWhereCondition, cast, createDrizzleCrud, createDrizzleSchemas, createInsertSchema, createSelectSchema, createUpdateSchema, getColumn, getTable, isDrizzleZodAvailable, loadDrizzleRelation, loadDrizzleRelations };
@@ -1 +1 @@
1
- export{I as DrizzleAdapters,x as DrizzleAggregateEndpoint,n as DrizzleBatchCreateEndpoint,p as DrizzleBatchDeleteEndpoint,q as DrizzleBatchRestoreEndpoint,o as DrizzleBatchUpdateEndpoint,s as DrizzleBatchUpsertEndpoint,B as DrizzleCloneEndpoint,h as DrizzleCreateEndpoint,k as DrizzleDeleteEndpoint,z as DrizzleExportEndpoint,A as DrizzleImportEndpoint,l as DrizzleListEndpoint,i as DrizzleReadEndpoint,m as DrizzleRestoreEndpoint,y as DrizzleSearchEndpoint,j as DrizzleUpdateEndpoint,r as DrizzleUpsertEndpoint,v as DrizzleVersionCompareEndpoint,t as DrizzleVersionHistoryEndpoint,u as DrizzleVersionReadEndpoint,w as DrizzleVersionRollbackEndpoint,f as batchLoadDrizzleRelations,g as buildWhereCondition,a as cast,C as createDrizzleCrud,G as createDrizzleSchemas,E as createInsertSchema,D as createSelectSchema,F as createUpdateSchema,c as getColumn,b as getTable,H as isDrizzleZodAvailable,d as loadDrizzleRelation,e as loadDrizzleRelations}from'../../chunk-75XHZDBH.js';import'../../chunk-V4YEHNEZ.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-XI7HT5ZM.js';import'../../chunk-NGUMNUOP.js';import'../../chunk-FJCWFB5L.js';import'../../chunk-FC56WWPB.js';import'../../chunk-KUFOENSK.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';
1
+ export{I as DrizzleAdapters,x as DrizzleAggregateEndpoint,n as DrizzleBatchCreateEndpoint,p as DrizzleBatchDeleteEndpoint,q as DrizzleBatchRestoreEndpoint,o as DrizzleBatchUpdateEndpoint,s as DrizzleBatchUpsertEndpoint,B as DrizzleCloneEndpoint,h as DrizzleCreateEndpoint,k as DrizzleDeleteEndpoint,z as DrizzleExportEndpoint,A as DrizzleImportEndpoint,l as DrizzleListEndpoint,i as DrizzleReadEndpoint,m as DrizzleRestoreEndpoint,y as DrizzleSearchEndpoint,j as DrizzleUpdateEndpoint,r as DrizzleUpsertEndpoint,v as DrizzleVersionCompareEndpoint,t as DrizzleVersionHistoryEndpoint,u as DrizzleVersionReadEndpoint,w as DrizzleVersionRollbackEndpoint,f as batchLoadDrizzleRelations,g as buildWhereCondition,a as cast,C as createDrizzleCrud,G as createDrizzleSchemas,E as createInsertSchema,D as createSelectSchema,F as createUpdateSchema,c as getColumn,b as getTable,H as isDrizzleZodAvailable,d as loadDrizzleRelation,e as loadDrizzleRelations}from'../../chunk-WXIFQDJI.js';import'../../chunk-ZBCVLQ3W.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-XI7HT5ZM.js';import'../../chunk-NGUMNUOP.js';import'../../chunk-FC56WWPB.js';import'../../chunk-FJCWFB5L.js';import'../../chunk-KUFOENSK.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';
@@ -1 +1 @@
1
- export{f as MEMORY_NOOP_TX,x as MemoryAggregateEndpoint,m as MemoryBatchCreateEndpoint,o as MemoryBatchDeleteEndpoint,p as MemoryBatchRestoreEndpoint,n as MemoryBatchUpdateEndpoint,q as MemoryBatchUpsertEndpoint,B as MemoryBulkPatchEndpoint,r as MemoryCloneEndpoint,g as MemoryCreateEndpoint,j as MemoryDeleteEndpoint,z as MemoryExportEndpoint,A as MemoryImportEndpoint,k as MemoryListEndpoint,h as MemoryReadEndpoint,l as MemoryRestoreEndpoint,y as MemorySearchEndpoint,i as MemoryUpdateEndpoint,s as MemoryUpsertEndpoint,v as MemoryVersionCompareEndpoint,t as MemoryVersionHistoryEndpoint,u as MemoryVersionReadEndpoint,w as MemoryVersionRollbackEndpoint,d as clearStorage,e as getStorage,c as getStore,b as storage}from'../../chunk-S2C35QM7.js';import'../../chunk-V4YEHNEZ.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-XI7HT5ZM.js';import'../../chunk-NGUMNUOP.js';import'../../chunk-FJCWFB5L.js';import'../../chunk-FC56WWPB.js';import'../../chunk-KUFOENSK.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';
1
+ export{f as MEMORY_NOOP_TX,x as MemoryAggregateEndpoint,m as MemoryBatchCreateEndpoint,o as MemoryBatchDeleteEndpoint,p as MemoryBatchRestoreEndpoint,n as MemoryBatchUpdateEndpoint,q as MemoryBatchUpsertEndpoint,B as MemoryBulkPatchEndpoint,r as MemoryCloneEndpoint,g as MemoryCreateEndpoint,j as MemoryDeleteEndpoint,z as MemoryExportEndpoint,A as MemoryImportEndpoint,k as MemoryListEndpoint,h as MemoryReadEndpoint,l as MemoryRestoreEndpoint,y as MemorySearchEndpoint,i as MemoryUpdateEndpoint,s as MemoryUpsertEndpoint,v as MemoryVersionCompareEndpoint,t as MemoryVersionHistoryEndpoint,u as MemoryVersionReadEndpoint,w as MemoryVersionRollbackEndpoint,d as clearStorage,e as getStorage,c as getStore,b as storage}from'../../chunk-BXWKFJXP.js';import'../../chunk-ZBCVLQ3W.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-XI7HT5ZM.js';import'../../chunk-NGUMNUOP.js';import'../../chunk-FC56WWPB.js';import'../../chunk-FJCWFB5L.js';import'../../chunk-KUFOENSK.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';
@@ -1 +1 @@
1
- export{y as PrismaAdapters,w as PrismaAggregateEndpoint,j as PrismaBatchCreateEndpoint,l as PrismaBatchDeleteEndpoint,m as PrismaBatchRestoreEndpoint,k as PrismaBatchUpdateEndpoint,n as PrismaBatchUpsertEndpoint,x as PrismaCloneEndpoint,d as PrismaCreateEndpoint,g as PrismaDeleteEndpoint,p as PrismaExportEndpoint,q as PrismaImportEndpoint,h as PrismaListEndpoint,e as PrismaReadEndpoint,i as PrismaRestoreEndpoint,o as PrismaSearchEndpoint,f as PrismaUpdateEndpoint,r as PrismaUpsertEndpoint,u as PrismaVersionCompareEndpoint,s as PrismaVersionHistoryEndpoint,t as PrismaVersionReadEndpoint,v as PrismaVersionRollbackEndpoint,c as clearPrismaModelMappings,a as registerPrismaModelMapping,b as registerPrismaModelMappings}from'../../chunk-CGVBR7MW.js';import'../../chunk-V4YEHNEZ.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-XI7HT5ZM.js';import'../../chunk-NGUMNUOP.js';import'../../chunk-FJCWFB5L.js';import'../../chunk-FC56WWPB.js';import'../../chunk-KUFOENSK.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';
1
+ export{y as PrismaAdapters,w as PrismaAggregateEndpoint,j as PrismaBatchCreateEndpoint,l as PrismaBatchDeleteEndpoint,m as PrismaBatchRestoreEndpoint,k as PrismaBatchUpdateEndpoint,n as PrismaBatchUpsertEndpoint,x as PrismaCloneEndpoint,d as PrismaCreateEndpoint,g as PrismaDeleteEndpoint,p as PrismaExportEndpoint,q as PrismaImportEndpoint,h as PrismaListEndpoint,e as PrismaReadEndpoint,i as PrismaRestoreEndpoint,o as PrismaSearchEndpoint,f as PrismaUpdateEndpoint,r as PrismaUpsertEndpoint,u as PrismaVersionCompareEndpoint,s as PrismaVersionHistoryEndpoint,t as PrismaVersionReadEndpoint,v as PrismaVersionRollbackEndpoint,c as clearPrismaModelMappings,a as registerPrismaModelMapping,b as registerPrismaModelMappings}from'../../chunk-FOTF3T22.js';import'../../chunk-ZBCVLQ3W.js';import'../../chunk-SDNXN7M5.js';import'../../chunk-XI7HT5ZM.js';import'../../chunk-NGUMNUOP.js';import'../../chunk-FC56WWPB.js';import'../../chunk-FJCWFB5L.js';import'../../chunk-KUFOENSK.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';
@@ -1 +1 @@
1
- export{b as KVCacheStorage,a as RedisCacheStorage}from'../chunk-H3H65KZF.js';export{C as MemoryCacheStorage,y as createInvalidationPattern,z as createRelatedPatterns,x as generateCacheKey,E as getCacheStorage,A as matchesPattern,B as parseCacheKey,D as setCacheStorage,F as withCache,G as withCacheInvalidation}from'../chunk-IPMPKM4J.js';import'../chunk-NGUMNUOP.js';import'../chunk-GF2EC5G4.js';import'../chunk-FJCWFB5L.js';import'../chunk-2M5BM4VD.js';import'../chunk-FC56WWPB.js';import'../chunk-KUFOENSK.js';import'../chunk-GBQQ3YQX.js';import'../chunk-DMGP7QDL.js';import'../chunk-MDHMZPXK.js';import'../chunk-VJRDAVID.js';
1
+ export{b as KVCacheStorage,a as RedisCacheStorage}from'../chunk-H3H65KZF.js';export{C as MemoryCacheStorage,y as createInvalidationPattern,z as createRelatedPatterns,x as generateCacheKey,E as getCacheStorage,A as matchesPattern,B as parseCacheKey,D as setCacheStorage,F as withCache,G as withCacheInvalidation}from'../chunk-UANCAA7V.js';import'../chunk-NGUMNUOP.js';import'../chunk-GF2EC5G4.js';import'../chunk-2M5BM4VD.js';import'../chunk-FC56WWPB.js';import'../chunk-FJCWFB5L.js';import'../chunk-KUFOENSK.js';import'../chunk-GBQQ3YQX.js';import'../chunk-DMGP7QDL.js';import'../chunk-MDHMZPXK.js';import'../chunk-VJRDAVID.js';
@@ -1 +1 @@
1
- import {d}from'./chunk-IPMPKM4J.js';var m=class{entriesById=new Map;entryIds=[];maxEntries;maxAge;cleanupInterval;lastCleanup=0;constructor(e){this.maxEntries=e?.maxEntries??1e4,this.maxAge=e?.maxAge??864e5,this.cleanupInterval=e?.cleanupInterval??3e5;}maybeCleanup(){if(this.cleanupInterval<=0||this.maxAge<=0)return;let e=Date.now();e-this.lastCleanup>=this.cleanupInterval&&(this.lastCleanup=e,this.deleteOlderThanSync(this.maxAge));}deleteOlderThanSync(e){let n=Date.now()-e,a=0;for(let t=this.entryIds.length-1;t>=0;t--){let s=this.entryIds[t],r=this.entriesById.get(s);if(r)if(new Date(r.timestamp).getTime()<n)this.entriesById.delete(s),this.entryIds.splice(t,1),a++;else break}return a}async store(e){for(this.maybeCleanup();this.entryIds.length>=this.maxEntries;){let n=this.entryIds.pop();n&&this.entriesById.delete(n);}this.entriesById.set(e.id,e),this.entryIds.unshift(e.id);}async query(e){this.maybeCleanup();let n=this.getFilteredEntries(e);if(e?.sort){let{field:s,direction:r}=e.sort;n=n.sort((i,o)=>{let g,u;switch(s){case "timestamp":g=new Date(i.timestamp).getTime(),u=new Date(o.timestamp).getTime();break;case "responseTimeMs":g=i.response.responseTimeMs,u=o.response.responseTimeMs;break;case "statusCode":g=i.response.statusCode,u=o.response.statusCode;break;default:return 0}return r==="asc"?g-u:u-g});}let a=e?.offset??0,t=e?.limit??n.length;return n.slice(a,a+t)}async getById(e){return this.entriesById.get(e)??null}async count(e){return this.getFilteredEntries(e).length}async deleteOlderThan(e){return this.deleteOlderThanSync(e)}async clear(){let e=this.entriesById.size;return this.entriesById.clear(),this.entryIds=[],e}destroy(){this.entriesById.clear(),this.entryIds=[];}getSize(){return this.entriesById.size}getFilteredEntries(e){if(!e)return Array.from(this.entriesById.values());let n=[];for(let a of this.entryIds){let t=this.entriesById.get(a);if(t&&!(e.level&&!(Array.isArray(e.level)?e.level:[e.level]).includes(t.level))&&!(e.method&&!(Array.isArray(e.method)?e.method:[e.method]).map(r=>r.toUpperCase()).includes(t.request.method.toUpperCase()))&&!(e.path&&!d(t.request.path,e.path))){if(e.statusCode){let{min:s,max:r}=e.statusCode,i=t.response.statusCode;if(s!==void 0&&i<s||r!==void 0&&i>r)continue}if(e.timeRange){let s=new Date(t.timestamp).getTime(),{start:r,end:i}=e.timeRange;if(r){let o=typeof r=="string"?new Date(r).getTime():r.getTime();if(s<o)continue}if(i){let o=typeof i=="string"?new Date(i).getTime():i.getTime();if(s>o)continue}}e.userId&&t.request.userId!==e.userId||e.clientIp&&t.request.clientIp!==e.clientIp||e.requestId&&t.id!==e.requestId||e.errorMessage&&(!t.error?.message||!t.error.message.toLowerCase().includes(e.errorMessage.toLowerCase()))||n.push(t);}}return n}};export{m as a};
1
+ import {d}from'./chunk-UANCAA7V.js';var m=class{entriesById=new Map;entryIds=[];maxEntries;maxAge;cleanupInterval;lastCleanup=0;constructor(e){this.maxEntries=e?.maxEntries??1e4,this.maxAge=e?.maxAge??864e5,this.cleanupInterval=e?.cleanupInterval??3e5;}maybeCleanup(){if(this.cleanupInterval<=0||this.maxAge<=0)return;let e=Date.now();e-this.lastCleanup>=this.cleanupInterval&&(this.lastCleanup=e,this.deleteOlderThanSync(this.maxAge));}deleteOlderThanSync(e){let n=Date.now()-e,a=0;for(let t=this.entryIds.length-1;t>=0;t--){let s=this.entryIds[t],r=this.entriesById.get(s);if(r)if(new Date(r.timestamp).getTime()<n)this.entriesById.delete(s),this.entryIds.splice(t,1),a++;else break}return a}async store(e){for(this.maybeCleanup();this.entryIds.length>=this.maxEntries;){let n=this.entryIds.pop();n&&this.entriesById.delete(n);}this.entriesById.set(e.id,e),this.entryIds.unshift(e.id);}async query(e){this.maybeCleanup();let n=this.getFilteredEntries(e);if(e?.sort){let{field:s,direction:r}=e.sort;n=n.sort((i,o)=>{let g,u;switch(s){case "timestamp":g=new Date(i.timestamp).getTime(),u=new Date(o.timestamp).getTime();break;case "responseTimeMs":g=i.response.responseTimeMs,u=o.response.responseTimeMs;break;case "statusCode":g=i.response.statusCode,u=o.response.statusCode;break;default:return 0}return r==="asc"?g-u:u-g});}let a=e?.offset??0,t=e?.limit??n.length;return n.slice(a,a+t)}async getById(e){return this.entriesById.get(e)??null}async count(e){return this.getFilteredEntries(e).length}async deleteOlderThan(e){return this.deleteOlderThanSync(e)}async clear(){let e=this.entriesById.size;return this.entriesById.clear(),this.entryIds=[],e}destroy(){this.entriesById.clear(),this.entryIds=[];}getSize(){return this.entriesById.size}getFilteredEntries(e){if(!e)return Array.from(this.entriesById.values());let n=[];for(let a of this.entryIds){let t=this.entriesById.get(a);if(t&&!(e.level&&!(Array.isArray(e.level)?e.level:[e.level]).includes(t.level))&&!(e.method&&!(Array.isArray(e.method)?e.method:[e.method]).map(r=>r.toUpperCase()).includes(t.request.method.toUpperCase()))&&!(e.path&&!d(t.request.path,e.path))){if(e.statusCode){let{min:s,max:r}=e.statusCode,i=t.response.statusCode;if(s!==void 0&&i<s||r!==void 0&&i>r)continue}if(e.timeRange){let s=new Date(t.timestamp).getTime(),{start:r,end:i}=e.timeRange;if(r){let o=typeof r=="string"?new Date(r).getTime():r.getTime();if(s<o)continue}if(i){let o=typeof i=="string"?new Date(i).getTime():i.getTime();if(s>o)continue}}e.userId&&t.request.userId!==e.userId||e.clientIp&&t.request.clientIp!==e.clientIp||e.requestId&&t.id!==e.requestId||e.errorMessage&&(!t.error?.message||!t.error.message.toLowerCase().includes(e.errorMessage.toLowerCase()))||n.push(t);}}return n}};export{m as a};
@@ -0,0 +1 @@
1
+ import {t,u,v as v$1,w,x,z,B,C,D,E as E$1,F,m as m$1,o,y,A,G,H,I,J,K,L,T,U,ba,ca}from'./chunk-ZBCVLQ3W.js';import {b,a}from'./chunk-KUFOENSK.js';import {z as z$1}from'zod';var E=new Map;function m(u){return E.has(u)||E.set(u,new Map),E.get(u)}function Ee(u,t,a){let n=m(a.model),e=a.localKey||"id",r=u[e];if(r==null)return u;let o=Array.from(n.values()).filter(s=>s[a.foreignKey]===r);switch(a.type){case "hasOne":return {...u,[t]:o[0]||null};case "hasMany":return {...u,[t]:o};case "belongsTo":{let s=u[a.foreignKey];if(s==null)return {...u,[t]:null};let i=Array.from(n.values()).find(d=>d[a.localKey||"id"]===s);return {...u,[t]:i||null}}default:return u}}function v(u,t,a){if(!a?.relations?.length||!t.model.relations)return u;let n={...u};for(let e of a.relations){let r=t.model.relations[e];r&&(n=Ee(n,e,r));}return n}function _e(){E.clear();}function Ie(u){return m(u)}function R(u,t,a){if(u==null||typeof u!="object")return false;let n=u;if(t.enabled){let e=n[t.field];if(e!=null)return false}if(a){for(let[e,r]of Object.entries(a))if(String(n[e])!==r)return false}return true}var P=Object.freeze({__memoryNoopTx:true,rolledBack:false}),se=class extends t{_tx=P;generateId(){return crypto.randomUUID()}async create(t){let a=m(this._meta.model.tableName),n=this._meta.model.primaryKeys[0],e=this.applyManagedInsertFields(t,"memory",()=>this.generateId()),r=String(e[n]);return a.set(r,e),e}async createNested(t,a,n,e){let r=m(n.model),o=[],s=Array.isArray(e)?e:[e];for(let i of s){if(typeof i!="object"||i===null)continue;let d={...i,id:crypto.randomUUID(),[n.foreignKey]:t};r.set(d.id,d),o.push(d);}return o}},ie=class extends u{async read(t,a,n){let r=m(this._meta.model.tableName).get(t),o=this.getSoftDeleteConfig();return !r||!R(r,o,a)?null:v(r,this._meta,n)}},ae=class extends v$1{_tx=P;async findExisting(t,a){let e=m(this._meta.model.tableName).get(t),r=this.getSoftDeleteConfig();return !e||!R(e,r,a)?null:{...e}}async update(t,a,n){let e=m(this._meta.model.tableName),r=e.get(t),o=this.getSoftDeleteConfig();if(!r||!R(r,o,n))return null;let s={...r,...this.applyManagedUpdateFields(a)};return e.set(t,s),s}async processNestedWrites(t,a,n,e){let r=m(n.model),o={created:[],updated:[],deleted:[],connected:[],disconnected:[]};if(e.create){let s=Array.isArray(e.create)?e.create:[e.create];for(let i of s){if(typeof i!="object"||i===null)continue;let d={...i,id:crypto.randomUUID(),[n.foreignKey]:t};r.set(d.id,d),o.created.push(d);}}if(e.update)for(let s of e.update){if(!s.id)continue;let i=r.get(String(s.id));if(!i||i[n.foreignKey]!==t)continue;let d={...i,...s};r.set(String(s.id),d),o.updated.push(d);}if(e.delete)for(let s of e.delete){let i=r.get(String(s));i&&i[n.foreignKey]===t&&(r.delete(String(s)),o.deleted.push(s));}if(e.connect)for(let s of e.connect){let i=r.get(String(s));if(!i)continue;let d={...i,[n.foreignKey]:t};r.set(String(s),d),o.connected.push(s);}if(e.disconnect)for(let s of e.disconnect){let i=r.get(String(s));if(!i||i[n.foreignKey]!==t)continue;let d={...i,[n.foreignKey]:null};r.set(String(s),d),o.disconnected.push(s);}if(e.set!==void 0){let s=Array.from(r.values()).filter(i=>i[n.foreignKey]===t);for(let i of s)if(i.id){let d={...i,[n.foreignKey]:null};r.set(String(i.id),d),o.disconnected.push(i.id);}if(e.set!==null){let i={...e.set,id:crypto.randomUUID(),[n.foreignKey]:t};r.set(i.id,i),o.created.push(i);}}return o}},de=class extends w{_tx=P;async findForDelete(t,a){let e=m(this._meta.model.tableName).get(t),r=this.getSoftDeleteConfig();return !e||!R(e,r,a)?null:e}async countRelated(t,a,n){let e=m(n.model),r=0;for(let o of e.values())o[n.foreignKey]===t&&r++;return r}async deleteRelated(t,a,n){let e=m(n.model),r=0;for(let[o,s]of e.entries())s[n.foreignKey]===t&&(e.delete(o),r++);return r}async nullifyRelated(t,a,n){let e=m(n.model),r=0;for(let[o,s]of e.entries())if(s[n.foreignKey]===t){let i={...s,[n.foreignKey]:null};e.set(o,i),r++;}return r}async delete(t,a){let n=m(this._meta.model.tableName),e=n.get(t),r=this.getSoftDeleteConfig();if(!e||!R(e,r,a))return null;if(r.enabled){let o={...e,[r.field]:new Date};return n.set(t,o),o}else return n.delete(t),e}},le=class extends x{async list(t){let a$1=m(this._meta.model.tableName),n=Array.from(a$1.values()),e=this.getSoftDeleteConfig();e.enabled&&(t.options.onlyDeleted?n=n.filter(l=>{let p=l[e.field];return p!=null}):t.options.withDeleted||(n=n.filter(l=>{let p=l[e.field];return p==null})));for(let l of t.filters)n=n.filter(p=>{let c=p[l.field];switch(l.operator){case "eq":return String(c)===String(l.value);case "ne":return String(c)!==String(l.value);case "gt":return Number(c)>Number(l.value);case "gte":return Number(c)>=Number(l.value);case "lt":return Number(c)<Number(l.value);case "lte":return Number(c)<=Number(l.value);case "in":return l.value.map(String).includes(String(c));case "nin":return !l.value.map(String).includes(String(c));case "like":return String(c).includes(String(l.value).replace(/%/g,""));case "ilike":return String(c).toLowerCase().includes(String(l.value).replace(/%/g,"").toLowerCase());case "null":return l.value?c===null:c!==null;case "between":{let[y,f]=l.value;return Number(c)>=Number(y)&&Number(c)<=Number(f)}default:return true}});if(t.options.search&&this.searchFields.length>0){let l=t.options.search.toLowerCase();n=n.filter(p=>this.searchFields.some(c=>{let y=p[c];return String(y).toLowerCase().includes(l)}));}let r=n.length;if(t.options.order_by){let l=t.options.order_by,p=t.options.order_by_direction==="desc"?-1:1;n.sort((c,y)=>{let f=c[l],b=y[l];return f<b?-1*p:f>b?1*p:0});}if(this.cursorPaginationEnabled&&(t.options.cursor||t.options.limit)){let l=this.cursorField||"id",p=t.options.limit||t.options.per_page||this.defaultPerPage,c=0;if(t.options.cursor){let x=b(t.options.cursor);if(x!==null){let I=n.findIndex(ve=>String(ve[l])===x);I!==-1&&(c=I+1);}}let y=n.slice(c,c+p),f={relations:t.options.include||[]},b$1=y.map(x=>v(x,this._meta,f)),M=c+p<n.length,w=c>0,j,S;if(M&&y.length>0){let x=y[y.length-1];j=a(x[l]);}if(w&&c>0){let x=n[c-1];S=a(x[l]);}return {result:b$1,result_info:{page:0,per_page:p,total_count:r,has_next_page:M,has_prev_page:w,next_cursor:j,prev_cursor:S}}}let o=t.options.page||1,s=t.options.per_page||this.defaultPerPage,i=(o-1)*s,d=n.slice(i,i+s),g={relations:t.options.include||[]},O=d.map(l=>v(l,this._meta,g)),h=Math.ceil(r/s);return {result:O,result_info:{page:o,per_page:s,total_count:r,total_pages:h,has_next_page:o<h,has_prev_page:o>1}}}},ce=class extends z{async restore(t,a){let n=m(this._meta.model.tableName),e=n.get(t),r=this.getSoftDeleteConfig();if(!e)return null;let o=e[r.field];if(o==null)return null;if(a){for(let[i,d]of Object.entries(a))if(String(e[i])!==d)return null}let s={...e,[r.field]:null};return n.set(t,s),s}};var ue=class extends B{generateId(){return crypto.randomUUID()}async batchCreate(t){let a=m(this._meta.model.tableName),n=this._meta.model.primaryKeys[0],e=[];for(let r of t){let o=this.applyManagedInsertFields(r,"memory",()=>this.generateId()),s=String(o[n]);a.set(s,o),e.push(o);}return e}},me=class extends C{async batchUpdate(t){let a=m(this._meta.model.tableName),n=this.getSoftDeleteConfig(),e=[],r=[];for(let o of t){let s=a.get(o.id);if(!s){r.push(o.id);continue}if(!R(s,n)){r.push(o.id);continue}let i={...s,...this.applyManagedUpdateFields(o.data)};a.set(o.id,i),e.push(i);}return {updated:e,notFound:r}}},ge=class extends D{async batchDelete(t){let a=m(this._meta.model.tableName),n=this.getSoftDeleteConfig(),e=[],r=[];for(let o of t){let s=a.get(o);if(!s){r.push(o);continue}if(!R(s,n)){r.push(o);continue}if(n.enabled){let i={...s,[n.field]:new Date};a.set(o,i),e.push(i);}else a.delete(o),e.push(s);}return {deleted:e,notFound:r}}},pe=class extends E$1{async batchRestore(t){let a=m(this._meta.model.tableName),n=this.getSoftDeleteConfig(),e=[],r=[];for(let o of t){let s=a.get(o);if(!s){r.push(o);continue}let i=s[n.field];if(i==null){r.push(o);continue}let d={...s,[n.field]:null};a.set(o,d),e.push(d);}return {restored:e,notFound:r}}},fe=class extends F{generateId(){return crypto.randomUUID()}async findExisting(t){let a=m(this._meta.model.tableName),n=this.getUpsertKeys();for(let e of a.values()){let r=true;for(let o of n){let s=t[o],i=e[o];if(s!==i){r=false;break}}if(r)return e}return null}async create(t){let a=m(this._meta.model.tableName),n=this._meta.model.primaryKeys[0],e=this.applyManagedInsertFields(t,"memory",()=>this.generateId());return a.set(String(e[n]),e),e}async update(t,a){let n=m(this._meta.model.tableName),e=this._meta.model.primaryKeys[0],r=String(t[e]),o={...t,...this.applyManagedUpdateFields(a)};return n.set(r,o),o}async nativeBatchUpsert(t,a){let n=m(this._meta.model.tableName),e=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],o=[],s=0,i=0;for(let d=0;d<t.length;d++){let g=t[d],O=null;for(let h of n.values()){let l=true;for(let p of e){let c=g[p],y=h[p];if(c!==y){l=false;break}}if(l){O=h;break}}if(O){let h={...g};if(this.createOnlyFields)for(let c of this.createOnlyFields)delete h[c];let l=String(O[r]),p={...O,...this.applyManagedUpdateFields(h)};n.set(l,p),o.push({data:p,created:false,index:d}),i++;}else {let h={...g};if(this.updateOnlyFields)for(let c of this.updateOnlyFields)delete h[c];let l=this.applyManagedInsertFields(h,"memory",()=>this.generateId()),p=String(l[r]);n.set(p,l),o.push({data:l,created:true,index:d}),s++;}}return {items:o,createdCount:s,updatedCount:i,totalCount:o.length}}};var _=class extends m$1{maxBulkSize=1e3;confirmThreshold=100;returnRecords=false;hookMode="parallel";filterFields;getSchema(){return {request:{body:{content:{"application/json":{schema:this.getUpdateSchema().partial()}}},query:z$1.object({dryRun:z$1.string().optional()}).passthrough()},responses:{200:{description:"Bulk patch result",content:{"application/json":{schema:z$1.object({success:z$1.boolean(),matched:z$1.number(),updated:z$1.number(),dryRun:z$1.boolean()})}}},400:{description:"Bad request",content:{"application/json":{schema:z$1.object({success:z$1.boolean(),error:z$1.string()})}}}}}}async handle(){let t=this.getContext(),n=(await this.getValidatedData()).body;if(!n||Object.keys(n).length===0)return this.error("Request body is required with at least one field to update","EMPTY_BODY",400);let e=t.req.query("dryRun"),r=e==="true"||e==="1",o$1=o(t.req.query(),{filterFields:this.filterFields,defaultPerPage:this.maxBulkSize,maxPerPage:this.maxBulkSize}),s=await this.countMatching(o$1);if(s===0)return this.json({success:true,matched:0,updated:0,dryRun:r});if(s>this.maxBulkSize)return this.error(`Bulk patch affects ${s} records, exceeding the maximum of ${this.maxBulkSize}. Use more specific filters.`,"BULK_TOO_LARGE",400);if(s>=this.confirmThreshold&&t.req.header("X-Confirm-Bulk")!=="true")return this.error(`This operation will affect ${s} records. Set X-Confirm-Bulk: true header to confirm.`,"CONFIRMATION_REQUIRED",400);if(r)return this.json({success:true,matched:s,updated:0,dryRun:true});let i=n;this.beforeBulkPatch&&(i=await this.beforeBulkPatch(i,o$1,s));let d=await this.applyPatch(i,o$1),g={matched:s,updated:d.updated,dryRun:false,records:this.returnRecords?d.records:void 0};return this.afterBulkPatch&&await this.afterBulkPatch(g),this.json({success:true,matched:g.matched,updated:g.updated,dryRun:false,...this.returnRecords&&g.records?{records:g.records}:{}})}};var Me=class extends y{generateId(){return crypto.randomUUID()}async findSource(t,a){let e=m(this._meta.model.tableName).get(t),r=this.getSoftDeleteConfig();return !e||!R(e,r,a)?null:e}async createClone(t){let a=m(this._meta.model.tableName),n=this._meta.model.primaryKeys[0],e=this.applyManagedInsertFields(t,"memory",()=>this.generateId()),r=String(e[n]);return a.set(r,e),e}},be=class extends A{generateId(){return crypto.randomUUID()}async findExisting(t){let a=m(this._meta.model.tableName),n=this.getUpsertKeys(),e=this.getSoftDeleteConfig();for(let r of a.values()){if(e.enabled){let s=r[e.field];if(s!=null)continue}let o=true;for(let s of n){let i=t[s],d=r[s];if(i!==d){o=false;break}}if(o)return r}return null}async create(t){let a=m(this._meta.model.tableName),n=this._meta.model.primaryKeys[0],e=this.applyManagedInsertFields(t,"memory",()=>this.generateId());return a.set(String(e[n]),e),e}async update(t,a){let n=m(this._meta.model.tableName),e=this._meta.model.primaryKeys[0],r=String(t[e]),o={...t,...this.applyManagedUpdateFields(a)};return n.set(r,o),o}async nativeUpsert(t,a){let n=m(this._meta.model.tableName),e=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],o=this.getSoftDeleteConfig(),s=null;for(let i of n.values()){if(o.enabled){let g=i[o.field];if(g!=null)continue}let d=true;for(let g of e){let O=t[g],h=i[g];if(O!==h){d=false;break}}if(d){s=i;break}}if(s){let i={...t};if(this.createOnlyFields)for(let O of this.createOnlyFields)delete i[O];let d=String(s[r]),g={...s,...this.applyManagedUpdateFields(i)};return n.set(d,g),{data:g,created:false}}else {let i={...t};if(this.updateOnlyFields)for(let O of this.updateOnlyFields)delete i[O];let d=this.applyManagedInsertFields(i,"memory",()=>this.generateId()),g=String(d[r]);return n.set(g,d),{data:d,created:true}}}async processNestedWrites(t,a,n,e){let r=m(n.model),o={created:[],updated:[],deleted:[],connected:[],disconnected:[]};if(e.create){let s=Array.isArray(e.create)?e.create:[e.create];for(let i of s){if(typeof i!="object"||i===null)continue;let d={...i,id:crypto.randomUUID(),[n.foreignKey]:t};r.set(d.id,d),o.created.push(d);}}if(e.update)for(let s of e.update){let i=String(s.id),d=r.get(i);if(d&&d[n.foreignKey]===t){let g={...d,...s};r.set(i,g),o.updated.push(g);}}if(e.delete)for(let s of e.delete){let i=String(s),d=r.get(i);d&&d[n.foreignKey]===t&&(r.delete(i),o.deleted.push(s));}if(e.connect)for(let s of e.connect){let i=String(s),d=r.get(i);if(d){let g={...d,[n.foreignKey]:t};r.set(i,g),o.connected.push(s);}}if(e.disconnect)for(let s of e.disconnect){let i=String(s),d=r.get(i);if(d&&d[n.foreignKey]===t){let g={...d,[n.foreignKey]:null};r.set(i,g),o.disconnected.push(s);}}return o}},he=class extends G{async recordExists(t){return m(this._meta.model.tableName).has(t)}},ye=class extends H{},Oe=class extends I{},xe=class extends J{async rollback(t,a,n){let e=m(this._meta.model.tableName),r=this.getVersioningConfig().field,o={...a,[r]:n};return e.set(t,o),o}},Re=class extends K{async aggregate(t){let a=m(this._meta.model.tableName),n=Array.from(a.values()),e=this.getSoftDeleteConfig();if(e.enabled){let{query:r}=await this.getValidatedData();r?.withDeleted===true||r?.withDeleted==="true"||(n=n.filter(s=>{let i=s[e.field];return i==null}));}if(t.filters)for(let[r,o]of Object.entries(t.filters))n=n.filter(s=>{if(typeof o=="object"&&o!==null){for(let[i,d]of Object.entries(o)){let g=s[r];switch(i){case "eq":return String(g)===String(d);case "ne":return String(g)!==String(d);case "gt":return Number(g)>Number(d);case "gte":return Number(g)>=Number(d);case "lt":return Number(g)<Number(d);case "lte":return Number(g)<=Number(d);case "in":return d.map(String).includes(String(g));default:return true}}return true}return String(s[r])===String(o)});return L(n,t)}},ke=class extends T{async search(t,a){let n=m(this._meta.model.tableName),e=Array.from(n.values()),r=this.getSoftDeleteConfig();r.enabled&&(a.options.onlyDeleted?e=e.filter(f=>{let b=f[r.field];return b!=null}):a.options.withDeleted||(e=e.filter(f=>{let b=f[r.field];return b==null})));for(let f of a.filters)e=e.filter(b=>{let M=b[f.field];switch(f.operator){case "eq":return String(M)===String(f.value);case "ne":return String(M)!==String(f.value);case "gt":return Number(M)>Number(f.value);case "gte":return Number(M)>=Number(f.value);case "lt":return Number(M)<Number(f.value);case "lte":return Number(M)<=Number(f.value);case "in":return f.value.map(String).includes(String(M));case "nin":return !f.value.map(String).includes(String(M));case "like":return String(M).includes(String(f.value).replace(/%/g,""));case "ilike":return String(M).toLowerCase().includes(String(f.value).replace(/%/g,"").toLowerCase());case "null":return f.value?M===null:M!==null;case "between":{let[w,j]=f.value;return Number(M)>=Number(w)&&Number(M)<=Number(j)}default:return true}});let o=this.getSearchableFields(),s=e,i=t;if(t.mode==="all"){let f=t.query.toLowerCase().split(/\s+/).filter(M=>M.length>0),b=t.fields||Object.keys(o);f.length>0&&(s=s.filter(M=>{let w=M;return f.every(j=>b.some(S=>{let x=w[S];return x==null?false:(Array.isArray(x)?x.join(" "):String(x)).toLowerCase().includes(j)}))})),i={...t,mode:"any"};}let d=U(s,i,o),g=d.length;if(a.options.order_by){let f=a.options.order_by,b=a.options.order_by_direction==="desc"?-1:1;d.sort((M,w)=>{let j=M.item[f],S=w.item[f];return j<S?-1*b:j>S?1*b:0});}let O=a.options.page||1,h=a.options.per_page||this.defaultPerPage,l=(O-1)*h,p=d.slice(l,l+h),c={relations:a.options.include||[]};return {items:p.map(f=>({...f,item:v(f.item,this._meta,c)})),totalCount:g}}},je=class extends ba{async list(t){let a=m(this._meta.model.tableName),n=Array.from(a.values()),e=this.getSoftDeleteConfig();e.enabled&&(t.options.onlyDeleted?n=n.filter(l=>{let p=l[e.field];return p!=null}):t.options.withDeleted||(n=n.filter(l=>{let p=l[e.field];return p==null})));for(let l of t.filters)n=n.filter(p=>{let c=p[l.field];switch(l.operator){case "eq":return String(c)===String(l.value);case "ne":return String(c)!==String(l.value);case "gt":return Number(c)>Number(l.value);case "gte":return Number(c)>=Number(l.value);case "lt":return Number(c)<Number(l.value);case "lte":return Number(c)<=Number(l.value);case "in":return l.value.map(String).includes(String(c));case "nin":return !l.value.map(String).includes(String(c));case "like":return String(c).includes(String(l.value).replace(/%/g,""));case "ilike":return String(c).toLowerCase().includes(String(l.value).replace(/%/g,"").toLowerCase());case "null":return l.value?c===null:c!==null;case "between":{let[y,f]=l.value;return Number(c)>=Number(y)&&Number(c)<=Number(f)}default:return true}});if(t.options.search&&this.searchFields.length>0){let l=t.options.search.toLowerCase();n=n.filter(p=>this.searchFields.some(c=>{let y=p[c];return String(y).toLowerCase().includes(l)}));}let r=n.length;if(t.options.order_by){let l=t.options.order_by,p=t.options.order_by_direction==="desc"?-1:1;n.sort((c,y)=>{let f=c[l],b=y[l];return f<b?-1*p:f>b?1*p:0});}let o=t.options.page||1,s=t.options.per_page||this.defaultPerPage,i=(o-1)*s,d=n.slice(i,i+s),g={relations:t.options.include||[]},O=d.map(l=>v(l,this._meta,g)),h=Math.ceil(r/s);return {result:O,result_info:{page:o,per_page:s,total_count:r,total_pages:h,has_next_page:o<h,has_prev_page:o>1}}}},we=class extends ca{generateId(){return crypto.randomUUID()}async findExisting(t){let a=m(this._meta.model.tableName),n=this.getUpsertKeys(),e=this.getSoftDeleteConfig();for(let r of a.values()){if(e.enabled){let s=r[e.field];if(s!=null)continue}let o=true;for(let s of n){let i=t[s],d=r[s];if(i!==d){o=false;break}}if(o)return r}return null}async create(t){let a=m(this._meta.model.tableName),n=this._meta.model.primaryKeys[0],e=this.applyManagedInsertFields(t,"memory",()=>this.generateId());return a.set(String(e[n]),e),e}async update(t,a){let n=m(this._meta.model.tableName),e=this._meta.model.primaryKeys[0],r=String(t[e]),o={...t,...this.applyManagedUpdateFields(a)};return n.set(r,o),o}},Se=class extends _{async countMatching(t){return this.getFilteredItems(t).length}async applyPatch(t,a){let n=m(this._meta.model.tableName),e=this._meta.model.primaryKeys[0],r=this.getFilteredItems(a),o=[];for(let s of r){let i=String(s[e]),d={...s,...t};n.set(i,d),o.push(d);}return {updated:o.length,records:o}}getFilteredItems(t){let a=m(this._meta.model.tableName),n=Array.from(a.values());for(let e of t.filters)n=n.filter(r=>{let o=r[e.field];switch(e.operator){case "eq":return String(o)===String(e.value);case "ne":return String(o)!==String(e.value);case "gt":return Number(o)>Number(e.value);case "gte":return Number(o)>=Number(e.value);case "lt":return Number(o)<Number(e.value);case "lte":return Number(o)<=Number(e.value);case "in":return e.value.map(String).includes(String(o));case "nin":return !e.value.map(String).includes(String(o));case "like":return String(o).includes(String(e.value).replace(/%/g,""));case "ilike":return String(o).toLowerCase().includes(String(e.value).replace(/%/g,"").toLowerCase());case "null":return e.value?o===null:o!==null;default:return true}});return n}};export{we as A,Se as B,_ as a,E as b,m as c,_e as d,Ie as e,P as f,se as g,ie as h,ae as i,de as j,le as k,ce as l,ue as m,me as n,ge as o,pe as p,fe as q,Me as r,be as s,he as t,ye as u,Oe as v,xe as w,Re as x,ke as y,je as z};
@@ -0,0 +1 @@
1
+ import {t,u,v as v$1,w as w$1,x as x$1,z as z$1,B as B$1,C as C$1,D as D$1,E,F as F$1,T as T$1,U as U$1,ba,ca,A as A$1,G as G$1,H as H$1,I as I$1,J as J$1,K as K$1,L as L$1,y as y$1}from'./chunk-ZBCVLQ3W.js';var v,_;async function Ce(){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 Fe(){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 G(a){return (await Ce()).singular(a)}async function H(a,t){return (await Fe())(a,t)}function ke(a,t){return a[t]}function Ie(a){return typeof a=="object"&&a!==null&&"create"in a&&typeof a.create=="function"}function h(a,t){let e=ke(a,t);return Ie(e)?e:void 0}function X(a){if(typeof a.$transaction!="function")throw new Error("Prisma client does not support $transaction");return a.$transaction.bind(a)}function x(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 Y(a){let t={};for(let e of a){let o=x(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(x)};break}case "nin":{let n=Array.isArray(e.value)?e.value:[e.value];t[e.field]={notIn:n.map(x)};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,s]=e.value;t[e.field]={gte:x(n),lte:x(s)};break}}}return t}var De=500,y=new Map;function Pe(a,t){if(y.size>=De){let e=y.keys().next().value;e!==void 0&&y.delete(e);}y.set(a,t);}var J=new Map;function xe(a,t){J.set(a.toLowerCase(),t),y.delete(a);}function Ae(a){for(let[t,e]of Object.entries(a))xe(t,e);}function Ke(){J.clear(),y.clear();}async function w(a){let t=y.get(a);if(t)return t;let e=J.get(a.toLowerCase());if(e)return Pe(a,e),e;let o=a.replace(/[-_](.)/g,(n,s)=>s.toUpperCase()).replace(/^./,n=>n.toLowerCase());return o=await G(o),Pe(a,o),o}function Ne(a){let t=[];for(let e of Object.keys(a)){if(e.startsWith("$")||e.startsWith("_"))continue;let o=ke(a,e);o&&typeof o=="object"&&"create"in o&&t.push(e);}return t}async function Ue(a,t,e=3){if(t.length===0)return [];let o=a.toLowerCase();return (await Promise.all(t.map(async s=>({name:s,distance:await H(o,s.toLowerCase())})))).filter(s=>s.distance<=Math.max(3,a.length/2)).sort((s,r)=>s.distance-r.distance).slice(0,e).map(s=>s.name)}async function M(a,t){let e=await w(t),o=h(a,e);if(!o){let n=Ne(a),s=await Ue(e,n),r=`Model '${e}' not found in Prisma client. Table name: '${t}'. `;throw s.length>0&&(r+=`Did you mean: ${s.map(i=>`'${i}'`).join(", ")}? `),n.length>0&&n.length<=10&&(r+=`Available models: ${n.join(", ")}. `),r+=`You can register a custom mapping with: registerPrismaModelMapping('${t}', 'yourModelName')`,new Error(r)}return o}async function Se(a,t,e,o){let n=await w(o.model),s=h(a,n);if(!s)return t;switch(o.type){case "hasOne":{let r=o.localKey||"id",i=t[r];if(i==null)return {...t,[e]:null};let l=await s.findFirst({where:{[o.foreignKey]:i}});return {...t,[e]:l||null}}case "hasMany":{let r=o.localKey||"id",i=t[r];if(i==null)return {...t,[e]:[]};let l=await s.findMany({where:{[o.foreignKey]:i}});return {...t,[e]:l}}case "belongsTo":{let r=t[o.foreignKey];if(r==null)return {...t,[e]:null};let i=o.localKey||"id",l=await s.findFirst({where:{[i]:r}});return {...t,[e]:l||null}}default:return t}}async function Oe(a,t,e,o){if(!o?.relations?.length||!e.model.relations)return t;let n={...t};for(let s of o.relations){let r=e.model.relations[s];r&&(n=await Se(a,n,s,r));}return n}async function O(a,t,e,o){if(!t.length||!o?.relations?.length||!e.model.relations)return t;let n=t.map(s=>({...s}));for(let s of o.relations){let r=e.model.relations[s];if(!r)continue;let i=await w(r.model),l=h(a,i);if(l)switch(r.type){case "hasOne":case "hasMany":{let c=r.localKey||"id",u=[...new Set(n.map(m=>m[c]).filter(m=>m!=null))];if(u.length===0){n=n.map(m=>({...m,[s]:r.type==="hasMany"?[]:null}));continue}let d=await l.findMany({where:{[r.foreignKey]:{in:u}}}),g=new Map;for(let m of d){let p=m[r.foreignKey];g.has(p)||g.set(p,[]),g.get(p).push(m);}n=n.map(m=>{let p=m[c],f=g.get(p)||[];return {...m,[s]:r.type==="hasMany"?f:f[0]||null}});break}case "belongsTo":{let c=r.localKey||"id",u=[...new Set(n.map(m=>m[r.foreignKey]).filter(m=>m!=null))];if(u.length===0){n=n.map(m=>({...m,[s]:null}));continue}let d=await l.findMany({where:{[c]:{in:u}}}),g=new Map;for(let m of d){let p=m[c];g.set(p,m);}n=n.map(m=>{let p=m[r.foreignKey];return {...m,[s]:g.get(p)||null}});break}}}return n}async function j(a){let{model:t,filters:e,searchFields:o=[],softDeleteConfig:n,defaultPerPage:s=20,additionalWhere:r={}}=a,i={...Y(e.filters),...r};if(n?.enabled){let{withDeleted:p,onlyDeleted:f}=e.options;f?i[n.field]={not:null}:p||(i[n.field]=null);}if(e.options.search&&o.length>0){let p=o.map(f=>({[f]:{contains:e.options.search,mode:"insensitive"}}));i={...i,OR:p};}let l=await t.count({where:i}),c;e.options.order_by&&(c={[e.options.order_by]:e.options.order_by_direction||"asc"});let u=e.options.page||1,d=e.options.per_page||s,g=await t.findMany({where:i,orderBy:c,skip:(u-1)*d,take:d}),m=Math.ceil(l/d);return {records:g,where:i,totalCount:l,page:u,perPage:d,totalPages:m}}function C(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 F=class extends t{useTransaction=false;async getModel(){return M(this.prisma,this._meta.model.tableName)}async create(t){let e=await this.getModel(),o=this.applyManagedInsertFields(t,"prisma");return await e.create({data:o})}},I=class extends u{async getModel(){return M(this.prisma,this._meta.model.tableName)}async read(t,e,o){let n=await this.getModel(),s={[this.lookupField]:t,...e},r=await n.findFirst({where:s});return r?await Oe(this.prisma,r,this._meta,o):null}},D=class extends v$1{useTransaction=false;async getModel(){return M(this.prisma,this._meta.model.tableName)}async update(t,e,o){let n=await this.getModel(),s={[this.lookupField]:t,...o},r=await n.findFirst({where:s});if(!r)return null;let i=this._meta.model.primaryKeys[0];return await n.update({where:{[i]:r[i]},data:this.applyManagedUpdateFields(e)})}},A=class extends w$1{useTransaction=false;async getModel(){return M(this.prisma,this._meta.model.tableName)}async findForDelete(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),s={[this.lookupField]:t,...e};return n.enabled&&(s[n.field]=null),await o.findFirst({where:s})}async delete(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),s={[this.lookupField]:t,...e};n.enabled&&(s[n.field]=null);let r=await o.findFirst({where:s});if(!r)return null;let i=this._meta.model.primaryKeys[0],l=r[i];return n.enabled?await o.update({where:{[i]:l},data:{[n.field]:new Date}}):await o.delete({where:{[i]:l}})}},K=class extends x$1{async getModel(){return M(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 O(this.prisma,e.records,this._meta,o);return C(n,e)}};var N=class extends z$1{useTransaction=false;async getModel(){return M(this.prisma,this._meta.model.tableName)}async restore(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),s={[this.lookupField]:t,[n.field]:{not:null},...e},r=await o.findFirst({where:s});if(!r)return null;let i=this._meta.model.primaryKeys[0];return await o.update({where:{[i]:r[i]},data:{[n.field]:null}})}},U=class extends B$1{async getModel(){return M(this.prisma,this._meta.model.tableName)}async batchCreate(t){let e=t.map(n=>this.applyManagedInsertFields(n,"prisma")),o=[];return await X(this.prisma)(async n=>{let s=h(n,await w(this._meta.model.tableName));if(!s)throw new Error(`Model '${this._meta.model.tableName}' not found in Prisma transaction client`);for(let r of e){let i=await s.create({data:r});o.push(i);}}),o}},S=class extends C$1{async getModel(){return M(this.prisma,this._meta.model.tableName)}async batchUpdate(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],s=[],r=[],i=t.map(d=>d.id),l={[this.lookupField]:{in:i}};o.enabled&&(l[o.field]=null);let c=await e.findMany({where:l}),u=new Map;for(let d of c){let g=d[this.lookupField];u.set(g,d);}for(let d of t){let g=u.get(d.id);if(!g){r.push(d.id);continue}let m=await e.update({where:{[n]:g[n]},data:this.applyManagedUpdateFields(d.data)});s.push(m);}return {updated:s,notFound:r}}},B=class extends D$1{async getModel(){return M(this.prisma,this._meta.model.tableName)}async batchDelete(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],s=[],r=[],i={[this.lookupField]:{in:t}};o.enabled&&(i[o.field]=null);let l=await e.findMany({where:i}),c=new Map;for(let u of l){let d=u[this.lookupField];c.set(d,u);}for(let u of t)c.has(u)||r.push(u);for(let u of t){let d=c.get(u);if(d)if(o.enabled){let g=await e.update({where:{[n]:d[n]},data:{[o.field]:new Date}});s.push(g);}else {let g=await e.delete({where:{[n]:d[n]}});s.push(g);}}return {deleted:s,notFound:r}}},T=class extends E{async getModel(){return M(this.prisma,this._meta.model.tableName)}async batchRestore(t){let e=await this.getModel(),o=this.getSoftDeleteConfig(),n=this._meta.model.primaryKeys[0],s=[],r=[],i={[this.lookupField]:{in:t},[o.field]:{not:null}},l=await e.findMany({where:i}),c=new Map;for(let u of l){let d=u[this.lookupField];c.set(d,u);}for(let u of t){let d=c.get(u);if(!d){r.push(u);continue}let g=await e.update({where:{[n]:d[n]},data:{[o.field]:null}});s.push(g);}return {restored:s,notFound:r}}},$=class extends F$1{useTransaction=true;async getModel(){return M(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let r of o){let i=t[r];i!==void 0&&(n[r]=i);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this.applyManagedInsertFields(t,"prisma");return await e.create({data:o})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:this.applyManagedUpdateFields(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],s=this.getTimestampsConfig(),r=async c=>{let u=h(c,await w(this._meta.model.tableName));if(!u)throw new Error(`Model '${this._meta.model.tableName}' not found in Prisma client`);let d=[],g=[];for(let m=0;m<t.length;m++){let p=t[m];try{let f={};for(let b of o){let R=p[b];R!==void 0&&(f[b]=R);}let k=this.applyManagedInsertFields(p,"prisma"),P={};for(let[b,R]of Object.entries(p))!o.includes(b)&&b!==n&&(this.createOnlyFields?.includes(b)||(P[b]=R));s.enabled&&(P[s.updatedAt]=Date.now());let je=await u.upsert({where:f,create:k,update:Object.keys(P).length>0?P:{}});d.push({data:je,created:!1,index:m});}catch(f){if(this.continueOnError)g.push({index:m,error:f instanceof Error?f.message:String(f)});else throw f}}return {results:d,errors:g}},i;this.useTransaction?i=await X(this.prisma)(r):i=await r(this.prisma);let l={items:i.results,createdCount:0,updatedCount:i.results.length,totalCount:i.results.length};return i.errors.length>0&&(l.errors=i.errors),l}};var L=class extends T$1{async getModel(){return M(this.prisma,this._meta.model.tableName)}buildSearchWhere(t,e){let o=Y(e.filters),n=this.getSoftDeleteConfig();if(n.enabled){let{withDeleted:l,onlyDeleted:c}=e.options;c?o[n.field]={not:null}:l||(o[n.field]=null);}let s=this.getSearchableFields(),r=t.fields||Object.keys(s),i=(l,c)=>({[l]:{contains:c,mode:"insensitive"}});if(r.length>0)if(t.mode==="all"){let l=t.query.split(/\s+/).filter(c=>c.length>0);l.length>0&&(o={...o,AND:l.map(c=>({OR:r.map(u=>i(u,c))}))});}else o={...o,OR:r.map(l=>i(l,t.query))};return o}async search(t,e){let o=await this.getModel(),n=this.buildSearchWhere(t,e),s=await o.count({where:n}),r=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,c=await o.findMany({where:n,orderBy:r,skip:(i-1)*l,take:l}),u=t.mode==="all"?{...t,mode:"any"}:t,d=U$1(c,u,this.getSearchableFields()),g={relations:e.options.include||[]},m=d.map(k=>k.item),p=await O(this.prisma,m,this._meta,g);return {items:d.map((k,P)=>({...k,item:p[P]})),totalCount:s}}},W=class extends ba{async getModel(){return M(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 O(this.prisma,e.records,this._meta,o);return C(n,e)}},V=class extends ca{async getModel(){return M(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let r of o){let i=t[r];i!==void 0&&(n[r]=i);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this.applyManagedInsertFields(t,"prisma");return await e.create({data:o})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:this.applyManagedUpdateFields(e)})}},Q=class extends A$1{useTransaction=false;async getModel(){return M(this.prisma,this._meta.model.tableName)}async findExisting(t){let e=await this.getModel(),o=this.getUpsertKeys(),n={};for(let r of o){let i=t[r];i!==void 0&&(n[r]=i);}return Object.keys(n).length===0?null:await e.findFirst({where:n})||null}async create(t){let e=await this.getModel(),o=this.applyManagedInsertFields(t,"prisma");return await e.create({data:o})}async update(t,e){let o=await this.getModel(),n=this._meta.model.primaryKeys[0];return await o.update({where:{[n]:t[n]},data:this.applyManagedUpdateFields(e)})}async nativeUpsert(t,e){let o=await this.getModel(),n=this.getUpsertKeys(),s=this._meta.model.primaryKeys[0],r=this.getTimestampsConfig(),i={};for(let d of n){let g=t[d];g!==void 0&&(i[d]=g);}let l=this.applyManagedInsertFields(t,"prisma"),c={};for(let[d,g]of Object.entries(t))!n.includes(d)&&d!==s&&(this.createOnlyFields?.includes(d)||(c[d]=g));return r.enabled&&(c[r.updatedAt]=Date.now()),{data:await o.upsert({where:i,create:l,update:Object.keys(c).length>0?c:{}}),created:false}}},Re=class extends G$1{async getModel(){return M(this.prisma,this._meta.model.tableName)}async recordExists(t){return await(await this.getModel()).count({where:{[this.lookupField]:t}})>0}},Ee=class extends H$1{},ve=class extends I$1{},_e=class extends J$1{async getModel(){return M(this.prisma,this._meta.model.tableName)}async rollback(t,e,o){let n=await this.getModel(),s=this.getVersioningConfig().field,r=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:{[r]:i[r]},data:{...e,[s]:o}})}},z=class extends K$1{useNativeAggregation=true;async getModel(){return M(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,s]of Object.entries(t.filters))if(typeof s=="object"&&s!==null){let r={};for(let[i,l]of Object.entries(s))switch(i){case "eq":r.equals=l;break;case "ne":r.not=l;break;case "gt":r.gt=l;break;case "gte":r.gte=l;break;case "lt":r.lt=l;break;case "lte":r.lte=l;break;case "in":r.in=l;break;case "nin":r.notIn=l;break;default:r[i]=l;}e[n]=r;}else e[n]=s;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 L$1(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},s={},r=this.groupAggregationsByOperation(o.aggregations);if(n._count=true,r.sum.length){n._sum={};for(let c of r.sum)n._sum[c]=true;}if(r.avg.length){n._avg={};for(let c of r.avg)n._avg[c]=true;}if(r.min.length){n._min={};for(let c of r.min)n._min[c]=true;}if(r.max.length){n._max={};for(let c of r.max)n._max[c]=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 c=await l.aggregate(n);if(c._count!==void 0&&(s.count=typeof c._count=="object"?c._count._all??0:c._count),c._sum&&r.sum.length)for(let u of r.sum){let d=u.charAt(0).toUpperCase()+u.slice(1);s[`sum${d}`]=c._sum[u]??0;}if(c._avg&&r.avg.length)for(let u of r.avg){let d=u.charAt(0).toUpperCase()+u.slice(1);s[`avg${d}`]=c._avg[u]??0;}if(c._min&&r.min.length)for(let u of r.min){let d=u.charAt(0).toUpperCase()+u.slice(1);s[`min${d}`]=c._min[u];}if(c._max&&r.max.length)for(let u of r.max){let d=u.charAt(0).toUpperCase()+u.slice(1);s[`max${d}`]=c._max[u];}return {values:s,groups:[]}}catch{let u=await t.findMany({where:e});return L$1(u,o)}}async aggregateWithGroupBy(t,e,o){let n={by:o.groupBy,where:e},s=this.groupAggregationsByOperation(o.aggregations);if(n._count=true,s.sum.length){n._sum={};for(let l of s.sum)n._sum[l]=true;}if(s.avg.length){n._avg={};for(let l of s.avg)n._avg[l]=true;}if(s.min.length){n._min={};for(let l of s.min)n._min[l]=true;}if(s.max.length){n._max={};for(let l of s.max)n._max[l]=true;}let r=await w(this._meta.model.tableName),i=h(this.prisma,r);if(!i)throw new Error(`Model '${r}' not found in Prisma client`);try{let c=(await i.groupBy(n)).map(d=>{let g={},m={};for(let p of o.groupBy)g[p]=d[p];if(m.count=typeof d._count=="object"?d._count._all??0:d._count??0,d._sum&&s.sum.length)for(let p of s.sum){let f=p.charAt(0).toUpperCase()+p.slice(1);m[`sum${f}`]=d._sum[p]??0;}if(d._avg&&s.avg.length)for(let p of s.avg){let f=p.charAt(0).toUpperCase()+p.slice(1);m[`avg${f}`]=d._avg[p]??0;}if(d._min&&s.min.length)for(let p of s.min){let f=p.charAt(0).toUpperCase()+p.slice(1);m[`min${f}`]=d._min[p];}if(d._max&&s.max.length)for(let p of s.max){let f=p.charAt(0).toUpperCase()+p.slice(1);m[`max${f}`]=d._max[p];}return {key:g,values:m}});return {values:{count:c.reduce((d,g)=>d+(g.values.count||0),0)},groups:c}}catch{let c=await t.findMany({where:e});return L$1(c,o)}}},q=class extends y$1{async getModel(){return M(this.prisma,this._meta.model.tableName)}generateId(){return crypto.randomUUID()}async findSource(t,e){let o=await this.getModel(),n=this.getSoftDeleteConfig(),s={[this.lookupField]:t,...e};n.enabled&&(s[n.field]=null);let r=await o.findFirst({where:s});return r||null}async createClone(t){let e=await this.getModel(),o=this.applyManagedInsertFields(t,"prisma",()=>this.generateId());return await e.create({data:o})}};var ht={CreateEndpoint:F,ListEndpoint:K,ReadEndpoint:I,UpdateEndpoint:D,DeleteEndpoint:A,RestoreEndpoint:N,BatchCreateEndpoint:U,BatchUpdateEndpoint:S,BatchDeleteEndpoint:B,BatchRestoreEndpoint:T,BatchUpsertEndpoint:$,SearchEndpoint:L,AggregateEndpoint:z,ExportEndpoint:W,ImportEndpoint:V,UpsertEndpoint:Q,CloneEndpoint:q};export{xe as a,Ae as b,Ke as c,F as d,I as e,D as f,A as g,K as h,N as i,U as j,S as k,B as l,T as m,$ as n,L as o,W as p,V as q,Q as r,Re as s,Ee as t,ve as u,_e as v,z as w,q as x,ht as y};
@@ -1 +1 @@
1
- import {b as b$4}from'./chunk-NGUMNUOP.js';import {a as a$3}from'./chunk-GF2EC5G4.js';import {b as b$3}from'./chunk-FJCWFB5L.js';import {a,g}from'./chunk-2M5BM4VD.js';import {a as a$1,i}from'./chunk-FC56WWPB.js';import {b,c}from'./chunk-GBQQ3YQX.js';import {b as b$2}from'./chunk-DMGP7QDL.js';import {e,a as a$2,b as b$1}from'./chunk-VJRDAVID.js';function B(e,t={}){let{ipHeader:n="X-Forwarded-For",trustProxy:r=true}=t;if(r){let s=e.req.header(n);if(s){let c=s.split(",")[0]?.trim();if(c)return c}let a=e.req.header("X-Real-IP")?.trim();if(a)return a;let i=e.req.header("CF-Connecting-IP")?.trim();if(i)return i}let o=e.req.raw;if(o&&typeof o.socket=="object"&&o.socket?.remoteAddress)return o.socket.remoteAddress;if(o?.cf?.ip)return o.cf.ip}function $(e){return a$2(e,"userId")}function z(e,t){let n=e.toLowerCase();for(let r of t){if(r instanceof RegExp){if(r.test(e))return true;continue}let o=r.toLowerCase();if(o.includes("*")){let s=o.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");if(new RegExp(`^${s}$`).test(n))return true}else if(n===o)return true}return false}function j(e,t){if(e==null)return e;if(Array.isArray(e))return e.map(r=>j(r,t));if(typeof e!="object")return e;let n={};for(let[r,o]of Object.entries(e))z(r,t)?n[r]="[REDACTED]":typeof o=="object"&&o!==null?n[r]=j(o,t):n[r]=o;return n}function he(e,t){let n={};for(let[r,o]of Object.entries(e))n[r]=z(r,t)?"[REDACTED]":o;return n}function Ye(e,t){return z(e,t)}function ee(e,t){return j(e,t)}function te(e,t){return he(e,t)}function Ze(e,t){return a(e,t)}function ye(e,t,n){for(let r of n)if(a(e,r))return true;if(t.length===0)return false;for(let r of t)if(a(e,r))return false;return true}function xe(e,t="X-Forwarded-For",n=false){return B(e,{ipHeader:t,trustProxy:n||true})}function re(e){let t={};return e.forEach((n,r)=>{t[r.toLowerCase()]=n;}),t}function Ce(e){let t={};return new URL(e.req.url).searchParams.forEach((r,o)=>{t[o]=r;}),t}function D(e,t){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [TRUNCATED]":e;let n=JSON.stringify(e);return n.length>t?{_truncated:true,_originalSize:n.length,_maxSize:t}:e}function Ee(e,t){if(!e)return false;if(t.length===0)return true;let n=e.toLowerCase();for(let r of t)if(n.includes(r.toLowerCase()))return true;return false}function Se(e){return $(e)}function Re(){return e()}var U=class extends a$1{constructor(t="Too many requests",n=60){super(t,429,"RATE_LIMIT_EXCEEDED",{retryAfter:n}),this.name="RateLimitExceededException";}};function q(e,t="X-Forwarded-For",n=false){return B(e,{ipHeader:t,trustProxy:n})??"unknown"}function ne(e){return $(e)??null}function we(e,t="X-API-Key"){return e.req.header(t)||null}function st(e,t){return a(e,t)}function ve(e,t){return t.some(n=>a(e,n))}function Ie(e,...t){let n=t.filter(r=>r!==void 0&&r!=="");return `${e}:${n.join(":")}`}function V(e){return e instanceof Error?e:new Error(String(e))}function Me(e,t){let n=V(e),r=new Error(`${t}: ${n.message}`);return r.cause=n,r}function Oe(e){return e instanceof Error?e.message:String(e)}var X=b("loggingStorage");function ht(e){X.set(e);}function yt(){return X.get()}var De=["authorization","cookie","x-api-key","x-auth-token"],Fe=["password","token","secret","apiKey","api_key","accessToken","access_token","refreshToken","refresh_token","creditCard","credit_card","ssn","socialSecurityNumber"],_e=["/health","/healthz","/ready","/readyz","/live","/livez","/metrics","/favicon.ico"];function xt(e){return a$2(e,"requestId")}function Ct(e){return a$2(e,"requestStartTime")}function Et(e={}){let t=e.enabled??true,n=e.level??"info",r=e.includePaths??[],o=e.excludePaths??_e,s=e.redactHeaders??De,a=e.redactBodyFields??Fe,i=e.requestBody??{enabled:false},c=e.responseBody??{enabled:false},u=e.includeHeaders??true,d=e.includeQuery??true,g=e.includeClientIp??true,C=e.ipHeader??"X-Forwarded-For",m=e.trustProxy??false,h=e.minResponseTimeMs??0,R=e.generateRequestId??Re;return async(l,P)=>{if(!t)return P();let w=l.req.path;if(ye(w,r,o))return P();let f=R(),T=Date.now();b$1(l,"requestId",f),b$1(l,"requestStartTime",T),l.header("X-Request-ID",f);let Ae=l.req.method,qe=l.req.url,oe;if(u){let E=re(l.req.raw.headers);oe=te(E,s);}let se;d&&(se=Ce(l));let ae;g&&(ae=xe(l,C,m));let Ke=Se(l),Q;if(i.enabled){let E=l.req.header("content-type"),H=i.contentTypes??[];if(Ee(E,H))try{let L=await l.req.raw.clone().text();if(L)try{let x=JSON.parse(L);x=ee(x,a);let y=i.maxSize??10240;Q=D(x,y);}catch{let x=i.maxSize??10240;Q=D(L,x);}}catch{}}let S,Y;try{await P();}catch(E){throw S=E instanceof Error?E:new Error(String(E)),E}finally{let H=Date.now()-T;if(H<h)return;let b=l.res.status,L;if(u){let p=re(l.res.headers);L=te(p,s);}if(c.enabled&&!S){let p=c.statusCodes??[];if(p.length===0||p.includes(b))try{let Z=await l.res.clone().text();if(Z)try{let M=JSON.parse(Z);M=ee(M,a);let He=c.maxSize??10240;Y=D(M,He);}catch{let M=c.maxSize??10240;Y=D(Z,M);}}catch{}}let x=n;e.levelResolver?x=e.levelResolver(l,H,b,S):S||b>=500?x="error":b>=400&&(x="warn");let y={id:f,timestamp:new Date(T).toISOString(),level:x,request:{method:Ae,path:w,url:qe,headers:oe,query:se,body:Q,clientIp:ae,userId:Ke},response:{statusCode:b,headers:L,body:Y,responseTimeMs:H}};if(S&&(y.error={message:S.message,name:S.name,stack:S.stack}),e.metadata){let p=typeof e.metadata=="function"?e.metadata(l):e.metadata;y.metadata=p;}e.formatter&&(y=e.formatter(y));let ie=Pe(l,e.storage);(async()=>{if(ie)try{await ie.store(y);}catch(p){e.onError&&e.onError(p instanceof Error?p:new Error(String(p)),y);}if(e.handlers)for(let p of e.handlers)try{await p(y);}catch(v){e.onError&&e.onError(v instanceof Error?v:new Error(String(v)),y);}})().catch(p=>{let v=V(p);e.onError?e.onError(v,y):b$2().error("Failed to process log entry",{error:v.message});});}}}function Te(e){let{tableName:t,method:n,params:r,query:o,keyFields:s,userId:a,prefix:i}=e,c=[];if(i&&c.push(i),c.push(t),c.push(n),r&&Object.keys(r).length>0){let u=Object.keys(r).sort().map(d=>`${d}=${r[d]}`).join("&");c.push(u);}if(o&&Object.keys(o).length>0){let u=Object.keys(o).filter(d=>o[d]!==void 0&&o[d]!==null&&o[d]!=="");if(s&&s.length>0&&(u=u.filter(d=>s.includes(d))),u.length>0){let d=u.sort().map(g=>`${g}=${String(o[g])}`).join("&");c.push(d);}}return a&&c.push(`user=${a}`),c.join(":")}function K(e,t,n){let r=[];if(n&&r.push(n),r.push(e),!t)return r.push("*"),r.join(":");let{method:o,id:s,userId:a}=t;return o?(r.push(o),r.join(":")+"*"):(s!==void 0?(r.push("*"),r.push(`id=${s}*`)):a?(r.push("*"),r.push(`user=${a}`)):r.push("*"),r.join(":"))}function be(e,t,n){return t.map(r=>K(r,void 0,n))}function Le(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`).test(e)}function Rt(e){let t=e.split(":"),n=t.length>2&&!["GET","LIST"].includes(t[1]),r=0,o=n?t[r++]:void 0,s=t[r++],a=t[r++],i={tableName:s,method:a};o&&(i.prefix=o);for(let c=r;c<t.length;c++){let u=t[c];if(u.startsWith("user="))i.userId=u.substring(5);else if(u.includes("=")){let d=u.split("&"),g={};for(let C of d){let[m,h]=C.split("=");m&&h!==void 0&&(g[m]=h);}a==="GET"&&!i.params?i.params=g:a==="LIST"&&!i.query||i.params?i.query=g:i.params=g;}}return i}var W=class{storage=new Map;tagIndex=new Map;stats={hits:0,misses:0,size:0};defaultTtl;maxEntries;constructor(t){this.defaultTtl=t?.defaultTtl??300,this.maxEntries=t?.maxEntries??1e4;}async get(t){let n=this.storage.get(t);return n?n.expiresAt&&n.expiresAt<Date.now()?(await this.delete(t),this.stats.misses++,null):(this.stats.hits++,n):(this.stats.misses++,null)}async set(t,n,r){let o=r?.ttl??this.defaultTtl,s=r?.tags;this.maxEntries>0&&this.storage.size>=this.maxEntries&&!this.storage.has(t)&&this.evictOldest();let a=Date.now(),i={data:n,createdAt:a,expiresAt:o>0?a+o*1e3:null,tags:s},c=this.storage.get(t);if(c?.tags)for(let u of c.tags)this.tagIndex.get(u)?.delete(t);if(c&&this.storage.delete(t),this.storage.set(t,i),this.stats.size=this.storage.size,s)for(let u of s)this.tagIndex.has(u)||this.tagIndex.set(u,new Set),this.tagIndex.get(u).add(t);}async delete(t){let n=this.storage.get(t);if(!n)return false;if(n.tags)for(let r of n.tags)this.tagIndex.get(r)?.delete(t);return this.storage.delete(t),this.stats.size=this.storage.size,true}async deletePattern(t){let n=0,r=[];for(let o of this.storage.keys())Le(o,t)&&r.push(o);for(let o of r)await this.delete(o)&&n++;return n}async deleteByTag(t){let n=this.tagIndex.get(t);if(!n||n.size===0)return 0;let r=0,o=Array.from(n);for(let s of o)await this.delete(s)&&r++;return this.tagIndex.delete(t),r}async has(t){let n=this.storage.get(t);return n?n.expiresAt&&n.expiresAt<Date.now()?(await this.delete(t),false):true:false}async clear(){this.storage.clear(),this.tagIndex.clear(),this.stats.size=0;}getStats(){return {...this.stats}}resetStats(){this.stats.hits=0,this.stats.misses=0;}getKeys(){return Array.from(this.storage.keys())}getTags(){return Array.from(this.tagIndex.keys())}evictOldest(){let t=this.storage.keys().next().value;t!==void 0&&this.delete(t).catch(()=>{});}async cleanup(){let t=Date.now(),n=0,r=[];for(let[o,s]of this.storage.entries())s.expiresAt&&s.expiresAt<t&&r.push(o);for(let o of r)await this.delete(o),n++;return n}};function G(e){let n=e._meta?.model?.tableName;if(!n)throw new i("Cache mixin requires `_meta.model.tableName`. Declare `_meta` on the endpoint or remove the cache mixin.");return n}var J=c("cacheStorage",()=>new W);function qt(e){J.set(e);}function Kt(){return J.getRequired()}function Ht(e){class t extends e{cacheConfig;getCacheConfig(){return {enabled:true,ttl:300,perUser:false,...this.cacheConfig}}async generateCacheKey(){let r=this.getCacheConfig(),o=this.getContext(),s=G(this),a=await this.getValidatedData(),i=a.params,c=a.query,u=i&&Object.keys(i).length>0?"GET":"LIST",d;return r.perUser&&(d=o.var?.userId),Te({tableName:s,method:u,params:i,query:c,keyFields:r.keyFields,userId:d,prefix:r.prefix})}_cacheHit=false;async getCachedResponse(){if(!this.getCacheConfig().enabled)return this._cacheHit=false,null;let o=await this.generateCacheKey(),s=this.getContext(),a=F(s);if(!a)return this._cacheHit=false,null;let i=await a.get(o);return this._cacheHit=i!==null,i?.data??null}getCacheStatus(){return this._cacheHit?"HIT":"MISS"}successWithCache(r,o=200){return new Response(JSON.stringify({success:true,result:r}),{status:o,headers:{"Content-Type":"application/json","X-Cache":this.getCacheStatus()}})}jsonWithCache(r,o=200){return new Response(JSON.stringify(r),{status:o,headers:{"Content-Type":"application/json","X-Cache":this.getCacheStatus()}})}async setCachedResponse(r){let o=this.getCacheConfig();if(!o.enabled)return;let s=await this.generateCacheKey(),a=this.getContext(),i=F(a);if(!i)return;let c=o.tags?[...o.tags]:[],u=this._meta;u?.model?.tableName&&c.push(u.model.tableName),await i.set(s,r,{ttl:o.ttl,tags:c.length>0?c:void 0});}async invalidateCache(r){let o=this.getContext(),s=F(o);if(!s)return;let a=this.getCacheConfig();if(r?.pattern)await s.deletePattern(r.pattern);else if(r?.tags&&s.deleteByTag)for(let i of r.tags)await s.deleteByTag(i);else {let i=G(this),c=K(i,void 0,a.prefix);await s.deletePattern(c);}}}return t}function Mt(e){class t extends e{cacheInvalidation;getCacheInvalidationConfig(){return {strategy:"all",...this.cacheInvalidation}}async performCacheInvalidation(r){let o=this.getCacheInvalidationConfig(),s=this.getContext(),a=F(s);if(!a)return;let i=G(this);switch(o.strategy??"all"){case "single":if(r!==void 0){let g=K(i,{id:r});await a.deletePattern(g);}break;case "list":let u=K(i,{method:"LIST"});await a.deletePattern(u);break;case "all":let d=K(i);await a.deletePattern(d);break;case "pattern":o.pattern&&await a.deletePattern(o.pattern);break;case "tags":if(o.tags&&a.deleteByTag)for(let g of o.tags)await a.deleteByTag(g);break}if(o.relatedModels&&o.relatedModels.length>0){let u=be(i,o.relatedModels);for(let d of u)await a.deletePattern(d);}}async handle(){let r=await super.handle();if(r.status>=200&&r.status<300){let o;try{o=(await r.clone().json())?.result?.id;}catch{}let s=G(this);this.performCacheInvalidation(o).catch(a=>{b$2().error("Cache invalidation failed",{error:a instanceof Error?a.message:String(a),tableName:s,recordId:o});});}return r}}return t}function ke(e,t){return _.resolve(e,t)}function Pe(e,t){return X.resolve(e,t)}function F(e,t){return J.resolve(e,t)}function zt(e,t){return b$3.resolve(e,t)}function Ut(e,t){return b$4.resolve(e,t)}function Vt(e,t){return g.resolve(e,t)}function Xt(e,t){return a$3.resolve(e,t)}var _=b("rateLimitStorage");function tr(e){_.set(e);}function rr(){return _.get()}function Ne(){return {ip:e=>t=>q(t,e.ipHeader,e.trustProxy),user:e=>t=>{let n=ne(t);return n?`user:${n}`:q(t,e.ipHeader,e.trustProxy)},"api-key":e=>t=>{let n=we(t,e.apiKeyHeader);return n?`apikey:${n.substring(0,8)}`:q(t,e.ipHeader,e.trustProxy)},combined:e=>t=>{let n=q(t,e.ipHeader,e.trustProxy),r=ne(t);return r?`${n}:user:${r}`:n}}}function Be(e,t){if(typeof e=="function")return e;let r=Ne()[e];return r?r(t):o=>q(o,t.ipHeader,t.trustProxy)}async function $e(e,t,n,r){let o=await e.increment(t,r),s=Math.ceil((o.windowStart+r)/1e3),a=Math.max(0,n-o.count),i=o.count<=n;return {allowed:i,limit:n,remaining:a,resetAt:s,retryAfter:i?void 0:Math.ceil((o.windowStart+r-Date.now())/1e3)}}async function je(e,t,n,r){let o=Date.now(),s=await e.addTimestamp(t,r,o),a=s.timestamps.length,i=Math.max(0,n-a),c=a<=n,u=s.timestamps.length>0?Math.min(...s.timestamps):o,d=Math.ceil((u+r)/1e3),g;if(!c&&s.timestamps.length>0){let C=[...s.timestamps].sort((h,R)=>h-R),m=a-n;if(m>0&&C.length>=m){let h=C[m-1];g=Math.max(1,Math.ceil((h+r-o)/1e3));}}return {allowed:c,limit:n,remaining:i,resetAt:d,retryAfter:g}}function nr(e={}){let t=e.limit??100,n=e.windowSeconds??60,r=e.algorithm??"sliding-window",o=e.keyStrategy??"ip",s=e.keyPrefix??"rl",a=e.skipPaths??[],i=e.includeHeaders??true,c=e.errorMessage??"Too many requests",u=Be(o,e);return async(d,g)=>{let C=d.req.path;if(a.length>0&&ve(C,a))return g();let m=ke(d,e.storage);if(!m)return b$2().warn("Rate limit storage not configured. Skipping rate limiting."),g();let h=u(d);if(!h)return g();let R=t,l=n;if(e.getTier){let T=await e.getTier(d);R=T.limit,l=T.windowSeconds??n;}let P=l*1e3,w=Ie(s,C,h),f;if(r==="fixed-window"?f=await $e(m,w,R,P):f=await je(m,w,R,P),b$1(d,"rateLimit",f),b$1(d,"rateLimitKey",w),i&&(d.header("X-RateLimit-Limit",String(f.limit)),d.header("X-RateLimit-Remaining",String(f.remaining)),d.header("X-RateLimit-Reset",String(f.resetAt))),!f.allowed)throw f.retryAfter&&d.header("Retry-After",String(f.retryAfter)),e.onRateLimitExceeded&&await e.onRateLimitExceeded(d,f,w),new U(c,f.retryAfter??60);await g();}}async function or(e,t){let n=t??_.get();if(!n)throw new Error("Rate limit storage not configured");await n.reset(e);}export{Le as A,Rt as B,W as C,qt as D,Kt as E,Ht as F,Mt as G,ke as H,Pe as I,F as J,zt as K,Ut as L,Vt as M,Xt as N,V as O,Me as P,Oe as Q,ht as R,yt as S,xt as T,Ct as U,Et as V,Ye as a,ee as b,te as c,Ze as d,ye as e,xe as f,re as g,Ce as h,D as i,Ee as j,Se as k,Re as l,U as m,q as n,ne as o,we as p,st as q,ve as r,Ie as s,tr as t,rr as u,nr as v,or as w,Te as x,K as y,be as z};
1
+ import {b as b$4}from'./chunk-NGUMNUOP.js';import {a as a$3}from'./chunk-GF2EC5G4.js';import {a,g}from'./chunk-2M5BM4VD.js';import {a as a$1,i}from'./chunk-FC56WWPB.js';import {b as b$3}from'./chunk-FJCWFB5L.js';import {b,c}from'./chunk-GBQQ3YQX.js';import {b as b$2}from'./chunk-DMGP7QDL.js';import {e,a as a$2,b as b$1}from'./chunk-VJRDAVID.js';function B(e,t={}){let{ipHeader:n="X-Forwarded-For",trustProxy:r=true}=t;if(r){let s=e.req.header(n);if(s){let c=s.split(",")[0]?.trim();if(c)return c}let a=e.req.header("X-Real-IP")?.trim();if(a)return a;let i=e.req.header("CF-Connecting-IP")?.trim();if(i)return i}let o=e.req.raw;if(o&&typeof o.socket=="object"&&o.socket?.remoteAddress)return o.socket.remoteAddress;if(o?.cf?.ip)return o.cf.ip}function $(e){return a$2(e,"userId")}function z(e,t){let n=e.toLowerCase();for(let r of t){if(r instanceof RegExp){if(r.test(e))return true;continue}let o=r.toLowerCase();if(o.includes("*")){let s=o.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");if(new RegExp(`^${s}$`).test(n))return true}else if(n===o)return true}return false}function j(e,t){if(e==null)return e;if(Array.isArray(e))return e.map(r=>j(r,t));if(typeof e!="object")return e;let n={};for(let[r,o]of Object.entries(e))z(r,t)?n[r]="[REDACTED]":typeof o=="object"&&o!==null?n[r]=j(o,t):n[r]=o;return n}function he(e,t){let n={};for(let[r,o]of Object.entries(e))n[r]=z(r,t)?"[REDACTED]":o;return n}function Ye(e,t){return z(e,t)}function ee(e,t){return j(e,t)}function te(e,t){return he(e,t)}function Ze(e,t){return a(e,t)}function ye(e,t,n){for(let r of n)if(a(e,r))return true;if(t.length===0)return false;for(let r of t)if(a(e,r))return false;return true}function xe(e,t="X-Forwarded-For",n=false){return B(e,{ipHeader:t,trustProxy:n||true})}function re(e){let t={};return e.forEach((n,r)=>{t[r.toLowerCase()]=n;}),t}function Ce(e){let t={};return new URL(e.req.url).searchParams.forEach((r,o)=>{t[o]=r;}),t}function D(e,t){if(typeof e=="string")return e.length>t?e.substring(0,t)+"... [TRUNCATED]":e;let n=JSON.stringify(e);return n.length>t?{_truncated:true,_originalSize:n.length,_maxSize:t}:e}function Ee(e,t){if(!e)return false;if(t.length===0)return true;let n=e.toLowerCase();for(let r of t)if(n.includes(r.toLowerCase()))return true;return false}function Se(e){return $(e)}function Re(){return e()}var U=class extends a$1{constructor(t="Too many requests",n=60){super(t,429,"RATE_LIMIT_EXCEEDED",{retryAfter:n}),this.name="RateLimitExceededException";}};function q(e,t="X-Forwarded-For",n=false){return B(e,{ipHeader:t,trustProxy:n})??"unknown"}function ne(e){return $(e)??null}function we(e,t="X-API-Key"){return e.req.header(t)||null}function st(e,t){return a(e,t)}function ve(e,t){return t.some(n=>a(e,n))}function Ie(e,...t){let n=t.filter(r=>r!==void 0&&r!=="");return `${e}:${n.join(":")}`}function V(e){return e instanceof Error?e:new Error(String(e))}function Me(e,t){let n=V(e),r=new Error(`${t}: ${n.message}`);return r.cause=n,r}function Oe(e){return e instanceof Error?e.message:String(e)}var X=b("loggingStorage");function ht(e){X.set(e);}function yt(){return X.get()}var De=["authorization","cookie","x-api-key","x-auth-token"],Fe=["password","token","secret","apiKey","api_key","accessToken","access_token","refreshToken","refresh_token","creditCard","credit_card","ssn","socialSecurityNumber"],_e=["/health","/healthz","/ready","/readyz","/live","/livez","/metrics","/favicon.ico"];function xt(e){return a$2(e,"requestId")}function Ct(e){return a$2(e,"requestStartTime")}function Et(e={}){let t=e.enabled??true,n=e.level??"info",r=e.includePaths??[],o=e.excludePaths??_e,s=e.redactHeaders??De,a=e.redactBodyFields??Fe,i=e.requestBody??{enabled:false},c=e.responseBody??{enabled:false},u=e.includeHeaders??true,d=e.includeQuery??true,g=e.includeClientIp??true,C=e.ipHeader??"X-Forwarded-For",m=e.trustProxy??false,h=e.minResponseTimeMs??0,R=e.generateRequestId??Re;return async(l,P)=>{if(!t)return P();let w=l.req.path;if(ye(w,r,o))return P();let f=R(),T=Date.now();b$1(l,"requestId",f),b$1(l,"requestStartTime",T),l.header("X-Request-ID",f);let Ae=l.req.method,qe=l.req.url,oe;if(u){let E=re(l.req.raw.headers);oe=te(E,s);}let se;d&&(se=Ce(l));let ae;g&&(ae=xe(l,C,m));let Ke=Se(l),Q;if(i.enabled){let E=l.req.header("content-type"),H=i.contentTypes??[];if(Ee(E,H))try{let L=await l.req.raw.clone().text();if(L)try{let x=JSON.parse(L);x=ee(x,a);let y=i.maxSize??10240;Q=D(x,y);}catch{let x=i.maxSize??10240;Q=D(L,x);}}catch{}}let S,Y;try{await P();}catch(E){throw S=E instanceof Error?E:new Error(String(E)),E}finally{let H=Date.now()-T;if(H<h)return;let b=l.res.status,L;if(u){let p=re(l.res.headers);L=te(p,s);}if(c.enabled&&!S){let p=c.statusCodes??[];if(p.length===0||p.includes(b))try{let Z=await l.res.clone().text();if(Z)try{let M=JSON.parse(Z);M=ee(M,a);let He=c.maxSize??10240;Y=D(M,He);}catch{let M=c.maxSize??10240;Y=D(Z,M);}}catch{}}let x=n;e.levelResolver?x=e.levelResolver(l,H,b,S):S||b>=500?x="error":b>=400&&(x="warn");let y={id:f,timestamp:new Date(T).toISOString(),level:x,request:{method:Ae,path:w,url:qe,headers:oe,query:se,body:Q,clientIp:ae,userId:Ke},response:{statusCode:b,headers:L,body:Y,responseTimeMs:H}};if(S&&(y.error={message:S.message,name:S.name,stack:S.stack}),e.metadata){let p=typeof e.metadata=="function"?e.metadata(l):e.metadata;y.metadata=p;}e.formatter&&(y=e.formatter(y));let ie=Pe(l,e.storage);(async()=>{if(ie)try{await ie.store(y);}catch(p){e.onError&&e.onError(p instanceof Error?p:new Error(String(p)),y);}if(e.handlers)for(let p of e.handlers)try{await p(y);}catch(v){e.onError&&e.onError(v instanceof Error?v:new Error(String(v)),y);}})().catch(p=>{let v=V(p);e.onError?e.onError(v,y):b$2().error("Failed to process log entry",{error:v.message});});}}}function Te(e){let{tableName:t,method:n,params:r,query:o,keyFields:s,userId:a,prefix:i}=e,c=[];if(i&&c.push(i),c.push(t),c.push(n),r&&Object.keys(r).length>0){let u=Object.keys(r).sort().map(d=>`${d}=${r[d]}`).join("&");c.push(u);}if(o&&Object.keys(o).length>0){let u=Object.keys(o).filter(d=>o[d]!==void 0&&o[d]!==null&&o[d]!=="");if(s&&s.length>0&&(u=u.filter(d=>s.includes(d))),u.length>0){let d=u.sort().map(g=>`${g}=${String(o[g])}`).join("&");c.push(d);}}return a&&c.push(`user=${a}`),c.join(":")}function K(e,t,n){let r=[];if(n&&r.push(n),r.push(e),!t)return r.push("*"),r.join(":");let{method:o,id:s,userId:a}=t;return o?(r.push(o),r.join(":")+"*"):(s!==void 0?(r.push("*"),r.push(`id=${s}*`)):a?(r.push("*"),r.push(`user=${a}`)):r.push("*"),r.join(":"))}function be(e,t,n){return t.map(r=>K(r,void 0,n))}function Le(e,t){let n=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*");return new RegExp(`^${n}$`).test(e)}function Rt(e){let t=e.split(":"),n=t.length>2&&!["GET","LIST"].includes(t[1]),r=0,o=n?t[r++]:void 0,s=t[r++],a=t[r++],i={tableName:s,method:a};o&&(i.prefix=o);for(let c=r;c<t.length;c++){let u=t[c];if(u.startsWith("user="))i.userId=u.substring(5);else if(u.includes("=")){let d=u.split("&"),g={};for(let C of d){let[m,h]=C.split("=");m&&h!==void 0&&(g[m]=h);}a==="GET"&&!i.params?i.params=g:a==="LIST"&&!i.query||i.params?i.query=g:i.params=g;}}return i}var W=class{storage=new Map;tagIndex=new Map;stats={hits:0,misses:0,size:0};defaultTtl;maxEntries;constructor(t){this.defaultTtl=t?.defaultTtl??300,this.maxEntries=t?.maxEntries??1e4;}async get(t){let n=this.storage.get(t);return n?n.expiresAt&&n.expiresAt<Date.now()?(await this.delete(t),this.stats.misses++,null):(this.stats.hits++,n):(this.stats.misses++,null)}async set(t,n,r){let o=r?.ttl??this.defaultTtl,s=r?.tags;this.maxEntries>0&&this.storage.size>=this.maxEntries&&!this.storage.has(t)&&this.evictOldest();let a=Date.now(),i={data:n,createdAt:a,expiresAt:o>0?a+o*1e3:null,tags:s},c=this.storage.get(t);if(c?.tags)for(let u of c.tags)this.tagIndex.get(u)?.delete(t);if(c&&this.storage.delete(t),this.storage.set(t,i),this.stats.size=this.storage.size,s)for(let u of s)this.tagIndex.has(u)||this.tagIndex.set(u,new Set),this.tagIndex.get(u).add(t);}async delete(t){let n=this.storage.get(t);if(!n)return false;if(n.tags)for(let r of n.tags)this.tagIndex.get(r)?.delete(t);return this.storage.delete(t),this.stats.size=this.storage.size,true}async deletePattern(t){let n=0,r=[];for(let o of this.storage.keys())Le(o,t)&&r.push(o);for(let o of r)await this.delete(o)&&n++;return n}async deleteByTag(t){let n=this.tagIndex.get(t);if(!n||n.size===0)return 0;let r=0,o=Array.from(n);for(let s of o)await this.delete(s)&&r++;return this.tagIndex.delete(t),r}async has(t){let n=this.storage.get(t);return n?n.expiresAt&&n.expiresAt<Date.now()?(await this.delete(t),false):true:false}async clear(){this.storage.clear(),this.tagIndex.clear(),this.stats.size=0;}getStats(){return {...this.stats}}resetStats(){this.stats.hits=0,this.stats.misses=0;}getKeys(){return Array.from(this.storage.keys())}getTags(){return Array.from(this.tagIndex.keys())}evictOldest(){let t=this.storage.keys().next().value;t!==void 0&&this.delete(t).catch(()=>{});}async cleanup(){let t=Date.now(),n=0,r=[];for(let[o,s]of this.storage.entries())s.expiresAt&&s.expiresAt<t&&r.push(o);for(let o of r)await this.delete(o),n++;return n}};function G(e){let n=e._meta?.model?.tableName;if(!n)throw new i("Cache mixin requires `_meta.model.tableName`. Declare `_meta` on the endpoint or remove the cache mixin.");return n}var J=c("cacheStorage",()=>new W);function qt(e){J.set(e);}function Kt(){return J.getRequired()}function Ht(e){class t extends e{cacheConfig;getCacheConfig(){return {enabled:true,ttl:300,perUser:false,...this.cacheConfig}}async generateCacheKey(){let r=this.getCacheConfig(),o=this.getContext(),s=G(this),a=await this.getValidatedData(),i=a.params,c=a.query,u=i&&Object.keys(i).length>0?"GET":"LIST",d;return r.perUser&&(d=o.var?.userId),Te({tableName:s,method:u,params:i,query:c,keyFields:r.keyFields,userId:d,prefix:r.prefix})}_cacheHit=false;async getCachedResponse(){if(!this.getCacheConfig().enabled)return this._cacheHit=false,null;let o=await this.generateCacheKey(),s=this.getContext(),a=F(s);if(!a)return this._cacheHit=false,null;let i=await a.get(o);return this._cacheHit=i!==null,i?.data??null}getCacheStatus(){return this._cacheHit?"HIT":"MISS"}successWithCache(r,o=200){return new Response(JSON.stringify({success:true,result:r}),{status:o,headers:{"Content-Type":"application/json","X-Cache":this.getCacheStatus()}})}jsonWithCache(r,o=200){return new Response(JSON.stringify(r),{status:o,headers:{"Content-Type":"application/json","X-Cache":this.getCacheStatus()}})}async setCachedResponse(r){let o=this.getCacheConfig();if(!o.enabled)return;let s=await this.generateCacheKey(),a=this.getContext(),i=F(a);if(!i)return;let c=o.tags?[...o.tags]:[],u=this._meta;u?.model?.tableName&&c.push(u.model.tableName),await i.set(s,r,{ttl:o.ttl,tags:c.length>0?c:void 0});}async invalidateCache(r){let o=this.getContext(),s=F(o);if(!s)return;let a=this.getCacheConfig();if(r?.pattern)await s.deletePattern(r.pattern);else if(r?.tags&&s.deleteByTag)for(let i of r.tags)await s.deleteByTag(i);else {let i=G(this),c=K(i,void 0,a.prefix);await s.deletePattern(c);}}}return t}function Mt(e){class t extends e{cacheInvalidation;getCacheInvalidationConfig(){return {strategy:"all",...this.cacheInvalidation}}async performCacheInvalidation(r){let o=this.getCacheInvalidationConfig(),s=this.getContext(),a=F(s);if(!a)return;let i=G(this);switch(o.strategy??"all"){case "single":if(r!==void 0){let g=K(i,{id:r});await a.deletePattern(g);}break;case "list":let u=K(i,{method:"LIST"});await a.deletePattern(u);break;case "all":let d=K(i);await a.deletePattern(d);break;case "pattern":o.pattern&&await a.deletePattern(o.pattern);break;case "tags":if(o.tags&&a.deleteByTag)for(let g of o.tags)await a.deleteByTag(g);break}if(o.relatedModels&&o.relatedModels.length>0){let u=be(i,o.relatedModels);for(let d of u)await a.deletePattern(d);}}async handle(){let r=await super.handle();if(r.status>=200&&r.status<300){let o;try{o=(await r.clone().json())?.result?.id;}catch{}let s=G(this);this.performCacheInvalidation(o).catch(a=>{b$2().error("Cache invalidation failed",{error:a instanceof Error?a.message:String(a),tableName:s,recordId:o});});}return r}}return t}function ke(e,t){return _.resolve(e,t)}function Pe(e,t){return X.resolve(e,t)}function F(e,t){return J.resolve(e,t)}function zt(e,t){return b$3.resolve(e,t)}function Ut(e,t){return b$4.resolve(e,t)}function Vt(e,t){return g.resolve(e,t)}function Xt(e,t){return a$3.resolve(e,t)}var _=b("rateLimitStorage");function tr(e){_.set(e);}function rr(){return _.get()}function Ne(){return {ip:e=>t=>q(t,e.ipHeader,e.trustProxy),user:e=>t=>{let n=ne(t);return n?`user:${n}`:q(t,e.ipHeader,e.trustProxy)},"api-key":e=>t=>{let n=we(t,e.apiKeyHeader);return n?`apikey:${n.substring(0,8)}`:q(t,e.ipHeader,e.trustProxy)},combined:e=>t=>{let n=q(t,e.ipHeader,e.trustProxy),r=ne(t);return r?`${n}:user:${r}`:n}}}function Be(e,t){if(typeof e=="function")return e;let r=Ne()[e];return r?r(t):o=>q(o,t.ipHeader,t.trustProxy)}async function $e(e,t,n,r){let o=await e.increment(t,r),s=Math.ceil((o.windowStart+r)/1e3),a=Math.max(0,n-o.count),i=o.count<=n;return {allowed:i,limit:n,remaining:a,resetAt:s,retryAfter:i?void 0:Math.ceil((o.windowStart+r-Date.now())/1e3)}}async function je(e,t,n,r){let o=Date.now(),s=await e.addTimestamp(t,r,o),a=s.timestamps.length,i=Math.max(0,n-a),c=a<=n,u=s.timestamps.length>0?Math.min(...s.timestamps):o,d=Math.ceil((u+r)/1e3),g;if(!c&&s.timestamps.length>0){let C=[...s.timestamps].sort((h,R)=>h-R),m=a-n;if(m>0&&C.length>=m){let h=C[m-1];g=Math.max(1,Math.ceil((h+r-o)/1e3));}}return {allowed:c,limit:n,remaining:i,resetAt:d,retryAfter:g}}function nr(e={}){let t=e.limit??100,n=e.windowSeconds??60,r=e.algorithm??"sliding-window",o=e.keyStrategy??"ip",s=e.keyPrefix??"rl",a=e.skipPaths??[],i=e.includeHeaders??true,c=e.errorMessage??"Too many requests",u=Be(o,e);return async(d,g)=>{let C=d.req.path;if(a.length>0&&ve(C,a))return g();let m=ke(d,e.storage);if(!m)return b$2().warn("Rate limit storage not configured. Skipping rate limiting."),g();let h=u(d);if(!h)return g();let R=t,l=n;if(e.getTier){let T=await e.getTier(d);R=T.limit,l=T.windowSeconds??n;}let P=l*1e3,w=Ie(s,C,h),f;if(r==="fixed-window"?f=await $e(m,w,R,P):f=await je(m,w,R,P),b$1(d,"rateLimit",f),b$1(d,"rateLimitKey",w),i&&(d.header("X-RateLimit-Limit",String(f.limit)),d.header("X-RateLimit-Remaining",String(f.remaining)),d.header("X-RateLimit-Reset",String(f.resetAt))),!f.allowed)throw f.retryAfter&&d.header("Retry-After",String(f.retryAfter)),e.onRateLimitExceeded&&await e.onRateLimitExceeded(d,f,w),new U(c,f.retryAfter??60);await g();}}async function or(e,t){let n=t??_.get();if(!n)throw new Error("Rate limit storage not configured");await n.reset(e);}export{Le as A,Rt as B,W as C,qt as D,Kt as E,Ht as F,Mt as G,ke as H,Pe as I,F as J,zt as K,Ut as L,Vt as M,Xt as N,V as O,Me as P,Oe as Q,ht as R,yt as S,xt as T,Ct as U,Et as V,Ye as a,ee as b,te as c,Ze as d,ye as e,xe as f,re as g,Ce as h,D as i,Ee as j,Se as k,Re as l,U as m,q as n,ne as o,we as p,st as q,ve as r,Ie as s,tr as t,rr as u,nr as v,or as w,Te as x,K as y,be as z};
@@ -0,0 +1,4 @@
1
+ import {t,u,v,w,x,z as z$1,B as B$1,C,D as D$1,E,A as A$1,F as F$1,G,H as H$1,I as I$1,J as J$1,K as K$1,L as L$1,T,U as U$1,ba,ca,y}from'./chunk-ZBCVLQ3W.js';import {b as b$1}from'./chunk-DMGP7QDL.js';import {getTableColumns,eq,inArray,between,isNull,isNotNull,ilike,like,notInArray,lte,lt,gte,gt as gt$1,ne as ne$1,and,sql,or,desc,asc}from'drizzle-orm';import {z}from'zod';function X(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 b(l,e){let n=getTableColumns(l),o=n[e];if(!o)throw new Error(`Column '${e}' not found in table. Available columns: ${Object.keys(n).join(", ")}`);return o}async function Pe(l,e,n,o){if(!o.table)return e;let t=o.table;switch(o.type){case "hasOne":{let r=o.localKey||"id",s=e[r];if(s==null)return e;let i=b(t,o.foreignKey),a=await l.select().from(t).where(eq(i,s)).limit(1);return {...e,[n]:a[0]||null}}case "hasMany":{let r=o.localKey||"id",s=e[r];if(s==null)return {...e,[n]:[]};let i=b(t,o.foreignKey),a=await l.select().from(t).where(eq(i,s));return {...e,[n]:a}}case "belongsTo":{let r=e[o.foreignKey];if(r==null)return {...e,[n]:null};let s=b(t,o.localKey||"id"),i=await l.select().from(t).where(eq(s,r)).limit(1);return {...e,[n]:i[0]||null}}default:return e}}async function de(l,e,n,o){if(!o?.relations?.length||!n.model.relations)return e;let t={...e};for(let r of o.relations){let s=n.model.relations[r];s&&(t=await Pe(l,t,r,s));}return t}async function j(l,e,n,o){if(!e.length||!o?.relations?.length||!n.model.relations)return e;let t=e.map(r=>({...r}));for(let r of o.relations){let s=n.model.relations[r];if(!s||!s.table)continue;let i=s.table;switch(s.type){case "hasOne":case "hasMany":{let a=s.localKey||"id",d=[...new Set(t.map(p=>p[a]).filter(p=>p!=null))];if(d.length===0){t=t.map(p=>({...p,[r]:s.type==="hasMany"?[]:null}));continue}let u=b(i,s.foreignKey),c=await l.select().from(i).where(inArray(u,d)),m=new Map;for(let p of c){let g=p[s.foreignKey];m.has(g)||m.set(g,[]),m.get(g).push(p);}t=t.map(p=>{let g=p[a],h=m.get(g)||[];return {...p,[r]:s.type==="hasMany"?h:h[0]||null}});break}case "belongsTo":{let a=s.localKey||"id",d=[...new Set(t.map(p=>p[s.foreignKey]).filter(p=>p!=null))];if(d.length===0){t=t.map(p=>({...p,[r]:null}));continue}let u=b(i,a),c=await l.select().from(i).where(inArray(u,d)),m=new Map;for(let p of c){let g=p[a];m.set(g,p);}t=t.map(p=>{let g=p[s.foreignKey];return {...p,[r]:m.get(g)||null}});break}}}return t}function O(l,e){let n=b(l,e.field);switch(e.operator){case "eq":return eq(n,e.value);case "ne":return ne$1(n,e.value);case "gt":return gt$1(n,e.value);case "gte":return gte(n,e.value);case "lt":return lt(n,e.value);case "lte":return lte(n,e.value);case "in":return inArray(n,e.value);case "nin":return notInArray(n,e.value);case "like":return like(n,e.value);case "ilike":return ilike(n,e.value);case "null":return e.value?isNull(n):isNotNull(n);case "between":{let[o,t]=e.value;return between(n,o,t)}default:return}}function D(l){let e=l;if(e._tx)return e._tx;if(e.db)return e.db;let n=e.context?.get?.("db");if(n)return n;throw new Error(`Database not configured. Either:
2
+ 1. Set db property: db = myDb;
3
+ 2. Use middleware: c.set("db", myDb);
4
+ 3. Use factory: createDrizzleCrud(db, meta)`)}var _=class extends t{db;useTransaction=false;getDb(){return D(this)}getTable(){return f(this._meta)}getRelatedTable(e){return e.table}async create(e,n){let o=n??this.getDb(),t=this.getTable(),r=this.applyManagedInsertFields(e,"drizzle");return (await o.insert(t).values(r).returning())[0]}async createNested(e,n,o,t,r){let s=r??this.getDb(),i=this.getRelatedTable(o);if(!i)return b$1().warn(`Related table not found for ${n}. Add 'table' to the relation config.`),[];let a=Array.isArray(t)?t:[t],d=[];for(let u of a){if(typeof u!="object"||u===null)continue;let c={...u,id:crypto.randomUUID(),[o.foreignKey]:e},m=await s.insert(i).values(c).returning();m[0]&&d.push(m[0]);}return d}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()}},I=class extends u{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async read(e,n,o){let t=this.getTable(),r=this.getColumn(this.lookupField),s=this.getSoftDeleteConfig(),i=[eq(r,e)];if(n)for(let[u,c]of Object.entries(n))i.push(eq(this.getColumn(u),c));s.enabled&&i.push(isNull(this.getColumn(s.field)));let a=await this.getDb().select().from(t).where(and(...i)).limit(1);return a[0]?await de(this.getDb(),a[0],this._meta,o):null}},P=class extends v{db;useTransaction=false;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}getRelatedTable(e){return e.table}async findExisting(e,n,o){let t=o??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),i=this.getSoftDeleteConfig(),a=[eq(s,e)];if(n)for(let[u,c]of Object.entries(n))a.push(eq(this.getColumn(u),c));return i.enabled&&a.push(isNull(this.getColumn(i.field))),(await t.select().from(r).where(and(...a)).limit(1))[0]||null}async update(e,n,o,t){let r=t??this.getDb(),s=this.getTable(),i=this.getColumn(this.lookupField),a=this.getSoftDeleteConfig(),d=[eq(i,e)];if(o)for(let[c,m]of Object.entries(o))d.push(eq(this.getColumn(c),m));return a.enabled&&d.push(isNull(this.getColumn(a.field))),(await r.update(s).set(this.applyManagedUpdateFields(n)).where(and(...d)).returning())[0]||null}async processNestedWrites(e,n,o,t,r){let s=r??this.getDb(),i=this.getRelatedTable(o);if(!i)return b$1().warn(`Related table not found for ${n}. Add 'table' to the relation config.`),{created:[],updated:[],deleted:[],connected:[],disconnected:[]};let a={created:[],updated:[],deleted:[],connected:[],disconnected:[]},d=b(i,o.foreignKey),u=b(i,"id");if(t.create){let c=Array.isArray(t.create)?t.create:[t.create];for(let m of c){if(typeof m!="object"||m===null)continue;let p={...m,id:crypto.randomUUID(),[o.foreignKey]:e},g=await s.insert(i).values(p).returning();g[0]&&a.created.push(g[0]);}}if(t.update)for(let c of t.update){if(!c.id||!(await s.select().from(i).where(and(eq(u,c.id),eq(d,e))).limit(1))[0])continue;let{id:p,...g}=c,h=await s.update(i).set(g).where(eq(u,p)).returning();h[0]&&a.updated.push(h[0]);}if(t.delete)for(let c of t.delete)(await s.delete(i).where(and(eq(u,c),eq(d,e))).returning())[0]&&a.deleted.push(c);if(t.connect)for(let c of t.connect)(await s.update(i).set({[o.foreignKey]:e}).where(eq(u,c)).returning())[0]&&a.connected.push(c);if(t.disconnect)for(let c of t.disconnect)(await s.update(i).set({[o.foreignKey]:null}).where(and(eq(u,c),eq(d,e))).returning())[0]&&a.disconnected.push(c);return a}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 w{db;useTransaction=false;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}getRelatedTable(e){return e.table}async findForDelete(e,n,o){let t=o??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),i=this.getSoftDeleteConfig(),a=[eq(s,e)];if(n)for(let[u,c]of Object.entries(n))a.push(eq(this.getColumn(u),c));return i.enabled&&a.push(isNull(this.getColumn(i.field))),(await t.select().from(r).where(and(...a)).limit(1))[0]||null}async delete(e,n,o){let t=o??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),i=this.getSoftDeleteConfig(),a=[eq(s,e)];if(n)for(let[d,u]of Object.entries(n))a.push(eq(this.getColumn(d),u));return i.enabled&&a.push(isNull(this.getColumn(i.field))),i.enabled?(await t.update(r).set({[i.field]:new Date}).where(and(...a)).returning())[0]||null:(await t.delete(r).where(and(...a)).returning())[0]||null}async countRelated(e,n,o,t){let r=t??this.getDb(),s=this.getRelatedTable(o);if(!s)return 0;let i=b(s,o.foreignKey),a=await r.select({count:sql`count(*)`}).from(s).where(eq(i,e));return Number(a[0]?.count)||0}async deleteRelated(e,n,o,t){let r=t??this.getDb(),s=this.getRelatedTable(o);if(!s)return 0;let i=b(s,o.foreignKey);return (await r.delete(s).where(eq(i,e)).returning()).length}async nullifyRelated(e,n,o,t){let r=t??this.getDb(),s=this.getRelatedTable(o);if(!s)return 0;let i=b(s,o.foreignKey);return (await r.update(s).set({[o.foreignKey]:null}).where(eq(i,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()}},B=class extends x{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async list(e){let n=this.getTable(),o=[],t=this.getSoftDeleteConfig();if(t.enabled){let y=this.getColumn(t.field);e.options.onlyDeleted?o.push(isNotNull(y)):e.options.withDeleted||o.push(isNull(y));}for(let y of e.filters){let R=O(n,y);R&&o.push(R);}if(e.options.search&&this.searchFields.length>0){let y=this.searchFields.map(R=>{let q=this.getColumn(R);return sql`LOWER(${q}) LIKE LOWER(${`%${e.options.search}%`})`});o.push(or(...y));}let r=o.length>0?and(...o):void 0,s=this.getDb(),i=await s.select({count:sql`count(*)`}).from(n).where(r),a=Number(i[0]?.count)||0,d=s.select().from(n).where(r);if(e.options.order_by){let y=this.getColumn(e.options.order_by),R=e.options.order_by_direction==="desc"?desc:asc;d=d.orderBy(R(y));}let u=e.options.page||1,c=e.options.per_page||this.defaultPerPage;d=d.limit(c).offset((u-1)*c);let m=await d,p={relations:e.options.include||[]},g=await j(this.getDb(),m,this._meta,p),h=Math.ceil(a/c);return {result:g,result_info:{page:u,per_page:c,total_count:a,total_pages:h,has_next_page:u<h,has_prev_page:u>1}}}},A=class extends z$1{db;useTransaction=false;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async restore(e,n,o){let t=o??this.getDb(),r=this.getTable(),s=this.getColumn(this.lookupField),i=this.getSoftDeleteConfig(),a=[eq(s,e)];if(n)for(let[u,c]of Object.entries(n))a.push(eq(this.getColumn(u),c));return a.push(isNotNull(this.getColumn(i.field))),(await t.update(r).set({[i.field]:null}).where(and(...a)).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 L=class extends B$1{db;getDb(){return D(this)}getTable(){return f(this._meta)}async batchCreate(e){let n=this.getTable(),o=e.map(r=>this.applyManagedInsertFields(r,"drizzle"));return await this.getDb().insert(n).values(o).returning()}},K=class extends C{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async batchUpdate(e){let n=this.getTable(),o=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[],s=[];for(let i of e){let a=[eq(o,i.id)];t.enabled&&a.push(isNull(this.getColumn(t.field)));let d=await this.getDb().update(n).set(this.applyManagedUpdateFields(i.data)).where(and(...a)).returning();d[0]?r.push(d[0]):s.push(i.id);}return {updated:r,notFound:s}}},Z=class extends D$1{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async batchDelete(e){let n=this.getTable(),o=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[inArray(o,e)];t.enabled&&r.push(isNull(this.getColumn(t.field)));let s;t.enabled?s=await this.getDb().update(n).set({[t.field]:new Date}).where(and(...r)).returning():s=await this.getDb().delete(n).where(and(...r)).returning();let i=s,a=new Set(i.map(u=>String(u[this.lookupField]))),d=e.filter(u=>!a.has(u));return {deleted:i,notFound:d}}},F=class extends E{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async batchRestore(e){let n=this.getTable(),o=this.getColumn(this.lookupField),t=this.getSoftDeleteConfig(),r=[inArray(o,e),isNotNull(this.getColumn(t.field))],i=await this.getDb().update(n).set({[t.field]:null}).where(and(...r)).returning(),a=new Set(i.map(u=>String(u[this.lookupField]))),d=e.filter(u=>!a.has(u));return {restored:i,notFound:d}}};function $e(l){return l.replace(/\\/g,"\\\\").replace(/%/g,"\\%").replace(/_/g,"\\_")}function gt(l){return l.split(/\s+/).filter(e=>e.length>0)}var Q=class extends A$1{db;dialect="sqlite";getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async findExisting(e){let n=this.getTable(),o=this.getUpsertKeys(),t=this.getSoftDeleteConfig(),r=[];for(let i of o){let a=e[i];a!==void 0&&r.push(eq(this.getColumn(i),a));}return t.enabled&&r.push(isNull(this.getColumn(t.field))),r.length===0?null:(await this.getDb().select().from(n).where(and(...r)).limit(1))[0]||null}async create(e){let n=this.getTable(),o=this.applyManagedInsertFields(e,"drizzle");return (await this.getDb().insert(n).values(o).returning())[0]}async update(e,n){let o=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(o).set(this.applyManagedUpdateFields(n)).where(eq(this.getColumn(t),r)).returning())[0]}async nativeUpsert(e,n){let o=this.getTable(),t=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s=this.getSoftDeleteConfig(),i=this.getTimestampsConfig(),a=this.applyManagedInsertFields(e,"drizzle"),d={};for(let[h,y]of Object.entries(e))!t.includes(h)&&h!==r&&(this.createOnlyFields?.includes(h)||(d[h]=y));i.enabled&&(d[i.updatedAt]=Date.now());let u=t.map(h=>this.getColumn(h)),c;s.enabled&&(c=isNull(this.getColumn(s.field)));let m=Object.keys(d).length>0?d:{[r]:sql`${this.getColumn(r)}`},p=this.getDb().insert(o).values(a);return this.dialect==="mysql"?{data:(await p.onDuplicateKeyUpdate({set:m}).returning())[0],created:false}:{data:(await p.onConflictDoUpdate({target:u,set:m,where:c}).returning())[0],created:false}}},N=class extends F$1{db;dialect="sqlite";getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async findExisting(e){let n=this.getTable(),o=this.getUpsertKeys(),t=[];for(let s of o){let i=e[s];i!==void 0&&t.push(eq(this.getColumn(s),i));}return t.length===0?null:(await this.getDb().select().from(n).where(and(...t)).limit(1))[0]||null}async create(e){let n=this.getTable(),o=this.applyManagedInsertFields(e,"drizzle");return (await this.getDb().insert(n).values(o).returning())[0]}async update(e,n){let o=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(o).set(this.applyManagedUpdateFields(n)).where(eq(this.getColumn(t),r)).returning())[0]}async nativeBatchUpsert(e,n){if(e.length===0)return {items:[],createdCount:0,updatedCount:0,totalCount:0};let o=this.getTable(),t=this.getUpsertKeys(),r=this._meta.model.primaryKeys[0],s=this.getTimestampsConfig(),i=e.map(g=>this.applyManagedInsertFields(g,"drizzle")),a={},d=e[0];for(let g of Object.keys(d))!t.includes(g)&&g!==r&&(this.createOnlyFields?.includes(g)||(a[g]=sql`excluded.${sql.identifier(g)}`));s.enabled&&(a[s.updatedAt]=Date.now());let u=t.map(g=>this.getColumn(g)),c=Object.keys(a).length>0?a:{[r]:sql`${this.getColumn(r)}`},m=this.getDb().insert(o).values(i),p=await(this.dialect==="mysql"?m.onDuplicateKeyUpdate({set:c}):m.onConflictDoUpdate({target:u,set:c})).returning();return {items:p.map((g,h)=>({data:g,created:false,index:h})),createdCount:0,updatedCount:p.length,totalCount:p.length}}},Le=class extends G{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async recordExists(e){let n=this.getTable(),o=await this.getDb().select({count:sql`count(*)`}).from(n).where(eq(this.getColumn("id"),e));return Number(o[0]?.count)>0}},Ke=class extends H$1{},Ze=class extends I$1{},Fe=class extends J$1{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async rollback(e,n,o){let t=this.getTable(),r=this.getVersioningConfig().field;return (await this.getDb().update(t).set({...n,[r]:o}).where(eq(this.getColumn("id"),e)).returning())[0]}},H=class extends K$1{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async aggregate(e){let n=this.getTable(),o=[],t=this.getSoftDeleteConfig();if(t.enabled){let{query:i}=await this.getValidatedData();i?.withDeleted===true||i?.withDeleted==="true"||o.push(isNull(this.getColumn(t.field)));}if(e.filters)for(let[i,a]of Object.entries(e.filters))if(typeof a=="object"&&a!==null)for(let[d,u]of Object.entries(a)){let c=O(n,{field:i,operator:d,value:u});c&&o.push(c);}else o.push(eq(this.getColumn(i),a));let r=o.length>0?and(...o):void 0,s=await this.getDb().select().from(n).where(r);return L$1(s,e)}},J=class extends T{db;getDb(){return D(this)}useNativeSearch=false;vectorColumn;vectorConfig="english";getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async search(e,n){let o=this.getTable(),t=[],r=this.getSoftDeleteConfig();r.enabled&&(n.options.onlyDeleted?t.push(isNotNull(this.getColumn(r.field))):n.options.withDeleted||t.push(isNull(this.getColumn(r.field))));for(let w of n.filters){let M=O(o,w);M&&t.push(M);}let s=this.getSearchableFields(),i=e.fields||Object.keys(s);if(this.useNativeSearch&&this.vectorColumn){let w=this.getColumn(this.vectorColumn),M=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} @@ ${M}`);}else {let w=(M,x)=>{try{let se=this.getColumn(M),W=`%${$e(x)}%`;return sql`LOWER(CAST(${se} AS TEXT)) LIKE LOWER(${W}) ESCAPE '\\'`}catch{return}};if(e.mode==="all"){let M=gt(e.query);if(M.length>0){let x=[];for(let se of M){let W=i.map(ie=>w(ie,se)).filter(ie=>ie!==void 0);W.length>0&&x.push(or(...W));}x.length>0&&t.push(and(...x));}}else {let M=i.map(x=>w(x,e.query)).filter(x=>x!==void 0);M.length>0&&t.push(or(...M));}}let a=t.length>0?and(...t):void 0,d=await this.getDb().select({count:sql`count(*)`}).from(o).where(a),u=Number(d[0]?.count)||0,c=this.getDb().select().from(o).where(a);if(n.options.order_by){let w=this.getColumn(n.options.order_by),M=n.options.order_by_direction==="desc"?desc:asc;c=c.orderBy(M(w));}let m=n.options.page||1,p=n.options.per_page||this.defaultPerPage;c=c.limit(p).offset((m-1)*p);let g=await c,h=e.mode==="all"?{...e,mode:"any"}:e,y=U$1(g,h,s),R={relations:n.options.include||[]},q=y.map(w=>w.item),Xe=await j(this.getDb(),q,this._meta,R);return {items:y.map((w,M)=>({...w,item:Xe[M]})),totalCount:u}}},Y=class extends ba{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async list(e){let n=this.getTable(),o=[],t=this.getSoftDeleteConfig();if(t.enabled){let h=this.getColumn(t.field);e.options.onlyDeleted?o.push(isNotNull(h)):e.options.withDeleted||o.push(isNull(h));}for(let h of e.filters){let y=O(n,h);y&&o.push(y);}if(e.options.search&&this.searchFields.length>0){let h=`%${$e(e.options.search)}%`,y=this.searchFields.map(R=>{let q=this.getColumn(R);return sql`LOWER(${q}) LIKE LOWER(${h}) ESCAPE '\\'`});o.push(or(...y));}let r=o.length>0?and(...o):void 0,s=await this.getDb().select({count:sql`count(*)`}).from(n).where(r),i=Number(s[0]?.count)||0,a=this.getDb().select().from(n).where(r);if(e.options.order_by){let h=this.getColumn(e.options.order_by),y=e.options.order_by_direction==="desc"?desc:asc;a=a.orderBy(y(h));}let d=e.options.page||1,u=e.options.per_page||this.defaultPerPage;a=a.limit(u).offset((d-1)*u);let c=await a,m={relations:e.options.include||[]},p=await j(this.getDb(),c,this._meta,m),g=Math.ceil(i/u);return {result:p,result_info:{page:d,per_page:u,total_count:i,total_pages:g,has_next_page:d<g,has_prev_page:d>1}}}},ee=class extends ca{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}async findExisting(e){let n=this.getTable(),o=this.getUpsertKeys(),t=this.getSoftDeleteConfig(),r=[];for(let i of o){let a=e[i];a!==void 0&&r.push(eq(this.getColumn(i),a));}return t.enabled&&r.push(isNull(this.getColumn(t.field))),r.length===0?null:(await this.getDb().select().from(n).where(and(...r)).limit(1))[0]||null}async create(e){let n=this.getTable(),o=this.applyManagedInsertFields(e,"drizzle");return (await this.getDb().insert(n).values(o).returning())[0]}async update(e,n){let o=this.getTable(),t=this._meta.model.primaryKeys[0],r=e[t];return (await this.getDb().update(o).set(this.applyManagedUpdateFields(n)).where(eq(this.getColumn(t),r)).returning())[0]}},te=class extends y{db;getDb(){return D(this)}getTable(){return f(this._meta)}getColumn(e){return b(this.getTable(),e)}generateId(){return crypto.randomUUID()}async findSource(e,n){let o=this.getTable(),t=this.getColumn(this.lookupField),r=this.getSoftDeleteConfig(),s=[eq(t,e)];if(n)for(let[a,d]of Object.entries(n))s.push(eq(this.getColumn(a),d));r.enabled&&s.push(isNull(this.getColumn(r.field)));let i=await this.getDb().select().from(o).where(and(...s)).limit(1);return i[0]?i[0]:null}async createClone(e){let n=this.getTable(),o=this.applyManagedInsertFields(e,"drizzle",()=>this.generateId());return (await this.getDb().insert(n).values(o).returning())[0]}};function an(l,e,n){let o=n?.dialect??"sqlite";return {Create:class extends _{_meta=e;db=l},Read:class extends I{_meta=e;db=l},Update:class extends P{_meta=e;db=l},Delete:class extends U{_meta=e;db=l},List:class extends B{_meta=e;db=l},Restore:class extends A{_meta=e;db=l},Upsert:class extends Q{_meta=e;db=l;dialect=o},BatchCreate:class extends L{_meta=e;db=l},BatchUpdate:class extends K{_meta=e;db=l},BatchDelete:class extends Z{_meta=e;db=l},BatchRestore:class extends F{_meta=e;db=l},BatchUpsert:class extends N{_meta=e;db=l;dialect=o}}}var oe=null,We=false,ne=null;async function re(){if(We){if(ne)throw ne;return oe}We=true;try{return oe=await import('drizzle-zod'),oe}catch{throw ne=new Error("drizzle-zod is not installed. Please install it: npm install drizzle-zod"),ne}}async function mt(l,e){return (await re()).createSelectSchema(l,e)}async function bt(l,e){return (await re()).createInsertSchema(l,e)}async function ht(l,e){let n=await re();return n.createUpdateSchema?n.createUpdateSchema(l,e):n.createInsertSchema(l,e).partial()}async function ft(l,e){let n=await re(),o=e?.coerceDates!==false,t=o?Mt(l):new Set,r=n.createSelectSchema(l,e?.selectRefine),s=n.createInsertSchema(l,e?.insertRefine),i;return n.createUpdateSchema?i=n.createUpdateSchema(l,e?.updateRefine):i=n.createInsertSchema(l,e?.updateRefine).partial(),o&&t.size>0&&(s=Ve(s,t),i=Ve(i,t)),{select:r,insert:s,update:i}}function zt(){return oe!==null}var Dt=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()),yt=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 Mt(l){let e=new Set,n=l;for(let[o,t]of Object.entries(n)){if(o==="_"||o==="$inferInsert"||o==="$inferSelect")continue;let r=t;if(!r||typeof r!="object")continue;let s=String(r.dataType??"").toLowerCase(),i=String(r.columnType??"").toLowerCase(),a=r.config,d=String(a?.dataType??"").toLowerCase();(s.includes("timestamp")||s.includes("date")||s.includes("datetime")||i.includes("pgtimestamp")||i.includes("pgdate")||i.includes("mysqltimestamp")||i.includes("mysqldate")||i.includes("sqlitetimestamp")||d.includes("timestamp")||d.includes("date"))&&e.add(o);}return e}function Ve(l,e){if(e.size===0)return l;let n=l.shape,o={};for(let[t,r]of Object.entries(n))if(e.has(t)){let s=r.isOptional?.()??false,i=r.isNullable?.()??false,a=Dt;(i||s)&&(a=yt),s&&(a=a.optional()),o[t]=a;}else o[t]=r;return z.object(o)}var Rn={CreateEndpoint:_,ListEndpoint:B,ReadEndpoint:I,UpdateEndpoint:P,DeleteEndpoint:U,RestoreEndpoint:A,BatchCreateEndpoint:L,BatchUpdateEndpoint:K,BatchDeleteEndpoint:Z,BatchRestoreEndpoint:F,BatchUpsertEndpoint:N,SearchEndpoint:J,AggregateEndpoint:H,ExportEndpoint:Y,ImportEndpoint:ee,UpsertEndpoint:Q,CloneEndpoint:te};export{ee as A,te as B,an as C,mt as D,bt as E,ht as F,ft as G,zt as H,Rn as I,X as a,f as b,b as c,Pe as d,de as e,j as f,O as g,_ as h,I as i,P as j,U as k,B as l,A as m,L as n,K as o,Z as p,F as q,Q as r,N as s,Le as t,Ke as u,Ze as v,Fe as w,H as x,J as y,Y as z};