@hypequery/clickhouse 1.3.0 → 1.3.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.
- package/README.md +16 -0
- package/dist/core/features/aggregations.d.ts +13 -17
- package/dist/core/features/aggregations.d.ts.map +1 -1
- package/dist/core/features/aggregations.js +6 -6
- package/dist/core/features/analytics.d.ts +12 -16
- package/dist/core/features/analytics.d.ts.map +1 -1
- package/dist/core/features/analytics.js +2 -2
- package/dist/core/features/cross-filtering.d.ts +4 -19
- package/dist/core/features/cross-filtering.d.ts.map +1 -1
- package/dist/core/features/cross-filtering.js +0 -33
- package/dist/core/features/executor.d.ts +5 -9
- package/dist/core/features/executor.d.ts.map +1 -1
- package/dist/core/features/filtering.d.ts +14 -30
- package/dist/core/features/filtering.d.ts.map +1 -1
- package/dist/core/features/filtering.js +10 -26
- package/dist/core/features/joins.d.ts +6 -10
- package/dist/core/features/joins.d.ts.map +1 -1
- package/dist/core/features/pagination.d.ts +7 -10
- package/dist/core/features/pagination.d.ts.map +1 -1
- package/dist/core/features/pagination.js +13 -41
- package/dist/core/features/query-modifiers.d.ts +17 -21
- package/dist/core/features/query-modifiers.d.ts.map +1 -1
- package/dist/core/query-builder.d.ts +46 -75
- package/dist/core/query-builder.d.ts.map +1 -1
- package/dist/core/query-builder.js +74 -95
- package/dist/core/tests/integration/setup.d.ts +1 -1
- package/dist/core/tests/test-utils.d.ts +4 -3
- package/dist/core/tests/test-utils.d.ts.map +1 -1
- package/dist/core/tests/test-utils.js +18 -8
- package/dist/core/types/builder-state.d.ts +25 -0
- package/dist/core/types/builder-state.d.ts.map +1 -0
- package/dist/core/types/builder-state.js +1 -0
- package/dist/core/types/select-types.d.ts +25 -0
- package/dist/core/types/select-types.d.ts.map +1 -0
- package/dist/core/types/select-types.js +1 -0
- package/dist/core/types/type-helpers.d.ts +5 -0
- package/dist/core/types/type-helpers.d.ts.map +1 -0
- package/dist/core/types/type-helpers.js +1 -0
- package/dist/core/utils/predicate-builder.d.ts +12 -10
- package/dist/core/utils/predicate-builder.d.ts.map +1 -1
- package/dist/core/utils/predicate-builder.js +2 -1
- package/dist/core/utils/sql-expressions.d.ts +11 -10
- package/dist/core/utils/sql-expressions.d.ts.map +1 -1
- package/dist/core/utils/sql-expressions.js +4 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types/schema.d.ts +1 -1
- package/dist/types/schema.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -7,7 +7,6 @@ export class FilteringFeature {
|
|
|
7
7
|
const config = this.builder.getConfig();
|
|
8
8
|
const where = config.where || [];
|
|
9
9
|
const parameters = config.parameters || [];
|
|
10
|
-
// Handle tuple columns
|
|
11
10
|
const columnString = Array.isArray(column)
|
|
12
11
|
? `(${column.map(String).join(', ')})`
|
|
13
12
|
: String(column);
|
|
@@ -18,7 +17,6 @@ export class FilteringFeature {
|
|
|
18
17
|
conjunction,
|
|
19
18
|
type: 'condition'
|
|
20
19
|
});
|
|
21
|
-
// Handle different parameter types based on operator
|
|
22
20
|
if (operator === 'in' || operator === 'notIn' || operator === 'globalIn' || operator === 'globalNotIn') {
|
|
23
21
|
if (!Array.isArray(value)) {
|
|
24
22
|
throw new Error(`Expected an array for ${operator} operator, but got ${typeof value}`);
|
|
@@ -37,13 +35,11 @@ export class FilteringFeature {
|
|
|
37
35
|
if (typeof value !== 'string') {
|
|
38
36
|
throw new Error(`Expected a string (subquery) for ${operator} operator, but got ${typeof value}`);
|
|
39
37
|
}
|
|
40
|
-
// No parameters
|
|
41
38
|
}
|
|
42
39
|
else if (operator === 'inTable' || operator === 'globalInTable') {
|
|
43
40
|
if (typeof value !== 'string') {
|
|
44
41
|
throw new Error(`Expected a string (table name) for ${operator} operator, but got ${typeof value}`);
|
|
45
42
|
}
|
|
46
|
-
// No parameters
|
|
47
43
|
}
|
|
48
44
|
else if (operator === 'between') {
|
|
49
45
|
parameters.push(value[0], value[1]);
|
|
@@ -74,17 +70,13 @@ export class FilteringFeature {
|
|
|
74
70
|
parameters
|
|
75
71
|
};
|
|
76
72
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Adds a group-start marker to start a parenthesized group of conditions with AND conjunction
|
|
79
|
-
* @returns The updated query config
|
|
80
|
-
*/
|
|
81
73
|
startWhereGroup() {
|
|
82
74
|
const config = this.builder.getConfig();
|
|
83
75
|
const where = config.where || [];
|
|
84
76
|
where.push({
|
|
85
|
-
column: '',
|
|
86
|
-
operator: 'eq',
|
|
87
|
-
value: null,
|
|
77
|
+
column: '',
|
|
78
|
+
operator: 'eq',
|
|
79
|
+
value: null,
|
|
88
80
|
conjunction: 'AND',
|
|
89
81
|
type: 'group-start'
|
|
90
82
|
});
|
|
@@ -93,17 +85,13 @@ export class FilteringFeature {
|
|
|
93
85
|
where
|
|
94
86
|
};
|
|
95
87
|
}
|
|
96
|
-
/**
|
|
97
|
-
* Adds a group-start marker to start a parenthesized group of conditions with OR conjunction
|
|
98
|
-
* @returns The updated query config
|
|
99
|
-
*/
|
|
100
88
|
startOrWhereGroup() {
|
|
101
89
|
const config = this.builder.getConfig();
|
|
102
90
|
const where = config.where || [];
|
|
103
91
|
where.push({
|
|
104
|
-
column: '',
|
|
105
|
-
operator: 'eq',
|
|
106
|
-
value: null,
|
|
92
|
+
column: '',
|
|
93
|
+
operator: 'eq',
|
|
94
|
+
value: null,
|
|
107
95
|
conjunction: 'OR',
|
|
108
96
|
type: 'group-start'
|
|
109
97
|
});
|
|
@@ -112,18 +100,14 @@ export class FilteringFeature {
|
|
|
112
100
|
where
|
|
113
101
|
};
|
|
114
102
|
}
|
|
115
|
-
/**
|
|
116
|
-
* Adds a group-end marker to end a parenthesized group of conditions
|
|
117
|
-
* @returns The updated query config
|
|
118
|
-
*/
|
|
119
103
|
endWhereGroup() {
|
|
120
104
|
const config = this.builder.getConfig();
|
|
121
105
|
const where = config.where || [];
|
|
122
106
|
where.push({
|
|
123
|
-
column: '',
|
|
124
|
-
operator: 'eq',
|
|
125
|
-
value: null,
|
|
126
|
-
conjunction: 'AND',
|
|
107
|
+
column: '',
|
|
108
|
+
operator: 'eq',
|
|
109
|
+
value: null,
|
|
110
|
+
conjunction: 'AND',
|
|
127
111
|
type: 'group-end'
|
|
128
112
|
});
|
|
129
113
|
return {
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
+
import type { BuilderState, SchemaDefinition } from '../types/builder-state.js';
|
|
1
2
|
import { QueryBuilder } from '../query-builder.js';
|
|
2
3
|
import { JoinType } from '../../types/index.js';
|
|
3
|
-
|
|
4
|
-
export declare class JoinFeature<Schema extends {
|
|
5
|
-
[tableName: string]: {
|
|
6
|
-
[columnName: string]: ColumnType;
|
|
7
|
-
};
|
|
8
|
-
}, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
|
|
4
|
+
export declare class JoinFeature<Schema extends SchemaDefinition<Schema>, State extends BuilderState<Schema, string, any, keyof Schema, Partial<Record<string, keyof Schema>>>> {
|
|
9
5
|
private builder;
|
|
10
|
-
constructor(builder: QueryBuilder<Schema,
|
|
11
|
-
addJoin<TableName extends keyof Schema>(type: JoinType, table: TableName, leftColumn:
|
|
6
|
+
constructor(builder: QueryBuilder<Schema, State>);
|
|
7
|
+
addJoin<TableName extends keyof Schema>(type: JoinType, table: TableName, leftColumn: string, rightColumn: `${TableName & string}.${keyof Schema[TableName] & string}`, alias?: string): {
|
|
12
8
|
joins: import("../../types/base.js").JoinClause[];
|
|
13
|
-
select?: (string | keyof
|
|
9
|
+
select?: (string | keyof State["output"])[] | undefined;
|
|
14
10
|
where?: import("../../types/base.js").WhereCondition[];
|
|
15
11
|
groupBy?: string[];
|
|
16
12
|
having?: string[];
|
|
@@ -18,7 +14,7 @@ export declare class JoinFeature<Schema extends {
|
|
|
18
14
|
offset?: number;
|
|
19
15
|
distinct?: boolean;
|
|
20
16
|
orderBy?: {
|
|
21
|
-
column: keyof
|
|
17
|
+
column: keyof State["output"] | import("../../types/schema.js").TableColumn<Schema>;
|
|
22
18
|
direction: import("../../types/base.js").OrderDirection;
|
|
23
19
|
}[] | undefined;
|
|
24
20
|
parameters?: any[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"joins.d.ts","sourceRoot":"","sources":["../../../src/core/features/joins.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"joins.d.ts","sourceRoot":"","sources":["../../../src/core/features/joins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhD,qBAAa,WAAW,CACtB,MAAM,SAAS,gBAAgB,CAAC,MAAM,CAAC,EACvC,KAAK,SAAS,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC;IAExF,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAExD,OAAO,CAAC,SAAS,SAAS,MAAM,MAAM,EACpC,IAAI,EAAE,QAAQ,EACd,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,GAAG,SAAS,GAAG,MAAM,IAAI,MAAM,MAAM,CAAC,SAAS,CAAC,GAAG,MAAM,EAAE,EACxE,KAAK,CAAC,EAAE,MAAM;;;;;;;;;;;;;;;;;;CAYjB"}
|
|
@@ -1,24 +1,21 @@
|
|
|
1
|
+
import type { BuilderState, SchemaDefinition } from '../types/builder-state.js';
|
|
1
2
|
import { QueryBuilder } from '../query-builder.js';
|
|
2
3
|
import { PaginatedResult, PaginationOptions } from '../../types/index.js';
|
|
3
|
-
|
|
4
|
-
export declare class PaginationFeature<Schema extends {
|
|
5
|
-
[tableName: string]: {
|
|
6
|
-
[columnName: string]: ColumnType;
|
|
7
|
-
};
|
|
8
|
-
}, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
|
|
4
|
+
export declare class PaginationFeature<Schema extends SchemaDefinition<Schema>, State extends BuilderState<Schema, string, any, keyof Schema, Partial<Record<string, keyof Schema>>>> {
|
|
9
5
|
private builder;
|
|
10
6
|
private static cursorStacks;
|
|
11
7
|
private stackKey;
|
|
12
|
-
constructor(builder: QueryBuilder<Schema,
|
|
8
|
+
constructor(builder: QueryBuilder<Schema, State>);
|
|
13
9
|
private get cursorStack();
|
|
14
10
|
private set cursorStack(value);
|
|
15
11
|
private get currentPosition();
|
|
16
12
|
private set currentPosition(value);
|
|
17
13
|
private encodeCursor;
|
|
18
14
|
private decodeCursor;
|
|
19
|
-
paginate(options: PaginationOptions<
|
|
15
|
+
paginate(options: PaginationOptions<State['output']>): Promise<PaginatedResult<State['output']>>;
|
|
20
16
|
private generateCursor;
|
|
21
|
-
firstPage(pageSize: number): Promise<PaginatedResult<
|
|
22
|
-
iteratePages(pageSize: number): AsyncGenerator<PaginatedResult<
|
|
17
|
+
firstPage(pageSize: number): Promise<PaginatedResult<State['output']>>;
|
|
18
|
+
iteratePages(pageSize: number): AsyncGenerator<PaginatedResult<State['output']>>;
|
|
19
|
+
private paginationGenerator;
|
|
23
20
|
}
|
|
24
21
|
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/core/features/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../../../src/core/features/pagination.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAE1E,qBAAa,iBAAiB,CAC5B,MAAM,SAAS,gBAAgB,CAAC,MAAM,CAAC,EACvC,KAAK,SAAS,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC;IAKxF,OAAO,CAAC,OAAO;IAH3B,OAAO,CAAC,MAAM,CAAC,YAAY,CAAiE;IAC5F,OAAO,CAAC,QAAQ,CAAS;gBAEL,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAOxD,OAAO,KAAK,WAAW,GAEtB;IAED,OAAO,KAAK,WAAW,QAGtB;IAED,OAAO,KAAK,eAAe,GAE1B;IAED,OAAO,KAAK,eAAe,QAG1B;IAED,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,YAAY;IAId,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IA+GtG,OAAO,CAAC,cAAc;IAkBhB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;IAI5E,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,cAAc,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;YAIjE,mBAAmB;CAWnC"}
|
|
@@ -4,7 +4,6 @@ export class PaginationFeature {
|
|
|
4
4
|
stackKey;
|
|
5
5
|
constructor(builder) {
|
|
6
6
|
this.builder = builder;
|
|
7
|
-
// Create a unique key for this pagination instance based on the table and sort
|
|
8
7
|
this.stackKey = builder.getTableName();
|
|
9
8
|
if (!PaginationFeature.cursorStacks.has(this.stackKey)) {
|
|
10
9
|
PaginationFeature.cursorStacks.set(this.stackKey, { stack: [], position: -1 });
|
|
@@ -33,44 +32,34 @@ export class PaginationFeature {
|
|
|
33
32
|
async paginate(options) {
|
|
34
33
|
const { pageSize, after, before, orderBy = [] } = options;
|
|
35
34
|
const requestSize = pageSize + 1;
|
|
36
|
-
// Update cursor stack
|
|
37
35
|
if (after) {
|
|
38
|
-
// Moving forward: add new cursor and update position
|
|
39
36
|
if (this.currentPosition < this.cursorStack.length - 1) {
|
|
40
|
-
// If we're not at the end, truncate the stack
|
|
41
37
|
this.cursorStack = this.cursorStack.slice(0, this.currentPosition + 1);
|
|
42
38
|
}
|
|
43
39
|
this.cursorStack = [...this.cursorStack, after];
|
|
44
40
|
this.currentPosition = this.cursorStack.length - 1;
|
|
45
41
|
}
|
|
46
42
|
else if (before) {
|
|
47
|
-
// Moving backward: find the cursor in the stack
|
|
48
43
|
const cursorIndex = this.cursorStack.indexOf(before);
|
|
49
44
|
if (cursorIndex === -1) {
|
|
50
|
-
// If cursor not found in stack, add it
|
|
51
45
|
if (this.currentPosition === this.cursorStack.length - 1) {
|
|
52
46
|
this.cursorStack = [...this.cursorStack, before];
|
|
53
47
|
}
|
|
54
|
-
// Move back one position
|
|
55
48
|
this.currentPosition = Math.max(-1, this.currentPosition - 1);
|
|
56
49
|
}
|
|
57
50
|
else {
|
|
58
|
-
// Move to the previous cursor position
|
|
59
51
|
this.currentPosition = Math.max(-1, cursorIndex - 1);
|
|
60
52
|
}
|
|
61
53
|
}
|
|
62
54
|
else {
|
|
63
|
-
// Reset for first page only if we don't have a cursor
|
|
64
55
|
if (!this.cursorStack.length) {
|
|
65
56
|
this.cursorStack = [];
|
|
66
57
|
this.currentPosition = -1;
|
|
67
58
|
}
|
|
68
59
|
}
|
|
69
|
-
// Apply ordering first
|
|
70
60
|
orderBy.forEach(({ column, direction }) => {
|
|
71
61
|
this.builder.orderBy(column, direction);
|
|
72
62
|
});
|
|
73
|
-
// Handle cursor-based pagination
|
|
74
63
|
const cursor = after || before;
|
|
75
64
|
if (cursor && orderBy && orderBy.length > 0) {
|
|
76
65
|
const [{ column, direction }] = orderBy;
|
|
@@ -78,46 +67,33 @@ export class PaginationFeature {
|
|
|
78
67
|
const cursorValues = this.decodeCursor(cursor);
|
|
79
68
|
const value = cursorValues[columnName];
|
|
80
69
|
if (before) {
|
|
81
|
-
// For backward pagination:
|
|
82
|
-
// If sorting DESC, we want records > cursor
|
|
83
|
-
// If sorting ASC, we want records < cursor
|
|
84
70
|
const operator = direction === 'DESC' ? 'gt' : 'lt';
|
|
85
71
|
this.builder.where(columnName, operator, value);
|
|
86
|
-
// Reverse the order for backward pagination
|
|
87
72
|
orderBy.forEach(({ column, direction }) => {
|
|
88
73
|
const reversedDirection = direction === 'DESC' ? 'ASC' : 'DESC';
|
|
89
74
|
this.builder.orderBy(column, reversedDirection);
|
|
90
75
|
});
|
|
91
76
|
}
|
|
92
77
|
else {
|
|
93
|
-
// For forward pagination:
|
|
94
|
-
// If sorting DESC, we want records < cursor
|
|
95
|
-
// If sorting ASC, we want records > cursor
|
|
96
78
|
const operator = direction === 'DESC' ? 'lt' : 'gt';
|
|
97
79
|
this.builder.where(columnName, operator, value);
|
|
98
80
|
}
|
|
99
81
|
}
|
|
100
82
|
this.builder.limit(requestSize);
|
|
101
|
-
// Execute query
|
|
102
83
|
let results = await this.builder.execute();
|
|
103
|
-
// For backward pagination, we need to reverse the results
|
|
104
84
|
if (before) {
|
|
105
85
|
results = results.reverse();
|
|
106
86
|
}
|
|
107
|
-
// Only take pageSize records for the actual data
|
|
108
87
|
const data = results.slice(0, pageSize);
|
|
109
|
-
// Generate cursors
|
|
110
88
|
const startCursor = data.length > 0 ? this.generateCursor(data[0], orderBy) : '';
|
|
111
89
|
const endCursor = data.length > 0 ? this.generateCursor(data[data.length - 1], orderBy) : '';
|
|
112
|
-
// Determine if there are more pages
|
|
113
90
|
const hasMore = results.length > pageSize;
|
|
114
|
-
// For the first page
|
|
115
91
|
if (!cursor) {
|
|
116
92
|
return {
|
|
117
93
|
data,
|
|
118
94
|
pageInfo: {
|
|
119
95
|
hasNextPage: hasMore,
|
|
120
|
-
hasPreviousPage: data.length > 0 && this.currentPosition > 0,
|
|
96
|
+
hasPreviousPage: data.length > 0 && this.currentPosition > 0,
|
|
121
97
|
startCursor,
|
|
122
98
|
endCursor,
|
|
123
99
|
totalCount: 0,
|
|
@@ -126,13 +102,12 @@ export class PaginationFeature {
|
|
|
126
102
|
}
|
|
127
103
|
};
|
|
128
104
|
}
|
|
129
|
-
// For pages accessed via 'before' cursor
|
|
130
105
|
if (before) {
|
|
131
106
|
return {
|
|
132
107
|
data,
|
|
133
108
|
pageInfo: {
|
|
134
|
-
hasNextPage: true,
|
|
135
|
-
hasPreviousPage: data.length > 0 && (this.currentPosition >= 0 || hasMore),
|
|
109
|
+
hasNextPage: true,
|
|
110
|
+
hasPreviousPage: data.length > 0 && (this.currentPosition >= 0 || hasMore),
|
|
136
111
|
startCursor,
|
|
137
112
|
endCursor,
|
|
138
113
|
totalCount: 0,
|
|
@@ -141,12 +116,11 @@ export class PaginationFeature {
|
|
|
141
116
|
}
|
|
142
117
|
};
|
|
143
118
|
}
|
|
144
|
-
// For pages accessed via 'after' cursor
|
|
145
119
|
return {
|
|
146
120
|
data,
|
|
147
121
|
pageInfo: {
|
|
148
|
-
hasNextPage: hasMore,
|
|
149
|
-
hasPreviousPage: data.length > 0,
|
|
122
|
+
hasNextPage: hasMore,
|
|
123
|
+
hasPreviousPage: data.length > 0,
|
|
150
124
|
startCursor,
|
|
151
125
|
endCursor,
|
|
152
126
|
totalCount: 0,
|
|
@@ -164,7 +138,6 @@ export class PaginationFeature {
|
|
|
164
138
|
});
|
|
165
139
|
}
|
|
166
140
|
else {
|
|
167
|
-
// Use primary key or first column as default
|
|
168
141
|
const [firstColumn] = Object.keys(record);
|
|
169
142
|
if (firstColumn) {
|
|
170
143
|
cursorData[firstColumn] = record[firstColumn];
|
|
@@ -175,18 +148,17 @@ export class PaginationFeature {
|
|
|
175
148
|
async firstPage(pageSize) {
|
|
176
149
|
return this.paginate({ pageSize });
|
|
177
150
|
}
|
|
178
|
-
|
|
179
|
-
|
|
151
|
+
iteratePages(pageSize) {
|
|
152
|
+
return this.paginationGenerator(pageSize);
|
|
153
|
+
}
|
|
154
|
+
async *paginationGenerator(pageSize) {
|
|
155
|
+
let cursor;
|
|
180
156
|
while (true) {
|
|
181
|
-
const result = await this.paginate({
|
|
182
|
-
pageSize,
|
|
183
|
-
after: currentCursor
|
|
184
|
-
});
|
|
157
|
+
const result = await this.paginate({ pageSize, after: cursor });
|
|
185
158
|
yield result;
|
|
186
|
-
if (!result.pageInfo.hasNextPage)
|
|
159
|
+
if (!result.pageInfo.hasNextPage)
|
|
187
160
|
break;
|
|
188
|
-
|
|
189
|
-
currentCursor = result.pageInfo.endCursor;
|
|
161
|
+
cursor = result.pageInfo.endCursor;
|
|
190
162
|
}
|
|
191
163
|
}
|
|
192
164
|
}
|
|
@@ -1,23 +1,19 @@
|
|
|
1
|
+
import type { BuilderState, SchemaDefinition } from '../types/builder-state.js';
|
|
1
2
|
import { QueryBuilder } from '../query-builder.js';
|
|
2
3
|
import { OrderDirection } from '../../types/index.js';
|
|
3
|
-
|
|
4
|
-
export declare class QueryModifiersFeature<Schema extends {
|
|
5
|
-
[tableName: string]: {
|
|
6
|
-
[columnName: string]: ColumnType;
|
|
7
|
-
};
|
|
8
|
-
}, T, HasSelect extends boolean = false, Aggregations = {}, OriginalT = T> {
|
|
4
|
+
export declare class QueryModifiersFeature<Schema extends SchemaDefinition<Schema>, State extends BuilderState<Schema, string, any, keyof Schema, Partial<Record<string, keyof Schema>>>> {
|
|
9
5
|
private builder;
|
|
10
|
-
constructor(builder: QueryBuilder<Schema,
|
|
11
|
-
addGroupBy(columns:
|
|
6
|
+
constructor(builder: QueryBuilder<Schema, State>);
|
|
7
|
+
addGroupBy(columns: string | string[]): {
|
|
12
8
|
groupBy: string[];
|
|
13
|
-
select?: (string | keyof
|
|
9
|
+
select?: (string | keyof State["output"])[] | undefined;
|
|
14
10
|
where?: import("../../types/base.js").WhereCondition[];
|
|
15
11
|
having?: string[];
|
|
16
12
|
limit?: number;
|
|
17
13
|
offset?: number;
|
|
18
14
|
distinct?: boolean;
|
|
19
15
|
orderBy?: {
|
|
20
|
-
column: TableColumn<Schema
|
|
16
|
+
column: keyof State["output"] | import("../../types/schema.js").TableColumn<Schema>;
|
|
21
17
|
direction: OrderDirection;
|
|
22
18
|
}[] | undefined;
|
|
23
19
|
joins?: import("../../types/base.js").JoinClause[];
|
|
@@ -28,14 +24,14 @@ export declare class QueryModifiersFeature<Schema extends {
|
|
|
28
24
|
};
|
|
29
25
|
addLimit(count: number): {
|
|
30
26
|
limit: number;
|
|
31
|
-
select?: (string | keyof
|
|
27
|
+
select?: (string | keyof State["output"])[] | undefined;
|
|
32
28
|
where?: import("../../types/base.js").WhereCondition[];
|
|
33
29
|
groupBy?: string[];
|
|
34
30
|
having?: string[];
|
|
35
31
|
offset?: number;
|
|
36
32
|
distinct?: boolean;
|
|
37
33
|
orderBy?: {
|
|
38
|
-
column: TableColumn<Schema
|
|
34
|
+
column: keyof State["output"] | import("../../types/schema.js").TableColumn<Schema>;
|
|
39
35
|
direction: OrderDirection;
|
|
40
36
|
}[] | undefined;
|
|
41
37
|
joins?: import("../../types/base.js").JoinClause[];
|
|
@@ -46,14 +42,14 @@ export declare class QueryModifiersFeature<Schema extends {
|
|
|
46
42
|
};
|
|
47
43
|
addOffset(count: number): {
|
|
48
44
|
offset: number;
|
|
49
|
-
select?: (string | keyof
|
|
45
|
+
select?: (string | keyof State["output"])[] | undefined;
|
|
50
46
|
where?: import("../../types/base.js").WhereCondition[];
|
|
51
47
|
groupBy?: string[];
|
|
52
48
|
having?: string[];
|
|
53
49
|
limit?: number;
|
|
54
50
|
distinct?: boolean;
|
|
55
51
|
orderBy?: {
|
|
56
|
-
column: TableColumn<Schema
|
|
52
|
+
column: keyof State["output"] | import("../../types/schema.js").TableColumn<Schema>;
|
|
57
53
|
direction: OrderDirection;
|
|
58
54
|
}[] | undefined;
|
|
59
55
|
joins?: import("../../types/base.js").JoinClause[];
|
|
@@ -62,12 +58,12 @@ export declare class QueryModifiersFeature<Schema extends {
|
|
|
62
58
|
unionQueries?: string[];
|
|
63
59
|
settings?: string;
|
|
64
60
|
};
|
|
65
|
-
addOrderBy
|
|
61
|
+
addOrderBy(column: string, direction?: OrderDirection): {
|
|
66
62
|
orderBy: {
|
|
67
|
-
column: TableColumn<Schema
|
|
63
|
+
column: keyof State["output"] | import("../../types/schema.js").TableColumn<Schema>;
|
|
68
64
|
direction: OrderDirection;
|
|
69
65
|
}[];
|
|
70
|
-
select?: (string | keyof
|
|
66
|
+
select?: (string | keyof State["output"])[] | undefined;
|
|
71
67
|
where?: import("../../types/base.js").WhereCondition[];
|
|
72
68
|
groupBy?: string[];
|
|
73
69
|
having?: string[];
|
|
@@ -83,14 +79,14 @@ export declare class QueryModifiersFeature<Schema extends {
|
|
|
83
79
|
addHaving(condition: string, parameters?: any[]): {
|
|
84
80
|
having: string[];
|
|
85
81
|
parameters: any[] | undefined;
|
|
86
|
-
select?: (string | keyof
|
|
82
|
+
select?: (string | keyof State["output"])[] | undefined;
|
|
87
83
|
where?: import("../../types/base.js").WhereCondition[];
|
|
88
84
|
groupBy?: string[];
|
|
89
85
|
limit?: number;
|
|
90
86
|
offset?: number;
|
|
91
87
|
distinct?: boolean;
|
|
92
88
|
orderBy?: {
|
|
93
|
-
column: TableColumn<Schema
|
|
89
|
+
column: keyof State["output"] | import("../../types/schema.js").TableColumn<Schema>;
|
|
94
90
|
direction: OrderDirection;
|
|
95
91
|
}[] | undefined;
|
|
96
92
|
joins?: import("../../types/base.js").JoinClause[];
|
|
@@ -100,14 +96,14 @@ export declare class QueryModifiersFeature<Schema extends {
|
|
|
100
96
|
};
|
|
101
97
|
setDistinct(): {
|
|
102
98
|
distinct: boolean;
|
|
103
|
-
select?: (string | keyof
|
|
99
|
+
select?: (string | keyof State["output"])[] | undefined;
|
|
104
100
|
where?: import("../../types/base.js").WhereCondition[];
|
|
105
101
|
groupBy?: string[];
|
|
106
102
|
having?: string[];
|
|
107
103
|
limit?: number;
|
|
108
104
|
offset?: number;
|
|
109
105
|
orderBy?: {
|
|
110
|
-
column: TableColumn<Schema
|
|
106
|
+
column: keyof State["output"] | import("../../types/schema.js").TableColumn<Schema>;
|
|
111
107
|
direction: OrderDirection;
|
|
112
108
|
}[] | undefined;
|
|
113
109
|
joins?: import("../../types/base.js").JoinClause[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query-modifiers.d.ts","sourceRoot":"","sources":["../../../src/core/features/query-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"query-modifiers.d.ts","sourceRoot":"","sources":["../../../src/core/features/query-modifiers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,qBAAa,qBAAqB,CAChC,MAAM,SAAS,gBAAgB,CAAC,MAAM,CAAC,EACvC,KAAK,SAAS,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,MAAM,CAAC,CAAC,CAAC;IAExF,OAAO,CAAC,OAAO;gBAAP,OAAO,EAAE,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;IAExD,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE;;;;;;;;;;;;;;;;;;IAQrC,QAAQ,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;IAQtB,SAAS,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;;IAQvB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,GAAE,cAAsB;;;;;;;;;;;;;;;;;;IAQ5D,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,GAAG,EAAE;;;;;;;;;;;;;;;;;;IAY/C,WAAW;;;;;;;;;;;;;;;;;;CAOZ"}
|