@malloydata/malloy 0.0.334 → 0.0.336

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.
Files changed (91) hide show
  1. package/CONTEXT.md +4 -3
  2. package/MALLOY_API.md +129 -0
  3. package/dist/annotation.d.ts +0 -2
  4. package/dist/annotation.js +29 -23
  5. package/dist/api/asynchronous.d.ts +1 -1
  6. package/dist/api/foundation/cache.d.ts +32 -0
  7. package/dist/api/foundation/cache.js +92 -0
  8. package/dist/api/foundation/compile.d.ts +175 -0
  9. package/dist/api/foundation/compile.js +391 -0
  10. package/dist/api/foundation/core.d.ts +493 -0
  11. package/dist/api/foundation/core.js +1247 -0
  12. package/dist/api/foundation/document.d.ts +167 -0
  13. package/dist/api/foundation/document.js +206 -0
  14. package/dist/api/foundation/index.d.ts +10 -0
  15. package/dist/api/foundation/index.js +77 -0
  16. package/dist/api/foundation/readers.d.ts +53 -0
  17. package/dist/api/foundation/readers.js +134 -0
  18. package/dist/api/foundation/result.d.ts +185 -0
  19. package/dist/api/foundation/result.js +704 -0
  20. package/dist/api/foundation/runtime.d.ts +361 -0
  21. package/dist/api/foundation/runtime.js +733 -0
  22. package/dist/api/foundation/types.d.ts +54 -0
  23. package/dist/api/foundation/types.js +7 -0
  24. package/dist/api/foundation/writers.d.ts +42 -0
  25. package/dist/api/foundation/writers.js +230 -0
  26. package/dist/api/util.d.ts +1 -1
  27. package/dist/connection/base_connection.d.ts +5 -0
  28. package/dist/connection/types.d.ts +5 -0
  29. package/dist/dialect/duckdb/duckdb.js +2 -1
  30. package/dist/dialect/snowflake/snowflake.js +7 -1
  31. package/dist/dialect/trino/trino.js +7 -2
  32. package/dist/index.d.ts +6 -3
  33. package/dist/index.js +30 -26
  34. package/dist/lang/ast/error-factory.js +3 -5
  35. package/dist/lang/ast/expressions/expr-count-distinct.js +7 -1
  36. package/dist/lang/ast/expressions/expr-granular-time.js +1 -1
  37. package/dist/lang/ast/expressions/expr-max.js +7 -1
  38. package/dist/lang/ast/expressions/expr-min.js +7 -1
  39. package/dist/lang/ast/expressions/for-range.js +1 -1
  40. package/dist/lang/ast/source-elements/query-source.js +2 -7
  41. package/dist/lang/ast/source-elements/refined-source.js +11 -1
  42. package/dist/lang/ast/source-elements/sql-source.d.ts +1 -1
  43. package/dist/lang/ast/source-elements/sql-source.js +18 -3
  44. package/dist/lang/ast/sql-elements/sql-string.d.ts +2 -2
  45. package/dist/lang/ast/sql-elements/sql-string.js +18 -1
  46. package/dist/lang/ast/statements/define-source.js +7 -2
  47. package/dist/lang/ast/statements/import-statement.js +53 -21
  48. package/dist/lang/ast/types/document-compile-result.d.ts +1 -0
  49. package/dist/lang/ast/types/expression-def.js +1 -1
  50. package/dist/lang/ast/types/malloy-element.d.ts +3 -1
  51. package/dist/lang/ast/types/malloy-element.js +23 -7
  52. package/dist/lang/malloy-to-ast.d.ts +1 -1
  53. package/dist/lang/malloy-to-ast.js +1 -1
  54. package/dist/lang/parse-malloy.d.ts +3 -2
  55. package/dist/lang/parse-malloy.js +14 -25
  56. package/dist/lang/test/test-translator.d.ts +9 -2
  57. package/dist/lang/test/test-translator.js +103 -77
  58. package/dist/lang/translate-response.d.ts +1 -0
  59. package/dist/model/constant_expression_compiler.js +6 -7
  60. package/dist/model/index.d.ts +3 -1
  61. package/dist/model/index.js +15 -9
  62. package/dist/model/malloy_types.d.ts +89 -15
  63. package/dist/model/malloy_types.js +12 -0
  64. package/dist/model/persist_utils.d.ts +47 -0
  65. package/dist/model/persist_utils.js +257 -0
  66. package/dist/model/query_model_impl.d.ts +2 -4
  67. package/dist/model/query_model_impl.js +5 -13
  68. package/dist/model/query_node.d.ts +1 -2
  69. package/dist/model/query_node.js +3 -13
  70. package/dist/model/query_query.d.ts +17 -1
  71. package/dist/model/query_query.js +81 -36
  72. package/dist/model/source_def_utils.d.ts +50 -0
  73. package/dist/model/source_def_utils.js +154 -0
  74. package/dist/model/sql_block.d.ts +5 -1
  75. package/dist/model/sql_block.js +29 -4
  76. package/dist/model/sql_compiled.d.ts +29 -0
  77. package/dist/model/sql_compiled.js +102 -0
  78. package/dist/model/stage_writer.d.ts +1 -3
  79. package/dist/model/stage_writer.js +7 -25
  80. package/dist/model/utils.d.ts +20 -1
  81. package/dist/model/utils.js +40 -0
  82. package/dist/run_sql_options.d.ts +0 -1
  83. package/dist/taggable.d.ts +10 -0
  84. package/dist/taggable.js +7 -0
  85. package/dist/version.d.ts +1 -1
  86. package/dist/version.js +1 -1
  87. package/package.json +6 -4
  88. package/dist/malloy.d.ts +0 -1365
  89. package/dist/malloy.js +0 -3421
  90. package/dist/model/materialization/utils.d.ts +0 -3
  91. package/dist/model/materialization/utils.js +0 -41
@@ -0,0 +1,185 @@
1
+ import type { QueryData, QueryDataRow, QueryResult, QueryRunStats, ModelDef } from '../../model';
2
+ import type { Explore, Field, AtomicField, StringField, NumberField, BooleanField, DateField, TimestampField, JSONField, UnsupportedField } from './core';
3
+ import { PreparedResult } from './core';
4
+ export type ResultJSON = {
5
+ queryResult: QueryResult;
6
+ modelDef: ModelDef;
7
+ };
8
+ /**
9
+ * The result of running a Malloy query.
10
+ *
11
+ * A `Result` is a `PreparedResult` along with the data retrieved from running the query.
12
+ */
13
+ export declare class Result extends PreparedResult {
14
+ protected inner: QueryResult;
15
+ constructor(queryResult: QueryResult, modelDef: ModelDef);
16
+ get _queryResult(): QueryResult;
17
+ /**
18
+ * @return The result data.
19
+ */
20
+ get data(): DataArray;
21
+ get totalRows(): number;
22
+ get runStats(): QueryRunStats | undefined;
23
+ get profilingUrl(): string | undefined;
24
+ toJSON(): ResultJSON;
25
+ static fromJSON({ queryResult, modelDef }: ResultJSON): Result;
26
+ }
27
+ export type DataColumn = DataArray | DataRecord | DataString | DataBoolean | DataNumber | DataDate | DataTimestamp | DataNull | DataBytes | DataJSON | DataUnsupported;
28
+ export type DataArrayOrRecord = DataArray | DataRecord;
29
+ declare abstract class Data<T> {
30
+ readonly parent: DataArrayOrRecord | undefined;
31
+ readonly parentRecord: DataRecord | undefined;
32
+ protected _field: Field | Explore;
33
+ constructor(field: Field | Explore, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
34
+ get field(): Field | Explore;
35
+ abstract get value(): T;
36
+ isString(): this is DataString;
37
+ get string(): DataString;
38
+ isBoolean(): this is DataBoolean;
39
+ get boolean(): DataBoolean;
40
+ isNumber(): this is DataNumber;
41
+ get number(): DataNumber;
42
+ isTimestamp(): this is DataTimestamp;
43
+ get timestamp(): DataTimestamp;
44
+ isDate(): this is DataDate;
45
+ get date(): DataDate;
46
+ isNull(): this is DataNull;
47
+ isBytes(): this is DataBytes;
48
+ get bytes(): DataBytes;
49
+ isRecord(): this is DataRecord;
50
+ get record(): DataRecord;
51
+ isUnsupported(): this is DataUnsupported;
52
+ get unsupported(): DataUnsupported;
53
+ isArray(): this is DataArray;
54
+ get array(): DataArray;
55
+ isArrayOrRecord(): DataArrayOrRecord;
56
+ isScalar(): this is ScalarData<T>;
57
+ }
58
+ declare abstract class ScalarData<T> extends Data<T> {
59
+ protected _value: T;
60
+ protected _field: AtomicField;
61
+ constructor(value: T, field: AtomicField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
62
+ get value(): T;
63
+ get field(): AtomicField;
64
+ abstract get key(): string;
65
+ isScalar(): this is ScalarData<T>;
66
+ abstract compareTo(other: ScalarData<T>): number;
67
+ }
68
+ declare class DataString extends ScalarData<string> {
69
+ protected _field: StringField;
70
+ constructor(value: string, field: StringField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
71
+ get field(): StringField;
72
+ get key(): string;
73
+ compareTo(other: ScalarData<string>): number;
74
+ }
75
+ declare class DataUnsupported extends ScalarData<unknown> {
76
+ protected _field: UnsupportedField;
77
+ constructor(value: unknown, field: UnsupportedField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
78
+ get field(): UnsupportedField;
79
+ get key(): string;
80
+ compareTo(_other: ScalarData<unknown>): number;
81
+ }
82
+ declare class DataBoolean extends ScalarData<boolean> {
83
+ protected _field: BooleanField;
84
+ constructor(value: boolean, field: BooleanField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
85
+ get field(): BooleanField;
86
+ get key(): string;
87
+ compareTo(other: ScalarData<boolean>): 0 | 1 | -1;
88
+ }
89
+ declare class DataJSON extends ScalarData<string> {
90
+ protected _field: JSONField;
91
+ constructor(value: string, field: JSONField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
92
+ get field(): JSONField;
93
+ get key(): string;
94
+ compareTo(other: ScalarData<string>): 0 | 1 | -1;
95
+ }
96
+ declare class DataNumber extends ScalarData<number> {
97
+ protected _field: NumberField;
98
+ constructor(value: unknown, field: NumberField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
99
+ get field(): NumberField;
100
+ get key(): string;
101
+ compareTo(other: ScalarData<number>): 0 | 1 | -1;
102
+ }
103
+ declare class DataTimestamp extends ScalarData<Date> {
104
+ protected _field: TimestampField;
105
+ constructor(value: Date, field: TimestampField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
106
+ get value(): Date;
107
+ get field(): TimestampField;
108
+ get key(): string;
109
+ compareTo(other: ScalarData<Date>): 0 | 1 | -1;
110
+ }
111
+ declare class DataDate extends ScalarData<Date> {
112
+ protected _field: DateField;
113
+ constructor(value: Date, field: DateField, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
114
+ get value(): Date;
115
+ get field(): DateField;
116
+ get key(): string;
117
+ compareTo(other: ScalarData<Date>): 0 | 1 | -1;
118
+ }
119
+ declare class DataBytes extends ScalarData<Buffer> {
120
+ get key(): string;
121
+ compareTo(other: ScalarData<Buffer>): 0 | 1 | -1;
122
+ }
123
+ declare class DataNull extends Data<null> {
124
+ get value(): null;
125
+ get key(): string;
126
+ }
127
+ export declare class DataArray extends Data<QueryData> implements Iterable<DataRecord> {
128
+ private queryData;
129
+ protected _field: Explore;
130
+ private rowCache;
131
+ constructor(queryData: QueryData, field: Explore, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
132
+ /**
133
+ * @return The `Explore` that describes the structure of this data.
134
+ */
135
+ get field(): Explore;
136
+ /**
137
+ * @return The raw query data as returned by the database driver.
138
+ * Values may be in various formats depending on the driver (wrapper objects, strings, etc.).
139
+ * Use this for passing to mapData() which handles normalization itself.
140
+ */
141
+ get rawData(): QueryData;
142
+ /**
143
+ * @return Normalized data with JS native types (number | bigint, Date).
144
+ * Use this for CSV output, tests, and general programmatic access.
145
+ */
146
+ toObject(): QueryData;
147
+ /**
148
+ * @return Normalized data with JSON-safe types (numbers as number | string, dates as ISO strings).
149
+ * Use this for JSON serialization.
150
+ */
151
+ toJSON(): QueryData;
152
+ path(...path: (number | string)[]): DataColumn;
153
+ row(index: number): DataRecord;
154
+ get rowCount(): number;
155
+ get value(): QueryData;
156
+ [Symbol.iterator](): Iterator<DataRecord>;
157
+ inMemoryStream(): AsyncIterableIterator<DataRecord>;
158
+ }
159
+ export declare class DataRecord extends Data<{
160
+ [fieldName: string]: DataColumn;
161
+ }> {
162
+ private queryDataRow;
163
+ protected _field: Explore;
164
+ readonly index: number | undefined;
165
+ private cellCache;
166
+ constructor(queryDataRow: QueryDataRow, index: number | undefined, field: Explore, parent: DataArrayOrRecord | undefined, parentRecord: DataRecord | undefined);
167
+ /**
168
+ * @return Normalized data with JS native types (number | bigint, Date).
169
+ * Use this for CSV output, tests, and general programmatic access.
170
+ */
171
+ toObject(): QueryDataRow;
172
+ /**
173
+ * @return Normalized data with JSON-safe types (numbers as number | string, dates as ISO strings).
174
+ * Use this for JSON serialization.
175
+ */
176
+ toJSON(): QueryDataRow;
177
+ path(...path: (number | string)[]): DataColumn;
178
+ cell(fieldOrName: string | Field): DataColumn;
179
+ get value(): {
180
+ [fieldName: string]: DataColumn;
181
+ };
182
+ get field(): Explore;
183
+ [Symbol.iterator](): Iterator<DataRecord>;
184
+ }
185
+ export {};