@kalutskii/foundation 0.6.18 → 0.6.20

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/README.md CHANGED
@@ -42,7 +42,7 @@ Status code groups are exported as constants and used by types:
42
42
 
43
43
  ### 1. Build typed contracts
44
44
 
45
- ```ts
45
+ ```typescript
46
46
  import { failure, success } from '@kalutskii/foundation';
47
47
  import type { APIContractResult } from '@kalutskii/foundation';
48
48
 
@@ -56,7 +56,7 @@ const result: APIContractResult<User> = Math.random() > 0.5 ? ok : bad;
56
56
 
57
57
  ### 2. Resolve fetchers safely
58
58
 
59
- ```ts
59
+ ```typescript
60
60
  import { fetchAndThrow, fetchSafely } from '@kalutskii/foundation';
61
61
  import type { APIContractResult } from '@kalutskii/foundation';
62
62
 
@@ -81,7 +81,7 @@ try {
81
81
 
82
82
  ### 3. Use typed Hono JSON responses
83
83
 
84
- ```ts
84
+ ```typescript
85
85
  import { respond } from '@kalutskii/foundation';
86
86
  import { Hono } from 'hono';
87
87
 
@@ -99,7 +99,7 @@ app.get('/health', (c) => {
99
99
 
100
100
  ### 4. Wire up Hono error handler and logging middleware
101
101
 
102
- ```ts
102
+ ```typescript
103
103
  import { honoLoggingHandler, onHandlerError } from '@kalutskii/foundation';
104
104
  import { Hono } from 'hono';
105
105
 
@@ -116,7 +116,7 @@ Example: `[12:12:12 (+4 UTC)] hono | POST 200 123ms /api/v1/users (se
116
116
 
117
117
  ### 5. Execute functions safely and measure performance
118
118
 
119
- ```ts
119
+ ```typescript
120
120
  import { measureExecutionTime, safeExecute } from '@kalutskii/foundation';
121
121
 
122
122
  const result = await safeExecute(
@@ -130,7 +130,7 @@ console.log(`Done in ${executionTime}ms`);
130
130
 
131
131
  ### 6. Parse query params with `asQuery`
132
132
 
133
- ```ts
133
+ ```typescript
134
134
  import { asQuery } from '@kalutskii/foundation';
135
135
  import { z } from 'zod';
136
136
 
@@ -146,7 +146,7 @@ schema.parse({ page: '2', isActive: 'true' }); // { page: 2, isActive: true }
146
146
 
147
147
  ### 8. Build flat query schemas from nested objects
148
148
 
149
- ```ts
149
+ ```typescript
150
150
  import { asQuerySchema } from '@kalutskii/foundation';
151
151
  import { z } from 'zod';
152
152
 
@@ -173,7 +173,7 @@ schema.parse({ sort: { field: 'name', order: 'asc' } }); // throws
173
173
 
174
174
  ### 8. Use pagination schema
175
175
 
176
- ```ts
176
+ ```typescript
177
177
  import { refinePagination, zodPaginationSchema, zodPaginationShape } from '@kalutskii/foundation';
178
178
  import { z } from 'zod';
179
179
 
@@ -195,7 +195,7 @@ await db.query.users.findMany({
195
195
 
196
196
  ### 9. Work with JWT using `ZodJWTService`
197
197
 
198
- ```ts
198
+ ```typescript
199
199
  import { ZodJWTService } from '@kalutskii/foundation';
200
200
  import { z } from 'zod';
201
201
 
@@ -212,7 +212,7 @@ const decoded = await jwt.decode(token);
212
212
 
213
213
  ### 10. Datetime helpers
214
214
 
215
- ```ts
215
+ ```typescript
216
216
  import { formatTime, getFormattedDate, getFormattedTime, getZonedTime } from '@kalutskii/foundation';
217
217
 
218
218
  getFormattedTime({ tz: 'Europe/Moscow' }); // '15:30:00 (+3 UTC)'
@@ -223,7 +223,7 @@ formatTime(new Date(), { tz: 'Europe/Moscow' }); // '15:30:00, 22 июня 2026
223
223
 
224
224
  ### 11. Logging
225
225
 
226
- ```ts
226
+ ```typescript
227
227
  import { log } from '@kalutskii/foundation';
228
228
 
229
229
  log.info('Server started', 'app');
package/dist/index.d.ts CHANGED
@@ -10,7 +10,7 @@ import z, { ZodObject, ZodRawShape, z as z$1 } from 'zod';
10
10
  * Maps each `where` entry to `eq(table[key], value)` and combines them with `and`.
11
11
  * Assumes that `where` was already validated and contains only existing table fields.
12
12
  *
13
- * ```ts
13
+ * ```typescript
14
14
  * await db.update(usersTable).set(values).where(sqlWhere(usersTable, { id: 1 })).returning();
15
15
  * ```
16
16
  */
@@ -73,7 +73,7 @@ type AsQuery<T> = T extends null | undefined ? T : T extends QueryPrimitive ? st
73
73
  * This is useful for scenarios where you want to enforce that at least one
74
74
  * of several optional (nullable) properties must be provided in an object.
75
75
  *
76
- * ```ts
76
+ * ```typescript
77
77
  * type Example = AtLeastOne<{ a?: string; b?: number; c?: boolean }>;
78
78
  * // Valid: { a: "hello" }, { b: 42 }, { c: true }, { a: "hello", b: 42 }
79
79
  * // Invalid: {}, { a: undefined, b: undefined, c: undefined }
@@ -189,7 +189,7 @@ type MeasuredExecution<T> = {
189
189
  * Utility function to measure the execution time of an asynchronous function.
190
190
  * @returns An object containing the result of the execution and the time taken in milliseconds.
191
191
  *
192
- * ```ts
192
+ * ```typescript
193
193
  * const { result, executionTime } = await measureExecutionTime(async () => {
194
194
  * return await fetchData();
195
195
  * });
@@ -306,7 +306,7 @@ type ZodPaginationOptions = z.infer<typeof zodPaginationSchema>;
306
306
  * 2. A `.transform()` that narrows the output type to `AtLeastOne<T>`,
307
307
  * making it directly assignable to domain `*Select` and `*Update` types without casting.
308
308
  *
309
- * ```ts
309
+ * ```typescript
310
310
  * zQuery(zodAtLeastOne(userSelectSchema)) // result: UserSelect ✓
311
311
  * ```
312
312
  */
@@ -320,7 +320,7 @@ declare const parseQueryValue: (value: unknown) => unknown;
320
320
  * numbers or booleans. This helper converts only clear primitive values, allowing
321
321
  * regular schemas like `z.number()` and `z.boolean()` to validate query input directly.
322
322
  *
323
- * ```ts
323
+ * ```typescript
324
324
  * const schema = asQuery(z.object({
325
325
  * page: z.number().int().positive(),
326
326
  * isActive: z.boolean(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kalutskii/foundation",
3
- "version": "0.6.18",
3
+ "version": "0.6.20",
4
4
  "description": "Typescript collection of most common utilities, schemas and functions among private projects.",
5
5
  "type": "module",
6
6
  "repository": {
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "scripts": {
14
14
  "build": "tsup",
15
- "lint": "eslint . --ext .ts",
15
+ "lint": "eslint . --ext .ts --fix",
16
16
  "format": "prettier --write .",
17
17
  "typecheck": "tsc --noEmit"
18
18
  },