arkormx 2.8.1 → 2.9.1

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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as applyOperationsToPersistedColumnMappingsState, $t as resolvePrismaType, A as getRuntimePrismaClient, An as writeAppliedMigrationsStateToStore, At as buildInverseRelationLine, B as getRegisteredModels, Bt as deriveRelationFieldName, C as getActiveTransactionClient, Cn as markMigrationRun, Ct as applyMigrationRollbackToPrismaSchema, D as getRuntimeDebugHandler, Dn as resolveMigrationStateFilePath, Dt as buildEnumBlock, E as getRuntimeClient, En as removeAppliedMigration, Et as applyOperationsToPrismaSchema, F as loadArkormConfig, Fn as RelationResolutionException, Ft as buildUniqueConstraintLine, G as loadModelsFrom, Gt as formatDefaultValue, H as getRegisteredSeeders, Ht as escapeRegex, I as resetArkormRuntimeForTests, In as ArkormCollection, It as createMigrationTimestamp, J as registerMigrations, Jt as generateMigrationFile, K as loadSeedersFrom, Kt as formatEnumDefaultValue, L as runArkormTransaction, Ln as ArkormException, Lt as deriveCollectionFieldName, M as isDelegateLike, Mn as UnsupportedAdapterFeatureException, Mt as buildModelBlock, N as isQuerySchemaLike, Nn as SetBasedEagerLoader, Nt as buildPrimaryKeyLine, O as getRuntimePaginationCurrentPageResolver, On as supportsDatabaseMigrationState, Ot as buildFieldLine, P as isTransactionCapableClient, Pt as buildRelationLine, Q as resetRuntimeRegistryForTests, Qt as resolveMigrationClassName, R as getRegisteredFactories, Rt as deriveInverseRelationAlias, S as getActiveTransactionAdapter, Sn as markMigrationApplied, St as applyMigrationRollbackToDatabase, T as getRuntimeAdapter, Tn as readAppliedMigrationsStateFromStore, Tt as applyMigrationToPrismaSchema, U as loadFactoriesFrom, Ut as findEnumBlock, V as getRegisteredPaths, Vt as deriveSingularFieldName, W as loadMigrationsFrom, Wt as findModelBlock, X as registerPaths, Xt as pad, Y as registerModels, Yt as getMigrationPlan, Z as registerSeeders, Zt as resolveEnumName, _ as bindAdapterToModels, _n as deleteAppliedMigrationsStateFromStore, _t as PRISMA_ENUM_REGEX, a as HasOneThroughRelation, an as supportsDatabaseReset, at as getPersistedPrimaryKeyGeneration, b as emitRuntimeDebugEvent, bn as getLatestAppliedMigrations, bt as applyCreateTableOperation, c as HasManyRelation, cn as SchemaBuilder, ct as readPersistedColumnMappingsState, d as BelongsToManyRelation, dn as PrimaryKeyGenerationPlanner, dt as resolveColumnMappingsFilePath, en as runMigrationWithPrisma, et as createEmptyPersistedColumnMappingsState, f as Relation, fn as ForeignKeyBuilder, ft as resolvePersistedMetadataFeatures, g as awaitConfiguredModelsRegistration, gn as createEmptyAppliedMigrationsState, gt as PRISMA_ENUM_MEMBER_REGEX, h as URLDriver, hn as computeMigrationChecksum, ht as writePersistedColumnMappingsState, i as MorphManyRelation, in as supportsDatabaseMigrationExecution, it as getPersistedEnumTsType, j as getUserConfig, jn as RuntimeModuleLoader, jt as buildMigrationSource, k as getRuntimePaginationURLDriverFactory, kn as writeAppliedMigrationsState, kt as buildIndexLine, l as BelongsToRelation, ln as EnumBuilder, lt as rebuildPersistedColumnMappingsState, m as Paginator, mn as buildMigrationRunId, mt as validatePersistedMetadataFeaturesForMigrations, n as MorphToManyRelation, nn as stripPrismaSchemaModelsAndEnums, nt as getPersistedColumnMap, o as HasOneRelation, on as toMigrationFileSlug, ot as getPersistedTableMetadata, p as LengthAwarePaginator, pn as buildMigrationIdentity, pt as syncPersistedColumnMappingsFromState, q as registerFactories, qt as formatRelationAction, r as MorphOneRelation, rn as supportsDatabaseCreation, rt as getPersistedEnumMap, s as HasManyThroughRelation, sn as toModelName, st as getPersistedTimestampColumns, t as MorphToRelation, tn as runPrismaCommand, tt as deletePersistedColumnMappingsState, un as TableBuilder, ut as resetPersistedColumnMappingsCache, v as configureArkormRuntime, vn as findAppliedMigration, vt as PRISMA_MODEL_REGEX, w as getDefaultStubsPath, wn as readAppliedMigrationsState, wt as applyMigrationToDatabase, x as ensureArkormConfigLoading, xn as isMigrationApplied, xt as applyDropTableOperation, y as defineConfig, yn as getLastMigrationRun, yt as applyAlterTableOperation, z as getRegisteredMigrations, zt as deriveRelationAlias } from "./relationship--l8RA_yy.mjs";
1
+ import { $ as applyOperationsToPersistedColumnMappingsState, $t as resolvePrismaType, A as getRuntimePrismaClient, An as writeAppliedMigrationsStateToStore, At as buildInverseRelationLine, B as getRegisteredModels, Bt as deriveRelationFieldName, C as getActiveTransactionClient, Cn as markMigrationRun, Ct as applyMigrationRollbackToPrismaSchema, D as getRuntimeDebugHandler, Dn as resolveMigrationStateFilePath, Dt as buildEnumBlock, E as getRuntimeClient, En as removeAppliedMigration, Et as applyOperationsToPrismaSchema, F as loadArkormConfig, Fn as RelationResolutionException, Ft as buildUniqueConstraintLine, G as loadModelsFrom, Gt as formatDefaultValue, H as getRegisteredSeeders, Ht as escapeRegex, I as resetArkormRuntimeForTests, In as ArkormCollection, It as createMigrationTimestamp, J as registerMigrations, Jt as generateMigrationFile, K as loadSeedersFrom, Kt as formatEnumDefaultValue, L as runArkormTransaction, Ln as ArkormException, Lt as deriveCollectionFieldName, M as isDelegateLike, Mn as UnsupportedAdapterFeatureException, Mt as buildModelBlock, N as isQuerySchemaLike, Nn as SetBasedEagerLoader, Nt as buildPrimaryKeyLine, O as getRuntimePaginationCurrentPageResolver, On as supportsDatabaseMigrationState, Ot as buildFieldLine, P as isTransactionCapableClient, Pt as buildRelationLine, Q as resetRuntimeRegistryForTests, Qt as resolveMigrationClassName, R as getRegisteredFactories, Rt as deriveInverseRelationAlias, S as getActiveTransactionAdapter, Sn as markMigrationApplied, St as applyMigrationRollbackToDatabase, T as getRuntimeAdapter, Tn as readAppliedMigrationsStateFromStore, Tt as applyMigrationToPrismaSchema, U as loadFactoriesFrom, Ut as findEnumBlock, V as getRegisteredPaths, Vt as deriveSingularFieldName, W as loadMigrationsFrom, Wt as findModelBlock, X as registerPaths, Xt as pad, Y as registerModels, Yt as getMigrationPlan, Z as registerSeeders, Zt as resolveEnumName, _ as bindAdapterToModels, _n as deleteAppliedMigrationsStateFromStore, _t as PRISMA_ENUM_REGEX, a as HasOneThroughRelation, an as supportsDatabaseReset, at as getPersistedPrimaryKeyGeneration, b as emitRuntimeDebugEvent, bn as getLatestAppliedMigrations, bt as applyCreateTableOperation, c as HasManyRelation, cn as SchemaBuilder, ct as readPersistedColumnMappingsState, d as BelongsToManyRelation, dn as PrimaryKeyGenerationPlanner, dt as resolveColumnMappingsFilePath, en as runMigrationWithPrisma, et as createEmptyPersistedColumnMappingsState, f as Relation, fn as ForeignKeyBuilder, ft as resolvePersistedMetadataFeatures, g as awaitConfiguredModelsRegistration, gn as createEmptyAppliedMigrationsState, gt as PRISMA_ENUM_MEMBER_REGEX, h as URLDriver, hn as computeMigrationChecksum, ht as writePersistedColumnMappingsState, i as MorphManyRelation, in as supportsDatabaseMigrationExecution, it as getPersistedEnumTsType, j as getUserConfig, jn as RuntimeModuleLoader, jt as buildMigrationSource, k as getRuntimePaginationURLDriverFactory, kn as writeAppliedMigrationsState, kt as buildIndexLine, l as BelongsToRelation, ln as EnumBuilder, lt as rebuildPersistedColumnMappingsState, m as Paginator, mn as buildMigrationRunId, mt as validatePersistedMetadataFeaturesForMigrations, n as MorphToManyRelation, nn as stripPrismaSchemaModelsAndEnums, nt as getPersistedColumnMap, o as HasOneRelation, on as toMigrationFileSlug, ot as getPersistedTableMetadata, p as LengthAwarePaginator, pn as buildMigrationIdentity, pt as syncPersistedColumnMappingsFromState, q as registerFactories, qt as formatRelationAction, r as MorphOneRelation, rn as supportsDatabaseCreation, rt as getPersistedEnumMap, s as HasManyThroughRelation, sn as toModelName, st as getPersistedTimestampColumns, t as MorphToRelation, tn as runPrismaCommand, tt as deletePersistedColumnMappingsState, un as TableBuilder, ut as resetPersistedColumnMappingsCache, v as configureArkormRuntime, vn as findAppliedMigration, vt as PRISMA_MODEL_REGEX, w as getDefaultStubsPath, wn as readAppliedMigrationsState, wt as applyMigrationToDatabase, x as ensureArkormConfigLoading, xn as isMigrationApplied, xt as applyDropTableOperation, y as defineConfig, yn as getLastMigrationRun, yt as applyAlterTableOperation, z as getRegisteredMigrations, zt as deriveRelationAlias } from "./relationship-DtNgcxxv.mjs";
2
2
  import { Pool } from "pg";
3
3
  import { join, resolve } from "node:path";
4
4
  import { createRequire } from "module";
@@ -614,6 +614,10 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
614
614
  if (!groupBy || groupBy.length === 0) return sql``;
615
615
  return sql` group by ${sql.join(groupBy.map((column) => sql.ref(this.mapColumn(target, column))), sql`, `)}`;
616
616
  }
617
+ buildHavingClause(target, having) {
618
+ if (!having) return sql``;
619
+ return sql` having ${this.buildWhereCondition(target, having)}`;
620
+ }
617
621
  buildJoinClause(target, joins) {
618
622
  if (!joins || joins.length === 0) return sql``;
619
623
  return sql` ${sql.join(joins.map((join) => this.buildSingleJoin(target, join)), sql` `)}`;
@@ -739,6 +743,24 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
739
743
  return sql`coalesce(${sql.ref(this.mapColumn(target, column))}::text, '')`;
740
744
  }), sql` || ' ' || `)}) @@ plainto_tsquery(${language}, ${condition.value})`;
741
745
  }
746
+ buildJsonAccessor(target, column, path) {
747
+ const base = sql`${sql.ref(this.mapColumn(target, column))}::jsonb`;
748
+ if (!path || path.length === 0) return base;
749
+ return sql`(${base} #> ${`{${path.join(",")}}`}::text[])`;
750
+ }
751
+ buildJsonCondition(target, condition) {
752
+ const accessor = this.buildJsonAccessor(target, condition.column, condition.path);
753
+ if (condition.kind === "contains-key") return condition.not ? sql`${accessor} is null` : sql`${accessor} is not null`;
754
+ if (condition.kind === "length") return sql`jsonb_array_length(${accessor}) ${sql.raw(condition.operator ?? "=")} ${condition.value}`;
755
+ const jsonValue = JSON.stringify(condition.value ?? null);
756
+ if (condition.kind === "overlaps") return sql`exists (
757
+ select 1
758
+ from jsonb_array_elements(${accessor}) as _arkorm_overlap
759
+ where _arkorm_overlap in (select jsonb_array_elements(${jsonValue}::jsonb))
760
+ )`;
761
+ const contains = sql`${accessor} @> ${jsonValue}::jsonb`;
762
+ return condition.not ? sql`not (${contains})` : contains;
763
+ }
742
764
  buildWhereCondition(target, condition) {
743
765
  if (!condition) return sql`1 = 1`;
744
766
  if (condition.type === "comparison") return this.buildComparisonCondition(target, condition);
@@ -747,6 +769,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
747
769
  if (condition.type === "day") return this.buildDayCondition(target, condition);
748
770
  if (condition.type === "exists") return this.buildExistsCondition(condition);
749
771
  if (condition.type === "full-text") return this.buildFullTextCondition(target, condition);
772
+ if (condition.type === "json") return this.buildJsonCondition(target, condition);
750
773
  if (condition.type === "group") {
751
774
  const group = condition;
752
775
  const conditions = group.conditions.map((entry) => {
@@ -974,6 +997,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
974
997
  ${this.buildJoinClause(spec.target, spec.joins)}
975
998
  ${this.buildCombinedWhereClause(spec.target, spec.where, spec.relationFilters)}
976
999
  ${this.buildGroupBy(spec.target, spec.groupBy)}
1000
+ ${this.buildHavingClause(spec.target, spec.having)}
977
1001
  ${this.buildOrderBy(spec.target, spec.orderBy)}
978
1002
  ${this.buildPaginationClause(spec)}
979
1003
  `;
@@ -1723,6 +1747,10 @@ var PrismaDatabaseAdapter = class PrismaDatabaseAdapter {
1723
1747
  operation: "adapter.select",
1724
1748
  meta: { feature: "groupBy" }
1725
1749
  });
1750
+ if (spec.having) throw new UnsupportedAdapterFeatureException("Having clauses are not supported by the Prisma compatibility adapter; use a SQL-backed adapter.", {
1751
+ operation: "adapter.select",
1752
+ meta: { feature: "having" }
1753
+ });
1726
1754
  if (spec.joins?.length) throw new UnsupportedAdapterFeatureException("Join clauses are not supported by the Prisma compatibility adapter; use a SQL-backed adapter or DB.raw().", {
1727
1755
  operation: "adapter.select",
1728
1756
  meta: { feature: "joins" }
@@ -4377,24 +4405,37 @@ var QueryBuilder = class QueryBuilder {
4377
4405
  if (typeof resolvedPage !== "number" || !Number.isFinite(resolvedPage)) return 1;
4378
4406
  return Math.max(1, resolvedPage);
4379
4407
  }
4408
+ where(whereOrCallback) {
4409
+ if (typeof whereOrCallback === "function") return this.appendNestedWhere("AND", whereOrCallback);
4410
+ return this.addLogicalWhere("AND", whereOrCallback);
4411
+ }
4412
+ orWhere(whereOrCallback) {
4413
+ if (typeof whereOrCallback === "function") return this.appendNestedWhere("OR", whereOrCallback);
4414
+ return this.addLogicalWhere("OR", whereOrCallback);
4415
+ }
4380
4416
  /**
4381
- * Adds a where clause to the query. Multiple calls to where will combine
4382
- * the clauses with AND logic.
4383
- *
4384
- * @param where
4385
- * @returns
4417
+ * Resolve a callback into a parenthesized group condition and append it.
4386
4418
  */
4387
- where(where) {
4388
- return this.addLogicalWhere("AND", where);
4419
+ appendNestedWhere(boolean, callback) {
4420
+ const nested = new QueryBuilder(this.model, this.adapter);
4421
+ callback(nested);
4422
+ const condition = nested.getNestedWhereCondition();
4423
+ if (!condition) return this;
4424
+ const grouped = condition.type === "group" ? condition : {
4425
+ type: "group",
4426
+ operator: "and",
4427
+ conditions: [condition]
4428
+ };
4429
+ this.appendQueryCondition(boolean, grouped);
4430
+ return this;
4389
4431
  }
4390
4432
  /**
4391
- * Adds an OR where clause to the query.
4392
- *
4393
- * @param where
4394
- * @returns
4433
+ * Returns the user-authored where condition for nesting, excluding any
4434
+ * soft-delete predicate (the parent query owns that).
4395
4435
  */
4396
- orWhere(where) {
4397
- return this.addLogicalWhere("OR", where);
4436
+ getNestedWhereCondition() {
4437
+ if (this.legacyWhere) return this.tryBuildQueryCondition(this.legacyWhere) ?? void 0;
4438
+ return this.queryWhere;
4398
4439
  }
4399
4440
  /**
4400
4441
  * Adds a NOT where clause to the query.
@@ -4669,6 +4710,27 @@ var QueryBuilder = class QueryBuilder {
4669
4710
  return this;
4670
4711
  }
4671
4712
  /**
4713
+ * Adds an OR fulltext clause for columns that have full text indexes.
4714
+ *
4715
+ * @param columns
4716
+ * @param value
4717
+ * @param options
4718
+ * @returns
4719
+ */
4720
+ orWhereFullText(columns, value, options = {}) {
4721
+ const normalizedColumns = Array.isArray(columns) ? columns : [columns];
4722
+ if (normalizedColumns.length === 0) throw new ArkormException("orWhereFullText() expects at least one column.");
4723
+ const language = options.language ?? "simple";
4724
+ if (!/^[a-z][a-z0-9_]*$/i.test(language)) throw new ArkormException("orWhereFullText() language must be a valid PostgreSQL text search configuration name.");
4725
+ this.appendQueryCondition("OR", {
4726
+ type: "full-text",
4727
+ columns: normalizedColumns,
4728
+ value,
4729
+ language
4730
+ });
4731
+ return this;
4732
+ }
4733
+ /**
4672
4734
  * Adds a strongly-typed inequality where clause for a single attribute key.
4673
4735
  *
4674
4736
  * @param key
@@ -4709,6 +4771,188 @@ var QueryBuilder = class QueryBuilder {
4709
4771
  return this.where({ [key]: { contains: value } });
4710
4772
  }
4711
4773
  /**
4774
+ * Adds an OR string contains clause for a single attribute key.
4775
+ *
4776
+ * @param key
4777
+ * @param value
4778
+ * @returns
4779
+ */
4780
+ orWhereLike(key, value) {
4781
+ return this.orWhere({ [key]: { contains: value } });
4782
+ }
4783
+ /**
4784
+ * Adds a negated string contains (NOT LIKE) clause for a single attribute key.
4785
+ *
4786
+ * @param key
4787
+ * @param value
4788
+ * @returns
4789
+ */
4790
+ whereNotLike(key, value) {
4791
+ return this.where({ NOT: { [key]: { contains: value } } });
4792
+ }
4793
+ /**
4794
+ * Adds an OR negated string contains (NOT LIKE) clause for a single attribute key.
4795
+ *
4796
+ * @param key
4797
+ * @param value
4798
+ * @returns
4799
+ */
4800
+ orWhereNotLike(key, value) {
4801
+ return this.orWhere({ NOT: { [key]: { contains: value } } });
4802
+ }
4803
+ /**
4804
+ * Append a structured JSON predicate, splitting a `column->path->key`
4805
+ * expression into its base column and nested path segments.
4806
+ *
4807
+ * @param boolean
4808
+ * @param kind
4809
+ * @param column
4810
+ * @param options
4811
+ * @returns
4812
+ */
4813
+ appendJsonCondition(boolean, kind, column, options = {}) {
4814
+ const [base, ...path] = column.split("->").map((segment) => segment.trim());
4815
+ if (!base) throw new ArkormException("JSON where clauses require a column name.");
4816
+ this.appendQueryCondition(boolean, {
4817
+ type: "json",
4818
+ kind,
4819
+ column: base,
4820
+ path: path.length > 0 ? path : void 0,
4821
+ not: options.not,
4822
+ value: options.value,
4823
+ operator: options.operator
4824
+ });
4825
+ return this;
4826
+ }
4827
+ /**
4828
+ * Adds a clause asserting the JSON column contains the given value
4829
+ * (PostgreSQL `@>` containment).
4830
+ *
4831
+ * @param column
4832
+ * @param value
4833
+ * @returns
4834
+ */
4835
+ whereJsonContains(column, value) {
4836
+ return this.appendJsonCondition("AND", "contains", column, { value });
4837
+ }
4838
+ /**
4839
+ * OR variant of whereJsonContains().
4840
+ *
4841
+ * @param column
4842
+ * @param value
4843
+ * @returns
4844
+ */
4845
+ orWhereJsonContains(column, value) {
4846
+ return this.appendJsonCondition("OR", "contains", column, { value });
4847
+ }
4848
+ /**
4849
+ * Adds a clause asserting the JSON column does not contain the given value.
4850
+ *
4851
+ * @param column
4852
+ * @param value
4853
+ * @returns
4854
+ */
4855
+ whereJsonDoesntContain(column, value) {
4856
+ return this.appendJsonCondition("AND", "contains", column, {
4857
+ value,
4858
+ not: true
4859
+ });
4860
+ }
4861
+ /**
4862
+ * OR variant of whereJsonDoesntContain().
4863
+ *
4864
+ * @param column
4865
+ * @param value
4866
+ * @returns
4867
+ */
4868
+ orWhereJsonDoesntContain(column, value) {
4869
+ return this.appendJsonCondition("OR", "contains", column, {
4870
+ value,
4871
+ not: true
4872
+ });
4873
+ }
4874
+ /**
4875
+ * Adds a clause asserting the JSON document contains the given key/path.
4876
+ *
4877
+ * @param column
4878
+ * @returns
4879
+ */
4880
+ whereJsonContainsKey(column) {
4881
+ return this.appendJsonCondition("AND", "contains-key", column);
4882
+ }
4883
+ /**
4884
+ * OR variant of whereJsonContainsKey().
4885
+ *
4886
+ * @param column
4887
+ * @returns
4888
+ */
4889
+ orWhereJsonContainsKey(column) {
4890
+ return this.appendJsonCondition("OR", "contains-key", column);
4891
+ }
4892
+ /**
4893
+ * Adds a clause asserting the JSON document does not contain the given key/path.
4894
+ *
4895
+ * @param column
4896
+ * @returns
4897
+ */
4898
+ whereJsonDoesntContainKey(column) {
4899
+ return this.appendJsonCondition("AND", "contains-key", column, { not: true });
4900
+ }
4901
+ /**
4902
+ * OR variant of whereJsonDoesntContainKey().
4903
+ *
4904
+ * @param column
4905
+ * @returns
4906
+ */
4907
+ orWhereJsonDoesntContainKey(column) {
4908
+ return this.appendJsonCondition("OR", "contains-key", column, { not: true });
4909
+ }
4910
+ whereJsonLength(column, operatorOrValue, maybeValue) {
4911
+ const { operator, value } = this.resolveJsonLengthArgs(operatorOrValue, maybeValue);
4912
+ return this.appendJsonCondition("AND", "length", column, {
4913
+ operator,
4914
+ value
4915
+ });
4916
+ }
4917
+ orWhereJsonLength(column, operatorOrValue, maybeValue) {
4918
+ const { operator, value } = this.resolveJsonLengthArgs(operatorOrValue, maybeValue);
4919
+ return this.appendJsonCondition("OR", "length", column, {
4920
+ operator,
4921
+ value
4922
+ });
4923
+ }
4924
+ resolveJsonLengthArgs(operatorOrValue, maybeValue) {
4925
+ const hasOperator = maybeValue !== void 0;
4926
+ const operator = hasOperator ? operatorOrValue : "=";
4927
+ const value = hasOperator ? maybeValue : operatorOrValue;
4928
+ if (!Number.isInteger(value) || value < 0) throw new ArkormException("whereJsonLength() expects a non-negative integer length.");
4929
+ return {
4930
+ operator,
4931
+ value
4932
+ };
4933
+ }
4934
+ /**
4935
+ * Adds a clause asserting the JSON array column overlaps with the given
4936
+ * array (shares at least one element).
4937
+ *
4938
+ * @param column
4939
+ * @param value
4940
+ * @returns
4941
+ */
4942
+ whereJsonOverlaps(column, value) {
4943
+ return this.appendJsonCondition("AND", "overlaps", column, { value });
4944
+ }
4945
+ /**
4946
+ * OR variant of whereJsonOverlaps().
4947
+ *
4948
+ * @param column
4949
+ * @param value
4950
+ * @returns
4951
+ */
4952
+ orWhereJsonOverlaps(column, value) {
4953
+ return this.appendJsonCondition("OR", "overlaps", column, { value });
4954
+ }
4955
+ /**
4712
4956
  * Adds a string starts-with clause for a single attribute key.
4713
4957
  *
4714
4958
  * @param key
@@ -5253,6 +5497,65 @@ var QueryBuilder = class QueryBuilder {
5253
5497
  this.queryGroupBy = [...normalized];
5254
5498
  return this;
5255
5499
  }
5500
+ appendHavingCondition(boolean, condition) {
5501
+ if (!this.queryHaving) {
5502
+ this.queryHaving = condition;
5503
+ return;
5504
+ }
5505
+ this.queryHaving = {
5506
+ type: "group",
5507
+ operator: boolean === "AND" ? "and" : "or",
5508
+ conditions: [this.queryHaving, condition]
5509
+ };
5510
+ }
5511
+ buildHavingComparison(operatorOrValue, maybeValue, column) {
5512
+ const hasOperator = maybeValue !== void 0;
5513
+ return {
5514
+ type: "comparison",
5515
+ column,
5516
+ operator: hasOperator ? operatorOrValue : "=",
5517
+ value: hasOperator ? maybeValue : operatorOrValue
5518
+ };
5519
+ }
5520
+ having(column, operatorOrValue, maybeValue) {
5521
+ this.appendHavingCondition("AND", this.buildHavingComparison(operatorOrValue, maybeValue, column));
5522
+ return this;
5523
+ }
5524
+ orHaving(column, operatorOrValue, maybeValue) {
5525
+ this.appendHavingCondition("OR", this.buildHavingComparison(operatorOrValue, maybeValue, column));
5526
+ return this;
5527
+ }
5528
+ /**
5529
+ * Adds a raw HAVING clause, useful for filtering on aggregate expressions
5530
+ * such as `count(*)`. Combines with previous HAVING clauses using AND.
5531
+ *
5532
+ * @param sql
5533
+ * @param bindings
5534
+ * @returns
5535
+ */
5536
+ havingRaw(sql, bindings = []) {
5537
+ this.appendHavingCondition("AND", {
5538
+ type: "raw",
5539
+ sql,
5540
+ bindings
5541
+ });
5542
+ return this;
5543
+ }
5544
+ /**
5545
+ * Adds a raw OR HAVING clause.
5546
+ *
5547
+ * @param sql
5548
+ * @param bindings
5549
+ * @returns
5550
+ */
5551
+ orHavingRaw(sql, bindings = []) {
5552
+ this.appendHavingCondition("OR", {
5553
+ type: "raw",
5554
+ sql,
5555
+ bindings
5556
+ });
5557
+ return this;
5558
+ }
5256
5559
  /**
5257
5560
  * Adds a join clause to the query.
5258
5561
  *
@@ -6305,6 +6608,7 @@ var QueryBuilder = class QueryBuilder {
6305
6608
  builder.querySelect = this.querySelect ? [...this.querySelect] : void 0;
6306
6609
  builder.queryDistinct = this.queryDistinct;
6307
6610
  builder.queryGroupBy = this.queryGroupBy ? [...this.queryGroupBy] : void 0;
6611
+ builder.queryHaving = this.queryHaving;
6308
6612
  builder.offsetValue = this.offsetValue;
6309
6613
  builder.limitValue = this.limitValue;
6310
6614
  builder.includeTrashed = this.includeTrashed;
@@ -6829,6 +7133,7 @@ var QueryBuilder = class QueryBuilder {
6829
7133
  columns,
6830
7134
  distinct: this.queryDistinct || void 0,
6831
7135
  groupBy: this.queryGroupBy ? [...this.queryGroupBy] : void 0,
7136
+ having: this.queryHaving,
6832
7137
  joins: this.queryJoins ? [...this.queryJoins] : void 0,
6833
7138
  where: condition,
6834
7139
  orderBy,
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
- const require_relationship = require('../relationship-WiXlopzY.cjs');
2
+ const require_relationship = require('../relationship-BVYP9lU2.cjs');
3
3
 
4
4
  exports.BelongsToManyRelation = require_relationship.BelongsToManyRelation;
5
5
  exports.BelongsToRelation = require_relationship.BelongsToRelation;
@@ -1,2 +1,2 @@
1
- import { Ao as MorphManyRelation, Do as MorphToRelation, Eo as SetBasedEagerLoader, Fo as BelongsToRelation, Io as SingleResultRelation, Lo as BelongsToManyRelation, Mo as HasOneRelation, No as HasManyThroughRelation, Oo as MorphToManyRelation, Po as HasManyRelation, Ro as Relation, jo as HasOneThroughRelation, ko as MorphOneRelation, zo as RelationTableLoader } from "../index-4mi5sLRA.cjs";
1
+ import { Ao as HasOneRelation, Do as MorphOneRelation, Eo as MorphToManyRelation, Fo as BelongsToManyRelation, Io as Relation, Lo as RelationTableLoader, Mo as HasManyRelation, No as BelongsToRelation, Oo as MorphManyRelation, Po as SingleResultRelation, To as MorphToRelation, jo as HasManyThroughRelation, ko as HasOneThroughRelation, wo as SetBasedEagerLoader } from "../index-18M5gEFk.cjs";
2
2
  export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -1,2 +1,2 @@
1
- import { Ao as MorphManyRelation, Do as MorphToRelation, Eo as SetBasedEagerLoader, Fo as BelongsToRelation, Io as SingleResultRelation, Lo as BelongsToManyRelation, Mo as HasOneRelation, No as HasManyThroughRelation, Oo as MorphToManyRelation, Po as HasManyRelation, Ro as Relation, jo as HasOneThroughRelation, ko as MorphOneRelation, zo as RelationTableLoader } from "../index-De8zXqTD.mjs";
1
+ import { Ao as HasOneRelation, Do as MorphOneRelation, Eo as MorphToManyRelation, Fo as BelongsToManyRelation, Io as Relation, Lo as RelationTableLoader, Mo as HasManyRelation, No as BelongsToRelation, Oo as MorphManyRelation, Po as SingleResultRelation, To as MorphToRelation, jo as HasManyThroughRelation, ko as HasOneThroughRelation, wo as SetBasedEagerLoader } from "../index-CFXreeV7.mjs";
2
2
  export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -1,3 +1,3 @@
1
- import { Nn as SetBasedEagerLoader, Pn as RelationTableLoader, a as HasOneThroughRelation, c as HasManyRelation, d as BelongsToManyRelation, f as Relation, i as MorphManyRelation, l as BelongsToRelation, n as MorphToManyRelation, o as HasOneRelation, r as MorphOneRelation, s as HasManyThroughRelation, t as MorphToRelation, u as SingleResultRelation } from "../relationship--l8RA_yy.mjs";
1
+ import { Nn as SetBasedEagerLoader, Pn as RelationTableLoader, a as HasOneThroughRelation, c as HasManyRelation, d as BelongsToManyRelation, f as Relation, i as MorphManyRelation, l as BelongsToRelation, n as MorphToManyRelation, o as HasOneRelation, r as MorphOneRelation, s as HasManyThroughRelation, t as MorphToRelation, u as SingleResultRelation } from "../relationship-DtNgcxxv.mjs";
2
2
 
3
3
  export { BelongsToManyRelation, BelongsToRelation, HasManyRelation, HasManyThroughRelation, HasOneRelation, HasOneThroughRelation, MorphManyRelation, MorphOneRelation, MorphToManyRelation, MorphToRelation, Relation, RelationTableLoader, SetBasedEagerLoader, SingleResultRelation };
@@ -4015,6 +4015,17 @@ var Relation = class {
4015
4015
  return this.constrain((query) => query.whereFullText(columns, value, options));
4016
4016
  }
4017
4017
  /**
4018
+ * Add an OR fulltext clause to the relationship query.
4019
+ *
4020
+ * @param columns
4021
+ * @param value
4022
+ * @param options
4023
+ * @returns
4024
+ */
4025
+ orWhereFullText(columns, value, options = {}) {
4026
+ return this.constrain((query) => query.orWhereFullText(columns, value, options));
4027
+ }
4028
+ /**
4018
4029
  * Add a strongly-typed where key clause to the relationship query.
4019
4030
  *
4020
4031
  * @param key
@@ -4085,6 +4096,155 @@ var Relation = class {
4085
4096
  return this.constrain((query) => query.whereLike(key, value));
4086
4097
  }
4087
4098
  /**
4099
+ * Add an OR string contains clause to the relationship query.
4100
+ *
4101
+ * @param key
4102
+ * @param value
4103
+ * @returns
4104
+ */
4105
+ orWhereLike(key, value) {
4106
+ return this.constrain((query) => query.orWhereLike(key, value));
4107
+ }
4108
+ /**
4109
+ * Add a negated string contains (NOT LIKE) clause to the relationship query.
4110
+ *
4111
+ * @param key
4112
+ * @param value
4113
+ * @returns
4114
+ */
4115
+ whereNotLike(key, value) {
4116
+ return this.constrain((query) => query.whereNotLike(key, value));
4117
+ }
4118
+ /**
4119
+ * Add an OR negated string contains (NOT LIKE) clause to the relationship query.
4120
+ *
4121
+ * @param key
4122
+ * @param value
4123
+ * @returns
4124
+ */
4125
+ orWhereNotLike(key, value) {
4126
+ return this.constrain((query) => query.orWhereNotLike(key, value));
4127
+ }
4128
+ /**
4129
+ * Add a JSON containment clause to the relationship query.
4130
+ *
4131
+ * @param key
4132
+ * @param value
4133
+ * @returns
4134
+ */
4135
+ whereJsonContains(column, value) {
4136
+ return this.constrain((query) => query.whereJsonContains(column, value));
4137
+ }
4138
+ /**
4139
+ * OR variant of whereJsonContains().
4140
+ *
4141
+ * @param column
4142
+ * @param value
4143
+ * @returns
4144
+ */
4145
+ orWhereJsonContains(column, value) {
4146
+ return this.constrain((query) => query.orWhereJsonContains(column, value));
4147
+ }
4148
+ /**
4149
+ * Add a negated JSON containment clause to the relationship query.
4150
+ *
4151
+ * @param column
4152
+ * @param value
4153
+ * @returns
4154
+ */
4155
+ whereJsonDoesntContain(column, value) {
4156
+ return this.constrain((query) => query.whereJsonDoesntContain(column, value));
4157
+ }
4158
+ /**
4159
+ * OR variant of whereJsonDoesntContain().
4160
+ *
4161
+ * @param column
4162
+ * @param value
4163
+ * @returns
4164
+ */
4165
+ orWhereJsonDoesntContain(column, value) {
4166
+ return this.constrain((query) => query.orWhereJsonDoesntContain(column, value));
4167
+ }
4168
+ /**
4169
+ * Add a JSON key-existence clause to the relationship query.
4170
+ *
4171
+ * @param column
4172
+ * @param value
4173
+ * @returns
4174
+ */
4175
+ whereJsonContainsKey(column) {
4176
+ return this.constrain((query) => query.whereJsonContainsKey(column));
4177
+ }
4178
+ /**
4179
+ * OR variant of whereJsonContainsKey().
4180
+ *
4181
+ * @param column
4182
+ * @returns
4183
+ */
4184
+ orWhereJsonContainsKey(column) {
4185
+ return this.constrain((query) => query.orWhereJsonContainsKey(column));
4186
+ }
4187
+ /**
4188
+ * Add a negated JSON key-existence clause to the relationship query.
4189
+ *
4190
+ * @param column
4191
+ * @returns
4192
+ */
4193
+ whereJsonDoesntContainKey(column) {
4194
+ return this.constrain((query) => query.whereJsonDoesntContainKey(column));
4195
+ }
4196
+ /**
4197
+ * OR variant of whereJsonDoesntContainKey().
4198
+ *
4199
+ * @param column
4200
+ * @returns
4201
+ */
4202
+ orWhereJsonDoesntContainKey(column) {
4203
+ return this.constrain((query) => query.orWhereJsonDoesntContainKey(column));
4204
+ }
4205
+ whereJsonLength(column, operatorOrValue, maybeValue) {
4206
+ return this.constrain((query) => maybeValue === void 0 ? query.whereJsonLength(column, operatorOrValue) : query.whereJsonLength(column, operatorOrValue, maybeValue));
4207
+ }
4208
+ orWhereJsonLength(column, operatorOrValue, maybeValue) {
4209
+ return this.constrain((query) => maybeValue === void 0 ? query.orWhereJsonLength(column, operatorOrValue) : query.orWhereJsonLength(column, operatorOrValue, maybeValue));
4210
+ }
4211
+ /**
4212
+ * Add a JSON array overlap clause to the relationship query.
4213
+ *
4214
+ * @param column
4215
+ * @param value
4216
+ */
4217
+ whereJsonOverlaps(column, value) {
4218
+ return this.constrain((query) => query.whereJsonOverlaps(column, value));
4219
+ }
4220
+ /**
4221
+ * OR variant of whereJsonOverlaps().
4222
+ *
4223
+ * @param column
4224
+ * @param value
4225
+ */
4226
+ orWhereJsonOverlaps(column, value) {
4227
+ return this.constrain((query) => query.orWhereJsonOverlaps(column, value));
4228
+ }
4229
+ having(column, operatorOrValue, maybeValue) {
4230
+ return this.constrain((query) => maybeValue === void 0 ? query.having(column, operatorOrValue) : query.having(column, operatorOrValue, maybeValue));
4231
+ }
4232
+ orHaving(column, operatorOrValue, maybeValue) {
4233
+ return this.constrain((query) => maybeValue === void 0 ? query.orHaving(column, operatorOrValue) : query.orHaving(column, operatorOrValue, maybeValue));
4234
+ }
4235
+ /**
4236
+ * Add a raw HAVING clause to the relationship query.
4237
+ */
4238
+ havingRaw(sql, bindings = []) {
4239
+ return this.constrain((query) => query.havingRaw(sql, bindings));
4240
+ }
4241
+ /**
4242
+ * Add a raw OR HAVING clause to the relationship query.
4243
+ */
4244
+ orHavingRaw(sql, bindings = []) {
4245
+ return this.constrain((query) => query.orHavingRaw(sql, bindings));
4246
+ }
4247
+ /**
4088
4248
  * Add a string starts-with clause to the relationship query.
4089
4249
  *
4090
4250
  * @param key