@kalutskii/foundation 0.6.7 → 0.6.8

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.d.ts CHANGED
@@ -11,14 +11,10 @@ import z from 'zod';
11
11
  * Assumes that `where` was already validated and contains only existing table fields.
12
12
  *
13
13
  * ```ts
14
- * await db
15
- * .update(usersTable)
16
- * .set(values)
17
- * .where(sqlWhere(usersTable, { id: 1 }))
18
- * .returning();
14
+ * await db.update(usersTable).set(values).where(sqlWhere(usersTable, { id: 1 })).returning();
19
15
  * ```
20
16
  */
21
- declare function sqlWhere(table: unknown, where: Record<string, unknown>): SQL | undefined;
17
+ declare function sqlWhere(table: unknown, where: Record<string, unknown>): SQL;
22
18
 
23
19
  /**
24
20
  * Global error handler for Hono framework. Catches all exceptions thrown in route handlers and middlewares.
package/dist/index.js CHANGED
@@ -1,7 +1,13 @@
1
1
  // src/drizzle/drizzle.refiners.ts
2
2
  import { and, eq } from "drizzle-orm";
3
+ var AT_LEAST_ONE_DEFINED_CONDITION_ERROR = "sqlWhere requires at least one defined condition.";
3
4
  function sqlWhere(table, where) {
4
- return and(...Object.entries(where).map(([key, value]) => eq(table[key], value)));
5
+ const columns = table;
6
+ const conditions = Object.entries(where).filter(([, value]) => value !== void 0).map(([key, value]) => eq(columns[key], value));
7
+ if (conditions.length === 0) {
8
+ throw new Error(AT_LEAST_ONE_DEFINED_CONDITION_ERROR);
9
+ }
10
+ return and(...conditions);
5
11
  }
6
12
 
7
13
  // src/hono/hono.execution.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.6.7",
3
+ "version": "0.6.8",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "type": "module",
6
6
  "repository": {