@malloydata/malloy-interfaces 0.0.119-dev240124182419 → 0.0.119-dev240124192531
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/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/dialect/dialect.d.ts +0 -81
- package/dist/dialect/dialect.js +0 -131
- package/dist/dialect/functions/index.d.ts +0 -11
- package/dist/dialect/functions/index.js +0 -3
- package/dist/dialect/index.d.ts +0 -1
- package/dist/dialect/index.js +0 -28
- package/dist/model/index.d.ts +0 -1
- package/dist/model/index.js +0 -40
- package/dist/model/malloy_types.d.ts +0 -714
- package/dist/model/malloy_types.js +0 -421
- package/dist/run_sql_options.d.ts +0 -3
- package/dist/run_sql_options.js +0 -25
- package/dist/runtime_types.d.ts +0 -131
- package/dist/runtime_types.js +0 -25
|
@@ -1,421 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.isSQLFragment = exports.isJoinOn = exports.isIndexSegment = exports.isRawSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isPartialSegment = exports.isReduceSegment = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.FieldIsIntrinsic = exports.isCastType = exports.isAtomicFieldType = exports.isTimeFieldType = exports.hasExpression = exports.maxOfExpressionTypes = exports.maxExpressionType = exports.isExpressionTypeLEQ = exports.expressionIsAnalytic = exports.expressionIsCalculation = exports.expressionInvolvesAggregate = exports.expressionIsUngroupedAggregate = exports.expressionIsAggregate = exports.expressionIsScalar = exports.mkExpr = exports.isApplyFragment = exports.isApplyValue = exports.isParameterFragment = exports.isFieldFragment = exports.isSpreadFragment = exports.isSQLExpressionFragment = exports.isFunctionCallFragment = exports.isFunctionParameterFragment = exports.isUngroupFragment = exports.isAsymmetricFragment = exports.isAggregateFragment = exports.isDialectFragment = exports.isFilterFragment = exports.isOutputFieldFragment = exports.paramHasValue = exports.isConditionParameter = exports.isValueParameter = void 0;
|
|
26
|
-
exports.isValueDate = exports.isValueTimestamp = exports.isValueBoolean = exports.isValueNumber = exports.isValueString = exports.isMeasureLike = exports.getPhysicalFields = exports.getDimensions = exports.isPhysical = exports.isDimensional = exports.isAtomicField = exports.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = exports.isSQLBlockStruct = exports.mergeEvalSpaces = void 0;
|
|
27
|
-
function isValueParameter(p) {
|
|
28
|
-
return p.value !== undefined;
|
|
29
|
-
}
|
|
30
|
-
exports.isValueParameter = isValueParameter;
|
|
31
|
-
function isConditionParameter(p) {
|
|
32
|
-
return p.condition !== undefined;
|
|
33
|
-
}
|
|
34
|
-
exports.isConditionParameter = isConditionParameter;
|
|
35
|
-
function paramHasValue(p) {
|
|
36
|
-
return isValueParameter(p) || p.condition !== null;
|
|
37
|
-
}
|
|
38
|
-
exports.paramHasValue = paramHasValue;
|
|
39
|
-
function isOutputFieldFragment(f) {
|
|
40
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'outputField';
|
|
41
|
-
}
|
|
42
|
-
exports.isOutputFieldFragment = isOutputFieldFragment;
|
|
43
|
-
function isFilterFragment(f) {
|
|
44
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'filterExpression';
|
|
45
|
-
}
|
|
46
|
-
exports.isFilterFragment = isFilterFragment;
|
|
47
|
-
function isDialectFragment(f) {
|
|
48
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'dialect';
|
|
49
|
-
}
|
|
50
|
-
exports.isDialectFragment = isDialectFragment;
|
|
51
|
-
function isAggregateFragment(f) {
|
|
52
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'aggregate';
|
|
53
|
-
}
|
|
54
|
-
exports.isAggregateFragment = isAggregateFragment;
|
|
55
|
-
function isAsymmetricFragment(f) {
|
|
56
|
-
return isAggregateFragment(f) && ['sum', 'avg', 'count'].includes(f.function);
|
|
57
|
-
}
|
|
58
|
-
exports.isAsymmetricFragment = isAsymmetricFragment;
|
|
59
|
-
function isUngroupFragment(f) {
|
|
60
|
-
const ftype = f === null || f === void 0 ? void 0 : f.type;
|
|
61
|
-
return ftype === 'all' || ftype === 'exclude';
|
|
62
|
-
}
|
|
63
|
-
exports.isUngroupFragment = isUngroupFragment;
|
|
64
|
-
function isFunctionParameterFragment(f) {
|
|
65
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'function_parameter';
|
|
66
|
-
}
|
|
67
|
-
exports.isFunctionParameterFragment = isFunctionParameterFragment;
|
|
68
|
-
function isFunctionCallFragment(f) {
|
|
69
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'function_call';
|
|
70
|
-
}
|
|
71
|
-
exports.isFunctionCallFragment = isFunctionCallFragment;
|
|
72
|
-
function isSQLExpressionFragment(f) {
|
|
73
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'sql_expression';
|
|
74
|
-
}
|
|
75
|
-
exports.isSQLExpressionFragment = isSQLExpressionFragment;
|
|
76
|
-
function isSpreadFragment(f) {
|
|
77
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'spread';
|
|
78
|
-
}
|
|
79
|
-
exports.isSpreadFragment = isSpreadFragment;
|
|
80
|
-
function isFieldFragment(f) {
|
|
81
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'field';
|
|
82
|
-
}
|
|
83
|
-
exports.isFieldFragment = isFieldFragment;
|
|
84
|
-
function isParameterFragment(f) {
|
|
85
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'parameter';
|
|
86
|
-
}
|
|
87
|
-
exports.isParameterFragment = isParameterFragment;
|
|
88
|
-
function isApplyValue(f) {
|
|
89
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'applyVal';
|
|
90
|
-
}
|
|
91
|
-
exports.isApplyValue = isApplyValue;
|
|
92
|
-
function isApplyFragment(f) {
|
|
93
|
-
return (f === null || f === void 0 ? void 0 : f.type) === 'apply';
|
|
94
|
-
}
|
|
95
|
-
exports.isApplyFragment = isApplyFragment;
|
|
96
|
-
/**
|
|
97
|
-
* Return an Expr based on the string template, subsittutions can be
|
|
98
|
-
* either strings, or other Exprs.
|
|
99
|
-
|
|
100
|
-
* ```
|
|
101
|
-
* units = "inches"
|
|
102
|
-
* len: Expr = [ "something", "returning", "a length "]
|
|
103
|
-
* computeExpr = mkExpr`MEASURE(${len} in ${units})`;
|
|
104
|
-
* ```
|
|
105
|
-
*/
|
|
106
|
-
function mkExpr(src, ...exprs) {
|
|
107
|
-
const ret = [];
|
|
108
|
-
let index;
|
|
109
|
-
for (index = 0; index < exprs.length; index++) {
|
|
110
|
-
const el = exprs[index];
|
|
111
|
-
if (src[index].length > 0) {
|
|
112
|
-
ret.push(src[index]);
|
|
113
|
-
}
|
|
114
|
-
if (typeof el === 'string') {
|
|
115
|
-
ret.push(el);
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
ret.push(...el);
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (src[index].length > 0) {
|
|
122
|
-
ret.push(src[index]);
|
|
123
|
-
}
|
|
124
|
-
return ret;
|
|
125
|
-
}
|
|
126
|
-
exports.mkExpr = mkExpr;
|
|
127
|
-
function expressionIsScalar(e) {
|
|
128
|
-
return e === undefined || e === 'scalar';
|
|
129
|
-
}
|
|
130
|
-
exports.expressionIsScalar = expressionIsScalar;
|
|
131
|
-
function expressionIsAggregate(e) {
|
|
132
|
-
return e === 'aggregate' || e === 'ungrouped_aggregate';
|
|
133
|
-
}
|
|
134
|
-
exports.expressionIsAggregate = expressionIsAggregate;
|
|
135
|
-
function expressionIsUngroupedAggregate(e) {
|
|
136
|
-
return e === 'ungrouped_aggregate';
|
|
137
|
-
}
|
|
138
|
-
exports.expressionIsUngroupedAggregate = expressionIsUngroupedAggregate;
|
|
139
|
-
function expressionInvolvesAggregate(e) {
|
|
140
|
-
return (e === 'aggregate' ||
|
|
141
|
-
e === 'ungrouped_aggregate' ||
|
|
142
|
-
e === 'aggregate_analytic');
|
|
143
|
-
}
|
|
144
|
-
exports.expressionInvolvesAggregate = expressionInvolvesAggregate;
|
|
145
|
-
function expressionIsCalculation(e) {
|
|
146
|
-
return (e === 'aggregate' ||
|
|
147
|
-
e === 'scalar_analytic' ||
|
|
148
|
-
e === 'aggregate_analytic' ||
|
|
149
|
-
e === 'ungrouped_aggregate');
|
|
150
|
-
}
|
|
151
|
-
exports.expressionIsCalculation = expressionIsCalculation;
|
|
152
|
-
function expressionIsAnalytic(e) {
|
|
153
|
-
return e === 'aggregate_analytic' || e === 'scalar_analytic';
|
|
154
|
-
}
|
|
155
|
-
exports.expressionIsAnalytic = expressionIsAnalytic;
|
|
156
|
-
function expressionTypeLevel(e) {
|
|
157
|
-
return {
|
|
158
|
-
scalar: 0,
|
|
159
|
-
aggregate: 1,
|
|
160
|
-
ungrouped_aggregate: 2,
|
|
161
|
-
scalar_analytic: 2,
|
|
162
|
-
aggregate_analytic: 3,
|
|
163
|
-
}[e];
|
|
164
|
-
}
|
|
165
|
-
function isExpressionTypeLEQ(e1, e2) {
|
|
166
|
-
return e1 === e2 || expressionTypeLevel(e1) < expressionTypeLevel(e2);
|
|
167
|
-
}
|
|
168
|
-
exports.isExpressionTypeLEQ = isExpressionTypeLEQ;
|
|
169
|
-
// TODO rename this to be like `combineExpressionTypes`
|
|
170
|
-
function maxExpressionType(e1, e2) {
|
|
171
|
-
// TODO handle the case where e1 is analytic and e2 is ungrouped_aggregate
|
|
172
|
-
let ret = 'scalar';
|
|
173
|
-
if (e1 === 'aggregate' || e2 === 'aggregate') {
|
|
174
|
-
ret = 'aggregate';
|
|
175
|
-
}
|
|
176
|
-
if (e1 === 'ungrouped_aggregate' || e2 === 'ungrouped_aggregate') {
|
|
177
|
-
ret = 'ungrouped_aggregate';
|
|
178
|
-
}
|
|
179
|
-
if (e1 === 'scalar_analytic' || e2 === 'scalar_analytic') {
|
|
180
|
-
ret = 'scalar_analytic';
|
|
181
|
-
}
|
|
182
|
-
if (e1 === 'aggregate_analytic' || e2 === 'aggregate_analytic') {
|
|
183
|
-
ret = 'aggregate_analytic';
|
|
184
|
-
}
|
|
185
|
-
if (e1 === 'scalar_analytic' && e2 === 'aggregate') {
|
|
186
|
-
ret = 'aggregate_analytic';
|
|
187
|
-
}
|
|
188
|
-
else if (e1 === 'aggregate' && e2 === 'scalar_analytic') {
|
|
189
|
-
ret = 'aggregate_analytic';
|
|
190
|
-
}
|
|
191
|
-
return ret;
|
|
192
|
-
}
|
|
193
|
-
exports.maxExpressionType = maxExpressionType;
|
|
194
|
-
function maxOfExpressionTypes(types) {
|
|
195
|
-
return types.reduce(maxExpressionType, 'scalar');
|
|
196
|
-
}
|
|
197
|
-
exports.maxOfExpressionTypes = maxOfExpressionTypes;
|
|
198
|
-
/** Grants access to the expression property of a FieldDef */
|
|
199
|
-
function hasExpression(f) {
|
|
200
|
-
return f.e !== undefined;
|
|
201
|
-
}
|
|
202
|
-
exports.hasExpression = hasExpression;
|
|
203
|
-
function isTimeFieldType(s) {
|
|
204
|
-
return s === 'date' || s === 'timestamp';
|
|
205
|
-
}
|
|
206
|
-
exports.isTimeFieldType = isTimeFieldType;
|
|
207
|
-
function isAtomicFieldType(s) {
|
|
208
|
-
return [
|
|
209
|
-
'string',
|
|
210
|
-
'number',
|
|
211
|
-
'date',
|
|
212
|
-
'timestamp',
|
|
213
|
-
'boolean',
|
|
214
|
-
'json',
|
|
215
|
-
'unsupported',
|
|
216
|
-
'error',
|
|
217
|
-
].includes(s);
|
|
218
|
-
}
|
|
219
|
-
exports.isAtomicFieldType = isAtomicFieldType;
|
|
220
|
-
function isCastType(s) {
|
|
221
|
-
return ['string', 'number', 'date', 'timestamp', 'boolean', 'json'].includes(s);
|
|
222
|
-
}
|
|
223
|
-
exports.isCastType = isCastType;
|
|
224
|
-
// this field definition represents something in the database.
|
|
225
|
-
function FieldIsIntrinsic(f) {
|
|
226
|
-
if (isAtomicFieldType(f.type) && !hasExpression(f)) {
|
|
227
|
-
return true;
|
|
228
|
-
}
|
|
229
|
-
else if (f.type === 'struct' &&
|
|
230
|
-
(f.structSource.type === 'inline' || f.structSource.type === 'nested')) {
|
|
231
|
-
return true;
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
return false;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
exports.FieldIsIntrinsic = FieldIsIntrinsic;
|
|
238
|
-
function isDateUnit(str) {
|
|
239
|
-
return ['day', 'week', 'month', 'quarter', 'year'].includes(str);
|
|
240
|
-
}
|
|
241
|
-
exports.isDateUnit = isDateUnit;
|
|
242
|
-
function isTimestampUnit(s) {
|
|
243
|
-
return isDateUnit(s) || ['hour', 'minute', 'second'].includes(s);
|
|
244
|
-
}
|
|
245
|
-
exports.isTimestampUnit = isTimestampUnit;
|
|
246
|
-
function isExtractUnit(s) {
|
|
247
|
-
return isTimestampUnit(s) || s === 'day_of_week' || s === 'day_of_year';
|
|
248
|
-
}
|
|
249
|
-
exports.isExtractUnit = isExtractUnit;
|
|
250
|
-
/** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
|
|
251
|
-
var ValueType;
|
|
252
|
-
(function (ValueType) {
|
|
253
|
-
ValueType["Date"] = "date";
|
|
254
|
-
ValueType["Timestamp"] = "timestamp";
|
|
255
|
-
ValueType["Number"] = "number";
|
|
256
|
-
ValueType["String"] = "string";
|
|
257
|
-
})(ValueType || (exports.ValueType = ValueType = {}));
|
|
258
|
-
function isByName(by) {
|
|
259
|
-
if (by === undefined) {
|
|
260
|
-
return false;
|
|
261
|
-
}
|
|
262
|
-
return by.by === 'name';
|
|
263
|
-
}
|
|
264
|
-
exports.isByName = isByName;
|
|
265
|
-
function isByExpression(by) {
|
|
266
|
-
if (by === undefined) {
|
|
267
|
-
return false;
|
|
268
|
-
}
|
|
269
|
-
return by.by === 'name';
|
|
270
|
-
}
|
|
271
|
-
exports.isByExpression = isByExpression;
|
|
272
|
-
function refIsStructDef(ref) {
|
|
273
|
-
return typeof ref !== 'string' && ref.type === 'struct';
|
|
274
|
-
}
|
|
275
|
-
exports.refIsStructDef = refIsStructDef;
|
|
276
|
-
function isReduceSegment(pe) {
|
|
277
|
-
return pe.type === 'reduce';
|
|
278
|
-
}
|
|
279
|
-
exports.isReduceSegment = isReduceSegment;
|
|
280
|
-
function isPartialSegment(pe) {
|
|
281
|
-
return pe.type === 'partial';
|
|
282
|
-
}
|
|
283
|
-
exports.isPartialSegment = isPartialSegment;
|
|
284
|
-
function isProjectSegment(pe) {
|
|
285
|
-
return pe.type === 'project';
|
|
286
|
-
}
|
|
287
|
-
exports.isProjectSegment = isProjectSegment;
|
|
288
|
-
function isQuerySegment(pe) {
|
|
289
|
-
return isProjectSegment(pe) || isReduceSegment(pe);
|
|
290
|
-
}
|
|
291
|
-
exports.isQuerySegment = isQuerySegment;
|
|
292
|
-
function isSamplingRows(s) {
|
|
293
|
-
return s.rows !== undefined;
|
|
294
|
-
}
|
|
295
|
-
exports.isSamplingRows = isSamplingRows;
|
|
296
|
-
function isSamplingPercent(s) {
|
|
297
|
-
return s.percent !== undefined;
|
|
298
|
-
}
|
|
299
|
-
exports.isSamplingPercent = isSamplingPercent;
|
|
300
|
-
function isSamplingEnable(s) {
|
|
301
|
-
return s.enable !== undefined;
|
|
302
|
-
}
|
|
303
|
-
exports.isSamplingEnable = isSamplingEnable;
|
|
304
|
-
function isRawSegment(pe) {
|
|
305
|
-
return pe.type === 'raw';
|
|
306
|
-
}
|
|
307
|
-
exports.isRawSegment = isRawSegment;
|
|
308
|
-
function isIndexSegment(pe) {
|
|
309
|
-
return pe.type === 'index';
|
|
310
|
-
}
|
|
311
|
-
exports.isIndexSegment = isIndexSegment;
|
|
312
|
-
function isJoinOn(sr) {
|
|
313
|
-
return ['one', 'many', 'cross'].includes(sr.type);
|
|
314
|
-
}
|
|
315
|
-
exports.isJoinOn = isJoinOn;
|
|
316
|
-
function isSQLFragment(f) {
|
|
317
|
-
return f.sql !== undefined;
|
|
318
|
-
}
|
|
319
|
-
exports.isSQLFragment = isSQLFragment;
|
|
320
|
-
function mergeEvalSpaces(...evalSpaces) {
|
|
321
|
-
if (evalSpaces.every(e => e === 'constant' || e === 'literal')) {
|
|
322
|
-
return 'constant';
|
|
323
|
-
}
|
|
324
|
-
else if (evalSpaces.every(e => e === 'output' || e === 'constant' || e === 'literal')) {
|
|
325
|
-
return 'output';
|
|
326
|
-
}
|
|
327
|
-
return 'input';
|
|
328
|
-
}
|
|
329
|
-
exports.mergeEvalSpaces = mergeEvalSpaces;
|
|
330
|
-
function isSQLBlockStruct(sd) {
|
|
331
|
-
const src = sd.structSource;
|
|
332
|
-
return src.type === 'sql' && src.method === 'subquery';
|
|
333
|
-
}
|
|
334
|
-
exports.isSQLBlockStruct = isSQLBlockStruct;
|
|
335
|
-
function isFieldTypeDef(f) {
|
|
336
|
-
return (f.type === 'string' ||
|
|
337
|
-
f.type === 'date' ||
|
|
338
|
-
f.type === 'number' ||
|
|
339
|
-
f.type === 'timestamp' ||
|
|
340
|
-
f.type === 'boolean' ||
|
|
341
|
-
f.type === 'json');
|
|
342
|
-
}
|
|
343
|
-
exports.isFieldTypeDef = isFieldTypeDef;
|
|
344
|
-
function isFieldTimeBased(f) {
|
|
345
|
-
return f.type === 'date' || f.type === 'timestamp';
|
|
346
|
-
}
|
|
347
|
-
exports.isFieldTimeBased = isFieldTimeBased;
|
|
348
|
-
function isFieldStructDef(f) {
|
|
349
|
-
return f.type === 'struct';
|
|
350
|
-
}
|
|
351
|
-
exports.isFieldStructDef = isFieldStructDef;
|
|
352
|
-
/** Get the output name for a NamedObject */
|
|
353
|
-
function getIdentifier(n) {
|
|
354
|
-
if (n.as !== undefined) {
|
|
355
|
-
return n.as;
|
|
356
|
-
}
|
|
357
|
-
return n.name;
|
|
358
|
-
}
|
|
359
|
-
exports.getIdentifier = getIdentifier;
|
|
360
|
-
function isTurtleDef(def) {
|
|
361
|
-
return def.type === 'turtle';
|
|
362
|
-
}
|
|
363
|
-
exports.isTurtleDef = isTurtleDef;
|
|
364
|
-
function isAtomicField(def) {
|
|
365
|
-
return isAtomicFieldType(def.type);
|
|
366
|
-
}
|
|
367
|
-
exports.isAtomicField = isAtomicField;
|
|
368
|
-
function isDimensional(field) {
|
|
369
|
-
var _a;
|
|
370
|
-
if ('resultMetadata' in field) {
|
|
371
|
-
return ((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'dimension';
|
|
372
|
-
}
|
|
373
|
-
return false;
|
|
374
|
-
}
|
|
375
|
-
exports.isDimensional = isDimensional;
|
|
376
|
-
function isPhysical(field) {
|
|
377
|
-
return ((isFieldTypeDef(field) && field.e === undefined) ||
|
|
378
|
-
(isFieldStructDef(field) &&
|
|
379
|
-
(field.structSource.type === 'nested' ||
|
|
380
|
-
field.structSource.type === 'inline')));
|
|
381
|
-
}
|
|
382
|
-
exports.isPhysical = isPhysical;
|
|
383
|
-
function getDimensions(structDef) {
|
|
384
|
-
return structDef.fields.filter(isDimensional);
|
|
385
|
-
}
|
|
386
|
-
exports.getDimensions = getDimensions;
|
|
387
|
-
function getPhysicalFields(structDef) {
|
|
388
|
-
return structDef.fields.filter(isPhysical);
|
|
389
|
-
}
|
|
390
|
-
exports.getPhysicalFields = getPhysicalFields;
|
|
391
|
-
function isMeasureLike(field) {
|
|
392
|
-
var _a, _b;
|
|
393
|
-
if ('resultMetadata' in field) {
|
|
394
|
-
return (((_a = field.resultMetadata) === null || _a === void 0 ? void 0 : _a.fieldKind) === 'measure' ||
|
|
395
|
-
((_b = field.resultMetadata) === null || _b === void 0 ? void 0 : _b.fieldKind) === 'struct');
|
|
396
|
-
}
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
exports.isMeasureLike = isMeasureLike;
|
|
400
|
-
function isValueString(value, field) {
|
|
401
|
-
return field.type === 'string';
|
|
402
|
-
}
|
|
403
|
-
exports.isValueString = isValueString;
|
|
404
|
-
function isValueNumber(value, field) {
|
|
405
|
-
return field.type === 'number';
|
|
406
|
-
}
|
|
407
|
-
exports.isValueNumber = isValueNumber;
|
|
408
|
-
function isValueBoolean(value, field) {
|
|
409
|
-
return field.type === 'boolean';
|
|
410
|
-
}
|
|
411
|
-
exports.isValueBoolean = isValueBoolean;
|
|
412
|
-
function isValueTimestamp(value, field) {
|
|
413
|
-
return field.type === 'timestamp';
|
|
414
|
-
}
|
|
415
|
-
exports.isValueTimestamp = isValueTimestamp;
|
|
416
|
-
function isValueDate(value, field) {
|
|
417
|
-
return field.type === 'date';
|
|
418
|
-
}
|
|
419
|
-
exports.isValueDate = isValueDate;
|
|
420
|
-
// clang-format on
|
|
421
|
-
//# sourceMappingURL=malloy_types.js.map
|
package/dist/run_sql_options.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
//# sourceMappingURL=run_sql_options.js.map
|
package/dist/runtime_types.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import { RunSQLOptions } from './run_sql_options';
|
|
2
|
-
import { MalloyQueryData, QueryDataRow, QueryRunStats, SQLBlock, StructDef } from './model/malloy_types';
|
|
3
|
-
import { Dialect } from './dialect';
|
|
4
|
-
/**
|
|
5
|
-
* The contents of a Malloy query document.
|
|
6
|
-
*/
|
|
7
|
-
export type QueryString = string;
|
|
8
|
-
/**
|
|
9
|
-
* The contents of a Malloy model document.
|
|
10
|
-
*/
|
|
11
|
-
export type ModelString = string;
|
|
12
|
-
/**
|
|
13
|
-
* A URL whose contents is a Malloy model.
|
|
14
|
-
*/
|
|
15
|
-
export type ModelURL = URL;
|
|
16
|
-
/**
|
|
17
|
-
* A URL whose contents is a Malloy query.
|
|
18
|
-
*/
|
|
19
|
-
export type QueryURL = URL;
|
|
20
|
-
/**
|
|
21
|
-
* An object capable of reading the contents of a URL in some context.
|
|
22
|
-
*/
|
|
23
|
-
export interface URLReader {
|
|
24
|
-
/**
|
|
25
|
-
* Read the contents of the given URL.
|
|
26
|
-
*
|
|
27
|
-
* @param url The URL to read.
|
|
28
|
-
* @return A promise to the contents of the URL.
|
|
29
|
-
*/
|
|
30
|
-
readURL: (url: URL) => Promise<string>;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Options passed to fetchSchema methods.
|
|
34
|
-
*/
|
|
35
|
-
export interface FetchSchemaOptions {
|
|
36
|
-
refreshTimestamp?: number;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* An object capable of reading schemas for given table names.
|
|
40
|
-
*/
|
|
41
|
-
export interface InfoConnection {
|
|
42
|
-
/**
|
|
43
|
-
* Fetch schemas for multiple tables.
|
|
44
|
-
*
|
|
45
|
-
* @param tables The names of tables to fetch schemas for, represented
|
|
46
|
-
* as a map of keys to table names.
|
|
47
|
-
* @return A mapping of table keys to schemas.
|
|
48
|
-
*/
|
|
49
|
-
fetchSchemaForTables(tables: Record<string, string>, options: FetchSchemaOptions): Promise<{
|
|
50
|
-
schemas: Record<string, StructDef>;
|
|
51
|
-
errors: Record<string, string>;
|
|
52
|
-
}>;
|
|
53
|
-
/**
|
|
54
|
-
* Fetch schemas an SQL blocks
|
|
55
|
-
*
|
|
56
|
-
* @param block The SQL blocks to fetch schemas for.
|
|
57
|
-
* @return A mapping of SQL block names to schemas.
|
|
58
|
-
*/
|
|
59
|
-
fetchSchemaForSQLBlock(block: SQLBlock, options: FetchSchemaOptions): Promise<{
|
|
60
|
-
structDef: StructDef;
|
|
61
|
-
error?: undefined;
|
|
62
|
-
} | {
|
|
63
|
-
error: string;
|
|
64
|
-
structDef?: undefined;
|
|
65
|
-
}>;
|
|
66
|
-
/**
|
|
67
|
-
* The name of the connection.
|
|
68
|
-
*/
|
|
69
|
-
get name(): string;
|
|
70
|
-
}
|
|
71
|
-
export type ConnectionParameterValue = string | number | boolean;
|
|
72
|
-
export interface ConnectionParameter {
|
|
73
|
-
name: string;
|
|
74
|
-
label: string;
|
|
75
|
-
type: 'string' | 'number' | 'boolean';
|
|
76
|
-
isOptional?: boolean;
|
|
77
|
-
isSecret?: boolean;
|
|
78
|
-
defaultValue?: ConnectionParameterValue;
|
|
79
|
-
}
|
|
80
|
-
export type ConnectionConfigSchema = ConnectionParameter[];
|
|
81
|
-
export type ConnectionConfig = Record<string, ConnectionParameterValue>;
|
|
82
|
-
export interface ConnectionFactory {
|
|
83
|
-
connectionName: string;
|
|
84
|
-
configSchema: ConnectionConfigSchema;
|
|
85
|
-
createConnection(connectionConfig: ConnectionConfig, dialectRegistrar?: (dialect: Dialect) => void): Connection & TestableConnection;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* An object capable of running SQL.
|
|
89
|
-
*/
|
|
90
|
-
export interface Connection extends InfoConnection {
|
|
91
|
-
/**
|
|
92
|
-
* Run some SQL and yield results.
|
|
93
|
-
*
|
|
94
|
-
* @param sql The SQL to run.
|
|
95
|
-
* @param options.pageSize Maximum number of results to return at once.
|
|
96
|
-
* @return The rows of data resulting from running the given SQL query
|
|
97
|
-
* and the total number of rows available.
|
|
98
|
-
*/
|
|
99
|
-
runSQL(sql: string, options?: RunSQLOptions): Promise<MalloyQueryData>;
|
|
100
|
-
isPool(): this is PooledConnection;
|
|
101
|
-
canPersist(): this is PersistSQLResults;
|
|
102
|
-
canStream(): this is StreamingConnection;
|
|
103
|
-
close(): Promise<void>;
|
|
104
|
-
estimateQueryCost(sqlCommand: string): Promise<QueryRunStats>;
|
|
105
|
-
get dialectName(): string;
|
|
106
|
-
}
|
|
107
|
-
export interface TestableConnection extends Connection {
|
|
108
|
-
test(): Promise<void>;
|
|
109
|
-
}
|
|
110
|
-
export interface PooledConnection extends Connection {
|
|
111
|
-
drain(): Promise<void>;
|
|
112
|
-
isPool(): true;
|
|
113
|
-
}
|
|
114
|
-
export interface PersistSQLResults extends Connection {
|
|
115
|
-
manifestTemporaryTable(sqlCommand: string): Promise<string>;
|
|
116
|
-
}
|
|
117
|
-
export interface StreamingConnection extends Connection {
|
|
118
|
-
runSQLStream(sqlCommand: string, options?: {
|
|
119
|
-
rowLimit?: number;
|
|
120
|
-
}): AsyncIterableIterator<QueryDataRow>;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* A mapping of connection names to connections.
|
|
124
|
-
*/
|
|
125
|
-
export interface LookupConnection<T extends InfoConnection> {
|
|
126
|
-
/**
|
|
127
|
-
* @param connectionName The name of the connection for which a `Connection` is required.
|
|
128
|
-
* @return A promise to a `Connection` for the connection named `connectionName`.
|
|
129
|
-
*/
|
|
130
|
-
lookupConnection(connectionName?: string): Promise<T>;
|
|
131
|
-
}
|
package/dist/runtime_types.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright 2023 Google LLC
|
|
4
|
-
*
|
|
5
|
-
* Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
* a copy of this software and associated documentation files
|
|
7
|
-
* (the "Software"), to deal in the Software without restriction,
|
|
8
|
-
* including without limitation the rights to use, copy, modify, merge,
|
|
9
|
-
* publish, distribute, sublicense, and/or sell copies of the Software,
|
|
10
|
-
* and to permit persons to whom the Software is furnished to do so,
|
|
11
|
-
* subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be
|
|
14
|
-
* included in all copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
-
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
-
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
-
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
-
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
//# sourceMappingURL=runtime_types.js.map
|