sonamu 0.7.7 → 0.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sonamu",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "description": "Sonamu — TypeScript Fullstack API Framework",
5
5
  "keywords": [
6
6
  "typescript",
@@ -77,8 +77,8 @@
77
77
  "tsicli": "^1.0.5",
78
78
  "vitest": "^4.0.10",
79
79
  "zod": "^4.1.12",
80
- "@sonamu-kit/hmr-runner": "^0.1.1",
81
80
  "@sonamu-kit/hmr-hook": "^0.4.1",
81
+ "@sonamu-kit/hmr-runner": "^0.1.1",
82
82
  "@sonamu-kit/ts-loader": "^2.1.3"
83
83
  },
84
84
  "devDependencies": {
@@ -171,10 +171,12 @@ export function defaultCatch(e: any) {
171
171
  /*
172
172
  Isomorphic Types
173
173
  */
174
- export type ListResult<T> = {
175
- rows: T[];
176
- total?: number;
177
- };
174
+ export type ListResult<LP extends { queryMode?: SonamuQueryMode }, T> = LP["queryMode"] extends "list"
175
+ ? { rows: T[] }
176
+ : LP["queryMode"] extends "count"
177
+ ? { total: number }
178
+ : { rows: T[]; total: number };
179
+
178
180
  export const SonamuQueryMode = z.enum(["both", "list", "count"]);
179
181
  export type SonamuQueryMode = z.infer<typeof SonamuQueryMode>;
180
182
 
@@ -224,7 +226,7 @@ export function handleConditional(
224
226
  /*
225
227
  Utils
226
228
  */
227
- export function zArrayable<T extends z.ZodTypeAny>(shape: T) {
229
+ export function zArrayable<T extends z.ZodTypeAny>(shape: T): z.ZodUnion<[T, z.ZodArray<T>]> {
228
230
  return z.union([shape, shape.array()]);
229
231
  }
230
232