@housekit/orm 0.1.17 → 0.1.18
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 +2 -6
- package/dist/builders/insert.d.ts +5 -3
- package/dist/index.js +3 -0
- package/dist/table.d.ts +18 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -178,11 +178,7 @@ await repository.insertEvents([
|
|
|
178
178
|
]);
|
|
179
179
|
```
|
|
180
180
|
|
|
181
|
-
###
|
|
182
|
-
|
|
183
|
-
When you write `table.$inferInsert`, it includes a callable signature. TypeScript interprets `table[]` as invoking that callable and applying the array type, giving you `TableInsert<T>[]` automatically.
|
|
184
|
-
|
|
185
|
-
### Alternative Approaches
|
|
181
|
+
### Type Helpers
|
|
186
182
|
|
|
187
183
|
```typescript
|
|
188
184
|
import { TableInsertArray } from '@housekit/orm';
|
|
@@ -198,7 +194,7 @@ async insertEvents(events: typeof salesEvents.$inferInsert[]) {
|
|
|
198
194
|
}
|
|
199
195
|
```
|
|
200
196
|
|
|
201
|
-
**
|
|
197
|
+
**Note**: Autocomplete shows clean data types by default without exposing internal types.
|
|
202
198
|
|
|
203
199
|
---
|
|
204
200
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ClickHouseClient } from '@clickhouse/client';
|
|
2
|
-
import { type TableDefinition, type
|
|
2
|
+
import { type TableDefinition, type TableColumns, type CleanInsert } from '../core';
|
|
3
3
|
import { type BatchTransformOptions } from '../utils/batch-transform';
|
|
4
4
|
import { Readable } from 'stream';
|
|
5
5
|
import { type BatchConfig } from '../utils/background-batcher';
|
|
@@ -32,7 +32,9 @@ export declare class ClickHouseInsertBuilder<TTable extends TableDefinition<Tabl
|
|
|
32
32
|
private _batchConfig;
|
|
33
33
|
private _forceJson;
|
|
34
34
|
constructor(client: ClickHouseClient, table: TTable);
|
|
35
|
-
values(value:
|
|
35
|
+
values(value: CleanInsert<TTable> | Array<CleanInsert<TTable>> | Iterable<CleanInsert<TTable>> | AsyncIterable<CleanInsert<TTable>> | Readable): this;
|
|
36
|
+
/** @template [T = CleanInsert<TTable>] */
|
|
37
|
+
insert(data: CleanInsert<TTable> | CleanInsert<TTable>[]): Promise<this>;
|
|
36
38
|
/**
|
|
37
39
|
* Force synchronous insert (disables async_insert).
|
|
38
40
|
* Use when you need immediate durability guarantee.
|
|
@@ -73,7 +75,7 @@ export declare class ClickHouseInsertBuilder<TTable extends TableDefinition<Tabl
|
|
|
73
75
|
* Note: This method is "fire-and-forget" and does not wait for
|
|
74
76
|
* the database to acknowledge the insert.
|
|
75
77
|
*/
|
|
76
|
-
append(row:
|
|
78
|
+
append(row: CleanInsert<TTable>): Promise<void>;
|
|
77
79
|
/**
|
|
78
80
|
* Force JSON format (useful for debugging or compatibility).
|
|
79
81
|
*
|
package/dist/index.js
CHANGED
package/dist/table.d.ts
CHANGED
|
@@ -86,6 +86,24 @@ export type InferInsertModel<T extends {
|
|
|
86
86
|
(): TableInsert<T['$columns']>[];
|
|
87
87
|
(): TableInsert<T['$columns']>;
|
|
88
88
|
};
|
|
89
|
+
export type CleanInsert<T extends {
|
|
90
|
+
$inferInsert?: any;
|
|
91
|
+
}> = T extends {
|
|
92
|
+
$inferInsert?: infer I;
|
|
93
|
+
} ? I : never;
|
|
94
|
+
export type CleanSelect<T extends {
|
|
95
|
+
$inferSelect?: any;
|
|
96
|
+
}> = T extends {
|
|
97
|
+
$inferSelect?: infer S;
|
|
98
|
+
} ? S : never;
|
|
99
|
+
export type InferInsertValue<TCols extends TableColumns, K extends keyof TCols> = TCols[K] extends ClickHouseColumn<infer Type, infer NotNull, any> ? NotNull extends true ? Type : Type | undefined | null : never;
|
|
100
|
+
export type TableInsertArray<T extends TableDefinition<TableColumns>> = T['$inferInsert'][];
|
|
101
|
+
export type TableModel<T extends TableDefinition<TableColumns>> = PublicSelectModel<T>;
|
|
102
|
+
export type InsertModel<T extends TableDefinition<TableColumns>> = PublicInsertModel<T>;
|
|
103
|
+
type PublicSelectModel<T extends TableDefinition<TableColumns>> = {
|
|
104
|
+
[K in keyof T['$columns']]: GetColumnType<T['$columns'][K]>;
|
|
105
|
+
};
|
|
106
|
+
type PublicInsertModel<T extends TableDefinition<TableColumns>> = TableInsert<T['$columns']>;
|
|
89
107
|
export type TableDefinition<TCols extends TableColumns, TOptions = TableOptions> = {
|
|
90
108
|
$table: string;
|
|
91
109
|
$columns: TCols;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@housekit/orm",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Type-safe ClickHouse ORM with modern DX and ClickHouse-specific optimizations. Features Turbo Mode (RowBinary), full engine support, and advanced query capabilities.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|