@query-graph/core 1.1.3 → 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,1839 +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
- }
536
-
537
- export interface RelationalQueryGraph<Definition extends GraphDefinitionInput = GraphDefinitionInput> {
538
- readonly [graphDefinitionType]?: Definition
539
- readonly name: string
540
- compileSqlServer(
541
- operation: QueryOperation<Definition>,
542
- options?: SqlServerCompileOptions,
543
- ): import('./index.js').CompiledSqlStatement
544
- compileOracle(
545
- operation: QueryOperation<Definition>,
546
- options?: OracleCompileOptions,
547
- ): import('./index.js').CompiledSqlStatement
548
- }
549
-
550
- export type BatchCardinality = RelationCardinality
551
-
552
- export interface BatchRelationWire {
553
- name: string
554
- from: string
555
- to: string
556
- parameter: string
557
- cardinality: BatchCardinality
558
- parameters?: Record<string, unknown>
559
- ordering?: string
560
- }
561
-
562
- type ListDefinitionParameter<Definition extends GraphDefinitionInput> =
563
- DefinitionParameter<Definition> extends infer Parameter extends ParameterDefinition
564
- ? Parameter extends { shape: 'list' }
565
- ? Parameter
566
- : never
567
- : never
568
-
569
- type ListParameterReference<Definition extends GraphDefinitionInput> =
570
- | ListDefinitionParameter<Definition>
571
- | ListDefinitionParameter<Definition>['name']
572
-
573
- type ParameterReferenceName<Reference> = Reference extends { name: infer Name extends string }
574
- ? Name
575
- : Reference extends string
576
- ? Reference
577
- : never
578
-
579
- type ResolveListParameter<Definition extends GraphDefinitionInput, Reference> = Extract<
580
- ListDefinitionParameter<Definition>,
581
- { name: ParameterReferenceName<Reference> }
582
- >
583
-
584
- type BatchStaticParameterCandidate<
585
- Parameter extends ParameterDefinition,
586
- KeyName extends string,
587
- > = Parameter extends ParameterDefinition ? (Parameter['name'] extends KeyName ? never : Parameter) : never
588
-
589
- type BatchStaticParameter<
590
- Definition extends GraphDefinitionInput,
591
- KeyName extends string,
592
- > = BatchStaticParameterCandidate<DefinitionParameter<Definition>, KeyName>
593
-
594
- type BatchStaticParameters<Definition extends GraphDefinitionInput, KeyName extends string> = {
595
- [Parameter in RequiredParameter<
596
- BatchStaticParameter<Definition, KeyName>
597
- > as Parameter['name']]-?: ParameterValue<Parameter>
598
- } & {
599
- [Parameter in OptionalParameter<
600
- BatchStaticParameter<Definition, KeyName>
601
- > as Parameter['name']]?: ParameterValue<Parameter>
602
- }
603
-
604
- type BatchStaticParameterInput<Definition extends GraphDefinitionInput, KeyName extends string> = [
605
- BatchStaticParameter<Definition, KeyName>,
606
- ] extends [never]
607
- ? { parameters?: never }
608
- : [RequiredParameter<BatchStaticParameter<Definition, KeyName>>] extends [never]
609
- ? { parameters?: BatchStaticParameters<Definition, KeyName> }
610
- : { parameters: BatchStaticParameters<Definition, KeyName> }
611
-
612
- declare const batchQueryType: unique symbol
613
-
614
- export interface BatchQuery<
615
- Child extends RelationalQueryGraph = RelationalQueryGraph,
616
- KeyPath extends string = string,
617
- KeyParameter extends ParameterDefinition & { shape: 'list' } = ListParameterRef,
618
- > {
619
- readonly graph: Child
620
- readonly key: {
621
- readonly path: KeyPath
622
- readonly parameter: KeyParameter['name']
623
- }
624
- readonly [batchQueryType]?: KeyParameter
625
- }
626
-
627
- export type BatchQueryConfiguration<
628
- Child extends RelationalQueryGraph,
629
- KeyPath extends DefinitionProjectionPath<DefinitionOf<Child>>,
630
- ParameterReference extends ListParameterReference<DefinitionOf<Child>>,
631
- > = {
632
- graph: Child
633
- key: {
634
- path: KeyPath
635
- parameter: ParameterReference
636
- }
637
- }
638
-
639
- type CompatibleBatchQueryConfiguration<
640
- Child extends RelationalQueryGraph,
641
- KeyPath extends DefinitionProjectionPath<DefinitionOf<Child>>,
642
- KeyParameter extends ParameterDefinition & { shape: 'list' },
643
- > =
644
- EqualScalarType<ProjectionScalarTypeAtPath<DefinitionOf<Child>, KeyPath>, KeyParameter['scalarType']> extends true
645
- ? unknown
646
- : never
647
-
648
- export function batchQuery<
649
- const Child extends RelationalQueryGraph,
650
- const KeyPath extends DefinitionProjectionPath<DefinitionOf<Child>>,
651
- const ParameterReference extends ListParameterReference<DefinitionOf<Child>>,
652
- >(
653
- configuration: BatchQueryConfiguration<Child, KeyPath, ParameterReference> &
654
- CompatibleBatchQueryConfiguration<
655
- Child,
656
- KeyPath,
657
- ResolveListParameter<DefinitionOf<Child>, NoInfer<ParameterReference>>
658
- >,
659
- ): BatchQuery<Child, KeyPath, ResolveListParameter<DefinitionOf<Child>, ParameterReference>>
660
-
661
- type BatchQueryGraph<Query extends BatchQuery> =
662
- Query extends BatchQuery<infer Child, infer _KeyPath, infer _KeyParameter> ? Child : never
663
-
664
- type BatchQueryKeyPath<Query extends BatchQuery> =
665
- Query extends BatchQuery<infer _Child, infer KeyPath, infer _KeyParameter> ? KeyPath : never
666
-
667
- type BatchQueryKeyParameter<Query extends BatchQuery> =
668
- Query extends BatchQuery<infer _Child, infer _KeyPath, infer KeyParameter> ? KeyParameter : never
669
-
670
- declare const batchRelationType: unique symbol
671
-
672
- export interface BatchRelation<
673
- Name extends string = string,
674
- Query extends BatchQuery = BatchQuery,
675
- From extends string = string,
676
- Cardinality extends BatchCardinality = BatchCardinality,
677
- > {
678
- readonly name: Name
679
- readonly from: From
680
- readonly query: Query
681
- readonly cardinality: Cardinality
682
- readonly parameters: BatchStaticParameters<
683
- DefinitionOf<BatchQueryGraph<Query>>,
684
- BatchQueryKeyParameter<Query>['name']
685
- >
686
- readonly ordering?: DefinitionOrderingName<DefinitionOf<BatchQueryGraph<Query>>>
687
- readonly [batchRelationType]?: Query
688
- }
689
-
690
- export type BatchRelationConfiguration<
691
- Name extends string,
692
- Query extends BatchQuery,
693
- From extends string,
694
- Cardinality extends BatchCardinality,
695
- > = {
696
- name: Name
697
- from: From
698
- query: Query
699
- cardinality: Cardinality
700
- ordering?: DefinitionOrderingName<DefinitionOf<BatchQueryGraph<Query>>>
701
- } & BatchStaticParameterInput<DefinitionOf<BatchQueryGraph<Query>>, BatchQueryKeyParameter<Query>['name']>
702
-
703
- export function batchRelation<
704
- const Name extends string,
705
- const Query extends BatchQuery,
706
- const From extends string,
707
- const Cardinality extends BatchCardinality,
708
- >(
709
- configuration: BatchRelationConfiguration<Name, Query, From, Cardinality>,
710
- ): BatchRelation<Name, Query, From, Cardinality>
711
-
712
- type ProjectionScalarTypeAtPath<Definition extends GraphDefinitionInput, Path extends string> =
713
- ProjectionFieldByPath<DefinitionProjectionField<Definition>, Path> extends infer Field
714
- ? Field extends ProjectionTypeMetadata<infer _Path, infer Type, infer _Nullability, infer _SelectedByDefault>
715
- ? Type
716
- : Field extends ProjectionFieldDefinition<infer _Path, infer Type>
717
- ? Type
718
- : never
719
- : never
720
-
721
- type EqualScalarType<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false
722
-
723
- type CompatibleBatchRelation<Root extends RelationalQueryGraph, Relation extends BatchRelation> =
724
- Relation extends BatchRelation<infer Name, infer Query, infer From, infer _Cardinality>
725
- ? From extends DefinitionProjectionPath<DefinitionOf<Root>>
726
- ? Extract<DefinitionProjectionPath<DefinitionOf<Root>>, Name | `${Name}.${string}`> extends never
727
- ? EqualScalarType<
728
- ProjectionScalarTypeAtPath<DefinitionOf<Root>, From>,
729
- ProjectionScalarTypeAtPath<DefinitionOf<BatchQueryGraph<Query>>, BatchQueryKeyPath<Query>>
730
- > extends true
731
- ? EqualScalarType<
732
- ProjectionScalarTypeAtPath<DefinitionOf<BatchQueryGraph<Query>>, BatchQueryKeyPath<Query>>,
733
- BatchQueryKeyParameter<Query>['scalarType']
734
- > extends true
735
- ? Relation
736
- : never
737
- : never
738
- : never
739
- : never
740
- : never
741
-
742
- type CompatibleBatchRelations<Root extends RelationalQueryGraph, Relations extends readonly BatchRelation[]> = {
743
- readonly [Index in keyof Relations]: Relations[Index] extends BatchRelation
744
- ? CompatibleBatchRelation<Root, Relations[Index]>
745
- : never
746
- }
747
-
748
- type RelationName<Relations extends readonly BatchRelation[]> = Relations[number]['name']
749
- type ChildPathsForRelation<Relation extends BatchRelation> = Relation extends BatchRelation
750
- ? `${Relation['name']}.${DefinitionProjectionPath<DefinitionOf<BatchQueryGraph<Relation['query']>>>}`
751
- : never
752
- type ChildPaths<Relations extends readonly BatchRelation[]> = ChildPathsForRelation<Relations[number]>
753
-
754
- export type ComposedSelection<Root extends RelationalQueryGraph, Relations extends readonly BatchRelation[]> =
755
- | DefinitionProjectionPath<DefinitionOf<Root>>
756
- | ChildPaths<Relations>
757
-
758
- export interface BatchPlanMetadata<Relation extends BatchRelation = BatchRelation> {
759
- name: Relation['name']
760
- parentKey: Relation['from']
761
- childKey: BatchQueryKeyPath<Relation['query']>
762
- keyParameter: BatchQueryKeyParameter<Relation['query']>['name']
763
- parameters: Readonly<Relation['parameters']>
764
- cardinality: Relation['cardinality']
765
- parentKeyInjected: boolean
766
- childKeyInjected: boolean
767
- }
768
-
769
- type BatchRelationNamed<Relation extends BatchRelation, Name extends string> = Relation extends BatchRelation
770
- ? Relation['name'] extends Name
771
- ? Relation
772
- : never
773
- : never
774
-
775
- type BatchRelationByName<Relations extends readonly BatchRelation[], Name extends string> = BatchRelationNamed<
776
- Relations[number],
777
- Name
778
- >
779
-
780
- type BatchKeyValue<Relation extends BatchRelation> = ScalarParameterValue<
781
- BatchQueryKeyParameter<Relation['query']>['scalarType']
782
- >
783
-
784
- export interface CompiledQueryPlan<Relations extends readonly BatchRelation[] = readonly BatchRelation[]> {
785
- readonly root: import('./index.js').CompiledSqlStatement
786
- readonly batches: readonly BatchPlanMetadata<Relations[number]>[]
787
- compileBatch<const Name extends RelationName<Relations>>(
788
- name: Name,
789
- keys: readonly BatchKeyValue<BatchRelationByName<Relations, Name>>[],
790
- ): import('./index.js').CompiledSqlStatement
791
- }
792
-
793
- export type ComposedQueryOperation<
794
- Root extends RelationalQueryGraph,
795
- Relations extends readonly BatchRelation[],
796
- > = QueryOperationBase<ComposedSelection<Root, Relations>, DefinitionOrderingName<DefinitionOf<Root>>> &
797
- OperationParameterInput<DefinitionOf<Root>>
798
-
799
- export interface ComposedQueryGraph<
800
- Root extends RelationalQueryGraph = RelationalQueryGraph,
801
- Relations extends readonly BatchRelation[] = readonly BatchRelation[],
802
- > {
803
- readonly name: string
804
- compileOraclePlan(
805
- operation: ComposedQueryOperation<Root, Relations>,
806
- options?: OracleCompileOptions,
807
- ): CompiledQueryPlan<Relations>
808
- compileSqlServerPlan(
809
- operation: ComposedQueryOperation<Root, Relations>,
810
- options?: SqlServerCompileOptions,
811
- ): CompiledQueryPlan<Relations>
812
- }
813
-
814
- export function composeGraph<
815
- const Root extends RelationalQueryGraph,
816
- const Relations extends readonly BatchRelation[],
817
- >(configuration: {
818
- root: Root
819
- relations: Relations & CompatibleBatchRelations<Root, Relations>
820
- }): ComposedQueryGraph<Root, Relations>
821
-
822
- export interface ScalarOutputTypeMap {
823
- boolean: unknown
824
- int32: unknown
825
- int64: unknown
826
- float64: unknown
827
- decimal: unknown
828
- string: unknown
829
- date: unknown
830
- dateTime: unknown
831
- binary: unknown
832
- json: unknown
833
- }
834
-
835
- export interface DefaultScalarOutputTypeMap extends ScalarOutputTypeMap {
836
- boolean: boolean
837
- int32: number
838
- int64: number | string
839
- float64: number
840
- decimal: number | string
841
- string: string
842
- date: string
843
- dateTime: string
844
- binary: string
845
- json: JsonValue
846
- }
847
-
848
- export type DefinitionOf<Subject extends GraphDefinitionInput | QueryGraph | RelationalQueryGraph> =
849
- Subject extends GraphDefinitionInput
850
- ? Subject
851
- : Subject extends QueryGraph<infer Definition>
852
- ? Definition
853
- : Subject extends RelationalQueryGraph<infer Definition>
854
- ? Definition
855
- : never
856
-
857
- type IncomingRelation<Definition extends GraphDefinitionInput, Source extends string> =
858
- DefinitionRelation<Definition> extends infer Candidate
859
- ? Candidate extends RelationDefinition<infer _Name, infer _From, infer To, infer _Required, infer _Cardinality>
860
- ? Source extends To
861
- ? Candidate
862
- : never
863
- : never
864
- : never
865
-
866
- type RelationPathNullability<
867
- Definition extends GraphDefinitionInput,
868
- Relation,
869
- Visited extends string,
870
- Depth extends readonly unknown[],
871
- > =
872
- Relation extends RelationDefinition<infer _Name, infer From, infer _To, infer Required, infer _Cardinality>
873
- ? BooleanOr<
874
- | (Required extends true ? false : true)
875
- | SourceOuterNullable<Definition, From, Visited, readonly [...Depth, unknown]>
876
- >
877
- : boolean
878
-
879
- type SourceOuterNullable<
880
- Definition extends GraphDefinitionInput,
881
- Source extends string,
882
- Visited extends string = never,
883
- Depth extends readonly unknown[] = readonly [],
884
- > = Depth['length'] extends 12
885
- ? boolean
886
- : string extends Source
887
- ? boolean
888
- : string extends DefinitionRoot<Definition>
889
- ? boolean
890
- : Source extends DefinitionRoot<Definition>
891
- ? false
892
- : Source extends Visited
893
- ? boolean
894
- : [IncomingRelation<Definition, Source>] extends [never]
895
- ? boolean
896
- : BooleanOr<
897
- RelationPathNullability<Definition, IncomingRelation<Definition, Source>, Visited | Source, Depth>
898
- >
899
-
900
- type CombineAllNullability<Left extends boolean, Right extends boolean> = [Left] extends [false]
901
- ? false
902
- : [Right] extends [false]
903
- ? false
904
- : [Left] extends [true]
905
- ? Right
906
- : [Right] extends [true]
907
- ? Left
908
- : boolean
909
-
910
- type EvaluateAnyNullability<
911
- Definition extends GraphDefinitionInput,
912
- Values,
913
- Depth extends readonly unknown[],
914
- > = Values extends readonly []
915
- ? false
916
- : Values extends readonly [
917
- infer First extends NullabilityExpression,
918
- ...infer Rest extends readonly NullabilityExpression[],
919
- ]
920
- ? BooleanOr<
921
- | EvaluateNullability<Definition, First, readonly [...Depth, unknown]>
922
- | EvaluateAnyNullability<Definition, Rest, readonly [...Depth, unknown]>
923
- >
924
- : Values extends readonly (infer Value extends NullabilityExpression)[]
925
- ? BooleanOr<EvaluateNullability<Definition, Value, readonly [...Depth, unknown]>>
926
- : boolean
927
-
928
- type EvaluateAllNullability<
929
- Definition extends GraphDefinitionInput,
930
- Values,
931
- Depth extends readonly unknown[],
932
- > = Values extends readonly []
933
- ? true
934
- : Values extends readonly [
935
- infer First extends NullabilityExpression,
936
- ...infer Rest extends readonly NullabilityExpression[],
937
- ]
938
- ? CombineAllNullability<
939
- EvaluateNullability<Definition, First, readonly [...Depth, unknown]>,
940
- EvaluateAllNullability<Definition, Rest, readonly [...Depth, unknown]>
941
- >
942
- : boolean
943
-
944
- type EvaluateNullability<
945
- Definition extends GraphDefinitionInput,
946
- Formula extends NullabilityExpression,
947
- Depth extends readonly unknown[] = readonly [],
948
- > = Depth['length'] extends 16
949
- ? boolean
950
- : NullabilityExpression extends Formula
951
- ? boolean
952
- : Formula extends boolean
953
- ? Formula
954
- : Formula extends SourceFieldNullability<infer Source, infer FieldNullable>
955
- ? BooleanOr<FieldNullable | SourceOuterNullable<Definition, Source, never, Depth>>
956
- : Formula extends AnyNullability<infer Values>
957
- ? EvaluateAnyNullability<Definition, Values, Depth>
958
- : Formula extends AllNullability<infer Values>
959
- ? EvaluateAllNullability<Definition, Values, Depth>
960
- : boolean
961
-
962
- type ProjectionFieldPath<Field> =
963
- Field extends ProjectionTypeMetadata<infer Path, infer _Type, infer _Nullability, infer _SelectedByDefault>
964
- ? Path
965
- : Field extends ProjectionFieldDefinition<infer Path>
966
- ? Path
967
- : never
968
-
969
- type ProjectionObjectPath<Object> =
970
- Object extends ProjectionObjectTypeMetadata<infer Path, infer _Nullability>
971
- ? Path
972
- : Object extends ProjectionObjectDefinition<infer Path>
973
- ? Path
974
- : never
975
-
976
- type ProjectionObjectNullability<Object> =
977
- Object extends ProjectionObjectTypeMetadata<infer _Path, infer Nullability>
978
- ? Nullability
979
- : Object extends ProjectionObjectDefinition<infer _Path, infer Nullability>
980
- ? Nullability
981
- : boolean
982
-
983
- type ProjectionObjectIsNullable<Definition extends GraphDefinitionInput, Object> =
984
- true extends EvaluateNullability<Definition, ProjectionObjectNullability<Object>> ? true : false
985
-
986
- type ProjectionFieldValue<Definition extends GraphDefinitionInput, Field, TypeMap extends ScalarOutputTypeMap> =
987
- Field extends ProjectionTypeMetadata<infer _Path, infer Type, infer Nullability, infer _SelectedByDefault>
988
- ? true extends EvaluateNullability<Definition, Nullability>
989
- ? TypeMap[Type] | null
990
- : TypeMap[Type]
991
- : Field extends ProjectionFieldDefinition<infer _Path, infer Type, infer Nullability, infer _SelectedByDefault>
992
- ? true extends EvaluateNullability<Definition, Nullability>
993
- ? TypeMap[Type] | null
994
- : TypeMap[Type]
995
- : never
996
-
997
- type ProjectionFieldByPath<Field, Path extends string> = Field extends ProjectionFieldDefinition
998
- ? ProjectionFieldPath<Field> extends Path
999
- ? Field
1000
- : never
1001
- : never
1002
-
1003
- type ProjectionDefaultAtPath<Field, Path extends string> =
1004
- Field extends ProjectionTypeMetadata<infer FieldPath, infer _Type, infer _Nullability, infer SelectedByDefault>
1005
- ? FieldPath extends Path
1006
- ? SelectedByDefault
1007
- : never
1008
- : Field extends ProjectionFieldDefinition
1009
- ? ProjectionFieldPath<Field> extends Path
1010
- ? Field extends { selectedByDefault: true }
1011
- ? true
1012
- : false
1013
- : never
1014
- : never
1015
-
1016
- type DefaultProjectionPath<Field, Path extends string = ProjectionFieldPath<Field>> = Path extends unknown
1017
- ? [ProjectionDefaultAtPath<Field, Path>] extends [never]
1018
- ? never
1019
- : ProjectionDefaultAtPath<Field, Path> extends true
1020
- ? Path
1021
- : never
1022
- : never
1023
-
1024
- type DefaultProjectionField<Field> = ProjectionFieldByPath<Field, DefaultProjectionPath<Field>>
1025
-
1026
- type SelectedProjectionField<Definition extends GraphDefinitionInput, Operation> = [Operation] extends [undefined]
1027
- ? DefaultProjectionField<DefinitionProjectionField<Definition>>
1028
- : Operation extends { select: readonly (infer Path extends string)[] }
1029
- ? ProjectionFieldByPath<DefinitionProjectionField<Definition>, Path>
1030
- : DefaultProjectionField<DefinitionProjectionField<Definition>>
1031
-
1032
- type ProjectionObjectForField<Object, Field> = Object extends ProjectionObjectDefinition
1033
- ? Field extends ProjectionFieldDefinition
1034
- ? ProjectionFieldPath<Field> extends `${ProjectionObjectPath<Object>}.${string}`
1035
- ? Object
1036
- : never
1037
- : never
1038
- : never
1039
-
1040
- type SelectedProjectionObject<Definition extends GraphDefinitionInput, Field> = ProjectionObjectForField<
1041
- DefinitionProjectionObject<Definition>,
1042
- Field
1043
- >
1044
-
1045
- type ProjectionEntry<
1046
- Definition extends GraphDefinitionInput,
1047
- Field,
1048
- TypeMap extends ScalarOutputTypeMap,
1049
- > = Field extends ProjectionFieldDefinition
1050
- ? {
1051
- path: ProjectionFieldPath<Field>
1052
- value: ProjectionFieldValue<Definition, Field, TypeMap>
1053
- }
1054
- : never
1055
-
1056
- type ProjectionObjectEntry<Definition extends GraphDefinitionInput, Object> = Object extends ProjectionObjectDefinition
1057
- ? {
1058
- path: ProjectionObjectPath<Object>
1059
- nullable: ProjectionObjectIsNullable<Definition, Object>
1060
- }
1061
- : never
1062
-
1063
- type ProjectionEntryHead<Entry> = Entry extends { path: infer Path extends string }
1064
- ? Path extends `${infer Head}.${string}`
1065
- ? Head
1066
- : Path
1067
- : never
1068
-
1069
- type DirectProjectionEntryValue<Entry, Key extends string> = Entry extends {
1070
- path: infer Path extends string
1071
- value: infer Value
1072
- }
1073
- ? Path extends Key
1074
- ? Value
1075
- : never
1076
- : never
1077
-
1078
- type NestedProjectionEntry<Entry, Key extends string> = Entry extends {
1079
- path: infer Path extends string
1080
- value: infer Value
1081
- }
1082
- ? Path extends `${Key}.${infer Rest}`
1083
- ? { path: Rest; value: Value }
1084
- : never
1085
- : never
1086
-
1087
- type DirectProjectionObjectNullable<ObjectEntry, Key extends string> = ObjectEntry extends {
1088
- path: infer Path extends string
1089
- nullable: infer Nullable extends boolean
1090
- }
1091
- ? Path extends Key
1092
- ? Nullable
1093
- : never
1094
- : never
1095
-
1096
- type NestedProjectionObjectEntry<ObjectEntry, Key extends string> = ObjectEntry extends {
1097
- path: infer Path extends string
1098
- nullable: infer Nullable extends boolean
1099
- }
1100
- ? Path extends `${Key}.${infer Rest}`
1101
- ? { path: Rest; nullable: Nullable }
1102
- : never
1103
- : never
1104
-
1105
- type ApplyProjectionObjectNullability<Value, ObjectEntry, Key extends string> =
1106
- true extends DirectProjectionObjectNullable<ObjectEntry, Key> ? Value | null : Value
1107
-
1108
- type ProjectionValueAtKeyWithoutObject<Entry, ObjectEntry, Key extends string> = [
1109
- NestedProjectionEntry<Entry, Key>,
1110
- ] extends [never]
1111
- ? DirectProjectionEntryValue<Entry, Key>
1112
- : [DirectProjectionEntryValue<Entry, Key>] extends [never]
1113
- ? BuildProjectionResult<NestedProjectionEntry<Entry, Key>, NestedProjectionObjectEntry<ObjectEntry, Key>>
1114
- :
1115
- | DirectProjectionEntryValue<Entry, Key>
1116
- | BuildProjectionResult<NestedProjectionEntry<Entry, Key>, NestedProjectionObjectEntry<ObjectEntry, Key>>
1117
-
1118
- type ProjectionValueAtKey<Entry, ObjectEntry, Key extends string> = ApplyProjectionObjectNullability<
1119
- ProjectionValueAtKeyWithoutObject<Entry, ObjectEntry, Key>,
1120
- ObjectEntry,
1121
- Key
1122
- >
1123
-
1124
- type BuildProjectionResult<Entry, ObjectEntry = never> = [Entry] extends [never]
1125
- ? Record<never, never>
1126
- : {
1127
- [Key in ProjectionEntryHead<Entry>]: ProjectionValueAtKey<Entry, ObjectEntry, Key>
1128
- }
1129
-
1130
- export type ResultOf<
1131
- Subject extends GraphDefinitionInput | QueryGraph | RelationalQueryGraph | ComposedQueryGraph,
1132
- Operation = undefined,
1133
- TypeMap extends ScalarOutputTypeMap = DefaultScalarOutputTypeMap,
1134
- > =
1135
- Subject extends ComposedQueryGraph<infer Root, infer Relations>
1136
- ? ComposedResult<Root, Relations, Operation, TypeMap>
1137
- : DefinitionOf<
1138
- Extract<Subject, GraphDefinitionInput | QueryGraph | RelationalQueryGraph>
1139
- > extends infer Definition extends GraphDefinitionInput
1140
- ? SelectedProjectionField<Definition, Operation> extends infer Field
1141
- ? BuildProjectionResult<
1142
- ProjectionEntry<Definition, Field, TypeMap>,
1143
- ProjectionObjectEntry<Definition, SelectedProjectionObject<Definition, Field>>
1144
- >
1145
- : never
1146
- : never
1147
-
1148
- type SelectedPaths<Operation> = Operation extends { select: readonly (infer Path extends string)[] } ? Path : never
1149
-
1150
- type RootOperation<Operation, Relations extends readonly BatchRelation[]> = Operation extends {
1151
- select: readonly string[]
1152
- }
1153
- ? { select: readonly Exclude<SelectedPaths<Operation>, ChildPaths<Relations>>[] }
1154
- : undefined
1155
-
1156
- type SelectedChildPath<Operation, Name extends string> =
1157
- Extract<SelectedPaths<Operation>, `${Name}.${string}`> extends `${Name}.${infer Path}` ? Path : never
1158
-
1159
- type ChildOperation<Operation, Name extends string> = {
1160
- select: readonly SelectedChildPath<Operation, Name>[]
1161
- }
1162
-
1163
- type SelectedRelationCandidate<Relation extends BatchRelation, Operation> = Relation extends BatchRelation
1164
- ? Extract<SelectedPaths<Operation>, `${Relation['name']}.${string}`> extends never
1165
- ? never
1166
- : Relation
1167
- : never
1168
-
1169
- type SelectedRelation<Relations extends readonly BatchRelation[], Operation> = SelectedRelationCandidate<
1170
- Relations[number],
1171
- Operation
1172
- >
1173
-
1174
- type BatchResult<Relation extends BatchRelation, Operation, TypeMap extends ScalarOutputTypeMap> =
1175
- ResultOf<BatchQueryGraph<Relation['query']>, ChildOperation<Operation, Relation['name']>, TypeMap> extends infer Child
1176
- ? Relation['cardinality'] extends 'many'
1177
- ? Child[]
1178
- : Child | null
1179
- : never
1180
-
1181
- type ComposedResult<
1182
- Root extends RelationalQueryGraph,
1183
- Relations extends readonly BatchRelation[],
1184
- Operation,
1185
- TypeMap extends ScalarOutputTypeMap,
1186
- > = ResultOf<Root, RootOperation<Operation, Relations>, TypeMap> & {
1187
- [Relation in SelectedRelation<Relations, Operation> as Relation['name']]: BatchResult<Relation, Operation, TypeMap>
1188
- }
1189
-
1190
- export type SqlServerVersion = '2008' | '2012' | '2016' | '2019' | '2022'
1191
- export type OracleVersion = '11g' | '12c' | '19c' | '21c' | '23ai'
1192
-
1193
- export interface SqlServerCompileOptions {
1194
- version?: SqlServerVersion
1195
- }
1196
-
1197
- export interface OracleCompileOptions {
1198
- version?: OracleVersion
1199
- }
1200
-
1201
- export type QueryGraphErrorPhase = 'definition' | 'mapping' | 'composition' | 'operation' | 'sql'
1202
-
1203
- export interface QueryGraphDiagnostic {
1204
- code: string
1205
- location: string
1206
- message: string
1207
- }
1208
-
1209
- export interface QueryGraphError extends Error {
1210
- readonly name: 'QueryGraphError'
1211
- readonly code: string
1212
- readonly phase: QueryGraphErrorPhase
1213
- readonly issues: readonly QueryGraphDiagnostic[]
1214
- }
1215
-
1216
- export interface FieldSpecDefinition<
1217
- Type extends ScalarType = ScalarType,
1218
- Nullable extends boolean = boolean,
1219
- Selectable extends boolean = boolean,
1220
- > {
1221
- scalarType: Type
1222
- nullable?: Nullable
1223
- selectable?: Selectable
1224
- }
1225
-
1226
- export type FieldSpec = ScalarType | FieldSpecDefinition
1227
- export type FieldSpecMap = Record<string, FieldSpec>
1228
-
1229
- export type FieldSpecScalarType<Specification extends FieldSpec> = Specification extends ScalarType
1230
- ? Specification
1231
- : Specification extends FieldSpecDefinition<infer Type, infer _Nullable, infer _Selectable>
1232
- ? Type
1233
- : never
1234
-
1235
- export type FieldSpecIsNullable<Specification extends FieldSpec> = Specification extends ScalarType
1236
- ? false
1237
- : Specification extends FieldSpecDefinition<infer _Type, infer Nullable, infer _Selectable>
1238
- ? Nullable
1239
- : boolean
1240
-
1241
- export type FieldSpecIsSelectable<Specification extends FieldSpec> = Specification extends ScalarType
1242
- ? true
1243
- : Specification extends FieldSpecDefinition<infer _Type, infer _Nullable, infer Selectable>
1244
- ? Selectable
1245
- : boolean
1246
-
1247
- export interface SourceRef<Key extends string = string, Fields extends FieldSpecMap = FieldSpecMap>
1248
- extends SourceDefinition {
1249
- key: Key
1250
- field<Name extends Extract<keyof Fields, string>>(
1251
- name: Name,
1252
- ): TypedExpression<
1253
- FieldExpression<Key, Name>,
1254
- FieldSpecScalarType<Fields[Name]>,
1255
- SourceFieldNullability<Key, FieldSpecIsNullable<Fields[Name]>>
1256
- >
1257
- }
1258
-
1259
- export interface ScalarParameterRef<
1260
- Name extends string = string,
1261
- Type extends ScalarType = ScalarType,
1262
- Required extends boolean = boolean,
1263
- > extends ParameterDefinition {
1264
- name: Name
1265
- scalarType: Type
1266
- shape?: 'scalar'
1267
- required?: Required
1268
- }
1269
-
1270
- export interface ListParameterRef<
1271
- Name extends string = string,
1272
- Type extends ScalarType = ScalarType,
1273
- Required extends boolean = boolean,
1274
- > extends ParameterDefinition {
1275
- name: Name
1276
- scalarType: Type
1277
- shape: 'list'
1278
- required?: Required
1279
- }
1280
-
1281
- export type ParameterRef<
1282
- Name extends string = string,
1283
- Type extends ScalarType = ScalarType,
1284
- Required extends boolean = boolean,
1285
- > = ScalarParameterRef<Name, Type, Required> | ListParameterRef<Name, Type, Required>
1286
-
1287
- export type RelationRef<
1288
- Name extends string = string,
1289
- From extends string = string,
1290
- To extends string = string,
1291
- Required extends boolean = boolean,
1292
- Cardinality extends RelationCardinality = RelationCardinality,
1293
- > = RelationDefinition<Name, From, To, Required, Cardinality>
1294
-
1295
- export type LiteralInput = null | boolean | string | number
1296
- export type ExpressionInput = Expression | LiteralInput | SummaryFieldDefinition
1297
-
1298
- type NumberLiteralScalarType<Value extends number> = number extends Value
1299
- ? 'int64' | 'decimal'
1300
- : `${Value}` extends `${bigint}`
1301
- ? 'int64'
1302
- : 'decimal'
1303
-
1304
- type InputScalarType<Input extends ExpressionInput> =
1305
- Input extends ExpressionTypeMetadata<infer Type, infer _Nullability>
1306
- ? Type
1307
- : Input extends ProjectionFieldDefinition<infer _Path, infer Type, infer _Nullability, infer _SelectedByDefault>
1308
- ? Type
1309
- : Input extends null
1310
- ? null
1311
- : Input extends boolean
1312
- ? 'boolean'
1313
- : Input extends string
1314
- ? 'string'
1315
- : Input extends number
1316
- ? NumberLiteralScalarType<Input>
1317
- : ScalarType
1318
-
1319
- type InputNullability<Input extends ExpressionInput> =
1320
- Input extends ExpressionTypeMetadata<infer _Type, infer Nullability>
1321
- ? Nullability
1322
- : Input extends ProjectionFieldDefinition<infer _Path, infer _Type, infer Nullability, infer _SelectedByDefault>
1323
- ? Nullability
1324
- : Input extends null
1325
- ? true
1326
- : Input extends Expression
1327
- ? boolean
1328
- : false
1329
-
1330
- export type ExpressionScalarType<Input extends ExpressionInput> = InputScalarType<Input>
1331
- export type ExpressionNullability<Input extends ExpressionInput> = InputNullability<Input>
1332
-
1333
- type PromoteScalarType<Type extends ScalarType | null> = 'float64' extends Type
1334
- ? 'float64'
1335
- : 'decimal' extends Type
1336
- ? 'decimal'
1337
- : 'int64' extends Type
1338
- ? 'int64'
1339
- : 'int32' extends Type
1340
- ? 'int32'
1341
- : 'dateTime' extends Type
1342
- ? 'dateTime'
1343
- : Exclude<Type, null>
1344
-
1345
- type AverageScalarType<Type extends ScalarType | null> = Type extends 'float64'
1346
- ? 'float64'
1347
- : Type extends 'int32' | 'int64' | 'decimal'
1348
- ? 'decimal'
1349
- : Exclude<Type, null>
1350
-
1351
- type InputNullabilities<Inputs extends readonly ExpressionInput[]> = {
1352
- [Index in keyof Inputs]: InputNullability<Inputs[Index]>
1353
- }
1354
-
1355
- type AnyInputNullability<Inputs extends readonly ExpressionInput[]> = AnyNullability<InputNullabilities<Inputs>>
1356
- type AllInputNullability<Inputs extends readonly ExpressionInput[]> = AllNullability<InputNullabilities<Inputs>>
1357
-
1358
- export interface FieldTypeOptions {
1359
- nullable?: boolean
1360
- selectable?: boolean
1361
- }
1362
-
1363
- type OptionNullable<Options extends FieldTypeOptions> = Options extends { nullable: true } ? true : false
1364
- type OptionSelectable<Options extends FieldTypeOptions> = Options extends { selectable: false } ? false : true
1365
-
1366
- export function fieldType<const Type extends ScalarType, const Options extends FieldTypeOptions = Record<never, never>>(
1367
- scalarType: Type,
1368
- options?: Options,
1369
- ): FieldSpecDefinition<Type, OptionNullable<Options>, OptionSelectable<Options>>
1370
- export function nullable<const Specification extends FieldSpec>(
1371
- specification: Specification,
1372
- ): FieldSpecDefinition<FieldSpecScalarType<Specification>, true, FieldSpecIsSelectable<Specification>>
1373
- export function hidden<const Specification extends FieldSpec>(
1374
- specification: Specification,
1375
- ): FieldSpecDefinition<FieldSpecScalarType<Specification>, FieldSpecIsNullable<Specification>, false>
1376
-
1377
- export function source<const Key extends string, const Fields extends FieldSpecMap>(
1378
- key: Key,
1379
- fields: Fields,
1380
- ): SourceRef<Key, Fields>
1381
-
1382
- export function requiredParameter<const Name extends string, const Type extends ScalarType>(
1383
- name: Name,
1384
- scalarType: Type,
1385
- ): ScalarParameterRef<Name, Type, true>
1386
- export function optionalParameter<const Name extends string, const Type extends ScalarType>(
1387
- name: Name,
1388
- scalarType: Type,
1389
- ): ScalarParameterRef<Name, Type, false>
1390
- export function requiredListParameter<const Name extends string, const Type extends ScalarType>(
1391
- name: Name,
1392
- scalarType: Type,
1393
- ): ListParameterRef<Name, Type, true>
1394
- export function optionalListParameter<const Name extends string, const Type extends ScalarType>(
1395
- name: Name,
1396
- scalarType: Type,
1397
- ): ListParameterRef<Name, Type, false>
1398
- export function param<const Name extends string, const Type extends ScalarType>(
1399
- parameter: ScalarParameterRef<Name, Type>,
1400
- ): TypedExpression<ParameterExpression<Name>, Type, false>
1401
-
1402
- export function literal<const Value extends LiteralInput>(
1403
- value: Value,
1404
- ): TypedExpression<LiteralExpression, InputScalarType<Value>, InputNullability<Value>>
1405
- export function integer(value: number): TypedExpression<LiteralExpression, 'int64', false>
1406
- export function decimal(value: string | number): TypedExpression<LiteralExpression, 'decimal', false>
1407
-
1408
- type EqualityNullability<Left extends ExpressionInput, Right extends ExpressionInput> = null extends
1409
- | InputScalarType<Left>
1410
- | InputScalarType<Right>
1411
- ? false
1412
- : AnyInputNullability<readonly [Left, Right]>
1413
-
1414
- export function eq<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1415
- left: Left,
1416
- right: Right,
1417
- ): TypedExpression<BinaryExpression, 'boolean', EqualityNullability<Left, Right>>
1418
- export function neq<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1419
- left: Left,
1420
- right: Right,
1421
- ): TypedExpression<BinaryExpression, 'boolean', EqualityNullability<Left, Right>>
1422
- export function lt<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1423
- left: Left,
1424
- right: Right,
1425
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1426
- export function lte<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1427
- left: Left,
1428
- right: Right,
1429
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1430
- export function gt<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1431
- left: Left,
1432
- right: Right,
1433
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1434
- export function gte<const Left extends ExpressionInput, const Right extends ExpressionInput>(
1435
- left: Left,
1436
- right: Right,
1437
- ): TypedExpression<BinaryExpression, 'boolean', AnyInputNullability<readonly [Left, Right]>>
1438
- export function like<const Value extends ExpressionInput, const Pattern extends ExpressionInput>(
1439
- expression: Value,
1440
- pattern: Pattern,
1441
- ): TypedExpression<LikeExpression, 'boolean', AnyInputNullability<readonly [Value, Pattern]>>
1442
- export function inList<const Value extends ExpressionInput, const Values extends readonly ExpressionInput[]>(
1443
- expression: Value,
1444
- values: Values,
1445
- ): TypedExpression<InExpression, 'boolean', AnyInputNullability<readonly [Value, ...Values]>>
1446
- export function and<const Expressions extends readonly ExpressionInput[]>(
1447
- ...expressions: Expressions
1448
- ): TypedExpression<ExpressionGroup, 'boolean', AnyInputNullability<Expressions>>
1449
- export function inParameter<
1450
- const Value extends ExpressionInput,
1451
- const Name extends string,
1452
- const Type extends ScalarType,
1453
- >(
1454
- expression: Value,
1455
- parameter: ListParameterRef<Name, Type>,
1456
- ): TypedExpression<InParameterExpression<Name>, 'boolean', InputNullability<Value>>
1457
- export function or<const Expressions extends readonly ExpressionInput[]>(
1458
- ...expressions: Expressions
1459
- ): TypedExpression<ExpressionGroup, 'boolean', AnyInputNullability<Expressions>>
1460
- export function not<const Value extends ExpressionInput>(
1461
- expression: Value,
1462
- ): TypedExpression<UnaryExpression, 'boolean', InputNullability<Value>>
1463
- export function isNull(expression: ExpressionInput): TypedExpression<UnaryExpression, 'boolean', false>
1464
- export function isNotNull(expression: ExpressionInput): TypedExpression<UnaryExpression, 'boolean', false>
1465
- export function exists<const Source extends string>(
1466
- source: Source | SourceRef<Source>,
1467
- predicate?: ExpressionInput,
1468
- ): TypedExpression<ExistsExpression<Source, never>, 'boolean', false>
1469
- export interface ExistsConfiguration<From extends string = string> {
1470
- from: From | SourceRef<From>
1471
- }
1472
- export function exists<const Source extends string, const From extends string>(
1473
- source: Source | SourceRef<Source>,
1474
- predicate: ExpressionInput | undefined,
1475
- configuration: ExistsConfiguration<From>,
1476
- ): TypedExpression<ExistsExpression<Source, From>, 'boolean', false>
1477
-
1478
- export function lower<const Value extends ExpressionInput>(
1479
- expression: Value,
1480
- ): TypedExpression<FunctionExpression, 'string', InputNullability<Value>>
1481
- export function upper<const Value extends ExpressionInput>(
1482
- expression: Value,
1483
- ): TypedExpression<FunctionExpression, 'string', InputNullability<Value>>
1484
- export function coalesce<
1485
- const First extends ExpressionInput,
1486
- const Second extends ExpressionInput,
1487
- const Rest extends readonly ExpressionInput[],
1488
- >(
1489
- first: First,
1490
- second: Second,
1491
- ...rest: Rest
1492
- ): 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,
1493
33
  FunctionExpression,
1494
- PromoteScalarType<InputScalarType<First | Second | Rest[number]>>,
1495
- AllInputNullability<readonly [First, Second, ...Rest]>
1496
- >
1497
- export function concat<const First extends ExpressionInput, const Rest extends readonly ExpressionInput[]>(
1498
- first: First,
1499
- ...rest: Rest
1500
- ): TypedExpression<FunctionExpression, 'string', AllInputNullability<readonly [First, ...Rest]>>
1501
-
1502
- export function count(expression?: ExpressionInput): TypedExpression<AggregateExpression, 'int64', false>
1503
- export function countDistinct(expression: ExpressionInput): TypedExpression<AggregateExpression, 'int64', false>
1504
- export function sum<const Value extends ExpressionInput>(
1505
- expression: Value,
1506
- ): TypedExpression<AggregateExpression, Exclude<InputScalarType<Value>, null>, true>
1507
- export function average<const Value extends ExpressionInput>(
1508
- expression: Value,
1509
- ): TypedExpression<AggregateExpression, AverageScalarType<InputScalarType<Value>>, true>
1510
- export function minimum<const Value extends ExpressionInput>(
1511
- expression: Value,
1512
- ): TypedExpression<AggregateExpression, Exclude<InputScalarType<Value>, null>, true>
1513
- export function maximum<const Value extends ExpressionInput>(
1514
- expression: Value,
1515
- ): TypedExpression<AggregateExpression, Exclude<InputScalarType<Value>, null>, true>
1516
-
1517
- export type SourceReferenceKey<Reference extends string | SourceRef> =
1518
- Reference extends SourceRef<infer Key, infer _Fields> ? Key : Reference extends string ? Reference : string
1519
-
1520
- export interface RelationConfiguration<
1521
- Name extends string = string,
1522
- From extends string | SourceRef = string | SourceRef,
1523
- To extends string | SourceRef = string | SourceRef,
1524
- Required extends boolean = boolean,
1525
- Cardinality extends RelationCardinality = RelationCardinality,
1526
- > {
1527
- name: Name
1528
- from: From
1529
- to: To
1530
- on: Expression
1531
- required?: Required
1532
- cardinality?: Cardinality
1533
- selection?: RelationSelection
1534
- }
1535
-
1536
- export function relation<
1537
- const Name extends string,
1538
- const From extends string | SourceRef,
1539
- const To extends string | SourceRef,
1540
- const Required extends boolean = false,
1541
- const Cardinality extends RelationCardinality = 'one',
1542
- >(
1543
- configuration: RelationConfiguration<Name, From, To, Required, Cardinality>,
1544
- ): RelationRef<Name, SourceReferenceKey<From>, SourceReferenceKey<To>, Required, Cardinality>
1545
-
1546
- export interface ConstraintConfiguration {
1547
- predicate: Expression
1548
- when?: string | ParameterRef
1549
- }
1550
-
1551
- export function constraint(configuration: ConstraintConfiguration): ConstraintDefinition
1552
-
1553
- export interface ProjectionConfiguration<
1554
- Path extends string | readonly string[] = string | readonly string[],
1555
- Value extends ExpressionInput = ExpressionInput,
1556
- SelectedByDefault extends boolean = boolean,
1557
- > {
1558
- path: Path
1559
- expression: Value
1560
- default?: SelectedByDefault
1561
- }
1562
-
1563
- export interface ProjectionObjectConfiguration<
1564
- Path extends string | readonly string[] = string | readonly string[],
1565
- Value extends ExpressionInput = ExpressionInput,
1566
- > {
1567
- path: Path
1568
- presence: Value
1569
- }
1570
-
1571
- type ConfigurationPath<Path extends string | readonly string[]> = Path extends string
1572
- ? Path
1573
- : Path extends readonly string[]
1574
- ? JoinProjectionPath<Path>
1575
- : never
1576
-
1577
- export function project<
1578
- const Path extends string | readonly string[],
1579
- const Value extends ExpressionInput,
1580
- const SelectedByDefault extends boolean = false,
1581
- >(
1582
- configuration: ProjectionConfiguration<Path, Value, SelectedByDefault>,
1583
- ): TypedProjectionField<
1584
- ConfigurationPath<Path>,
1585
- Extract<InputScalarType<Value>, ScalarType>,
1586
- InputNullability<Value>,
1587
- SelectedByDefault
1588
- >
1589
-
1590
- export function projectObject<const Path extends string | readonly string[], const Value extends ExpressionInput>(
1591
- configuration: ProjectionObjectConfiguration<Path, Value>,
1592
- ): TypedProjectionObject<ConfigurationPath<Path>, InputNullability<Value>>
1593
-
1594
- export function dimension<
1595
- const Path extends string | readonly string[],
1596
- const Value extends ExpressionInput,
1597
- const SelectedByDefault extends boolean = false,
1598
- >(
1599
- configuration: ProjectionConfiguration<Path, Value, SelectedByDefault>,
1600
- ): TypedDimensionDefinition<
1601
- ConfigurationPath<Path>,
1602
- Extract<InputScalarType<Value>, ScalarType>,
1603
- InputNullability<Value>,
1604
- SelectedByDefault
1605
- >
1606
-
1607
- export function measure<
1608
- const Path extends string | readonly string[],
1609
- const Value extends ExpressionInput,
1610
- const SelectedByDefault extends boolean = false,
1611
- >(
1612
- configuration: ProjectionConfiguration<Path, Value, SelectedByDefault>,
1613
- ): TypedMeasureDefinition<
1614
- ConfigurationPath<Path>,
1615
- Extract<InputScalarType<Value>, ScalarType>,
1616
- InputNullability<Value>,
1617
- SelectedByDefault
1618
- >
1619
-
1620
- export interface OrderByOptions {
1621
- nulls?: NullsOrder
1622
- }
1623
-
1624
- export function asc(expression: ExpressionInput, options?: OrderByOptions): OrderByDefinition
1625
- export function desc(expression: ExpressionInput, options?: OrderByOptions): OrderByDefinition
1626
-
1627
- export function firstBy(firstOrder: OrderByDefinition, ...rest: readonly OrderByDefinition[]): FirstBySelection
1628
-
1629
- export interface OrderingConfiguration<Name extends string = string> {
1630
- name: Name
1631
- by: readonly [OrderByDefinition, ...OrderByDefinition[]]
1632
- default?: boolean
1633
- }
1634
-
1635
- export function ordering<const Name extends string>(
1636
- configuration: OrderingConfiguration<Name>,
1637
- ): OrderingDefinition<Name>
1638
-
1639
- export interface GraphModuleConfiguration {
1640
- name: string
1641
- modules?: readonly GraphModule[]
1642
- sources?: readonly SourceRef[]
1643
- parameters?: readonly ParameterDefinition[]
1644
- relations?: readonly RelationDefinition[]
1645
- constraints?: readonly ConstraintDefinition[]
1646
- projection?: readonly ProjectionFieldDefinition[]
1647
- objects?: readonly ProjectionObjectDefinition[]
1648
- orderings?: readonly OrderingDefinition[]
1649
- }
1650
-
1651
- type ConfigurationElement<Configuration, Key extends PropertyKey> = Key extends keyof Configuration
1652
- ? NonNullable<Configuration[Key]> extends readonly (infer Element)[]
1653
- ? Element
1654
- : never
1655
- : never
1656
-
1657
- type ModuleParameter<Module> =
1658
- Module extends GraphModule<
1659
- infer Parameter,
1660
- infer _ProjectionPath,
1661
- infer _OrderingName,
1662
- infer _ProjectionField,
1663
- infer _Relation
1664
- >
1665
- ? Parameter
1666
- : never
1667
-
1668
- type ModuleProjectionPath<Module> =
1669
- Module extends GraphModule<
1670
- infer _Parameter,
1671
- infer ProjectionPath,
1672
- infer _OrderingName,
1673
- infer _ProjectionField,
1674
- infer _Relation
1675
- >
1676
- ? ProjectionPath
1677
- : never
1678
-
1679
- type ModuleOrderingName<Module> =
1680
- Module extends GraphModule<
1681
- infer _Parameter,
1682
- infer _ProjectionPath,
1683
- infer OrderingName,
1684
- infer _ProjectionField,
1685
- infer _Relation
1686
- >
1687
- ? OrderingName
1688
- : never
1689
-
1690
- type ModuleProjectionField<Module> =
1691
- Module extends GraphModule<
1692
- infer _Parameter,
1693
- infer _ProjectionPath,
1694
- infer _OrderingName,
1695
- infer ProjectionField,
1696
- infer _Relation
1697
- >
1698
- ? ProjectionField
1699
- : never
1700
-
1701
- type ModuleRelation<Module> =
1702
- Module extends GraphModule<
1703
- infer _Parameter,
1704
- infer _ProjectionPath,
1705
- infer _OrderingName,
1706
- infer _ProjectionField,
1707
- infer Relation
1708
- >
1709
- ? Relation
1710
- : never
1711
-
1712
- type ModuleProjectionObject<Module> =
1713
- Module extends GraphModule<
1714
- infer _Parameter,
1715
- infer _ProjectionPath,
1716
- infer _OrderingName,
1717
- infer _ProjectionField,
1718
- infer _Relation,
1719
- infer ProjectionObject
1720
- >
1721
- ? ProjectionObject
1722
- : never
1723
-
1724
- type ProjectionPathOf<Field> = Field extends ProjectionFieldDefinition<infer Path> ? Path : never
1725
-
1726
- type OrderingNameOf<Ordering> = Ordering extends OrderingDefinition<infer Name> ? Name : never
1727
-
1728
- type ConfigurationParameter<Configuration> =
1729
- | Extract<ConfigurationElement<Configuration, 'parameters'>, ParameterDefinition>
1730
- | ModuleParameter<ConfigurationElement<Configuration, 'modules'>>
1731
-
1732
- type ConfigurationProjectionPath<Configuration> =
1733
- | ProjectionPathOf<ConfigurationElement<Configuration, 'projection'>>
1734
- | ProjectionPathOf<ConfigurationElement<Configuration, 'dimensions'>>
1735
- | ProjectionPathOf<ConfigurationElement<Configuration, 'measures'>>
1736
- | ModuleProjectionPath<ConfigurationElement<Configuration, 'modules'>>
1737
-
1738
- type ConfigurationProjectionField<Configuration> =
1739
- | Extract<ConfigurationElement<Configuration, 'projection'>, ProjectionFieldDefinition>
1740
- | Extract<ConfigurationElement<Configuration, 'dimensions'>, ProjectionFieldDefinition>
1741
- | Extract<ConfigurationElement<Configuration, 'measures'>, ProjectionFieldDefinition>
1742
- | ModuleProjectionField<ConfigurationElement<Configuration, 'modules'>>
1743
-
1744
- type ConfigurationProjectionObject<Configuration> =
1745
- | Extract<ConfigurationElement<Configuration, 'objects'>, ProjectionObjectDefinition>
1746
- | ModuleProjectionObject<ConfigurationElement<Configuration, 'modules'>>
1747
-
1748
- type ConfigurationOrderingName<Configuration> =
1749
- | OrderingNameOf<ConfigurationElement<Configuration, 'orderings'>>
1750
- | ModuleOrderingName<ConfigurationElement<Configuration, 'modules'>>
1751
-
1752
- type ConfigurationRelation<Configuration> =
1753
- | Extract<ConfigurationElement<Configuration, 'relations'>, RelationDefinition>
1754
- | ModuleRelation<ConfigurationElement<Configuration, 'modules'>>
1755
-
1756
- type ConfigurationRoot<Configuration> = Configuration extends {
1757
- root: infer Root extends string | SourceRef
1758
- }
1759
- ? SourceReferenceKey<Root>
1760
- : string
1761
-
1762
- export interface GraphModule<
1763
- Parameter extends ParameterDefinition = ParameterDefinition,
1764
- ProjectionPath extends string = string,
1765
- OrderingName extends string = string,
1766
- ProjectionField extends ProjectionFieldDefinition = ProjectionFieldDefinition<ProjectionPath>,
1767
- Relation extends RelationDefinition = RelationDefinition,
1768
- ProjectionObject extends ProjectionObjectDefinition = ProjectionObjectDefinition,
1769
- > {
1770
- readonly name: string
1771
- readonly sources: readonly SourceRef[]
1772
- readonly parameters: readonly Parameter[]
1773
- readonly relations: readonly Relation[]
1774
- readonly constraints: readonly ConstraintDefinition[]
1775
- readonly projection: readonly ProjectionField[]
1776
- readonly objects: readonly ProjectionObject[]
1777
- readonly orderings: readonly OrderingDefinition<OrderingName>[]
1778
- }
1779
-
1780
- export function defineGraphModule<const Configuration extends GraphModuleConfiguration>(
1781
- configuration: Configuration,
1782
- ): GraphModule<
1783
- ConfigurationParameter<Configuration>,
1784
- ConfigurationProjectionPath<Configuration>,
1785
- ConfigurationOrderingName<Configuration>,
1786
- ConfigurationProjectionField<Configuration>,
1787
- ConfigurationRelation<Configuration>,
1788
- ConfigurationProjectionObject<Configuration>
1789
- >
1790
-
1791
- export interface GraphConfiguration {
1792
- name: string
1793
- root: string | SourceRef
1794
- modules?: readonly GraphModule[]
1795
- sources?: readonly SourceRef[]
1796
- parameters?: readonly ParameterDefinition[]
1797
- relations?: readonly RelationDefinition[]
1798
- constraints?: readonly ConstraintDefinition[]
1799
- projection?: readonly ProjectionFieldDefinition[]
1800
- objects?: readonly ProjectionObjectDefinition[]
1801
- orderings?: readonly OrderingDefinition[]
1802
- }
1803
-
1804
- export function defineGraph<const Configuration extends GraphConfiguration>(
1805
- configuration: Configuration,
1806
- ): GraphDefinition<
1807
- ConfigurationParameter<Configuration>,
1808
- ConfigurationProjectionPath<Configuration>,
1809
- ConfigurationOrderingName<Configuration>,
1810
- ConfigurationProjectionField<Configuration>,
1811
- ConfigurationRelation<Configuration>,
1812
- ConfigurationRoot<Configuration>,
1813
- ConfigurationProjectionObject<Configuration>
1814
- >
1815
-
1816
- export interface SummaryGraphConfiguration {
1817
- name: string
1818
- root: string | SourceRef
1819
- modules?: readonly GraphModule[]
1820
- sources?: readonly SourceRef[]
1821
- parameters?: readonly ParameterDefinition[]
1822
- relations?: readonly RelationDefinition[]
1823
- constraints?: readonly ConstraintDefinition[]
1824
- dimensions?: readonly DimensionDefinition[]
1825
- measures?: readonly MeasureDefinition[]
1826
- orderings?: readonly OrderingDefinition[]
1827
- }
1828
-
1829
- export function defineSummaryGraph<const Configuration extends SummaryGraphConfiguration>(
1830
- configuration: Configuration,
1831
- ): GraphDefinition<
1832
- ConfigurationParameter<Configuration>,
1833
- ConfigurationProjectionPath<Configuration>,
1834
- ConfigurationOrderingName<Configuration>,
1835
- ConfigurationProjectionField<Configuration>,
1836
- ConfigurationRelation<Configuration>,
1837
- ConfigurationRoot<Configuration>,
1838
- never
1839
- >
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'