@query-graph/core 1.0.0-next.1
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/LICENSE +21 -0
- package/README.md +620 -0
- package/definition.d.ts +87 -0
- package/definition.js +112 -0
- package/dsl.d.ts +687 -0
- package/dsl.js +742 -0
- package/index.d.ts +60 -0
- package/index.js +562 -0
- package/package.json +143 -0
package/definition.d.ts
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
export * from './dsl.js'
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
ConstraintDefinition,
|
|
5
|
+
DimensionDefinition,
|
|
6
|
+
Expression,
|
|
7
|
+
ExpressionInput,
|
|
8
|
+
FieldExpression,
|
|
9
|
+
FieldSpecMap,
|
|
10
|
+
JoinProjectionPath,
|
|
11
|
+
MeasureDefinition,
|
|
12
|
+
ParameterRef,
|
|
13
|
+
ProjectionFieldDefinition,
|
|
14
|
+
RelationCardinality,
|
|
15
|
+
RelationRef,
|
|
16
|
+
RelationSelection,
|
|
17
|
+
SourceRef,
|
|
18
|
+
} from './dsl.js'
|
|
19
|
+
|
|
20
|
+
export const GRAPH_DEFINITION_VERSION: 9
|
|
21
|
+
|
|
22
|
+
export function field<
|
|
23
|
+
const Key extends string,
|
|
24
|
+
const Fields extends FieldSpecMap,
|
|
25
|
+
const Name extends Extract<keyof Fields, string>,
|
|
26
|
+
>(source: SourceRef<Key, Fields>, name: Name): FieldExpression<Key, Name>
|
|
27
|
+
export function field<const Source extends string, const Name extends string>(
|
|
28
|
+
source: Source,
|
|
29
|
+
name: Name,
|
|
30
|
+
): FieldExpression<Source, Name>
|
|
31
|
+
|
|
32
|
+
export interface RelationOptions {
|
|
33
|
+
required?: boolean
|
|
34
|
+
cardinality?: RelationCardinality
|
|
35
|
+
selection?: RelationSelection
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function relation<const Name extends string>(
|
|
39
|
+
name: Name,
|
|
40
|
+
from: string | SourceRef,
|
|
41
|
+
to: string | SourceRef,
|
|
42
|
+
on: Expression,
|
|
43
|
+
options?: RelationOptions,
|
|
44
|
+
): RelationRef<Name>
|
|
45
|
+
|
|
46
|
+
export interface ConstraintOptions {
|
|
47
|
+
when?: string | ParameterRef
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function constraint(predicate: Expression, options?: ConstraintOptions): ConstraintDefinition
|
|
51
|
+
|
|
52
|
+
export interface ProjectionOptions {
|
|
53
|
+
default?: boolean
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function project<const Path extends string>(
|
|
57
|
+
path: Path,
|
|
58
|
+
expression: ExpressionInput,
|
|
59
|
+
options?: ProjectionOptions,
|
|
60
|
+
): ProjectionFieldDefinition<Path>
|
|
61
|
+
export function project<const Path extends readonly string[]>(
|
|
62
|
+
path: Path,
|
|
63
|
+
expression: ExpressionInput,
|
|
64
|
+
options?: ProjectionOptions,
|
|
65
|
+
): ProjectionFieldDefinition<JoinProjectionPath<Path>>
|
|
66
|
+
|
|
67
|
+
export function dimension<const Path extends string>(
|
|
68
|
+
path: Path,
|
|
69
|
+
expression: ExpressionInput,
|
|
70
|
+
options?: ProjectionOptions,
|
|
71
|
+
): DimensionDefinition<Path>
|
|
72
|
+
export function dimension<const Path extends readonly string[]>(
|
|
73
|
+
path: Path,
|
|
74
|
+
expression: ExpressionInput,
|
|
75
|
+
options?: ProjectionOptions,
|
|
76
|
+
): DimensionDefinition<JoinProjectionPath<Path>>
|
|
77
|
+
|
|
78
|
+
export function measure<const Path extends string>(
|
|
79
|
+
path: Path,
|
|
80
|
+
expression: ExpressionInput,
|
|
81
|
+
options?: ProjectionOptions,
|
|
82
|
+
): MeasureDefinition<Path>
|
|
83
|
+
export function measure<const Path extends readonly string[]>(
|
|
84
|
+
path: Path,
|
|
85
|
+
expression: ExpressionInput,
|
|
86
|
+
options?: ProjectionOptions,
|
|
87
|
+
): MeasureDefinition<JoinProjectionPath<Path>>
|
package/definition.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const objectDsl = require('./dsl.js')
|
|
4
|
+
|
|
5
|
+
const GRAPH_DEFINITION_VERSION = 9
|
|
6
|
+
|
|
7
|
+
function field(sourceReference, name) {
|
|
8
|
+
if (typeof sourceReference === 'string') {
|
|
9
|
+
return {
|
|
10
|
+
kind: 'field',
|
|
11
|
+
source: sourceReference,
|
|
12
|
+
field: name,
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return sourceReference.field(name)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function relation(name, from, to, on, options = {}) {
|
|
20
|
+
return objectDsl.relation({
|
|
21
|
+
name,
|
|
22
|
+
from,
|
|
23
|
+
to,
|
|
24
|
+
on,
|
|
25
|
+
required: options.required,
|
|
26
|
+
cardinality: options.cardinality,
|
|
27
|
+
selection: options.selection,
|
|
28
|
+
})
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function constraint(predicate, options = {}) {
|
|
32
|
+
return objectDsl.constraint({
|
|
33
|
+
predicate,
|
|
34
|
+
when: options.when,
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function project(path, expression, options = {}) {
|
|
39
|
+
return objectDsl.project({
|
|
40
|
+
path,
|
|
41
|
+
expression,
|
|
42
|
+
default: options.default,
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function dimension(path, expression, options = {}) {
|
|
47
|
+
return objectDsl.dimension({
|
|
48
|
+
path,
|
|
49
|
+
expression,
|
|
50
|
+
default: options.default,
|
|
51
|
+
})
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function measure(path, expression, options = {}) {
|
|
55
|
+
return objectDsl.measure({
|
|
56
|
+
path,
|
|
57
|
+
expression,
|
|
58
|
+
default: options.default,
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
exports.GRAPH_DEFINITION_VERSION = GRAPH_DEFINITION_VERSION
|
|
63
|
+
exports.fieldType = objectDsl.fieldType
|
|
64
|
+
exports.nullable = objectDsl.nullable
|
|
65
|
+
exports.hidden = objectDsl.hidden
|
|
66
|
+
exports.source = objectDsl.source
|
|
67
|
+
exports.field = field
|
|
68
|
+
exports.requiredParameter = objectDsl.requiredParameter
|
|
69
|
+
exports.optionalParameter = objectDsl.optionalParameter
|
|
70
|
+
exports.param = objectDsl.param
|
|
71
|
+
exports.literal = objectDsl.literal
|
|
72
|
+
exports.integer = objectDsl.integer
|
|
73
|
+
exports.decimal = objectDsl.decimal
|
|
74
|
+
exports.requiredListParameter = objectDsl.requiredListParameter
|
|
75
|
+
exports.optionalListParameter = objectDsl.optionalListParameter
|
|
76
|
+
exports.eq = objectDsl.eq
|
|
77
|
+
exports.neq = objectDsl.neq
|
|
78
|
+
exports.lt = objectDsl.lt
|
|
79
|
+
exports.lte = objectDsl.lte
|
|
80
|
+
exports.gt = objectDsl.gt
|
|
81
|
+
exports.gte = objectDsl.gte
|
|
82
|
+
exports.like = objectDsl.like
|
|
83
|
+
exports.inList = objectDsl.inList
|
|
84
|
+
exports.and = objectDsl.and
|
|
85
|
+
exports.or = objectDsl.or
|
|
86
|
+
exports.not = objectDsl.not
|
|
87
|
+
exports.isNull = objectDsl.isNull
|
|
88
|
+
exports.isNotNull = objectDsl.isNotNull
|
|
89
|
+
exports.inParameter = objectDsl.inParameter
|
|
90
|
+
exports.exists = objectDsl.exists
|
|
91
|
+
exports.lower = objectDsl.lower
|
|
92
|
+
exports.upper = objectDsl.upper
|
|
93
|
+
exports.coalesce = objectDsl.coalesce
|
|
94
|
+
exports.concat = objectDsl.concat
|
|
95
|
+
exports.count = objectDsl.count
|
|
96
|
+
exports.countDistinct = objectDsl.countDistinct
|
|
97
|
+
exports.sum = objectDsl.sum
|
|
98
|
+
exports.average = objectDsl.average
|
|
99
|
+
exports.minimum = objectDsl.minimum
|
|
100
|
+
exports.maximum = objectDsl.maximum
|
|
101
|
+
exports.relation = relation
|
|
102
|
+
exports.constraint = constraint
|
|
103
|
+
exports.ordering = objectDsl.ordering
|
|
104
|
+
exports.project = project
|
|
105
|
+
exports.dimension = dimension
|
|
106
|
+
exports.measure = measure
|
|
107
|
+
exports.asc = objectDsl.asc
|
|
108
|
+
exports.desc = objectDsl.desc
|
|
109
|
+
exports.defineGraphModule = objectDsl.defineGraphModule
|
|
110
|
+
exports.defineGraph = objectDsl.defineGraph
|
|
111
|
+
exports.defineSummaryGraph = objectDsl.defineSummaryGraph
|
|
112
|
+
exports.firstBy = objectDsl.firstBy
|