@malloydata/malloy-interfaces 0.0.119-dev240118215411 → 0.0.119-dev240124170348

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.
@@ -7,6 +7,7 @@ type ConstantExpr = Expr;
7
7
  type Condition = Expr;
8
8
  interface ParamCondition extends ParamBase {
9
9
  condition: Condition | null;
10
+ type: CastType;
10
11
  }
11
12
  interface ParamValue extends ParamBase {
12
13
  value: ConstantExpr | null;
@@ -70,10 +71,6 @@ export interface AliasedName {
70
71
  export interface TypedObject {
71
72
  type: string;
72
73
  }
73
- export interface FilteredAliasedName extends AliasedName {
74
- filterList?: FilterExpression[];
75
- }
76
- export declare function isFilteredAliasedName(f: FieldTypeRef): f is FilteredAliasedName;
77
74
  /** all named objects have a type an a name (optionally aliased) */
78
75
  export interface NamedObject extends AliasedName, HasLocation {
79
76
  type: string;
@@ -198,7 +195,9 @@ export interface TypecastFragment extends DialectFragmentBase {
198
195
  function: 'cast';
199
196
  safe: boolean;
200
197
  expr: Expr;
201
- dstType: AtomicFieldType;
198
+ dstType: CastType | {
199
+ raw: string;
200
+ };
202
201
  srcType?: AtomicFieldType;
203
202
  }
204
203
  export interface RegexpMatchFragment extends DialectFragmentBase {
@@ -266,16 +265,17 @@ export declare function expressionIsAnalytic(e: ExpressionType | undefined): boo
266
265
  export declare function isExpressionTypeLEQ(e1: ExpressionType, e2: ExpressionType): boolean;
267
266
  export declare function maxExpressionType(e1: ExpressionType, e2: ExpressionType): ExpressionType;
268
267
  export declare function maxOfExpressionTypes(types: ExpressionType[]): ExpressionType;
269
- interface JustExpression {
268
+ type HasExpression = FieldDef & Expression & {
270
269
  e: Expr;
271
- }
272
- type HasExpression = FieldDef & JustExpression;
270
+ };
273
271
  /** Grants access to the expression property of a FieldDef */
274
272
  export declare function hasExpression(f: FieldDef): f is HasExpression;
275
273
  export type TimeFieldType = 'date' | 'timestamp';
276
274
  export declare function isTimeFieldType(s: string): s is TimeFieldType;
277
- export type AtomicFieldType = 'string' | 'number' | TimeFieldType | 'boolean' | 'unsupported' | 'json' | 'error';
275
+ export type CastType = 'string' | 'number' | TimeFieldType | 'boolean' | 'json';
276
+ export type AtomicFieldType = CastType | 'unsupported' | 'error';
278
277
  export declare function isAtomicFieldType(s: string): s is AtomicFieldType;
278
+ export declare function isCastType(s: string): s is CastType;
279
279
  /**
280
280
  * Fields which contain scalar data all inherit from this. The field
281
281
  * value could be an expression, and this is one of the objects
@@ -286,31 +286,49 @@ export interface FieldAtomicDef extends NamedObject, Expression, ResultMetadata
286
286
  annotation?: Annotation;
287
287
  }
288
288
  export declare function FieldIsIntrinsic(f: FieldDef): boolean;
289
- /** Scalar String Field */
290
- export interface FieldStringDef extends FieldAtomicDef {
289
+ export interface FieldStringTypeDef {
291
290
  type: 'string';
292
291
  bucketFilter?: string;
293
292
  bucketOther?: string;
294
293
  }
295
- /** Scalar Numeric String Field */
296
- export interface FieldNumberDef extends FieldAtomicDef {
294
+ /** Scalar String Field */
295
+ export interface FieldStringDef extends FieldAtomicDef, FieldStringTypeDef {
296
+ type: 'string';
297
+ }
298
+ export interface FieldNumberTypeDef {
297
299
  type: 'number';
298
300
  numberType?: 'integer' | 'float';
299
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
+ }
300
309
  /** Scalar Boolean Field */
301
- export interface FieldBooleanDef extends FieldAtomicDef {
310
+ export interface FieldBooleanDef extends FieldAtomicDef, FieldBooleanTypeDef {
302
311
  type: 'boolean';
303
312
  }
313
+ export interface FieldJSONTypeDef {
314
+ type: 'json';
315
+ }
304
316
  /** Scalar JSON Field */
305
- export interface FieldJSONDef extends FieldAtomicDef {
317
+ export interface FieldJSONDef extends FieldAtomicDef, FieldJSONTypeDef {
306
318
  type: 'json';
307
319
  }
308
- /** Scalar unsupported Field */
309
- export interface FieldUnsupportedDef extends FieldAtomicDef {
320
+ export interface FieldUnsupportedTypeDef {
310
321
  type: 'unsupported';
311
322
  rawType?: string;
312
323
  }
313
- export interface FieldErrorDef extends FieldAtomicDef {
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 {
314
332
  type: 'error';
315
333
  }
316
334
  export type DateUnit = 'day' | 'week' | 'month' | 'quarter' | 'year';
@@ -327,16 +345,22 @@ export declare enum ValueType {
327
345
  String = "string"
328
346
  }
329
347
  export type TimeValueType = ValueType.Date | ValueType.Timestamp;
330
- /** Scalar Date Field. */
331
- export interface FieldDateDef extends FieldAtomicDef {
348
+ export interface FieldDateTypeDef {
332
349
  type: 'date';
333
350
  timeframe?: DateUnit;
334
351
  }
335
- /** Scalar Timestamp Field */
336
- export interface FieldTimestampDef extends FieldAtomicDef {
352
+ /** Scalar Date Field. */
353
+ export interface FieldDateDef extends FieldAtomicDef, FieldDateTypeDef {
354
+ type: 'date';
355
+ }
356
+ export interface FieldTimestampTypeDef {
337
357
  type: 'timestamp';
338
358
  timeframe?: TimestampUnit;
339
359
  }
360
+ /** Scalar Timestamp Field */
361
+ export interface FieldTimestampDef extends FieldAtomicDef, FieldTimestampTypeDef {
362
+ type: 'timestamp';
363
+ }
340
364
  /** parameter to order a query */
341
365
  export interface OrderBy {
342
366
  field: string | number;
@@ -376,16 +400,21 @@ export interface Pipeline {
376
400
  }
377
401
  export interface Query extends Pipeline, Filtered, HasLocation {
378
402
  type?: 'query';
403
+ name?: string;
379
404
  structRef: StructRef;
380
405
  annotation?: Annotation;
381
406
  modelAnnotation?: Annotation;
382
407
  }
383
408
  export type NamedQuery = Query & NamedObject;
384
- export type PipeSegment = QuerySegment | IndexSegment;
409
+ export type PipeSegment = QuerySegment | IndexSegment | RawSegment;
385
410
  export interface ReduceSegment extends QuerySegment {
386
411
  type: 'reduce';
387
412
  }
388
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;
389
418
  export interface ProjectSegment extends QuerySegment {
390
419
  type: 'project';
391
420
  }
@@ -404,6 +433,11 @@ interface SamplingEnable {
404
433
  enable: boolean;
405
434
  }
406
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;
407
441
  export interface IndexSegment extends Filtered {
408
442
  type: 'index';
409
443
  fields: string[];
@@ -413,7 +447,7 @@ export interface IndexSegment extends Filtered {
413
447
  }
414
448
  export declare function isIndexSegment(pe: PipeSegment): pe is IndexSegment;
415
449
  export interface QuerySegment extends Filtered {
416
- type: 'reduce' | 'project';
450
+ type: 'reduce' | 'project' | 'partial';
417
451
  fields: QueryFieldDef[];
418
452
  extendSource?: FieldDef[];
419
453
  limit?: number;
@@ -439,7 +473,7 @@ export type StructRelationship = {
439
473
  type: 'inline';
440
474
  } | {
441
475
  type: 'nested';
442
- field: FieldRef;
476
+ fieldName: string;
443
477
  isArray: boolean;
444
478
  };
445
479
  export interface SQLFragment {
@@ -530,6 +564,7 @@ export interface FunctionOverloadDef {
530
564
  preceding: number | string;
531
565
  following: number | string;
532
566
  };
567
+ isSymmetric?: boolean;
533
568
  params: FunctionParameterDef[];
534
569
  dialect: {
535
570
  [dialect: string]: Expr;
@@ -549,17 +584,20 @@ export interface SQLBlockStructDef extends StructDef {
549
584
  export declare function isSQLBlockStruct(sd: StructDef): sd is SQLBlockStructDef;
550
585
  /** any of the different field types */
551
586
  export type FieldTypeDef = FieldStringDef | FieldDateDef | FieldTimestampDef | FieldNumberDef | FieldBooleanDef | FieldJSONDef | FieldUnsupportedDef | FieldErrorDef;
587
+ export type FieldAtomicTypeDef = FieldStringTypeDef | FieldDateTypeDef | FieldTimestampTypeDef | FieldNumberTypeDef | FieldBooleanTypeDef | FieldJSONTypeDef | FieldUnsupportedTypeDef | FieldErrorTypeDef;
552
588
  export declare function isFieldTypeDef(f: FieldDef): f is FieldTypeDef;
553
589
  export declare function isFieldTimeBased(f: FieldDef): f is FieldTimestampDef | FieldDateDef;
554
590
  export declare function isFieldStructDef(f: FieldDef): f is StructDef;
555
- /** field reference in a query */
556
- export type FieldTypeRef = string | FieldTypeDef | FilteredAliasedName;
557
- /** field reference with with possibly and order by. */
558
- export type QueryFieldDef = FieldTypeRef | TurtleDef;
591
+ export type QueryFieldDef = FieldTypeDef | TurtleDef | RefToField;
559
592
  /** basics statement */
560
593
  export type FieldDef = FieldTypeDef | StructDef | TurtleDef;
561
594
  /** reference to a field */
562
- export type FieldRef = string | FieldDef;
595
+ export interface RefToField {
596
+ type: 'fieldref';
597
+ path: string[];
598
+ annotation?: Annotation;
599
+ }
600
+ export type FieldRefOrDef = FieldDef | RefToField;
563
601
  /** which field is the primary key in this struct */
564
602
  export type PrimaryKeyRef = string;
565
603
  /** filters */
@@ -613,6 +651,7 @@ export type MalloyQueryData = {
613
651
  rows: QueryDataRow[];
614
652
  totalRows: number;
615
653
  runStats?: QueryRunStats;
654
+ profilingUrl?: string;
616
655
  };
617
656
  export interface DrillSource {
618
657
  sourceExplore: string;
@@ -634,8 +673,10 @@ export interface QueryResult extends CompiledQuery {
634
673
  totalRows: number;
635
674
  error?: string;
636
675
  runStats?: QueryRunStats;
676
+ profilingUrl?: string;
637
677
  }
638
678
  export declare function isTurtleDef(def: FieldDef): def is TurtleDef;
679
+ export declare function isAtomicField(def: FieldDef): def is FieldAtomicDef;
639
680
  export interface SearchResultRow {
640
681
  field_name: string;
641
682
  field_value: string;
@@ -22,8 +22,8 @@
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- exports.isSQLBlockStruct = exports.mergeEvalSpaces = exports.isSQLFragment = exports.isJoinOn = exports.isIndexSegment = exports.isSamplingEnable = exports.isSamplingPercent = exports.isSamplingRows = exports.isQuerySegment = exports.isProjectSegment = exports.isReduceSegment = exports.refIsStructDef = exports.isByExpression = exports.isByName = exports.ValueType = exports.isExtractUnit = exports.isTimestampUnit = exports.isDateUnit = exports.FieldIsIntrinsic = 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.isFilteredAliasedName = 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.isTurtleDef = exports.getIdentifier = exports.isFieldStructDef = exports.isFieldTimeBased = exports.isFieldTypeDef = void 0;
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
27
  function isValueParameter(p) {
28
28
  return p.value !== undefined;
29
29
  }
@@ -36,15 +36,6 @@ function paramHasValue(p) {
36
36
  return isValueParameter(p) || p.condition !== null;
37
37
  }
38
38
  exports.paramHasValue = paramHasValue;
39
- function isFilteredAliasedName(f) {
40
- for (const prop of Object.keys(f)) {
41
- if (!['name', 'as', 'filterList'].includes(prop)) {
42
- return false;
43
- }
44
- }
45
- return true;
46
- }
47
- exports.isFilteredAliasedName = isFilteredAliasedName;
48
39
  function isOutputFieldFragment(f) {
49
40
  return (f === null || f === void 0 ? void 0 : f.type) === 'outputField';
50
41
  }
@@ -222,9 +213,14 @@ function isAtomicFieldType(s) {
222
213
  'boolean',
223
214
  'json',
224
215
  'unsupported',
216
+ 'error',
225
217
  ].includes(s);
226
218
  }
227
219
  exports.isAtomicFieldType = isAtomicFieldType;
220
+ function isCastType(s) {
221
+ return ['string', 'number', 'date', 'timestamp', 'boolean', 'json'].includes(s);
222
+ }
223
+ exports.isCastType = isCastType;
228
224
  // this field definition represents something in the database.
229
225
  function FieldIsIntrinsic(f) {
230
226
  if (isAtomicFieldType(f.type) && !hasExpression(f)) {
@@ -281,6 +277,10 @@ function isReduceSegment(pe) {
281
277
  return pe.type === 'reduce';
282
278
  }
283
279
  exports.isReduceSegment = isReduceSegment;
280
+ function isPartialSegment(pe) {
281
+ return pe.type === 'partial';
282
+ }
283
+ exports.isPartialSegment = isPartialSegment;
284
284
  function isProjectSegment(pe) {
285
285
  return pe.type === 'project';
286
286
  }
@@ -301,6 +301,10 @@ function isSamplingEnable(s) {
301
301
  return s.enable !== undefined;
302
302
  }
303
303
  exports.isSamplingEnable = isSamplingEnable;
304
+ function isRawSegment(pe) {
305
+ return pe.type === 'raw';
306
+ }
307
+ exports.isRawSegment = isRawSegment;
304
308
  function isIndexSegment(pe) {
305
309
  return pe.type === 'index';
306
310
  }
@@ -357,6 +361,10 @@ function isTurtleDef(def) {
357
361
  return def.type === 'turtle';
358
362
  }
359
363
  exports.isTurtleDef = isTurtleDef;
364
+ function isAtomicField(def) {
365
+ return isAtomicFieldType(def.type);
366
+ }
367
+ exports.isAtomicField = isAtomicField;
360
368
  function isDimensional(field) {
361
369
  var _a;
362
370
  if ('resultMetadata' in field) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy-interfaces",
3
- "version": "0.0.119-dev240118215411",
3
+ "version": "0.0.119-dev240124170348",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",