@query-graph/core 1.1.4 → 1.1.5

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/dsl.d.ts CHANGED
@@ -1,1840 +1,183 @@
1
- export type ScalarType =
2
- | 'boolean'
3
- | 'int32'
4
- | 'int64'
5
- | 'float64'
6
- | 'decimal'
7
- | 'string'
8
- | 'date'
9
- | 'dateTime'
10
- | 'binary'
11
- | 'json'
12
-
13
- export type JsonValue = null | boolean | number | string | readonly JsonValue[] | { readonly [key: string]: JsonValue }
14
-
15
- export type ScalarParameterValue<Type extends ScalarType> = Type extends 'boolean'
16
- ? boolean
17
- : Type extends 'int32' | 'float64'
18
- ? number
19
- : Type extends 'int64' | 'decimal'
20
- ? number | string
21
- : Type extends 'string' | 'date' | 'dateTime' | 'binary'
22
- ? string
23
- : Type extends 'json'
24
- ? JsonValue
25
- : never
26
-
27
- export type ParameterShape = 'scalar' | 'list'
28
- export type RelationCardinality = 'one' | 'many'
29
- export type OrderDirection = 'asc' | 'desc'
30
- export type NullsOrder = 'first' | 'last'
31
- export type SemanticFunctionName = 'lower' | 'upper' | 'coalesce' | 'concat'
32
- export type AggregateFunctionName = 'count' | 'countDistinct' | 'sum' | 'average' | 'minimum' | 'maximum'
33
- export type ProjectionFieldRole = 'value' | 'dimension' | 'measure'
34
-
35
- type BooleanOr<Value extends boolean> = true extends Value ? true : false
36
-
37
- export interface SourceFieldNullability<Source extends string = string, FieldNullable extends boolean = boolean> {
38
- kind: 'sourceField'
39
- source: Source
40
- fieldNullable: FieldNullable
41
- }
42
-
43
- export interface AnyNullability<Values = unknown> {
44
- kind: 'any'
45
- values: Values
46
- }
47
-
48
- export interface AllNullability<Values = unknown> {
49
- kind: 'all'
50
- values: Values
51
- }
52
-
53
- export type NullabilityExpression = boolean | SourceFieldNullability | AnyNullability | AllNullability
54
-
55
- declare const expressionTypeMetadata: unique symbol
56
-
57
- export interface ExpressionTypeMetadata<
58
- Type extends ScalarType | null = ScalarType,
59
- Nullability extends NullabilityExpression = NullabilityExpression,
60
- > {
61
- readonly [expressionTypeMetadata]: {
62
- scalarType: Type
63
- nullability: Nullability
64
- }
65
- }
66
-
67
- export type TypedExpression<
68
- Definition extends Expression = Expression,
69
- Type extends ScalarType | null = ScalarType,
70
- Nullability extends NullabilityExpression = NullabilityExpression,
71
- > = Definition & ExpressionTypeMetadata<Type, Nullability>
72
-
73
- export interface FieldDefinition {
74
- name: string
75
- scalarType: ScalarType
76
- nullable?: boolean
77
- selectable?: boolean
78
- }
79
-
80
- export interface SourceDefinition {
81
- key: string
82
- fields: FieldDefinition[]
83
- }
84
-
85
- export interface ParameterDefinition {
86
- name: string
87
- scalarType: ScalarType
88
- shape?: ParameterShape
89
- required?: boolean
90
- }
91
-
92
- export interface FieldExpression<Source extends string = string, Field extends string = string> {
93
- kind: 'field'
94
- source: Source
95
- field: Field
96
- }
97
-
98
- export interface ParameterExpression<Name extends string = string> {
99
- kind: 'parameter'
100
- name: Name
101
- }
102
-
103
- export type LiteralValue =
104
- | { kind: 'null' }
105
- | { kind: 'boolean'; value: boolean }
106
- | { kind: 'integer'; value: number }
107
- | { kind: 'decimal'; value: string }
108
- | { kind: 'string'; value: string }
109
-
110
- export interface LiteralExpression {
111
- kind: 'literal'
112
- value: LiteralValue
113
- }
114
-
115
- export type BinaryExpressionKind =
116
- | 'eq'
117
- | 'notEq'
118
- | 'lessThan'
119
- | 'lessThanOrEqual'
120
- | 'greaterThan'
121
- | 'greaterThanOrEqual'
122
-
123
- export interface BinaryExpression {
124
- kind: BinaryExpressionKind
125
- left: Expression
126
- right: Expression
127
- }
128
-
129
- export interface LikeExpression {
130
- kind: 'like'
131
- expression: Expression
132
- pattern: Expression
133
- }
134
-
135
- export interface InExpression {
136
- kind: 'in'
137
- expression: Expression
138
- values: Expression[]
139
- }
140
-
141
- export interface InParameterExpression<Name extends string = string> {
142
- kind: 'inParameter'
143
- expression: Expression
144
- parameter: Name
145
- }
146
-
147
- export interface ExpressionGroup {
148
- kind: 'and' | 'or'
149
- expressions: Expression[]
150
- }
151
-
152
- export interface UnaryExpression {
153
- kind: 'not' | 'isNull' | 'isNotNull'
154
- expression: Expression
155
- }
156
-
157
- export interface ExistsExpression<Source extends string = string, From extends string = string> {
158
- kind: 'exists'
159
- source: Source
160
- from?: From
161
- predicate?: Expression
162
- }
163
-
164
- export interface FunctionExpression {
165
- kind: 'function'
166
- name: SemanticFunctionName
167
- arguments: Expression[]
168
- }
169
-
170
- export interface AggregateExpression {
171
- kind: 'aggregate'
172
- function: AggregateFunctionName
173
- expression?: Expression
174
- }
175
-
176
- export type Expression =
177
- | FieldExpression
178
- | ParameterExpression
179
- | LiteralExpression
180
- | BinaryExpression
181
- | LikeExpression
182
- | InExpression
183
- | InParameterExpression
184
- | ExpressionGroup
185
- | UnaryExpression
186
- | ExistsExpression
187
- | FunctionExpression
188
- | AggregateExpression
189
-
190
- export interface RelationDefinition<
191
- Name extends string = string,
192
- From extends string = string,
193
- To extends string = string,
194
- Required extends boolean = boolean,
195
- Cardinality extends RelationCardinality = RelationCardinality,
196
- > {
197
- name: Name
198
- from: From
199
- to: To
200
- cardinality?: Cardinality
201
- required?: Required
202
- selection?: RelationSelection
203
- on: Expression
204
- }
205
-
206
- export type ConstraintCondition = { kind: 'always' } | { kind: 'parameterPresent'; parameter: string }
207
-
208
- export interface ConstraintDefinition {
209
- when?: ConstraintCondition
210
- predicate: Expression
211
- }
212
-
213
- export type JoinProjectionPath<Segments extends readonly string[]> = number extends Segments['length']
214
- ? string
215
- : Segments extends readonly []
216
- ? ''
217
- : Segments extends readonly [infer Only extends string]
218
- ? Only
219
- : Segments extends readonly [infer Head extends string, ...infer Tail extends readonly string[]]
220
- ? `${Head}.${JoinProjectionPath<Tail>}`
221
- : string
222
-
223
- declare const projectionPathType: unique symbol
224
- declare const projectionScalarType: unique symbol
225
- declare const projectionNullabilityType: unique symbol
226
- declare const projectionDefaultType: unique symbol
227
- declare const projectionObjectPathType: unique symbol
228
- declare const projectionObjectNullabilityType: unique symbol
229
- declare const summaryFieldType: unique symbol
230
- declare const typedProjectionPathType: unique symbol
231
- declare const typedProjectionScalarType: unique symbol
232
- declare const typedProjectionNullabilityType: unique symbol
233
- declare const typedProjectionDefaultType: unique symbol
234
- declare const typedProjectionObjectPathType: unique symbol
235
- declare const typedProjectionObjectNullabilityType: unique symbol
236
-
237
- export interface ProjectionTypeMetadata<
238
- Path extends string = string,
239
- Type extends ScalarType = ScalarType,
240
- Nullability extends NullabilityExpression = NullabilityExpression,
241
- SelectedByDefault extends boolean = boolean,
242
- > {
243
- readonly [typedProjectionPathType]: Path
244
- readonly [typedProjectionScalarType]: Type
245
- readonly [typedProjectionNullabilityType]: Nullability
246
- readonly [typedProjectionDefaultType]: SelectedByDefault
247
- }
248
-
249
- export interface ProjectionObjectTypeMetadata<
250
- Path extends string = string,
251
- Nullability extends NullabilityExpression = NullabilityExpression,
252
- > {
253
- readonly [typedProjectionObjectPathType]: Path
254
- readonly [typedProjectionObjectNullabilityType]: Nullability
255
- }
256
-
257
- export type TypedProjectionObject<
258
- Path extends string = string,
259
- Nullability extends NullabilityExpression = NullabilityExpression,
260
- > = ProjectionObjectDefinition<Path, Nullability> & ProjectionObjectTypeMetadata<Path, Nullability>
261
-
262
- export type TypedProjectionField<
263
- Path extends string = string,
264
- Type extends ScalarType = ScalarType,
265
- Nullability extends NullabilityExpression = NullabilityExpression,
266
- SelectedByDefault extends boolean = boolean,
267
- > = ProjectionFieldDefinition<Path, Type, Nullability, SelectedByDefault> &
268
- ProjectionTypeMetadata<Path, Type, Nullability, SelectedByDefault>
269
-
270
- export type TypedDimensionDefinition<
271
- Path extends string = string,
272
- Type extends ScalarType = ScalarType,
273
- Nullability extends NullabilityExpression = NullabilityExpression,
274
- SelectedByDefault extends boolean = boolean,
275
- > = DimensionDefinition<Path, Type, Nullability, SelectedByDefault> &
276
- ProjectionTypeMetadata<Path, Type, Nullability, SelectedByDefault>
277
-
278
- export type TypedMeasureDefinition<
279
- Path extends string = string,
280
- Type extends ScalarType = ScalarType,
281
- Nullability extends NullabilityExpression = NullabilityExpression,
282
- SelectedByDefault extends boolean = boolean,
283
- > = MeasureDefinition<Path, Type, Nullability, SelectedByDefault> &
284
- ProjectionTypeMetadata<Path, Type, Nullability, SelectedByDefault>
285
-
286
- export interface ProjectionFieldDefinition<
287
- Path extends string = string,
288
- Type extends ScalarType = ScalarType,
289
- Nullability extends NullabilityExpression = NullabilityExpression,
290
- SelectedByDefault extends boolean = boolean,
291
- > {
292
- path: string[]
293
- readonly [projectionPathType]?: Path
294
- readonly [projectionScalarType]?: Type
295
- readonly [projectionNullabilityType]?: Nullability
296
- readonly [projectionDefaultType]?: SelectedByDefault
297
- expression: Expression
298
- role?: ProjectionFieldRole
299
- selectedByDefault?: boolean
300
- }
301
-
302
- export interface ProjectionObjectDefinition<
303
- Path extends string = string,
304
- Nullability extends NullabilityExpression = NullabilityExpression,
305
- > {
306
- path: string[]
307
- readonly [projectionObjectPathType]?: Path
308
- readonly [projectionObjectNullabilityType]?: Nullability
309
- presence: Expression
310
- }
311
-
312
- export interface DimensionDefinition<
313
- Path extends string = string,
314
- Type extends ScalarType = ScalarType,
315
- Nullability extends NullabilityExpression = NullabilityExpression,
316
- SelectedByDefault extends boolean = boolean,
317
- > extends ProjectionFieldDefinition<Path, Type, Nullability, SelectedByDefault> {
318
- readonly [summaryFieldType]: 'dimension'
319
- role: 'dimension'
320
- }
321
-
322
- export interface MeasureDefinition<
323
- Path extends string = string,
324
- Type extends ScalarType = ScalarType,
325
- Nullability extends NullabilityExpression = NullabilityExpression,
326
- SelectedByDefault extends boolean = boolean,
327
- > extends ProjectionFieldDefinition<Path, Type, Nullability, SelectedByDefault> {
328
- readonly [summaryFieldType]: 'measure'
329
- role: 'measure'
330
- }
331
-
332
- export type SummaryFieldDefinition<
333
- Path extends string = string,
334
- Type extends ScalarType = ScalarType,
335
- Nullability extends NullabilityExpression = NullabilityExpression,
336
- SelectedByDefault extends boolean = boolean,
337
- > =
338
- | DimensionDefinition<Path, Type, Nullability, SelectedByDefault>
339
- | MeasureDefinition<Path, Type, Nullability, SelectedByDefault>
340
-
341
- export interface ProjectionDefinition<
342
- Path extends string = string,
343
- Field extends ProjectionFieldDefinition = ProjectionFieldDefinition<Path>,
344
- Object extends ProjectionObjectDefinition = ProjectionObjectDefinition,
345
- > {
346
- fields: Field[]
347
- objects: Object[]
348
- }
349
-
350
- export interface ProjectionDefinitionInput<
351
- Path extends string = string,
352
- Field extends ProjectionFieldDefinition = ProjectionFieldDefinition<Path>,
353
- Object extends ProjectionObjectDefinition = ProjectionObjectDefinition,
354
- > {
355
- fields?: Field[]
356
- objects?: Object[]
357
- }
358
-
359
- export interface OrderByDefinition {
360
- expression: Expression
361
- direction: OrderDirection
362
- nulls?: NullsOrder
363
- }
364
-
365
- export interface OrderingDefinition<Name extends string = string> {
366
- name: Name
367
- orderBy: OrderByDefinition[]
368
- default?: boolean
369
- }
370
-
371
- export interface FirstBySelection {
372
- kind: 'firstBy'
373
- orderBy: OrderByDefinition[]
374
- }
375
-
376
- export type RelationSelection = FirstBySelection
377
-
378
- export interface GraphDefinitionInput {
379
- schemaVersion: 10
380
- name: string
381
- root: string
382
- sources: SourceDefinition[]
383
- parameters?: ParameterDefinition[]
384
- relations?: RelationDefinition[]
385
- constraints?: ConstraintDefinition[]
386
- projection?: ProjectionDefinitionInput
387
- orderings?: OrderingDefinition[]
388
- }
389
-
390
- export interface GraphDefinition<
391
- Parameter extends ParameterDefinition = ParameterDefinition,
392
- ProjectionPath extends string = string,
393
- OrderingName extends string = string,
394
- ProjectionField extends ProjectionFieldDefinition = ProjectionFieldDefinition<ProjectionPath>,
395
- Relation extends RelationDefinition = RelationDefinition,
396
- Root extends string = string,
397
- ProjectionObject extends ProjectionObjectDefinition = ProjectionObjectDefinition,
398
- > extends GraphDefinitionInput {
399
- root: Root
400
- parameters: Parameter[]
401
- relations: Relation[]
402
- constraints: ConstraintDefinition[]
403
- projection: ProjectionDefinition<ProjectionPath, ProjectionField, ProjectionObject>
404
- orderings: OrderingDefinition<OrderingName>[]
405
- }
406
-
407
- export type ExactGraphDefinitionInput<Definition extends GraphDefinitionInput> = Definition &
408
- Record<Exclude<keyof Definition, keyof GraphDefinitionInput>, never>
409
-
410
- export type TableName =
411
- | string
412
- | {
413
- catalog?: string
414
- schema?: string
415
- name: string
416
- }
417
-
418
- export interface SourceMapping {
419
- table: TableName
420
- columns?: Record<string, string>
421
- }
422
-
423
- export interface RelationalMapping {
424
- sources: Record<string, SourceMapping>
425
- }
426
-
427
- export interface QueryOperationBase<SelectPath extends string = string, OrderingName extends string = string> {
428
- select?: readonly SelectPath[]
429
- ordering?: OrderingName
430
- offset?: number
431
- limit?: number
432
- }
433
-
434
- export type DefinitionParameter<Definition extends GraphDefinitionInput> =
435
- Definition extends GraphDefinition<
436
- infer Parameter,
437
- infer _ProjectionPath,
438
- infer _OrderingName,
439
- infer _ProjectionField,
440
- infer _Relation,
441
- infer _Root
442
- >
443
- ? Parameter
444
- : NonNullable<Definition['parameters']>[number]
445
-
446
- export type DefinitionProjectionPath<Definition extends GraphDefinitionInput> =
447
- Definition extends GraphDefinition<
448
- infer _Parameter,
449
- infer ProjectionPath,
450
- infer _OrderingName,
451
- infer _ProjectionField,
452
- infer _Relation,
453
- infer _Root
454
- >
455
- ? ProjectionPath
456
- : Definition['projection'] extends ProjectionDefinitionInput<infer ProjectionPath>
457
- ? ProjectionPath
458
- : string
459
-
460
- export type DefinitionOrderingName<Definition extends GraphDefinitionInput> =
461
- Definition extends GraphDefinition<
462
- infer _Parameter,
463
- infer _ProjectionPath,
464
- infer OrderingName,
465
- infer _ProjectionField,
466
- infer _Relation,
467
- infer _Root
468
- >
469
- ? OrderingName
470
- : NonNullable<Definition['orderings']>[number] extends OrderingDefinition<infer OrderingName>
471
- ? OrderingName
472
- : never
473
-
474
- export type DefinitionProjectionField<Definition extends GraphDefinitionInput> = NonNullable<
475
- NonNullable<Definition['projection']>['fields']
476
- >[number]
477
- export type DefinitionProjectionObject<Definition extends GraphDefinitionInput> = NonNullable<
478
- NonNullable<Definition['projection']>['objects']
479
- >[number]
480
-
481
- export type DefinitionRelation<Definition extends GraphDefinitionInput> = NonNullable<Definition['relations']>[number]
482
-
483
- export type DefinitionRoot<Definition extends GraphDefinitionInput> = Definition['root']
484
-
485
- export type ParameterValue<Parameter extends ParameterDefinition> = Parameter extends { shape: 'list' }
486
- ? readonly ScalarParameterValue<Parameter['scalarType']>[]
487
- : ScalarParameterValue<Parameter['scalarType']>
488
-
489
- type RequiredParameter<Parameter extends ParameterDefinition> = Parameter extends unknown
490
- ? Parameter extends { required?: true }
491
- ? Parameter
492
- : never
493
- : never
494
-
495
- type OptionalParameter<Parameter extends ParameterDefinition> = Parameter extends unknown
496
- ? Parameter extends { required?: true }
497
- ? never
498
- : Parameter
499
- : never
500
-
501
- export type OperationParameters<Definition extends GraphDefinitionInput> = {
502
- [Parameter in RequiredParameter<DefinitionParameter<Definition>> as Parameter['name']]-?: ParameterValue<Parameter>
503
- } & {
504
- [Parameter in OptionalParameter<DefinitionParameter<Definition>> as Parameter['name']]?: ParameterValue<Parameter>
505
- }
506
-
507
- type OperationParameterInput<Definition extends GraphDefinitionInput> = [DefinitionParameter<Definition>] extends [
508
- never,
509
- ]
510
- ? { parameters?: never }
511
- : [RequiredParameter<DefinitionParameter<Definition>>] extends [never]
512
- ? { parameters?: OperationParameters<Definition> }
513
- : { parameters: OperationParameters<Definition> }
514
-
515
- export type QueryOperation<Definition extends GraphDefinitionInput = GraphDefinitionInput> = QueryOperationBase<
516
- DefinitionProjectionPath<Definition>,
517
- DefinitionOrderingName<Definition>
518
- > &
519
- OperationParameterInput<Definition>
520
-
521
- declare const graphDefinitionType: unique symbol
522
-
523
- export interface QueryGraph<Definition extends GraphDefinitionInput = GraphDefinitionInput> {
524
- readonly [graphDefinitionType]?: Definition
525
- readonly name: string
526
- readonly root: string
527
- readonly sourceCount: number
528
- readonly relationCount: number
529
- hasSource(source: string): boolean
530
- hasField(source: string, field: string): boolean
531
- hasParameter(parameter: string): boolean
532
- hasRelation(relation: string): boolean
533
- selectableFields(): Array<DefinitionProjectionPath<Definition>>
534
- withRelationalMapping(mapping: RelationalMapping): RelationalQueryGraph<Definition>
535
- withRelationalMappings(mappings: readonly RelationalMapping[]): RelationalQueryGraph<Definition>
536
- }
537
-
538
- export interface RelationalQueryGraph<Definition extends GraphDefinitionInput = GraphDefinitionInput> {
539
- readonly [graphDefinitionType]?: Definition
540
- readonly name: string
541
- compileSqlServer(
542
- operation: QueryOperation<Definition>,
543
- options?: SqlServerCompileOptions,
544
- ): import('./index.js').CompiledSqlStatement
545
- compileOracle(
546
- operation: QueryOperation<Definition>,
547
- options?: OracleCompileOptions,
548
- ): import('./index.js').CompiledSqlStatement
549
- }
550
-
551
- export type BatchCardinality = RelationCardinality
552
-
553
- export interface BatchRelationWire {
554
- name: string
555
- from: string
556
- to: string
557
- parameter: string
558
- cardinality: BatchCardinality
559
- parameters?: Record<string, unknown>
560
- ordering?: string
561
- }
562
-
563
- type ListDefinitionParameter<Definition extends GraphDefinitionInput> =
564
- DefinitionParameter<Definition> extends infer Parameter extends ParameterDefinition
565
- ? Parameter extends { shape: 'list' }
566
- ? Parameter
567
- : never
568
- : never
569
-
570
- type ListParameterReference<Definition extends GraphDefinitionInput> =
571
- | ListDefinitionParameter<Definition>
572
- | ListDefinitionParameter<Definition>['name']
573
-
574
- type ParameterReferenceName<Reference> = Reference extends { name: infer Name extends string }
575
- ? Name
576
- : Reference extends string
577
- ? Reference
578
- : never
579
-
580
- type ResolveListParameter<Definition extends GraphDefinitionInput, Reference> = Extract<
581
- ListDefinitionParameter<Definition>,
582
- { name: ParameterReferenceName<Reference> }
583
- >
584
-
585
- type BatchStaticParameterCandidate<
586
- Parameter extends ParameterDefinition,
587
- KeyName extends string,
588
- > = Parameter extends ParameterDefinition ? (Parameter['name'] extends KeyName ? never : Parameter) : never
589
-
590
- type BatchStaticParameter<
591
- Definition extends GraphDefinitionInput,
592
- KeyName extends string,
593
- > = BatchStaticParameterCandidate<DefinitionParameter<Definition>, KeyName>
594
-
595
- type BatchStaticParameters<Definition extends GraphDefinitionInput, KeyName extends string> = {
596
- [Parameter in RequiredParameter<
597
- BatchStaticParameter<Definition, KeyName>
598
- > as Parameter['name']]-?: ParameterValue<Parameter>
599
- } & {
600
- [Parameter in OptionalParameter<
601
- BatchStaticParameter<Definition, KeyName>
602
- > as Parameter['name']]?: ParameterValue<Parameter>
603
- }
604
-
605
- type BatchStaticParameterInput<Definition extends GraphDefinitionInput, KeyName extends string> = [
606
- BatchStaticParameter<Definition, KeyName>,
607
- ] extends [never]
608
- ? { parameters?: never }
609
- : [RequiredParameter<BatchStaticParameter<Definition, KeyName>>] extends [never]
610
- ? { parameters?: BatchStaticParameters<Definition, KeyName> }
611
- : { parameters: BatchStaticParameters<Definition, KeyName> }
612
-
613
- declare const batchQueryType: unique symbol
614
-
615
- export interface BatchQuery<
616
- Child extends RelationalQueryGraph = RelationalQueryGraph,
617
- KeyPath extends string = string,
618
- KeyParameter extends ParameterDefinition & { shape: 'list' } = ListParameterRef,
619
- > {
620
- readonly graph: Child
621
- readonly key: {
622
- readonly path: KeyPath
623
- readonly parameter: KeyParameter['name']
624
- }
625
- readonly [batchQueryType]?: KeyParameter
626
- }
627
-
628
- export type BatchQueryConfiguration<
629
- Child extends RelationalQueryGraph,
630
- KeyPath extends DefinitionProjectionPath<DefinitionOf<Child>>,
631
- ParameterReference extends ListParameterReference<DefinitionOf<Child>>,
632
- > = {
633
- graph: Child
634
- key: {
635
- path: KeyPath
636
- parameter: ParameterReference
637
- }
638
- }
639
-
640
- type CompatibleBatchQueryConfiguration<
641
- Child extends RelationalQueryGraph,
642
- KeyPath extends DefinitionProjectionPath<DefinitionOf<Child>>,
643
- KeyParameter extends ParameterDefinition & { shape: 'list' },
644
- > =
645
- EqualScalarType<ProjectionScalarTypeAtPath<DefinitionOf<Child>, KeyPath>, KeyParameter['scalarType']> extends true
646
- ? unknown
647
- : never
648
-
649
- export function batchQuery<
650
- const Child extends RelationalQueryGraph,
651
- const KeyPath extends DefinitionProjectionPath<DefinitionOf<Child>>,
652
- const ParameterReference extends ListParameterReference<DefinitionOf<Child>>,
653
- >(
654
- configuration: BatchQueryConfiguration<Child, KeyPath, ParameterReference> &
655
- CompatibleBatchQueryConfiguration<
656
- Child,
657
- KeyPath,
658
- ResolveListParameter<DefinitionOf<Child>, NoInfer<ParameterReference>>
659
- >,
660
- ): BatchQuery<Child, KeyPath, ResolveListParameter<DefinitionOf<Child>, ParameterReference>>
661
-
662
- type BatchQueryGraph<Query extends BatchQuery> =
663
- Query extends BatchQuery<infer Child, infer _KeyPath, infer _KeyParameter> ? Child : never
664
-
665
- type BatchQueryKeyPath<Query extends BatchQuery> =
666
- Query extends BatchQuery<infer _Child, infer KeyPath, infer _KeyParameter> ? KeyPath : never
667
-
668
- type BatchQueryKeyParameter<Query extends BatchQuery> =
669
- Query extends BatchQuery<infer _Child, infer _KeyPath, infer KeyParameter> ? KeyParameter : never
670
-
671
- declare const batchRelationType: unique symbol
672
-
673
- export interface BatchRelation<
674
- Name extends string = string,
675
- Query extends BatchQuery = BatchQuery,
676
- From extends string = string,
677
- Cardinality extends BatchCardinality = BatchCardinality,
678
- > {
679
- readonly name: Name
680
- readonly from: From
681
- readonly query: Query
682
- readonly cardinality: Cardinality
683
- readonly parameters: BatchStaticParameters<
684
- DefinitionOf<BatchQueryGraph<Query>>,
685
- BatchQueryKeyParameter<Query>['name']
686
- >
687
- readonly ordering?: DefinitionOrderingName<DefinitionOf<BatchQueryGraph<Query>>>
688
- readonly [batchRelationType]?: Query
689
- }
690
-
691
- export type BatchRelationConfiguration<
692
- Name extends string,
693
- Query extends BatchQuery,
694
- From extends string,
695
- Cardinality extends BatchCardinality,
696
- > = {
697
- name: Name
698
- from: From
699
- query: Query
700
- cardinality: Cardinality
701
- ordering?: DefinitionOrderingName<DefinitionOf<BatchQueryGraph<Query>>>
702
- } & BatchStaticParameterInput<DefinitionOf<BatchQueryGraph<Query>>, BatchQueryKeyParameter<Query>['name']>
703
-
704
- export function batchRelation<
705
- const Name extends string,
706
- const Query extends BatchQuery,
707
- const From extends string,
708
- const Cardinality extends BatchCardinality,
709
- >(
710
- configuration: BatchRelationConfiguration<Name, Query, From, Cardinality>,
711
- ): BatchRelation<Name, Query, From, Cardinality>
712
-
713
- type ProjectionScalarTypeAtPath<Definition extends GraphDefinitionInput, Path extends string> =
714
- ProjectionFieldByPath<DefinitionProjectionField<Definition>, Path> extends infer Field
715
- ? Field extends ProjectionTypeMetadata<infer _Path, infer Type, infer _Nullability, infer _SelectedByDefault>
716
- ? Type
717
- : Field extends ProjectionFieldDefinition<infer _Path, infer Type>
718
- ? Type
719
- : never
720
- : never
721
-
722
- type EqualScalarType<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false
723
-
724
- type CompatibleBatchRelation<Root extends RelationalQueryGraph, Relation extends BatchRelation> =
725
- Relation extends BatchRelation<infer Name, infer Query, infer From, infer _Cardinality>
726
- ? From extends DefinitionProjectionPath<DefinitionOf<Root>>
727
- ? Extract<DefinitionProjectionPath<DefinitionOf<Root>>, Name | `${Name}.${string}`> extends never
728
- ? EqualScalarType<
729
- ProjectionScalarTypeAtPath<DefinitionOf<Root>, From>,
730
- ProjectionScalarTypeAtPath<DefinitionOf<BatchQueryGraph<Query>>, BatchQueryKeyPath<Query>>
731
- > extends true
732
- ? EqualScalarType<
733
- ProjectionScalarTypeAtPath<DefinitionOf<BatchQueryGraph<Query>>, BatchQueryKeyPath<Query>>,
734
- BatchQueryKeyParameter<Query>['scalarType']
735
- > extends true
736
- ? Relation
737
- : never
738
- : never
739
- : never
740
- : never
741
- : never
742
-
743
- type CompatibleBatchRelations<Root extends RelationalQueryGraph, Relations extends readonly BatchRelation[]> = {
744
- readonly [Index in keyof Relations]: Relations[Index] extends BatchRelation
745
- ? CompatibleBatchRelation<Root, Relations[Index]>
746
- : never
747
- }
748
-
749
- type RelationName<Relations extends readonly BatchRelation[]> = Relations[number]['name']
750
- type ChildPathsForRelation<Relation extends BatchRelation> = Relation extends BatchRelation
751
- ? `${Relation['name']}.${DefinitionProjectionPath<DefinitionOf<BatchQueryGraph<Relation['query']>>>}`
752
- : never
753
- type ChildPaths<Relations extends readonly BatchRelation[]> = ChildPathsForRelation<Relations[number]>
754
-
755
- export type ComposedSelection<Root extends RelationalQueryGraph, Relations extends readonly BatchRelation[]> =
756
- | DefinitionProjectionPath<DefinitionOf<Root>>
757
- | ChildPaths<Relations>
758
-
759
- export interface BatchPlanMetadata<Relation extends BatchRelation = BatchRelation> {
760
- name: Relation['name']
761
- parentKey: Relation['from']
762
- childKey: BatchQueryKeyPath<Relation['query']>
763
- keyParameter: BatchQueryKeyParameter<Relation['query']>['name']
764
- parameters: Readonly<Relation['parameters']>
765
- cardinality: Relation['cardinality']
766
- parentKeyInjected: boolean
767
- childKeyInjected: boolean
768
- }
769
-
770
- type BatchRelationNamed<Relation extends BatchRelation, Name extends string> = Relation extends BatchRelation
771
- ? Relation['name'] extends Name
772
- ? Relation
773
- : never
774
- : never
775
-
776
- type BatchRelationByName<Relations extends readonly BatchRelation[], Name extends string> = BatchRelationNamed<
777
- Relations[number],
778
- Name
779
- >
780
-
781
- type BatchKeyValue<Relation extends BatchRelation> = ScalarParameterValue<
782
- BatchQueryKeyParameter<Relation['query']>['scalarType']
783
- >
784
-
785
- export interface CompiledQueryPlan<Relations extends readonly BatchRelation[] = readonly BatchRelation[]> {
786
- readonly root: import('./index.js').CompiledSqlStatement
787
- readonly batches: readonly BatchPlanMetadata<Relations[number]>[]
788
- compileBatch<const Name extends RelationName<Relations>>(
789
- name: Name,
790
- keys: readonly BatchKeyValue<BatchRelationByName<Relations, Name>>[],
791
- ): import('./index.js').CompiledSqlStatement
792
- }
793
-
794
- export type ComposedQueryOperation<
795
- Root extends RelationalQueryGraph,
796
- Relations extends readonly BatchRelation[],
797
- > = QueryOperationBase<ComposedSelection<Root, Relations>, DefinitionOrderingName<DefinitionOf<Root>>> &
798
- OperationParameterInput<DefinitionOf<Root>>
799
-
800
- export interface ComposedQueryGraph<
801
- Root extends RelationalQueryGraph = RelationalQueryGraph,
802
- Relations extends readonly BatchRelation[] = readonly BatchRelation[],
803
- > {
804
- readonly name: string
805
- compileOraclePlan(
806
- operation: ComposedQueryOperation<Root, Relations>,
807
- options?: OracleCompileOptions,
808
- ): CompiledQueryPlan<Relations>
809
- compileSqlServerPlan(
810
- operation: ComposedQueryOperation<Root, Relations>,
811
- options?: SqlServerCompileOptions,
812
- ): CompiledQueryPlan<Relations>
813
- }
814
-
815
- export function composeGraph<
816
- const Root extends RelationalQueryGraph,
817
- const Relations extends readonly BatchRelation[],
818
- >(configuration: {
819
- root: Root
820
- relations: Relations & CompatibleBatchRelations<Root, Relations>
821
- }): ComposedQueryGraph<Root, Relations>
822
-
823
- export interface ScalarOutputTypeMap {
824
- boolean: unknown
825
- int32: unknown
826
- int64: unknown
827
- float64: unknown
828
- decimal: unknown
829
- string: unknown
830
- date: unknown
831
- dateTime: unknown
832
- binary: unknown
833
- json: unknown
834
- }
835
-
836
- export interface DefaultScalarOutputTypeMap extends ScalarOutputTypeMap {
837
- boolean: boolean
838
- int32: number
839
- int64: number | string
840
- float64: number
841
- decimal: number | string
842
- string: string
843
- date: string
844
- dateTime: string
845
- binary: string
846
- json: JsonValue
847
- }
848
-
849
- export type DefinitionOf<Subject extends GraphDefinitionInput | QueryGraph | RelationalQueryGraph> =
850
- Subject extends GraphDefinitionInput
851
- ? Subject
852
- : Subject extends QueryGraph<infer Definition>
853
- ? Definition
854
- : Subject extends RelationalQueryGraph<infer Definition>
855
- ? Definition
856
- : never
857
-
858
- type IncomingRelation<Definition extends GraphDefinitionInput, Source extends string> =
859
- DefinitionRelation<Definition> extends infer Candidate
860
- ? Candidate extends RelationDefinition<infer _Name, infer _From, infer To, infer _Required, infer _Cardinality>
861
- ? Source extends To
862
- ? Candidate
863
- : never
864
- : never
865
- : never
866
-
867
- type RelationPathNullability<
868
- Definition extends GraphDefinitionInput,
869
- Relation,
870
- Visited extends string,
871
- Depth extends readonly unknown[],
872
- > =
873
- Relation extends RelationDefinition<infer _Name, infer From, infer _To, infer Required, infer _Cardinality>
874
- ? BooleanOr<
875
- | (Required extends true ? false : true)
876
- | SourceOuterNullable<Definition, From, Visited, readonly [...Depth, unknown]>
877
- >
878
- : boolean
879
-
880
- type SourceOuterNullable<
881
- Definition extends GraphDefinitionInput,
882
- Source extends string,
883
- Visited extends string = never,
884
- Depth extends readonly unknown[] = readonly [],
885
- > = Depth['length'] extends 12
886
- ? boolean
887
- : string extends Source
888
- ? boolean
889
- : string extends DefinitionRoot<Definition>
890
- ? boolean
891
- : Source extends DefinitionRoot<Definition>
892
- ? false
893
- : Source extends Visited
894
- ? boolean
895
- : [IncomingRelation<Definition, Source>] extends [never]
896
- ? boolean
897
- : BooleanOr<
898
- RelationPathNullability<Definition, IncomingRelation<Definition, Source>, Visited | Source, Depth>
899
- >
900
-
901
- type CombineAllNullability<Left extends boolean, Right extends boolean> = [Left] extends [false]
902
- ? false
903
- : [Right] extends [false]
904
- ? false
905
- : [Left] extends [true]
906
- ? Right
907
- : [Right] extends [true]
908
- ? Left
909
- : boolean
910
-
911
- type EvaluateAnyNullability<
912
- Definition extends GraphDefinitionInput,
913
- Values,
914
- Depth extends readonly unknown[],
915
- > = Values extends readonly []
916
- ? false
917
- : Values extends readonly [
918
- infer First extends NullabilityExpression,
919
- ...infer Rest extends readonly NullabilityExpression[],
920
- ]
921
- ? BooleanOr<
922
- | EvaluateNullability<Definition, First, readonly [...Depth, unknown]>
923
- | EvaluateAnyNullability<Definition, Rest, readonly [...Depth, unknown]>
924
- >
925
- : Values extends readonly (infer Value extends NullabilityExpression)[]
926
- ? BooleanOr<EvaluateNullability<Definition, Value, readonly [...Depth, unknown]>>
927
- : boolean
928
-
929
- type EvaluateAllNullability<
930
- Definition extends GraphDefinitionInput,
931
- Values,
932
- Depth extends readonly unknown[],
933
- > = Values extends readonly []
934
- ? true
935
- : Values extends readonly [
936
- infer First extends NullabilityExpression,
937
- ...infer Rest extends readonly NullabilityExpression[],
938
- ]
939
- ? CombineAllNullability<
940
- EvaluateNullability<Definition, First, readonly [...Depth, unknown]>,
941
- EvaluateAllNullability<Definition, Rest, readonly [...Depth, unknown]>
942
- >
943
- : boolean
944
-
945
- type EvaluateNullability<
946
- Definition extends GraphDefinitionInput,
947
- Formula extends NullabilityExpression,
948
- Depth extends readonly unknown[] = readonly [],
949
- > = Depth['length'] extends 16
950
- ? boolean
951
- : NullabilityExpression extends Formula
952
- ? boolean
953
- : Formula extends boolean
954
- ? Formula
955
- : Formula extends SourceFieldNullability<infer Source, infer FieldNullable>
956
- ? BooleanOr<FieldNullable | SourceOuterNullable<Definition, Source, never, Depth>>
957
- : Formula extends AnyNullability<infer Values>
958
- ? EvaluateAnyNullability<Definition, Values, Depth>
959
- : Formula extends AllNullability<infer Values>
960
- ? EvaluateAllNullability<Definition, Values, Depth>
961
- : boolean
962
-
963
- type ProjectionFieldPath<Field> =
964
- Field extends ProjectionTypeMetadata<infer Path, infer _Type, infer _Nullability, infer _SelectedByDefault>
965
- ? Path
966
- : Field extends ProjectionFieldDefinition<infer Path>
967
- ? Path
968
- : never
969
-
970
- type ProjectionObjectPath<Object> =
971
- Object extends ProjectionObjectTypeMetadata<infer Path, infer _Nullability>
972
- ? Path
973
- : Object extends ProjectionObjectDefinition<infer Path>
974
- ? Path
975
- : never
976
-
977
- type ProjectionObjectNullability<Object> =
978
- Object extends ProjectionObjectTypeMetadata<infer _Path, infer Nullability>
979
- ? Nullability
980
- : Object extends ProjectionObjectDefinition<infer _Path, infer Nullability>
981
- ? Nullability
982
- : boolean
983
-
984
- type ProjectionObjectIsNullable<Definition extends GraphDefinitionInput, Object> =
985
- true extends EvaluateNullability<Definition, ProjectionObjectNullability<Object>> ? true : false
986
-
987
- type ProjectionFieldValue<Definition extends GraphDefinitionInput, Field, TypeMap extends ScalarOutputTypeMap> =
988
- Field extends ProjectionTypeMetadata<infer _Path, infer Type, infer Nullability, infer _SelectedByDefault>
989
- ? true extends EvaluateNullability<Definition, Nullability>
990
- ? TypeMap[Type] | null
991
- : TypeMap[Type]
992
- : Field extends ProjectionFieldDefinition<infer _Path, infer Type, infer Nullability, infer _SelectedByDefault>
993
- ? true extends EvaluateNullability<Definition, Nullability>
994
- ? TypeMap[Type] | null
995
- : TypeMap[Type]
996
- : never
997
-
998
- type ProjectionFieldByPath<Field, Path extends string> = Field extends ProjectionFieldDefinition
999
- ? ProjectionFieldPath<Field> extends Path
1000
- ? Field
1001
- : never
1002
- : never
1003
-
1004
- type ProjectionDefaultAtPath<Field, Path extends string> =
1005
- Field extends ProjectionTypeMetadata<infer FieldPath, infer _Type, infer _Nullability, infer SelectedByDefault>
1006
- ? FieldPath extends Path
1007
- ? SelectedByDefault
1008
- : never
1009
- : Field extends ProjectionFieldDefinition
1010
- ? ProjectionFieldPath<Field> extends Path
1011
- ? Field extends { selectedByDefault: true }
1012
- ? true
1013
- : false
1014
- : never
1015
- : never
1016
-
1017
- type DefaultProjectionPath<Field, Path extends string = ProjectionFieldPath<Field>> = Path extends unknown
1018
- ? [ProjectionDefaultAtPath<Field, Path>] extends [never]
1019
- ? never
1020
- : ProjectionDefaultAtPath<Field, Path> extends true
1021
- ? Path
1022
- : never
1023
- : never
1024
-
1025
- type DefaultProjectionField<Field> = ProjectionFieldByPath<Field, DefaultProjectionPath<Field>>
1026
-
1027
- type SelectedProjectionField<Definition extends GraphDefinitionInput, Operation> = [Operation] extends [undefined]
1028
- ? DefaultProjectionField<DefinitionProjectionField<Definition>>
1029
- : Operation extends { select: readonly (infer Path extends string)[] }
1030
- ? ProjectionFieldByPath<DefinitionProjectionField<Definition>, Path>
1031
- : DefaultProjectionField<DefinitionProjectionField<Definition>>
1032
-
1033
- type ProjectionObjectForField<Object, Field> = Object extends ProjectionObjectDefinition
1034
- ? Field extends ProjectionFieldDefinition
1035
- ? ProjectionFieldPath<Field> extends `${ProjectionObjectPath<Object>}.${string}`
1036
- ? Object
1037
- : never
1038
- : never
1039
- : never
1040
-
1041
- type SelectedProjectionObject<Definition extends GraphDefinitionInput, Field> = ProjectionObjectForField<
1042
- DefinitionProjectionObject<Definition>,
1043
- Field
1044
- >
1045
-
1046
- type ProjectionEntry<
1047
- Definition extends GraphDefinitionInput,
1048
- Field,
1049
- TypeMap extends ScalarOutputTypeMap,
1050
- > = Field extends ProjectionFieldDefinition
1051
- ? {
1052
- path: ProjectionFieldPath<Field>
1053
- value: ProjectionFieldValue<Definition, Field, TypeMap>
1054
- }
1055
- : never
1056
-
1057
- type ProjectionObjectEntry<Definition extends GraphDefinitionInput, Object> = Object extends ProjectionObjectDefinition
1058
- ? {
1059
- path: ProjectionObjectPath<Object>
1060
- nullable: ProjectionObjectIsNullable<Definition, Object>
1061
- }
1062
- : never
1063
-
1064
- type ProjectionEntryHead<Entry> = Entry extends { path: infer Path extends string }
1065
- ? Path extends `${infer Head}.${string}`
1066
- ? Head
1067
- : Path
1068
- : never
1069
-
1070
- type DirectProjectionEntryValue<Entry, Key extends string> = Entry extends {
1071
- path: infer Path extends string
1072
- value: infer Value
1073
- }
1074
- ? Path extends Key
1075
- ? Value
1076
- : never
1077
- : never
1078
-
1079
- type NestedProjectionEntry<Entry, Key extends string> = Entry extends {
1080
- path: infer Path extends string
1081
- value: infer Value
1082
- }
1083
- ? Path extends `${Key}.${infer Rest}`
1084
- ? { path: Rest; value: Value }
1085
- : never
1086
- : never
1087
-
1088
- type DirectProjectionObjectNullable<ObjectEntry, Key extends string> = ObjectEntry extends {
1089
- path: infer Path extends string
1090
- nullable: infer Nullable extends boolean
1091
- }
1092
- ? Path extends Key
1093
- ? Nullable
1094
- : never
1095
- : never
1096
-
1097
- type NestedProjectionObjectEntry<ObjectEntry, Key extends string> = ObjectEntry extends {
1098
- path: infer Path extends string
1099
- nullable: infer Nullable extends boolean
1100
- }
1101
- ? Path extends `${Key}.${infer Rest}`
1102
- ? { path: Rest; nullable: Nullable }
1103
- : never
1104
- : never
1105
-
1106
- type ApplyProjectionObjectNullability<Value, ObjectEntry, Key extends string> =
1107
- true extends DirectProjectionObjectNullable<ObjectEntry, Key> ? Value | null : Value
1108
-
1109
- type ProjectionValueAtKeyWithoutObject<Entry, ObjectEntry, Key extends string> = [
1110
- NestedProjectionEntry<Entry, Key>,
1111
- ] extends [never]
1112
- ? DirectProjectionEntryValue<Entry, Key>
1113
- : [DirectProjectionEntryValue<Entry, Key>] extends [never]
1114
- ? BuildProjectionResult<NestedProjectionEntry<Entry, Key>, NestedProjectionObjectEntry<ObjectEntry, Key>>
1115
- :
1116
- | DirectProjectionEntryValue<Entry, Key>
1117
- | BuildProjectionResult<NestedProjectionEntry<Entry, Key>, NestedProjectionObjectEntry<ObjectEntry, Key>>
1118
-
1119
- type ProjectionValueAtKey<Entry, ObjectEntry, Key extends string> = ApplyProjectionObjectNullability<
1120
- ProjectionValueAtKeyWithoutObject<Entry, ObjectEntry, Key>,
1121
- ObjectEntry,
1122
- Key
1123
- >
1124
-
1125
- type BuildProjectionResult<Entry, ObjectEntry = never> = [Entry] extends [never]
1126
- ? Record<never, never>
1127
- : {
1128
- [Key in ProjectionEntryHead<Entry>]: ProjectionValueAtKey<Entry, ObjectEntry, Key>
1129
- }
1130
-
1131
- export type ResultOf<
1132
- Subject extends GraphDefinitionInput | QueryGraph | RelationalQueryGraph | ComposedQueryGraph,
1133
- Operation = undefined,
1134
- TypeMap extends ScalarOutputTypeMap = DefaultScalarOutputTypeMap,
1135
- > =
1136
- Subject extends ComposedQueryGraph<infer Root, infer Relations>
1137
- ? ComposedResult<Root, Relations, Operation, TypeMap>
1138
- : DefinitionOf<
1139
- Extract<Subject, GraphDefinitionInput | QueryGraph | RelationalQueryGraph>
1140
- > extends infer Definition extends GraphDefinitionInput
1141
- ? SelectedProjectionField<Definition, Operation> extends infer Field
1142
- ? BuildProjectionResult<
1143
- ProjectionEntry<Definition, Field, TypeMap>,
1144
- ProjectionObjectEntry<Definition, SelectedProjectionObject<Definition, Field>>
1145
- >
1146
- : never
1147
- : never
1148
-
1149
- type SelectedPaths<Operation> = Operation extends { select: readonly (infer Path extends string)[] } ? Path : never
1150
-
1151
- type RootOperation<Operation, Relations extends readonly BatchRelation[]> = Operation extends {
1152
- select: readonly string[]
1153
- }
1154
- ? { select: readonly Exclude<SelectedPaths<Operation>, ChildPaths<Relations>>[] }
1155
- : undefined
1156
-
1157
- type SelectedChildPath<Operation, Name extends string> =
1158
- Extract<SelectedPaths<Operation>, `${Name}.${string}`> extends `${Name}.${infer Path}` ? Path : never
1159
-
1160
- type ChildOperation<Operation, Name extends string> = {
1161
- select: readonly SelectedChildPath<Operation, Name>[]
1162
- }
1163
-
1164
- type SelectedRelationCandidate<Relation extends BatchRelation, Operation> = Relation extends BatchRelation
1165
- ? Extract<SelectedPaths<Operation>, `${Relation['name']}.${string}`> extends never
1166
- ? never
1167
- : Relation
1168
- : never
1169
-
1170
- type SelectedRelation<Relations extends readonly BatchRelation[], Operation> = SelectedRelationCandidate<
1171
- Relations[number],
1172
- Operation
1173
- >
1174
-
1175
- type BatchResult<Relation extends BatchRelation, Operation, TypeMap extends ScalarOutputTypeMap> =
1176
- ResultOf<BatchQueryGraph<Relation['query']>, ChildOperation<Operation, Relation['name']>, TypeMap> extends infer Child
1177
- ? Relation['cardinality'] extends 'many'
1178
- ? Child[]
1179
- : Child | null
1180
- : never
1181
-
1182
- type ComposedResult<
1183
- Root extends RelationalQueryGraph,
1184
- Relations extends readonly BatchRelation[],
1185
- Operation,
1186
- TypeMap extends ScalarOutputTypeMap,
1187
- > = ResultOf<Root, RootOperation<Operation, Relations>, TypeMap> & {
1188
- [Relation in SelectedRelation<Relations, Operation> as Relation['name']]: BatchResult<Relation, Operation, TypeMap>
1189
- }
1190
-
1191
- export type SqlServerVersion = '2008' | '2012' | '2016' | '2019' | '2022'
1192
- export type OracleVersion = '11g' | '12c' | '19c' | '21c' | '23ai'
1193
-
1194
- export interface SqlServerCompileOptions {
1195
- version?: SqlServerVersion
1196
- }
1197
-
1198
- export interface OracleCompileOptions {
1199
- version?: OracleVersion
1200
- }
1201
-
1202
- export type QueryGraphErrorPhase = 'definition' | 'mapping' | 'composition' | 'operation' | 'sql'
1203
-
1204
- export interface QueryGraphDiagnostic {
1205
- code: string
1206
- location: string
1207
- message: string
1208
- }
1209
-
1210
- export interface QueryGraphError extends Error {
1211
- readonly name: 'QueryGraphError'
1212
- readonly code: string
1213
- readonly phase: QueryGraphErrorPhase
1214
- readonly issues: readonly QueryGraphDiagnostic[]
1215
- }
1216
-
1217
- export interface FieldSpecDefinition<
1218
- Type extends ScalarType = ScalarType,
1219
- Nullable extends boolean = boolean,
1220
- Selectable extends boolean = boolean,
1221
- > {
1222
- scalarType: Type
1223
- nullable?: Nullable
1224
- selectable?: Selectable
1225
- }
1226
-
1227
- export type FieldSpec = ScalarType | FieldSpecDefinition
1228
- export type FieldSpecMap = Record<string, FieldSpec>
1229
-
1230
- export type FieldSpecScalarType<Specification extends FieldSpec> = Specification extends ScalarType
1231
- ? Specification
1232
- : Specification extends FieldSpecDefinition<infer Type, infer _Nullable, infer _Selectable>
1233
- ? Type
1234
- : never
1235
-
1236
- export type FieldSpecIsNullable<Specification extends FieldSpec> = Specification extends ScalarType
1237
- ? false
1238
- : Specification extends FieldSpecDefinition<infer _Type, infer Nullable, infer _Selectable>
1239
- ? Nullable
1240
- : boolean
1241
-
1242
- export type FieldSpecIsSelectable<Specification extends FieldSpec> = Specification extends ScalarType
1243
- ? true
1244
- : Specification extends FieldSpecDefinition<infer _Type, infer _Nullable, infer Selectable>
1245
- ? Selectable
1246
- : boolean
1247
-
1248
- export interface SourceRef<Key extends string = string, Fields extends FieldSpecMap = FieldSpecMap>
1249
- extends SourceDefinition {
1250
- key: Key
1251
- field<Name extends Extract<keyof Fields, string>>(
1252
- name: Name,
1253
- ): TypedExpression<
1254
- FieldExpression<Key, Name>,
1255
- FieldSpecScalarType<Fields[Name]>,
1256
- SourceFieldNullability<Key, FieldSpecIsNullable<Fields[Name]>>
1257
- >
1258
- }
1259
-
1260
- export interface ScalarParameterRef<
1261
- Name extends string = string,
1262
- Type extends ScalarType = ScalarType,
1263
- Required extends boolean = boolean,
1264
- > extends ParameterDefinition {
1265
- name: Name
1266
- scalarType: Type
1267
- shape?: 'scalar'
1268
- required?: Required
1269
- }
1270
-
1271
- export interface ListParameterRef<
1272
- Name extends string = string,
1273
- Type extends ScalarType = ScalarType,
1274
- Required extends boolean = boolean,
1275
- > extends ParameterDefinition {
1276
- name: Name
1277
- scalarType: Type
1278
- shape: 'list'
1279
- required?: Required
1280
- }
1281
-
1282
- export type ParameterRef<
1283
- Name extends string = string,
1284
- Type extends ScalarType = ScalarType,
1285
- Required extends boolean = boolean,
1286
- > = ScalarParameterRef<Name, Type, Required> | ListParameterRef<Name, Type, Required>
1287
-
1288
- export type RelationRef<
1289
- Name extends string = string,
1290
- From extends string = string,
1291
- To extends string = string,
1292
- Required extends boolean = boolean,
1293
- Cardinality extends RelationCardinality = RelationCardinality,
1294
- > = RelationDefinition<Name, From, To, Required, Cardinality>
1295
-
1296
- export type LiteralInput = null | boolean | string | number
1297
- export type ExpressionInput = Expression | LiteralInput | SummaryFieldDefinition
1298
-
1299
- type NumberLiteralScalarType<Value extends number> = number extends Value
1300
- ? 'int64' | 'decimal'
1301
- : `${Value}` extends `${bigint}`
1302
- ? 'int64'
1303
- : 'decimal'
1304
-
1305
- type InputScalarType<Input extends ExpressionInput> =
1306
- Input extends ExpressionTypeMetadata<infer Type, infer _Nullability>
1307
- ? Type
1308
- : Input extends ProjectionFieldDefinition<infer _Path, infer Type, infer _Nullability, infer _SelectedByDefault>
1309
- ? Type
1310
- : Input extends null
1311
- ? null
1312
- : Input extends boolean
1313
- ? 'boolean'
1314
- : Input extends string
1315
- ? 'string'
1316
- : Input extends number
1317
- ? NumberLiteralScalarType<Input>
1318
- : ScalarType
1319
-
1320
- type InputNullability<Input extends ExpressionInput> =
1321
- Input extends ExpressionTypeMetadata<infer _Type, infer Nullability>
1322
- ? Nullability
1323
- : Input extends ProjectionFieldDefinition<infer _Path, infer _Type, infer Nullability, infer _SelectedByDefault>
1324
- ? Nullability
1325
- : Input extends null
1326
- ? true
1327
- : Input extends Expression
1328
- ? boolean
1329
- : false
1330
-
1331
- export type ExpressionScalarType<Input extends ExpressionInput> = InputScalarType<Input>
1332
- export type ExpressionNullability<Input extends ExpressionInput> = InputNullability<Input>
1333
-
1334
- type PromoteScalarType<Type extends ScalarType | null> = 'float64' extends Type
1335
- ? 'float64'
1336
- : 'decimal' extends Type
1337
- ? 'decimal'
1338
- : 'int64' extends Type
1339
- ? 'int64'
1340
- : 'int32' extends Type
1341
- ? 'int32'
1342
- : 'dateTime' extends Type
1343
- ? 'dateTime'
1344
- : Exclude<Type, null>
1345
-
1346
- type AverageScalarType<Type extends ScalarType | null> = Type extends 'float64'
1347
- ? 'float64'
1348
- : Type extends 'int32' | 'int64' | 'decimal'
1349
- ? 'decimal'
1350
- : Exclude<Type, null>
1351
-
1352
- type InputNullabilities<Inputs extends readonly ExpressionInput[]> = {
1353
- [Index in keyof Inputs]: InputNullability<Inputs[Index]>
1354
- }
1355
-
1356
- type AnyInputNullability<Inputs extends readonly ExpressionInput[]> = AnyNullability<InputNullabilities<Inputs>>
1357
- type AllInputNullability<Inputs extends readonly ExpressionInput[]> = AllNullability<InputNullabilities<Inputs>>
1358
-
1359
- export interface FieldTypeOptions {
1360
- nullable?: boolean
1361
- selectable?: boolean
1362
- }
1363
-
1364
- type OptionNullable<Options extends FieldTypeOptions> = Options extends { nullable: true } ? true : false
1365
- type OptionSelectable<Options extends FieldTypeOptions> = Options extends { selectable: false } ? false : true
1366
-
1367
- export function fieldType<const Type extends ScalarType, const Options extends FieldTypeOptions = Record<never, never>>(
1368
- scalarType: Type,
1369
- options?: Options,
1370
- ): FieldSpecDefinition<Type, OptionNullable<Options>, OptionSelectable<Options>>
1371
- export function nullable<const Specification extends FieldSpec>(
1372
- specification: Specification,
1373
- ): FieldSpecDefinition<FieldSpecScalarType<Specification>, true, FieldSpecIsSelectable<Specification>>
1374
- export function hidden<const Specification extends FieldSpec>(
1375
- specification: Specification,
1376
- ): FieldSpecDefinition<FieldSpecScalarType<Specification>, FieldSpecIsNullable<Specification>, false>
1377
-
1378
- export function source<const Key extends string, const Fields extends FieldSpecMap>(
1379
- key: Key,
1380
- fields: Fields,
1381
- ): SourceRef<Key, Fields>
1382
-
1383
- export function requiredParameter<const Name extends string, const Type extends ScalarType>(
1384
- name: Name,
1385
- scalarType: Type,
1386
- ): ScalarParameterRef<Name, Type, true>
1387
- export function optionalParameter<const Name extends string, const Type extends ScalarType>(
1388
- name: Name,
1389
- scalarType: Type,
1390
- ): ScalarParameterRef<Name, Type, false>
1391
- export function requiredListParameter<const Name extends string, const Type extends ScalarType>(
1392
- name: Name,
1393
- scalarType: Type,
1394
- ): ListParameterRef<Name, Type, true>
1395
- export function optionalListParameter<const Name extends string, const Type extends ScalarType>(
1396
- name: Name,
1397
- scalarType: Type,
1398
- ): ListParameterRef<Name, Type, false>
1399
- export function param<const Name extends string, const Type extends ScalarType>(
1400
- parameter: ScalarParameterRef<Name, Type>,
1401
- ): TypedExpression<ParameterExpression<Name>, Type, false>
1402
-
1403
- export function literal<const Value extends LiteralInput>(
1404
- value: Value,
1405
- ): TypedExpression<LiteralExpression, InputScalarType<Value>, InputNullability<Value>>
1406
- export function integer(value: number): TypedExpression<LiteralExpression, 'int64', false>
1407
- export function decimal(value: string | number): TypedExpression<LiteralExpression, 'decimal', false>
1408
-
1409
- type EqualityNullability<Left extends ExpressionInput, Right extends ExpressionInput> = null extends
1410
- | InputScalarType<Left>
1411
- | InputScalarType<Right>
1412
- ? false
1413
- : AnyInputNullability<readonly [Left, Right]>
1414
-
1415
- export function eq<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1416
- left: Left,
1417
- right: Right,
1418
- ): TypedExpression<BinaryExpression, 'boolean', EqualityNullability<Left, Right>>
1419
- export function neq<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1420
- left: Left,
1421
- right: Right,
1422
- ): TypedExpression<BinaryExpression, 'boolean', EqualityNullability<Left, Right>>
1423
- export function lt<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1424
- left: Left,
1425
- right: Right,
1426
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1427
- export function lte<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1428
- left: Left,
1429
- right: Right,
1430
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1431
- export function gt<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1432
- left: Left,
1433
- right: Right,
1434
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1435
- export function gte<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1436
- left: Left,
1437
- right: Right,
1438
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1439
- export function like<const Value extends ExpressionInput, const Pattern extends ExpressionInput>(
1440
- expression: Value,
1441
- pattern: Pattern,
1442
- ): TypedExpression<LikeExpression, 'boolean', AnyInputNullability<readonly [Value, Pattern]>>
1443
- export function inList<const Value extends ExpressionInput, const Values extends readonly ExpressionInput[]>(
1444
- expression: Value,
1445
- values: Values,
1446
- ): TypedExpression<InExpression, 'boolean', AnyInputNullability<readonly [Value, ...Values]>>
1447
- export function and<const Expressions extends readonly ExpressionInput[]>(
1448
- ...expressions: Expressions
1449
- ): TypedExpression<ExpressionGroup, 'boolean', AnyInputNullability<Expressions>>
1450
- export function inParameter<
1451
- const Value extends ExpressionInput,
1452
- const Name extends string,
1453
- const Type extends ScalarType,
1454
- >(
1455
- expression: Value,
1456
- parameter: ListParameterRef<Name, Type>,
1457
- ): TypedExpression<InParameterExpression<Name>, 'boolean', InputNullability<Value>>
1458
- export function or<const Expressions extends readonly ExpressionInput[]>(
1459
- ...expressions: Expressions
1460
- ): TypedExpression<ExpressionGroup, 'boolean', AnyInputNullability<Expressions>>
1461
- export function not<const Value extends ExpressionInput>(
1462
- expression: Value,
1463
- ): TypedExpression<UnaryExpression, 'boolean', InputNullability<Value>>
1464
- export function isNull(expression: ExpressionInput): TypedExpression<UnaryExpression, 'boolean', false>
1465
- export function isNotNull(expression: ExpressionInput): TypedExpression<UnaryExpression, 'boolean', false>
1466
- export function exists<const Source extends string>(
1467
- source: Source | SourceRef<Source>,
1468
- predicate?: ExpressionInput,
1469
- ): TypedExpression<ExistsExpression<Source, never>, 'boolean', false>
1470
- export interface ExistsConfiguration<From extends string = string> {
1471
- from: From | SourceRef<From>
1472
- }
1473
- export function exists<const Source extends string, const From extends string>(
1474
- source: Source | SourceRef<Source>,
1475
- predicate: ExpressionInput | undefined,
1476
- configuration: ExistsConfiguration<From>,
1477
- ): TypedExpression<ExistsExpression<Source, From>, 'boolean', false>
1478
-
1479
- export function lower<const Value extends ExpressionInput>(
1480
- expression: Value,
1481
- ): TypedExpression<FunctionExpression, 'string', InputNullability<Value>>
1482
- export function upper<const Value extends ExpressionInput>(
1483
- expression: Value,
1484
- ): TypedExpression<FunctionExpression, 'string', InputNullability<Value>>
1485
- export function coalesce<
1486
- const First extends ExpressionInput,
1487
- const Second extends ExpressionInput,
1488
- const Rest extends readonly ExpressionInput[],
1489
- >(
1490
- first: First,
1491
- second: Second,
1492
- ...rest: Rest
1493
- ): TypedExpression<
1
+ export type {
2
+ ScalarType,
3
+ JsonValue,
4
+ ScalarParameterValue,
5
+ ParameterShape,
6
+ RelationCardinality,
7
+ OrderDirection,
8
+ NullsOrder,
9
+ SemanticFunctionName,
10
+ AggregateFunctionName,
11
+ ProjectionFieldRole,
12
+ SourceFieldNullability,
13
+ AnyNullability,
14
+ AllNullability,
15
+ NullabilityExpression,
16
+ ExpressionTypeMetadata,
17
+ TypedExpression,
18
+ FieldDefinition,
19
+ SourceDefinition,
20
+ ParameterDefinition,
21
+ FieldExpression,
22
+ ParameterExpression,
23
+ LiteralValue,
24
+ LiteralExpression,
25
+ BinaryExpressionKind,
26
+ BinaryExpression,
27
+ LikeExpression,
28
+ InExpression,
29
+ InParameterExpression,
30
+ ExpressionGroup,
31
+ UnaryExpression,
32
+ ExistsExpression,
1494
33
  FunctionExpression,
1495
- PromoteScalarType<InputScalarType<First | Second | Rest[number]>>,
1496
- AllInputNullability<readonly [First, Second, ...Rest]>
1497
- >
1498
- export function concat<const First extends ExpressionInput, const Rest extends readonly ExpressionInput[]>(
1499
- first: First,
1500
- ...rest: Rest
1501
- ): TypedExpression<FunctionExpression, 'string', AllInputNullability<readonly [First, ...Rest]>>
1502
-
1503
- export function count(expression?: ExpressionInput): TypedExpression<AggregateExpression, 'int64', false>
1504
- export function countDistinct(expression: ExpressionInput): TypedExpression<AggregateExpression, 'int64', false>
1505
- export function sum<const Value extends ExpressionInput>(
1506
- expression: Value,
1507
- ): TypedExpression<AggregateExpression, Exclude<InputScalarType<Value>, null>, true>
1508
- export function average<const Value extends ExpressionInput>(
1509
- expression: Value,
1510
- ): TypedExpression<AggregateExpression, AverageScalarType<InputScalarType<Value>>, true>
1511
- export function minimum<const Value extends ExpressionInput>(
1512
- expression: Value,
1513
- ): TypedExpression<AggregateExpression, Exclude<InputScalarType<Value>, null>, true>
1514
- export function maximum<const Value extends ExpressionInput>(
1515
- expression: Value,
1516
- ): TypedExpression<AggregateExpression, Exclude<InputScalarType<Value>, null>, true>
1517
-
1518
- export type SourceReferenceKey<Reference extends string | SourceRef> =
1519
- Reference extends SourceRef<infer Key, infer _Fields> ? Key : Reference extends string ? Reference : string
1520
-
1521
- export interface RelationConfiguration<
1522
- Name extends string = string,
1523
- From extends string | SourceRef = string | SourceRef,
1524
- To extends string | SourceRef = string | SourceRef,
1525
- Required extends boolean = boolean,
1526
- Cardinality extends RelationCardinality = RelationCardinality,
1527
- > {
1528
- name: Name
1529
- from: From
1530
- to: To
1531
- on: Expression
1532
- required?: Required
1533
- cardinality?: Cardinality
1534
- selection?: RelationSelection
1535
- }
1536
-
1537
- export function relation<
1538
- const Name extends string,
1539
- const From extends string | SourceRef,
1540
- const To extends string | SourceRef,
1541
- const Required extends boolean = false,
1542
- const Cardinality extends RelationCardinality = 'one',
1543
- >(
1544
- configuration: RelationConfiguration<Name, From, To, Required, Cardinality>,
1545
- ): RelationRef<Name, SourceReferenceKey<From>, SourceReferenceKey<To>, Required, Cardinality>
1546
-
1547
- export interface ConstraintConfiguration {
1548
- predicate: Expression
1549
- when?: string | ParameterRef
1550
- }
1551
-
1552
- export function constraint(configuration: ConstraintConfiguration): ConstraintDefinition
1553
-
1554
- export interface ProjectionConfiguration<
1555
- Path extends string | readonly string[] = string | readonly string[],
1556
- Value extends ExpressionInput = ExpressionInput,
1557
- SelectedByDefault extends boolean = boolean,
1558
- > {
1559
- path: Path
1560
- expression: Value
1561
- default?: SelectedByDefault
1562
- }
1563
-
1564
- export interface ProjectionObjectConfiguration<
1565
- Path extends string | readonly string[] = string | readonly string[],
1566
- Value extends ExpressionInput = ExpressionInput,
1567
- > {
1568
- path: Path
1569
- presence: Value
1570
- }
1571
-
1572
- type ConfigurationPath<Path extends string | readonly string[]> = Path extends string
1573
- ? Path
1574
- : Path extends readonly string[]
1575
- ? JoinProjectionPath<Path>
1576
- : never
1577
-
1578
- export function project<
1579
- const Path extends string | readonly string[],
1580
- const Value extends ExpressionInput,
1581
- const SelectedByDefault extends boolean = false,
1582
- >(
1583
- configuration: ProjectionConfiguration<Path, Value, SelectedByDefault>,
1584
- ): TypedProjectionField<
1585
- ConfigurationPath<Path>,
1586
- Extract<InputScalarType<Value>, ScalarType>,
1587
- InputNullability<Value>,
1588
- SelectedByDefault
1589
- >
1590
-
1591
- export function projectObject<const Path extends string | readonly string[], const Value extends ExpressionInput>(
1592
- configuration: ProjectionObjectConfiguration<Path, Value>,
1593
- ): TypedProjectionObject<ConfigurationPath<Path>, InputNullability<Value>>
1594
-
1595
- export function dimension<
1596
- const Path extends string | readonly string[],
1597
- const Value extends ExpressionInput,
1598
- const SelectedByDefault extends boolean = false,
1599
- >(
1600
- configuration: ProjectionConfiguration<Path, Value, SelectedByDefault>,
1601
- ): TypedDimensionDefinition<
1602
- ConfigurationPath<Path>,
1603
- Extract<InputScalarType<Value>, ScalarType>,
1604
- InputNullability<Value>,
1605
- SelectedByDefault
1606
- >
1607
-
1608
- export function measure<
1609
- const Path extends string | readonly string[],
1610
- const Value extends ExpressionInput,
1611
- const SelectedByDefault extends boolean = false,
1612
- >(
1613
- configuration: ProjectionConfiguration<Path, Value, SelectedByDefault>,
1614
- ): TypedMeasureDefinition<
1615
- ConfigurationPath<Path>,
1616
- Extract<InputScalarType<Value>, ScalarType>,
1617
- InputNullability<Value>,
1618
- SelectedByDefault
1619
- >
1620
-
1621
- export interface OrderByOptions {
1622
- nulls?: NullsOrder
1623
- }
1624
-
1625
- export function asc(expression: ExpressionInput, options?: OrderByOptions): OrderByDefinition
1626
- export function desc(expression: ExpressionInput, options?: OrderByOptions): OrderByDefinition
1627
-
1628
- export function firstBy(firstOrder: OrderByDefinition, ...rest: readonly OrderByDefinition[]): FirstBySelection
1629
-
1630
- export interface OrderingConfiguration<Name extends string = string> {
1631
- name: Name
1632
- by: readonly [OrderByDefinition, ...OrderByDefinition[]]
1633
- default?: boolean
1634
- }
1635
-
1636
- export function ordering<const Name extends string>(
1637
- configuration: OrderingConfiguration<Name>,
1638
- ): OrderingDefinition<Name>
1639
-
1640
- export interface GraphModuleConfiguration {
1641
- name: string
1642
- modules?: readonly GraphModule[]
1643
- sources?: readonly SourceRef[]
1644
- parameters?: readonly ParameterDefinition[]
1645
- relations?: readonly RelationDefinition[]
1646
- constraints?: readonly ConstraintDefinition[]
1647
- projection?: readonly ProjectionFieldDefinition[]
1648
- objects?: readonly ProjectionObjectDefinition[]
1649
- orderings?: readonly OrderingDefinition[]
1650
- }
1651
-
1652
- type ConfigurationElement<Configuration, Key extends PropertyKey> = Key extends keyof Configuration
1653
- ? NonNullable<Configuration[Key]> extends readonly (infer Element)[]
1654
- ? Element
1655
- : never
1656
- : never
1657
-
1658
- type ModuleParameter<Module> =
1659
- Module extends GraphModule<
1660
- infer Parameter,
1661
- infer _ProjectionPath,
1662
- infer _OrderingName,
1663
- infer _ProjectionField,
1664
- infer _Relation
1665
- >
1666
- ? Parameter
1667
- : never
1668
-
1669
- type ModuleProjectionPath<Module> =
1670
- Module extends GraphModule<
1671
- infer _Parameter,
1672
- infer ProjectionPath,
1673
- infer _OrderingName,
1674
- infer _ProjectionField,
1675
- infer _Relation
1676
- >
1677
- ? ProjectionPath
1678
- : never
1679
-
1680
- type ModuleOrderingName<Module> =
1681
- Module extends GraphModule<
1682
- infer _Parameter,
1683
- infer _ProjectionPath,
1684
- infer OrderingName,
1685
- infer _ProjectionField,
1686
- infer _Relation
1687
- >
1688
- ? OrderingName
1689
- : never
1690
-
1691
- type ModuleProjectionField<Module> =
1692
- Module extends GraphModule<
1693
- infer _Parameter,
1694
- infer _ProjectionPath,
1695
- infer _OrderingName,
1696
- infer ProjectionField,
1697
- infer _Relation
1698
- >
1699
- ? ProjectionField
1700
- : never
1701
-
1702
- type ModuleRelation<Module> =
1703
- Module extends GraphModule<
1704
- infer _Parameter,
1705
- infer _ProjectionPath,
1706
- infer _OrderingName,
1707
- infer _ProjectionField,
1708
- infer Relation
1709
- >
1710
- ? Relation
1711
- : never
1712
-
1713
- type ModuleProjectionObject<Module> =
1714
- Module extends GraphModule<
1715
- infer _Parameter,
1716
- infer _ProjectionPath,
1717
- infer _OrderingName,
1718
- infer _ProjectionField,
1719
- infer _Relation,
1720
- infer ProjectionObject
1721
- >
1722
- ? ProjectionObject
1723
- : never
1724
-
1725
- type ProjectionPathOf<Field> = Field extends ProjectionFieldDefinition<infer Path> ? Path : never
1726
-
1727
- type OrderingNameOf<Ordering> = Ordering extends OrderingDefinition<infer Name> ? Name : never
1728
-
1729
- type ConfigurationParameter<Configuration> =
1730
- | Extract<ConfigurationElement<Configuration, 'parameters'>, ParameterDefinition>
1731
- | ModuleParameter<ConfigurationElement<Configuration, 'modules'>>
1732
-
1733
- type ConfigurationProjectionPath<Configuration> =
1734
- | ProjectionPathOf<ConfigurationElement<Configuration, 'projection'>>
1735
- | ProjectionPathOf<ConfigurationElement<Configuration, 'dimensions'>>
1736
- | ProjectionPathOf<ConfigurationElement<Configuration, 'measures'>>
1737
- | ModuleProjectionPath<ConfigurationElement<Configuration, 'modules'>>
1738
-
1739
- type ConfigurationProjectionField<Configuration> =
1740
- | Extract<ConfigurationElement<Configuration, 'projection'>, ProjectionFieldDefinition>
1741
- | Extract<ConfigurationElement<Configuration, 'dimensions'>, ProjectionFieldDefinition>
1742
- | Extract<ConfigurationElement<Configuration, 'measures'>, ProjectionFieldDefinition>
1743
- | ModuleProjectionField<ConfigurationElement<Configuration, 'modules'>>
1744
-
1745
- type ConfigurationProjectionObject<Configuration> =
1746
- | Extract<ConfigurationElement<Configuration, 'objects'>, ProjectionObjectDefinition>
1747
- | ModuleProjectionObject<ConfigurationElement<Configuration, 'modules'>>
1748
-
1749
- type ConfigurationOrderingName<Configuration> =
1750
- | OrderingNameOf<ConfigurationElement<Configuration, 'orderings'>>
1751
- | ModuleOrderingName<ConfigurationElement<Configuration, 'modules'>>
1752
-
1753
- type ConfigurationRelation<Configuration> =
1754
- | Extract<ConfigurationElement<Configuration, 'relations'>, RelationDefinition>
1755
- | ModuleRelation<ConfigurationElement<Configuration, 'modules'>>
1756
-
1757
- type ConfigurationRoot<Configuration> = Configuration extends {
1758
- root: infer Root extends string | SourceRef
1759
- }
1760
- ? SourceReferenceKey<Root>
1761
- : string
1762
-
1763
- export interface GraphModule<
1764
- Parameter extends ParameterDefinition = ParameterDefinition,
1765
- ProjectionPath extends string = string,
1766
- OrderingName extends string = string,
1767
- ProjectionField extends ProjectionFieldDefinition = ProjectionFieldDefinition<ProjectionPath>,
1768
- Relation extends RelationDefinition = RelationDefinition,
1769
- ProjectionObject extends ProjectionObjectDefinition = ProjectionObjectDefinition,
1770
- > {
1771
- readonly name: string
1772
- readonly sources: readonly SourceRef[]
1773
- readonly parameters: readonly Parameter[]
1774
- readonly relations: readonly Relation[]
1775
- readonly constraints: readonly ConstraintDefinition[]
1776
- readonly projection: readonly ProjectionField[]
1777
- readonly objects: readonly ProjectionObject[]
1778
- readonly orderings: readonly OrderingDefinition<OrderingName>[]
1779
- }
1780
-
1781
- export function defineGraphModule<const Configuration extends GraphModuleConfiguration>(
1782
- configuration: Configuration,
1783
- ): GraphModule<
1784
- ConfigurationParameter<Configuration>,
1785
- ConfigurationProjectionPath<Configuration>,
1786
- ConfigurationOrderingName<Configuration>,
1787
- ConfigurationProjectionField<Configuration>,
1788
- ConfigurationRelation<Configuration>,
1789
- ConfigurationProjectionObject<Configuration>
1790
- >
1791
-
1792
- export interface GraphConfiguration {
1793
- name: string
1794
- root: string | SourceRef
1795
- modules?: readonly GraphModule[]
1796
- sources?: readonly SourceRef[]
1797
- parameters?: readonly ParameterDefinition[]
1798
- relations?: readonly RelationDefinition[]
1799
- constraints?: readonly ConstraintDefinition[]
1800
- projection?: readonly ProjectionFieldDefinition[]
1801
- objects?: readonly ProjectionObjectDefinition[]
1802
- orderings?: readonly OrderingDefinition[]
1803
- }
1804
-
1805
- export function defineGraph<const Configuration extends GraphConfiguration>(
1806
- configuration: Configuration,
1807
- ): GraphDefinition<
1808
- ConfigurationParameter<Configuration>,
1809
- ConfigurationProjectionPath<Configuration>,
1810
- ConfigurationOrderingName<Configuration>,
1811
- ConfigurationProjectionField<Configuration>,
1812
- ConfigurationRelation<Configuration>,
1813
- ConfigurationRoot<Configuration>,
1814
- ConfigurationProjectionObject<Configuration>
1815
- >
1816
-
1817
- export interface SummaryGraphConfiguration {
1818
- name: string
1819
- root: string | SourceRef
1820
- modules?: readonly GraphModule[]
1821
- sources?: readonly SourceRef[]
1822
- parameters?: readonly ParameterDefinition[]
1823
- relations?: readonly RelationDefinition[]
1824
- constraints?: readonly ConstraintDefinition[]
1825
- dimensions?: readonly DimensionDefinition[]
1826
- measures?: readonly MeasureDefinition[]
1827
- orderings?: readonly OrderingDefinition[]
1828
- }
1829
-
1830
- export function defineSummaryGraph<const Configuration extends SummaryGraphConfiguration>(
1831
- configuration: Configuration,
1832
- ): GraphDefinition<
1833
- ConfigurationParameter<Configuration>,
1834
- ConfigurationProjectionPath<Configuration>,
1835
- ConfigurationOrderingName<Configuration>,
1836
- ConfigurationProjectionField<Configuration>,
1837
- ConfigurationRelation<Configuration>,
1838
- ConfigurationRoot<Configuration>,
1839
- never
1840
- >
34
+ AggregateExpression,
35
+ Expression,
36
+ RelationDefinition,
37
+ ConstraintCondition,
38
+ ConstraintDefinition,
39
+ JoinProjectionPath,
40
+ ProjectionTypeMetadata,
41
+ ProjectionObjectTypeMetadata,
42
+ TypedProjectionObject,
43
+ TypedProjectionField,
44
+ TypedDimensionDefinition,
45
+ TypedMeasureDefinition,
46
+ ProjectionFieldDefinition,
47
+ ProjectionObjectDefinition,
48
+ DimensionDefinition,
49
+ MeasureDefinition,
50
+ SummaryFieldDefinition,
51
+ ProjectionDefinition,
52
+ ProjectionDefinitionInput,
53
+ OrderByDefinition,
54
+ OrderingDefinition,
55
+ FirstBySelection,
56
+ RelationSelection,
57
+ GraphDefinitionInput,
58
+ GraphDefinition,
59
+ ExactGraphDefinitionInput,
60
+ TableName,
61
+ SourceMapping,
62
+ RelationalMapping,
63
+ } from './types/model.js'
64
+ export type {
65
+ QueryOperationBase,
66
+ DefinitionParameter,
67
+ DefinitionProjectionPath,
68
+ DefinitionOrderingName,
69
+ DefinitionProjectionField,
70
+ DefinitionProjectionObject,
71
+ DefinitionRelation,
72
+ DefinitionRoot,
73
+ ParameterValue,
74
+ OperationParameters,
75
+ QueryOperation,
76
+ QueryGraph,
77
+ RelationalQueryGraph,
78
+ DefinitionOf,
79
+ SqlServerVersion,
80
+ OracleVersion,
81
+ SqlServerCompileOptions,
82
+ OracleCompileOptions,
83
+ QueryGraphErrorPhase,
84
+ QueryGraphDiagnostic,
85
+ QueryGraphError,
86
+ } from './types/runtime.js'
87
+ export type {
88
+ FieldSpecDefinition,
89
+ FieldSpec,
90
+ FieldSpecMap,
91
+ FieldSpecScalarType,
92
+ FieldSpecIsNullable,
93
+ FieldSpecIsSelectable,
94
+ SourceRef,
95
+ ScalarParameterRef,
96
+ ListParameterRef,
97
+ ParameterRef,
98
+ RelationRef,
99
+ LiteralInput,
100
+ ExpressionInput,
101
+ ExpressionScalarType,
102
+ ExpressionNullability,
103
+ FieldTypeOptions,
104
+ ExistsConfiguration,
105
+ SourceReferenceKey,
106
+ RelationConfiguration,
107
+ ConstraintConfiguration,
108
+ ProjectionConfiguration,
109
+ ProjectionObjectConfiguration,
110
+ OrderByOptions,
111
+ OrderingConfiguration,
112
+ GraphModuleConfiguration,
113
+ GraphModule,
114
+ GraphConfiguration,
115
+ SummaryGraphConfiguration,
116
+ } from './types/authoring.js'
117
+ export {
118
+ fieldType,
119
+ nullable,
120
+ hidden,
121
+ source,
122
+ requiredParameter,
123
+ optionalParameter,
124
+ requiredListParameter,
125
+ optionalListParameter,
126
+ param,
127
+ literal,
128
+ integer,
129
+ decimal,
130
+ eq,
131
+ neq,
132
+ lt,
133
+ lte,
134
+ gt,
135
+ gte,
136
+ like,
137
+ inList,
138
+ and,
139
+ inParameter,
140
+ or,
141
+ not,
142
+ isNull,
143
+ isNotNull,
144
+ exists,
145
+ lower,
146
+ upper,
147
+ coalesce,
148
+ concat,
149
+ count,
150
+ countDistinct,
151
+ sum,
152
+ average,
153
+ minimum,
154
+ maximum,
155
+ relation,
156
+ constraint,
157
+ project,
158
+ projectObject,
159
+ dimension,
160
+ measure,
161
+ asc,
162
+ desc,
163
+ firstBy,
164
+ ordering,
165
+ defineGraphModule,
166
+ defineGraph,
167
+ defineSummaryGraph,
168
+ } from './types/authoring.js'
169
+ export type {
170
+ BatchCardinality,
171
+ BatchRelationWire,
172
+ BatchQuery,
173
+ BatchQueryConfiguration,
174
+ BatchRelation,
175
+ BatchRelationConfiguration,
176
+ ComposedSelection,
177
+ BatchPlanMetadata,
178
+ CompiledQueryPlan,
179
+ ComposedQueryOperation,
180
+ ComposedQueryGraph,
181
+ } from './types/composition.js'
182
+ export { batchQuery, batchRelation, composeGraph } from './types/composition.js'
183
+ export type { ScalarOutputTypeMap, DefaultScalarOutputTypeMap, ResultOf } from './types/result.js'