@objectql/driver-excel 4.0.2 → 4.0.4
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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +60 -0
- package/dist/index.d.ts +43 -221
- package/dist/index.js +201 -884
- package/dist/index.js.map +1 -1
- package/jest.config.js +14 -1
- package/package.json +4 -3
- package/src/index.ts +217 -993
- package/test/index.test.ts +55 -0
- package/test/tck.test.ts +59 -0
- package/tsconfig.tsbuildinfo +1 -1
package/test/index.test.ts
CHANGED
|
@@ -744,4 +744,59 @@ describe('ExcelDriver', () => {
|
|
|
744
744
|
});
|
|
745
745
|
});
|
|
746
746
|
});
|
|
747
|
+
|
|
748
|
+
describe('Aggregation Operations', () => {
|
|
749
|
+
beforeEach(async () => {
|
|
750
|
+
// Create sample data for aggregation tests
|
|
751
|
+
await driver.create('orders', { id: '1', customer: 'Alice', product: 'Phone', amount: 500, quantity: 2, status: 'completed' });
|
|
752
|
+
await driver.create('orders', { id: '2', customer: 'Bob', product: 'Tablet', amount: 300, quantity: 1, status: 'pending' });
|
|
753
|
+
await driver.create('orders', { id: '3', customer: 'Alice', product: 'Laptop', amount: 700, quantity: 1, status: 'completed' });
|
|
754
|
+
await driver.create('orders', { id: '4', customer: 'Charlie', product: 'Monitor', amount: 250, quantity: 2, status: 'completed' });
|
|
755
|
+
await driver.create('orders', { id: '5', customer: 'Bob', product: 'Keyboard', amount: 100, quantity: 1, status: 'cancelled' });
|
|
756
|
+
});
|
|
757
|
+
|
|
758
|
+
test('should aggregate with $match stage', async () => {
|
|
759
|
+
const results = await driver.aggregate('orders', [
|
|
760
|
+
{ $match: { status: 'completed' } }
|
|
761
|
+
]);
|
|
762
|
+
|
|
763
|
+
expect(results).toBeDefined();
|
|
764
|
+
expect(results.length).toBe(3);
|
|
765
|
+
expect(results.every((r: any) => r.status === 'completed')).toBe(true);
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
test('should aggregate with $group and $sum', async () => {
|
|
769
|
+
const results = await driver.aggregate('orders', [
|
|
770
|
+
{ $match: { status: 'completed' } },
|
|
771
|
+
{
|
|
772
|
+
$group: {
|
|
773
|
+
_id: '$customer',
|
|
774
|
+
totalAmount: { $sum: '$amount' }
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
]);
|
|
778
|
+
|
|
779
|
+
expect(results).toBeDefined();
|
|
780
|
+
expect(results.length).toBeGreaterThan(0);
|
|
781
|
+
|
|
782
|
+
const alice = results.find((r: any) => r._id === 'Alice');
|
|
783
|
+
expect(alice).toBeDefined();
|
|
784
|
+
expect(alice.totalAmount).toBe(1200);
|
|
785
|
+
});
|
|
786
|
+
|
|
787
|
+
test('should aggregate with $group and $avg', async () => {
|
|
788
|
+
const results = await driver.aggregate('orders', [
|
|
789
|
+
{
|
|
790
|
+
$group: {
|
|
791
|
+
_id: null,
|
|
792
|
+
avgAmount: { $avg: '$amount' }
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
]);
|
|
796
|
+
|
|
797
|
+
expect(results).toBeDefined();
|
|
798
|
+
expect(results.length).toBe(1);
|
|
799
|
+
expect(results[0].avgAmount).toBeCloseTo(370, 0);
|
|
800
|
+
});
|
|
801
|
+
});
|
|
747
802
|
});
|
package/test/tck.test.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ObjectQL Excel Driver TCK Tests
|
|
3
|
+
* Copyright (c) 2026-present ObjectStack Inc.
|
|
4
|
+
*
|
|
5
|
+
* This source code is licensed under the MIT license found in the
|
|
6
|
+
* LICENSE file in the root directory of this source tree.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Excel Driver TCK (Technology Compatibility Kit) Tests
|
|
11
|
+
*
|
|
12
|
+
* This test suite verifies that the Excel driver passes all TCK requirements.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { runDriverTCK } from '@objectql/driver-tck';
|
|
16
|
+
import { ExcelDriver } from '../src';
|
|
17
|
+
import * as fs from 'fs';
|
|
18
|
+
import * as path from 'path';
|
|
19
|
+
|
|
20
|
+
describe('ExcelDriver TCK Compliance', () => {
|
|
21
|
+
const testFilePath = path.join(__dirname, 'tck-test.xlsx');
|
|
22
|
+
let driver: ExcelDriver;
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
// Clean up test file
|
|
26
|
+
if (fs.existsSync(testFilePath)) {
|
|
27
|
+
fs.unlinkSync(testFilePath);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
runDriverTCK(
|
|
32
|
+
() => {
|
|
33
|
+
driver = new ExcelDriver({
|
|
34
|
+
filePath: testFilePath,
|
|
35
|
+
autoSave: true
|
|
36
|
+
});
|
|
37
|
+
return driver;
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
skip: {
|
|
41
|
+
aggregations: true, // Excel driver doesn't support aggregations
|
|
42
|
+
transactions: true, // Excel doesn't support transactions
|
|
43
|
+
joins: true, // Excel doesn't support joins
|
|
44
|
+
},
|
|
45
|
+
timeout: 30000,
|
|
46
|
+
hooks: {
|
|
47
|
+
beforeEach: async () => {
|
|
48
|
+
// Create fresh Excel file
|
|
49
|
+
if (fs.existsSync(testFilePath)) {
|
|
50
|
+
fs.unlinkSync(testFilePath);
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
afterEach: async () => {
|
|
54
|
+
// Cleanup handled in test afterEach
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
});
|