@malloydata/malloy 0.0.327 → 0.0.329
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/dist/dialect/dialect.d.ts +20 -21
- package/dist/dialect/dialect.js +26 -7
- package/dist/dialect/duckdb/duckdb.d.ts +2 -2
- package/dist/dialect/duckdb/duckdb.js +5 -5
- package/dist/dialect/snowflake/snowflake.d.ts +2 -2
- package/dist/dialect/snowflake/snowflake.js +4 -5
- package/dist/dialect/standardsql/standardsql.d.ts +2 -2
- package/dist/dialect/standardsql/standardsql.js +4 -5
- package/dist/lang/ast/expressions/expr-number.d.ts +5 -9
- package/dist/lang/ast/expressions/expr-number.js +14 -63
- package/dist/malloy.js +6 -1
- package/dist/test/index.d.ts +40 -0
- package/dist/test/index.js +79 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -34,26 +34,16 @@ export type OrderByClauseType = 'output_name' | 'ordinal' | 'expression';
|
|
|
34
34
|
export type OrderByRequest = 'query' | 'turtle' | 'analytical';
|
|
35
35
|
export type BooleanTypeSupport = 'supported' | 'simulated' | 'none';
|
|
36
36
|
/**
|
|
37
|
-
*
|
|
38
|
-
* - null: type is not supported by this dialect
|
|
39
|
-
* - {min, max}: the range of values (use the exported constants like MIN_INT64, MAX_INT64)
|
|
40
|
-
*/
|
|
41
|
-
export type IntegerTypeRange = {
|
|
42
|
-
min: number | bigint;
|
|
43
|
-
max: number | bigint;
|
|
44
|
-
} | null;
|
|
45
|
-
/**
|
|
46
|
-
* Configuration for integer literal type selection.
|
|
37
|
+
* Maps a range of integer values to a Malloy number type.
|
|
47
38
|
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
39
|
+
* Dialects define an array of these mappings to describe how integer literals
|
|
40
|
+
* should be typed. The array is searched in order, and the first matching
|
|
41
|
+
* range determines the type.
|
|
51
42
|
*/
|
|
52
|
-
export interface
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
bigint: IntegerTypeRange;
|
|
43
|
+
export interface IntegerTypeMapping {
|
|
44
|
+
min: bigint;
|
|
45
|
+
max: bigint;
|
|
46
|
+
numberType: 'integer' | 'bigint';
|
|
57
47
|
}
|
|
58
48
|
export declare abstract class Dialect {
|
|
59
49
|
abstract name: string;
|
|
@@ -94,10 +84,19 @@ export declare abstract class Dialect {
|
|
|
94
84
|
booleanType: BooleanTypeSupport;
|
|
95
85
|
likeEscape: boolean;
|
|
96
86
|
/**
|
|
97
|
-
*
|
|
98
|
-
*
|
|
87
|
+
* Mappings from integer value ranges to Malloy number types.
|
|
88
|
+
*
|
|
89
|
+
* The array is searched in order; the first matching range determines the type.
|
|
90
|
+
* Default: small integers (≤32-bit) → 'integer', larger → 'bigint'.
|
|
91
|
+
*/
|
|
92
|
+
integerTypeMappings: IntegerTypeMapping[];
|
|
93
|
+
/**
|
|
94
|
+
* Determine the Malloy number type for a numeric literal.
|
|
99
95
|
*/
|
|
100
|
-
|
|
96
|
+
literalNumberType(value: string): {
|
|
97
|
+
type: 'number';
|
|
98
|
+
numberType: 'integer' | 'float' | 'bigint';
|
|
99
|
+
};
|
|
101
100
|
/**
|
|
102
101
|
* Create the appropriate time literal IR node based on dialect support.
|
|
103
102
|
* Static method so it can be called with undefined dialect (e.g., ConstantFieldSpace).
|
package/dist/dialect/dialect.js
CHANGED
|
@@ -28,7 +28,7 @@ exports.qtz = qtz;
|
|
|
28
28
|
const malloy_types_1 = require("../model/malloy_types");
|
|
29
29
|
/*
|
|
30
30
|
* Standard integer type limits.
|
|
31
|
-
* Use these in dialect
|
|
31
|
+
* Use these in dialect integerTypeMappings definitions.
|
|
32
32
|
*/
|
|
33
33
|
// 32-bit signed integer limits (for databases with 32-bit INTEGER type)
|
|
34
34
|
exports.MIN_INT32 = -2147483648; // -2^31
|
|
@@ -110,13 +110,32 @@ class Dialect {
|
|
|
110
110
|
// Like characters are escaped with ESCAPE clause
|
|
111
111
|
this.likeEscape = true;
|
|
112
112
|
/**
|
|
113
|
-
*
|
|
114
|
-
*
|
|
113
|
+
* Mappings from integer value ranges to Malloy number types.
|
|
114
|
+
*
|
|
115
|
+
* The array is searched in order; the first matching range determines the type.
|
|
116
|
+
* Default: small integers (≤32-bit) → 'integer', larger → 'bigint'.
|
|
115
117
|
*/
|
|
116
|
-
this.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
this.integerTypeMappings = [
|
|
119
|
+
{ min: BigInt(exports.MIN_INT32), max: BigInt(exports.MAX_INT32), numberType: 'integer' },
|
|
120
|
+
{ min: exports.MIN_INT64, max: exports.MAX_INT64, numberType: 'bigint' },
|
|
121
|
+
];
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Determine the Malloy number type for a numeric literal.
|
|
125
|
+
*/
|
|
126
|
+
literalNumberType(value) {
|
|
127
|
+
const isInteger = /^-?\d+$/.test(value);
|
|
128
|
+
if (!isInteger) {
|
|
129
|
+
return { type: 'number', numberType: 'float' };
|
|
130
|
+
}
|
|
131
|
+
const bigValue = BigInt(value);
|
|
132
|
+
for (const mapping of this.integerTypeMappings) {
|
|
133
|
+
if (bigValue >= mapping.min && bigValue <= mapping.max) {
|
|
134
|
+
return { type: 'number', numberType: mapping.numberType };
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// Value exceeds all supported ranges - let SQL fail at runtime
|
|
138
|
+
return { type: 'number', numberType: 'bigint' };
|
|
120
139
|
}
|
|
121
140
|
/**
|
|
122
141
|
* Create the appropriate time literal IR node based on dialect support.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Sampling, AtomicTypeDef, RegexMatchExpr, MeasureTimeExpr, BasicAtomicTypeDef, RecordLiteralNode, OrderBy, TimestampUnit } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import type { DialectFieldList, FieldReferenceType,
|
|
3
|
+
import type { DialectFieldList, FieldReferenceType, IntegerTypeMapping } from '../dialect';
|
|
4
4
|
import { PostgresBase } from '../pg_impl';
|
|
5
5
|
export declare class DuckDBDialect extends PostgresBase {
|
|
6
6
|
name: string;
|
|
@@ -22,7 +22,7 @@ export declare class DuckDBDialect extends PostgresBase {
|
|
|
22
22
|
supportsSafeCast: boolean;
|
|
23
23
|
supportsNesting: boolean;
|
|
24
24
|
supportsCountApprox: boolean;
|
|
25
|
-
|
|
25
|
+
integerTypeMappings: IntegerTypeMapping[];
|
|
26
26
|
get udfPrefix(): string;
|
|
27
27
|
quoteTablePath(tableName: string): string;
|
|
28
28
|
sqlGroupSetTable(groupSetCount: number): string;
|
|
@@ -73,11 +73,11 @@ class DuckDBDialect extends pg_impl_1.PostgresBase {
|
|
|
73
73
|
this.supportsSafeCast = true;
|
|
74
74
|
this.supportsNesting = true;
|
|
75
75
|
this.supportsCountApprox = true;
|
|
76
|
-
// DuckDB
|
|
77
|
-
this.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
// DuckDB: 32-bit INTEGER is safe, larger integers need bigint
|
|
77
|
+
this.integerTypeMappings = [
|
|
78
|
+
{ min: BigInt(dialect_1.MIN_INT32), max: BigInt(dialect_1.MAX_INT32), numberType: 'integer' },
|
|
79
|
+
{ min: dialect_1.MIN_INT128, max: dialect_1.MAX_INT128, numberType: 'bigint' },
|
|
80
|
+
];
|
|
81
81
|
}
|
|
82
82
|
// hack until they support temporary macros.
|
|
83
83
|
get udfPrefix() {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Sampling, AtomicTypeDef, TimeExtractExpr, TypecastExpr, MeasureTimeExpr, RegexMatchExpr, BasicAtomicTypeDef, TimestampTypeDef, ArrayLiteralNode, RecordLiteralNode } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import type { DialectFieldList, FieldReferenceType,
|
|
3
|
+
import type { DialectFieldList, FieldReferenceType, IntegerTypeMapping, QueryInfo } from '../dialect';
|
|
4
4
|
import { Dialect } from '../dialect';
|
|
5
5
|
export declare class SnowflakeDialect extends Dialect {
|
|
6
6
|
name: string;
|
|
@@ -26,7 +26,7 @@ export declare class SnowflakeDialect extends Dialect {
|
|
|
26
26
|
supportsQualify: boolean;
|
|
27
27
|
supportsPipelinesInViews: boolean;
|
|
28
28
|
supportsComplexFilteredSources: boolean;
|
|
29
|
-
|
|
29
|
+
integerTypeMappings: IntegerTypeMapping[];
|
|
30
30
|
quoteTablePath(tablePath: string): string;
|
|
31
31
|
sqlGroupSetTable(groupSetCount: number): string;
|
|
32
32
|
sqlAnyValue(groupSet: number, fieldName: string): string;
|
|
@@ -98,11 +98,10 @@ class SnowflakeDialect extends dialect_1.Dialect {
|
|
|
98
98
|
this.supportsQualify = false;
|
|
99
99
|
this.supportsPipelinesInViews = false;
|
|
100
100
|
this.supportsComplexFilteredSources = false;
|
|
101
|
-
// Snowflake uses NUMBER(38,0) for all integers -
|
|
102
|
-
this.
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
};
|
|
101
|
+
// Snowflake uses NUMBER(38,0) for all integers - can exceed JS Number precision
|
|
102
|
+
this.integerTypeMappings = [
|
|
103
|
+
{ min: dialect_1.MIN_DECIMAL38, max: dialect_1.MAX_DECIMAL38, numberType: 'bigint' },
|
|
104
|
+
];
|
|
106
105
|
}
|
|
107
106
|
// don't mess with the table pathing.
|
|
108
107
|
quoteTablePath(tablePath) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Sampling, AtomicTypeDef, TimeExtractExpr, TypecastExpr, RegexMatchExpr, MeasureTimeExpr, BasicAtomicTypeDef, RecordLiteralNode, ArrayLiteralNode, TimestampUnit, TimestampTypeDef } from '../../model/malloy_types';
|
|
2
2
|
import type { DialectFunctionOverloadDef } from '../functions';
|
|
3
|
-
import type { DialectFieldList,
|
|
3
|
+
import type { DialectFieldList, IntegerTypeMapping, OrderByRequest, QueryInfo } from '../dialect';
|
|
4
4
|
import { Dialect } from '../dialect';
|
|
5
5
|
export declare class StandardSQLDialect extends Dialect {
|
|
6
6
|
name: string;
|
|
@@ -27,7 +27,7 @@ export declare class StandardSQLDialect extends Dialect {
|
|
|
27
27
|
nestedArrays: boolean;
|
|
28
28
|
supportsHyperLogLog: boolean;
|
|
29
29
|
likeEscape: boolean;
|
|
30
|
-
|
|
30
|
+
integerTypeMappings: IntegerTypeMapping[];
|
|
31
31
|
quoteTablePath(tablePath: string): string;
|
|
32
32
|
needsCivilTimeComputation(typeDef: AtomicTypeDef, truncateTo: TimestampUnit | undefined, offsetUnit: TimestampUnit | undefined, qi: QueryInfo): {
|
|
33
33
|
needed: boolean;
|
|
@@ -97,11 +97,10 @@ class StandardSQLDialect extends dialect_1.Dialect {
|
|
|
97
97
|
this.nestedArrays = false; // Can't have an array of arrays for some reason
|
|
98
98
|
this.supportsHyperLogLog = true;
|
|
99
99
|
this.likeEscape = false; // Uses \ instead of ESCAPE 'X' in like clauses
|
|
100
|
-
// BigQuery only has INT64 -
|
|
101
|
-
this.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
};
|
|
100
|
+
// BigQuery only has INT64 - all integers can exceed JS Number precision
|
|
101
|
+
this.integerTypeMappings = [
|
|
102
|
+
{ min: dialect_1.MIN_INT64, max: dialect_1.MAX_INT64, numberType: 'bigint' },
|
|
103
|
+
];
|
|
105
104
|
}
|
|
106
105
|
quoteTablePath(tablePath) {
|
|
107
106
|
return `\`${tablePath}\``;
|
|
@@ -7,19 +7,15 @@ export declare class ExprNumber extends ExpressionDef {
|
|
|
7
7
|
elementType: string;
|
|
8
8
|
constructor(n: string);
|
|
9
9
|
getExpression(fs: FieldSpace): ExprValue;
|
|
10
|
+
/**
|
|
11
|
+
* Default number type when no dialect is available.
|
|
12
|
+
* Integers default to bigint for safety, floats to float.
|
|
13
|
+
*/
|
|
14
|
+
private defaultNumberType;
|
|
10
15
|
/**
|
|
11
16
|
* For constants (no dialect context), always use bigint for integers
|
|
12
17
|
* to ensure large values render correctly.
|
|
13
18
|
*/
|
|
14
19
|
constantExpression(): ExprValue;
|
|
15
|
-
/**
|
|
16
|
-
* Select the appropriate integer type based on dialect limits.
|
|
17
|
-
* Returns null if no type can hold the value.
|
|
18
|
-
*/
|
|
19
|
-
private selectIntegerType;
|
|
20
|
-
/**
|
|
21
|
-
* Get the largest supported range for error messages.
|
|
22
|
-
*/
|
|
23
|
-
private getMaxRange;
|
|
24
20
|
getStableLiteral(): Malloy.LiteralValue;
|
|
25
21
|
}
|
|
@@ -32,82 +32,33 @@ class ExprNumber extends expression_def_1.ExpressionDef {
|
|
|
32
32
|
this.elementType = 'numeric literal';
|
|
33
33
|
}
|
|
34
34
|
getExpression(fs) {
|
|
35
|
-
var _a
|
|
36
|
-
// Check if this is an integer (no decimal point, no exponent notation)
|
|
37
|
-
const isInteger = /^-?\d+$/.test(this.n);
|
|
38
|
-
if (!isInteger) {
|
|
39
|
-
return (0, expr_value_1.literalExprValue)({
|
|
40
|
-
dataType: { type: 'number', numberType: 'float' },
|
|
41
|
-
value: { node: 'numberLiteral', literal: this.n },
|
|
42
|
-
});
|
|
43
|
-
}
|
|
35
|
+
var _a;
|
|
44
36
|
const dialect = fs.dialectObj();
|
|
45
|
-
const
|
|
46
|
-
integer: { min: Number.MIN_SAFE_INTEGER, max: Number.MAX_SAFE_INTEGER },
|
|
47
|
-
bigint: null,
|
|
48
|
-
};
|
|
49
|
-
const literalValue = BigInt(this.n);
|
|
50
|
-
const numberType = this.selectIntegerType(literalValue, limits);
|
|
51
|
-
if (numberType === null) {
|
|
52
|
-
// Find the largest supported range for the error message
|
|
53
|
-
const maxRange = this.getMaxRange(limits);
|
|
54
|
-
this.logError('integer-literal-out-of-range', `Integer literal ${this.n} exceeds ${(_b = dialect === null || dialect === void 0 ? void 0 : dialect.name) !== null && _b !== void 0 ? _b : 'dialect'} integer range [${maxRange.min} to ${maxRange.max}]`);
|
|
55
|
-
// Fall back to bigint so we can continue compilation
|
|
56
|
-
return (0, expr_value_1.literalExprValue)({
|
|
57
|
-
dataType: { type: 'number', numberType: 'bigint' },
|
|
58
|
-
value: { node: 'numberLiteral', literal: this.n },
|
|
59
|
-
});
|
|
60
|
-
}
|
|
37
|
+
const dataType = (_a = dialect === null || dialect === void 0 ? void 0 : dialect.literalNumberType(this.n)) !== null && _a !== void 0 ? _a : this.defaultNumberType();
|
|
61
38
|
return (0, expr_value_1.literalExprValue)({
|
|
62
|
-
dataType
|
|
39
|
+
dataType,
|
|
63
40
|
value: { node: 'numberLiteral', literal: this.n },
|
|
64
41
|
});
|
|
65
42
|
}
|
|
66
43
|
/**
|
|
67
|
-
*
|
|
68
|
-
* to
|
|
44
|
+
* Default number type when no dialect is available.
|
|
45
|
+
* Integers default to bigint for safety, floats to float.
|
|
69
46
|
*/
|
|
70
|
-
|
|
47
|
+
defaultNumberType() {
|
|
71
48
|
const isInteger = /^-?\d+$/.test(this.n);
|
|
72
|
-
|
|
49
|
+
return isInteger
|
|
73
50
|
? { type: 'number', numberType: 'bigint' }
|
|
74
51
|
: { type: 'number', numberType: 'float' };
|
|
75
|
-
return (0, expr_value_1.literalExprValue)({
|
|
76
|
-
dataType,
|
|
77
|
-
value: { node: 'numberLiteral', literal: this.n },
|
|
78
|
-
});
|
|
79
52
|
}
|
|
80
53
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*/
|
|
84
|
-
selectIntegerType(value, limits) {
|
|
85
|
-
const types = ['integer', 'bigint'];
|
|
86
|
-
for (const numType of types) {
|
|
87
|
-
const range = limits[numType];
|
|
88
|
-
if (range !== null) {
|
|
89
|
-
// Comparison between bigint and number works in JS
|
|
90
|
-
if (value >= range.min && value <= range.max) {
|
|
91
|
-
return numType;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
return null;
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* Get the largest supported range for error messages.
|
|
54
|
+
* For constants (no dialect context), always use bigint for integers
|
|
55
|
+
* to ensure large values render correctly.
|
|
99
56
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (range !== null) {
|
|
106
|
-
return range;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
// Should never happen, but fallback
|
|
110
|
-
return { min: 0, max: 0 };
|
|
57
|
+
constantExpression() {
|
|
58
|
+
return (0, expr_value_1.literalExprValue)({
|
|
59
|
+
dataType: this.defaultNumberType(),
|
|
60
|
+
value: { node: 'numberLiteral', literal: this.n },
|
|
61
|
+
});
|
|
111
62
|
}
|
|
112
63
|
getStableLiteral() {
|
|
113
64
|
return {
|
package/dist/malloy.js
CHANGED
|
@@ -2432,7 +2432,12 @@ class Result extends PreparedResult {
|
|
|
2432
2432
|
return this.inner.profilingUrl;
|
|
2433
2433
|
}
|
|
2434
2434
|
toJSON() {
|
|
2435
|
-
|
|
2435
|
+
// The result rows are converted to JSON separately because they
|
|
2436
|
+
// may contain un-serializable data types.
|
|
2437
|
+
return {
|
|
2438
|
+
queryResult: { ...this.inner, result: this.data.toJSON() },
|
|
2439
|
+
modelDef: this._modelDef,
|
|
2440
|
+
};
|
|
2436
2441
|
}
|
|
2437
2442
|
static fromJSON({ queryResult, modelDef }) {
|
|
2438
2443
|
return new Result(queryResult, modelDef);
|
package/dist/test/index.d.ts
CHANGED
|
@@ -1,3 +1,43 @@
|
|
|
1
|
+
import type { Connection, URLReader, EventStream, CacheManager } from '..';
|
|
2
|
+
import { SingleConnectionRuntime } from '..';
|
|
3
|
+
/**
|
|
4
|
+
* Options for createTestRuntime.
|
|
5
|
+
*/
|
|
6
|
+
export interface TestRuntimeOptions {
|
|
7
|
+
/** Custom URL reader. Defaults to reading from filesystem. */
|
|
8
|
+
urlReader?: URLReader;
|
|
9
|
+
/** Event stream for runtime events. */
|
|
10
|
+
eventStream?: EventStream;
|
|
11
|
+
/** Cache manager for model caching. */
|
|
12
|
+
cacheManager?: CacheManager;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Create a SingleConnectionRuntime for testing.
|
|
16
|
+
*
|
|
17
|
+
* By default, creates a runtime with a file URL reader that reads from the filesystem.
|
|
18
|
+
* Options can be provided to customize the URL reader, event stream, and cache manager.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* // Simple usage (connection package tests)
|
|
22
|
+
* import { createTestRuntime } from '@malloydata/malloy/test';
|
|
23
|
+
* import { BigQueryConnection } from '@malloydata/malloy-db-bigquery';
|
|
24
|
+
*
|
|
25
|
+
* const bq = new BigQueryConnection('test');
|
|
26
|
+
* const runtime = createTestRuntime(bq);
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // With options (internal test infrastructure)
|
|
30
|
+
* const runtime = createTestRuntime(connection, {
|
|
31
|
+
* urlReader: customReader,
|
|
32
|
+
* eventStream: new EventEmitter(),
|
|
33
|
+
* cacheManager: new TestCacheManager(),
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* @param connection - The database connection to use
|
|
37
|
+
* @param options - Optional configuration for the runtime
|
|
38
|
+
* @returns A SingleConnectionRuntime configured for testing
|
|
39
|
+
*/
|
|
40
|
+
export declare function createTestRuntime<T extends Connection>(connection: T, options?: TestRuntimeOptions): SingleConnectionRuntime<T>;
|
|
1
41
|
export { TV } from './test-values';
|
|
2
42
|
export type { TypedValue } from './test-values';
|
|
3
43
|
export { mkTestModel, wrapTestModel, extendTestModel } from './test-models';
|
package/dist/test/index.js
CHANGED
|
@@ -3,11 +3,90 @@
|
|
|
3
3
|
* Copyright Contributors to the Malloy project
|
|
4
4
|
* SPDX-License-Identifier: MIT
|
|
5
5
|
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
6
39
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
40
|
exports.runQuery = exports.extendTestModel = exports.wrapTestModel = exports.mkTestModel = exports.TV = void 0;
|
|
41
|
+
exports.createTestRuntime = createTestRuntime;
|
|
8
42
|
exports.databasesFromEnvironmentOr = databasesFromEnvironmentOr;
|
|
9
43
|
exports.describeIfDatabaseAvailable = describeIfDatabaseAvailable;
|
|
10
44
|
exports.brokenIn = brokenIn;
|
|
45
|
+
const fs = __importStar(require("fs"));
|
|
46
|
+
const util = __importStar(require("util"));
|
|
47
|
+
const url_1 = require("url");
|
|
48
|
+
const __1 = require("..");
|
|
49
|
+
/**
|
|
50
|
+
* Create a SingleConnectionRuntime for testing.
|
|
51
|
+
*
|
|
52
|
+
* By default, creates a runtime with a file URL reader that reads from the filesystem.
|
|
53
|
+
* Options can be provided to customize the URL reader, event stream, and cache manager.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* // Simple usage (connection package tests)
|
|
57
|
+
* import { createTestRuntime } from '@malloydata/malloy/test';
|
|
58
|
+
* import { BigQueryConnection } from '@malloydata/malloy-db-bigquery';
|
|
59
|
+
*
|
|
60
|
+
* const bq = new BigQueryConnection('test');
|
|
61
|
+
* const runtime = createTestRuntime(bq);
|
|
62
|
+
*
|
|
63
|
+
* @example
|
|
64
|
+
* // With options (internal test infrastructure)
|
|
65
|
+
* const runtime = createTestRuntime(connection, {
|
|
66
|
+
* urlReader: customReader,
|
|
67
|
+
* eventStream: new EventEmitter(),
|
|
68
|
+
* cacheManager: new TestCacheManager(),
|
|
69
|
+
* });
|
|
70
|
+
*
|
|
71
|
+
* @param connection - The database connection to use
|
|
72
|
+
* @param options - Optional configuration for the runtime
|
|
73
|
+
* @returns A SingleConnectionRuntime configured for testing
|
|
74
|
+
*/
|
|
75
|
+
function createTestRuntime(connection, options) {
|
|
76
|
+
var _a;
|
|
77
|
+
const urlReader = (_a = options === null || options === void 0 ? void 0 : options.urlReader) !== null && _a !== void 0 ? _a : {
|
|
78
|
+
readURL: async (url) => {
|
|
79
|
+
const filePath = (0, url_1.fileURLToPath)(url);
|
|
80
|
+
return await util.promisify(fs.readFile)(filePath, 'utf8');
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
return new __1.SingleConnectionRuntime({
|
|
84
|
+
urlReader,
|
|
85
|
+
connection,
|
|
86
|
+
eventStream: options === null || options === void 0 ? void 0 : options.eventStream,
|
|
87
|
+
cacheManager: options === null || options === void 0 ? void 0 : options.cacheManager,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
11
90
|
// Test data creation
|
|
12
91
|
var test_values_1 = require("./test-values");
|
|
13
92
|
Object.defineProperty(exports, "TV", { enumerable: true, get: function () { return test_values_1.TV; } });
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.329";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.329';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.329",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@malloydata/malloy-filter": "0.0.
|
|
49
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
50
|
-
"@malloydata/malloy-tag": "0.0.
|
|
48
|
+
"@malloydata/malloy-filter": "0.0.329",
|
|
49
|
+
"@malloydata/malloy-interfaces": "0.0.329",
|
|
50
|
+
"@malloydata/malloy-tag": "0.0.329",
|
|
51
51
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
52
52
|
"assert": "^2.0.0",
|
|
53
53
|
"jaro-winkler": "^0.2.8",
|