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