@hypequery/clickhouse 0.2.1 → 0.2.3
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/dist/cli/bin.js +128 -36
- package/dist/cli/generate-types.js +101 -12
- package/dist/core/connection.d.ts +136 -0
- package/dist/core/connection.d.ts.map +1 -1
- package/dist/core/connection.js +58 -0
- package/dist/core/cross-filter.d.ts +85 -0
- package/dist/core/features/aggregations.d.ts +102 -0
- package/dist/core/features/analytics.d.ts +66 -0
- package/dist/core/features/cross-filtering.d.ts +31 -0
- package/dist/core/features/cross-filtering.d.ts.map +1 -0
- package/dist/core/features/cross-filtering.js +123 -0
- package/dist/core/features/executor.d.ts +19 -0
- package/dist/core/features/filtering.d.ts +95 -0
- package/dist/core/features/filtering.d.ts.map +1 -1
- package/dist/core/features/filtering.js +59 -1
- package/dist/core/features/joins.d.ts +29 -0
- package/dist/core/features/pagination.d.ts +23 -0
- package/dist/core/features/query-modifiers.d.ts +119 -0
- package/dist/core/formatters/sql-formatter.d.ts +9 -0
- package/dist/core/formatters/sql-formatter.d.ts.map +1 -1
- package/dist/core/formatters/sql-formatter.js +24 -5
- package/dist/core/join-relationships.d.ts +50 -0
- package/dist/core/query-builder.d.ts +222 -0
- package/dist/core/query-builder.d.ts.map +1 -1
- package/dist/core/query-builder.js +38 -6
- package/dist/core/tests/index.d.ts +2 -0
- package/dist/core/tests/integration/pagination-test-tbc.d.ts +2 -0
- package/dist/core/tests/integration/pagination-test-tbc.d.ts.map +1 -0
- package/dist/core/tests/integration/pagination-test-tbc.js +189 -0
- package/dist/core/tests/integration/setup.d.ts +40 -0
- package/dist/core/tests/integration/setup.d.ts.map +1 -1
- package/dist/core/tests/integration/setup.js +278 -237
- package/dist/core/tests/integration/test-config.d.ts +15 -0
- package/dist/core/tests/integration/test-config.d.ts.map +1 -0
- package/dist/core/tests/integration/test-config.js +15 -0
- package/dist/core/tests/test-utils.d.ts +30 -0
- package/dist/core/utils/logger.d.ts +37 -0
- package/dist/core/utils/logger.js +2 -2
- package/dist/core/utils/sql-expressions.d.ts +59 -0
- package/dist/core/utils.d.ts +3 -0
- package/dist/core/validators/filter-validator.d.ts +8 -0
- package/dist/core/validators/value-validator.d.ts +6 -0
- package/dist/formatters/index.d.ts +1 -0
- package/dist/index.d.ts +10 -27
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -2
- package/dist/types/base.d.ts +77 -0
- package/dist/types/base.d.ts.map +1 -1
- package/dist/types/clickhouse-types.d.ts +13 -0
- package/dist/types/filters.d.ts +37 -0
- package/dist/types/index.d.ts +3 -0
- package/package.json +15 -8
|
@@ -63,6 +63,8 @@ class Logger {
|
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
logQuery(log) {
|
|
66
|
+
if (!this.enabled)
|
|
67
|
+
return;
|
|
66
68
|
if (this.onQueryLog) {
|
|
67
69
|
this.onQueryLog(log);
|
|
68
70
|
}
|
|
@@ -72,8 +74,6 @@ class Logger {
|
|
|
72
74
|
subscribers.forEach(callback => callback(log));
|
|
73
75
|
}
|
|
74
76
|
}
|
|
75
|
-
if (!this.enabled)
|
|
76
|
-
return;
|
|
77
77
|
const { query, parameters, duration, status, error, rowCount } = log;
|
|
78
78
|
const message = `Query ${status}: ${query}`;
|
|
79
79
|
const details = {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a raw SQL expression that can be used in queries
|
|
3
|
+
*/
|
|
4
|
+
export interface SqlExpression {
|
|
5
|
+
__type: string;
|
|
6
|
+
toSql(): string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Represents an aliased SQL expression that can be used in select clauses
|
|
10
|
+
*/
|
|
11
|
+
export interface AliasedExpression extends SqlExpression {
|
|
12
|
+
__type: 'aliased_expression';
|
|
13
|
+
alias: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Creates a raw SQL expression
|
|
17
|
+
* @param sql The SQL expression string
|
|
18
|
+
* @returns A SqlExpression object
|
|
19
|
+
*/
|
|
20
|
+
export declare function raw(sql: string): SqlExpression;
|
|
21
|
+
/**
|
|
22
|
+
* Creates an aliased SQL expression for use in SELECT clauses
|
|
23
|
+
* @param sql The SQL expression string
|
|
24
|
+
* @param alias The alias to use for the expression
|
|
25
|
+
* @returns An AliasedExpression object
|
|
26
|
+
*/
|
|
27
|
+
export declare function rawAs(sql: string, alias: string): AliasedExpression;
|
|
28
|
+
/**
|
|
29
|
+
* Converts a value to DateTime format
|
|
30
|
+
* @param field The field or expression to convert
|
|
31
|
+
* @param alias Optional alias for the result
|
|
32
|
+
* @returns SQL expression or aliased expression
|
|
33
|
+
*/
|
|
34
|
+
export declare function toDateTime(field: string, alias?: string): SqlExpression | AliasedExpression;
|
|
35
|
+
/**
|
|
36
|
+
* Formats a DateTime value using the specified format
|
|
37
|
+
* @param field The field or expression to format
|
|
38
|
+
* @param format The date format string
|
|
39
|
+
* @param alias Optional alias for the result
|
|
40
|
+
* @returns SQL expression or aliased expression
|
|
41
|
+
*/
|
|
42
|
+
export declare function formatDateTime(field: string, format: string, alias?: string): SqlExpression | AliasedExpression;
|
|
43
|
+
/**
|
|
44
|
+
* Truncates a date/time value to the start of the specified interval
|
|
45
|
+
* @param field The field to truncate
|
|
46
|
+
* @param interval The interval (e.g., '1 day', '15 minute')
|
|
47
|
+
* @param alias Optional alias for the result
|
|
48
|
+
* @returns SQL expression or aliased expression
|
|
49
|
+
*/
|
|
50
|
+
export declare function toStartOfInterval(field: string, interval: string, alias?: string): SqlExpression | AliasedExpression;
|
|
51
|
+
/**
|
|
52
|
+
* Extracts the specified part from a date/time value
|
|
53
|
+
* @param part The part to extract (year, month, day, etc.)
|
|
54
|
+
* @param field The field to extract from
|
|
55
|
+
* @param alias Optional alias for the result
|
|
56
|
+
* @returns SQL expression or aliased expression
|
|
57
|
+
*/
|
|
58
|
+
export declare function datePart(part: 'year' | 'quarter' | 'month' | 'week' | 'day' | 'hour' | 'minute' | 'second', field: string, alias?: string): SqlExpression | AliasedExpression;
|
|
59
|
+
//# sourceMappingURL=sql-expressions.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ColumnType, FilterConditionInput } from '../../types';
|
|
2
|
+
export declare class FilterValidator {
|
|
3
|
+
static validateFilterCondition<T = any>(condition: FilterConditionInput<T>, columnType?: ColumnType, options?: {
|
|
4
|
+
allowNull?: boolean;
|
|
5
|
+
}): void;
|
|
6
|
+
static validateJoinedColumn(column: string): boolean;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=filter-validator.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ColumnType, FilterOperator } from '../../types';
|
|
2
|
+
export declare class ValueValidator {
|
|
3
|
+
static validateFilterValue(columnType: ColumnType, operator: FilterOperator, value: any, columnName: string): void;
|
|
4
|
+
private static validateSingleValue;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=value-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
static initialize(config: {
|
|
12
|
-
host: string;
|
|
13
|
-
username: string;
|
|
14
|
-
password: string;
|
|
15
|
-
database: string;
|
|
16
|
-
}): typeof ClickHouseConnection;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Get the ClickHouse client instance
|
|
20
|
-
*/
|
|
21
|
-
static getClient(): any;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get the current configuration
|
|
25
|
-
*/
|
|
26
|
-
static getConfig(): any;
|
|
27
|
-
}
|
|
1
|
+
export { createQueryBuilder } from './core/query-builder.js';
|
|
2
|
+
export { ClickHouseConnection } from './core/connection.js';
|
|
3
|
+
export { JoinRelationships } from './core/join-relationships.js';
|
|
4
|
+
export type { TableSchema, QueryConfig, ColumnType, WhereExpression, GroupByExpression, TableRecord, DatabaseSchema, PaginatedResult, PageInfo, PaginationOptions } from './types/base';
|
|
5
|
+
export type { JoinPath, JoinPathOptions } from './core/join-relationships.js';
|
|
6
|
+
export { CrossFilter } from './core/cross-filter.js';
|
|
7
|
+
export { logger } from './core/utils/logger.js';
|
|
8
|
+
export { raw, rawAs, toDateTime, formatDateTime, toStartOfInterval, datePart } from './core/utils/sql-expressions.js';
|
|
9
|
+
export type { SqlExpression, AliasedExpression } from './core/utils/sql-expressions.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
28
11
|
|
|
29
12
|
/**
|
|
30
13
|
* Generates TypeScript type definitions from ClickHouse schema
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,GAAG,EACH,KAAK,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACT,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,iCAAiC,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,YAAY,EACV,WAAW,EACX,WAAW,EACX,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,WAAW,EACX,cAAc,EACd,eAAe,EACf,QAAQ,EACR,iBAAiB,EAClB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EACL,GAAG,EACH,KAAK,EACL,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,QAAQ,EACT,MAAM,iCAAiC,CAAC;AACzC,YAAY,EACV,aAAa,EACb,iBAAiB,EAClB,MAAM,iCAAiC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
// Main entry point
|
|
2
|
+
export { createQueryBuilder } from './core/query-builder.js';
|
|
2
3
|
export { ClickHouseConnection } from './core/connection.js';
|
|
4
|
+
export { JoinRelationships } from './core/join-relationships.js';
|
|
5
|
+
export { CrossFilter } from './core/cross-filter.js';
|
|
6
|
+
export { logger } from './core/utils/logger.js';
|
|
7
|
+
export {
|
|
8
|
+
raw,
|
|
9
|
+
rawAs,
|
|
10
|
+
toDateTime,
|
|
11
|
+
formatDateTime,
|
|
12
|
+
toStartOfInterval,
|
|
13
|
+
datePart
|
|
14
|
+
} from './core/utils/sql-expressions.js';
|
|
3
15
|
|
|
4
|
-
// CLI
|
|
5
|
-
|
|
16
|
+
// Note: CLI functionality is deliberately not exported from the main package
|
|
17
|
+
// This prevents Node.js-specific modules from being included in browser bundles
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ClickHouseType, InferClickHouseType } from "./clickhouse-types";
|
|
2
|
+
import { FilterOperator } from "./filters";
|
|
3
|
+
export interface QueryConfig<T, Schema> {
|
|
4
|
+
select?: Array<keyof T | string>;
|
|
5
|
+
where?: WhereCondition[];
|
|
6
|
+
groupBy?: string[];
|
|
7
|
+
having?: string[];
|
|
8
|
+
limit?: number;
|
|
9
|
+
offset?: number;
|
|
10
|
+
distinct?: boolean;
|
|
11
|
+
orderBy?: Array<{
|
|
12
|
+
column: keyof T | TableColumn<Schema>;
|
|
13
|
+
direction: OrderDirection;
|
|
14
|
+
}>;
|
|
15
|
+
joins?: JoinClause[];
|
|
16
|
+
parameters?: any[];
|
|
17
|
+
ctes?: string[];
|
|
18
|
+
unionQueries?: string[];
|
|
19
|
+
settings?: string;
|
|
20
|
+
}
|
|
21
|
+
export interface TableSchema<T> {
|
|
22
|
+
name: string;
|
|
23
|
+
columns: T;
|
|
24
|
+
}
|
|
25
|
+
export type DatabaseSchema = Record<string, Record<string, ColumnType>>;
|
|
26
|
+
export type WhereExpression = string;
|
|
27
|
+
export type GroupByExpression<T> = keyof T | Array<keyof T>;
|
|
28
|
+
export type TableRecord<T> = {
|
|
29
|
+
[K in keyof T]: T[K] extends ColumnType ? InferColumnType<T[K]> : never;
|
|
30
|
+
};
|
|
31
|
+
export type ColumnType = ClickHouseType;
|
|
32
|
+
export type InferColumnType<T extends ColumnType> = InferClickHouseType<T>;
|
|
33
|
+
export type OrderDirection = 'ASC' | 'DESC';
|
|
34
|
+
export interface WhereCondition {
|
|
35
|
+
column: string;
|
|
36
|
+
operator: FilterOperator;
|
|
37
|
+
value: any;
|
|
38
|
+
conjunction: 'AND' | 'OR';
|
|
39
|
+
type?: 'condition' | 'group-start' | 'group-end';
|
|
40
|
+
}
|
|
41
|
+
export type JoinType = 'INNER' | 'LEFT' | 'RIGHT' | 'FULL';
|
|
42
|
+
export interface JoinClause {
|
|
43
|
+
type: JoinType;
|
|
44
|
+
table: string;
|
|
45
|
+
leftColumn: string;
|
|
46
|
+
rightColumn: string;
|
|
47
|
+
alias?: string;
|
|
48
|
+
}
|
|
49
|
+
export type TableColumn<Schema> = {
|
|
50
|
+
[Table in keyof Schema]: `${string & Table}.${string & keyof Schema[Table]}`;
|
|
51
|
+
}[keyof Schema] | keyof Schema[keyof Schema];
|
|
52
|
+
export type AggregationType<T, Aggregations, Column, A extends string, Suffix extends string, HasSelect extends boolean> = HasSelect extends true ? {
|
|
53
|
+
[K in keyof T | A]: K extends keyof T ? T[K] : string;
|
|
54
|
+
} : Aggregations extends Record<string, string> ? Aggregations & Record<A extends undefined ? `${Column & string}_${Suffix}` : A, string> : Record<A extends undefined ? `${Column & string}_${Suffix}` : A, string>;
|
|
55
|
+
export interface PaginationOptions<T> {
|
|
56
|
+
pageSize: number;
|
|
57
|
+
after?: string;
|
|
58
|
+
before?: string;
|
|
59
|
+
orderBy?: Array<{
|
|
60
|
+
column: keyof T | TableColumn<any>;
|
|
61
|
+
direction: OrderDirection;
|
|
62
|
+
}>;
|
|
63
|
+
}
|
|
64
|
+
export interface PageInfo {
|
|
65
|
+
hasNextPage: boolean;
|
|
66
|
+
hasPreviousPage: boolean;
|
|
67
|
+
startCursor: string;
|
|
68
|
+
endCursor: string;
|
|
69
|
+
totalCount: number;
|
|
70
|
+
totalPages: number;
|
|
71
|
+
pageSize: number;
|
|
72
|
+
}
|
|
73
|
+
export interface PaginatedResult<T> {
|
|
74
|
+
data: T[];
|
|
75
|
+
pageInfo: PageInfo;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=base.d.ts.map
|
package/dist/types/base.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/types/base.ts"],"names":[],"mappings":"AAAA,O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J;AAED,MAAM,WAAW,QAAQ;IACvB,WAAW,EAAE,OAAO,CAAC;IACrB,eAAe,EAAE,OAAO,CAAC;IACzB,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,QAAQ,EAAE,QAAQ,CAAC;CACpB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type ClickHouseInteger = 'Int8' | 'Int16' | 'Int32' | 'Int64' | 'Int128' | 'Int256' | 'UInt8' | 'UInt16' | 'UInt32' | 'UInt64' | 'UInt128' | 'UInt256';
|
|
2
|
+
export type ClickHouseFloat = 'Float32' | 'Float64';
|
|
3
|
+
export type ClickHouseDecimal = 'Decimal32' | 'Decimal64' | 'Decimal128' | 'Decimal256' | `Decimal(${number}, ${number})`;
|
|
4
|
+
export type ClickHouseDateTime = 'Date' | 'Date32' | 'DateTime' | `DateTime64(${number})` | `DateTime64(${number}, '${string}')`;
|
|
5
|
+
export type ClickHouseString = 'String' | `FixedString(${number})` | 'UUID';
|
|
6
|
+
export type ClickHouseArray = `Array(${ClickHouseBaseType})`;
|
|
7
|
+
export type ClickHouseNullable = `Nullable(${ClickHouseBaseType})`;
|
|
8
|
+
export type ClickHouseLowCardinality = `LowCardinality(${ClickHouseString})`;
|
|
9
|
+
export type ClickHouseMap = `Map(${ClickHouseBaseType}, ${ClickHouseBaseType})`;
|
|
10
|
+
export type ClickHouseBaseType = ClickHouseInteger | ClickHouseFloat | ClickHouseDecimal | ClickHouseDateTime | ClickHouseString;
|
|
11
|
+
export type ClickHouseType = ClickHouseBaseType | ClickHouseArray | ClickHouseNullable | ClickHouseLowCardinality | ClickHouseMap;
|
|
12
|
+
export type InferClickHouseType<T extends ClickHouseType> = T extends ClickHouseInteger ? number : T extends ClickHouseFloat ? number : T extends ClickHouseDecimal ? number : T extends ClickHouseDateTime ? Date : T extends ClickHouseString ? string : T extends `Array(${infer U extends ClickHouseBaseType})` ? Array<InferClickHouseType<U>> : T extends `Nullable(${infer U extends ClickHouseBaseType})` ? InferClickHouseType<U> | null : T extends `LowCardinality(${infer U extends ClickHouseString})` ? InferClickHouseType<U> : T extends `Map(${infer K extends ClickHouseBaseType}, ${infer V extends ClickHouseBaseType})` ? Map<InferClickHouseType<K>, InferClickHouseType<V>> : never;
|
|
13
|
+
//# sourceMappingURL=clickhouse-types.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { TableColumn } from "./base";
|
|
2
|
+
export type FilterValue<T> = T extends Date ? Date | string : T extends number ? number : T extends string ? string : T extends boolean ? boolean : never;
|
|
3
|
+
export type FilterCondition<T> = {
|
|
4
|
+
eq: FilterValue<T>;
|
|
5
|
+
neq: FilterValue<T>;
|
|
6
|
+
gt: T extends number | Date ? FilterValue<T> : never;
|
|
7
|
+
gte: T extends number | Date ? FilterValue<T> : never;
|
|
8
|
+
lt: T extends number | Date ? FilterValue<T> : never;
|
|
9
|
+
lte: T extends number | Date ? FilterValue<T> : never;
|
|
10
|
+
in: FilterValue<T>[];
|
|
11
|
+
notIn: FilterValue<T>[];
|
|
12
|
+
between: [FilterValue<T>, FilterValue<T>] | [string, string];
|
|
13
|
+
like: T extends string ? string : never;
|
|
14
|
+
notLike: T extends string ? string : never;
|
|
15
|
+
};
|
|
16
|
+
export type FilterValueType<T, Op extends FilterOperator> = Op extends 'in' | 'notIn' ? T extends (infer U)[] ? U[] : T[] : Op extends 'between' ? [T, T] | [string, string] : T;
|
|
17
|
+
export type OperatorValueMap<T> = {
|
|
18
|
+
'eq': T | string;
|
|
19
|
+
'neq': T | string;
|
|
20
|
+
'gt': T extends string | number | Date ? T | string : never;
|
|
21
|
+
'lt': T extends string | number | Date ? T | string : never;
|
|
22
|
+
'gte': T extends string | number | Date ? T | string : never;
|
|
23
|
+
'lte': T extends string | number | Date ? T | string : never;
|
|
24
|
+
'in': (T | string)[];
|
|
25
|
+
'notIn': (T | string)[];
|
|
26
|
+
'between': [T | string, T | string] | [string, string];
|
|
27
|
+
'like': T extends string ? string : never;
|
|
28
|
+
'notLike': T extends string ? string : never;
|
|
29
|
+
};
|
|
30
|
+
export type FilterOperator = keyof OperatorValueMap<any>;
|
|
31
|
+
export interface FilterConditionInput<T = any, Schema extends Record<string, Record<string, any>> = any, OriginalT extends Record<string, any> = any> {
|
|
32
|
+
column: keyof OriginalT | TableColumn<Schema>;
|
|
33
|
+
operator: FilterOperator;
|
|
34
|
+
value: T;
|
|
35
|
+
conjunction?: 'AND' | 'OR';
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=filters.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypequery/clickhouse",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "ClickHouse typescript query builder",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"scripts": {
|
|
9
9
|
"build": "npm run build:main && npm run build:cli && npm run fix-typedefs && npm run verify-build || npm run diagnose-ci",
|
|
10
|
-
"build:main": "tsc",
|
|
11
|
-
"build:cli": "node scripts/ensure-core-files.js && node scripts/
|
|
12
|
-
"build:ci": "npm run build:main && node scripts/
|
|
10
|
+
"build:main": "tsc --project tsconfig.json",
|
|
11
|
+
"build:cli": "node scripts/ensure-core-files.js && node scripts/handle-cli-files.js",
|
|
12
|
+
"build:ci": "npm run build:main && node scripts/ensure-core-files.js && node scripts/handle-cli-files.js && npm run fix-typedefs && npm run verify-build || npm run diagnose-ci",
|
|
13
13
|
"fix-typedefs": "node scripts/fix-typedefs.js",
|
|
14
14
|
"verify-build": "node scripts/verify-build.js",
|
|
15
15
|
"diagnose-ci": "node scripts/diagnose-ci.js",
|
|
16
16
|
"dev": "tsc --watch",
|
|
17
17
|
"test": "npm run test:unit",
|
|
18
|
-
"test:unit": "jest --testPathIgnorePatterns='integration'",
|
|
19
|
-
"test:
|
|
20
|
-
"test:
|
|
18
|
+
"test:unit": "jest --testPathIgnorePatterns='integration' --config=jest.config.cjs",
|
|
19
|
+
"test:integration": "node scripts/run-integration-tests.js",
|
|
20
|
+
"test:watch": "jest --testPathIgnorePatterns='integration' --watch --config=jest.config.cjs",
|
|
21
|
+
"test:coverage": "jest --coverage --config=jest.config.cjs",
|
|
21
22
|
"test:cli": "node scripts/test-cli-integration.js",
|
|
22
23
|
"lint": "eslint src/**/*.ts",
|
|
23
24
|
"semantic-release": "npx semantic-release",
|
|
24
|
-
"release": "npx semantic-release --extends ./.releaserc.cjs --no-ci"
|
|
25
|
+
"release": "npx semantic-release --extends ./.releaserc.cjs --no-ci",
|
|
26
|
+
"docs:api": "typedoc --options typedoc.json",
|
|
27
|
+
"docs:mdx": "npm run docs:api && node scripts/process-typedoc-markdown.js"
|
|
25
28
|
},
|
|
26
29
|
"bin": {
|
|
27
30
|
"hypequery-generate-types": "./dist/cli/bin.js"
|
|
@@ -35,6 +38,7 @@
|
|
|
35
38
|
"dotenv": "^16.0.0"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
41
|
+
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
|
|
38
42
|
"@semantic-release/changelog": "^6.0.3",
|
|
39
43
|
"@semantic-release/commit-analyzer": "^11.1.0",
|
|
40
44
|
"@semantic-release/git": "^10.0.1",
|
|
@@ -44,9 +48,12 @@
|
|
|
44
48
|
"@types/jest": "^29.5.11",
|
|
45
49
|
"@types/node": "^18.19.80",
|
|
46
50
|
"jest": "^29.7.0",
|
|
51
|
+
"jest-esbuild": "^0.3.0",
|
|
47
52
|
"semantic-release": "^23.0.2",
|
|
48
53
|
"ts-jest": "^29.1.1",
|
|
49
54
|
"ts-node": "^10.9.0",
|
|
55
|
+
"typedoc": "^0.28.1",
|
|
56
|
+
"typedoc-plugin-markdown": "^4.6.0",
|
|
50
57
|
"typescript": "^5.7.3"
|
|
51
58
|
},
|
|
52
59
|
"ts-node": {
|