@housekit/orm 0.1.1

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.
Files changed (50) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +224 -0
  3. package/dist/builders/delete.d.ts +21 -0
  4. package/dist/builders/insert.d.ts +128 -0
  5. package/dist/builders/prepared.d.ts +11 -0
  6. package/dist/builders/select.d.ts +352 -0
  7. package/dist/builders/select.types.d.ts +76 -0
  8. package/dist/builders/update.d.ts +23 -0
  9. package/dist/client.d.ts +52 -0
  10. package/dist/codegen/zod.d.ts +4 -0
  11. package/dist/column.d.ts +76 -0
  12. package/dist/compiler.d.ts +27 -0
  13. package/dist/core.d.ts +6 -0
  14. package/dist/data-types.d.ts +150 -0
  15. package/dist/dictionary.d.ts +263 -0
  16. package/dist/engines.d.ts +558 -0
  17. package/dist/expressions.d.ts +72 -0
  18. package/dist/external.d.ts +177 -0
  19. package/dist/index.d.ts +187 -0
  20. package/dist/index.js +222 -0
  21. package/dist/logger.d.ts +8 -0
  22. package/dist/materialized-views.d.ts +271 -0
  23. package/dist/metadata.d.ts +33 -0
  24. package/dist/modules/aggregates.d.ts +205 -0
  25. package/dist/modules/array.d.ts +122 -0
  26. package/dist/modules/conditional.d.ts +110 -0
  27. package/dist/modules/conversion.d.ts +189 -0
  28. package/dist/modules/geo.d.ts +202 -0
  29. package/dist/modules/hash.d.ts +7 -0
  30. package/dist/modules/index.d.ts +12 -0
  31. package/dist/modules/json.d.ts +130 -0
  32. package/dist/modules/math.d.ts +28 -0
  33. package/dist/modules/string.d.ts +167 -0
  34. package/dist/modules/time.d.ts +154 -0
  35. package/dist/modules/types.d.ts +177 -0
  36. package/dist/modules/window.d.ts +27 -0
  37. package/dist/relational.d.ts +33 -0
  38. package/dist/relations.d.ts +15 -0
  39. package/dist/schema-builder.d.ts +172 -0
  40. package/dist/table.d.ts +172 -0
  41. package/dist/utils/background-batcher.d.ts +20 -0
  42. package/dist/utils/batch-transform.d.ts +20 -0
  43. package/dist/utils/binary-reader.d.ts +48 -0
  44. package/dist/utils/binary-serializer.d.ts +160 -0
  45. package/dist/utils/binary-worker-code.d.ts +1 -0
  46. package/dist/utils/binary-worker-pool.d.ts +76 -0
  47. package/dist/utils/binary-worker.d.ts +12 -0
  48. package/dist/utils/insert-processing.d.ts +23 -0
  49. package/dist/utils/lru-cache.d.ts +10 -0
  50. package/package.json +68 -0
@@ -0,0 +1,167 @@
1
+ import { ClickHouseColumn } from '../core';
2
+ import { SQLExpression } from '../expressions';
3
+ /**
4
+ * Get string length
5
+ * @param col - Column or expression
6
+ */
7
+ export declare function length(col: ClickHouseColumn | SQLExpression): SQLExpression;
8
+ /**
9
+ * Get string length in UTF-8 bytes
10
+ * @param col - Column or expression
11
+ */
12
+ export declare function lengthUTF8(col: ClickHouseColumn | SQLExpression): SQLExpression;
13
+ /**
14
+ * Convert to lowercase
15
+ * @param col - Column or expression
16
+ */
17
+ export declare function lower(col: ClickHouseColumn | SQLExpression): SQLExpression;
18
+ /**
19
+ * Convert to uppercase
20
+ * @param col - Column or expression
21
+ */
22
+ export declare function upper(col: ClickHouseColumn | SQLExpression): SQLExpression;
23
+ /**
24
+ * Reverse string
25
+ * @param col - Column or expression
26
+ */
27
+ export declare function reverse(col: ClickHouseColumn | SQLExpression): SQLExpression;
28
+ /**
29
+ * Repeat string N times
30
+ * @param col - Column or expression
31
+ * @param n - Number of repetitions
32
+ */
33
+ export declare function repeat(col: ClickHouseColumn | SQLExpression, n: number): SQLExpression;
34
+ /**
35
+ * Get substring
36
+ * @param col - Column or expression
37
+ * @param offset - Starting position (1-based)
38
+ * @param length - Length of substring
39
+ */
40
+ export declare function substring(col: ClickHouseColumn | SQLExpression, offset: number, length?: number): SQLExpression;
41
+ /**
42
+ * Get substring from left
43
+ * @param col - Column or expression
44
+ * @param length - Length from left
45
+ */
46
+ export declare function left(col: ClickHouseColumn | SQLExpression, length: number): SQLExpression;
47
+ /**
48
+ * Get substring from right
49
+ * @param col - Column or expression
50
+ * @param length - Length from right
51
+ */
52
+ export declare function right(col: ClickHouseColumn | SQLExpression, length: number): SQLExpression;
53
+ /**
54
+ * Trim whitespace from string
55
+ * @param col - Column or expression
56
+ */
57
+ export declare function stringTrim(col: ClickHouseColumn | SQLExpression): SQLExpression;
58
+ /**
59
+ * Trim left whitespace
60
+ * @param col - Column or expression
61
+ */
62
+ export declare function stringTrimLeft(col: ClickHouseColumn | SQLExpression): SQLExpression;
63
+ /**
64
+ * Trim right whitespace
65
+ * @param col - Column or expression
66
+ */
67
+ export declare function stringTrimRight(col: ClickHouseColumn | SQLExpression): SQLExpression;
68
+ /**
69
+ * Check if string contains substring
70
+ * @param col - Column or expression
71
+ * @param substring - Substring to search for
72
+ */
73
+ export declare function contains(col: ClickHouseColumn | SQLExpression, substring: string): SQLExpression;
74
+ /**
75
+ * Check if string starts with substring
76
+ * @param col - Column or expression
77
+ * @param substring - Substring to check
78
+ */
79
+ export declare function startsWith(col: ClickHouseColumn | SQLExpression, substring: string): SQLExpression;
80
+ /**
81
+ * Check if string ends with substring
82
+ * @param col - Column or expression
83
+ * @param substring - Substring to check
84
+ */
85
+ export declare function endsWith(col: ClickHouseColumn | SQLExpression, substring: string): SQLExpression;
86
+ /**
87
+ * Find position of substring
88
+ * @param col - Column or expression
89
+ * @param substring - Substring to find
90
+ */
91
+ export declare function position(col: ClickHouseColumn | SQLExpression, substring: string): SQLExpression;
92
+ /**
93
+ * Count occurrences of substring
94
+ * @param col - Column or expression
95
+ * @param substring - Substring to count
96
+ */
97
+ export declare function countMatches(col: ClickHouseColumn | SQLExpression, substring: string): SQLExpression;
98
+ /**
99
+ * Concatenate strings
100
+ * @param cols - Strings to concatenate
101
+ */
102
+ export declare function concat(...cols: (ClickHouseColumn | SQLExpression | string)[]): SQLExpression;
103
+ /**
104
+ * Replace all occurrences of substring
105
+ * @param col - Column or expression
106
+ * @param pattern - Pattern to replace
107
+ * @param replacement - Replacement string
108
+ */
109
+ export declare function replace(col: ClickHouseColumn | SQLExpression, pattern: string, replacement: string): SQLExpression;
110
+ /**
111
+ * Replace using regex
112
+ * @param col - Column or expression
113
+ * @param pattern - Regex pattern
114
+ * @param replacement - Replacement string
115
+ */
116
+ export declare function replaceRegexpAll(col: ClickHouseColumn | SQLExpression, pattern: string, replacement: string): SQLExpression;
117
+ /**
118
+ * Match using regex (returns 1 if matches, 0 if not)
119
+ * @param col - Column or expression
120
+ * @param pattern - Regex pattern
121
+ */
122
+ export declare function match(col: ClickHouseColumn | SQLExpression, pattern: string): SQLExpression;
123
+ /**
124
+ * Check if string matches pattern (LIKE)
125
+ * @param col - Column or expression
126
+ * @param pattern - Pattern to match
127
+ */
128
+ export declare function like(col: ClickHouseColumn | SQLExpression, pattern: string): SQLExpression;
129
+ /**
130
+ * Check if string matches pattern (NOT LIKE)
131
+ * @param col - Column or expression
132
+ * @param pattern - Pattern to match
133
+ */
134
+ export declare function notLike(col: ClickHouseColumn | SQLExpression, pattern: string): SQLExpression;
135
+ /**
136
+ * Check if string matches pattern (ILIKE - case insensitive)
137
+ * @param col - Column or expression
138
+ * @param pattern - Pattern to match
139
+ */
140
+ export declare function ilike(col: ClickHouseColumn | SQLExpression, pattern: string): SQLExpression;
141
+ /**
142
+ * Check if string matches pattern (NOT ILIKE)
143
+ * @param col - Column or expression
144
+ * @param pattern - Pattern to match
145
+ */
146
+ export declare function notIlike(col: ClickHouseColumn | SQLExpression, pattern: string): SQLExpression;
147
+ /**
148
+ * Calculate SHA1 hash
149
+ * @param col - Column or expression
150
+ */
151
+ export declare function sha1(col: ClickHouseColumn | SQLExpression): SQLExpression;
152
+ /**
153
+ * Calculate SIP hash
154
+ * @param col - Column or expression
155
+ */
156
+ export declare function sipHash64(col: ClickHouseColumn | SQLExpression): SQLExpression;
157
+ /**
158
+ * Split string by delimiter
159
+ * @param col - Column or expression
160
+ * @param delimiter - Delimiter string
161
+ */
162
+ export declare function splitByChar(col: ClickHouseColumn | SQLExpression, delimiter: string): SQLExpression;
163
+ /**
164
+ * Split string by whitespace
165
+ * @param col - Column or expression
166
+ */
167
+ export declare function splitByWhitespace(col: ClickHouseColumn | SQLExpression): SQLExpression;
@@ -0,0 +1,154 @@
1
+ import { ClickHouseColumn } from '../core';
2
+ import { SQLExpression } from '../expressions';
3
+ /**
4
+ * Get current timestamp
5
+ */
6
+ export declare function timeNow(): SQLExpression;
7
+ /**
8
+ * Get current date (without time)
9
+ */
10
+ export declare function timeToday(): SQLExpression;
11
+ /**
12
+ * Get yesterday's date (without time)
13
+ */
14
+ export declare function timeYesterday(): SQLExpression;
15
+ /**
16
+ * Convert to Date type (without time)
17
+ * @param col - Date/datetime column or expression
18
+ */
19
+ export declare function timeToDate(col: ClickHouseColumn | SQLExpression): SQLExpression;
20
+ /**
21
+ * Convert to DateTime type
22
+ * @param col - Date/datetime column or expression
23
+ */
24
+ export declare function timeToDateTime(col: ClickHouseColumn | SQLExpression): SQLExpression;
25
+ /**
26
+ * Convert to Unix timestamp (super common in time-series analytics)
27
+ * @param col - DateTime column or expression
28
+ */
29
+ export declare function toUnixTimestamp(col: ClickHouseColumn | SQLExpression): SQLExpression;
30
+ /**
31
+ * Format datetime to string
32
+ * @param col - DateTime column or expression
33
+ * @param format - Format string (e.g., '%Y-%m-%d %H:%M:%S')
34
+ */
35
+ export declare function timeFormatDateTime(col: ClickHouseColumn | SQLExpression, format: string): SQLExpression;
36
+ /**
37
+ * Truncate to start of hour
38
+ * @param col - DateTime column or expression
39
+ */
40
+ export declare function timeToStartOfHour(col: ClickHouseColumn | SQLExpression): SQLExpression;
41
+ /**
42
+ * Truncate to start of day
43
+ * @param col - DateTime column or expression
44
+ */
45
+ export declare function timeToStartOfDay(col: ClickHouseColumn | SQLExpression): SQLExpression;
46
+ /**
47
+ * Truncate to start of week
48
+ * @param col - DateTime column or expression
49
+ */
50
+ export declare function timeToStartOfWeek(col: ClickHouseColumn | SQLExpression): SQLExpression;
51
+ /**
52
+ * Truncate to start of month
53
+ * @param col - DateTime column or expression
54
+ */
55
+ export declare function timeToStartOfMonth(col: ClickHouseColumn | SQLExpression): SQLExpression;
56
+ /**
57
+ * Truncate to start of quarter
58
+ * @param col - DateTime column or expression
59
+ */
60
+ export declare function toStartOfQuarter(col: ClickHouseColumn | SQLExpression): SQLExpression;
61
+ /**
62
+ * Truncate to start of year
63
+ * @param col - DateTime column or expression
64
+ */
65
+ export declare function toStartOfYear(col: ClickHouseColumn | SQLExpression): SQLExpression;
66
+ /**
67
+ * Truncate to start of interval (very flexible for custom time buckets)
68
+ * @param col - DateTime column or expression
69
+ * @param interval - Interval string (e.g., 'INTERVAL 1 HOUR', 'INTERVAL 15 MINUTE')
70
+ * @param timezone - Optional timezone
71
+ */
72
+ export declare function toStartOfInterval(col: ClickHouseColumn | SQLExpression, interval: string, timezone?: string): SQLExpression;
73
+ /**
74
+ * Calculate difference between two dates
75
+ * @param unit - Unit of difference ('year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second')
76
+ * @param start - Start date
77
+ * @param end - End date
78
+ */
79
+ export declare function dateDiff(unit: 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second', start: ClickHouseColumn | SQLExpression, end: ClickHouseColumn | SQLExpression): SQLExpression;
80
+ /**
81
+ * Add interval to date
82
+ * @param unit - Unit to add ('year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second')
83
+ * @param amount - Amount to add
84
+ * @param date - Date to add to
85
+ */
86
+ export declare function dateAdd(unit: 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second', amount: number, date: ClickHouseColumn | SQLExpression): SQLExpression;
87
+ /**
88
+ * Subtract interval from date
89
+ * @param unit - Unit to subtract ('year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second')
90
+ * @param amount - Amount to subtract
91
+ * @param date - Date to subtract from
92
+ */
93
+ export declare function dateSub(unit: 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second', amount: number, date: ClickHouseColumn | SQLExpression): SQLExpression;
94
+ /**
95
+ * Convert datetime to different timezone
96
+ * @param col - DateTime column or expression
97
+ * @param timezone - Target timezone
98
+ */
99
+ export declare function toTimezone(col: ClickHouseColumn | SQLExpression, timezone: string): SQLExpression;
100
+ /**
101
+ * Get timezone offset for datetime
102
+ * @param col - DateTime column or expression
103
+ */
104
+ export declare function timeOffset(col: ClickHouseColumn | SQLExpression): SQLExpression;
105
+ /**
106
+ * Extract year from date
107
+ * @param col - Date/datetime column or expression
108
+ */
109
+ export declare function toYear(col: ClickHouseColumn | SQLExpression): SQLExpression;
110
+ /**
111
+ * Extract quarter from date
112
+ * @param col - Date/datetime column or expression
113
+ */
114
+ export declare function toQuarter(col: ClickHouseColumn | SQLExpression): SQLExpression;
115
+ /**
116
+ * Extract month from date
117
+ * @param col - Date/datetime column or expression
118
+ */
119
+ export declare function toMonth(col: ClickHouseColumn | SQLExpression): SQLExpression;
120
+ /**
121
+ * Extract day of month from date
122
+ * @param col - Date/datetime column or expression
123
+ */
124
+ export declare function toDayOfMonth(col: ClickHouseColumn | SQLExpression): SQLExpression;
125
+ /**
126
+ * Extract day of week from date
127
+ * @param col - Date/datetime column or expression
128
+ */
129
+ export declare function toDayOfWeek(col: ClickHouseColumn | SQLExpression): SQLExpression;
130
+ /**
131
+ * Extract hour from datetime
132
+ * @param col - DateTime column or expression
133
+ */
134
+ export declare function toHour(col: ClickHouseColumn | SQLExpression): SQLExpression;
135
+ /**
136
+ * Extract minute from datetime
137
+ * @param col - DateTime column or expression
138
+ */
139
+ export declare function toMinute(col: ClickHouseColumn | SQLExpression): SQLExpression;
140
+ /**
141
+ * Extract second from datetime
142
+ * @param col - DateTime column or expression
143
+ */
144
+ export declare function toSecond(col: ClickHouseColumn | SQLExpression): SQLExpression;
145
+ /**
146
+ * Get ISO week number from date
147
+ * @param col - Date/datetime column or expression
148
+ */
149
+ export declare function toISOWeek(col: ClickHouseColumn | SQLExpression): SQLExpression;
150
+ /**
151
+ * Get week number from date (ClickHouse-specific)
152
+ * @param col - Date/datetime column or expression
153
+ */
154
+ export declare function toWeek(col: ClickHouseColumn | SQLExpression): SQLExpression;
@@ -0,0 +1,177 @@
1
+ export type JsonValue = Record<string, any> | any[];
2
+ import { ClickHouseColumn } from '../column';
3
+ /**
4
+ * Low cardinality string column (very common for dimensions)
5
+ * @param name - Column name
6
+ */
7
+ export declare function lowCardinalityString(name: string): ClickHouseColumn<string>;
8
+ /**
9
+ * Low cardinality nullable string column
10
+ * @param name - Column name
11
+ */
12
+ export declare function lowCardinalityNullableString(name: string): ClickHouseColumn<string | null>;
13
+ /**
14
+ * Nullable JSON column
15
+ * @param name - Column name
16
+ */
17
+ export declare function nullableJson(name: string): ClickHouseColumn<JsonValue | null>;
18
+ /**
19
+ * Low cardinality JSON column
20
+ * @param name - Column name
21
+ */
22
+ export declare function lowCardinalityJson(name: string): ClickHouseColumn<JsonValue>;
23
+ /**
24
+ * Low cardinality nullable JSON column
25
+ * @param name - Column name
26
+ */
27
+ export declare function lowCardinalityNullableJson(name: string): ClickHouseColumn<JsonValue | null>;
28
+ /**
29
+ * Create an Enum8 column with TypeScript union type support
30
+ * @param name - Column name
31
+ * @param values - Array of possible values
32
+ */
33
+ export declare function enum8<T extends string>(name: string, values: readonly T[]): ClickHouseColumn<T>;
34
+ /**
35
+ * Create a nullable Enum8 column with TypeScript union type support
36
+ * @param name - Column name
37
+ * @param values - Array of possible values
38
+ */
39
+ export declare function nullableEnum8<T extends string>(name: string, values: readonly T[]): ClickHouseColumn<T | null>;
40
+ /**
41
+ * Create an Enum16 column with TypeScript union type support
42
+ * @param name - Column name
43
+ * @param values - Array of possible values
44
+ */
45
+ export declare function enum16<T extends string>(name: string, values: readonly T[]): ClickHouseColumn<T>;
46
+ /**
47
+ * Create a nullable Enum16 column with TypeScript union type support
48
+ * @param name - Column name
49
+ * @param values - Array of possible values
50
+ */
51
+ export declare function nullableEnum16<T extends string>(name: string, values: readonly T[]): ClickHouseColumn<T | null>;
52
+ /**
53
+ * Array of strings with low cardinality
54
+ * @param name - Column name
55
+ */
56
+ export declare function lowCardinalityStringArray(name: string): ClickHouseColumn<string[]>;
57
+ /**
58
+ * Nullable array of strings
59
+ * @param name - Column name
60
+ */
61
+ export declare function nullableStringArray(name: string): ClickHouseColumn<string[] | null>;
62
+ /**
63
+ * Array of nullable strings
64
+ * @param name - Column name
65
+ */
66
+ export declare function stringNullableArray(name: string): ClickHouseColumn<(string | null)[]>;
67
+ /**
68
+ * Array of integers with low cardinality
69
+ * @param name - Column name
70
+ */
71
+ export declare function lowCardinalityInt32Array(name: string): ClickHouseColumn<number[]>;
72
+ /**
73
+ * Email column (low cardinality string)
74
+ * @param name - Column name
75
+ */
76
+ export declare function email(name: string): ClickHouseColumn<string>;
77
+ /**
78
+ * Nullable email column
79
+ * @param name - Column name
80
+ */
81
+ export declare function nullableEmail(name: string): ClickHouseColumn<string | null>;
82
+ /**
83
+ * Phone number column (low cardinality string)
84
+ * @param name - Column name
85
+ */
86
+ export declare function phone(name: string): ClickHouseColumn<string>;
87
+ /**
88
+ * Nullable phone number column
89
+ * @param name - Column name
90
+ */
91
+ export declare function nullablePhone(name: string): ClickHouseColumn<string | null>;
92
+ /**
93
+ * Country code column (Enum8 with common country codes)
94
+ * @param name - Column name
95
+ */
96
+ export declare function countryCode(name: string): ClickHouseColumn<string>;
97
+ /**
98
+ * Nullable country code column
99
+ * @param name - Column name
100
+ */
101
+ export declare function nullableCountryCode(name: string): ClickHouseColumn<string | null>;
102
+ /**
103
+ * Status column (Enum8 with common statuses)
104
+ * @param name - Column name
105
+ */
106
+ export declare function status<T extends string>(name: string, values: readonly T[]): ClickHouseColumn<T>;
107
+ /**
108
+ * Nullable status column
109
+ * @param name - Column name
110
+ * @param values - Array of possible status values
111
+ */
112
+ export declare function nullableStatus<T extends string>(name: string, values: readonly T[]): ClickHouseColumn<T | null>;
113
+ /**
114
+ * Common status values for reference
115
+ */
116
+ export declare const COMMON_STATUSES: {
117
+ readonly ACTIVE: "active";
118
+ readonly INACTIVE: "inactive";
119
+ readonly PENDING: "pending";
120
+ readonly COMPLETED: "completed";
121
+ readonly FAILED: "failed";
122
+ readonly CANCELLED: "cancelled";
123
+ readonly DRAFT: "draft";
124
+ readonly PUBLISHED: "published";
125
+ readonly ARCHIVED: "archived";
126
+ readonly DELETED: "deleted";
127
+ };
128
+ /**
129
+ * Create a status column with common predefined values
130
+ * @param name - Column name
131
+ * @param customValues - Optional custom status values
132
+ */
133
+ export declare function commonStatus(name: string, customValues?: readonly string[]): ClickHouseColumn<string>;
134
+ /**
135
+ * Create a nullable status column with common predefined values
136
+ * @param name - Column name
137
+ * @param customValues - Optional custom status values
138
+ */
139
+ export declare function nullableCommonStatus(name: string, customValues?: readonly string[]): ClickHouseColumn<string | null>;
140
+ /**
141
+ * Created at timestamp column (DateTime with default now())
142
+ * @param name - Column name
143
+ * @param timezone - Optional timezone
144
+ */
145
+ export declare function createdAt(name?: string, timezone?: string): ClickHouseColumn<string>;
146
+ /**
147
+ * Updated at timestamp column (DateTime with default now() and on update)
148
+ * @param name - Column name
149
+ * @param timezone - Optional timezone
150
+ */
151
+ export declare function updatedAt(name?: string, timezone?: string): ClickHouseColumn<string>;
152
+ /**
153
+ * Deleted at timestamp column (nullable DateTime for soft deletes)
154
+ * @param name - Column name
155
+ * @param timezone - Optional timezone
156
+ */
157
+ export declare function deletedAt(name?: string, timezone?: string): ClickHouseColumn<string | null>;
158
+ /**
159
+ * Auto-generated UUID primary key
160
+ * @param name - Column name
161
+ */
162
+ export declare function uuidPrimaryKey(name?: string): ClickHouseColumn<string>;
163
+ /**
164
+ * Auto-generated UUID primary key with low cardinality (for distributed systems)
165
+ * @param name - Column name
166
+ */
167
+ export declare function lowCardinalityUuidPrimaryKey(name?: string): ClickHouseColumn<string>;
168
+ /**
169
+ * Sequential integer primary key
170
+ * @param name - Column name
171
+ */
172
+ export declare function int32PrimaryKey(name?: string): ClickHouseColumn<number>;
173
+ /**
174
+ * Sequential big integer primary key
175
+ * @param name - Column name
176
+ */
177
+ export declare function int64PrimaryKey(name?: string): ClickHouseColumn<number>;
@@ -0,0 +1,27 @@
1
+ import { ClickHouseColumn } from '../core';
2
+ import { type SQLExpression, type SQLValue } from '../expressions';
3
+ type OrderDirection = 'ASC' | 'DESC';
4
+ export type WindowPartition = ClickHouseColumn | SQLExpression;
5
+ export type WindowOrder = WindowPartition | {
6
+ col: WindowPartition;
7
+ dir?: OrderDirection;
8
+ };
9
+ export interface WindowSpec {
10
+ partitionBy?: WindowPartition | WindowPartition[];
11
+ orderBy?: WindowOrder | WindowOrder[];
12
+ }
13
+ export declare function over<T>(expr: SQLExpression<T>, spec?: WindowSpec): SQLExpression<T>;
14
+ export declare function rowNumber(spec?: WindowSpec): SQLExpression<number>;
15
+ export declare function rank(spec?: WindowSpec): SQLExpression<number>;
16
+ export declare function denseRank(spec?: WindowSpec): SQLExpression<number>;
17
+ export declare function lag<T>(col: ClickHouseColumn<T, any, any> | SQLExpression<T>, offset?: number, defaultValue?: SQLValue, spec?: WindowSpec): SQLExpression<T>;
18
+ export declare function lead<T>(col: ClickHouseColumn<T, any, any> | SQLExpression<T>, offset?: number, defaultValue?: SQLValue, spec?: WindowSpec): SQLExpression<T>;
19
+ export declare const windowFns: {
20
+ over: typeof over;
21
+ rowNumber: typeof rowNumber;
22
+ rank: typeof rank;
23
+ denseRank: typeof denseRank;
24
+ lag: typeof lag;
25
+ lead: typeof lead;
26
+ };
27
+ export {};
@@ -0,0 +1,33 @@
1
+ import { type TableDefinition } from './core';
2
+ import type { SQLExpression } from './expressions';
3
+ /**
4
+ * Join strategy for relational queries
5
+ */
6
+ export type JoinStrategy = 'auto' | 'standard' | 'global' | 'any' | 'global_any';
7
+ export type RelationalFindOptions<TTable = any> = {
8
+ where?: SQLExpression | ((columns: TTable extends TableDefinition<infer TCols> ? TCols : any) => SQLExpression);
9
+ limit?: number;
10
+ offset?: number;
11
+ with?: Record<string, boolean | RelationalFindOptions>;
12
+ /**
13
+ * Join strategy for related data.
14
+ *
15
+ * - 'auto': Automatically uses GLOBAL when table has onCluster option
16
+ * - 'standard': Regular LEFT JOIN
17
+ * - 'global': Force GLOBAL JOIN (for clusters)
18
+ * - 'any': Use ANY JOIN (faster, single match)
19
+ * - 'global_any': Combine GLOBAL and ANY
20
+ *
21
+ * @default 'auto'
22
+ */
23
+ joinStrategy?: JoinStrategy;
24
+ };
25
+ /**
26
+ * Build a modern relational API with ClickHouse optimizations.
27
+ *
28
+ * Key improvements over standard ORMs:
29
+ * - Automatic GLOBAL JOIN detection for distributed tables
30
+ * - Join strategy selection for performance tuning
31
+ * - Support for dictionary lookups as alternative to JOINs
32
+ */
33
+ export declare function buildRelationalAPI(client: any, schema?: Record<string, TableDefinition<any>>): Record<string, any> | undefined;
@@ -0,0 +1,15 @@
1
+ import type { ClickHouseColumn, RelationDefinition, TableDefinition } from './core';
2
+ type OneConfig = {
3
+ fields: ClickHouseColumn[];
4
+ references: ClickHouseColumn[];
5
+ };
6
+ type ManyConfig = {
7
+ fields?: ClickHouseColumn[];
8
+ references?: ClickHouseColumn[];
9
+ };
10
+ type RelationBuilderHelpers = {
11
+ one: (table: TableDefinition<any>, config: OneConfig) => RelationDefinition;
12
+ many: (table: TableDefinition<any>, config?: ManyConfig) => RelationDefinition;
13
+ };
14
+ export declare function relations<TTable extends TableDefinition<any>, TRelations extends Record<string, RelationDefinition>>(table: TTable, callback: (helpers: RelationBuilderHelpers) => TRelations): TRelations;
15
+ export {};