@housekit/orm 0.1.44 → 0.1.46

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
@@ -4,10 +4,23 @@
4
4
 
5
5
  > ⚠️ **Public Beta**: This package is currently in public beta. Feedback is highly appreciated as we polish the API for v1.0.
6
6
 
7
+ > [!TIP]
8
+ > **Interactive Docs**: Use [RepoGrep](https://app.ami.dev/repogrep?repo=https://github.com/pablofdezr/housekit) to search and query the entire codebase and documentation for free (Updated instantly).
9
+
10
+ > [!TIP]
11
+ > **Ask ZRead**: Need deep insights? [Ask ZRead](https://zread.ai/pablofdezr/housekit) for AI-powered understanding of the codebase (Updated weekly).
12
+
13
+ > [!TIP]
14
+ > **Ask Devin AI**: Have questions about integrating HouseKit? [Ask the Wiki](https://deepwiki.com/pablofdezr/housekit) for AI-powered assistance (Updated weekly).
15
+
7
16
  HouseKit ORM is a modern database toolkit designed specifically for ClickHouse. It bridges the gap between ergonomic developer experiences and the extreme performance requirements of high-volume OLAP workloads.
8
17
 
9
18
  [![npm version](https://img.shields.io/npm/v/@housekit/orm.svg)](https://www.npmjs.com/package/@housekit/orm)
10
19
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
20
+ [![Documentation](https://img.shields.io/badge/Docs-RepoGrep-teal?style=flat-square)](https://app.ami.dev/repogrep?repo=https://github.com/pablofdezr/housekit)
21
+ [![zread](https://img.shields.io/badge/Ask_Zread-_.svg?style=flat&color=00b0aa&labelColor=000000&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQuOTYxNTYgMS42MDAxSDIuMjQxNTZDMS44ODgxIDEuNjAwMSAx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yTDEyIDQiIHN0cm9rZT0iI2ZmZiIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1saW5lY2FwPSJyb3VuZCIvPgo8L3N2Zz4K&logoColor=ffffff)](https://zread.ai/pablofdezr/housekit)
22
+ [![Documentation](https://img.shields.io/badge/Wiki-Devin%20AI-blueviolet?style=flat-square)](https://deepwiki.com/pablofdezr/housekit)
23
+ [![Documentation](https://img.shields.io/badge/Docs-WarpGrep-blue?style=flat-square)](https://www.morphllm.com/playground/na/warpgrep?repo=pablofdezr%2Fhousekit)
11
24
 
12
25
  ---
13
26
 
@@ -39,7 +52,7 @@ bun add @housekit/orm @clickhouse/client
39
52
  import { defineTable, t, Engine, relations } from '@housekit/orm';
40
53
 
41
54
  export const users = defineTable('users', {
42
- id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey().default('generateUUIDv7()'),
55
+ id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey(),
43
56
  email: t.string('email'),
44
57
  role: t.enum('role', ['admin', 'user']),
45
58
  ...t.timestamps(),
@@ -49,7 +62,7 @@ export const users = defineTable('users', {
49
62
  });
50
63
 
51
64
  export const posts = defineTable('posts', {
52
- id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey().default('generateUUIDv7()'),
65
+ id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey(),
53
66
  userId: t.uuid('user_id'),
54
67
  title: t.string('title'),
55
68
  createdAt: t.timestamp('created_at').default('now()'),
@@ -66,6 +79,27 @@ export type User = typeof users.$type;
66
79
  export type NewUser = typeof users.$insert;
67
80
  ```
68
81
 
82
+ #### UUID Generation Options
83
+
84
+ HouseKit supports two approaches for UUID generation:
85
+
86
+ | Approach | Method | When to Use |
87
+ |----------|--------|-------------|
88
+ | **Client-side** | `.autoGenerate({ version: 7 })` | When using `.returning()` or `.returningOne()` |
89
+ | **Server-side** | `.default('generateUUIDv7()')` | When you don't need the ID back immediately |
90
+
91
+ ```typescript
92
+ // Client-side generation (recommended for most cases)
93
+ // UUID is generated in JS before insert, works with returning()
94
+ id: t.uuid('id').autoGenerate({ version: 7 }).primaryKey()
95
+
96
+ // Server-side generation
97
+ // UUID is generated by ClickHouse, cannot use returning()
98
+ id: t.uuid('id').primaryKey().default('generateUUIDv7()')
99
+ ```
100
+
101
+ **Note:** Don't combine both - it's redundant. Choose one based on whether you need `.returning()` support.
102
+
69
103
  ### 2. Connect and Query
70
104
 
71
105
  ```typescript
package/dist/index.js CHANGED
@@ -2354,6 +2354,11 @@ class QueryCompiler {
2354
2354
  Object.assign(params, res.params);
2355
2355
  colSql = res.sql;
2356
2356
  }
2357
+ const sqlUpper = colSql.trim().toUpperCase();
2358
+ const alreadyHasDirection = sqlUpper.endsWith(" ASC") || sqlUpper.endsWith(" DESC");
2359
+ if (alreadyHasDirection) {
2360
+ return colSql;
2361
+ }
2357
2362
  return `${colSql} ${o.dir}`;
2358
2363
  });
2359
2364
  orderSql = `ORDER BY ${parts.join(", ")}`;
@@ -6240,14 +6245,14 @@ var windowFns = { over, rowNumber, rank, denseRank, lag, lead };
6240
6245
  // src/schema-builder.ts
6241
6246
  function primaryUuid(name) {
6242
6247
  const colName = name ?? "id";
6243
- const column = new ClickHouseColumn(colName, "UUID").autoGenerate().primaryKey().default("generateUUIDv4()");
6248
+ const column = new ClickHouseColumn(colName, "UUID").autoGenerate().primaryKey();
6244
6249
  return {
6245
6250
  [colName]: column
6246
6251
  };
6247
6252
  }
6248
6253
  function primaryUuidV7(name) {
6249
6254
  const colName = name ?? "id";
6250
- const column = new ClickHouseColumn(colName, "UUID").autoGenerate({ version: 7 }).primaryKey().default("generateUUIDv7()");
6255
+ const column = new ClickHouseColumn(colName, "UUID").autoGenerate({ version: 7 }).primaryKey();
6251
6256
  return {
6252
6257
  [colName]: column
6253
6258
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@housekit/orm",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "Type-safe ClickHouse ORM with modern DX and ClickHouse-specific optimizations. Features optimized JSONCompact streaming, full engine support, and advanced query capabilities.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",