diff --git a/packages/core/src/edge/common.ts b/packages/core/src/edge/common.ts index 22c2cfb..87623b6 100644 --- a/packages/core/src/edge/common.ts +++ b/packages/core/src/edge/common.ts @@ -5,7 +5,7 @@ export type GenericRawProjection = ObjectOrValue< Ref | string | boolean | 0 | 1 | T >; export type GenericProjection = { - [name: string]: Ref | string | false | T; + [name: string]: Ref | false | T; }; export function capitalize(s: string) { diff --git a/packages/core/src/edge/edge-builder.ts b/packages/core/src/edge/edge-builder.ts index 1fc2d52..8c69023 100644 --- a/packages/core/src/edge/edge-builder.ts +++ b/packages/core/src/edge/edge-builder.ts @@ -16,7 +16,11 @@ import { import { DirectiveBuilder } from '../directive'; import { Ref } from '../ref'; import { Runnable } from '../types'; -import { FieldBuilder, BuildFieldArgs } from '../field'; +import { + FieldBuilder, + CustomFieldBuilder, + BuildFieldArgs, +} from '../field'; import { AggregationBuilder } from '../aggregation'; type OpBuilders = OperatorBuilder | LogicalOperatorBuilder; @@ -24,7 +28,7 @@ export type RawProjection = GenericRawProjection< EdgeBuilder | FieldBuilder | AggregationBuilder >; export type Projection = GenericProjection< - EdgeBuilder | FieldBuilder | AggregationBuilder + EdgeBuilder | FieldBuilder | CustomFieldBuilder | AggregationBuilder >; export interface NameGenerators { @@ -83,6 +87,9 @@ export class EdgeBuilder extends FieldBuilder { if (existing) return r; v = new FieldBuilder(undefined); } + if (typeof v === 'string') + v = new CustomFieldBuilder(v); + if ( typeof v !== 'object' || v instanceof Ref @@ -100,7 +107,6 @@ export class EdgeBuilder extends FieldBuilder { if ( !existing - || typeof existing === 'string' || existing instanceof Ref || existing instanceof AggregationBuilder ) { diff --git a/packages/core/src/field/custom-field-builder.ts b/packages/core/src/field/custom-field-builder.ts new file mode 100644 index 0000000..ee62c7c --- /dev/null +++ b/packages/core/src/field/custom-field-builder.ts @@ -0,0 +1,4 @@ +import { FieldBuilder } from './field-builder'; + +export class CustomFieldBuilder extends FieldBuilder { +} diff --git a/packages/core/src/field/index.ts b/packages/core/src/field/index.ts index 7b8c6d7..1680382 100644 --- a/packages/core/src/field/index.ts +++ b/packages/core/src/field/index.ts @@ -1,2 +1,3 @@ export * from './field-builder'; export * from './field'; +export * from './custom-field-builder';