@malloydata/malloy
Advanced tools
Comparing version 0.0.22-dev230119001546 to 0.0.22-dev230119193053
import { By, ExpressionType } from "../../model/malloy_types"; | ||
import { FieldSpace } from "../field-space"; | ||
import { BinaryBoolean, ExpressionDef, ExprCompare, FieldName, FieldReference, Filter, MalloyElement } from "./ast-main"; | ||
import { BinaryBoolean, ExpressionDef, ExprCompare, FieldName, FieldReference, FieldSpace, Filter, MalloyElement } from "./ast-main"; | ||
import { ExprValue, FieldValueType, FragType } from "./ast-types"; | ||
@@ -5,0 +4,0 @@ export declare class ExprString extends ExpressionDef { |
@@ -31,7 +31,5 @@ "use strict"; | ||
const malloy_types_1 = require("../../model/malloy_types"); | ||
const field_space_1 = require("../field-space"); | ||
const ast_main_1 = require("./ast-main"); | ||
const ast_types_1 = require("./ast-types"); | ||
const apply_expr_1 = require("./apply-expr"); | ||
const space_field_1 = require("../space-field"); | ||
const time_utils_1 = require("./time-utils"); | ||
@@ -158,3 +156,3 @@ class ExprString extends ast_main_1.ExpressionDef { | ||
const entry = this.fieldReference.getField(fs).found; | ||
if (entry instanceof space_field_1.SpaceParam) { | ||
if (entry instanceof ast_main_1.SpaceParam) { | ||
const cParam = entry.parameter(); | ||
@@ -311,3 +309,3 @@ if ((0, malloy_types_1.isConditionParameter)(cParam)) { | ||
else { | ||
if (!(sourceFoot instanceof space_field_1.StructSpaceField)) { | ||
if (!(sourceFoot instanceof ast_main_1.StructSpaceField)) { | ||
this.log(`Aggregate source cannot be a ${footType.type}`); | ||
@@ -462,6 +460,6 @@ return (0, ast_types_1.errorFor)(`Aggregate source cannot be a ${footType.type}`); | ||
let qs = fs; | ||
if (fs instanceof field_space_1.DefSpace) { | ||
if (fs instanceof ast_main_1.DefSpace) { | ||
qs = fs.realFS; | ||
} | ||
if (!(qs instanceof field_space_1.QuerySpace)) { | ||
if (!(qs instanceof ast_main_1.QuerySpace)) { | ||
this.log(`${this.control}() must be in a query -- weird internal error`); | ||
@@ -468,0 +466,0 @@ return (0, ast_types_1.errorFor)("ungroup query check"); |
import * as model from "../../model/malloy_types"; | ||
import { Dialect } from "../../dialect/dialect"; | ||
import { AtomicFieldType, ExpressionType, FieldTypeDef, Fragment, TimeFieldType, TimestampUnit } from "../../model/malloy_types"; | ||
import { FieldSpace, QuerySpace, LookupResult } from "../field-space"; | ||
import { MalloyTranslation, ModelDataRequest } from "../parse-malloy"; | ||
import { Comparison, ExprValue } from "./ast-types"; | ||
import { Comparison, ExprValue, FieldValueType } from "./ast-types"; | ||
export declare class ErrorFactory { | ||
@@ -661,2 +661,256 @@ static get structDef(): model.StructDef; | ||
} | ||
/** | ||
* A FieldSpace is a hierarchy of namespaces, where the leaf nodes | ||
* are fields. A FieldSpace can lookup fields, and generate a StructDef | ||
*/ | ||
export interface FieldSpace { | ||
type: "fieldSpace"; | ||
structDef(): model.StructDef; | ||
emptyStructDef(): model.StructDef; | ||
lookup(symbol: FieldName[]): LookupResult; | ||
dialectObj(): Dialect | undefined; | ||
whenComplete: (step: () => void) => void; | ||
} | ||
/** | ||
* Used to detect references to fields in the statement which defines them | ||
*/ | ||
export declare class DefSpace implements FieldSpace { | ||
readonly realFS: FieldSpace; | ||
readonly circular: FieldDeclaration; | ||
readonly type = "fieldSpace"; | ||
foundCircle: boolean; | ||
constructor(realFS: FieldSpace, circular: FieldDeclaration); | ||
structDef(): model.StructDef; | ||
emptyStructDef(): model.StructDef; | ||
lookup(symbol: FieldName[]): LookupResult; | ||
dialectObj(): Dialect | undefined; | ||
whenComplete(step: () => void): void; | ||
} | ||
export declare class StaticSpace implements FieldSpace { | ||
readonly type = "fieldSpace"; | ||
private memoMap?; | ||
protected fromStruct: model.StructDef; | ||
constructor(sourceStructDef: model.StructDef); | ||
whenComplete(step: () => void): void; | ||
dialectObj(): Dialect | undefined; | ||
fromFieldDef(from: model.FieldDef): SpaceField; | ||
private get map(); | ||
protected dropEntries(): void; | ||
protected dropEntry(name: string): void; | ||
protected entry(name: string): SpaceEntry | undefined; | ||
protected setEntry(name: string, value: SpaceEntry): void; | ||
protected entries(): [string, SpaceEntry][]; | ||
structDef(): model.StructDef; | ||
emptyStructDef(): model.StructDef; | ||
lookup(path: FieldName[]): LookupResult; | ||
} | ||
/** | ||
* A FieldSpace which may undergo modification | ||
*/ | ||
export declare class DynamicSpace extends StaticSpace { | ||
protected final: model.StructDef | undefined; | ||
protected source: SpaceSeed; | ||
outputFS?: QuerySpace; | ||
completions: (() => void)[]; | ||
private complete; | ||
constructor(extending: SourceSpec); | ||
/** | ||
* Factory for DynamicSpace when there are accept/except edits | ||
* @param from A structdef which seeds this space | ||
* @param choose A accept/except edit of the "from" fields | ||
*/ | ||
static filteredFrom(from: model.StructDef, choose?: FieldListEdit): DynamicSpace; | ||
whenComplete(finalizeStep: () => void): void; | ||
isComplete(): void; | ||
protected setEntry(name: string, value: SpaceEntry): void; | ||
addParameters(params: HasParameter[]): DynamicSpace; | ||
newEntry(name: string, astEl: MalloyElement, entry: SpaceEntry): void; | ||
addField(...defs: ExploreField[]): void; | ||
addFieldDef(fd: model.FieldDef): void; | ||
structDef(): model.StructDef; | ||
} | ||
export declare abstract class ResultSpace extends DynamicSpace { | ||
readonly queryInputSpace: FieldSpace; | ||
readonly exprSpace: QuerySpace; | ||
astEl?: MalloyElement | undefined; | ||
abstract readonly segmentType: "reduce" | "project" | "index"; | ||
constructor(queryInputSpace: FieldSpace); | ||
log(s: string): void; | ||
addMembers(members: FieldCollectionMember[]): void; | ||
addReference(ref: FieldReference): void; | ||
addWild(wild: WildcardFieldReference): void; | ||
/** | ||
* Check for the definition of an ungrouping reference in the result space, | ||
* or in the case of an exclude reference, if this query is nested | ||
* in another query, in the result space of a query that this query | ||
* is nested inside of. | ||
*/ | ||
checkUngroup(fn: FieldName, isExclude: boolean): void; | ||
addQueryItems(...qiList: QueryItem[]): void; | ||
canContain(_qd: model.QueryFieldDef): boolean; | ||
protected queryFieldDefs(): model.QueryFieldDef[]; | ||
getQuerySegment(rf: model.QuerySegment | undefined): model.QuerySegment; | ||
getPipeSegment(refineFrom: model.QuerySegment | undefined): model.PipeSegment; | ||
} | ||
/** | ||
* Reduce and project queries use a "QuerySpace" | ||
*/ | ||
export declare class ReduceFieldSpace extends ResultSpace { | ||
readonly segmentType = "reduce"; | ||
} | ||
export declare class ProjectFieldSpace extends ResultSpace { | ||
readonly segmentType = "project"; | ||
canContain(qd: model.QueryFieldDef): boolean; | ||
} | ||
export declare abstract class SpaceEntry { | ||
abstract type(): FieldType; | ||
abstract refType: "field" | "parameter"; | ||
} | ||
export declare abstract class SpaceField extends SpaceEntry { | ||
readonly refType = "field"; | ||
protected fieldTypeFromFieldDef(def: model.FieldDef): FieldType; | ||
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined; | ||
fieldDef(): model.FieldDef | undefined; | ||
} | ||
export interface FieldType { | ||
type: FieldValueType; | ||
expressionType?: model.ExpressionType; | ||
} | ||
export declare class StructSpaceField extends SpaceField { | ||
protected sourceDef: model.StructDef; | ||
protected space?: FieldSpace; | ||
constructor(sourceDef: model.StructDef); | ||
get fieldSpace(): FieldSpace; | ||
fieldDef(): model.FieldDef; | ||
type(): FieldType; | ||
} | ||
export declare abstract class QueryField extends SpaceField { | ||
protected inSpace: FieldSpace; | ||
constructor(inSpace: FieldSpace); | ||
abstract getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined; | ||
abstract fieldDef(): model.FieldDef; | ||
type(): FieldType; | ||
} | ||
export declare class QueryFieldStruct extends QueryField { | ||
protected turtleDef: model.TurtleDef; | ||
constructor(fs: FieldSpace, turtleDef: model.TurtleDef); | ||
rename(name: string): void; | ||
fieldDef(): model.TurtleDef; | ||
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined; | ||
} | ||
export declare class ColumnSpaceField extends SpaceField { | ||
protected def: model.FieldTypeDef; | ||
constructor(def: model.FieldTypeDef); | ||
fieldDef(): model.FieldDef; | ||
type(): FieldType; | ||
} | ||
export declare abstract class SpaceParam extends SpaceEntry { | ||
abstract parameter(): model.Parameter; | ||
readonly refType = "parameter"; | ||
} | ||
export declare class DefinedParameter extends SpaceParam { | ||
readonly paramDef: model.Parameter; | ||
constructor(paramDef: model.Parameter); | ||
parameter(): model.Parameter; | ||
type(): FieldType; | ||
} | ||
/** | ||
* Based on how things are constructed, the starting field space | ||
* can either be another field space or an existing structdef. | ||
* Using a SpaceSeed allows a class to accept either one | ||
* and use either version at some future time. | ||
*/ | ||
export declare class SpaceSeed { | ||
readonly sourceSpec: SourceSpec; | ||
private spaceSpec; | ||
private asFS?; | ||
private asStruct?; | ||
constructor(sourceSpec: SourceSpec); | ||
get structDef(): model.StructDef; | ||
get fieldSpace(): FieldSpace; | ||
} | ||
export declare type SourceSpec = model.StructDef | FieldSpace; | ||
export declare class AbstractParameter extends SpaceParam { | ||
readonly astParam: HasParameter; | ||
constructor(astParam: HasParameter); | ||
parameter(): model.Parameter; | ||
type(): FieldType; | ||
} | ||
export declare class ExpressionFieldFromAst extends SpaceField { | ||
readonly space: DynamicSpace; | ||
readonly exprDef: FieldDeclaration; | ||
fieldName: string; | ||
defType?: FieldType; | ||
constructor(space: DynamicSpace, exprDef: FieldDeclaration); | ||
get name(): string; | ||
fieldDef(): model.FieldDef; | ||
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef; | ||
type(): FieldType; | ||
} | ||
export declare class QueryFieldAST extends QueryField { | ||
readonly turtle: TurtleDecl; | ||
protected name: string; | ||
renameAs?: string; | ||
nestParent?: QuerySpace; | ||
constructor(fs: FieldSpace, turtle: TurtleDecl, name: string); | ||
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef; | ||
fieldDef(): model.TurtleDef; | ||
} | ||
export declare class RenameSpaceField extends SpaceField { | ||
private readonly otherField; | ||
private readonly newName; | ||
private readonly location; | ||
constructor(otherField: SpaceField, newName: string, location: model.DocumentLocation); | ||
fieldDef(): model.FieldDef | undefined; | ||
type(): FieldType; | ||
} | ||
export declare class JoinSpaceField extends StructSpaceField { | ||
readonly intoFS: FieldSpace; | ||
readonly join: Join; | ||
constructor(intoFS: FieldSpace, join: Join); | ||
} | ||
/** | ||
* Unlike a source, which is a refinement of a namespace, a query | ||
* is creating a new unrelated namespace. The query starts with a | ||
* source, which it might modify. This set of fields used to resolve | ||
* expressions in the query is called the "input space". There is a | ||
* specialized QuerySpace for each type of query operation. | ||
* | ||
* The query output is managed by an instance of ResultSpace. | ||
*/ | ||
export declare class QuerySpace extends DynamicSpace { | ||
readonly result: ResultSpace; | ||
nestParent?: QuerySpace; | ||
extendList: string[]; | ||
constructor(input: SourceSpec, result: ResultSpace); | ||
extendSource(extendField: Join | FieldDeclaration): void; | ||
} | ||
export declare class ReferenceField extends SpaceField { | ||
readonly fieldRef: FieldReference; | ||
constructor(fieldRef: FieldReference); | ||
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined; | ||
type(): FieldType; | ||
} | ||
export declare class WildSpaceField extends SpaceField { | ||
readonly wildText: string; | ||
constructor(wildText: string); | ||
type(): FieldType; | ||
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef; | ||
} | ||
interface LookupFound { | ||
found: SpaceEntry; | ||
error: undefined; | ||
} | ||
interface LookupError { | ||
error: string; | ||
found: undefined; | ||
} | ||
export declare type LookupResult = LookupFound | LookupError; | ||
export declare class IndexFieldSpace extends ResultSpace { | ||
readonly segmentType = "index"; | ||
fieldList: Set<string>; | ||
addReference(ref: FieldReference): void; | ||
addWild(wild: WildcardFieldReference): void; | ||
getPipeSegment(refineIndex?: model.PipeSegment): model.IndexSegment; | ||
} | ||
export {}; |
import { TimestampUnit, ExtractUnit, TimeFieldType } from "../../model/malloy_types"; | ||
import { FieldSpace } from "../field-space"; | ||
import { Comparison, ExprValue } from "./ast-types"; | ||
import { ExpressionDef, MalloyElement } from "./ast-main"; | ||
import { ExpressionDef, FieldSpace, MalloyElement } from "./ast-main"; | ||
export declare class Timeframe extends MalloyElement { | ||
@@ -6,0 +5,0 @@ elementType: string; |
import * as model from "../model/malloy_types"; | ||
import { FieldSpace, DynamicSpace, QuerySpace } from "./field-space"; | ||
import { FieldValueType, FieldDeclaration, TurtleDecl, HasParameter, Join, FieldReference } from "./ast"; | ||
interface FieldType { | ||
type: FieldValueType; | ||
expressionType?: model.ExpressionType; | ||
} | ||
export declare abstract class SpaceEntry { | ||
abstract type(): FieldType; | ||
abstract refType: "field" | "parameter"; | ||
} | ||
export declare abstract class SpaceParam extends SpaceEntry { | ||
abstract parameter(): model.Parameter; | ||
readonly refType = "parameter"; | ||
} | ||
export declare class DefinedParameter extends SpaceParam { | ||
readonly paramDef: model.Parameter; | ||
constructor(paramDef: model.Parameter); | ||
parameter(): model.Parameter; | ||
type(): FieldType; | ||
} | ||
export declare class AbstractParameter extends SpaceParam { | ||
readonly astParam: HasParameter; | ||
constructor(astParam: HasParameter); | ||
parameter(): model.Parameter; | ||
type(): FieldType; | ||
} | ||
export declare abstract class SpaceField extends SpaceEntry { | ||
readonly refType = "field"; | ||
protected fieldTypeFromFieldDef(def: model.FieldDef): FieldType; | ||
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined; | ||
fieldDef(): model.FieldDef | undefined; | ||
} | ||
export declare class RenameSpaceField extends SpaceField { | ||
private readonly otherField; | ||
private readonly newName; | ||
private readonly location; | ||
constructor(otherField: SpaceField, newName: string, location: model.DocumentLocation); | ||
fieldDef(): model.FieldDef | undefined; | ||
type(): FieldType; | ||
} | ||
export declare class WildSpaceField extends SpaceField { | ||
readonly wildText: string; | ||
constructor(wildText: string); | ||
type(): FieldType; | ||
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef; | ||
} | ||
export declare class StructSpaceField extends SpaceField { | ||
protected sourceDef: model.StructDef; | ||
protected space?: FieldSpace; | ||
constructor(sourceDef: model.StructDef); | ||
get fieldSpace(): FieldSpace; | ||
fieldDef(): model.FieldDef; | ||
type(): FieldType; | ||
} | ||
export declare class JoinSpaceField extends StructSpaceField { | ||
readonly intoFS: FieldSpace; | ||
readonly join: Join; | ||
constructor(intoFS: FieldSpace, join: Join); | ||
} | ||
export declare class ColumnSpaceField extends SpaceField { | ||
protected def: model.FieldTypeDef; | ||
constructor(def: model.FieldTypeDef); | ||
fieldDef(): model.FieldDef; | ||
type(): FieldType; | ||
} | ||
export declare abstract class QueryField extends SpaceField { | ||
protected inSpace: FieldSpace; | ||
constructor(inSpace: FieldSpace); | ||
abstract getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined; | ||
abstract fieldDef(): model.FieldDef; | ||
type(): FieldType; | ||
} | ||
export declare class QueryFieldAST extends QueryField { | ||
readonly turtle: TurtleDecl; | ||
protected name: string; | ||
renameAs?: string; | ||
nestParent?: QuerySpace; | ||
constructor(fs: FieldSpace, turtle: TurtleDecl, name: string); | ||
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef; | ||
fieldDef(): model.TurtleDef; | ||
} | ||
export declare class QueryFieldStruct extends QueryField { | ||
protected turtleDef: model.TurtleDef; | ||
constructor(fs: FieldSpace, turtleDef: model.TurtleDef); | ||
rename(name: string): void; | ||
fieldDef(): model.TurtleDef; | ||
getQueryFieldDef(_fs: FieldSpace): model.QueryFieldDef | undefined; | ||
} | ||
import { FieldReference, FieldSpace, FieldType, SpaceField } from "./ast/ast-main"; | ||
/** | ||
@@ -105,19 +18,1 @@ * FilteredAliasedName | ||
} | ||
export declare class ReferenceField extends SpaceField { | ||
readonly fieldRef: FieldReference; | ||
constructor(fieldRef: FieldReference); | ||
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef | undefined; | ||
type(): FieldType; | ||
} | ||
export declare class ExpressionFieldFromAst extends SpaceField { | ||
readonly space: DynamicSpace; | ||
readonly exprDef: FieldDeclaration; | ||
fieldName: string; | ||
defType?: FieldType; | ||
constructor(space: DynamicSpace, exprDef: FieldDeclaration); | ||
get name(): string; | ||
fieldDef(): model.FieldDef; | ||
getQueryFieldDef(fs: FieldSpace): model.QueryFieldDef; | ||
type(): FieldType; | ||
} | ||
export {}; |
@@ -48,193 +48,10 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
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; | ||
exports.FANSPaceField = void 0; | ||
const model = __importStar(require("../model/malloy_types")); | ||
const field_space_1 = require("./field-space"); | ||
class SpaceEntry { | ||
} | ||
exports.SpaceEntry = SpaceEntry; | ||
class SpaceParam extends SpaceEntry { | ||
constructor() { | ||
super(...arguments); | ||
this.refType = "parameter"; | ||
} | ||
} | ||
exports.SpaceParam = SpaceParam; | ||
class DefinedParameter extends SpaceParam { | ||
constructor(paramDef) { | ||
super(); | ||
this.paramDef = paramDef; | ||
} | ||
parameter() { | ||
return this.paramDef; | ||
} | ||
type() { | ||
return { type: this.paramDef.type }; | ||
} | ||
} | ||
exports.DefinedParameter = DefinedParameter; | ||
class AbstractParameter extends SpaceParam { | ||
constructor(astParam) { | ||
super(); | ||
this.astParam = astParam; | ||
} | ||
parameter() { | ||
return this.astParam.parameter(); | ||
} | ||
type() { | ||
const type = this.astParam.type || "unknown"; | ||
return { type }; | ||
} | ||
} | ||
exports.AbstractParameter = AbstractParameter; | ||
class SpaceField extends SpaceEntry { | ||
constructor() { | ||
super(...arguments); | ||
this.refType = "field"; | ||
} | ||
fieldTypeFromFieldDef(def) { | ||
const ref = { type: def.type }; | ||
if (model.isFieldTypeDef(def) && def.expressionType) { | ||
ref.expressionType = def.expressionType; | ||
} | ||
return ref; | ||
} | ||
getQueryFieldDef(_fs) { | ||
return undefined; | ||
} | ||
fieldDef() { | ||
return undefined; | ||
} | ||
} | ||
exports.SpaceField = SpaceField; | ||
class RenameSpaceField extends SpaceField { | ||
constructor(otherField, newName, location) { | ||
super(); | ||
this.otherField = otherField; | ||
this.newName = newName; | ||
this.location = location; | ||
} | ||
fieldDef() { | ||
const renamedFieldRaw = this.otherField.fieldDef(); | ||
if (renamedFieldRaw === undefined) { | ||
return undefined; | ||
} | ||
return { | ||
...renamedFieldRaw, | ||
as: this.newName, | ||
location: this.location, | ||
}; | ||
} | ||
type() { | ||
return this.otherField.type(); | ||
} | ||
} | ||
exports.RenameSpaceField = RenameSpaceField; | ||
class WildSpaceField extends SpaceField { | ||
constructor(wildText) { | ||
super(); | ||
this.wildText = wildText; | ||
} | ||
type() { | ||
throw new Error("should never ask a wild field for its type"); | ||
} | ||
getQueryFieldDef(_fs) { | ||
return this.wildText; | ||
} | ||
} | ||
exports.WildSpaceField = WildSpaceField; | ||
class StructSpaceField extends SpaceField { | ||
constructor(sourceDef) { | ||
super(); | ||
this.sourceDef = sourceDef; | ||
} | ||
get fieldSpace() { | ||
if (!this.space) { | ||
this.space = new field_space_1.StaticSpace(this.sourceDef); | ||
} | ||
return this.space; | ||
} | ||
fieldDef() { | ||
return this.sourceDef; | ||
} | ||
type() { | ||
return { type: "struct" }; | ||
} | ||
} | ||
exports.StructSpaceField = StructSpaceField; | ||
class JoinSpaceField extends StructSpaceField { | ||
constructor(intoFS, join) { | ||
super(join.structDef()); | ||
this.intoFS = intoFS; | ||
this.join = join; | ||
} | ||
} | ||
exports.JoinSpaceField = JoinSpaceField; | ||
class ColumnSpaceField extends SpaceField { | ||
constructor(def) { | ||
super(); | ||
this.def = def; | ||
} | ||
fieldDef() { | ||
return this.def; | ||
} | ||
type() { | ||
return this.fieldTypeFromFieldDef(this.def); | ||
} | ||
} | ||
exports.ColumnSpaceField = ColumnSpaceField; | ||
class QueryField extends SpaceField { | ||
constructor(inSpace) { | ||
super(); | ||
this.inSpace = inSpace; | ||
} | ||
type() { | ||
return { type: "turtle" }; | ||
} | ||
} | ||
exports.QueryField = QueryField; | ||
class QueryFieldAST extends QueryField { | ||
constructor(fs, turtle, name) { | ||
super(fs); | ||
this.turtle = turtle; | ||
this.name = name; | ||
} | ||
getQueryFieldDef(fs) { | ||
const def = this.turtle.getFieldDef(fs, this.nestParent); | ||
if (this.renameAs) { | ||
def.as = this.renameAs; | ||
} | ||
return def; | ||
} | ||
fieldDef() { | ||
const def = this.turtle.getFieldDef(this.inSpace, this.nestParent); | ||
if (this.renameAs) { | ||
def.as = this.renameAs; | ||
} | ||
return def; | ||
} | ||
} | ||
exports.QueryFieldAST = QueryFieldAST; | ||
class QueryFieldStruct extends QueryField { | ||
constructor(fs, turtleDef) { | ||
super(fs); | ||
this.turtleDef = turtleDef; | ||
} | ||
rename(name) { | ||
this.turtleDef = { | ||
...this.turtleDef, | ||
as: name, | ||
}; | ||
} | ||
fieldDef() { | ||
return this.turtleDef; | ||
} | ||
getQueryFieldDef(_fs) { | ||
return this.fieldDef(); | ||
} | ||
} | ||
exports.QueryFieldStruct = QueryFieldStruct; | ||
const ast_main_1 = require("./ast/ast-main"); | ||
// "Space Fields" are a field in a field space | ||
/** | ||
* FilteredAliasedName | ||
*/ | ||
class FANSPaceField extends SpaceField { | ||
class FANSPaceField extends ast_main_1.SpaceField { | ||
constructor(ref, inSpace, refInit) { | ||
@@ -265,3 +82,3 @@ super(); | ||
if (model.isAtomicFieldType(fieldType)) { | ||
if (fromField instanceof SpaceParam) { | ||
if (fromField instanceof ast_main_1.SpaceParam) { | ||
return { | ||
@@ -312,48 +129,2 @@ type: fieldType, | ||
exports.FANSPaceField = FANSPaceField; | ||
class ReferenceField extends SpaceField { | ||
constructor(fieldRef) { | ||
super(); | ||
this.fieldRef = fieldRef; | ||
} | ||
getQueryFieldDef(fs) { | ||
// Lookup string and generate error if it isn't defined. | ||
const check = this.fieldRef.getField(fs); | ||
if (check.error) { | ||
this.fieldRef.log(check.error); | ||
} | ||
return this.fieldRef.refString; | ||
} | ||
type() { | ||
return { type: "unknown" }; | ||
} | ||
} | ||
exports.ReferenceField = ReferenceField; | ||
class ExpressionFieldFromAst extends SpaceField { | ||
constructor(space, exprDef) { | ||
super(); | ||
this.space = space; | ||
this.exprDef = exprDef; | ||
this.fieldName = exprDef.defineName; | ||
} | ||
get name() { | ||
return this.fieldName; | ||
} | ||
fieldDef() { | ||
const def = this.exprDef.fieldDef(this.space, this.name); | ||
this.defType = this.fieldTypeFromFieldDef(def); | ||
return def; | ||
} | ||
getQueryFieldDef(fs) { | ||
const def = this.exprDef.queryFieldDef(fs, this.name); | ||
this.defType = this.fieldTypeFromFieldDef(def); | ||
return def; | ||
} | ||
type() { | ||
if (this.defType) { | ||
return this.defType; | ||
} | ||
return this.fieldTypeFromFieldDef(this.fieldDef()); | ||
} | ||
} | ||
exports.ExpressionFieldFromAst = ExpressionFieldFromAst; | ||
//# sourceMappingURL=space-field.js.map |
@@ -25,5 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const space_field_1 = require("../space-field"); | ||
const field_space_1 = require("../field-space"); | ||
const ast_1 = require("../ast"); | ||
const ast_main_1 = require("../ast/ast-main"); | ||
/* | ||
@@ -45,3 +43,3 @@ ** A set of tests to make sure structdefs can become fieldspaces | ||
function fieldRef(fieldPath) { | ||
return fieldPath.split(".").map((name) => new ast_1.FieldName(name)); | ||
return fieldPath.split(".").map((name) => new ast_main_1.FieldName(name)); | ||
} | ||
@@ -54,4 +52,4 @@ test(`import string field`, () => { | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField); | ||
const oField = space.structDef().fields[0]; | ||
@@ -67,4 +65,4 @@ expect(oField).toEqual(field); | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField); | ||
const oField = space.structDef().fields[0]; | ||
@@ -80,4 +78,4 @@ expect(oField).toEqual(field); | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField); | ||
const oField = space.structDef().fields[0]; | ||
@@ -92,4 +90,4 @@ expect(oField).toEqual(field); | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.ColumnSpaceField); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField); | ||
const oField = space.structDef().fields[0]; | ||
@@ -108,4 +106,4 @@ expect(oField).toEqual(field); | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t.b")).found).toBeInstanceOf(space_field_1.ColumnSpaceField); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t.b")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField); | ||
const oField = space.structDef().fields[0]; | ||
@@ -124,4 +122,4 @@ expect(oField).toEqual(field); | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(space_field_1.ColumnSpaceField); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField); | ||
const oField = space.structDef().fields[0]; | ||
@@ -147,4 +145,4 @@ expect(oField).toEqual(field); | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(space_field_1.ColumnSpaceField); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t.a")).found).toBeInstanceOf(ast_main_1.ColumnSpaceField); | ||
const oField = space.structDef().fields[0]; | ||
@@ -165,4 +163,4 @@ expect(oField).toEqual(field); | ||
const struct = mkStructDef(field); | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(space_field_1.QueryFieldStruct); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("t")).found).toBeInstanceOf(ast_main_1.QueryFieldStruct); | ||
const oField = space.structDef().fields[0]; | ||
@@ -187,7 +185,7 @@ expect(oField).toEqual(field); | ||
}; | ||
const space = new field_space_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("cReqStr")).found).toBeInstanceOf(space_field_1.DefinedParameter); | ||
expect(space.lookup(fieldRef("cOptStr")).found).toBeInstanceOf(space_field_1.DefinedParameter); | ||
const space = new ast_main_1.StaticSpace(struct); | ||
expect(space.lookup(fieldRef("cReqStr")).found).toBeInstanceOf(ast_main_1.DefinedParameter); | ||
expect(space.lookup(fieldRef("cOptStr")).found).toBeInstanceOf(ast_main_1.DefinedParameter); | ||
}); | ||
}); | ||
//# sourceMappingURL=field-symbols.spec.js.map |
{ | ||
"name": "@malloydata/malloy", | ||
"version": "0.0.22-dev230119001546", | ||
"version": "0.0.22-dev230119193053", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1619760
94
41801