arkormx 2.0.0-next.21 → 2.0.0-next.22

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.cjs CHANGED
@@ -2384,7 +2384,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
2384
2384
  relationLoads: false,
2385
2385
  relationAggregates: true,
2386
2386
  relationFilters: true,
2387
- rawWhere: false
2387
+ rawWhere: true
2388
2388
  };
2389
2389
  constructor(db, mapping = {}) {
2390
2390
  this.db = db;
@@ -2669,6 +2669,18 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
2669
2669
  if (condition.operator === "ends-with") return kysely.sql`${column} like ${`%${String(condition.value ?? "")}`}`;
2670
2670
  return kysely.sql`${column} ${condition.operator === "!=" ? kysely.sql.raw("!=") : kysely.sql.raw(condition.operator)} ${condition.value}`;
2671
2671
  }
2672
+ buildRawWhereCondition(condition) {
2673
+ const segments = condition.sql.split("?");
2674
+ const bindings = condition.bindings ?? [];
2675
+ if (segments.length !== bindings.length + 1) throw new ArkormException("Raw where bindings do not match the number of placeholders.");
2676
+ const parts = [];
2677
+ segments.forEach((segment, index) => {
2678
+ if (segment.length > 0) parts.push(kysely.sql.raw(segment));
2679
+ if (index < bindings.length) parts.push(kysely.sql`${bindings[index]}`);
2680
+ });
2681
+ if (parts.length === 0) return kysely.sql`1 = 1`;
2682
+ return kysely.sql`${kysely.sql.join(parts, kysely.sql``)}`;
2683
+ }
2672
2684
  buildWhereCondition(target, condition) {
2673
2685
  if (!condition) return kysely.sql`1 = 1`;
2674
2686
  if (condition.type === "comparison") return this.buildComparisonCondition(target, condition);
@@ -2685,13 +2697,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
2685
2697
  const notCondition = condition;
2686
2698
  return kysely.sql`not (${this.buildWhereCondition(target, notCondition.condition)})`;
2687
2699
  }
2688
- throw new UnsupportedAdapterFeatureException("Raw where clauses are not supported by the Kysely adapter.", {
2689
- operation: "adapter.where",
2690
- meta: {
2691
- feature: "rawWhere",
2692
- sql: condition.sql
2693
- }
2694
- });
2700
+ return this.buildRawWhereCondition(condition);
2695
2701
  }
2696
2702
  buildWhereClause(target, condition) {
2697
2703
  if (!condition) return kysely.sql``;
@@ -6701,6 +6707,36 @@ var QueryBuilder = class QueryBuilder {
6701
6707
  return this.where({ [key]: { notIn: values } });
6702
6708
  }
6703
6709
  /**
6710
+ * Adds a string contains clause for a single attribute key.
6711
+ *
6712
+ * @param key
6713
+ * @param value
6714
+ * @returns
6715
+ */
6716
+ whereLike(key, value) {
6717
+ return this.where({ [key]: { contains: value } });
6718
+ }
6719
+ /**
6720
+ * Adds a string starts-with clause for a single attribute key.
6721
+ *
6722
+ * @param key
6723
+ * @param value
6724
+ * @returns
6725
+ */
6726
+ whereStartsWith(key, value) {
6727
+ return this.where({ [key]: { startsWith: value } });
6728
+ }
6729
+ /**
6730
+ * Adds a string ends-with clause for a single attribute key.
6731
+ *
6732
+ * @param key
6733
+ * @param value
6734
+ * @returns
6735
+ */
6736
+ whereEndsWith(key, value) {
6737
+ return this.where({ [key]: { endsWith: value } });
6738
+ }
6739
+ /**
6704
6740
  * Adds a strongly-typed OR NOT IN where clause for a single attribute key.
6705
6741
  *
6706
6742
  * @param key
@@ -8825,6 +8861,36 @@ var Relation = class {
8825
8861
  return this.constrain((query) => query.whereIn(key, values));
8826
8862
  }
8827
8863
  /**
8864
+ * Add a string contains clause to the relationship query.
8865
+ *
8866
+ * @param key
8867
+ * @param value
8868
+ * @returns
8869
+ */
8870
+ whereLike(key, value) {
8871
+ return this.constrain((query) => query.whereLike(key, value));
8872
+ }
8873
+ /**
8874
+ * Add a string starts-with clause to the relationship query.
8875
+ *
8876
+ * @param key
8877
+ * @param value
8878
+ * @returns
8879
+ */
8880
+ whereStartsWith(key, value) {
8881
+ return this.constrain((query) => query.whereStartsWith(key, value));
8882
+ }
8883
+ /**
8884
+ * Add a string ends-with clause to the relationship query.
8885
+ *
8886
+ * @param key
8887
+ * @param value
8888
+ * @returns
8889
+ */
8890
+ whereEndsWith(key, value) {
8891
+ return this.constrain((query) => query.whereEndsWith(key, value));
8892
+ }
8893
+ /**
8828
8894
  * Add an order by clause to the relationship query.
8829
8895
  *
8830
8896
  * @param orderBy
package/dist/index.d.cts CHANGED
@@ -554,6 +554,30 @@ declare abstract class Relation<TModel> {
554
554
  * @returns
555
555
  */
556
556
  whereIn<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, values: ModelAttributes<TModel>[TKey][]): this;
557
+ /**
558
+ * Add a string contains clause to the relationship query.
559
+ *
560
+ * @param key
561
+ * @param value
562
+ * @returns
563
+ */
564
+ whereLike<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
565
+ /**
566
+ * Add a string starts-with clause to the relationship query.
567
+ *
568
+ * @param key
569
+ * @param value
570
+ * @returns
571
+ */
572
+ whereStartsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
573
+ /**
574
+ * Add a string ends-with clause to the relationship query.
575
+ *
576
+ * @param key
577
+ * @param value
578
+ * @returns
579
+ */
580
+ whereEndsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
557
581
  /**
558
582
  * Add an order by clause to the relationship query.
559
583
  *
@@ -2176,6 +2200,30 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
2176
2200
  * @returns
2177
2201
  */
2178
2202
  whereNotIn<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, values: ModelAttributes<TModel>[TKey][]): this;
2203
+ /**
2204
+ * Adds a string contains clause for a single attribute key.
2205
+ *
2206
+ * @param key
2207
+ * @param value
2208
+ * @returns
2209
+ */
2210
+ whereLike<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
2211
+ /**
2212
+ * Adds a string starts-with clause for a single attribute key.
2213
+ *
2214
+ * @param key
2215
+ * @param value
2216
+ * @returns
2217
+ */
2218
+ whereStartsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
2219
+ /**
2220
+ * Adds a string ends-with clause for a single attribute key.
2221
+ *
2222
+ * @param key
2223
+ * @param value
2224
+ * @returns
2225
+ */
2226
+ whereEndsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
2179
2227
  /**
2180
2228
  * Adds a strongly-typed OR NOT IN where clause for a single attribute key.
2181
2229
  *
@@ -3162,6 +3210,7 @@ declare class KyselyDatabaseAdapter implements DatabaseAdapter {
3162
3210
  private buildOrderBy;
3163
3211
  private buildConditionValueList;
3164
3212
  private buildComparisonCondition;
3213
+ private buildRawWhereCondition;
3165
3214
  private buildWhereCondition;
3166
3215
  private buildWhereClause;
3167
3216
  private buildPaginationClause;
package/dist/index.d.mts CHANGED
@@ -554,6 +554,30 @@ declare abstract class Relation<TModel> {
554
554
  * @returns
555
555
  */
556
556
  whereIn<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, values: ModelAttributes<TModel>[TKey][]): this;
557
+ /**
558
+ * Add a string contains clause to the relationship query.
559
+ *
560
+ * @param key
561
+ * @param value
562
+ * @returns
563
+ */
564
+ whereLike<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
565
+ /**
566
+ * Add a string starts-with clause to the relationship query.
567
+ *
568
+ * @param key
569
+ * @param value
570
+ * @returns
571
+ */
572
+ whereStartsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
573
+ /**
574
+ * Add a string ends-with clause to the relationship query.
575
+ *
576
+ * @param key
577
+ * @param value
578
+ * @returns
579
+ */
580
+ whereEndsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
557
581
  /**
558
582
  * Add an order by clause to the relationship query.
559
583
  *
@@ -2176,6 +2200,30 @@ declare class QueryBuilder<TModel, TDelegate extends PrismaDelegateLike = Prisma
2176
2200
  * @returns
2177
2201
  */
2178
2202
  whereNotIn<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, values: ModelAttributes<TModel>[TKey][]): this;
2203
+ /**
2204
+ * Adds a string contains clause for a single attribute key.
2205
+ *
2206
+ * @param key
2207
+ * @param value
2208
+ * @returns
2209
+ */
2210
+ whereLike<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
2211
+ /**
2212
+ * Adds a string starts-with clause for a single attribute key.
2213
+ *
2214
+ * @param key
2215
+ * @param value
2216
+ * @returns
2217
+ */
2218
+ whereStartsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
2219
+ /**
2220
+ * Adds a string ends-with clause for a single attribute key.
2221
+ *
2222
+ * @param key
2223
+ * @param value
2224
+ * @returns
2225
+ */
2226
+ whereEndsWith<TKey extends keyof ModelAttributes<TModel> & string>(key: TKey, value: Extract<ModelAttributes<TModel>[TKey], string>): this;
2179
2227
  /**
2180
2228
  * Adds a strongly-typed OR NOT IN where clause for a single attribute key.
2181
2229
  *
@@ -3162,6 +3210,7 @@ declare class KyselyDatabaseAdapter implements DatabaseAdapter {
3162
3210
  private buildOrderBy;
3163
3211
  private buildConditionValueList;
3164
3212
  private buildComparisonCondition;
3213
+ private buildRawWhereCondition;
3165
3214
  private buildWhereCondition;
3166
3215
  private buildWhereClause;
3167
3216
  private buildPaginationClause;
package/dist/index.mjs CHANGED
@@ -2355,7 +2355,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
2355
2355
  relationLoads: false,
2356
2356
  relationAggregates: true,
2357
2357
  relationFilters: true,
2358
- rawWhere: false
2358
+ rawWhere: true
2359
2359
  };
2360
2360
  constructor(db, mapping = {}) {
2361
2361
  this.db = db;
@@ -2640,6 +2640,18 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
2640
2640
  if (condition.operator === "ends-with") return sql`${column} like ${`%${String(condition.value ?? "")}`}`;
2641
2641
  return sql`${column} ${condition.operator === "!=" ? sql.raw("!=") : sql.raw(condition.operator)} ${condition.value}`;
2642
2642
  }
2643
+ buildRawWhereCondition(condition) {
2644
+ const segments = condition.sql.split("?");
2645
+ const bindings = condition.bindings ?? [];
2646
+ if (segments.length !== bindings.length + 1) throw new ArkormException("Raw where bindings do not match the number of placeholders.");
2647
+ const parts = [];
2648
+ segments.forEach((segment, index) => {
2649
+ if (segment.length > 0) parts.push(sql.raw(segment));
2650
+ if (index < bindings.length) parts.push(sql`${bindings[index]}`);
2651
+ });
2652
+ if (parts.length === 0) return sql`1 = 1`;
2653
+ return sql`${sql.join(parts, sql``)}`;
2654
+ }
2643
2655
  buildWhereCondition(target, condition) {
2644
2656
  if (!condition) return sql`1 = 1`;
2645
2657
  if (condition.type === "comparison") return this.buildComparisonCondition(target, condition);
@@ -2656,13 +2668,7 @@ var KyselyDatabaseAdapter = class KyselyDatabaseAdapter {
2656
2668
  const notCondition = condition;
2657
2669
  return sql`not (${this.buildWhereCondition(target, notCondition.condition)})`;
2658
2670
  }
2659
- throw new UnsupportedAdapterFeatureException("Raw where clauses are not supported by the Kysely adapter.", {
2660
- operation: "adapter.where",
2661
- meta: {
2662
- feature: "rawWhere",
2663
- sql: condition.sql
2664
- }
2665
- });
2671
+ return this.buildRawWhereCondition(condition);
2666
2672
  }
2667
2673
  buildWhereClause(target, condition) {
2668
2674
  if (!condition) return sql``;
@@ -6672,6 +6678,36 @@ var QueryBuilder = class QueryBuilder {
6672
6678
  return this.where({ [key]: { notIn: values } });
6673
6679
  }
6674
6680
  /**
6681
+ * Adds a string contains clause for a single attribute key.
6682
+ *
6683
+ * @param key
6684
+ * @param value
6685
+ * @returns
6686
+ */
6687
+ whereLike(key, value) {
6688
+ return this.where({ [key]: { contains: value } });
6689
+ }
6690
+ /**
6691
+ * Adds a string starts-with clause for a single attribute key.
6692
+ *
6693
+ * @param key
6694
+ * @param value
6695
+ * @returns
6696
+ */
6697
+ whereStartsWith(key, value) {
6698
+ return this.where({ [key]: { startsWith: value } });
6699
+ }
6700
+ /**
6701
+ * Adds a string ends-with clause for a single attribute key.
6702
+ *
6703
+ * @param key
6704
+ * @param value
6705
+ * @returns
6706
+ */
6707
+ whereEndsWith(key, value) {
6708
+ return this.where({ [key]: { endsWith: value } });
6709
+ }
6710
+ /**
6675
6711
  * Adds a strongly-typed OR NOT IN where clause for a single attribute key.
6676
6712
  *
6677
6713
  * @param key
@@ -8796,6 +8832,36 @@ var Relation = class {
8796
8832
  return this.constrain((query) => query.whereIn(key, values));
8797
8833
  }
8798
8834
  /**
8835
+ * Add a string contains clause to the relationship query.
8836
+ *
8837
+ * @param key
8838
+ * @param value
8839
+ * @returns
8840
+ */
8841
+ whereLike(key, value) {
8842
+ return this.constrain((query) => query.whereLike(key, value));
8843
+ }
8844
+ /**
8845
+ * Add a string starts-with clause to the relationship query.
8846
+ *
8847
+ * @param key
8848
+ * @param value
8849
+ * @returns
8850
+ */
8851
+ whereStartsWith(key, value) {
8852
+ return this.constrain((query) => query.whereStartsWith(key, value));
8853
+ }
8854
+ /**
8855
+ * Add a string ends-with clause to the relationship query.
8856
+ *
8857
+ * @param key
8858
+ * @param value
8859
+ * @returns
8860
+ */
8861
+ whereEndsWith(key, value) {
8862
+ return this.constrain((query) => query.whereEndsWith(key, value));
8863
+ }
8864
+ /**
8799
8865
  * Add an order by clause to the relationship query.
8800
8866
  *
8801
8867
  * @param orderBy
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arkormx",
3
- "version": "2.0.0-next.21",
3
+ "version": "2.0.0-next.22",
4
4
  "description": "Modern TypeScript-first ORM for Node.js.",
5
5
  "keywords": [
6
6
  "orm",