@malloydata/malloy 0.0.271 → 0.0.273
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/core.js +21 -2
- package/dist/dialect/trino/dialect_functions.js +21 -0
- package/dist/lang/ast/expressions/constant-expression.d.ts +2 -2
- package/dist/lang/ast/expressions/constant-expression.js +2 -2
- package/dist/lang/ast/field-space/dynamic-space.js +1 -1
- package/dist/lang/ast/field-space/include-utils.d.ts +28 -0
- package/dist/lang/ast/field-space/include-utils.js +258 -0
- package/dist/lang/ast/field-space/parameter-space.d.ts +2 -2
- package/dist/lang/ast/field-space/parameter-space.js +2 -2
- package/dist/lang/ast/field-space/query-input-space.d.ts +4 -4
- package/dist/lang/ast/field-space/query-input-space.js +4 -4
- package/dist/lang/ast/field-space/query-spaces.d.ts +1 -0
- package/dist/lang/ast/field-space/query-spaces.js +4 -1
- package/dist/lang/ast/field-space/refined-space.d.ts +4 -8
- package/dist/lang/ast/field-space/refined-space.js +64 -7
- package/dist/lang/ast/field-space/static-space.d.ts +6 -4
- package/dist/lang/ast/field-space/static-space.js +29 -9
- package/dist/lang/ast/query-elements/query-arrow.js +2 -2
- package/dist/lang/ast/query-elements/query-refine.js +1 -1
- package/dist/lang/ast/query-items/field-declaration.d.ts +2 -2
- package/dist/lang/ast/query-items/field-declaration.js +2 -2
- package/dist/lang/ast/query-properties/qop-desc.js +1 -1
- package/dist/lang/ast/source-elements/refined-source.js +7 -134
- package/dist/lang/ast/types/field-space.d.ts +3 -3
- package/dist/lang/ast/view-elements/qop-desc-view.js +1 -1
- package/dist/lang/ast/view-elements/view-arrow.js +1 -1
- package/dist/lang/lib/Malloy/MalloyParser.d.ts +4 -4
- package/dist/lang/lib/Malloy/MalloyParser.js +13 -15
- package/dist/lang/malloy-to-ast.js +5 -9
- package/dist/lang/parse-log.d.ts +3 -0
- package/dist/lang/test/parse-expects.js +1 -1
- package/dist/lang/test/test-translator.js +1 -1
- package/dist/model/composite_source_utils.d.ts +1 -0
- package/dist/model/composite_source_utils.js +24 -3
- package/dist/model/malloy_query.js +4 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +4 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dialect } from '../../../dialect/dialect';
|
|
2
|
-
import type { FieldDef, StructDef, SourceDef, JoinFieldDef } from '../../../model/malloy_types';
|
|
2
|
+
import type { FieldDef, StructDef, SourceDef, JoinFieldDef, AccessModifierLabel } from '../../../model/malloy_types';
|
|
3
3
|
import type { SpaceEntry } from '../types/space-entry';
|
|
4
4
|
import type { LookupResult } from '../types/lookup-result';
|
|
5
5
|
import type { FieldName, FieldSpace, QueryFieldSpace, SourceFieldSpace } from '../types/field-space';
|
|
@@ -15,7 +15,7 @@ export declare class StaticSpace implements FieldSpace {
|
|
|
15
15
|
dialectObj(): Dialect | undefined;
|
|
16
16
|
defToSpaceField(from: FieldDef): SpaceField;
|
|
17
17
|
private get map();
|
|
18
|
-
|
|
18
|
+
accessProtectionLevel(): AccessModifierLabel;
|
|
19
19
|
protected dropEntries(): void;
|
|
20
20
|
protected dropEntry(name: string): void;
|
|
21
21
|
entry(name: string): SpaceEntry | undefined;
|
|
@@ -23,7 +23,7 @@ export declare class StaticSpace implements FieldSpace {
|
|
|
23
23
|
entries(): [string, SpaceEntry][];
|
|
24
24
|
structDef(): StructDef;
|
|
25
25
|
emptyStructDef(): StructDef;
|
|
26
|
-
lookup(path: FieldName[]): LookupResult;
|
|
26
|
+
lookup(path: FieldName[], accessLevel?: AccessModifierLabel): LookupResult;
|
|
27
27
|
isQueryFieldSpace(): this is QueryFieldSpace;
|
|
28
28
|
}
|
|
29
29
|
export declare class StructSpaceField extends StructSpaceFieldBase {
|
|
@@ -33,7 +33,9 @@ export declare class StructSpaceField extends StructSpaceFieldBase {
|
|
|
33
33
|
}
|
|
34
34
|
export declare class StaticSourceSpace extends StaticSpace implements SourceFieldSpace {
|
|
35
35
|
protected source: SourceDef;
|
|
36
|
-
|
|
36
|
+
readonly _accessProtectionLevel: AccessModifierLabel;
|
|
37
|
+
constructor(source: SourceDef, _accessProtectionLevel: AccessModifierLabel);
|
|
37
38
|
structDef(): SourceDef;
|
|
38
39
|
emptyStructDef(): SourceDef;
|
|
40
|
+
accessProtectionLevel(): AccessModifierLabel;
|
|
39
41
|
}
|
|
@@ -75,8 +75,8 @@ class StaticSpace {
|
|
|
75
75
|
}
|
|
76
76
|
return this.memoMap;
|
|
77
77
|
}
|
|
78
|
-
|
|
79
|
-
return
|
|
78
|
+
accessProtectionLevel() {
|
|
79
|
+
return 'internal';
|
|
80
80
|
}
|
|
81
81
|
dropEntries() {
|
|
82
82
|
this.memoMap = {};
|
|
@@ -105,7 +105,8 @@ class StaticSpace {
|
|
|
105
105
|
ret.fields = [];
|
|
106
106
|
return ret;
|
|
107
107
|
}
|
|
108
|
-
lookup(path) {
|
|
108
|
+
lookup(path, accessLevel) {
|
|
109
|
+
accessLevel !== null && accessLevel !== void 0 ? accessLevel : (accessLevel = this.accessProtectionLevel());
|
|
109
110
|
const head = path[0];
|
|
110
111
|
const rest = path.slice(1);
|
|
111
112
|
let found = this.entry(head.refString);
|
|
@@ -143,9 +144,8 @@ class StaticSpace {
|
|
|
143
144
|
}
|
|
144
145
|
if (definition === null || definition === void 0 ? void 0 : definition.accessModifier) {
|
|
145
146
|
// TODO path.length === 1 will not work with namespaces
|
|
146
|
-
if (!(
|
|
147
|
-
definition.accessModifier
|
|
148
|
-
path.length === 1)) {
|
|
147
|
+
if (!(path.length === 1 &&
|
|
148
|
+
accessAllowed(accessLevel, definition.accessModifier))) {
|
|
149
149
|
return {
|
|
150
150
|
error: {
|
|
151
151
|
message: `'${head}' is ${definition === null || definition === void 0 ? void 0 : definition.accessModifier}`,
|
|
@@ -161,7 +161,7 @@ class StaticSpace {
|
|
|
161
161
|
: [];
|
|
162
162
|
if (rest.length) {
|
|
163
163
|
if (found instanceof struct_space_field_base_1.StructSpaceFieldBase) {
|
|
164
|
-
const restResult = found.fieldSpace.lookup(rest);
|
|
164
|
+
const restResult = found.fieldSpace.lookup(rest, lessPermissiveAccessLevel(accessLevel, found.fieldSpace.accessProtectionLevel()));
|
|
165
165
|
if (restResult.found) {
|
|
166
166
|
return {
|
|
167
167
|
...restResult,
|
|
@@ -194,7 +194,7 @@ class StructSpaceField extends struct_space_field_base_1.StructSpaceFieldBase {
|
|
|
194
194
|
}
|
|
195
195
|
get fieldSpace() {
|
|
196
196
|
if ((0, malloy_types_1.isSourceDef)(this.structDef)) {
|
|
197
|
-
return new StaticSourceSpace(this.structDef);
|
|
197
|
+
return new StaticSourceSpace(this.structDef, 'internal');
|
|
198
198
|
}
|
|
199
199
|
else {
|
|
200
200
|
return new StaticSpace(this.structDef, this.forDialect);
|
|
@@ -203,9 +203,10 @@ class StructSpaceField extends struct_space_field_base_1.StructSpaceFieldBase {
|
|
|
203
203
|
}
|
|
204
204
|
exports.StructSpaceField = StructSpaceField;
|
|
205
205
|
class StaticSourceSpace extends StaticSpace {
|
|
206
|
-
constructor(source) {
|
|
206
|
+
constructor(source, _accessProtectionLevel) {
|
|
207
207
|
super(source, source.dialect);
|
|
208
208
|
this.source = source;
|
|
209
|
+
this._accessProtectionLevel = _accessProtectionLevel;
|
|
209
210
|
}
|
|
210
211
|
structDef() {
|
|
211
212
|
return this.source;
|
|
@@ -216,6 +217,25 @@ class StaticSourceSpace extends StaticSpace {
|
|
|
216
217
|
ret.fields = [];
|
|
217
218
|
return ret;
|
|
218
219
|
}
|
|
220
|
+
accessProtectionLevel() {
|
|
221
|
+
return this._accessProtectionLevel;
|
|
222
|
+
}
|
|
219
223
|
}
|
|
220
224
|
exports.StaticSourceSpace = StaticSourceSpace;
|
|
225
|
+
function accessAllowed(accessLevel, accessModifier) {
|
|
226
|
+
if (accessModifier === 'public')
|
|
227
|
+
return true;
|
|
228
|
+
if (accessLevel === 'internal')
|
|
229
|
+
return accessModifier === 'internal';
|
|
230
|
+
if (accessLevel === 'private')
|
|
231
|
+
return true;
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
function lessPermissiveAccessLevel(a, b) {
|
|
235
|
+
if (a === 'public' || b === 'public')
|
|
236
|
+
return 'public';
|
|
237
|
+
if (a === 'internal' || b === 'internal')
|
|
238
|
+
return 'internal';
|
|
239
|
+
return 'private';
|
|
240
|
+
}
|
|
221
241
|
//# sourceMappingURL=static-space.js.map
|
|
@@ -60,14 +60,14 @@ class QueryArrow extends query_base_1.QueryBase {
|
|
|
60
60
|
inputStruct = (0, malloy_types_1.refIsStructDef)(invoked.structRef)
|
|
61
61
|
? invoked.structRef
|
|
62
62
|
: this.source.getSourceDef(undefined);
|
|
63
|
-
fieldSpace = new static_space_1.StaticSourceSpace(inputStruct);
|
|
63
|
+
fieldSpace = new static_space_1.StaticSourceSpace(inputStruct, 'public');
|
|
64
64
|
}
|
|
65
65
|
else {
|
|
66
66
|
// We are adding a second stage to the given "source" query; we get the query and add a segment
|
|
67
67
|
const lhsQuery = this.source.queryComp(isRefOk);
|
|
68
68
|
queryBase = lhsQuery.query;
|
|
69
69
|
inputStruct = lhsQuery.outputStruct;
|
|
70
|
-
fieldSpace = new static_space_1.StaticSourceSpace(lhsQuery.outputStruct);
|
|
70
|
+
fieldSpace = new static_space_1.StaticSourceSpace(lhsQuery.outputStruct, 'public');
|
|
71
71
|
}
|
|
72
72
|
const { pipeline, annotation, outputStruct, name } = this.view.pipelineComp(fieldSpace);
|
|
73
73
|
const query = {
|
|
@@ -40,7 +40,7 @@ class QueryRefine extends query_base_1.QueryBase {
|
|
|
40
40
|
}
|
|
41
41
|
queryComp(isRefOk) {
|
|
42
42
|
const q = this.base.queryComp(isRefOk);
|
|
43
|
-
const inputFS = new static_space_1.StaticSourceSpace(q.inputStruct);
|
|
43
|
+
const inputFS = new static_space_1.StaticSourceSpace(q.inputStruct, 'public');
|
|
44
44
|
const resultPipe = this.refinement.refine(inputFS, q.query.pipeline, undefined);
|
|
45
45
|
const query = {
|
|
46
46
|
...q.query,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dialect } from '../../../dialect/dialect';
|
|
2
|
-
import type { Annotation, StructDef, TypeDesc, FieldDef, AtomicFieldDef } from '../../../model/malloy_types';
|
|
2
|
+
import type { Annotation, StructDef, TypeDesc, FieldDef, AtomicFieldDef, AccessModifierLabel } from '../../../model/malloy_types';
|
|
3
3
|
import type { ExprValue } from '../types/expr-value';
|
|
4
4
|
import type { ExpressionDef } from '../types/expression-def';
|
|
5
5
|
import type { FieldName, FieldSpace, QueryFieldSpace } from '../types/field-space';
|
|
@@ -74,7 +74,7 @@ export declare class DefSpace implements FieldSpace {
|
|
|
74
74
|
isQueryFieldSpace(): this is QueryFieldSpace;
|
|
75
75
|
outputSpace(): import("../field-space/query-spaces").QueryOperationSpace;
|
|
76
76
|
inputSpace(): import("../types/field-space").SourceFieldSpace;
|
|
77
|
-
|
|
77
|
+
accessProtectionLevel(): AccessModifierLabel;
|
|
78
78
|
}
|
|
79
79
|
export declare class FieldDefinitionValue extends SpaceField {
|
|
80
80
|
readonly space: FieldSpace;
|
|
@@ -98,7 +98,7 @@ class QOpDesc extends malloy_element_1.ListOf {
|
|
|
98
98
|
// TODO someday we'd like to get rid of the call to opOutputStruct here.
|
|
99
99
|
// If the `build.resultFS` is correct, then we should be able to just use that
|
|
100
100
|
// in a more direct way.
|
|
101
|
-
new static_space_1.StaticSourceSpace((0, struct_utils_1.opOutputStruct)(this, inputFS.structDef(), segment)),
|
|
101
|
+
new static_space_1.StaticSourceSpace((0, struct_utils_1.opOutputStruct)(this, inputFS.structDef(), segment), 'public'),
|
|
102
102
|
};
|
|
103
103
|
}
|
|
104
104
|
}
|
|
@@ -36,8 +36,7 @@ const annotation_elements_1 = require("../types/annotation-elements");
|
|
|
36
36
|
const renames_1 = require("../source-properties/renames");
|
|
37
37
|
const parameter_space_1 = require("../field-space/parameter-space");
|
|
38
38
|
const join_1 = require("../source-properties/join");
|
|
39
|
-
const
|
|
40
|
-
const field_references_1 = require("../query-items/field-references");
|
|
39
|
+
const include_utils_1 = require("../field-space/include-utils");
|
|
41
40
|
/**
|
|
42
41
|
* A Source made from a source reference and a set of refinements
|
|
43
42
|
*/
|
|
@@ -109,10 +108,11 @@ class RefinedSource extends source_1.Source {
|
|
|
109
108
|
}
|
|
110
109
|
const paramSpace = pList ? new parameter_space_1.ParameterSpace(pList) : undefined;
|
|
111
110
|
const from = structuredClone(this.source.getSourceDef(paramSpace));
|
|
112
|
-
const
|
|
111
|
+
const includeState = (0, include_utils_1.processIncludeList)(this.includeList, from);
|
|
112
|
+
const thisIncludeState = (0, include_utils_1.getIncludeStateForJoin)([], includeState);
|
|
113
113
|
for (const modifier of inlineAccessModifiers) {
|
|
114
114
|
for (const field of modifier.fields) {
|
|
115
|
-
modifiers.set(field, modifier.access);
|
|
115
|
+
thisIncludeState.modifiers.set(field, modifier.access);
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
118
|
// Note that this is explicitly not:
|
|
@@ -121,7 +121,7 @@ class RefinedSource extends source_1.Source {
|
|
|
121
121
|
if (primaryKey) {
|
|
122
122
|
from.primaryKey = primaryKey.field.name;
|
|
123
123
|
}
|
|
124
|
-
const fs = refined_space_1.RefinedSpace.filteredFrom(from, fieldListEdit,
|
|
124
|
+
const fs = refined_space_1.RefinedSpace.filteredFrom(from, fieldListEdit, includeState, paramSpace);
|
|
125
125
|
if (newTimezone) {
|
|
126
126
|
fs.setTimezone(newTimezone);
|
|
127
127
|
}
|
|
@@ -135,8 +135,8 @@ class RefinedSource extends source_1.Source {
|
|
|
135
135
|
primaryKey.logError(keyDef.error.code, keyDef.error.message);
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
-
fs.addAccessModifiers(modifiers);
|
|
139
|
-
fs.addNotes(notes);
|
|
138
|
+
fs.addAccessModifiers(thisIncludeState.modifiers);
|
|
139
|
+
fs.addNotes(thisIncludeState.notes);
|
|
140
140
|
const retStruct = fs.structDef();
|
|
141
141
|
const filterList = retStruct.filterList || [];
|
|
142
142
|
let moreFilters = false;
|
|
@@ -160,131 +160,4 @@ class RefinedSource extends source_1.Source {
|
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
162
|
exports.RefinedSource = RefinedSource;
|
|
163
|
-
function processIncludeList(includeItems, from) {
|
|
164
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
165
|
-
// TODO error/warning if you include both star and specific fields with the same modifier...
|
|
166
|
-
const allFields = new Set(from.fields.map(f => f.name));
|
|
167
|
-
const alreadyPrivateFields = new Set(from.fields.filter(f => f.accessModifier === 'private').map(f => f.name));
|
|
168
|
-
let mode = undefined;
|
|
169
|
-
const fieldsMentioned = new Set();
|
|
170
|
-
let star = undefined;
|
|
171
|
-
let starNote = undefined;
|
|
172
|
-
const modifiers = new Map();
|
|
173
|
-
const renames = [];
|
|
174
|
-
const notes = new Map();
|
|
175
|
-
if (includeItems === undefined) {
|
|
176
|
-
return { fieldsToInclude: undefined, modifiers, renames, notes };
|
|
177
|
-
}
|
|
178
|
-
for (const item of includeItems) {
|
|
179
|
-
if (item instanceof include_item_1.IncludeAccessItem) {
|
|
180
|
-
for (const f of item.fields) {
|
|
181
|
-
if (f.name instanceof field_references_1.WildcardFieldReference) {
|
|
182
|
-
if (f.name.joinPath) {
|
|
183
|
-
f.logError('unsupported-path-in-include', 'Wildcards with paths are not supported in `include` blocks');
|
|
184
|
-
}
|
|
185
|
-
if (star !== undefined) {
|
|
186
|
-
item.logError('already-used-star-in-include', 'Wildcard already used in this include block');
|
|
187
|
-
}
|
|
188
|
-
else {
|
|
189
|
-
star = (_a = item.kind) !== null && _a !== void 0 ? _a : 'inherit';
|
|
190
|
-
starNote = {
|
|
191
|
-
notes: (_c = (_b = f.note) === null || _b === void 0 ? void 0 : _b.notes) !== null && _c !== void 0 ? _c : [],
|
|
192
|
-
blockNotes: (_e = (_d = item.note) === null || _d === void 0 ? void 0 : _d.blockNotes) !== null && _e !== void 0 ? _e : [],
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
if (mode === 'exclude') {
|
|
198
|
-
item.logError('include-after-exclude', 'Cannot include specific fields if specific fields are already excluded');
|
|
199
|
-
continue;
|
|
200
|
-
}
|
|
201
|
-
mode = 'include';
|
|
202
|
-
const name = f.name.refString;
|
|
203
|
-
if (alreadyPrivateFields.has(name)) {
|
|
204
|
-
f.logError('cannot-expand-access', `Cannot expand access of \`${name}\` from private to ${item.kind}`);
|
|
205
|
-
}
|
|
206
|
-
if (modifiers.has(name)) {
|
|
207
|
-
f.logError('duplicate-include', `Field \`${name}\` already referenced in include list`);
|
|
208
|
-
}
|
|
209
|
-
else {
|
|
210
|
-
if (item.kind !== undefined) {
|
|
211
|
-
modifiers.set(name, item.kind);
|
|
212
|
-
}
|
|
213
|
-
fieldsMentioned.add(name);
|
|
214
|
-
if (f.note || item.note) {
|
|
215
|
-
notes.set(name, {
|
|
216
|
-
notes: (_g = (_f = f.note) === null || _f === void 0 ? void 0 : _f.notes) !== null && _g !== void 0 ? _g : [],
|
|
217
|
-
blockNotes: (_j = (_h = item.note) === null || _h === void 0 ? void 0 : _h.blockNotes) !== null && _j !== void 0 ? _j : [],
|
|
218
|
-
});
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
if (f.as) {
|
|
222
|
-
if (f.name instanceof field_references_1.WildcardFieldReference) {
|
|
223
|
-
f.logError('wildcard-include-rename', 'Cannot rename a wildcard field in an `include` block');
|
|
224
|
-
}
|
|
225
|
-
else {
|
|
226
|
-
renames.push({
|
|
227
|
-
name: f.name,
|
|
228
|
-
as: f.as,
|
|
229
|
-
location: f.location,
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
else if (item instanceof include_item_1.IncludeExceptItem) {
|
|
237
|
-
for (const f of item.fields) {
|
|
238
|
-
if (f instanceof field_references_1.WildcardFieldReference) {
|
|
239
|
-
if (f.joinPath) {
|
|
240
|
-
f.logError('unsupported-path-in-include', 'Wildcards with paths are not supported in `include` blocks');
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
f.logWarning('wildcard-except-redundant', '`except: *` is implied, unless another clause uses *');
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
else {
|
|
247
|
-
if (mode === 'include') {
|
|
248
|
-
item.logError('exclude-after-include', 'Cannot exclude specific fields if specific fields are already included');
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
mode = 'exclude';
|
|
252
|
-
star = 'inherit';
|
|
253
|
-
fieldsMentioned.add(f.refString);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
const starFields = new Set(allFields);
|
|
260
|
-
fieldsMentioned.forEach(f => starFields.delete(f));
|
|
261
|
-
alreadyPrivateFields.forEach(f => starFields.delete(f));
|
|
262
|
-
let fieldsToInclude;
|
|
263
|
-
if (star !== undefined) {
|
|
264
|
-
for (const field of starFields) {
|
|
265
|
-
if (star !== 'inherit') {
|
|
266
|
-
modifiers.set(field, star);
|
|
267
|
-
}
|
|
268
|
-
if (starNote) {
|
|
269
|
-
notes.set(field, { ...starNote });
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
if (mode !== 'exclude') {
|
|
274
|
-
if (star !== undefined) {
|
|
275
|
-
fieldsToInclude = allFields;
|
|
276
|
-
}
|
|
277
|
-
else {
|
|
278
|
-
fieldsToInclude = fieldsMentioned;
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
282
|
-
fieldsToInclude = starFields;
|
|
283
|
-
}
|
|
284
|
-
// TODO: validate that a field isn't renamed more than once
|
|
285
|
-
// TODO: validate that excluded fields are not referenced by included fields
|
|
286
|
-
// TODO: make renames fields work in existing references
|
|
287
|
-
// TODO: make renames that would replace an excluded field don't do that
|
|
288
|
-
return { fieldsToInclude, modifiers, renames, notes };
|
|
289
|
-
}
|
|
290
163
|
//# sourceMappingURL=refined-source.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Dialect } from '../../../dialect/dialect';
|
|
2
|
-
import type { SourceDef, StructDef } from '../../../model/malloy_types';
|
|
2
|
+
import type { AccessModifierLabel, SourceDef, StructDef } from '../../../model/malloy_types';
|
|
3
3
|
import type { QueryOperationSpace } from '../field-space/query-spaces';
|
|
4
4
|
import type { LookupResult } from './lookup-result';
|
|
5
5
|
import { MalloyElement } from './malloy-element';
|
|
@@ -12,13 +12,13 @@ export interface FieldSpace {
|
|
|
12
12
|
type: 'fieldSpace';
|
|
13
13
|
structDef(): StructDef;
|
|
14
14
|
emptyStructDef(): StructDef;
|
|
15
|
-
lookup(symbol: FieldName[]): LookupResult;
|
|
15
|
+
lookup(symbol: FieldName[], accessLevel?: AccessModifierLabel | undefined): LookupResult;
|
|
16
16
|
entry(symbol: string): SpaceEntry | undefined;
|
|
17
17
|
entries(): [string, SpaceEntry][];
|
|
18
18
|
dialectObj(): Dialect | undefined;
|
|
19
19
|
dialectName(): string;
|
|
20
20
|
isQueryFieldSpace(): this is QueryFieldSpace;
|
|
21
|
-
|
|
21
|
+
accessProtectionLevel(): AccessModifierLabel;
|
|
22
22
|
}
|
|
23
23
|
export interface SourceFieldSpace extends FieldSpace {
|
|
24
24
|
structDef(): SourceDef;
|
|
@@ -89,7 +89,7 @@ class QOpDescView extends view_1.View {
|
|
|
89
89
|
const last = pipeline.length - 1;
|
|
90
90
|
this.has({ tailRefinements });
|
|
91
91
|
const finalIn = (0, struct_utils_1.getFinalStruct)(this, inputFS.structDef(), pipeline.slice(-1));
|
|
92
|
-
pipeline[last] = this.getOp(new static_space_1.StaticSourceSpace(finalIn), undefined, tailRefinements, pipeline[last]);
|
|
92
|
+
pipeline[last] = this.getOp(new static_space_1.StaticSourceSpace(finalIn, 'public'), undefined, tailRefinements, pipeline[last]);
|
|
93
93
|
}
|
|
94
94
|
return pipeline;
|
|
95
95
|
}
|
|
@@ -40,7 +40,7 @@ class ViewArrow extends view_1.View {
|
|
|
40
40
|
}
|
|
41
41
|
pipelineComp(fs) {
|
|
42
42
|
const baseComp = this.base.pipelineComp(fs);
|
|
43
|
-
const nextFS = new static_space_1.StaticSourceSpace(baseComp.outputStruct);
|
|
43
|
+
const nextFS = new static_space_1.StaticSourceSpace(baseComp.outputStruct, 'public');
|
|
44
44
|
const finalComp = this.operation.pipelineComp(nextFS);
|
|
45
45
|
return {
|
|
46
46
|
pipeline: [...baseComp.pipeline, ...finalComp.pipeline],
|
|
@@ -1320,7 +1320,7 @@ export declare class IncludeExceptListContext extends ParserRuleContext {
|
|
|
1320
1320
|
}
|
|
1321
1321
|
export declare class IncludeExceptListItemContext extends ParserRuleContext {
|
|
1322
1322
|
tags(): TagsContext;
|
|
1323
|
-
|
|
1323
|
+
fieldPath(): FieldPathContext | undefined;
|
|
1324
1324
|
collectionWildCard(): CollectionWildCardContext | undefined;
|
|
1325
1325
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
1326
1326
|
get ruleIndex(): number;
|
|
@@ -1341,11 +1341,11 @@ export declare class IncludeListContext extends ParserRuleContext {
|
|
|
1341
1341
|
}
|
|
1342
1342
|
export declare class IncludeFieldContext extends ParserRuleContext {
|
|
1343
1343
|
_as: FieldNameContext;
|
|
1344
|
-
_name:
|
|
1344
|
+
_name: FieldPathContext;
|
|
1345
1345
|
tags(): TagsContext;
|
|
1346
|
-
|
|
1347
|
-
fieldName(i: number): FieldNameContext;
|
|
1346
|
+
fieldPath(): FieldPathContext | undefined;
|
|
1348
1347
|
isDefine(): IsDefineContext | undefined;
|
|
1348
|
+
fieldName(): FieldNameContext | undefined;
|
|
1349
1349
|
collectionWildCard(): CollectionWildCardContext | undefined;
|
|
1350
1350
|
constructor(parent: ParserRuleContext | undefined, invokingState: number);
|
|
1351
1351
|
get ruleIndex(): number;
|
|
@@ -3173,7 +3173,7 @@ class MalloyParser extends Parser_1.Parser {
|
|
|
3173
3173
|
this.state = 770;
|
|
3174
3174
|
this.tags();
|
|
3175
3175
|
this.state = 771;
|
|
3176
|
-
this.
|
|
3176
|
+
this.fieldPath();
|
|
3177
3177
|
}
|
|
3178
3178
|
break;
|
|
3179
3179
|
case 2:
|
|
@@ -3290,7 +3290,7 @@ class MalloyParser extends Parser_1.Parser {
|
|
|
3290
3290
|
break;
|
|
3291
3291
|
}
|
|
3292
3292
|
this.state = 797;
|
|
3293
|
-
_localctx._name = this.
|
|
3293
|
+
_localctx._name = this.fieldPath();
|
|
3294
3294
|
}
|
|
3295
3295
|
break;
|
|
3296
3296
|
case 2:
|
|
@@ -3299,7 +3299,7 @@ class MalloyParser extends Parser_1.Parser {
|
|
|
3299
3299
|
this.state = 799;
|
|
3300
3300
|
this.tags();
|
|
3301
3301
|
this.state = 800;
|
|
3302
|
-
_localctx._name = this.
|
|
3302
|
+
_localctx._name = this.fieldPath();
|
|
3303
3303
|
}
|
|
3304
3304
|
break;
|
|
3305
3305
|
case 3:
|
|
@@ -9336,7 +9336,7 @@ MalloyParser._serializedATNSegment1 = "\u0156\x05l7\x02\u0156\v\x03\x02\x02\x02\
|
|
|
9336
9336
|
"\x03\x02\x02\x02\u02FE\u02FC\x03\x02\x02\x02\u02FE\u02FF\x03\x02\x02\x02" +
|
|
9337
9337
|
"\u02FF\u0302\x03\x02\x02\x02\u0300\u02FE\x03\x02\x02\x02\u0301\u0303\x07" +
|
|
9338
9338
|
"\x87\x02\x02\u0302\u0301\x03\x02\x02\x02\u0302\u0303\x03\x02\x02\x02\u0303" +
|
|
9339
|
-
"w\x03\x02\x02\x02\u0304\u0305\x05\f\x07\x02\u0305\u0306\x05\
|
|
9339
|
+
"w\x03\x02\x02\x02\u0304\u0305\x05\f\x07\x02\u0305\u0306\x05\u0124\x93" +
|
|
9340
9340
|
"\x02\u0306\u030B\x03\x02\x02\x02\u0307\u0308\x05\f\x07\x02\u0308\u0309" +
|
|
9341
9341
|
"\x05\u011A\x8E\x02\u0309\u030B\x03\x02\x02\x02\u030A\u0304\x03\x02\x02" +
|
|
9342
9342
|
"\x02\u030A\u0307\x03\x02\x02\x02\u030By\x03\x02\x02\x02\u030C\u0313\x05" +
|
|
@@ -9348,9 +9348,9 @@ MalloyParser._serializedATNSegment1 = "\u0156\x05l7\x02\u0156\v\x03\x02\x02\x02\
|
|
|
9348
9348
|
"\x02\x02\u0317\u0318\x03\x02\x02\x02\u0318{\x03\x02\x02\x02\u0319\u031D" +
|
|
9349
9349
|
"\x05\f\x07\x02\u031A\u031B\x05\u0128\x95\x02\u031B\u031C\x05\x0E\b\x02" +
|
|
9350
9350
|
"\u031C\u031E\x03\x02\x02\x02\u031D\u031A\x03\x02\x02\x02\u031D\u031E\x03" +
|
|
9351
|
-
"\x02\x02\x02\u031E\u031F\x03\x02\x02\x02\u031F\u0320\x05\
|
|
9351
|
+
"\x02\x02\x02\u031E\u031F\x03\x02\x02\x02\u031F\u0320\x05\u0124\x93\x02" +
|
|
9352
9352
|
"\u0320\u0328\x03\x02\x02\x02\u0321\u0322\x05\f\x07\x02\u0322\u0323\x05" +
|
|
9353
|
-
"\
|
|
9353
|
+
"\u0124\x93\x02\u0323\u0328\x03\x02\x02\x02\u0324\u0325\x05\f\x07\x02\u0325" +
|
|
9354
9354
|
"\u0326\x05\u011A\x8E\x02\u0326\u0328\x03\x02\x02\x02\u0327\u0319\x03\x02" +
|
|
9355
9355
|
"\x02\x02\u0327\u0321\x03\x02\x02\x02\u0327\u0324\x03\x02\x02\x02\u0328" +
|
|
9356
9356
|
"}\x03\x02\x02\x02\u0329\u032A\b@\x01\x02\u032A\u0331\x05\u0124\x93\x02" +
|
|
@@ -12723,8 +12723,8 @@ class IncludeExceptListItemContext extends ParserRuleContext_1.ParserRuleContext
|
|
|
12723
12723
|
tags() {
|
|
12724
12724
|
return this.getRuleContext(0, TagsContext);
|
|
12725
12725
|
}
|
|
12726
|
-
|
|
12727
|
-
return this.tryGetRuleContext(0,
|
|
12726
|
+
fieldPath() {
|
|
12727
|
+
return this.tryGetRuleContext(0, FieldPathContext);
|
|
12728
12728
|
}
|
|
12729
12729
|
collectionWildCard() {
|
|
12730
12730
|
return this.tryGetRuleContext(0, CollectionWildCardContext);
|
|
@@ -12806,17 +12806,15 @@ class IncludeFieldContext extends ParserRuleContext_1.ParserRuleContext {
|
|
|
12806
12806
|
tags() {
|
|
12807
12807
|
return this.getRuleContext(0, TagsContext);
|
|
12808
12808
|
}
|
|
12809
|
-
|
|
12810
|
-
|
|
12811
|
-
return this.getRuleContexts(FieldNameContext);
|
|
12812
|
-
}
|
|
12813
|
-
else {
|
|
12814
|
-
return this.getRuleContext(i, FieldNameContext);
|
|
12815
|
-
}
|
|
12809
|
+
fieldPath() {
|
|
12810
|
+
return this.tryGetRuleContext(0, FieldPathContext);
|
|
12816
12811
|
}
|
|
12817
12812
|
isDefine() {
|
|
12818
12813
|
return this.tryGetRuleContext(0, IsDefineContext);
|
|
12819
12814
|
}
|
|
12815
|
+
fieldName() {
|
|
12816
|
+
return this.tryGetRuleContext(0, FieldNameContext);
|
|
12817
|
+
}
|
|
12820
12818
|
collectionWildCard() {
|
|
12821
12819
|
return this.tryGetRuleContext(0, CollectionWildCardContext);
|
|
12822
12820
|
}
|
|
@@ -1349,11 +1349,9 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1349
1349
|
if (fcx.tags().ANNOTATION().length > 0) {
|
|
1350
1350
|
this.contextError(fcx.tags(), 'cannot-tag-include-except', 'Tags on `except:` are ignored', { severity: 'warn' });
|
|
1351
1351
|
}
|
|
1352
|
-
const fieldNameCx = fcx.
|
|
1352
|
+
const fieldNameCx = fcx.fieldPath();
|
|
1353
1353
|
if (fieldNameCx) {
|
|
1354
|
-
return this.astAt(
|
|
1355
|
-
this.astAt(this.getFieldName(fieldNameCx), fcx),
|
|
1356
|
-
]), fieldNameCx);
|
|
1354
|
+
return this.astAt(this.getFieldPath(fieldNameCx, ast.AccessModifierFieldReference), fieldNameCx);
|
|
1357
1355
|
}
|
|
1358
1356
|
const wildcardCx = fcx.collectionWildCard();
|
|
1359
1357
|
if (wildcardCx) {
|
|
@@ -1367,22 +1365,20 @@ class MalloyToAST extends AbstractParseTreeVisitor_1.AbstractParseTreeVisitor {
|
|
|
1367
1365
|
const wildcard = wildcardCx
|
|
1368
1366
|
? this.visitCollectionWildCard(wildcardCx)
|
|
1369
1367
|
: undefined;
|
|
1370
|
-
const as = pcx._as ? pcx._as
|
|
1368
|
+
const as = pcx._as ? this.getFieldName(pcx._as) : undefined;
|
|
1371
1369
|
const tags1cx = pcx.tags();
|
|
1372
1370
|
const tags1 = tags1cx ? this.getNotes(tags1cx) : [];
|
|
1373
1371
|
const tags2cx = pcx.isDefine();
|
|
1374
1372
|
const tags2 = tags2cx ? this.getIsNotes(tags2cx) : [];
|
|
1375
1373
|
const notes = [...tags1, ...tags2];
|
|
1376
1374
|
const name = pcx._name
|
|
1377
|
-
? this.astAt(
|
|
1378
|
-
this.astAt(this.getFieldName(pcx._name), pcx._name),
|
|
1379
|
-
]), pcx._name)
|
|
1375
|
+
? this.astAt(this.getFieldPath(pcx._name, ast.AccessModifierFieldReference), pcx._name)
|
|
1380
1376
|
: undefined;
|
|
1381
1377
|
const reference = name !== null && name !== void 0 ? name : wildcard;
|
|
1382
1378
|
if (reference === undefined) {
|
|
1383
1379
|
throw this.internalError(pcx, 'Expected a field name or wildcard');
|
|
1384
1380
|
}
|
|
1385
|
-
const item = this.astAt(new ast.IncludeListItem(reference, as), pcx);
|
|
1381
|
+
const item = this.astAt(new ast.IncludeListItem(reference, as === null || as === void 0 ? void 0 : as.refString), pcx);
|
|
1386
1382
|
item.extendNote({ notes });
|
|
1387
1383
|
return item;
|
|
1388
1384
|
}
|
package/dist/lang/parse-log.d.ts
CHANGED
|
@@ -328,6 +328,7 @@ type MessageParameterTypes = {
|
|
|
328
328
|
'illegal-record-property-type': string;
|
|
329
329
|
'record-literal-needs-keys': string;
|
|
330
330
|
'not-yet-implemented': string;
|
|
331
|
+
'cannot-rename-join-field': string;
|
|
331
332
|
'sql-case': string;
|
|
332
333
|
'case-then-type-does-not-match': {
|
|
333
334
|
thenType: ExpressionValueType;
|
|
@@ -346,6 +347,7 @@ type MessageParameterTypes = {
|
|
|
346
347
|
};
|
|
347
348
|
'or-choices-only': string;
|
|
348
349
|
'sql-in': string;
|
|
350
|
+
'except-star-and-list': string;
|
|
349
351
|
'dialect-cast-unsafe-only': string;
|
|
350
352
|
'field-not-accessible': string;
|
|
351
353
|
'cannot-expand-access': string;
|
|
@@ -357,6 +359,7 @@ type MessageParameterTypes = {
|
|
|
357
359
|
'include-after-exclude': string;
|
|
358
360
|
'duplicate-include': string;
|
|
359
361
|
'exclude-after-include': string;
|
|
362
|
+
'exclude-after-exclude': string;
|
|
360
363
|
'cannot-rename-non-field': string;
|
|
361
364
|
'array-values-incompatible': string;
|
|
362
365
|
'invalid-resolved-type-for-array': string;
|
|
@@ -319,7 +319,7 @@ function checkForProblems(context, expectCompiles, s, allowAdditionalErrors, ...
|
|
|
319
319
|
}
|
|
320
320
|
}
|
|
321
321
|
if (i !== msgs.length) {
|
|
322
|
-
explain.push(...msgs.slice(i).map(m => `Missing: ${m}`));
|
|
322
|
+
explain.push(...msgs.slice(i).map(m => `Missing: ${JSON.stringify(m)}`));
|
|
323
323
|
}
|
|
324
324
|
if (!allowAdditionalErrors && i !== errList.length) {
|
|
325
325
|
explain.push(...errList.slice(i).map(m => `Unexpected Error: ${m.message}`));
|
|
@@ -394,7 +394,7 @@ class BetaExpression extends TestTranslator {
|
|
|
394
394
|
testFS() {
|
|
395
395
|
const aStruct = this.internalModel.contents[this.sourceName];
|
|
396
396
|
if ((0, malloy_types_1.isSourceDef)(aStruct)) {
|
|
397
|
-
const tstFS = new static_space_1.StaticSourceSpace(aStruct);
|
|
397
|
+
const tstFS = new static_space_1.StaticSourceSpace(aStruct, 'public');
|
|
398
398
|
return tstFS;
|
|
399
399
|
}
|
|
400
400
|
else {
|
|
@@ -76,6 +76,7 @@ export declare function emptyFieldUsage(): FieldUsage[];
|
|
|
76
76
|
export declare function joinedFieldUsage(joinPath: string[], fieldUsage: FieldUsage[]): FieldUsage[];
|
|
77
77
|
export declare function fieldUsageJoinPaths(fieldUsage: FieldUsage[]): string[][];
|
|
78
78
|
export declare function checkRequiredGroupBys(compositeResolvedSourceDef: SourceDef, segment: PipeSegment): RequiredGroupBy[];
|
|
79
|
+
export declare function pathEq(a: string[], b: string[]): boolean;
|
|
79
80
|
export declare function sortFieldUsageByReferenceLocation(usage: FieldUsage[]): FieldUsage[];
|
|
80
81
|
export declare function hasCompositesAnywhere(source: StructDef): boolean;
|
|
81
82
|
export declare function logCompositeError(error: CompositeError, logTo: MalloyElement): void;
|