@devrev/meerkat-node 0.0.122 → 0.0.124
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/__fixtures__/test-data-with-safe-alias.js +58 -0
- package/__fixtures__/test-data-with-safe-alias.js.map +1 -1
- package/__tests__/comprehensive/helpers/test-helpers.js +214 -0
- package/__tests__/comprehensive/helpers/test-helpers.js.map +1 -0
- package/__tests__/comprehensive/synthetic/schema-setup.js +256 -0
- package/__tests__/comprehensive/synthetic/schema-setup.js.map +1 -0
- package/__tests__/comprehensive/synthetic/table-schemas.js +453 -0
- package/__tests__/comprehensive/synthetic/table-schemas.js.map +1 -0
- package/ensure-table-schema-alias/ensure-table-schema-alias.js +39 -0
- package/ensure-table-schema-alias/ensure-table-schema-alias.js.map +1 -0
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +2 -2
- package/src/__fixtures__/test-data-with-safe-alias.d.ts +22 -1
- package/src/__fixtures__/test-data.d.ts +22 -1
- package/src/__tests__/comprehensive/helpers/test-helpers.d.ts +106 -0
- package/src/__tests__/comprehensive/synthetic/schema-setup.d.ts +31 -0
- package/src/__tests__/comprehensive/synthetic/table-schemas.d.ts +123 -0
- package/src/ensure-table-schema-alias/ensure-table-schema-alias.d.ts +3 -0
- package/src/index.d.ts +1 -0
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test Helper Utilities
|
|
3
|
+
*
|
|
4
|
+
* Common utilities for Vitest-based comprehensive tests
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Batch Error Reporter
|
|
8
|
+
*
|
|
9
|
+
* Collects multiple test failures and reports them together
|
|
10
|
+
* instead of failing on the first error. Useful for data-driven tests.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BatchErrorReporter {
|
|
13
|
+
private errors;
|
|
14
|
+
/**
|
|
15
|
+
* Add an error to the batch
|
|
16
|
+
*/
|
|
17
|
+
addError(testCase: string, error: Error, context?: any): void;
|
|
18
|
+
/**
|
|
19
|
+
* Check if there are any errors
|
|
20
|
+
*/
|
|
21
|
+
hasErrors(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Get count of errors
|
|
24
|
+
*/
|
|
25
|
+
getErrorCount(): number;
|
|
26
|
+
/**
|
|
27
|
+
* Get all errors
|
|
28
|
+
*/
|
|
29
|
+
getErrors(): {
|
|
30
|
+
testCase: string;
|
|
31
|
+
error: Error;
|
|
32
|
+
context?: any;
|
|
33
|
+
}[];
|
|
34
|
+
/**
|
|
35
|
+
* Throw if there are any errors, with a comprehensive report
|
|
36
|
+
*/
|
|
37
|
+
throwIfErrors(): void;
|
|
38
|
+
/**
|
|
39
|
+
* Clear all errors
|
|
40
|
+
*/
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Compare numeric values with tolerance for floating-point precision
|
|
45
|
+
*/
|
|
46
|
+
export declare function compareNumbers(actual: number, expected: number, tolerance?: number): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Compare query results with tolerance for numeric fields
|
|
49
|
+
*/
|
|
50
|
+
export declare function compareResults(actual: any[], expected: any[], options?: {
|
|
51
|
+
numericTolerance?: number;
|
|
52
|
+
ignoreOrder?: boolean;
|
|
53
|
+
ignoreFields?: string[];
|
|
54
|
+
}): {
|
|
55
|
+
match: boolean;
|
|
56
|
+
diff?: string;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Create a reference SQL query for validation
|
|
60
|
+
* This is the "oracle" pattern - we create direct SQL to validate Meerkat's output
|
|
61
|
+
*/
|
|
62
|
+
export declare function createReferenceSQL(options: {
|
|
63
|
+
select: string[];
|
|
64
|
+
from: string;
|
|
65
|
+
where?: string;
|
|
66
|
+
groupBy?: string[];
|
|
67
|
+
orderBy?: string[];
|
|
68
|
+
limit?: number;
|
|
69
|
+
}): string;
|
|
70
|
+
/**
|
|
71
|
+
* Measure execution time of a function
|
|
72
|
+
*/
|
|
73
|
+
export declare function measureExecutionTime<T>(fn: () => Promise<T>): Promise<{
|
|
74
|
+
result: T;
|
|
75
|
+
duration: number;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Validate query performance against a budget
|
|
79
|
+
*/
|
|
80
|
+
export declare function validatePerformance(duration: number, budgetMs: number, queryDescription: string): void;
|
|
81
|
+
/**
|
|
82
|
+
* Execute a reference SQL and validate against Meerkat result
|
|
83
|
+
*/
|
|
84
|
+
export declare function validateAgainstReference(meerkatResult: any[], referenceSQL: string, options?: {
|
|
85
|
+
numericTolerance?: number;
|
|
86
|
+
ignoreOrder?: boolean;
|
|
87
|
+
ignoreFields?: string[];
|
|
88
|
+
}): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* Generate test cases for a data-driven test
|
|
91
|
+
*/
|
|
92
|
+
export declare function generateTestCases<T>(template: T, variations: Array<Partial<T>>): T[];
|
|
93
|
+
/**
|
|
94
|
+
* Format SQL for error messages (truncate if too long)
|
|
95
|
+
*/
|
|
96
|
+
export declare function formatSQL(sql: string, maxLength?: number): string;
|
|
97
|
+
/**
|
|
98
|
+
* Retry a function with exponential backoff
|
|
99
|
+
* Useful for flaky operations
|
|
100
|
+
*/
|
|
101
|
+
export declare function retryWithBackoff<T>(fn: () => Promise<T>, options?: {
|
|
102
|
+
maxRetries?: number;
|
|
103
|
+
initialDelay?: number;
|
|
104
|
+
maxDelay?: number;
|
|
105
|
+
backoffMultiplier?: number;
|
|
106
|
+
}): Promise<T>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Synthetic Schema Setup
|
|
3
|
+
*
|
|
4
|
+
* Creates comprehensive test tables with 1M+ rows covering all data types
|
|
5
|
+
* and patterns used in production Meerkat queries.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Create the comprehensive fact_all_types table
|
|
9
|
+
* This table contains ~100 columns covering all normalized DB types
|
|
10
|
+
*/
|
|
11
|
+
export declare function createFactAllTypesTable(): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Create dimension table: dim_user
|
|
14
|
+
*/
|
|
15
|
+
export declare function createDimUserTable(): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Create dimension table: dim_part
|
|
18
|
+
*/
|
|
19
|
+
export declare function createDimPartTable(): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Create all synthetic tables in one go
|
|
22
|
+
*/
|
|
23
|
+
export declare function createAllSyntheticTables(): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Drop all synthetic tables (for cleanup)
|
|
26
|
+
*/
|
|
27
|
+
export declare function dropSyntheticTables(): Promise<void>;
|
|
28
|
+
/**
|
|
29
|
+
* Verify tables exist and have data
|
|
30
|
+
*/
|
|
31
|
+
export declare function verifySyntheticTables(): Promise<void>;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TableSchema Definitions for Synthetic Test Tables
|
|
3
|
+
*
|
|
4
|
+
* These schemas match the synthetic tables created in schema-setup.ts
|
|
5
|
+
* and follow the same conventions as production Meerkat schemas.
|
|
6
|
+
*/
|
|
7
|
+
export declare const FACT_ALL_TYPES_SCHEMA: {
|
|
8
|
+
name: string;
|
|
9
|
+
sql: string;
|
|
10
|
+
measures: {
|
|
11
|
+
name: string;
|
|
12
|
+
sql: string;
|
|
13
|
+
type: string;
|
|
14
|
+
}[];
|
|
15
|
+
dimensions: {
|
|
16
|
+
name: string;
|
|
17
|
+
sql: string;
|
|
18
|
+
type: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
export declare const DIM_USER_SCHEMA: {
|
|
22
|
+
name: string;
|
|
23
|
+
sql: string;
|
|
24
|
+
measures: {
|
|
25
|
+
name: string;
|
|
26
|
+
sql: string;
|
|
27
|
+
type: string;
|
|
28
|
+
}[];
|
|
29
|
+
dimensions: {
|
|
30
|
+
name: string;
|
|
31
|
+
sql: string;
|
|
32
|
+
type: string;
|
|
33
|
+
}[];
|
|
34
|
+
joins: {
|
|
35
|
+
name: string;
|
|
36
|
+
relationship: string;
|
|
37
|
+
sql: string;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
export declare const DIM_PART_SCHEMA: {
|
|
41
|
+
name: string;
|
|
42
|
+
sql: string;
|
|
43
|
+
measures: {
|
|
44
|
+
name: string;
|
|
45
|
+
sql: string;
|
|
46
|
+
type: string;
|
|
47
|
+
}[];
|
|
48
|
+
dimensions: {
|
|
49
|
+
name: string;
|
|
50
|
+
sql: string;
|
|
51
|
+
type: string;
|
|
52
|
+
}[];
|
|
53
|
+
joins: {
|
|
54
|
+
name: string;
|
|
55
|
+
relationship: string;
|
|
56
|
+
sql: string;
|
|
57
|
+
}[];
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Helper to get all schemas as an array
|
|
61
|
+
*/
|
|
62
|
+
export declare function getAllSchemas(): {
|
|
63
|
+
name: string;
|
|
64
|
+
sql: string;
|
|
65
|
+
measures: {
|
|
66
|
+
name: string;
|
|
67
|
+
sql: string;
|
|
68
|
+
type: string;
|
|
69
|
+
}[];
|
|
70
|
+
dimensions: {
|
|
71
|
+
name: string;
|
|
72
|
+
sql: string;
|
|
73
|
+
type: string;
|
|
74
|
+
}[];
|
|
75
|
+
}[];
|
|
76
|
+
/**
|
|
77
|
+
* Helper to get just the fact schema
|
|
78
|
+
*/
|
|
79
|
+
export declare function getFactSchema(): {
|
|
80
|
+
name: string;
|
|
81
|
+
sql: string;
|
|
82
|
+
measures: {
|
|
83
|
+
name: string;
|
|
84
|
+
sql: string;
|
|
85
|
+
type: string;
|
|
86
|
+
}[];
|
|
87
|
+
dimensions: {
|
|
88
|
+
name: string;
|
|
89
|
+
sql: string;
|
|
90
|
+
type: string;
|
|
91
|
+
}[];
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Helper to get fact + one dimension
|
|
95
|
+
*/
|
|
96
|
+
export declare function getFactWithUserSchema(): {
|
|
97
|
+
name: string;
|
|
98
|
+
sql: string;
|
|
99
|
+
measures: {
|
|
100
|
+
name: string;
|
|
101
|
+
sql: string;
|
|
102
|
+
type: string;
|
|
103
|
+
}[];
|
|
104
|
+
dimensions: {
|
|
105
|
+
name: string;
|
|
106
|
+
sql: string;
|
|
107
|
+
type: string;
|
|
108
|
+
}[];
|
|
109
|
+
}[];
|
|
110
|
+
export declare function getFactWithPartSchema(): {
|
|
111
|
+
name: string;
|
|
112
|
+
sql: string;
|
|
113
|
+
measures: {
|
|
114
|
+
name: string;
|
|
115
|
+
sql: string;
|
|
116
|
+
type: string;
|
|
117
|
+
}[];
|
|
118
|
+
dimensions: {
|
|
119
|
+
name: string;
|
|
120
|
+
sql: string;
|
|
121
|
+
type: string;
|
|
122
|
+
}[];
|
|
123
|
+
}[];
|
package/src/index.d.ts
CHANGED