@malloydata/malloy 0.0.22-dev230119001546 → 0.0.22-dev230119193053

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,7 +1,6 @@
1
1
  import { TimestampUnit, ExtractUnit, TimeFieldType } from "../../model/malloy_types";
2
- import { FieldSpace } from "../field-space";
3
2
  import { Comparison, ExprValue } from "./ast-types";
4
- import { ExpressionDef, MalloyElement } from "./ast-main";
3
+ import { ExpressionDef, FieldSpace, MalloyElement } from "./ast-main";
5
4
  export declare class Timeframe extends MalloyElement {
6
5
  elementType: string;
7
6
  readonly text: TimestampUnit;
@@ -1,92 +1,5 @@
1
1
  import * as model from "../model/malloy_types";
2
- import { FieldSpace, DynamicSpace, QuerySpace } from "./field-space";
3
- import { FieldValueType, FieldDeclaration, TurtleDecl, HasParameter, Join, FieldReference } from "./ast";
4
- interface FieldType {
5
- type: FieldValueType;
6
- expressionType?: model.ExpressionType;
7
- }
8
- export declare abstract class SpaceEntry {
9
- abstract type(): FieldType;
10
- abstract refType: "field" | "parameter";
11
- }
12
- export declare abstract class SpaceParam extends SpaceEntry {
13
- abstract parameter(): model.Parameter;
14
- readonly refType = "parameter";
15
- }
16
- export declare class DefinedParameter extends SpaceParam {
17
- readonly paramDef: model.Parameter;
18
- constructor(paramDef: model.Parameter);
19
- parameter(): model.Parameter;
20
- type(): FieldType;
21
- }
22
- export declare class AbstractParameter extends SpaceParam {
23
- readonly astParam: HasParameter;
24
- constructor(astParam: HasParameter);
25
- parameter(): model.Parameter;
26
- type(): FieldType;
27
- }
28
- export declare abstract class SpaceField extends SpaceEntry {
29
- readonly refType = "field";
30
- protected fieldTypeFromFieldDef(def: model.FieldDef): FieldType;
31
- getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined;
32
- fieldDef(): model.FieldDef | undefined;
33
- }
34
- export declare class RenameSpaceField extends SpaceField {
35
- private readonly otherField;
36
- private readonly newName;
37
- private readonly location;
38
- constructor(otherField: SpaceField, newName: string, location: model.DocumentLocation);
39
- fieldDef(): model.FieldDef | undefined;
40
- type(): FieldType;
41
- }
42
- export declare class WildSpaceField extends SpaceField {
43
- readonly wildText: string;
44
- constructor(wildText: string);
45
- type(): FieldType;
46
- getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef;
47
- }
48
- export declare class StructSpaceField extends SpaceField {
49
- protected sourceDef: model.StructDef;
50
- protected space?: FieldSpace;
51
- constructor(sourceDef: model.StructDef);
52
- get fieldSpace(): FieldSpace;
53
- fieldDef(): model.FieldDef;
54
- type(): FieldType;
55
- }
56
- export declare class JoinSpaceField extends StructSpaceField {
57
- readonly intoFS: FieldSpace;
58
- readonly join: Join;
59
- constructor(intoFS: FieldSpace, join: Join);
60
- }
61
- export declare class ColumnSpaceField extends SpaceField {
62
- protected def: model.FieldTypeDef;
63
- constructor(def: model.FieldTypeDef);
64
- fieldDef(): model.FieldDef;
65
- type(): FieldType;
66
- }
67
- export declare abstract class QueryField extends SpaceField {
68
- protected inSpace: FieldSpace;
69
- constructor(inSpace: FieldSpace);
70
- abstract getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined;
71
- abstract fieldDef(): model.FieldDef;
72
- type(): FieldType;
73
- }
74
- export declare class QueryFieldAST extends QueryField {
75
- readonly turtle: TurtleDecl;
76
- protected name: string;
77
- renameAs?: string;
78
- nestParent?: QuerySpace;
79
- constructor(fs: FieldSpace, turtle: TurtleDecl, name: string);
80
- getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef;
81
- fieldDef(): model.TurtleDef;
82
- }
83
- export declare class QueryFieldStruct extends QueryField {
84
- protected turtleDef: model.TurtleDef;
85
- constructor(fs: FieldSpace, turtleDef: model.TurtleDef);
86
- rename(name: string): void;
87
- fieldDef(): model.TurtleDef;
88
- getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined;
89
- }
2
+ import { FieldReference, FieldSpace, FieldType, SpaceField } from "./ast/ast-main";
90
3
  /**
91
4
  * FilteredAliasedName
92
5
  */
@@ -102,21 +15,3 @@ export declare class FANSPaceField extends SpaceField {
102
15
  getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef;
103
16
  type(): FieldType;
104
17
  }
105
- export declare class ReferenceField extends SpaceField {
106
- readonly fieldRef: FieldReference;
107
- constructor(fieldRef: FieldReference);
108
- getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined;
109
- type(): FieldType;
110
- }
111
- export declare class ExpressionFieldFromAst extends SpaceField {
112
- readonly space: DynamicSpace;
113
- readonly exprDef: FieldDeclaration;
114
- fieldName: string;
115
- defType?: FieldType;
116
- constructor(space: DynamicSpace, exprDef: FieldDeclaration);
117
- get name(): string;
118
- fieldDef(): model.FieldDef;
119
- getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef;
120
- type(): FieldType;
121
- }
122
- export {};
@@ -45,197 +45,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
45
45
  return result;
46
46
  };
47
47
  Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.ExpressionFieldFromAst = exports.ReferenceField = exports.FANSPaceField = exports.QueryFieldStruct = exports.QueryFieldAST = exports.QueryField = exports.ColumnSpaceField = exports.JoinSpaceField = exports.StructSpaceField = exports.WildSpaceField = exports.RenameSpaceField = exports.SpaceField = exports.AbstractParameter = exports.DefinedParameter = exports.SpaceParam = exports.SpaceEntry = void 0;
48
+ exports.FANSPaceField = void 0;
49
49
  const model = __importStar(require("../model/malloy_types"));
50
- const field_space_1 = require("./field-space");
51
- class SpaceEntry {
52
- }
53
- exports.SpaceEntry = SpaceEntry;
54
- class SpaceParam extends SpaceEntry {
55
- constructor() {
56
- super(...arguments);
57
- this.refType = "parameter";
58
- }
59
- }
60
- exports.SpaceParam = SpaceParam;
61
- class DefinedParameter extends SpaceParam {
62
- constructor(paramDef) {
63
- super();
64
- this.paramDef = paramDef;
65
- }
66
- parameter() {
67
- return this.paramDef;
68
- }
69
- type() {
70
- return { type: this.paramDef.type };
71
- }
72
- }
73
- exports.DefinedParameter = DefinedParameter;
74
- class AbstractParameter extends SpaceParam {
75
- constructor(astParam) {
76
- super();
77
- this.astParam = astParam;
78
- }
79
- parameter() {
80
- return this.astParam.parameter();
81
- }
82
- type() {
83
- const type = this.astParam.type || "unknown";
84
- return { type };
85
- }
86
- }
87
- exports.AbstractParameter = AbstractParameter;
88
- class SpaceField extends SpaceEntry {
89
- constructor() {
90
- super(...arguments);
91
- this.refType = "field";
92
- }
93
- fieldTypeFromFieldDef(def) {
94
- const ref = { type: def.type };
95
- if (model.isFieldTypeDef(def) && def.expressionType) {
96
- ref.expressionType = def.expressionType;
97
- }
98
- return ref;
99
- }
100
- getQueryFieldDef(_fs) {
101
- return undefined;
102
- }
103
- fieldDef() {
104
- return undefined;
105
- }
106
- }
107
- exports.SpaceField = SpaceField;
108
- class RenameSpaceField extends SpaceField {
109
- constructor(otherField, newName, location) {
110
- super();
111
- this.otherField = otherField;
112
- this.newName = newName;
113
- this.location = location;
114
- }
115
- fieldDef() {
116
- const renamedFieldRaw = this.otherField.fieldDef();
117
- if (renamedFieldRaw === undefined) {
118
- return undefined;
119
- }
120
- return {
121
- ...renamedFieldRaw,
122
- as: this.newName,
123
- location: this.location,
124
- };
125
- }
126
- type() {
127
- return this.otherField.type();
128
- }
129
- }
130
- exports.RenameSpaceField = RenameSpaceField;
131
- class WildSpaceField extends SpaceField {
132
- constructor(wildText) {
133
- super();
134
- this.wildText = wildText;
135
- }
136
- type() {
137
- throw new Error("should never ask a wild field for its type");
138
- }
139
- getQueryFieldDef(_fs) {
140
- return this.wildText;
141
- }
142
- }
143
- exports.WildSpaceField = WildSpaceField;
144
- class StructSpaceField extends SpaceField {
145
- constructor(sourceDef) {
146
- super();
147
- this.sourceDef = sourceDef;
148
- }
149
- get fieldSpace() {
150
- if (!this.space) {
151
- this.space = new field_space_1.StaticSpace(this.sourceDef);
152
- }
153
- return this.space;
154
- }
155
- fieldDef() {
156
- return this.sourceDef;
157
- }
158
- type() {
159
- return { type: "struct" };
160
- }
161
- }
162
- exports.StructSpaceField = StructSpaceField;
163
- class JoinSpaceField extends StructSpaceField {
164
- constructor(intoFS, join) {
165
- super(join.structDef());
166
- this.intoFS = intoFS;
167
- this.join = join;
168
- }
169
- }
170
- exports.JoinSpaceField = JoinSpaceField;
171
- class ColumnSpaceField extends SpaceField {
172
- constructor(def) {
173
- super();
174
- this.def = def;
175
- }
176
- fieldDef() {
177
- return this.def;
178
- }
179
- type() {
180
- return this.fieldTypeFromFieldDef(this.def);
181
- }
182
- }
183
- exports.ColumnSpaceField = ColumnSpaceField;
184
- class QueryField extends SpaceField {
185
- constructor(inSpace) {
186
- super();
187
- this.inSpace = inSpace;
188
- }
189
- type() {
190
- return { type: "turtle" };
191
- }
192
- }
193
- exports.QueryField = QueryField;
194
- class QueryFieldAST extends QueryField {
195
- constructor(fs, turtle, name) {
196
- super(fs);
197
- this.turtle = turtle;
198
- this.name = name;
199
- }
200
- getQueryFieldDef(fs) {
201
- const def = this.turtle.getFieldDef(fs, this.nestParent);
202
- if (this.renameAs) {
203
- def.as = this.renameAs;
204
- }
205
- return def;
206
- }
207
- fieldDef() {
208
- const def = this.turtle.getFieldDef(this.inSpace, this.nestParent);
209
- if (this.renameAs) {
210
- def.as = this.renameAs;
211
- }
212
- return def;
213
- }
214
- }
215
- exports.QueryFieldAST = QueryFieldAST;
216
- class QueryFieldStruct extends QueryField {
217
- constructor(fs, turtleDef) {
218
- super(fs);
219
- this.turtleDef = turtleDef;
220
- }
221
- rename(name) {
222
- this.turtleDef = {
223
- ...this.turtleDef,
224
- as: name,
225
- };
226
- }
227
- fieldDef() {
228
- return this.turtleDef;
229
- }
230
- getQueryFieldDef(_fs) {
231
- return this.fieldDef();
232
- }
233
- }
234
- exports.QueryFieldStruct = QueryFieldStruct;
50
+ const ast_main_1 = require("./ast/ast-main");
51
+ // "Space Fields" are a field in a field space
235
52
  /**
236
53
  * FilteredAliasedName
237
54
  */
238
- class FANSPaceField extends SpaceField {
55
+ class FANSPaceField extends ast_main_1.SpaceField {
239
56
  constructor(ref, inSpace, refInit) {
240
57
  super();
241
58
  this.ref = ref;
@@ -261,7 +78,7 @@ class FANSPaceField extends SpaceField {
261
78
  const fieldType = fieldTypeInfo.type;
262
79
  // TODO starting to feel like this should be a method call on a spaceentry
263
80
  if (model.isAtomicFieldType(fieldType)) {
264
- if (fromField instanceof SpaceParam) {
81
+ if (fromField instanceof ast_main_1.SpaceParam) {
265
82
  return {
266
83
  type: fieldType,
267
84
  name: this.as,
@@ -307,50 +124,4 @@ class FANSPaceField extends SpaceField {
307
124
  }
308
125
  }
309
126
  exports.FANSPaceField = FANSPaceField;
310
- class ReferenceField extends SpaceField {
311
- constructor(fieldRef) {
312
- super();
313
- this.fieldRef = fieldRef;
314
- }
315
- getQueryFieldDef(fs) {
316
- // Lookup string and generate error if it isn't defined.
317
- const check = this.fieldRef.getField(fs);
318
- if (check.error) {
319
- this.fieldRef.log(check.error);
320
- }
321
- return this.fieldRef.refString;
322
- }
323
- type() {
324
- return { type: "unknown" };
325
- }
326
- }
327
- exports.ReferenceField = ReferenceField;
328
- class ExpressionFieldFromAst extends SpaceField {
329
- constructor(space, exprDef) {
330
- super();
331
- this.space = space;
332
- this.exprDef = exprDef;
333
- this.fieldName = exprDef.defineName;
334
- }
335
- get name() {
336
- return this.fieldName;
337
- }
338
- fieldDef() {
339
- const def = this.exprDef.fieldDef(this.space, this.name);
340
- this.defType = this.fieldTypeFromFieldDef(def);
341
- return def;
342
- }
343
- getQueryFieldDef(fs) {
344
- const def = this.exprDef.queryFieldDef(fs, this.name);
345
- this.defType = this.fieldTypeFromFieldDef(def);
346
- return def;
347
- }
348
- type() {
349
- if (this.defType) {
350
- return this.defType;
351
- }
352
- return this.fieldTypeFromFieldDef(this.fieldDef());
353
- }
354
- }
355
- exports.ExpressionFieldFromAst = ExpressionFieldFromAst;
356
127
  //# sourceMappingURL=space-field.js.map
@@ -22,9 +22,7 @@
22
22
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
23
  */
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
- const space_field_1 = require("../space-field");
26
- const field_space_1 = require("../field-space");
27
- const ast_1 = require("../ast");
25
+ const ast_main_1 = require("../ast/ast-main");
28
26
  /*
29
27
  ** A set of tests to make sure structdefs can become fieldspaces
30
28
  ** and the fieldspace produces the same strcutdef
@@ -41,7 +39,7 @@ describe("structdef comprehension", () => {
41
39
  };
42
40
  }
43
41
  function fieldRef(fieldPath) {
44
- return fieldPath.split(".").map((name) => new ast_1.FieldName(name));
42
+ return fieldPath.split(".").map((name) => new ast_main_1.FieldName(name));
45
43
  }
46
44
  test(`import string field`, () => {
47
45
  const field = {
@@ -49,8 +47,8 @@ describe("structdef comprehension", () => {
49
47
  type: "string",
50
48
  };
51
49
  const struct = mkStructDef(field);
52
- const space = new field_space_1.StaticSpace(struct);
53
- expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
50
+ const space = new ast_main_1.StaticSpace(struct);
51
+ expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField);
54
52
  const oField = space.structDef().fields[0];
55
53
  expect(oField).toEqual(field);
56
54
  });
@@ -61,8 +59,8 @@ describe("structdef comprehension", () => {
61
59
  numberType: "float",
62
60
  };
63
61
  const struct = mkStructDef(field);
64
- const space = new field_space_1.StaticSpace(struct);
65
- expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
62
+ const space = new ast_main_1.StaticSpace(struct);
63
+ expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField);
66
64
  const oField = space.structDef().fields[0];
67
65
  expect(oField).toEqual(field);
68
66
  });
@@ -73,8 +71,8 @@ describe("structdef comprehension", () => {
73
71
  numberType: "integer",
74
72
  };
75
73
  const struct = mkStructDef(field);
76
- const space = new field_space_1.StaticSpace(struct);
77
- expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
74
+ const space = new ast_main_1.StaticSpace(struct);
75
+ expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField);
78
76
  const oField = space.structDef().fields[0];
79
77
  expect(oField).toEqual(field);
80
78
  });
@@ -84,8 +82,8 @@ describe("structdef comprehension", () => {
84
82
  type: "boolean",
85
83
  };
86
84
  const struct = mkStructDef(field);
87
- const space = new field_space_1.StaticSpace(struct);
88
- expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
85
+ const space = new ast_main_1.StaticSpace(struct);
86
+ expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField);
89
87
  const oField = space.structDef().fields[0];
90
88
  expect(oField).toEqual(field);
91
89
  });
@@ -99,8 +97,8 @@ describe("structdef comprehension", () => {
99
97
  fields: [{ type: "string", name: "b" }],
100
98
  };
101
99
  const struct = mkStructDef(field);
102
- const space = new field_space_1.StaticSpace(struct);
103
- expect(space.lookup(fieldRef("t.b")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
100
+ const space = new ast_main_1.StaticSpace(struct);
101
+ expect(space.lookup(fieldRef("t.b")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField);
104
102
  const oField = space.structDef().fields[0];
105
103
  expect(oField).toEqual(field);
106
104
  });
@@ -114,8 +112,8 @@ describe("structdef comprehension", () => {
114
112
  fields: [{ type: "string", name: "a" }],
115
113
  };
116
114
  const struct = mkStructDef(field);
117
- const space = new field_space_1.StaticSpace(struct);
118
- expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
115
+ const space = new ast_main_1.StaticSpace(struct);
116
+ expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField);
119
117
  const oField = space.structDef().fields[0];
120
118
  expect(oField).toEqual(field);
121
119
  });
@@ -136,8 +134,8 @@ describe("structdef comprehension", () => {
136
134
  fields: [{ type: "string", name: "a" }],
137
135
  };
138
136
  const struct = mkStructDef(field);
139
- const space = new field_space_1.StaticSpace(struct);
140
- expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(space_field_1.ColumnSpaceField);
137
+ const space = new ast_main_1.StaticSpace(struct);
138
+ expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField);
141
139
  const oField = space.structDef().fields[0];
142
140
  expect(oField).toEqual(field);
143
141
  });
@@ -153,8 +151,8 @@ describe("structdef comprehension", () => {
153
151
  ],
154
152
  };
155
153
  const struct = mkStructDef(field);
156
- const space = new field_space_1.StaticSpace(struct);
157
- expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.QueryFieldStruct);
154
+ const space = new ast_main_1.StaticSpace(struct);
155
+ expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.QueryFieldStruct);
158
156
  const oField = space.structDef().fields[0];
159
157
  expect(oField).toEqual(field);
160
158
  });
@@ -174,9 +172,9 @@ describe("structdef comprehension", () => {
174
172
  constant: false,
175
173
  },
176
174
  };
177
- const space = new field_space_1.StaticSpace(struct);
178
- expect(space.lookup(fieldRef("cReqStr")).found).toBeInstanceOf(space_field_1.DefinedParameter);
179
- expect(space.lookup(fieldRef("cOptStr")).found).toBeInstanceOf(space_field_1.DefinedParameter);
175
+ const space = new ast_main_1.StaticSpace(struct);
176
+ expect(space.lookup(fieldRef("cReqStr")).found).toBeInstanceOf(ast_main_1.DefinedParameter);
177
+ expect(space.lookup(fieldRef("cOptStr")).found).toBeInstanceOf(ast_main_1.DefinedParameter);
180
178
  });
181
179
  });
182
180
  //# sourceMappingURL=field-symbols.spec.js.map
@@ -25,8 +25,7 @@
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  const model_1 = require("../../model");
27
27
  const sql_block_1 = require("../../model/sql_block");
28
- const ast_1 = require("../ast");
29
- const field_space_1 = require("../field-space");
28
+ const ast_main_1 = require("../ast/ast-main");
30
29
  const test_translator_1 = require("./test-translator");
31
30
  const lodash_1 = require("lodash");
32
31
  const util_1 = require("util");
@@ -298,10 +297,10 @@ class BetaExpression extends Testable {
298
297
  }
299
298
  compile() {
300
299
  const exprAst = this.ast();
301
- if (exprAst instanceof ast_1.ExpressionDef) {
300
+ if (exprAst instanceof ast_main_1.ExpressionDef) {
302
301
  const aStruct = this.internalModel.contents.ab;
303
302
  if (aStruct.type === "struct") {
304
- const tstFS = new field_space_1.StaticSpace(aStruct);
303
+ const tstFS = new ast_main_1.StaticSpace(aStruct);
305
304
  const exprDef = exprAst.getExpression(tstFS);
306
305
  if (inspectCompile) {
307
306
  console.log("EXPRESSION: ", (0, test_translator_1.pretty)(exprDef));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@malloydata/malloy",
3
- "version": "0.0.22-dev230119001546",
3
+ "version": "0.0.22-dev230119193053",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,159 +0,0 @@
1
- import { Dialect } from "../dialect";
2
- import * as model from "../model/malloy_types";
3
- import { ExploreField, FieldListEdit, FieldDeclaration, WildcardFieldReference, Join, FieldName, HasParameter, FieldCollectionMember, QueryItem, MalloyElement, FieldReference } from "./ast";
4
- import { SpaceField, SpaceEntry } from "./space-field";
5
- interface LookupFound {
6
- found: SpaceEntry;
7
- error: undefined;
8
- }
9
- interface LookupError {
10
- error: string;
11
- found: undefined;
12
- }
13
- export declare type LookupResult = LookupFound | LookupError;
14
- /**
15
- * A FieldSpace is a hierarchy of namespaces, where the leaf nodes
16
- * are fields. A FieldSpace can lookup fields, and generate a StructDef
17
- */
18
- export interface FieldSpace {
19
- type: "fieldSpace";
20
- structDef(): model.StructDef;
21
- emptyStructDef(): model.StructDef;
22
- lookup(symbol: FieldName[]): LookupResult;
23
- dialectObj(): Dialect | undefined;
24
- whenComplete: (step: () => void) => void;
25
- }
26
- /**
27
- * The father of all FieldSpaces is a wrapper for a StructDef.
28
- */
29
- export declare class StaticSpace implements FieldSpace {
30
- readonly type = "fieldSpace";
31
- private memoMap?;
32
- protected fromStruct: model.StructDef;
33
- constructor(sourceStructDef: model.StructDef);
34
- whenComplete(step: () => void): void;
35
- dialectObj(): Dialect | undefined;
36
- fromFieldDef(from: model.FieldDef): SpaceField;
37
- private get map();
38
- protected dropEntries(): void;
39
- protected dropEntry(name: string): void;
40
- protected entry(name: string): SpaceEntry | undefined;
41
- protected setEntry(name: string, value: SpaceEntry): void;
42
- protected entries(): [string, SpaceEntry][];
43
- structDef(): model.StructDef;
44
- emptyStructDef(): model.StructDef;
45
- lookup(path: FieldName[]): LookupResult;
46
- }
47
- export declare type SourceSpec = model.StructDef | FieldSpace;
48
- /**
49
- * Based on how things are constructed, the starting field space
50
- * can either be another field space or an existing structdef.
51
- * Using a SpaceSeed allows a class to accept either one
52
- * and use either version at some future time.
53
- */
54
- declare class SpaceSeed {
55
- readonly sourceSpec: SourceSpec;
56
- private spaceSpec;
57
- private asFS?;
58
- private asStruct?;
59
- constructor(sourceSpec: SourceSpec);
60
- get structDef(): model.StructDef;
61
- get fieldSpace(): FieldSpace;
62
- }
63
- /**
64
- * A FieldSpace which may undergo modification
65
- */
66
- export declare class DynamicSpace extends StaticSpace {
67
- protected final: model.StructDef | undefined;
68
- protected source: SpaceSeed;
69
- outputFS?: QuerySpace;
70
- completions: (() => void)[];
71
- private complete;
72
- constructor(extending: SourceSpec);
73
- /**
74
- * Factory for DynamicSpace when there are accept/except edits
75
- * @param from A structdef which seeds this space
76
- * @param choose A accept/except edit of the "from" fields
77
- */
78
- static filteredFrom(from: model.StructDef, choose?: FieldListEdit): DynamicSpace;
79
- whenComplete(finalizeStep: () => void): void;
80
- isComplete(): void;
81
- protected setEntry(name: string, value: SpaceEntry): void;
82
- addParameters(params: HasParameter[]): DynamicSpace;
83
- newEntry(name: string, astEl: MalloyElement, entry: SpaceEntry): void;
84
- addField(...defs: ExploreField[]): void;
85
- addFieldDef(fd: model.FieldDef): void;
86
- structDef(): model.StructDef;
87
- }
88
- /**
89
- * Unlike a source, which is a refinement of a namespace, a query
90
- * is creating a new unrelated namespace. The query starts with a
91
- * source, which it might modify. This set of fields used to resolve
92
- * expressions in the query is called the "input space". There is a
93
- * specialized QuerySpace for each type of query operation.
94
- *
95
- * The query output is managed by an instance of ResultSpace.
96
- */
97
- export declare class QuerySpace extends DynamicSpace {
98
- readonly result: ResultSpace;
99
- nestParent?: QuerySpace;
100
- extendList: string[];
101
- constructor(input: SourceSpec, result: ResultSpace);
102
- extendSource(extendField: Join | FieldDeclaration): void;
103
- }
104
- export declare abstract class ResultSpace extends DynamicSpace {
105
- readonly queryInputSpace: FieldSpace;
106
- readonly exprSpace: QuerySpace;
107
- astEl?: MalloyElement | undefined;
108
- abstract readonly segmentType: "reduce" | "project" | "index";
109
- constructor(queryInputSpace: FieldSpace);
110
- log(s: string): void;
111
- addMembers(members: FieldCollectionMember[]): void;
112
- addReference(ref: FieldReference): void;
113
- addWild(wild: WildcardFieldReference): void;
114
- /**
115
- * Check for the definition of an ungrouping reference in the result space,
116
- * or in the case of an exclude reference, if this query is nested
117
- * in another query, in the result space of a query that this query
118
- * is nested inside of.
119
- */
120
- checkUngroup(fn: FieldName, isExclude: boolean): void;
121
- addQueryItems(...qiList: QueryItem[]): void;
122
- canContain(_qd: model.QueryFieldDef): boolean;
123
- protected queryFieldDefs(): model.QueryFieldDef[];
124
- getQuerySegment(rf: model.QuerySegment | undefined): model.QuerySegment;
125
- getPipeSegment(refineFrom: model.QuerySegment | undefined): model.PipeSegment;
126
- }
127
- /**
128
- * Reduce and project queries use a "QuerySpace"
129
- */
130
- export declare class ReduceFieldSpace extends ResultSpace {
131
- readonly segmentType = "reduce";
132
- }
133
- export declare class ProjectFieldSpace extends ResultSpace {
134
- readonly segmentType = "project";
135
- canContain(qd: model.QueryFieldDef): boolean;
136
- }
137
- export declare class IndexFieldSpace extends ResultSpace {
138
- readonly segmentType = "index";
139
- fieldList: Set<string>;
140
- addReference(ref: FieldReference): void;
141
- addWild(wild: WildcardFieldReference): void;
142
- getPipeSegment(refineIndex?: model.PipeSegment): model.IndexSegment;
143
- }
144
- /**
145
- * Used to detect references to fields in the statement which defines them
146
- */
147
- export declare class DefSpace implements FieldSpace {
148
- readonly realFS: FieldSpace;
149
- readonly circular: FieldDeclaration;
150
- readonly type = "fieldSpace";
151
- foundCircle: boolean;
152
- constructor(realFS: FieldSpace, circular: FieldDeclaration);
153
- structDef(): model.StructDef;
154
- emptyStructDef(): model.StructDef;
155
- lookup(symbol: FieldName[]): LookupResult;
156
- dialectObj(): Dialect | undefined;
157
- whenComplete(step: () => void): void;
158
- }
159
- export {};