arkormx 2.5.4 → 2.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
- import { Kysely, Transaction } from "kysely";
2
- import { PrismaClient } from "@prisma/client";
3
1
  import { Collection } from "@h3ravel/collect.js";
2
+ import { Kysely, Transaction } from "kysely";
4
3
  import { Command } from "@h3ravel/musket";
4
+ import { PrismaClient } from "@prisma/client";
5
5
 
6
6
  //#region src/types/migrations.d.ts
7
7
  type SchemaColumnType = 'id' | 'uuid' | 'enum' | 'string' | 'text' | 'integer' | 'bigInteger' | 'float' | 'boolean' | 'json' | 'date' | 'timestamp';
@@ -470,6 +470,136 @@ declare abstract class Relation<TModel> {
470
470
  whereDate<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Date | string): this;
471
471
  whereMonth<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, month: number, year?: number): this;
472
472
  whereYear<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, year: number): this;
473
+ /**
474
+ * Adds a time clause for a date-like key.
475
+ *
476
+ * @param key
477
+ * @param value
478
+ * @returns
479
+ */
480
+ whereTime<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Date | string): this;
481
+ /**
482
+ * Adds a time clause for a date-like key.
483
+ *
484
+ * @param key
485
+ * @param operator
486
+ * @param value
487
+ * @returns
488
+ */
489
+ whereTime<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, operator: QueryScalarComparisonOperator, value: Date | string): this;
490
+ /**
491
+ * Adds a day clause for a date-like key.
492
+ *
493
+ * @param key
494
+ * @param day
495
+ * @returns
496
+ */
497
+ whereDay<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, day: number): this;
498
+ /**
499
+ * Adds a day clause for a date-like key.
500
+ *
501
+ * @param key
502
+ * @param operator
503
+ * @param day
504
+ * @returns
505
+ */
506
+ whereDay<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, operator: QueryScalarComparisonOperator, day: number): this;
507
+ /**
508
+ * Adds clause to determine if a column's value is in the past
509
+ *
510
+ * @param key
511
+ * @returns
512
+ */
513
+ wherePast<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
514
+ /**
515
+ * Adds clause to determine if a column's value is in the future
516
+ *
517
+ * @param key
518
+ * @returns
519
+ */
520
+ whereFuture<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
521
+ /**
522
+ * Adds clause to determine if a column's value is in the past, inclusive of the current date and time
523
+ *
524
+ * @param key
525
+ * @returns
526
+ */
527
+ whereNowOrPast<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
528
+ /**
529
+ * Adds clause to determine if a column's value is in the future, inclusive of the current date and time
530
+ *
531
+ * @param key
532
+ * @returns
533
+ */
534
+ whereNowOrFuture<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
535
+ /**
536
+ * Adds clause to determine if a column's value is today
537
+ *
538
+ * @param key
539
+ * @returns
540
+ */
541
+ whereToday<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
542
+ /**
543
+ * Adds clause to determine if a column's value is before today
544
+ *
545
+ * @param key
546
+ * @returns
547
+ */
548
+ whereBeforeToday<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
549
+ /**
550
+ * Adds clause to determine if a column's value is after today
551
+ *
552
+ * @param key
553
+ * @returns
554
+ */
555
+ whereAfterToday<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
556
+ /**
557
+ * Adds clause to determine if a column's value is today or before today
558
+ *
559
+ * @param key
560
+ * @returns
561
+ */
562
+ whereTodayOrBefore<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
563
+ /**
564
+ * Adds clause to determine if a column's value is today or after today
565
+ *
566
+ * @param key
567
+ * @returns
568
+ */
569
+ whereTodayOrAfter<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
570
+ /**
571
+ * Adds clause to verify that two columns are equal
572
+ *
573
+ * @param left
574
+ * @param right
575
+ */
576
+ whereColumn<TLeft extends keyof ModelAttributes<TModel> & string, TRight extends keyof ModelAttributes<TModel> & string>(left: TLeft, right: TRight): this;
577
+ /**
578
+ * Adds clause to verify that two columns are equal
579
+ *
580
+ * @param left
581
+ * @param operator
582
+ * @param right
583
+ */
584
+ whereColumn<TLeft extends keyof ModelAttributes<TModel> & string, TRight extends keyof ModelAttributes<TModel> & string>(left: TLeft, operator: QueryScalarComparisonOperator, right: TRight): this;
585
+ /**
586
+ * Adds "where exists" SQL clauses.
587
+ *
588
+ * @param queryOrCallback
589
+ * @returns
590
+ */
591
+ whereExists(queryOrCallback: QueryBuilder<any, any> | ((query: QueryBuilder<TModel>) => QueryBuilder<any, any> | void)): this;
592
+ /**
593
+ * Adds a fulltext clause for columns that have full text indexes.
594
+ *
595
+ * @param columns
596
+ * @param value
597
+ * @param options
598
+ * @returns
599
+ */
600
+ whereFullText<TKey extends keyof ModelAttributes<TModel> & string>(columns: TKey | TKey[], value: string, options?: {
601
+ language?: string;
602
+ }): this;
473
603
  /**
474
604
  * Add a strongly-typed where key clause to the relationship query.
475
605
  *
@@ -2731,6 +2861,136 @@ declare class QueryBuilder<TModel, TDelegate extends ModelQuerySchemaLike = Mode
2731
2861
  * @returns
2732
2862
  */
2733
2863
  whereYear<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, year: number): this;
2864
+ /**
2865
+ * Adds a time clause for a date-like key.
2866
+ *
2867
+ * @param key
2868
+ * @param value
2869
+ * @returns
2870
+ */
2871
+ whereTime<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Date | string): this;
2872
+ /**
2873
+ * Adds a time clause for a date-like key.
2874
+ *
2875
+ * @param key
2876
+ * @param operator
2877
+ * @param value
2878
+ * @returns
2879
+ */
2880
+ whereTime<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, operator: QueryScalarComparisonOperator, value: Date | string): this;
2881
+ /**
2882
+ * Adds a day clause for a date-like key.
2883
+ *
2884
+ * @param key
2885
+ * @param day
2886
+ * @returns
2887
+ */
2888
+ whereDay<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, day: number): this;
2889
+ /**
2890
+ * Adds a day clause for a date-like key.
2891
+ *
2892
+ * @param key
2893
+ * @param operator
2894
+ * @param day
2895
+ * @returns
2896
+ */
2897
+ whereDay<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, operator: QueryScalarComparisonOperator, day: number): this;
2898
+ /**
2899
+ * Adds clause to determine if a column's value is in the past
2900
+ *
2901
+ * @param key
2902
+ * @returns
2903
+ */
2904
+ wherePast<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2905
+ /**
2906
+ * Adds clause to determine if a column's value is in the future
2907
+ *
2908
+ * @param key
2909
+ * @returns
2910
+ */
2911
+ whereFuture<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2912
+ /**
2913
+ * Adds clause to determine if a column's value is in the past, inclusive of the current date and time
2914
+ *
2915
+ * @param key
2916
+ * @returns
2917
+ */
2918
+ whereNowOrPast<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2919
+ /**
2920
+ * Adds clause to determine if a column's value is in the future, inclusive of the current date and time
2921
+ *
2922
+ * @param key
2923
+ * @returns
2924
+ */
2925
+ whereNowOrFuture<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2926
+ /**
2927
+ * Adds clause to determine if a column's value is today
2928
+ *
2929
+ * @param key
2930
+ * @returns
2931
+ */
2932
+ whereToday<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2933
+ /**
2934
+ * Adds clause to determine if a column's value is before today
2935
+ *
2936
+ * @param key
2937
+ * @returns
2938
+ */
2939
+ whereBeforeToday<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2940
+ /**
2941
+ * Adds clause to determine if a column's value is after today
2942
+ *
2943
+ * @param key
2944
+ * @returns
2945
+ */
2946
+ whereAfterToday<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2947
+ /**
2948
+ * Adds clause to determine if a column's value is today or before today
2949
+ *
2950
+ * @param key
2951
+ * @returns
2952
+ */
2953
+ whereTodayOrBefore<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2954
+ /**
2955
+ * Adds clause to determine if a column's value is today or after today
2956
+ *
2957
+ * @param key
2958
+ * @returns
2959
+ */
2960
+ whereTodayOrAfter<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey): this;
2961
+ /**
2962
+ * Adds clause to verify that two columns are equal
2963
+ *
2964
+ * @param left
2965
+ * @param right
2966
+ */
2967
+ whereColumn<TLeft extends keyof ModelAttributes<TModel> & string, TRight extends keyof ModelAttributes<TModel> & string>(left: TLeft, right: TRight): this;
2968
+ /**
2969
+ * Adds clause to verify that two columns are equal
2970
+ *
2971
+ * @param left
2972
+ * @param operator
2973
+ * @param right
2974
+ */
2975
+ whereColumn<TLeft extends keyof ModelAttributes<TModel> & string, TRight extends keyof ModelAttributes<TModel> & string>(left: TLeft, operator: QueryScalarComparisonOperator, right: TRight): this;
2976
+ /**
2977
+ * Adds "where exists" SQL clauses.
2978
+ *
2979
+ * @param queryOrCallback
2980
+ * @returns
2981
+ */
2982
+ whereExists(queryOrCallback: QueryBuilder<any, any> | ((query: QueryBuilder<TModel, TDelegate>) => QueryBuilder<any, any> | void)): this;
2983
+ /**
2984
+ * Adds a fulltext clause for columns that have full text indexes.
2985
+ *
2986
+ * @param columns
2987
+ * @param value
2988
+ * @param options
2989
+ * @returns
2990
+ */
2991
+ whereFullText<TKey extends keyof ModelAttributes<TModel> & string>(columns: TKey | TKey[], value: string, options?: {
2992
+ language?: string;
2993
+ }): this;
2734
2994
  /**
2735
2995
  * Adds a strongly-typed inequality where clause for a single attribute key.
2736
2996
  *
@@ -2807,6 +3067,8 @@ declare class QueryBuilder<TModel, TDelegate extends ModelQuerySchemaLike = Mode
2807
3067
  private addLogicalWhere;
2808
3068
  private buildComparisonWhere;
2809
3069
  private coerceDate;
3070
+ private normalizeTimeValue;
3071
+ private getUtcDayBounds;
2810
3072
  /**
2811
3073
  * Adds a strongly-typed equality where clause for a single attribute key.
2812
3074
  *
@@ -3908,6 +4170,7 @@ type AdapterCapability = 'transactions' | 'returning' | 'insertMany' | 'upsert'
3908
4170
  type AdapterCapabilities = Partial<Record<AdapterCapability, boolean>>;
3909
4171
  type QueryLogicalOperator = 'and' | 'or';
3910
4172
  type QueryComparisonOperator = '=' | '!=' | '>' | '>=' | '<' | '<=' | 'in' | 'not-in' | 'contains' | 'starts-with' | 'ends-with' | 'is-null' | 'is-not-null';
4173
+ type QueryScalarComparisonOperator = '=' | '!=' | '>' | '>=' | '<' | '<=';
3911
4174
  type SortDirection = 'asc' | 'desc';
3912
4175
  type AggregateOperation = 'count' | 'exists' | 'sum' | 'avg' | 'min' | 'max';
3913
4176
  type SoftDeleteQueryMode = 'exclude' | 'include' | 'only';
@@ -3952,11 +4215,39 @@ interface QueryRawCondition {
3952
4215
  sql: string;
3953
4216
  bindings?: DatabaseValue[];
3954
4217
  }
4218
+ interface QueryColumnComparisonCondition {
4219
+ type: 'column-comparison';
4220
+ leftColumn: string;
4221
+ operator: QueryScalarComparisonOperator;
4222
+ rightColumn: string;
4223
+ }
4224
+ interface QueryTimeCondition {
4225
+ type: 'time';
4226
+ column: string;
4227
+ operator: QueryScalarComparisonOperator;
4228
+ value: string;
4229
+ }
4230
+ interface QueryDayCondition {
4231
+ type: 'day';
4232
+ column: string;
4233
+ operator: QueryScalarComparisonOperator;
4234
+ value: number;
4235
+ }
4236
+ interface QueryExistsCondition {
4237
+ type: 'exists';
4238
+ query: SelectSpec;
4239
+ }
4240
+ interface QueryFullTextCondition {
4241
+ type: 'full-text';
4242
+ columns: string[];
4243
+ value: string;
4244
+ language?: string;
4245
+ }
3955
4246
  interface RawQuerySpec {
3956
4247
  sql: string;
3957
4248
  bindings?: DatabaseValue[];
3958
4249
  }
3959
- type QueryCondition = QueryComparisonCondition | QueryGroupCondition | QueryNotCondition | QueryRawCondition;
4250
+ type QueryCondition = QueryComparisonCondition | QueryColumnComparisonCondition | QueryTimeCondition | QueryDayCondition | QueryExistsCondition | QueryFullTextCondition | QueryGroupCondition | QueryNotCondition | QueryRawCondition;
3960
4251
  interface AggregateSelection {
3961
4252
  type: AggregateOperation;
3962
4253
  column?: string;
@@ -4197,6 +4488,11 @@ declare class KyselyDatabaseAdapter implements DatabaseAdapter {
4197
4488
  private buildConditionValueList;
4198
4489
  private buildComparisonCondition;
4199
4490
  private buildRawWhereCondition;
4491
+ private buildColumnComparisonCondition;
4492
+ private buildTimeCondition;
4493
+ private buildDayCondition;
4494
+ private buildExistsCondition;
4495
+ private buildFullTextCondition;
4200
4496
  private buildWhereCondition;
4201
4497
  private buildWhereClause;
4202
4498
  private buildPaginationClause;
@@ -6428,4 +6724,4 @@ declare class URLDriver {
6428
6724
  url(page: number): string;
6429
6725
  }
6430
6726
  //#endregion
6431
- export { buildUniqueConstraintLine as $, QuerySchemaForModel as $a, PrismaLikeSortOrder as $i, getRegisteredFactories as $n, MorphManyRelationMetadata as $o, QueryRawCondition as $r, getPersistedEnumMap as $t, loadArkormConfig as A, AttributeQuerySchema as Aa, DelegateSelect as Ai, SeedCommand as An, RelationTableLookupSpec as Ao, AdapterModelIntrospectionOptions as Ar, deleteAppliedMigrationsStateFromStore as At, applyMigrationRollbackToDatabase as B, ModelCreateData as Ba, NamingCase as Bi, InitCommand as Bn, FactoryRelationshipResolver as Bo, DatabaseRows as Br, resolveMigrationStateFilePath as Bt, getRuntimePaginationCurrentPageResolver as C, TransactionContext as Ca, ClientResolver as Ci, DB as Cn, RelationColumnLookupSpec as Co, KyselyDatabaseAdapter as Cr, SchemaTableAlterOperation as Cs, supportsDatabaseReset as Ct, isDelegateLike as D, QueryBuilder as Da, DelegateOrderBy as Di, EnumBuilder as Dn, RelationMetadataProvider as Do, AdapterDatabaseCreationResult as Dr, TimestampColumnBehavior as Ds, buildMigrationRunId as Dt, getUserConfig as E, RelationshipModelStatic as Ea, DelegateInclude as Ei, SchemaBuilder as En, RelationDefaultValue as Eo, AdapterCapability as Er, SchemaUniqueConstraint as Es, buildMigrationIdentity as Et, PRISMA_ENUM_REGEX as F, DelegateForModelSchema as Fa, EagerLoadConstraint as Fi, MigrateCommand as Fn, FactoryAttributes as Fo, AggregateSelection as Fr, markMigrationApplied as Ft, buildEnumBlock as G, ModelEventListener as Ga, PaginationURLDriverFactory as Gi, Arkorm as Gn, BelongsToManyRelationMetadata as Go, InsertSpec as Gr, PersistedMetadataFeatures as Gt, applyMigrationToDatabase as H, ModelEventDispatcher as Ha, PaginationMeta as Hi, resolveCast as Hn, MaybePromise as Ho, DeleteManySpec as Hr, writeAppliedMigrationsState as Ht, PRISMA_MODEL_REGEX as I, GlobalScope as Ia, EagerLoadMap as Ii, MakeSeederCommand as In, FactoryCallback as Io, AggregateSpec as Ir, markMigrationRun as It, buildInverseRelationLine as J, ModelOrderByInput as Ja, PrismaFindManyArgsLike as Ji, RegisteredModel as Jn, HasManyRelationMetadata as Jo, QueryCondition as Jr, PersistedTimestampColumn as Jt, buildFieldLine as K, ModelEventName as Ka, PrismaClientLike as Ki, Arkormx as Kn, BelongsToRelationMetadata as Ko, QueryComparisonCondition as Kr, PersistedPrimaryKeyGeneration as Kt, applyAlterTableOperation as L, ModelAttributeValue as La, GetUserConfig as Li, MakeModelCommand as Ln, FactoryDefinition as Lo, DatabaseAdapter as Lr, readAppliedMigrationsState as Lt, runArkormTransaction as M, AttributeSelect as Ma, DelegateUpdateArgs as Mi, MigrationHistoryCommand as Mn, Paginator as Mo, AdapterQueryOperation as Mr, getLastMigrationRun as Mt, PrimaryKeyGenerationPlanner as N, AttributeUpdateInput as Na, DelegateUpdateData as Ni, MigrateRollbackCommand as Nn, ArkormCollection as No, AdapterTransactionContext as Nr, getLatestAppliedMigrations as Nt, isQuerySchemaLike as O, AttributeCreateInput as Oa, DelegateRow as Oi, TableBuilder as On, RelationResult as Oo, AdapterInspectionRequest as Or, computeMigrationChecksum as Ot, PRISMA_ENUM_MEMBER_REGEX as P, AttributeWhereInput as Pa, DelegateWhere as Pi, MigrateFreshCommand as Pn, FactoryAttributeResolver as Po, AggregateOperation as Pr, isMigrationApplied as Pt, buildRelationLine as Q, ModelWhereInput as Qa, PrismaLikeSelect as Qi, RuntimePathMap as Qn, ModelMetadata as Qo, QueryOrderBy as Qr, getPersistedColumnMap as Qt, applyCreateTableOperation as R, ModelAttributes as Ra, ModelQuerySchemaLike as Ri, MakeMigrationCommand as Rn, FactoryDefinitionAttributes as Ro, DatabasePrimitive as Rr, readAppliedMigrationsStateFromStore as Rt, getRuntimeDebugHandler as S, TransactionCapableClient as Sa, CastType as Si, ArkormException as Sn, RelationAggregateType as So, createPrismaDatabaseAdapter as Sr, SchemaPrimaryKey as Ss, supportsDatabaseMigrationExecution as St, getRuntimePrismaClient as T, ModelStatic as Ta, DelegateFindManyArgs as Ti, Migration as Tn, RelationDefaultResolver as To, AdapterCapabilities as Tr, SchemaTableDropOperation as Ts, toModelName as Tt, applyMigrationToPrismaSchema as U, ModelEventHandler as Ua, PaginationOptions as Ui, Attribute as Un, DatabaseTableOptions as Uo, DeleteSpec as Ur, writeAppliedMigrationsStateToStore as Ut, applyMigrationRollbackToPrismaSchema as V, ModelDeclaredAttributeKey as Va, PaginationCurrentPageResolver as Vi, CliApp as Vn, FactoryState as Vo, DatabaseValue as Vr, supportsDatabaseMigrationState as Vt, applyOperationsToPrismaSchema as W, ModelEventHandlerConstructor as Wa, PaginationURLDriver as Wi, AttributeOptions as Wn, DatabaseTablePersistedMetadataOptions as Wo, InsertManySpec as Wr, PersistedColumnMappingsState as Wt, buildModelBlock as X, ModelRelationshipResult as Xa, PrismaLikeOrderBy as Xi, RuntimePathInput as Xn, HasOneRelationMetadata as Xo, QueryLogicalOperator as Xr, createEmptyPersistedColumnMappingsState as Xt, buildMigrationSource as Y, ModelRelationshipKey as Ya, PrismaLikeInclude as Yi, RuntimeConstructor as Yn, HasManyThroughRelationMetadata as Yo, QueryGroupCondition as Yr, applyOperationsToPersistedColumnMappingsState as Yt, buildPrimaryKeyLine as Z, ModelUpdateData as Za, PrismaLikeScalarFilter as Zi, RuntimePathKey as Zn, HasOneThroughRelationMetadata as Zo, QueryNotCondition as Zr, deletePersistedColumnMappingsState as Zt, getActiveTransactionAdapter as _, RuntimeClientLike as _a, ArkormDebugEvent as _i, QueryExecutionExceptionContext as _n, BelongsToManyRelation as _o, SeederConstructor as _r, SchemaColumnType as _s, resolvePrismaType as _t, resolveRuntimeCompatibilityQuerySchema as a, QuerySchemaCreateData as aa, RelationLoadPlan as ai, rebuildPersistedColumnMappingsState as an, defineFactory as ao, loadMigrationsFrom as ar, RelationMetadataType as as, deriveSingularFieldName as at, getRuntimeAdapter as b, SoftDeleteConfig as ba, CastHandler as bi, MissingDelegateException as bn, RelationAggregateConstraint as bo, PrismaDelegateNameMapping as br, SchemaIndex as bs, stripPrismaSchemaModelsAndEnums as bt, createPrismaAdapter as c, QuerySchemaOrderBy as ca, SoftDeleteQueryMode as ci, resolvePersistedMetadataFeatures as cn, MorphToManyRelation as co, registerFactories as cr, AppliedMigrationsState as cs, findModelBlock as ct, awaitConfiguredModelsRegistration as d, QuerySchemaSelect as da, UpdateSpec as di, writePersistedColumnMappingsState as dn, HasOneThroughRelation as do, registerPaths as dr, MigrationClass as ds, formatRelationAction as dt, PrismaLikeWhereInput as ea, QuerySelectColumn as ei, getPersistedEnumTsType as en, QuerySchemaForModelInstance as eo, getRegisteredMigrations as er, MorphOneRelationMetadata as es, createMigrationTimestamp as et, bindAdapterToModels as f, QuerySchemaUniqueWhere as fa, UpsertSpec as fi, UnsupportedAdapterFeatureException as fn, HasOneRelation as fo, registerSeeders as fr, MigrationInstanceLike as fs, generateMigrationFile as ft, ensureArkormConfigLoading as g, RawSelectInput as ga, ArkormConfig as gi, QueryExecutionException as gn, SingleResultRelation as go, SeederCallArgument as gr, SchemaColumn as gs, resolveMigrationClassName as gt, emitRuntimeDebugEvent as h, QuerySchemaWhere as ha, ArkormBootContext as hi, RelationResolutionException as hn, BelongsToRelation as ho, Seeder as hr, PrismaSchemaSyncOptions as hs, resolveEnumName as ht, getRuntimeCompatibilityAdapter as i, PrismaTransactionOptions as ia, RelationFilterSpec as ii, readPersistedColumnMappingsState as in, ModelFactory as io, loadFactoriesFrom as ir, RelationMetadata as is, deriveRelationFieldName as it, resetArkormRuntimeForTests as j, AttributeSchemaDelegate as ja, DelegateUniqueWhere as ji, ModelsSyncCommand as jn, LengthAwarePaginator as jo, AdapterModelStructure as jr, findAppliedMigration as jt, isTransactionCapableClient as k, AttributeOrderBy as ka, DelegateRows as ki, ForeignKeyBuilder as kn, RelationResultCache as ko, AdapterModelFieldStructure as kr, createEmptyAppliedMigrationsState as kt, createPrismaDelegateMap as l, QuerySchemaRow as la, SortDirection as li, syncPersistedColumnMappingsFromState as ln, MorphOneRelation as lo, registerMigrations as lr, GenerateMigrationOptions as ls, formatDefaultValue as lt, defineConfig as m, QuerySchemaUpdateData as ma, AdapterQueryInspection as mi, ScopeNotDefinedException as mn, HasManyRelation as mo, SEEDER_BRAND as mr, PrismaMigrationWorkflowOptions as ms, pad as mt, PivotModel as n, PrismaTransactionCapableClient as na, RawQuerySpec as ni, getPersistedTableMetadata as nn, Model as no, getRegisteredPaths as nr, MorphToRelationMetadata as ns, deriveInverseRelationAlias as nt, resolveRuntimeCompatibilityQuerySchemaOrThrow as o, QuerySchemaFindManyArgs as oa, RelationLoadSpec as oi, resetPersistedColumnMappingsCache as on, SetBasedEagerLoader as oo, loadModelsFrom as or, AppliedMigrationEntry as os, escapeRegex as ot, configureArkormRuntime as p, QuerySchemaUpdateArgs as pa, AdapterBindableModel as pi, UniqueConstraintResolutionException as pn, HasManyThroughRelation as po, resetRuntimeRegistryForTests as pr, PrimaryKeyGeneration as ps, getMigrationPlan as pt, buildIndexLine as q, ModelLifecycleState as qa, PrismaDelegateLike as qi, RegisteredFactory as qn, ColumnMap as qo, QueryComparisonOperator as qr, PersistedTableMetadata as qt, RuntimeModuleLoader as r, PrismaTransactionContext as ra, RelationAggregateSpec as ri, getPersistedTimestampColumns as rn, InlineFactory as ro, getRegisteredSeeders as rr, PivotModelStatic as rs, deriveRelationAlias as rt, PrismaDelegateMap as s, QuerySchemaInclude as sa, SelectSpec as si, resolveColumnMappingsFilePath as sn, MorphToRelation as so, loadSeedersFrom as sr, AppliedMigrationRun as ss, findEnumBlock as st, URLDriver as t, PrismaTransactionCallback as ta, QueryTarget as ti, getPersistedPrimaryKeyGeneration as tn, RelatedModelClass as to, getRegisteredModels as tr, MorphToManyRelationMetadata as ts, deriveCollectionFieldName as tt, inferDelegateName as u, QuerySchemaRows as ua, UpdateManySpec as ui, validatePersistedMetadataFeaturesForMigrations as un, MorphManyRelation as uo, registerModels as ur, GeneratedMigrationFile as us, formatEnumDefaultValue as ut, getActiveTransactionClient as v, Serializable as va, ArkormDebugHandler as vi, QueryConstraintException as vn, Relation as vo, SeederInput as vr, SchemaForeignKey as vs, runMigrationWithPrisma as vt, getRuntimePaginationURLDriverFactory as w, TransactionOptions as wa, DelegateCreateData as wi, MIGRATION_BRAND as wn, RelationConstraint as wo, createKyselyAdapter as wr, SchemaTableCreateOperation as ws, toMigrationFileSlug as wt, getRuntimeClient as x, TransactionCallback as xa, CastMap as xi, ArkormErrorContext as xn, RelationAggregateInput as xo, createPrismaCompatibilityAdapter as xr, SchemaOperation as xs, supportsDatabaseCreation as xt, getDefaultStubsPath as y, SimplePaginationMeta as ya, CastDefinition as yi, ModelNotFoundException as yn, RelationTableLoader as yo, PrismaDatabaseAdapter as yr, SchemaForeignKeyAction as ys, runPrismaCommand as yt, applyDropTableOperation as z, ModelAttributesOf as za, ModelTableCase as zi, MakeFactoryCommand as zn, FactoryModelConstructor as zo, DatabaseRow as zr, removeAppliedMigration as zt };
6727
+ export { buildUniqueConstraintLine as $, ModelLifecycleState as $a, PrismaDelegateLike as $i, getRegisteredFactories as $n, ColumnMap as $o, QueryGroupCondition as $r, getPersistedEnumMap as $t, loadArkormConfig as A, TransactionOptions as Aa, DelegateCreateData as Ai, SeedCommand as An, RelationConstraint as Ao, AdapterModelIntrospectionOptions as Ar, SchemaTableCreateOperation as As, deleteAppliedMigrationsStateFromStore as At, applyMigrationRollbackToDatabase as B, AttributeWhereInput as Ba, DelegateWhere as Bi, InitCommand as Bn, FactoryAttributeResolver as Bo, DatabaseRows as Br, resolveMigrationStateFilePath as Bt, getRuntimePaginationCurrentPageResolver as C, RuntimeClientLike as Ca, ArkormDebugEvent as Ci, DB as Cn, BelongsToManyRelation as Co, KyselyDatabaseAdapter as Cr, SchemaColumnType as Cs, supportsDatabaseReset as Ct, isDelegateLike as D, TransactionCallback as Da, CastMap as Di, EnumBuilder as Dn, RelationAggregateInput as Do, AdapterDatabaseCreationResult as Dr, SchemaOperation as Ds, buildMigrationRunId as Dt, getUserConfig as E, SoftDeleteConfig as Ea, CastHandler as Ei, SchemaBuilder as En, RelationAggregateConstraint as Eo, AdapterCapability as Er, SchemaIndex as Es, buildMigrationIdentity as Et, PRISMA_ENUM_REGEX as F, AttributeOrderBy as Fa, DelegateRows as Fi, MigrateCommand as Fn, RelationResultCache as Fo, AggregateSelection as Fr, markMigrationApplied as Ft, buildEnumBlock as G, ModelAttributesOf as Ga, ModelTableCase as Gi, Arkorm as Gn, FactoryModelConstructor as Go, InsertSpec as Gr, PersistedMetadataFeatures as Gt, applyMigrationToDatabase as H, GlobalScope as Ha, EagerLoadMap as Hi, resolveCast as Hn, FactoryCallback as Ho, DeleteManySpec as Hr, writeAppliedMigrationsState as Ht, PRISMA_MODEL_REGEX as I, AttributeQuerySchema as Ia, DelegateSelect as Ii, MakeSeederCommand as In, RelationTableLookupSpec as Io, AggregateSpec as Ir, markMigrationRun as It, buildInverseRelationLine as J, ModelEventDispatcher as Ja, PaginationMeta as Ji, RegisteredModel as Jn, MaybePromise as Jo, QueryComparisonOperator as Jr, PersistedTimestampColumn as Jt, buildFieldLine as K, ModelCreateData as Ka, NamingCase as Ki, Arkormx as Kn, FactoryRelationshipResolver as Ko, QueryColumnComparisonCondition as Kr, PersistedPrimaryKeyGeneration as Kt, applyAlterTableOperation as L, AttributeSchemaDelegate as La, DelegateUniqueWhere as Li, MakeModelCommand as Ln, LengthAwarePaginator as Lo, DatabaseAdapter as Lr, readAppliedMigrationsState as Lt, runArkormTransaction as M, RelationshipModelStatic as Ma, DelegateInclude as Mi, MigrationHistoryCommand as Mn, RelationDefaultValue as Mo, AdapterQueryOperation as Mr, SchemaUniqueConstraint as Ms, getLastMigrationRun as Mt, PrimaryKeyGenerationPlanner as N, QueryBuilder as Na, DelegateOrderBy as Ni, MigrateRollbackCommand as Nn, RelationMetadataProvider as No, AdapterTransactionContext as Nr, TimestampColumnBehavior as Ns, getLatestAppliedMigrations as Nt, isQuerySchemaLike as O, TransactionCapableClient as Oa, CastType as Oi, TableBuilder as On, RelationAggregateType as Oo, AdapterInspectionRequest as Or, SchemaPrimaryKey as Os, computeMigrationChecksum as Ot, PRISMA_ENUM_MEMBER_REGEX as P, AttributeCreateInput as Pa, DelegateRow as Pi, MigrateFreshCommand as Pn, RelationResult as Po, AggregateOperation as Pr, isMigrationApplied as Pt, buildRelationLine as Q, ModelEventName as Qa, PrismaClientLike as Qi, RuntimePathMap as Qn, BelongsToRelationMetadata as Qo, QueryFullTextCondition as Qr, getPersistedColumnMap as Qt, applyCreateTableOperation as R, AttributeSelect as Ra, DelegateUpdateArgs as Ri, MakeMigrationCommand as Rn, Paginator as Ro, DatabasePrimitive as Rr, readAppliedMigrationsStateFromStore as Rt, getRuntimeDebugHandler as S, RawSelectInput as Sa, ArkormConfig as Si, ArkormException as Sn, SingleResultRelation as So, createPrismaDatabaseAdapter as Sr, SchemaColumn as Ss, supportsDatabaseMigrationExecution as St, getRuntimePrismaClient as T, SimplePaginationMeta as Ta, CastDefinition as Ti, Migration as Tn, RelationTableLoader as To, AdapterCapabilities as Tr, SchemaForeignKeyAction as Ts, toModelName as Tt, applyMigrationToPrismaSchema as U, ModelAttributeValue as Ua, GetUserConfig as Ui, Attribute as Un, FactoryDefinition as Uo, DeleteSpec as Ur, writeAppliedMigrationsStateToStore as Ut, applyMigrationRollbackToPrismaSchema as V, DelegateForModelSchema as Va, EagerLoadConstraint as Vi, CliApp as Vn, FactoryAttributes as Vo, DatabaseValue as Vr, supportsDatabaseMigrationState as Vt, applyOperationsToPrismaSchema as W, ModelAttributes as Wa, ModelQuerySchemaLike as Wi, AttributeOptions as Wn, FactoryDefinitionAttributes as Wo, InsertManySpec as Wr, PersistedColumnMappingsState as Wt, buildModelBlock as X, ModelEventHandlerConstructor as Xa, PaginationURLDriver as Xi, RuntimePathInput as Xn, DatabaseTablePersistedMetadataOptions as Xo, QueryDayCondition as Xr, createEmptyPersistedColumnMappingsState as Xt, buildMigrationSource as Y, ModelEventHandler as Ya, PaginationOptions as Yi, RuntimeConstructor as Yn, DatabaseTableOptions as Yo, QueryCondition as Yr, applyOperationsToPersistedColumnMappingsState as Yt, buildPrimaryKeyLine as Z, ModelEventListener as Za, PaginationURLDriverFactory as Zi, RuntimePathKey as Zn, BelongsToManyRelationMetadata as Zo, QueryExistsCondition as Zr, deletePersistedColumnMappingsState as Zt, getActiveTransactionAdapter as _, QuerySchemaSelect as _a, UpdateSpec as _i, QueryExecutionExceptionContext as _n, HasOneThroughRelation as _o, SeederConstructor as _r, MigrationClass as _s, resolvePrismaType as _t, resolveRuntimeCompatibilityQuerySchema as a, PrismaLikeSortOrder as aa, QuerySelectColumn as ai, rebuildPersistedColumnMappingsState as an, QuerySchemaForModel as ao, loadMigrationsFrom as ar, MorphManyRelationMetadata as as, deriveSingularFieldName as at, getRuntimeAdapter as b, QuerySchemaUpdateData as ba, AdapterQueryInspection as bi, MissingDelegateException as bn, HasManyRelation as bo, PrismaDelegateNameMapping as br, PrismaMigrationWorkflowOptions as bs, stripPrismaSchemaModelsAndEnums as bt, createPrismaAdapter as c, PrismaTransactionCapableClient as ca, RawQuerySpec as ci, resolvePersistedMetadataFeatures as cn, Model as co, registerFactories as cr, MorphToRelationMetadata as cs, findModelBlock as ct, awaitConfiguredModelsRegistration as d, QuerySchemaCreateData as da, RelationLoadPlan as di, writePersistedColumnMappingsState as dn, defineFactory as do, registerPaths as dr, RelationMetadataType as ds, formatRelationAction as dt, PrismaFindManyArgsLike as ea, QueryLogicalOperator as ei, getPersistedEnumTsType as en, ModelOrderByInput as eo, getRegisteredMigrations as er, HasManyRelationMetadata as es, createMigrationTimestamp as et, bindAdapterToModels as f, QuerySchemaFindManyArgs as fa, RelationLoadSpec as fi, UnsupportedAdapterFeatureException as fn, SetBasedEagerLoader as fo, registerSeeders as fr, AppliedMigrationEntry as fs, generateMigrationFile as ft, ensureArkormConfigLoading as g, QuerySchemaRows as ga, UpdateManySpec as gi, QueryExecutionException as gn, MorphManyRelation as go, SeederCallArgument as gr, GeneratedMigrationFile as gs, resolveMigrationClassName as gt, emitRuntimeDebugEvent as h, QuerySchemaRow as ha, SortDirection as hi, RelationResolutionException as hn, MorphOneRelation as ho, Seeder as hr, GenerateMigrationOptions as hs, resolveEnumName as ht, getRuntimeCompatibilityAdapter as i, PrismaLikeSelect as ia, QueryScalarComparisonOperator as ii, readPersistedColumnMappingsState as in, ModelWhereInput as io, loadFactoriesFrom as ir, ModelMetadata as is, deriveRelationFieldName as it, resetArkormRuntimeForTests as j, ModelStatic as ja, DelegateFindManyArgs as ji, ModelsSyncCommand as jn, RelationDefaultResolver as jo, AdapterModelStructure as jr, SchemaTableDropOperation as js, findAppliedMigration as jt, isTransactionCapableClient as k, TransactionContext as ka, ClientResolver as ki, ForeignKeyBuilder as kn, RelationColumnLookupSpec as ko, AdapterModelFieldStructure as kr, SchemaTableAlterOperation as ks, createEmptyAppliedMigrationsState as kt, createPrismaDelegateMap as l, PrismaTransactionContext as la, RelationAggregateSpec as li, syncPersistedColumnMappingsFromState as ln, InlineFactory as lo, registerMigrations as lr, PivotModelStatic as ls, formatDefaultValue as lt, defineConfig as m, QuerySchemaOrderBy as ma, SoftDeleteQueryMode as mi, ScopeNotDefinedException as mn, MorphToManyRelation as mo, SEEDER_BRAND as mr, AppliedMigrationsState as ms, pad as mt, PivotModel as n, PrismaLikeOrderBy as na, QueryOrderBy as ni, getPersistedTableMetadata as nn, ModelRelationshipResult as no, getRegisteredPaths as nr, HasOneRelationMetadata as ns, deriveInverseRelationAlias as nt, resolveRuntimeCompatibilityQuerySchemaOrThrow as o, PrismaLikeWhereInput as oa, QueryTarget as oi, resetPersistedColumnMappingsCache as on, QuerySchemaForModelInstance as oo, loadModelsFrom as or, MorphOneRelationMetadata as os, escapeRegex as ot, configureArkormRuntime as p, QuerySchemaInclude as pa, SelectSpec as pi, UniqueConstraintResolutionException as pn, MorphToRelation as po, resetRuntimeRegistryForTests as pr, AppliedMigrationRun as ps, getMigrationPlan as pt, buildIndexLine as q, ModelDeclaredAttributeKey as qa, PaginationCurrentPageResolver as qi, RegisteredFactory as qn, FactoryState as qo, QueryComparisonCondition as qr, PersistedTableMetadata as qt, RuntimeModuleLoader as r, PrismaLikeScalarFilter as ra, QueryRawCondition as ri, getPersistedTimestampColumns as rn, ModelUpdateData as ro, getRegisteredSeeders as rr, HasOneThroughRelationMetadata as rs, deriveRelationAlias as rt, PrismaDelegateMap as s, PrismaTransactionCallback as sa, QueryTimeCondition as si, resolveColumnMappingsFilePath as sn, RelatedModelClass as so, loadSeedersFrom as sr, MorphToManyRelationMetadata as ss, findEnumBlock as st, URLDriver as t, PrismaLikeInclude as ta, QueryNotCondition as ti, getPersistedPrimaryKeyGeneration as tn, ModelRelationshipKey as to, getRegisteredModels as tr, HasManyThroughRelationMetadata as ts, deriveCollectionFieldName as tt, inferDelegateName as u, PrismaTransactionOptions as ua, RelationFilterSpec as ui, validatePersistedMetadataFeaturesForMigrations as un, ModelFactory as uo, registerModels as ur, RelationMetadata as us, formatEnumDefaultValue as ut, getActiveTransactionClient as v, QuerySchemaUniqueWhere as va, UpsertSpec as vi, QueryConstraintException as vn, HasOneRelation as vo, SeederInput as vr, MigrationInstanceLike as vs, runMigrationWithPrisma as vt, getRuntimePaginationURLDriverFactory as w, Serializable as wa, ArkormDebugHandler as wi, MIGRATION_BRAND as wn, Relation as wo, createKyselyAdapter as wr, SchemaForeignKey as ws, toMigrationFileSlug as wt, getRuntimeClient as x, QuerySchemaWhere as xa, ArkormBootContext as xi, ArkormErrorContext as xn, BelongsToRelation as xo, createPrismaCompatibilityAdapter as xr, PrismaSchemaSyncOptions as xs, supportsDatabaseCreation as xt, getDefaultStubsPath as y, QuerySchemaUpdateArgs as ya, AdapterBindableModel as yi, ModelNotFoundException as yn, HasManyThroughRelation as yo, PrismaDatabaseAdapter as yr, PrimaryKeyGeneration as ys, runPrismaCommand as yt, applyDropTableOperation as z, AttributeUpdateInput as za, DelegateUpdateData as zi, MakeFactoryCommand as zn, ArkormCollection as zo, DatabaseRow as zr, removeAppliedMigration as zt };
package/dist/index.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_relationship = require('./relationship-BS1AHptf.cjs');
2
+ const require_relationship = require('./relationship-CKQaNPdK.cjs');
3
3
  let pg = require("pg");
4
4
  let node_path = require("node:path");
5
5
  let module$1 = require("module");
@@ -433,9 +433,40 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
433
433
  if (parts.length === 0) return kysely.sql`1 = 1`;
434
434
  return kysely.sql`${kysely.sql.join(parts, kysely.sql``)}`;
435
435
  }
436
+ buildColumnComparisonCondition(target, condition) {
437
+ const left = kysely.sql.ref(this.mapColumn(target, condition.leftColumn));
438
+ const right = kysely.sql.ref(this.mapColumn(target, condition.rightColumn));
439
+ return kysely.sql`${left} ${kysely.sql.raw(condition.operator)} ${right}`;
440
+ }
441
+ buildTimeCondition(target, condition) {
442
+ return kysely.sql`${kysely.sql.ref(this.mapColumn(target, condition.column))}::time ${kysely.sql.raw(condition.operator)} ${condition.value}::time`;
443
+ }
444
+ buildDayCondition(target, condition) {
445
+ return kysely.sql`extract(day from ${kysely.sql.ref(this.mapColumn(target, condition.column))}) ${kysely.sql.raw(condition.operator)} ${condition.value}`;
446
+ }
447
+ buildExistsCondition(condition) {
448
+ const target = condition.query.target;
449
+ const where = this.buildWhereClause(target, condition.query.where);
450
+ return kysely.sql`exists (
451
+ select 1
452
+ from ${kysely.sql.table(this.resolveTable(target))}
453
+ ${where}
454
+ )`;
455
+ }
456
+ buildFullTextCondition(target, condition) {
457
+ const language = kysely.sql.raw(`'${condition.language ?? "simple"}'`);
458
+ return kysely.sql`to_tsvector(${language}, ${kysely.sql.join(condition.columns.map((column) => {
459
+ return kysely.sql`coalesce(${kysely.sql.ref(this.mapColumn(target, column))}::text, '')`;
460
+ }), kysely.sql` || ' ' || `)}) @@ plainto_tsquery(${language}, ${condition.value})`;
461
+ }
436
462
  buildWhereCondition(target, condition) {
437
463
  if (!condition) return kysely.sql`1 = 1`;
438
464
  if (condition.type === "comparison") return this.buildComparisonCondition(target, condition);
465
+ if (condition.type === "column-comparison") return this.buildColumnComparisonCondition(target, condition);
466
+ if (condition.type === "time") return this.buildTimeCondition(target, condition);
467
+ if (condition.type === "day") return this.buildDayCondition(target, condition);
468
+ if (condition.type === "exists") return this.buildExistsCondition(condition);
469
+ if (condition.type === "full-text") return this.buildFullTextCondition(target, condition);
439
470
  if (condition.type === "group") {
440
471
  const group = condition;
441
472
  const conditions = group.conditions.map((entry) => {
@@ -1382,13 +1413,17 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
1382
1413
  if (!nested) return void 0;
1383
1414
  return { NOT: nested };
1384
1415
  }
1385
- throw new require_relationship.UnsupportedAdapterFeatureException("Raw where clauses are not supported by the Prisma compatibility adapter; use a SQL-backed adapter for raw SQL predicates.", {
1416
+ if (condition.type === "raw") throw new require_relationship.UnsupportedAdapterFeatureException("Raw where clauses are not supported by the Prisma compatibility adapter; use a SQL-backed adapter for raw SQL predicates.", {
1386
1417
  operation: "adapter.where",
1387
1418
  meta: {
1388
1419
  feature: "rawWhere",
1389
1420
  sql: condition.sql
1390
1421
  }
1391
1422
  });
1423
+ throw new require_relationship.UnsupportedAdapterFeatureException(`Where condition [${condition.type}] is not supported by the Prisma compatibility adapter; use a SQL-backed adapter.`, {
1424
+ operation: "adapter.where",
1425
+ meta: { feature: condition.type }
1426
+ });
1392
1427
  }
1393
1428
  buildFindArgs(spec) {
1394
1429
  return {
@@ -3956,6 +3991,179 @@ var QueryBuilder = class QueryBuilder {
3956
3991
  lt: end
3957
3992
  } });
3958
3993
  }
3994
+ whereTime(key, operatorOrValue, maybeValue) {
3995
+ const hasOperator = maybeValue !== void 0;
3996
+ const operator = hasOperator ? operatorOrValue : "=";
3997
+ const value = hasOperator ? maybeValue : operatorOrValue;
3998
+ this.appendQueryCondition("AND", {
3999
+ type: "time",
4000
+ column: key,
4001
+ operator,
4002
+ value: this.normalizeTimeValue(value)
4003
+ });
4004
+ return this;
4005
+ }
4006
+ whereDay(key, operatorOrDay, maybeDay) {
4007
+ const hasOperator = maybeDay !== void 0;
4008
+ const operator = hasOperator ? operatorOrDay : "=";
4009
+ const day = Number(hasOperator ? maybeDay : operatorOrDay);
4010
+ if (!Number.isInteger(day) || day < 1 || day > 31) throw new require_relationship.ArkormException("whereDay() expects an integer between 1 and 31.");
4011
+ this.appendQueryCondition("AND", {
4012
+ type: "day",
4013
+ column: key,
4014
+ operator,
4015
+ value: day
4016
+ });
4017
+ return this;
4018
+ }
4019
+ /**
4020
+ * Adds clause to determine if a column's value is in the past
4021
+ *
4022
+ * @param key
4023
+ * @returns
4024
+ */
4025
+ wherePast(key) {
4026
+ return this.where({ [key]: { lt: /* @__PURE__ */ new Date() } });
4027
+ }
4028
+ /**
4029
+ * Adds clause to determine if a column's value is in the future
4030
+ *
4031
+ * @param key
4032
+ * @returns
4033
+ */
4034
+ whereFuture(key) {
4035
+ return this.where({ [key]: { gt: /* @__PURE__ */ new Date() } });
4036
+ }
4037
+ /**
4038
+ * Adds clause to determine if a column's value is in the past, inclusive of the current date and time
4039
+ *
4040
+ * @param key
4041
+ * @returns
4042
+ */
4043
+ whereNowOrPast(key) {
4044
+ return this.where({ [key]: { lte: /* @__PURE__ */ new Date() } });
4045
+ }
4046
+ /**
4047
+ * Adds clause to determine if a column's value is in the future, inclusive of the current date and time
4048
+ *
4049
+ * @param key
4050
+ * @returns
4051
+ */
4052
+ whereNowOrFuture(key) {
4053
+ return this.where({ [key]: { gte: /* @__PURE__ */ new Date() } });
4054
+ }
4055
+ /**
4056
+ * Adds clause to determine if a column's value is today
4057
+ *
4058
+ * @param key
4059
+ * @returns
4060
+ */
4061
+ whereToday(key) {
4062
+ const [start, end] = this.getUtcDayBounds();
4063
+ return this.where({ [key]: {
4064
+ gte: start,
4065
+ lt: end
4066
+ } });
4067
+ }
4068
+ /**
4069
+ * Adds clause to determine if a column's value is before today
4070
+ *
4071
+ * @param key
4072
+ * @returns
4073
+ */
4074
+ whereBeforeToday(key) {
4075
+ const [start] = this.getUtcDayBounds();
4076
+ return this.where({ [key]: { lt: start } });
4077
+ }
4078
+ /**
4079
+ * Adds clause to determine if a column's value is after today
4080
+ *
4081
+ * @param key
4082
+ * @returns
4083
+ */
4084
+ whereAfterToday(key) {
4085
+ const [, end] = this.getUtcDayBounds();
4086
+ return this.where({ [key]: { gte: end } });
4087
+ }
4088
+ /**
4089
+ * Adds clause to determine if a column's value is today or before today
4090
+ *
4091
+ * @param key
4092
+ * @returns
4093
+ */
4094
+ whereTodayOrBefore(key) {
4095
+ const [, end] = this.getUtcDayBounds();
4096
+ return this.where({ [key]: { lt: end } });
4097
+ }
4098
+ /**
4099
+ * Adds clause to determine if a column's value is today or after today
4100
+ *
4101
+ * @param key
4102
+ * @returns
4103
+ */
4104
+ whereTodayOrAfter(key) {
4105
+ const [start] = this.getUtcDayBounds();
4106
+ return this.where({ [key]: { gte: start } });
4107
+ }
4108
+ whereColumn(left, operatorOrRight, maybeRight) {
4109
+ this.appendQueryCondition("AND", {
4110
+ type: "column-comparison",
4111
+ leftColumn: left,
4112
+ operator: maybeRight === void 0 ? "=" : operatorOrRight,
4113
+ rightColumn: maybeRight ?? operatorOrRight
4114
+ });
4115
+ return this;
4116
+ }
4117
+ /**
4118
+ * Adds "where exists" SQL clauses.
4119
+ *
4120
+ * @param queryOrCallback
4121
+ * @returns
4122
+ */
4123
+ whereExists(queryOrCallback) {
4124
+ const baseQuery = new QueryBuilder(this.model, this.adapter);
4125
+ const existsQuery = typeof queryOrCallback === "function" ? queryOrCallback(baseQuery) ?? baseQuery : queryOrCallback;
4126
+ const spec = existsQuery.tryBuildSelectSpec(existsQuery.buildWhere());
4127
+ if (!spec) throw new require_relationship.UnsupportedAdapterFeatureException("Exists subquery could not be compiled.", {
4128
+ operation: "whereExists",
4129
+ model: this.model.name
4130
+ });
4131
+ this.appendQueryCondition("AND", {
4132
+ type: "exists",
4133
+ query: {
4134
+ ...spec,
4135
+ columns: void 0,
4136
+ orderBy: void 0,
4137
+ limit: void 0,
4138
+ offset: void 0,
4139
+ relationLoads: void 0,
4140
+ relationAggregates: void 0,
4141
+ relationFilters: void 0
4142
+ }
4143
+ });
4144
+ return this;
4145
+ }
4146
+ /**
4147
+ * Adds a fulltext clause for columns that have full text indexes.
4148
+ *
4149
+ * @param columns
4150
+ * @param value
4151
+ * @param options
4152
+ * @returns
4153
+ */
4154
+ whereFullText(columns, value, options = {}) {
4155
+ const normalizedColumns = Array.isArray(columns) ? columns : [columns];
4156
+ if (normalizedColumns.length === 0) throw new require_relationship.ArkormException("whereFullText() expects at least one column.");
4157
+ const language = options.language ?? "simple";
4158
+ if (!/^[a-z][a-z0-9_]*$/i.test(language)) throw new require_relationship.ArkormException("whereFullText() language must be a valid PostgreSQL text search configuration name.");
4159
+ this.appendQueryCondition("AND", {
4160
+ type: "full-text",
4161
+ columns: normalizedColumns,
4162
+ value,
4163
+ language
4164
+ });
4165
+ return this;
4166
+ }
3959
4167
  /**
3960
4168
  * Adds a strongly-typed inequality where clause for a single attribute key.
3961
4169
  *
@@ -4068,6 +4276,25 @@ var QueryBuilder = class QueryBuilder {
4068
4276
  if (Number.isNaN(parsed.getTime())) throw new require_relationship.ArkormException("Invalid date value for date-based query helper.");
4069
4277
  return parsed;
4070
4278
  }
4279
+ normalizeTimeValue(value) {
4280
+ if (value instanceof Date) {
4281
+ if (Number.isNaN(value.getTime())) throw new require_relationship.ArkormException("Invalid date value for whereTime().");
4282
+ return value.toISOString().slice(11, 19);
4283
+ }
4284
+ const matched = value.match(/^(\d{2}):(\d{2})(?::(\d{2}))?$/);
4285
+ if (!matched) throw new require_relationship.ArkormException("whereTime() expects a Date or a time string in HH:mm[:ss] format.");
4286
+ const hour = Number(matched[1]);
4287
+ const minute = Number(matched[2]);
4288
+ const second = Number(matched[3] ?? 0);
4289
+ if (hour > 23 || minute > 59 || second > 59) throw new require_relationship.ArkormException("whereTime() received an invalid time value.");
4290
+ return `${matched[1]}:${matched[2]}:${String(second).padStart(2, "0")}`;
4291
+ }
4292
+ getUtcDayBounds(value = /* @__PURE__ */ new Date()) {
4293
+ const start = new Date(Date.UTC(value.getUTCFullYear(), value.getUTCMonth(), value.getUTCDate()));
4294
+ const end = new Date(start);
4295
+ end.setUTCDate(end.getUTCDate() + 1);
4296
+ return [start, end];
4297
+ }
4071
4298
  /**
4072
4299
  * Adds a strongly-typed equality where clause for a single attribute key.
4073
4300
  *