@malloydata/malloy-interfaces 0.0.78-dev230818010117

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.
@@ -0,0 +1,674 @@
1
+ /// <reference types="node" />
2
+ interface ParamBase {
3
+ name: string;
4
+ type: AtomicFieldType;
5
+ }
6
+ declare type ConstantExpr = Expr;
7
+ declare type Condition = Expr;
8
+ interface ParamCondition extends ParamBase {
9
+ condition: Condition | null;
10
+ }
11
+ interface ParamValue extends ParamBase {
12
+ value: ConstantExpr | null;
13
+ constant: boolean;
14
+ }
15
+ export declare type Parameter = ParamCondition | ParamValue;
16
+ export declare function isValueParameter(p: Parameter): p is ParamValue;
17
+ export declare function isConditionParameter(p: Parameter): p is ParamCondition;
18
+ export declare function paramHasValue(p: Parameter): boolean;
19
+ export interface DocumentRange {
20
+ start: DocumentPosition;
21
+ end: DocumentPosition;
22
+ }
23
+ export interface DocumentPosition {
24
+ line: number;
25
+ character: number;
26
+ }
27
+ export interface ImportLocation {
28
+ importURL: string;
29
+ location: DocumentLocation;
30
+ }
31
+ export interface DocumentLocation {
32
+ url: string;
33
+ range: DocumentRange;
34
+ }
35
+ interface DocumentReferenceBase {
36
+ text: string;
37
+ location: DocumentLocation;
38
+ definition: HasLocation;
39
+ }
40
+ export interface DocumentExploreReference extends DocumentReferenceBase {
41
+ type: 'exploreReference';
42
+ definition: StructDef;
43
+ }
44
+ export interface DocumentJoinReference extends DocumentReferenceBase {
45
+ type: 'joinReference';
46
+ definition: FieldDef;
47
+ }
48
+ export interface DocumentSQLBlockReference extends DocumentReferenceBase {
49
+ type: 'sqlBlockReference';
50
+ definition: SQLBlockStructDef;
51
+ }
52
+ export interface DocumentQueryReference extends DocumentReferenceBase {
53
+ type: 'queryReference';
54
+ definition: Query;
55
+ }
56
+ export interface DocumentFieldReference extends DocumentReferenceBase {
57
+ type: 'fieldReference';
58
+ definition: FieldDef;
59
+ }
60
+ export declare type DocumentReference = DocumentExploreReference | DocumentQueryReference | DocumentSQLBlockReference | DocumentFieldReference | DocumentJoinReference;
61
+ /** put location into the parse tree. */
62
+ export interface HasLocation {
63
+ location?: DocumentLocation;
64
+ }
65
+ /** All names have their source names and how they will appear in the symbol table that owns them */
66
+ export interface AliasedName {
67
+ name: string;
68
+ as?: string;
69
+ }
70
+ export interface TypedObject {
71
+ type: string;
72
+ }
73
+ export interface FilteredAliasedName extends AliasedName {
74
+ filterList?: FilterExpression[];
75
+ }
76
+ export declare function isFilteredAliasedName(f: FieldTypeRef): f is FilteredAliasedName;
77
+ /** all named objects have a type an a name (optionally aliased) */
78
+ export interface NamedObject extends AliasedName, HasLocation {
79
+ type: string;
80
+ }
81
+ export interface ResultMetadataDef {
82
+ sourceField: string;
83
+ sourceExpression?: string;
84
+ sourceClasses: string[];
85
+ filterList?: FilterExpression[];
86
+ fieldKind: 'measure' | 'dimension' | 'struct';
87
+ }
88
+ export interface ResultStructMetadataDef extends ResultMetadataDef {
89
+ limit?: number;
90
+ orderBy?: OrderBy[];
91
+ }
92
+ export interface ResultMetadata {
93
+ resultMetadata?: ResultMetadataDef;
94
+ }
95
+ export interface ResultStructMetadata {
96
+ resultMetadata?: ResultStructMetadataDef;
97
+ }
98
+ export interface OutputFieldFragment {
99
+ type: 'outputField';
100
+ name: string;
101
+ }
102
+ export declare function isOutputFieldFragment(f: Fragment): f is OutputFieldFragment;
103
+ export interface FilterFragment {
104
+ type: 'filterExpression';
105
+ filterList: FilterExpression[];
106
+ e: Expr;
107
+ }
108
+ export declare function isFilterFragment(f: Fragment): f is FilterFragment;
109
+ export declare function isDialectFragment(f: Fragment): f is DialectFragment;
110
+ export interface AggregateFragment {
111
+ type: 'aggregate';
112
+ function: string;
113
+ e: Expr;
114
+ structPath?: string;
115
+ }
116
+ export declare function isAggregateFragment(f: Fragment): f is AggregateFragment;
117
+ export declare function isAsymmetricFragment(f: Fragment): f is AggregateFragment;
118
+ export interface UngroupFragment {
119
+ type: 'all' | 'exclude';
120
+ e: Expr;
121
+ fields?: string[];
122
+ }
123
+ export declare function isUngroupFragment(f: Fragment): f is UngroupFragment;
124
+ export interface FunctionParameterFragment {
125
+ type: 'function_parameter';
126
+ name: string;
127
+ }
128
+ export declare function isFunctionParameterFragment(f: Fragment): f is FunctionParameterFragment;
129
+ export interface FunctionCallFragment {
130
+ type: 'function_call';
131
+ overload: FunctionOverloadDef;
132
+ expressionType: ExpressionType;
133
+ args: Expr[];
134
+ structPath?: string;
135
+ }
136
+ export declare function isFunctionCallFragment(f: Fragment): f is FunctionCallFragment;
137
+ export interface SQLExpressionFragment {
138
+ type: 'sql_expression';
139
+ e: Expr;
140
+ }
141
+ export declare function isSQLExpressionFragment(f: Fragment): f is SQLExpressionFragment;
142
+ export interface SpreadFragment {
143
+ type: 'spread';
144
+ e: Expr;
145
+ }
146
+ export declare function isSpreadFragment(f: Fragment): f is SpreadFragment;
147
+ export interface FieldFragment {
148
+ type: 'field';
149
+ path: string;
150
+ }
151
+ export declare function isFieldFragment(f: Fragment): f is FieldFragment;
152
+ export interface ParameterFragment {
153
+ type: 'parameter';
154
+ path: string;
155
+ }
156
+ export declare function isParameterFragment(f: Fragment): f is ParameterFragment;
157
+ export interface ApplyValueFragment {
158
+ type: 'applyVal';
159
+ }
160
+ export declare function isApplyValue(f: Fragment): f is ApplyValueFragment;
161
+ export interface ApplyFragment {
162
+ type: 'apply';
163
+ value: Expr;
164
+ to: Expr;
165
+ }
166
+ export declare function isApplyFragment(f: Fragment): f is ApplyFragment;
167
+ interface DialectFragmentBase {
168
+ type: 'dialect';
169
+ function: string;
170
+ }
171
+ export interface NowFragment extends DialectFragmentBase {
172
+ function: 'now';
173
+ }
174
+ export interface TimeDiffFragment extends DialectFragmentBase {
175
+ function: 'timeDiff';
176
+ units: TimestampUnit;
177
+ left: TimeValue;
178
+ right: TimeValue;
179
+ }
180
+ export interface TimeDeltaFragment extends DialectFragmentBase {
181
+ function: 'delta';
182
+ base: TimeValue;
183
+ op: '+' | '-';
184
+ delta: Expr;
185
+ units: TimestampUnit;
186
+ }
187
+ export interface TimeTruncFragment extends DialectFragmentBase {
188
+ function: 'trunc';
189
+ expr: TimeValue;
190
+ units: TimestampUnit;
191
+ }
192
+ export interface TimeExtractFragment extends DialectFragmentBase {
193
+ function: 'extract';
194
+ expr: TimeValue;
195
+ units: ExtractUnit;
196
+ }
197
+ export interface TypecastFragment extends DialectFragmentBase {
198
+ function: 'cast';
199
+ safe: boolean;
200
+ expr: Expr;
201
+ dstType: AtomicFieldType;
202
+ srcType?: AtomicFieldType;
203
+ }
204
+ export interface RegexpMatchFragment extends DialectFragmentBase {
205
+ function: 'regexpMatch';
206
+ expr: Expr;
207
+ regexp: Expr;
208
+ }
209
+ export interface DivFragment extends DialectFragmentBase {
210
+ function: 'div';
211
+ numerator: Expr;
212
+ denominator: Expr;
213
+ }
214
+ export interface TimeLiteralFragment extends DialectFragmentBase {
215
+ function: 'timeLiteral';
216
+ literal: string;
217
+ literalType: TimeFieldType;
218
+ timezone?: string;
219
+ }
220
+ export interface StringLiteralFragment extends DialectFragmentBase {
221
+ function: 'stringLiteral';
222
+ literal: string;
223
+ }
224
+ export interface RegexpLiteralFragment extends DialectFragmentBase {
225
+ function: 'regexpLiteral';
226
+ literal: string;
227
+ }
228
+ export interface NumberLiteralFragment extends DialectFragmentBase {
229
+ function: 'numberLiteral';
230
+ literal: string;
231
+ }
232
+ export declare type DialectFragment = DivFragment | TimeLiteralFragment | NowFragment | TimeDeltaFragment | TimeDiffFragment | TimeTruncFragment | TypecastFragment | TimeExtractFragment | StringLiteralFragment | RegexpLiteralFragment | NumberLiteralFragment | RegexpMatchFragment;
233
+ export declare type Fragment = string | ApplyFragment | ApplyValueFragment | FieldFragment | ParameterFragment | FilterFragment | OutputFieldFragment | AggregateFragment | UngroupFragment | DialectFragment | FunctionParameterFragment | FunctionCallFragment | SQLExpressionFragment | SpreadFragment;
234
+ export declare type Expr = Fragment[];
235
+ export interface TypedValue {
236
+ value: Expr;
237
+ valueType: AtomicFieldType;
238
+ }
239
+ export interface TimeValue extends TypedValue {
240
+ valueType: TimeFieldType;
241
+ }
242
+ declare type TagElement = Expr | string;
243
+ /**
244
+ * Return an Expr based on the string template, subsittutions can be
245
+ * either strings, or other Exprs.
246
+
247
+ * ```
248
+ * units = "inches"
249
+ * len: Expr = [ "something", "returning", "a length "]
250
+ * computeExpr = mkExpr`MEASURE(${len} in ${units})`;
251
+ * ```
252
+ */
253
+ export declare function mkExpr(src: TemplateStringsArray, ...exprs: TagElement[]): Expr;
254
+ export declare type ExpressionType = 'scalar' | 'aggregate' | 'scalar_analytic' | 'aggregate_analytic' | 'ungrouped_aggregate';
255
+ export interface Expression {
256
+ e?: Expr;
257
+ expressionType?: ExpressionType;
258
+ code?: string;
259
+ }
260
+ export declare function expressionIsScalar(e: ExpressionType | undefined): boolean;
261
+ export declare function expressionIsAggregate(e: ExpressionType | undefined): boolean;
262
+ export declare function expressionIsUngroupedAggregate(e: ExpressionType | undefined): boolean;
263
+ export declare function expressionInvolvesAggregate(e: ExpressionType | undefined): boolean;
264
+ export declare function expressionIsCalculation(e: ExpressionType | undefined): boolean;
265
+ export declare function expressionIsAnalytic(e: ExpressionType | undefined): boolean;
266
+ export declare function isExpressionTypeLEQ(e1: ExpressionType, e2: ExpressionType): boolean;
267
+ export declare function maxExpressionType(e1: ExpressionType, e2: ExpressionType): ExpressionType;
268
+ export declare function maxOfExpressionTypes(types: ExpressionType[]): ExpressionType;
269
+ interface JustExpression {
270
+ e: Expr;
271
+ }
272
+ declare type HasExpression = FieldDef & JustExpression;
273
+ /** Grants access to the expression property of a FieldDef */
274
+ export declare function hasExpression(f: FieldDef): f is HasExpression;
275
+ export declare type TimeFieldType = 'date' | 'timestamp';
276
+ export declare function isTimeFieldType(s: string): s is TimeFieldType;
277
+ export declare type AtomicFieldType = 'string' | 'number' | TimeFieldType | 'boolean' | 'unsupported' | 'json' | 'error';
278
+ export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
279
+ /**
280
+ * Fields which contain scalar data all inherit from this. The field
281
+ * value could be an expression, and this is one of the objects
282
+ * which might have an annotation.
283
+ */
284
+ export interface FieldAtomicDef extends NamedObject, Expression, ResultMetadata {
285
+ type: AtomicFieldType;
286
+ annotation?: Annotation;
287
+ }
288
+ export declare function FieldIsIntrinsic(f: FieldDef): boolean;
289
+ /** Scalar String Field */
290
+ export interface FieldStringDef extends FieldAtomicDef {
291
+ type: 'string';
292
+ bucketFilter?: string;
293
+ bucketOther?: string;
294
+ }
295
+ /** Scalar Numeric String Field */
296
+ export interface FieldNumberDef extends FieldAtomicDef {
297
+ type: 'number';
298
+ numberType?: 'integer' | 'float';
299
+ }
300
+ /** Scalar Boolean Field */
301
+ export interface FieldBooleanDef extends FieldAtomicDef {
302
+ type: 'boolean';
303
+ }
304
+ /** Scalar JSON Field */
305
+ export interface FieldJSONDef extends FieldAtomicDef {
306
+ type: 'json';
307
+ }
308
+ /** Scalar unsupported Field */
309
+ export interface FieldUnsupportedDef extends FieldAtomicDef {
310
+ type: 'unsupported';
311
+ rawType?: string;
312
+ }
313
+ export interface FieldErrorDef extends FieldAtomicDef {
314
+ type: 'error';
315
+ }
316
+ export declare type DateUnit = 'day' | 'week' | 'month' | 'quarter' | 'year';
317
+ export declare function isDateUnit(str: string): str is DateUnit;
318
+ export declare type TimestampUnit = DateUnit | 'hour' | 'minute' | 'second';
319
+ export declare function isTimestampUnit(s: string): s is TimestampUnit;
320
+ export declare type ExtractUnit = TimestampUnit | 'day_of_week' | 'day_of_year';
321
+ export declare function isExtractUnit(s: string): s is ExtractUnit;
322
+ /** Value types distinguished by their usage in generated SQL, particularly with respect to filters. */
323
+ export declare enum ValueType {
324
+ Date = "date",
325
+ Timestamp = "timestamp",
326
+ Number = "number",
327
+ String = "string"
328
+ }
329
+ export declare type TimeValueType = ValueType.Date | ValueType.Timestamp;
330
+ /** Scalar Date Field. */
331
+ export interface FieldDateDef extends FieldAtomicDef {
332
+ type: 'date';
333
+ timeframe?: DateUnit;
334
+ }
335
+ /** Scalar Timestamp Field */
336
+ export interface FieldTimestampDef extends FieldAtomicDef {
337
+ type: 'timestamp';
338
+ timeframe?: TimestampUnit;
339
+ }
340
+ /** parameter to order a query */
341
+ export interface OrderBy {
342
+ field: string | number;
343
+ dir?: 'asc' | 'desc';
344
+ }
345
+ export interface ByName {
346
+ by: 'name';
347
+ name: string;
348
+ }
349
+ export interface ByExpression {
350
+ by: 'expression';
351
+ e: Expr;
352
+ }
353
+ export declare type By = ByName | ByExpression;
354
+ export declare function isByName(by: By | undefined): by is ByName;
355
+ export declare function isByExpression(by: By | undefined): by is ByExpression;
356
+ /** reference to a data source */
357
+ export declare type StructRef = string | StructDef;
358
+ export declare function refIsStructDef(ref: StructRef): ref is StructDef;
359
+ /** join pattern structs is a struct. */
360
+ export interface JoinedStruct {
361
+ structRef: StructRef;
362
+ structRelationship: StructRelationship;
363
+ as: string;
364
+ }
365
+ export interface Filtered {
366
+ filterList?: FilterExpression[];
367
+ }
368
+ /**
369
+ * First element in a pipeline might be a reference to a turtle
370
+ */
371
+ export interface TurtleSegment extends Filtered {
372
+ name: string;
373
+ }
374
+ export interface Pipeline {
375
+ pipeHead?: TurtleSegment;
376
+ pipeline: PipeSegment[];
377
+ }
378
+ export interface Query extends Pipeline, Filtered, HasLocation {
379
+ type?: 'query';
380
+ structRef: StructRef;
381
+ annotation?: Annotation;
382
+ modelAnnotation?: Annotation;
383
+ }
384
+ export declare type NamedQuery = Query & NamedObject;
385
+ export declare type PipeSegment = QuerySegment | IndexSegment;
386
+ export interface ReduceSegment extends QuerySegment {
387
+ type: 'reduce';
388
+ }
389
+ export declare function isReduceSegment(pe: PipeSegment): pe is ReduceSegment;
390
+ export interface ProjectSegment extends QuerySegment {
391
+ type: 'project';
392
+ }
393
+ export declare function isProjectSegment(pe: PipeSegment): pe is ProjectSegment;
394
+ export declare function isQuerySegment(pe: PipeSegment): pe is QuerySegment;
395
+ export declare type Sampling = SamplingRows | SamplingEnable | SamplingPercent;
396
+ interface SamplingRows {
397
+ rows: number;
398
+ }
399
+ export declare function isSamplingRows(s: Sampling): s is SamplingRows;
400
+ interface SamplingPercent {
401
+ percent: number;
402
+ }
403
+ export declare function isSamplingPercent(s: Sampling): s is SamplingPercent;
404
+ interface SamplingEnable {
405
+ enable: boolean;
406
+ }
407
+ export declare function isSamplingEnable(s: Sampling): s is SamplingEnable;
408
+ export interface IndexSegment extends Filtered {
409
+ type: 'index';
410
+ fields: string[];
411
+ limit?: number;
412
+ weightMeasure?: string;
413
+ sample?: Sampling;
414
+ }
415
+ export declare function isIndexSegment(pe: PipeSegment): pe is IndexSegment;
416
+ export interface QuerySegment extends Filtered {
417
+ type: 'reduce' | 'project';
418
+ fields: QueryFieldDef[];
419
+ extendSource?: FieldDef[];
420
+ limit?: number;
421
+ by?: By;
422
+ orderBy?: OrderBy[];
423
+ queryTimezone?: string;
424
+ }
425
+ export interface TurtleDef extends NamedObject, Pipeline {
426
+ type: 'turtle';
427
+ annotation?: Annotation;
428
+ }
429
+ export declare type JoinRelationship = 'one_to_one' | 'one_to_many' | 'many_to_one' | 'many_to_many';
430
+ export interface JoinOn {
431
+ type: 'one' | 'many' | 'cross';
432
+ onExpression?: Expr;
433
+ }
434
+ export declare function isJoinOn(sr: StructRelationship): sr is JoinOn;
435
+ /** types of joins. */
436
+ export declare type StructRelationship = {
437
+ type: 'basetable';
438
+ connectionName: string;
439
+ } | JoinOn | {
440
+ type: 'inline';
441
+ } | {
442
+ type: 'nested';
443
+ field: FieldRef;
444
+ isArray: boolean;
445
+ };
446
+ export interface SQLFragment {
447
+ sql: string;
448
+ }
449
+ export declare type SQLPhrase = Query | SQLFragment;
450
+ export declare function isSQLFragment(f: SQLPhrase): f is SQLFragment;
451
+ /**
452
+ * A source reference to an SQL block. The compiler uses these to request
453
+ * an SQLBlock with it's schema and structdef defined. Use the factory
454
+ * makeSQLBlock to construct these.
455
+ */
456
+ export interface SQLBlockSource {
457
+ name: string;
458
+ connection?: string;
459
+ select: SQLPhrase[];
460
+ }
461
+ export interface SQLBlock extends NamedObject {
462
+ type: 'sqlBlock';
463
+ connection?: string;
464
+ selectStr: string;
465
+ }
466
+ interface SubquerySource {
467
+ type: 'sql';
468
+ method: 'subquery';
469
+ sqlBlock: SQLBlock;
470
+ }
471
+ /** where does the struct come from? */
472
+ export declare type StructSource = {
473
+ type: 'table';
474
+ tablePath: string;
475
+ } | {
476
+ type: 'nested';
477
+ } | {
478
+ type: 'inline';
479
+ } | {
480
+ type: 'query';
481
+ query: Query;
482
+ } | {
483
+ type: 'sql';
484
+ method: 'nested' | 'lastStage';
485
+ } | {
486
+ type: 'query_result';
487
+ } | SubquerySource;
488
+ /** struct that is intrinsic to the table */
489
+ export interface StructDef extends NamedObject, ResultStructMetadata, Filtered {
490
+ type: 'struct';
491
+ structSource: StructSource;
492
+ structRelationship: StructRelationship;
493
+ fields: FieldDef[];
494
+ primaryKey?: PrimaryKeyRef;
495
+ parameters?: Record<string, Parameter>;
496
+ queryTimezone?: string;
497
+ dialect: string;
498
+ annotation?: Annotation;
499
+ modelAnnotation?: ModelAnnotation;
500
+ }
501
+ export declare type ExpressionValueType = AtomicFieldType | 'null' | 'duration' | 'any' | 'regular expression';
502
+ export declare type FieldValueType = ExpressionValueType | 'turtle' | 'struct';
503
+ export interface ExpressionTypeDesc {
504
+ dataType: FieldValueType;
505
+ expressionType: ExpressionType;
506
+ rawType?: string;
507
+ evalSpace: EvalSpace;
508
+ }
509
+ export interface FunctionParamTypeDesc {
510
+ dataType: FieldValueType;
511
+ expressionType: ExpressionType | undefined;
512
+ evalSpace: EvalSpace;
513
+ }
514
+ export declare type EvalSpace = 'constant' | 'input' | 'output' | 'literal';
515
+ export declare function mergeEvalSpaces(...evalSpaces: EvalSpace[]): EvalSpace;
516
+ export interface TypeDesc {
517
+ dataType: FieldValueType;
518
+ expressionType: ExpressionType;
519
+ rawType?: string;
520
+ evalSpace: EvalSpace;
521
+ }
522
+ export interface FunctionParameterDef {
523
+ name: string;
524
+ allowedTypes: FunctionParamTypeDesc[];
525
+ isVariadic: boolean;
526
+ }
527
+ export interface FunctionOverloadDef {
528
+ returnType: TypeDesc;
529
+ needsWindowOrderBy?: boolean;
530
+ between?: {
531
+ preceding: number | string;
532
+ following: number | string;
533
+ };
534
+ params: FunctionParameterDef[];
535
+ dialect: {
536
+ [dialect: string]: Expr;
537
+ };
538
+ }
539
+ export interface FunctionDef extends NamedObject {
540
+ type: 'function';
541
+ overloads: FunctionOverloadDef[];
542
+ }
543
+ export interface ConnectionDef extends NamedObject {
544
+ type: 'connection';
545
+ }
546
+ export interface SQLBlockStructDef extends StructDef {
547
+ structSource: SubquerySource;
548
+ declaredSQLBlock?: boolean;
549
+ }
550
+ export declare function isSQLBlockStruct(sd: StructDef): sd is SQLBlockStructDef;
551
+ /** any of the different field types */
552
+ export declare type FieldTypeDef = FieldStringDef | FieldDateDef | FieldTimestampDef | FieldNumberDef | FieldBooleanDef | FieldJSONDef | FieldUnsupportedDef | FieldErrorDef;
553
+ export declare function isFieldTypeDef(f: FieldDef): f is FieldTypeDef;
554
+ export declare function isFieldTimeBased(f: FieldDef): f is FieldTimestampDef | FieldDateDef;
555
+ export declare function isFieldStructDef(f: FieldDef): f is StructDef;
556
+ /** field reference in a query */
557
+ export declare type FieldTypeRef = string | FieldTypeDef | FilteredAliasedName;
558
+ /** field reference with with possibly and order by. */
559
+ export declare type QueryFieldDef = FieldTypeRef | TurtleDef;
560
+ /** basics statement */
561
+ export declare type FieldDef = FieldTypeDef | StructDef | TurtleDef;
562
+ /** reference to a field */
563
+ export declare type FieldRef = string | FieldDef;
564
+ /** which field is the primary key in this struct */
565
+ export declare type PrimaryKeyRef = string;
566
+ /** filters */
567
+ export interface FilterExpression {
568
+ expression: Expr;
569
+ code: string;
570
+ expressionType: ExpressionType;
571
+ }
572
+ /** Get the output name for a NamedObject */
573
+ export declare function getIdentifier(n: AliasedName): string;
574
+ export declare type NamedModelObject = StructDef | NamedQuery | FunctionDef | ConnectionDef;
575
+ /** Result of parsing a model file */
576
+ export interface ModelDef {
577
+ name: string;
578
+ exports: string[];
579
+ contents: Record<string, NamedModelObject>;
580
+ annotation?: ModelAnnotation;
581
+ }
582
+ /** Very common record type */
583
+ export declare type NamedStructDefs = Record<string, StructDef>;
584
+ export declare type NamedModelObjects = Record<string, NamedModelObject>;
585
+ /** Malloy source annotations attached to objects */
586
+ export interface Annotation {
587
+ inherits?: Annotation;
588
+ blockNotes?: Note[];
589
+ notes?: Note[];
590
+ }
591
+ export interface Note {
592
+ text: string;
593
+ at: DocumentLocation;
594
+ }
595
+ /** Annotations with a uuid to make it easier to stream */
596
+ export interface ModelAnnotation extends Annotation {
597
+ id: string;
598
+ }
599
+ export declare type QueryScalar = string | boolean | number | Date | Buffer | null;
600
+ /** One value in one column of returned data. */
601
+ export declare type QueryValue = QueryScalar | QueryData | QueryDataRow;
602
+ /** A row of returned data. */
603
+ export declare type QueryDataRow = {
604
+ [columnName: string]: QueryValue;
605
+ };
606
+ /** Returned query data. */
607
+ export declare type QueryData = QueryDataRow[];
608
+ /** Query execution stats. */
609
+ export declare type QueryRunStats = {
610
+ queryCostBytes?: number;
611
+ };
612
+ /** Returned Malloy query data */
613
+ export declare type MalloyQueryData = {
614
+ rows: QueryDataRow[];
615
+ totalRows: number;
616
+ runStats?: QueryRunStats;
617
+ };
618
+ export interface DrillSource {
619
+ sourceExplore: string;
620
+ sourceFilters?: FilterExpression[];
621
+ }
622
+ export interface CompiledQuery extends DrillSource {
623
+ structs: StructDef[];
624
+ sql: string;
625
+ lastStageName: string;
626
+ malloy: string;
627
+ queryName?: string | undefined;
628
+ connectionName: string;
629
+ queryTimezone?: string;
630
+ annotation?: Annotation;
631
+ }
632
+ /** Result type for running a Malloy query. */
633
+ export interface QueryResult extends CompiledQuery {
634
+ result: QueryData;
635
+ totalRows: number;
636
+ error?: string;
637
+ runStats?: QueryRunStats;
638
+ }
639
+ export declare function isTurtleDef(def: FieldDef): def is TurtleDef;
640
+ export interface SearchResultRow {
641
+ field_name: string;
642
+ field_value: string;
643
+ weight: number;
644
+ }
645
+ export declare type SearchResult = SearchResultRow[];
646
+ export declare function isDimensional(field: FieldDef): boolean;
647
+ export declare function isPhysical(field: FieldDef): boolean;
648
+ export declare function getDimensions(structDef: StructDef): FieldAtomicDef[];
649
+ export declare function getPhysicalFields(structDef: StructDef): FieldDef[];
650
+ export declare function isMeasureLike(field: FieldDef): boolean;
651
+ export declare function isValueString(value: QueryValue, field: FieldDef): value is string | null;
652
+ export declare function isValueNumber(value: QueryValue, field: FieldDef): value is number | null;
653
+ export declare function isValueBoolean(value: QueryValue, field: FieldDef): value is boolean | null;
654
+ export declare function isValueTimestamp(value: QueryValue, field: FieldDef): value is {
655
+ value: string;
656
+ } | null;
657
+ export declare function isValueDate(value: QueryValue, field: FieldDef): value is {
658
+ value: string;
659
+ } | null;
660
+ export interface SearchIndexResult {
661
+ fieldName: string;
662
+ fieldValue: string;
663
+ fieldType: string;
664
+ weight: number;
665
+ }
666
+ export interface SearchValueMapResult {
667
+ fieldName: string;
668
+ cardinality: number;
669
+ values: {
670
+ fieldValue: string;
671
+ weight: number;
672
+ }[];
673
+ }
674
+ export {};