@hypequery/clickhouse 1.4.0 → 1.6.0

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 (35) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +1 -1
  3. package/dist/cli/generate-types.js +1 -1
  4. package/dist/core/cache/types.d.ts +2 -2
  5. package/dist/core/features/analytics.d.ts +19 -0
  6. package/dist/core/features/analytics.d.ts.map +1 -1
  7. package/dist/core/features/analytics.js +9 -0
  8. package/dist/core/query-builder.d.ts +5 -15
  9. package/dist/core/query-builder.d.ts.map +1 -1
  10. package/dist/core/query-builder.js +31 -22
  11. package/dist/core/tests/integration/setup.d.ts +1 -0
  12. package/dist/core/tests/integration/setup.d.ts.map +1 -1
  13. package/dist/core/tests/integration/setup.js +2 -1
  14. package/dist/core/tests/test-utils.d.ts.map +1 -1
  15. package/dist/core/tests/test-utils.js +4 -2
  16. package/dist/core/types/builder-state.d.ts +7 -5
  17. package/dist/core/types/builder-state.d.ts.map +1 -1
  18. package/dist/core/types/select-types.d.ts +3 -2
  19. package/dist/core/types/select-types.d.ts.map +1 -1
  20. package/dist/core/utils/predicate-builder.d.ts +4 -0
  21. package/dist/core/utils/predicate-builder.d.ts.map +1 -1
  22. package/dist/core/utils/predicate-builder.js +4 -1
  23. package/dist/index.d.ts +1 -1
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/types/base.d.ts +0 -22
  26. package/dist/types/base.d.ts.map +1 -1
  27. package/dist/types/clickhouse-types.d.ts +1 -1
  28. package/dist/types/clickhouse-types.d.ts.map +1 -1
  29. package/package.json +26 -30
  30. package/dist/core/features/pagination.d.ts +0 -21
  31. package/dist/core/features/pagination.d.ts.map +0 -1
  32. package/dist/core/features/pagination.js +0 -165
  33. package/dist/core/tests/integration/pagination-test-tbc.d.ts +0 -2
  34. package/dist/core/tests/integration/pagination-test-tbc.d.ts.map +0 -1
  35. package/dist/core/tests/integration/pagination-test-tbc.js +0 -190
@@ -1,190 +0,0 @@
1
- // @ts-nocheck
2
- // Skipping tests becuase this feature is not ready
3
- const SKIP_INTEGRATION_TESTS = true; // process.env.SKIP_INTEGRATION_TESTS === 'true' || process.env.CI === 'true';
4
- describe('Integration Tests - Pagination', () => {
5
- // Only run these tests if not skipped
6
- // Removing until this feature is ready
7
- // (SKIP_INTEGRATION_TESTS ? describe.skip : describe)('ClickHouse Integration', () => {
8
- // let db: Awaited<ReturnType<typeof initializeTestConnection>>;
9
- // beforeAll(async () => {
10
- // if (!SKIP_INTEGRATION_TESTS) {
11
- // try {
12
- // // Start ClickHouse container
13
- // startClickHouseContainer();
14
- // // Initialize connection
15
- // db = await initializeTestConnection();
16
- // // Set up test database
17
- // await setupTestDatabase();
18
- // } catch (error) {
19
- // console.error('Failed to set up integration tests:', error);
20
- // throw error;
21
- // }
22
- // }
23
- // }, 60000); // Allow up to 60 seconds for setup
24
- // afterAll(async () => {
25
- // if (!SKIP_INTEGRATION_TESTS) {
26
- // try {
27
- // // Wait for any pending operations to complete
28
- // console.log('Starting test cleanup...');
29
- // await new Promise(resolve => setTimeout(resolve, 1000));
30
- // // Close any active client connections to prevent lingering queries
31
- // if (db) {
32
- // try {
33
- // const client = ClickHouseConnection.getClient();
34
- // console.log('Closing ClickHouse client connection...');
35
- // // Wait for any in-flight queries to complete
36
- // await new Promise(resolve => setTimeout(resolve, 500));
37
- // // Ensure we're not running any more queries
38
- // await client.close().catch(err => {
39
- // console.error('Error closing ClickHouse client:', err);
40
- // });
41
- // console.log('ClickHouse client closed successfully');
42
- // } catch (closeError) {
43
- // console.error('Error during client close:', closeError);
44
- // }
45
- // }
46
- // // Then stop the container
47
- // console.log('Stopping ClickHouse container...');
48
- // await stopClickHouseContainer();
49
- // console.log('Cleanup completed');
50
- // // Make sure all async operations have a chance to complete
51
- // await new Promise(resolve => setTimeout(resolve, 500));
52
- // } catch (error) {
53
- // console.error('Error during test cleanup:', error);
54
- // }
55
- // }
56
- // }, 15000); // Allow up to 15 seconds for teardown
57
- // test('should paginate results with cursor-based pagination', async () => {
58
- // // Get first page
59
- // const firstPage = await db.table('test_table')
60
- // .orderBy('id', 'ASC')
61
- // .paginate({
62
- // pageSize: 2,
63
- // orderBy: [{ column: 'id', direction: 'ASC' }]
64
- // });
65
- // expect(firstPage.data).toHaveLength(2);
66
- // expect(firstPage.pageInfo.hasNextPage).toBe(true);
67
- // expect(firstPage.pageInfo.hasPreviousPage).toBe(false);
68
- // expect(firstPage.pageInfo.startCursor).toBeTruthy();
69
- // expect(firstPage.pageInfo.endCursor).toBeTruthy();
70
- // expect(firstPage.data[0].id).toBe(1);
71
- // expect(firstPage.data[1].id).toBe(2);
72
- // // Get second page using the cursor
73
- // const secondPage = await db.table('test_table')
74
- // .orderBy('id', 'ASC')
75
- // .paginate({
76
- // pageSize: 2,
77
- // after: firstPage.pageInfo.endCursor,
78
- // orderBy: [{ column: 'id', direction: 'ASC' }]
79
- // });
80
- // expect(secondPage.data).toHaveLength(2);
81
- // expect(secondPage.pageInfo.hasNextPage).toBe(true);
82
- // expect(secondPage.pageInfo.hasPreviousPage).toBe(true);
83
- // expect(secondPage.data[0].id).toBe(3);
84
- // expect(secondPage.data[1].id).toBe(4);
85
- // // Get third page using the cursor
86
- // const thirdPage = await db.table('test_table')
87
- // .orderBy('id', 'ASC')
88
- // .paginate({
89
- // pageSize: 2,
90
- // after: secondPage.pageInfo.endCursor,
91
- // orderBy: [{ column: 'id', direction: 'ASC' }]
92
- // });
93
- // expect(thirdPage.data).toHaveLength(1); // Only one record left
94
- // expect(thirdPage.pageInfo.hasNextPage).toBe(false);
95
- // expect(thirdPage.pageInfo.hasPreviousPage).toBe(true);
96
- // expect(thirdPage.data[0].id).toBe(5);
97
- // });
98
- // test('should navigate backwards with cursor-based pagination', async () => {
99
- // // Get first page
100
- // const firstPage = await db.table('test_table')
101
- // .orderBy('id', 'ASC')
102
- // .paginate({
103
- // pageSize: 2,
104
- // orderBy: [{ column: 'id', direction: 'ASC' }]
105
- // });
106
- // // Get second page
107
- // const secondPage = await db.table('test_table')
108
- // .orderBy('id', 'ASC')
109
- // .paginate({
110
- // pageSize: 2,
111
- // after: firstPage.pageInfo.endCursor,
112
- // orderBy: [{ column: 'id', direction: 'ASC' }]
113
- // });
114
- // // Navigate back to first page
115
- // const backToFirstPage = await db.table('test_table')
116
- // .orderBy('id', 'ASC')
117
- // .paginate({
118
- // pageSize: 2,
119
- // before: secondPage.pageInfo.startCursor,
120
- // orderBy: [{ column: 'id', direction: 'ASC' }]
121
- // });
122
- // expect(backToFirstPage.data).toHaveLength(2);
123
- // expect(backToFirstPage.pageInfo.hasNextPage).toBe(true);
124
- // expect(backToFirstPage.pageInfo.hasPreviousPage).toBe(false);
125
- // expect(backToFirstPage.data[0].id).toBe(1);
126
- // expect(backToFirstPage.data[1].id).toBe(2);
127
- // });
128
- // test('should handle empty results', async () => {
129
- // const result = await db.table('test_table')
130
- // .where('id', 'gt', 100) // No records with id > 100
131
- // .paginate({
132
- // pageSize: 10,
133
- // orderBy: [{ column: 'id', direction: 'ASC' }]
134
- // });
135
- // expect(result.data).toHaveLength(0);
136
- // expect(result.pageInfo.hasNextPage).toBe(false);
137
- // expect(result.pageInfo.hasPreviousPage).toBe(false);
138
- // expect(result.pageInfo.startCursor).toBe('');
139
- // expect(result.pageInfo.endCursor).toBe('');
140
- // });
141
- // test('should handle exactly pageSize results', async () => {
142
- // const result = await db.table('test_table')
143
- // .where('id', 'lte', 2) // Only 2 records
144
- // .paginate({
145
- // pageSize: 2,
146
- // orderBy: [{ column: 'id', direction: 'ASC' }]
147
- // });
148
- // console.log('CHECK!!!!: ', result.pageInfo)
149
- // expect(result.data).toHaveLength(2);
150
- // expect(result.pageInfo.hasNextPage).toBe(false);
151
- // expect(result.pageInfo.hasPreviousPage).toBe(false);
152
- // });
153
- // test('should iterate through all pages', async () => {
154
- // const allResults: any[] = [];
155
- // for await (const page of db.table('test_table')
156
- // .orderBy('id', 'ASC')
157
- // .iteratePages(2)) {
158
- // allResults.push(...page.data);
159
- // }
160
- // expect(allResults).toHaveLength(TEST_DATA.test_table.length);
161
- // // Check that all records were retrieved in the correct order
162
- // for (let i = 0; i < allResults.length; i++) {
163
- // expect(allResults[i].id).toBe(i + 1);
164
- // }
165
- // });
166
- // test('should paginate with complex ordering', async () => {
167
- // // First page ordered by price descending
168
- // const firstPage = await db.table('test_table')
169
- // .paginate({
170
- // pageSize: 2,
171
- // orderBy: [{ column: 'price', direction: 'DESC' }]
172
- // });
173
- // expect(firstPage.data).toHaveLength(2);
174
- // // Verify ordering
175
- // expect(Number(firstPage.data[0].price)).toBeGreaterThanOrEqual(Number(firstPage.data[1].price));
176
- // // Get second page
177
- // const secondPage = await db.table('test_table')
178
- // .paginate({
179
- // pageSize: 2,
180
- // after: firstPage.pageInfo.endCursor,
181
- // orderBy: [{ column: 'price', direction: 'DESC' }]
182
- // });
183
- // expect(secondPage.data).toHaveLength(2);
184
- // // Verify ordering continues correctly
185
- // expect(Number(firstPage.data[1].price)).toBeGreaterThanOrEqual(Number(secondPage.data[0].price));
186
- // expect(Number(secondPage.data[0].price)).toBeGreaterThanOrEqual(Number(secondPage.data[1].price));
187
- // });
188
- // });
189
- });
190
- export {};