@malloydata/malloy 0.0.353 → 0.0.355
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/api/foundation/core.d.ts +8 -1
- package/dist/api/foundation/core.js +56 -0
- package/dist/api/util.js +1 -45
- package/dist/model/query_node.js +5 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -3,8 +3,9 @@ import type { BuildID, CompiledQuery, DocumentLocation, BooleanFieldDef, JSONFie
|
|
|
3
3
|
import { QueryModel } from '../../model';
|
|
4
4
|
import type { Dialect } from '../../dialect';
|
|
5
5
|
import type { BuildGraph, CompileQueryOptions } from './types';
|
|
6
|
-
import
|
|
6
|
+
import { Tag } from '@malloydata/malloy-tag';
|
|
7
7
|
import type { MalloyTagParse, TagParseSpec } from '../../annotation';
|
|
8
|
+
import type * as Malloy from '@malloydata/malloy-interfaces';
|
|
8
9
|
import type { Taggable } from '../../taggable';
|
|
9
10
|
declare abstract class Entity {
|
|
10
11
|
private readonly _name;
|
|
@@ -494,5 +495,11 @@ export declare class PreparedResult implements Taggable {
|
|
|
494
495
|
* CREATE SECRET, etc.) do not return a schema.
|
|
495
496
|
*/
|
|
496
497
|
get hasSchema(): boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Convert to the stable Malloy.Result interface format.
|
|
500
|
+
* Pass data to include query results, or omit for schema-only
|
|
501
|
+
* (e.g. headless tag validation).
|
|
502
|
+
*/
|
|
503
|
+
toStableResult(data?: Malloy.Data): Malloy.Result;
|
|
497
504
|
}
|
|
498
505
|
export {};
|
|
@@ -10,7 +10,10 @@ const utils_1 = require("../../model/utils");
|
|
|
10
10
|
const dialect_1 = require("../../dialect");
|
|
11
11
|
const persist_utils_1 = require("../../model/persist_utils");
|
|
12
12
|
const source_def_utils_1 = require("../../model/source_def_utils");
|
|
13
|
+
const malloy_tag_1 = require("@malloydata/malloy-tag");
|
|
13
14
|
const annotation_1 = require("../../annotation");
|
|
15
|
+
const to_stable_1 = require("../../to_stable");
|
|
16
|
+
const util_1 = require("../util");
|
|
14
17
|
const utils_2 = require("../../lang/utils");
|
|
15
18
|
const reference_list_1 = require("../../lang/reference-list");
|
|
16
19
|
function isSourceComponent(source) {
|
|
@@ -1248,6 +1251,59 @@ class PreparedResult {
|
|
|
1248
1251
|
get hasSchema() {
|
|
1249
1252
|
return this.inner.structs.length > 0;
|
|
1250
1253
|
}
|
|
1254
|
+
/**
|
|
1255
|
+
* Convert to the stable Malloy.Result interface format.
|
|
1256
|
+
* Pass data to include query results, or omit for schema-only
|
|
1257
|
+
* (e.g. headless tag validation).
|
|
1258
|
+
*/
|
|
1259
|
+
toStableResult(data) {
|
|
1260
|
+
const structs = this.inner.structs;
|
|
1261
|
+
const struct = structs[structs.length - 1];
|
|
1262
|
+
const schema = { fields: (0, to_stable_1.convertFieldInfos)(struct, struct.fields) };
|
|
1263
|
+
const annotations = (0, annotation_1.annotationToTaglines)(this.inner.annotation).map(l => ({
|
|
1264
|
+
value: l,
|
|
1265
|
+
}));
|
|
1266
|
+
const metadataAnnot = struct.resultMetadata
|
|
1267
|
+
? (0, to_stable_1.getResultStructMetadataAnnotation)(struct, struct.resultMetadata)
|
|
1268
|
+
: undefined;
|
|
1269
|
+
if (metadataAnnot) {
|
|
1270
|
+
annotations.push(metadataAnnot);
|
|
1271
|
+
}
|
|
1272
|
+
const sourceMetadataTag = malloy_tag_1.Tag.withPrefix('#(malloy) ');
|
|
1273
|
+
const sourceExplore = this.sourceExplore;
|
|
1274
|
+
if (sourceExplore) {
|
|
1275
|
+
sourceMetadataTag.set(['source', 'name'], sourceExplore.name);
|
|
1276
|
+
}
|
|
1277
|
+
if (this._sourceArguments) {
|
|
1278
|
+
const args = Object.entries(this._sourceArguments);
|
|
1279
|
+
for (let i = 0; i < args.length; i++) {
|
|
1280
|
+
const [name, value] = args[i];
|
|
1281
|
+
const literal = (0, util_1.nodeToLiteralValue)(value.value);
|
|
1282
|
+
if (literal !== undefined) {
|
|
1283
|
+
(0, to_stable_1.writeLiteralToTag)(sourceMetadataTag, ['source', 'parameters', i, 'value'], literal);
|
|
1284
|
+
}
|
|
1285
|
+
sourceMetadataTag.set(['source', 'parameters', i, 'name'], name);
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
annotations.push({ value: sourceMetadataTag.toString() });
|
|
1289
|
+
annotations.push({
|
|
1290
|
+
value: malloy_tag_1.Tag.withPrefix('#(malloy) ')
|
|
1291
|
+
.set(['query_name'], this.inner.queryName || struct.name)
|
|
1292
|
+
.toString(),
|
|
1293
|
+
});
|
|
1294
|
+
const modelAnnotations = (0, annotation_1.annotationToTaglines)(this.modelDef.annotation).map(l => ({
|
|
1295
|
+
value: l,
|
|
1296
|
+
}));
|
|
1297
|
+
return {
|
|
1298
|
+
schema,
|
|
1299
|
+
data,
|
|
1300
|
+
connection_name: this.inner.connectionName,
|
|
1301
|
+
annotations: annotations.length > 0 ? annotations : undefined,
|
|
1302
|
+
model_annotations: modelAnnotations.length > 0 ? modelAnnotations : undefined,
|
|
1303
|
+
query_timezone: struct.queryTimezone,
|
|
1304
|
+
sql: this.inner.sql,
|
|
1305
|
+
};
|
|
1306
|
+
}
|
|
1251
1307
|
}
|
|
1252
1308
|
exports.PreparedResult = PreparedResult;
|
|
1253
1309
|
//# sourceMappingURL=core.js.map
|
package/dist/api/util.js
CHANGED
|
@@ -13,8 +13,6 @@ exports.mapData = mapData;
|
|
|
13
13
|
exports.wrapResult = wrapResult;
|
|
14
14
|
exports.nodeToLiteralValue = nodeToLiteralValue;
|
|
15
15
|
exports.mapLogs = mapLogs;
|
|
16
|
-
const malloy_tag_1 = require("@malloydata/malloy-tag");
|
|
17
|
-
const annotation_1 = require("../annotation");
|
|
18
16
|
const to_stable_1 = require("../to_stable");
|
|
19
17
|
const row_data_utils_1 = require("./row_data_utils");
|
|
20
18
|
function wrapLegacyInfoConnection(connection) {
|
|
@@ -165,49 +163,7 @@ function wrapResult(result) {
|
|
|
165
163
|
const structs = result._queryResult.structs;
|
|
166
164
|
const struct = structs[structs.length - 1];
|
|
167
165
|
const schema = { fields: (0, to_stable_1.convertFieldInfos)(struct, struct.fields) };
|
|
168
|
-
|
|
169
|
-
value: l,
|
|
170
|
-
}));
|
|
171
|
-
const metadataAnnot = struct.resultMetadata
|
|
172
|
-
? (0, to_stable_1.getResultStructMetadataAnnotation)(struct, struct.resultMetadata)
|
|
173
|
-
: undefined;
|
|
174
|
-
if (metadataAnnot) {
|
|
175
|
-
annotations.push(metadataAnnot);
|
|
176
|
-
}
|
|
177
|
-
annotations.push(...(struct.resultMetadata ? [] : []));
|
|
178
|
-
const sourceMetadataTag = malloy_tag_1.Tag.withPrefix('#(malloy) ');
|
|
179
|
-
if (result.sourceExplore) {
|
|
180
|
-
sourceMetadataTag.set(['source', 'name'], result.sourceExplore.name);
|
|
181
|
-
}
|
|
182
|
-
if (result._sourceArguments) {
|
|
183
|
-
const args = Object.entries(result._sourceArguments);
|
|
184
|
-
for (let i = 0; i < args.length; i++) {
|
|
185
|
-
const [name, value] = args[i];
|
|
186
|
-
const literal = nodeToLiteralValue(value.value);
|
|
187
|
-
if (literal !== undefined) {
|
|
188
|
-
(0, to_stable_1.writeLiteralToTag)(sourceMetadataTag, ['source', 'parameters', i, 'value'], literal);
|
|
189
|
-
}
|
|
190
|
-
sourceMetadataTag.set(['source', 'parameters', i, 'name'], name);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
annotations.push({ value: sourceMetadataTag.toString() });
|
|
194
|
-
annotations.push({
|
|
195
|
-
value: malloy_tag_1.Tag.withPrefix('#(malloy) ')
|
|
196
|
-
.set(['query_name'], result.resultExplore.name)
|
|
197
|
-
.toString(),
|
|
198
|
-
});
|
|
199
|
-
const modelAnnotations = (0, annotation_1.annotationToTaglines)(result._modelDef.annotation).map(l => ({
|
|
200
|
-
value: l,
|
|
201
|
-
}));
|
|
202
|
-
return {
|
|
203
|
-
schema,
|
|
204
|
-
data: mapData(result.data.rawData, schema),
|
|
205
|
-
connection_name: result.connectionName,
|
|
206
|
-
annotations: annotations.length > 0 ? annotations : undefined,
|
|
207
|
-
model_annotations: modelAnnotations.length > 0 ? modelAnnotations : undefined,
|
|
208
|
-
query_timezone: result.data.field.queryTimezone,
|
|
209
|
-
sql: result.sql,
|
|
210
|
-
};
|
|
166
|
+
return result.toStableResult(mapData(result.data.rawData, schema));
|
|
211
167
|
}
|
|
212
168
|
function nodeToLiteralValue(expr) {
|
|
213
169
|
switch (expr === null || expr === void 0 ? void 0 : expr.node) {
|
package/dist/model/query_node.js
CHANGED
|
@@ -290,7 +290,11 @@ class QueryStruct {
|
|
|
290
290
|
this.addFieldToNameMap(as, this.makeQueryField(field));
|
|
291
291
|
}
|
|
292
292
|
else {
|
|
293
|
-
|
|
293
|
+
// According to the type system this should be impossible, but we have seen this happen
|
|
294
|
+
// in the wild, so we are leaving error handling here to help debug if it happens again.
|
|
295
|
+
throw new Error(`Unexpected field '${as}' in addFieldsFromFieldList` +
|
|
296
|
+
`\n field: ${JSON.stringify(field)}` +
|
|
297
|
+
`\n structDef: ${JSON.stringify(this.structDef)}`);
|
|
294
298
|
}
|
|
295
299
|
}
|
|
296
300
|
// if we don't have distinct key yet for this struct, add it.
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const MALLOY_VERSION = "0.0.
|
|
1
|
+
export declare const MALLOY_VERSION = "0.0.355";
|
package/dist/version.js
CHANGED
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MALLOY_VERSION = void 0;
|
|
4
4
|
// generated with 'generate-version-file' script; do not edit manually
|
|
5
|
-
exports.MALLOY_VERSION = '0.0.
|
|
5
|
+
exports.MALLOY_VERSION = '0.0.355';
|
|
6
6
|
//# sourceMappingURL=version.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@malloydata/malloy",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.355",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dist/index.js",
|
|
@@ -47,9 +47,9 @@
|
|
|
47
47
|
"generate-version-file": "VERSION=$(npm pkg get version --workspaces=false | tr -d \\\")\necho \"// generated with 'generate-version-file' script; do not edit manually\\nexport const MALLOY_VERSION = '$VERSION';\" > src/version.ts"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@malloydata/malloy-filter": "0.0.
|
|
51
|
-
"@malloydata/malloy-interfaces": "0.0.
|
|
52
|
-
"@malloydata/malloy-tag": "0.0.
|
|
50
|
+
"@malloydata/malloy-filter": "0.0.355",
|
|
51
|
+
"@malloydata/malloy-interfaces": "0.0.355",
|
|
52
|
+
"@malloydata/malloy-tag": "0.0.355",
|
|
53
53
|
"@noble/hashes": "^1.8.0",
|
|
54
54
|
"antlr4ts": "^0.5.0-alpha.4",
|
|
55
55
|
"assert": "^2.0.0",
|