@hypequery/clickhouse 0.2.1 → 0.2.2

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 (38) hide show
  1. package/dist/cli/bin.js +128 -36
  2. package/dist/cli/generate-types.js +101 -12
  3. package/dist/core/connection.d.ts +145 -0
  4. package/dist/core/connection.d.ts.map +1 -1
  5. package/dist/core/connection.js +75 -0
  6. package/dist/core/cross-filter.d.ts +85 -0
  7. package/dist/core/features/aggregations.d.ts +102 -0
  8. package/dist/core/features/analytics.d.ts +66 -0
  9. package/dist/core/features/executor.d.ts +19 -0
  10. package/dist/core/features/filtering.d.ts +29 -0
  11. package/dist/core/features/joins.d.ts +29 -0
  12. package/dist/core/features/pagination.d.ts +23 -0
  13. package/dist/core/features/query-modifiers.d.ts +119 -0
  14. package/dist/core/formatters/sql-formatter.d.ts +9 -0
  15. package/dist/core/join-relationships.d.ts +50 -0
  16. package/dist/core/query-builder.d.ts +197 -0
  17. package/dist/core/tests/index.d.ts +2 -0
  18. package/dist/core/tests/integration/setup.d.ts +40 -0
  19. package/dist/core/tests/integration/setup.d.ts.map +1 -1
  20. package/dist/core/tests/integration/setup.js +279 -237
  21. package/dist/core/tests/integration/test-initializer.d.ts +7 -0
  22. package/dist/core/tests/integration/test-initializer.d.ts.map +1 -0
  23. package/dist/core/tests/integration/test-initializer.js +32 -0
  24. package/dist/core/tests/test-utils.d.ts +30 -0
  25. package/dist/core/utils/logger.d.ts +37 -0
  26. package/dist/core/utils/sql-expressions.d.ts +59 -0
  27. package/dist/core/utils.d.ts +3 -0
  28. package/dist/core/validators/filter-validator.d.ts +8 -0
  29. package/dist/core/validators/value-validator.d.ts +6 -0
  30. package/dist/formatters/index.d.ts +1 -0
  31. package/dist/index.d.ts +10 -27
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +14 -2
  34. package/dist/types/base.d.ts +76 -0
  35. package/dist/types/clickhouse-types.d.ts +13 -0
  36. package/dist/types/filters.d.ts +37 -0
  37. package/dist/types/index.d.ts +3 -0
  38. package/package.json +15 -8
@@ -0,0 +1,85 @@
1
+ import { ColumnType, FilterOperator, InferColumnType, OperatorValueMap, FilterConditionInput } from '../types';
2
+ export interface FilterGroup<Schema extends Record<string, Record<string, any>> = any, OriginalT extends Record<string, any> = any> {
3
+ operator: 'AND' | 'OR';
4
+ conditions: Array<FilterConditionInput<any, Schema, OriginalT> | FilterGroup<Schema, OriginalT>>;
5
+ limit?: number;
6
+ orderBy?: {
7
+ column: keyof OriginalT;
8
+ direction: 'ASC' | 'DESC';
9
+ };
10
+ }
11
+ export declare const DateRange: {
12
+ readonly TODAY: "today";
13
+ readonly YESTERDAY: "yesterday";
14
+ readonly LAST_7_DAYS: "last_7_days";
15
+ readonly LAST_30_DAYS: "last_30_days";
16
+ readonly THIS_MONTH: "this_month";
17
+ readonly LAST_MONTH: "last_month";
18
+ readonly THIS_QUARTER: "this_quarter";
19
+ readonly YEAR_TO_DATE: "year_to_date";
20
+ };
21
+ export type DateRangeType = typeof DateRange[keyof typeof DateRange];
22
+ /**
23
+ * A type-safe filter builder supporting both simple conditions and complex nested groups.
24
+ * @template Schema - The full database schema type
25
+ * @template TableName - The specific table being filtered
26
+ */
27
+ export declare class CrossFilter<Schema extends {
28
+ [tableName: string]: {
29
+ [columnName: string]: ColumnType;
30
+ };
31
+ } = any, TableName extends keyof Schema = Extract<keyof Schema, string>> {
32
+ private schema?;
33
+ private rootGroup;
34
+ constructor(schema?: Schema | undefined);
35
+ /**
36
+ * Adds a single filter condition to the root group with an implicit AND conjunction.
37
+ * Performs type-safe validation if a schema is provided.
38
+ */
39
+ add<ColumnName extends Extract<keyof Schema[TableName], string>, Op extends FilterOperator>(condition: FilterConditionInput<OperatorValueMap<InferColumnType<Schema[TableName][ColumnName]>>[Op], Schema, Schema[TableName]>): this;
40
+ /**
41
+ * Adds multiple filter conditions to the root group.
42
+ */
43
+ addMultiple(conditions: Array<FilterConditionInput<any, Schema, Schema[TableName]>>): this;
44
+ /**
45
+ * Adds a nested group of filter conditions to the root group using the specified logical operator.
46
+ * @param groupConditions - Array of filter conditions or nested groups to be grouped together.
47
+ * @param operator - Logical operator ('AND' or 'OR') to combine the conditions in the group.
48
+ */
49
+ addGroup(groupConditions: Array<FilterConditionInput<any, Schema, Schema[TableName]> | FilterGroup<Schema, Schema[TableName]>>, operator: 'AND' | 'OR'): this;
50
+ /**
51
+ * Returns the current filter tree representing all conditions and groups.
52
+ */
53
+ getConditions(): FilterGroup<Schema, Schema[TableName]>;
54
+ /**
55
+ * Looks up a column's type from the schema.
56
+ * Defaults to 'String' if no schema is provided.
57
+ * @param column - The column name as a string.
58
+ */
59
+ private getColumnType;
60
+ /**
61
+ * Validates the value of a filter condition against its expected column type.
62
+ */
63
+ private validateValueType;
64
+ /**
65
+ * Recursively validates an array of filter conditions and nested groups.
66
+ */
67
+ private validateGroup;
68
+ /**
69
+ * Type guard to check if an item is a FilterGroup.
70
+ */
71
+ private isGroup;
72
+ private addDateCondition;
73
+ addDateRange<K extends keyof Schema[TableName]>(column: K extends keyof Schema[TableName] ? Schema[TableName][K] extends 'Date' | 'DateTime' ? K : never : never, range: DateRangeType): this;
74
+ lastNDays<K extends keyof Schema[TableName]>(column: K extends keyof Schema[TableName] ? Schema[TableName][K] extends 'Date' | 'DateTime' ? K : never : never, days: number): this;
75
+ addComparisonPeriod<K extends keyof Schema[TableName]>(column: K extends keyof Schema[TableName] ? Schema[TableName][K] extends 'Date' | 'DateTime' ? K : never : never, currentRange: [Date, Date]): this;
76
+ addYearOverYear<K extends keyof Schema[TableName]>(column: K extends keyof Schema[TableName] ? Schema[TableName][K] extends 'Date' | 'DateTime' ? K : never : never, currentRange: [Date, Date]): this;
77
+ /**
78
+ * Creates a filter for top N records by a value column
79
+ * @param valueColumn - The column to filter and order by
80
+ * @param n - Number of records to return
81
+ * @param orderBy - Sort direction, defaults to 'desc'
82
+ */
83
+ topN<K extends keyof Schema[TableName]>(valueColumn: K, n: number, orderBy?: 'desc' | 'asc'): this;
84
+ }
85
+ //# sourceMappingURL=cross-filter.d.ts.map
@@ -0,0 +1,102 @@
1
+ import { QueryBuilder } from '../query-builder';
2
+ import { ColumnType } from '../../types';
3
+ export declare class AggregationFeature<Schema extends {
4
+ [tableName: string]: {
5
+ [columnName: string]: ColumnType;
6
+ };
7
+ }, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
8
+ private builder;
9
+ constructor(builder: QueryBuilder<Schema, T, HasSelect, Aggregations, OriginalT>);
10
+ private createAggregation;
11
+ sum<Column extends keyof OriginalT, Alias extends string = `${Column & string}_sum`>(column: Column, alias?: Alias): {
12
+ select: string[];
13
+ where?: import("../../types").WhereCondition[];
14
+ groupBy?: string[];
15
+ having?: string[];
16
+ limit?: number;
17
+ offset?: number;
18
+ distinct?: boolean;
19
+ orderBy?: {
20
+ column: keyof T | import("../../types").TableColumn<Schema>;
21
+ direction: import("../../types").OrderDirection;
22
+ }[] | undefined;
23
+ joins?: import("../../types").JoinClause[];
24
+ parameters?: any[];
25
+ ctes?: string[];
26
+ unionQueries?: string[];
27
+ settings?: string;
28
+ };
29
+ count<Column extends keyof OriginalT, Alias extends string = `${Column & string}_count`>(column: Column, alias?: Alias): {
30
+ select: string[];
31
+ where?: import("../../types").WhereCondition[];
32
+ groupBy?: string[];
33
+ having?: string[];
34
+ limit?: number;
35
+ offset?: number;
36
+ distinct?: boolean;
37
+ orderBy?: {
38
+ column: keyof T | import("../../types").TableColumn<Schema>;
39
+ direction: import("../../types").OrderDirection;
40
+ }[] | undefined;
41
+ joins?: import("../../types").JoinClause[];
42
+ parameters?: any[];
43
+ ctes?: string[];
44
+ unionQueries?: string[];
45
+ settings?: string;
46
+ };
47
+ avg<Column extends keyof OriginalT, Alias extends string = `${Column & string}_avg`>(column: Column, alias?: Alias): {
48
+ select: string[];
49
+ where?: import("../../types").WhereCondition[];
50
+ groupBy?: string[];
51
+ having?: string[];
52
+ limit?: number;
53
+ offset?: number;
54
+ distinct?: boolean;
55
+ orderBy?: {
56
+ column: keyof T | import("../../types").TableColumn<Schema>;
57
+ direction: import("../../types").OrderDirection;
58
+ }[] | undefined;
59
+ joins?: import("../../types").JoinClause[];
60
+ parameters?: any[];
61
+ ctes?: string[];
62
+ unionQueries?: string[];
63
+ settings?: string;
64
+ };
65
+ min<Column extends keyof OriginalT, Alias extends string = `${Column & string}_min`>(column: Column, alias?: Alias): {
66
+ select: string[];
67
+ where?: import("../../types").WhereCondition[];
68
+ groupBy?: string[];
69
+ having?: string[];
70
+ limit?: number;
71
+ offset?: number;
72
+ distinct?: boolean;
73
+ orderBy?: {
74
+ column: keyof T | import("../../types").TableColumn<Schema>;
75
+ direction: import("../../types").OrderDirection;
76
+ }[] | undefined;
77
+ joins?: import("../../types").JoinClause[];
78
+ parameters?: any[];
79
+ ctes?: string[];
80
+ unionQueries?: string[];
81
+ settings?: string;
82
+ };
83
+ max<Column extends keyof OriginalT, Alias extends string = `${Column & string}_max`>(column: Column, alias?: Alias): {
84
+ select: string[];
85
+ where?: import("../../types").WhereCondition[];
86
+ groupBy?: string[];
87
+ having?: string[];
88
+ limit?: number;
89
+ offset?: number;
90
+ distinct?: boolean;
91
+ orderBy?: {
92
+ column: keyof T | import("../../types").TableColumn<Schema>;
93
+ direction: import("../../types").OrderDirection;
94
+ }[] | undefined;
95
+ joins?: import("../../types").JoinClause[];
96
+ parameters?: any[];
97
+ ctes?: string[];
98
+ unionQueries?: string[];
99
+ settings?: string;
100
+ };
101
+ }
102
+ //# sourceMappingURL=aggregations.d.ts.map
@@ -0,0 +1,66 @@
1
+ import { QueryBuilder } from '../query-builder';
2
+ import { ColumnType, TableColumn } from '../../types';
3
+ import { ClickHouseSettings } from '@clickhouse/client-web';
4
+ export declare class AnalyticsFeature<Schema extends {
5
+ [tableName: string]: {
6
+ [columnName: string]: ColumnType;
7
+ };
8
+ }, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
9
+ private builder;
10
+ constructor(builder: QueryBuilder<Schema, T, HasSelect, Aggregations, OriginalT>);
11
+ addCTE(alias: string, subquery: QueryBuilder<any, any> | string): {
12
+ ctes: string[];
13
+ select?: (string | keyof T)[] | undefined;
14
+ where?: import("../../types").WhereCondition[];
15
+ groupBy?: string[];
16
+ having?: string[];
17
+ limit?: number;
18
+ offset?: number;
19
+ distinct?: boolean;
20
+ orderBy?: {
21
+ column: keyof T | TableColumn<Schema>;
22
+ direction: import("../../types").OrderDirection;
23
+ }[] | undefined;
24
+ joins?: import("../../types").JoinClause[];
25
+ parameters?: any[];
26
+ unionQueries?: string[];
27
+ settings?: string;
28
+ };
29
+ addTimeInterval(column: keyof T | TableColumn<Schema>, interval: string, method: 'toStartOfInterval' | 'toStartOfMinute' | 'toStartOfHour' | 'toStartOfDay' | 'toStartOfWeek' | 'toStartOfMonth' | 'toStartOfQuarter' | 'toStartOfYear'): {
30
+ groupBy: string[];
31
+ select?: (string | keyof T)[] | undefined;
32
+ where?: import("../../types").WhereCondition[];
33
+ having?: string[];
34
+ limit?: number;
35
+ offset?: number;
36
+ distinct?: boolean;
37
+ orderBy?: {
38
+ column: keyof T | TableColumn<Schema>;
39
+ direction: import("../../types").OrderDirection;
40
+ }[] | undefined;
41
+ joins?: import("../../types").JoinClause[];
42
+ parameters?: any[];
43
+ ctes?: string[];
44
+ unionQueries?: string[];
45
+ settings?: string;
46
+ };
47
+ addSettings(opts: ClickHouseSettings): {
48
+ settings: string;
49
+ select?: (string | keyof T)[] | undefined;
50
+ where?: import("../../types").WhereCondition[];
51
+ groupBy?: string[];
52
+ having?: string[];
53
+ limit?: number;
54
+ offset?: number;
55
+ distinct?: boolean;
56
+ orderBy?: {
57
+ column: keyof T | TableColumn<Schema>;
58
+ direction: import("../../types").OrderDirection;
59
+ }[] | undefined;
60
+ joins?: import("../../types").JoinClause[];
61
+ parameters?: any[];
62
+ ctes?: string[];
63
+ unionQueries?: string[];
64
+ };
65
+ }
66
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1,19 @@
1
+ import { QueryBuilder } from '../query-builder';
2
+ import { ColumnType } from '../../types';
3
+ export declare class ExecutorFeature<Schema extends {
4
+ [tableName: string]: {
5
+ [columnName: string]: ColumnType;
6
+ };
7
+ }, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
8
+ private builder;
9
+ constructor(builder: QueryBuilder<Schema, T, HasSelect, Aggregations, OriginalT>);
10
+ toSQLWithParams(): {
11
+ sql: string;
12
+ parameters: any[];
13
+ };
14
+ toSQL(): string;
15
+ execute(): Promise<T[]>;
16
+ stream(): Promise<ReadableStream<T[]>>;
17
+ private toSQLWithoutParameters;
18
+ }
19
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { QueryBuilder } from '../query-builder';
2
+ import { ColumnType, FilterOperator, TableColumn } from '../../types';
3
+ export declare class FilteringFeature<Schema extends {
4
+ [tableName: string]: {
5
+ [columnName: string]: ColumnType;
6
+ };
7
+ }, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
8
+ private builder;
9
+ constructor(builder: QueryBuilder<Schema, T, HasSelect, Aggregations, OriginalT>);
10
+ addCondition<K extends keyof OriginalT | TableColumn<Schema>>(conjunction: 'AND' | 'OR', column: K, operator: FilterOperator, value: any): {
11
+ where: import("../../types").WhereCondition[];
12
+ parameters: any[];
13
+ select?: (string | keyof T)[] | undefined;
14
+ groupBy?: string[];
15
+ having?: string[];
16
+ limit?: number;
17
+ offset?: number;
18
+ distinct?: boolean;
19
+ orderBy?: {
20
+ column: TableColumn<Schema> | keyof T;
21
+ direction: import("../../types").OrderDirection;
22
+ }[] | undefined;
23
+ joins?: import("../../types").JoinClause[];
24
+ ctes?: string[];
25
+ unionQueries?: string[];
26
+ settings?: string;
27
+ };
28
+ }
29
+ //# sourceMappingURL=filtering.d.ts.map
@@ -0,0 +1,29 @@
1
+ import { QueryBuilder } from '../query-builder';
2
+ import { ColumnType, JoinType } from '../../types';
3
+ export declare class JoinFeature<Schema extends {
4
+ [tableName: string]: {
5
+ [columnName: string]: ColumnType;
6
+ };
7
+ }, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
8
+ private builder;
9
+ constructor(builder: QueryBuilder<Schema, T, HasSelect, Aggregations, OriginalT>);
10
+ addJoin<TableName extends keyof Schema>(type: JoinType, table: TableName, leftColumn: keyof OriginalT, rightColumn: `${TableName & string}.${keyof Schema[TableName] & string}`, alias?: string): {
11
+ joins: import("../../types").JoinClause[];
12
+ select?: (string | keyof T)[] | undefined;
13
+ where?: import("../../types").WhereCondition[];
14
+ groupBy?: string[];
15
+ having?: string[];
16
+ limit?: number;
17
+ offset?: number;
18
+ distinct?: boolean;
19
+ orderBy?: {
20
+ column: keyof T | import("../../types").TableColumn<Schema>;
21
+ direction: import("../../types").OrderDirection;
22
+ }[] | undefined;
23
+ parameters?: any[];
24
+ ctes?: string[];
25
+ unionQueries?: string[];
26
+ settings?: string;
27
+ };
28
+ }
29
+ //# sourceMappingURL=joins.d.ts.map
@@ -0,0 +1,23 @@
1
+ import { QueryBuilder } from '../query-builder';
2
+ import { ColumnType, PaginationOptions, PaginatedResult } from '../../types';
3
+ export declare class PaginationFeature<Schema extends {
4
+ [tableName: string]: {
5
+ [columnName: string]: ColumnType;
6
+ };
7
+ }, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
8
+ private builder;
9
+ private static cursorStacks;
10
+ private stackKey;
11
+ constructor(builder: QueryBuilder<Schema, T, HasSelect, Aggregations, OriginalT>);
12
+ private get cursorStack();
13
+ private set cursorStack(value);
14
+ private get currentPosition();
15
+ private set currentPosition(value);
16
+ private encodeCursor;
17
+ private decodeCursor;
18
+ paginate(options: PaginationOptions<T>): Promise<PaginatedResult<T>>;
19
+ private generateCursor;
20
+ firstPage(pageSize: number): Promise<PaginatedResult<T>>;
21
+ iteratePages(pageSize: number): AsyncGenerator<PaginatedResult<T>>;
22
+ }
23
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1,119 @@
1
+ import { QueryBuilder } from '../query-builder';
2
+ import { ColumnType, OrderDirection, TableColumn } from '../../types';
3
+ export declare class QueryModifiersFeature<Schema extends {
4
+ [tableName: string]: {
5
+ [columnName: string]: ColumnType;
6
+ };
7
+ }, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
8
+ private builder;
9
+ constructor(builder: QueryBuilder<Schema, T, HasSelect, Aggregations, OriginalT>);
10
+ addGroupBy(columns: (keyof T | TableColumn<Schema>) | Array<keyof T | TableColumn<Schema>>): {
11
+ groupBy: string[];
12
+ select?: (string | keyof T)[] | undefined;
13
+ where?: import("../../types").WhereCondition[];
14
+ having?: string[];
15
+ limit?: number;
16
+ offset?: number;
17
+ distinct?: boolean;
18
+ orderBy?: {
19
+ column: TableColumn<Schema> | keyof T;
20
+ direction: OrderDirection;
21
+ }[] | undefined;
22
+ joins?: import("../../types").JoinClause[];
23
+ parameters?: any[];
24
+ ctes?: string[];
25
+ unionQueries?: string[];
26
+ settings?: string;
27
+ };
28
+ addLimit(count: number): {
29
+ limit: number;
30
+ select?: (string | keyof T)[] | undefined;
31
+ where?: import("../../types").WhereCondition[];
32
+ groupBy?: string[];
33
+ having?: string[];
34
+ offset?: number;
35
+ distinct?: boolean;
36
+ orderBy?: {
37
+ column: TableColumn<Schema> | keyof T;
38
+ direction: OrderDirection;
39
+ }[] | undefined;
40
+ joins?: import("../../types").JoinClause[];
41
+ parameters?: any[];
42
+ ctes?: string[];
43
+ unionQueries?: string[];
44
+ settings?: string;
45
+ };
46
+ addOffset(count: number): {
47
+ offset: number;
48
+ select?: (string | keyof T)[] | undefined;
49
+ where?: import("../../types").WhereCondition[];
50
+ groupBy?: string[];
51
+ having?: string[];
52
+ limit?: number;
53
+ distinct?: boolean;
54
+ orderBy?: {
55
+ column: TableColumn<Schema> | keyof T;
56
+ direction: OrderDirection;
57
+ }[] | undefined;
58
+ joins?: import("../../types").JoinClause[];
59
+ parameters?: any[];
60
+ ctes?: string[];
61
+ unionQueries?: string[];
62
+ settings?: string;
63
+ };
64
+ addOrderBy<K extends keyof T | TableColumn<Schema>>(column: K, direction?: OrderDirection): {
65
+ orderBy: {
66
+ column: TableColumn<Schema> | keyof T;
67
+ direction: OrderDirection;
68
+ }[];
69
+ select?: (string | keyof T)[] | undefined;
70
+ where?: import("../../types").WhereCondition[];
71
+ groupBy?: string[];
72
+ having?: string[];
73
+ limit?: number;
74
+ offset?: number;
75
+ distinct?: boolean;
76
+ joins?: import("../../types").JoinClause[];
77
+ parameters?: any[];
78
+ ctes?: string[];
79
+ unionQueries?: string[];
80
+ settings?: string;
81
+ };
82
+ addHaving(condition: string, parameters?: any[]): {
83
+ having: string[];
84
+ parameters: any[] | undefined;
85
+ select?: (string | keyof T)[] | undefined;
86
+ where?: import("../../types").WhereCondition[];
87
+ groupBy?: string[];
88
+ limit?: number;
89
+ offset?: number;
90
+ distinct?: boolean;
91
+ orderBy?: {
92
+ column: TableColumn<Schema> | keyof T;
93
+ direction: OrderDirection;
94
+ }[] | undefined;
95
+ joins?: import("../../types").JoinClause[];
96
+ ctes?: string[];
97
+ unionQueries?: string[];
98
+ settings?: string;
99
+ };
100
+ setDistinct(): {
101
+ distinct: boolean;
102
+ select?: (string | keyof T)[] | undefined;
103
+ where?: import("../../types").WhereCondition[];
104
+ groupBy?: string[];
105
+ having?: string[];
106
+ limit?: number;
107
+ offset?: number;
108
+ orderBy?: {
109
+ column: TableColumn<Schema> | keyof T;
110
+ direction: OrderDirection;
111
+ }[] | undefined;
112
+ joins?: import("../../types").JoinClause[];
113
+ parameters?: any[];
114
+ ctes?: string[];
115
+ unionQueries?: string[];
116
+ settings?: string;
117
+ };
118
+ }
119
+ //# sourceMappingURL=query-modifiers.d.ts.map
@@ -0,0 +1,9 @@
1
+ import { QueryConfig } from '../../types';
2
+ export declare class SQLFormatter {
3
+ formatSelect(config: QueryConfig<any, any>): string;
4
+ formatGroupBy(config: QueryConfig<any, any>): string;
5
+ formatWhere(config: QueryConfig<any, any>): string;
6
+ private getSqlOperator;
7
+ formatJoins(config: QueryConfig<any, any>): string;
8
+ }
9
+ //# sourceMappingURL=sql-formatter.d.ts.map
@@ -0,0 +1,50 @@
1
+ import { ColumnType, JoinType } from '../types';
2
+ export interface JoinPath<Schema> {
3
+ from: keyof Schema;
4
+ to: keyof Schema;
5
+ leftColumn: string;
6
+ rightColumn: string;
7
+ type?: JoinType;
8
+ alias?: string;
9
+ }
10
+ export interface JoinPathOptions {
11
+ type?: JoinType;
12
+ alias?: string;
13
+ context?: Record<string, any>;
14
+ }
15
+ export declare class JoinRelationships<Schema extends {
16
+ [tableName: string]: {
17
+ [columnName: string]: ColumnType;
18
+ };
19
+ }> {
20
+ private paths;
21
+ /**
22
+ * Define a single join relationship
23
+ */
24
+ define(name: string, path: JoinPath<Schema>): void;
25
+ /**
26
+ * Define a chain of join relationships
27
+ */
28
+ defineChain(name: string, paths: JoinPath<Schema>[]): void;
29
+ /**
30
+ * Get a join relationship by name
31
+ */
32
+ get(name: string): JoinPath<Schema> | JoinPath<Schema>[] | undefined;
33
+ /**
34
+ * Check if a join relationship exists
35
+ */
36
+ has(name: string): boolean;
37
+ /**
38
+ * Remove a join relationship
39
+ */
40
+ remove(name: string): boolean;
41
+ /**
42
+ * Clear all join relationships
43
+ */
44
+ clear(): void;
45
+ /**
46
+ * Get all defined relationship names
47
+ */
48
+ getDefinedRelationships(): string[];
49
+ }
50
+ //# sourceMappingURL=join-relationships.d.ts.map