@kalutskii/foundation 0.6.6 → 0.6.7
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 +18 -1
- package/dist/index.js +7 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,25 @@
|
|
|
1
|
+
import { SQL } from 'drizzle-orm';
|
|
1
2
|
import { ErrorHandler, MiddlewareHandler, Context, TypedResponse } from 'hono';
|
|
2
3
|
import { Locale } from 'date-fns';
|
|
3
4
|
import { SymmetricAlgorithm } from 'hono/utils/jwt/jwa';
|
|
4
5
|
import z from 'zod';
|
|
5
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Builds a Drizzle SQL `where` condition from a plain object.
|
|
9
|
+
*
|
|
10
|
+
* Maps each `where` entry to `eq(table[key], value)` and combines them with `and`.
|
|
11
|
+
* Assumes that `where` was already validated and contains only existing table fields.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* await db
|
|
15
|
+
* .update(usersTable)
|
|
16
|
+
* .set(values)
|
|
17
|
+
* .where(sqlWhere(usersTable, { id: 1 }))
|
|
18
|
+
* .returning();
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
declare function sqlWhere(table: unknown, where: Record<string, unknown>): SQL | undefined;
|
|
22
|
+
|
|
6
23
|
/**
|
|
7
24
|
* Global error handler for Hono framework. Catches all exceptions thrown in route handlers and middlewares.
|
|
8
25
|
* Distinguishes between expected HTTPExceptions (mapped to their status codes) and unexpected errors (500).
|
|
@@ -321,4 +338,4 @@ declare const refinePagination: (options?: ZodPaginationOptions) => ZodPaginatio
|
|
|
321
338
|
*/
|
|
322
339
|
declare const asQuery: <T extends z.ZodTypeAny>(schema: T) => z.ZodPreprocess<T>;
|
|
323
340
|
|
|
324
|
-
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, SUCCESS_STATUS_CODES, type Simplify, type SuccessStatusCode, ZodJWTService, type ZodPaginationOptions, asQuery, failure, fetchAndThrow, fetchSafely, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, log, measureExecutionTime, onHandlerError, refinePagination, respond, safeExecute, success, zodPaginationSchema, zodPaginationShape };
|
|
341
|
+
export { type APIContractData, type APIContractError, type APIContractResult, type APIError, type APISuccess, type AsQuery, type AtLeastOne, EXCEPTION_STATUS_CODES, type ExceptionStatusCode, type FetchResult, type JWTServiceOptions, type JWTSignOptions, type MeasuredExecution, type Payload, type PayloadSchema, SUCCESS_STATUS_CODES, type Simplify, type SuccessStatusCode, ZodJWTService, type ZodPaginationOptions, asQuery, failure, fetchAndThrow, fetchSafely, formatTime, generateRandomString, getColoredHTTPStatus, getFormattedDate, getFormattedTime, getUTCOffset, getZonedTime, honoLoggingHandler, log, measureExecutionTime, onHandlerError, refinePagination, respond, safeExecute, sqlWhere, success, zodPaginationSchema, zodPaginationShape };
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
// src/drizzle/drizzle.refiners.ts
|
|
2
|
+
import { and, eq } from "drizzle-orm";
|
|
3
|
+
function sqlWhere(table, where) {
|
|
4
|
+
return and(...Object.entries(where).map(([key, value]) => eq(table[key], value)));
|
|
5
|
+
}
|
|
6
|
+
|
|
1
7
|
// src/hono/hono.execution.ts
|
|
2
8
|
import { HTTPException } from "hono/http-exception";
|
|
3
9
|
import { red as red2 } from "kleur/colors";
|
|
@@ -255,6 +261,7 @@ export {
|
|
|
255
261
|
refinePagination,
|
|
256
262
|
respond,
|
|
257
263
|
safeExecute,
|
|
264
|
+
sqlWhere,
|
|
258
265
|
success,
|
|
259
266
|
zodPaginationSchema,
|
|
260
267
|
zodPaginationShape
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kalutskii/foundation",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.7",
|
|
4
4
|
"description": "Typescript collection of most common utilities, schemas and functions among private projects.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
"@hono/zod-validator": "^0.8.0",
|
|
30
30
|
"date-fns": "^4.1.0",
|
|
31
31
|
"date-fns-tz": "^3.2.0",
|
|
32
|
+
"drizzle-orm": "^1.0.0-beta.22",
|
|
32
33
|
"hono": "^4.12.18",
|
|
33
34
|
"kleur": "^4.1.5",
|
|
34
35
|
"typescript": "^5",
|