@_linked/core 1.1.0 → 1.2.0-next.20260303081922
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/CHANGELOG.md +68 -0
- package/README.md +321 -43
- package/lib/cjs/index.js +4 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/IQuadStore.d.ts +19 -7
- package/lib/cjs/queries/CreateQuery.d.ts +7 -8
- package/lib/cjs/queries/CreateQuery.js +4 -4
- package/lib/cjs/queries/CreateQuery.js.map +1 -1
- package/lib/cjs/queries/DeleteQuery.d.ts +7 -8
- package/lib/cjs/queries/DeleteQuery.js +4 -4
- package/lib/cjs/queries/DeleteQuery.js.map +1 -1
- package/lib/cjs/queries/IRAliasScope.d.ts +20 -0
- package/lib/cjs/queries/IRAliasScope.js +52 -0
- package/lib/cjs/queries/IRAliasScope.js.map +1 -0
- package/lib/cjs/queries/IRCanonicalize.d.ts +36 -0
- package/lib/cjs/queries/IRCanonicalize.js +121 -0
- package/lib/cjs/queries/IRCanonicalize.js.map +1 -0
- package/lib/cjs/queries/IRDesugar.d.ts +98 -0
- package/lib/cjs/queries/IRDesugar.js +244 -0
- package/lib/cjs/queries/IRDesugar.js.map +1 -0
- package/lib/cjs/queries/IRLower.d.ts +8 -0
- package/lib/cjs/queries/IRLower.js +268 -0
- package/lib/cjs/queries/IRLower.js.map +1 -0
- package/lib/cjs/queries/IRMutation.d.ts +23 -0
- package/lib/cjs/queries/IRMutation.js +77 -0
- package/lib/cjs/queries/IRMutation.js.map +1 -0
- package/lib/cjs/queries/IRPipeline.d.ts +8 -0
- package/lib/cjs/queries/IRPipeline.js +25 -0
- package/lib/cjs/queries/IRPipeline.js.map +1 -0
- package/lib/cjs/queries/IRProjection.d.ts +38 -0
- package/lib/cjs/queries/IRProjection.js +98 -0
- package/lib/cjs/queries/IRProjection.js.map +1 -0
- package/lib/cjs/queries/IntermediateRepresentation.d.ts +210 -0
- package/lib/cjs/queries/IntermediateRepresentation.js +3 -0
- package/lib/cjs/queries/IntermediateRepresentation.js.map +1 -0
- package/lib/cjs/queries/MutationQuery.js +9 -23
- package/lib/cjs/queries/MutationQuery.js.map +1 -1
- package/lib/cjs/queries/QueryFactory.d.ts +0 -2
- package/lib/cjs/queries/QueryFactory.js +0 -3
- package/lib/cjs/queries/QueryFactory.js.map +1 -1
- package/lib/cjs/queries/QueryParser.d.ts +6 -1
- package/lib/cjs/queries/QueryParser.js +14 -22
- package/lib/cjs/queries/QueryParser.js.map +1 -1
- package/lib/cjs/queries/SelectQuery.d.ts +18 -27
- package/lib/cjs/queries/SelectQuery.js +54 -45
- package/lib/cjs/queries/SelectQuery.js.map +1 -1
- package/lib/cjs/queries/UpdateQuery.d.ts +8 -9
- package/lib/cjs/queries/UpdateQuery.js +4 -4
- package/lib/cjs/queries/UpdateQuery.js.map +1 -1
- package/lib/cjs/shapes/SHACL.d.ts +1 -0
- package/lib/cjs/shapes/SHACL.js +82 -2
- package/lib/cjs/shapes/SHACL.js.map +1 -1
- package/lib/cjs/shapes/Shape.d.ts +11 -10
- package/lib/cjs/shapes/Shape.js +11 -5
- package/lib/cjs/shapes/Shape.js.map +1 -1
- package/lib/cjs/sparql/SparqlAlgebra.d.ts +158 -0
- package/lib/cjs/sparql/SparqlAlgebra.js +4 -0
- package/lib/cjs/sparql/SparqlAlgebra.js.map +1 -0
- package/lib/cjs/sparql/SparqlStore.d.ts +52 -0
- package/lib/cjs/sparql/SparqlStore.js +81 -0
- package/lib/cjs/sparql/SparqlStore.js.map +1 -0
- package/lib/cjs/sparql/algebraToString.d.ts +13 -0
- package/lib/cjs/sparql/algebraToString.js +298 -0
- package/lib/cjs/sparql/algebraToString.js.map +1 -0
- package/lib/cjs/sparql/index.d.ts +9 -0
- package/lib/cjs/sparql/index.js +40 -0
- package/lib/cjs/sparql/index.js.map +1 -0
- package/lib/cjs/sparql/irToAlgebra.d.ts +39 -0
- package/lib/cjs/sparql/irToAlgebra.js +927 -0
- package/lib/cjs/sparql/irToAlgebra.js.map +1 -0
- package/lib/cjs/sparql/resultMapping.d.ts +36 -0
- package/lib/cjs/sparql/resultMapping.js +501 -0
- package/lib/cjs/sparql/resultMapping.js.map +1 -0
- package/lib/cjs/sparql/sparqlUtils.d.ts +32 -0
- package/lib/cjs/sparql/sparqlUtils.js +89 -0
- package/lib/cjs/sparql/sparqlUtils.js.map +1 -0
- package/lib/cjs/test-helpers/FusekiStore.d.ts +29 -0
- package/lib/cjs/test-helpers/FusekiStore.js +82 -0
- package/lib/cjs/test-helpers/FusekiStore.js.map +1 -0
- package/lib/cjs/test-helpers/fuseki-test-store.d.ts +43 -0
- package/lib/cjs/test-helpers/fuseki-test-store.js +144 -0
- package/lib/cjs/test-helpers/fuseki-test-store.js.map +1 -0
- package/lib/cjs/test-helpers/query-capture-store.d.ts +5 -0
- package/lib/cjs/test-helpers/query-capture-store.js +59 -0
- package/lib/cjs/test-helpers/query-capture-store.js.map +1 -0
- package/lib/cjs/test-helpers/query-fixtures.d.ts +736 -77
- package/lib/cjs/test-helpers/query-fixtures.js +45 -1
- package/lib/cjs/test-helpers/query-fixtures.js.map +1 -1
- package/lib/cjs/utils/LinkedStorage.d.ts +7 -7
- package/lib/cjs/utils/LinkedStorage.js +4 -3
- package/lib/cjs/utils/LinkedStorage.js.map +1 -1
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/IQuadStore.d.ts +19 -7
- package/lib/esm/queries/CreateQuery.d.ts +7 -8
- package/lib/esm/queries/CreateQuery.js +4 -4
- package/lib/esm/queries/CreateQuery.js.map +1 -1
- package/lib/esm/queries/DeleteQuery.d.ts +7 -8
- package/lib/esm/queries/DeleteQuery.js +4 -4
- package/lib/esm/queries/DeleteQuery.js.map +1 -1
- package/lib/esm/queries/IRAliasScope.d.ts +20 -0
- package/lib/esm/queries/IRAliasScope.js +47 -0
- package/lib/esm/queries/IRAliasScope.js.map +1 -0
- package/lib/esm/queries/IRCanonicalize.d.ts +36 -0
- package/lib/esm/queries/IRCanonicalize.js +116 -0
- package/lib/esm/queries/IRCanonicalize.js.map +1 -0
- package/lib/esm/queries/IRDesugar.d.ts +98 -0
- package/lib/esm/queries/IRDesugar.js +240 -0
- package/lib/esm/queries/IRDesugar.js.map +1 -0
- package/lib/esm/queries/IRLower.d.ts +8 -0
- package/lib/esm/queries/IRLower.js +264 -0
- package/lib/esm/queries/IRLower.js.map +1 -0
- package/lib/esm/queries/IRMutation.d.ts +23 -0
- package/lib/esm/queries/IRMutation.js +71 -0
- package/lib/esm/queries/IRMutation.js.map +1 -0
- package/lib/esm/queries/IRPipeline.d.ts +8 -0
- package/lib/esm/queries/IRPipeline.js +21 -0
- package/lib/esm/queries/IRPipeline.js.map +1 -0
- package/lib/esm/queries/IRProjection.d.ts +38 -0
- package/lib/esm/queries/IRProjection.js +92 -0
- package/lib/esm/queries/IRProjection.js.map +1 -0
- package/lib/esm/queries/IntermediateRepresentation.d.ts +210 -0
- package/lib/esm/queries/IntermediateRepresentation.js +2 -0
- package/lib/esm/queries/IntermediateRepresentation.js.map +1 -0
- package/lib/esm/queries/MutationQuery.js +9 -23
- package/lib/esm/queries/MutationQuery.js.map +1 -1
- package/lib/esm/queries/QueryFactory.d.ts +0 -2
- package/lib/esm/queries/QueryFactory.js +0 -3
- package/lib/esm/queries/QueryFactory.js.map +1 -1
- package/lib/esm/queries/QueryParser.d.ts +6 -1
- package/lib/esm/queries/QueryParser.js +14 -23
- package/lib/esm/queries/QueryParser.js.map +1 -1
- package/lib/esm/queries/SelectQuery.d.ts +18 -27
- package/lib/esm/queries/SelectQuery.js +54 -45
- package/lib/esm/queries/SelectQuery.js.map +1 -1
- package/lib/esm/queries/UpdateQuery.d.ts +8 -9
- package/lib/esm/queries/UpdateQuery.js +4 -4
- package/lib/esm/queries/UpdateQuery.js.map +1 -1
- package/lib/esm/shapes/SHACL.d.ts +1 -0
- package/lib/esm/shapes/SHACL.js +82 -2
- package/lib/esm/shapes/SHACL.js.map +1 -1
- package/lib/esm/shapes/Shape.d.ts +11 -10
- package/lib/esm/shapes/Shape.js +11 -5
- package/lib/esm/shapes/Shape.js.map +1 -1
- package/lib/esm/sparql/SparqlAlgebra.d.ts +158 -0
- package/lib/esm/sparql/SparqlAlgebra.js +3 -0
- package/lib/esm/sparql/SparqlAlgebra.js.map +1 -0
- package/lib/esm/sparql/SparqlStore.d.ts +52 -0
- package/lib/esm/sparql/SparqlStore.js +77 -0
- package/lib/esm/sparql/SparqlStore.js.map +1 -0
- package/lib/esm/sparql/algebraToString.d.ts +13 -0
- package/lib/esm/sparql/algebraToString.js +289 -0
- package/lib/esm/sparql/algebraToString.js.map +1 -0
- package/lib/esm/sparql/index.d.ts +9 -0
- package/lib/esm/sparql/index.js +13 -0
- package/lib/esm/sparql/index.js.map +1 -0
- package/lib/esm/sparql/irToAlgebra.d.ts +39 -0
- package/lib/esm/sparql/irToAlgebra.js +917 -0
- package/lib/esm/sparql/irToAlgebra.js.map +1 -0
- package/lib/esm/sparql/resultMapping.d.ts +36 -0
- package/lib/esm/sparql/resultMapping.js +496 -0
- package/lib/esm/sparql/resultMapping.js.map +1 -0
- package/lib/esm/sparql/sparqlUtils.d.ts +32 -0
- package/lib/esm/sparql/sparqlUtils.js +82 -0
- package/lib/esm/sparql/sparqlUtils.js.map +1 -0
- package/lib/esm/test-helpers/FusekiStore.d.ts +29 -0
- package/lib/esm/test-helpers/FusekiStore.js +78 -0
- package/lib/esm/test-helpers/FusekiStore.js.map +1 -0
- package/lib/esm/test-helpers/fuseki-test-store.d.ts +43 -0
- package/lib/esm/test-helpers/fuseki-test-store.js +135 -0
- package/lib/esm/test-helpers/fuseki-test-store.js.map +1 -0
- package/lib/esm/test-helpers/query-capture-store.d.ts +5 -0
- package/lib/esm/test-helpers/query-capture-store.js +55 -0
- package/lib/esm/test-helpers/query-capture-store.js.map +1 -0
- package/lib/esm/test-helpers/query-fixtures.d.ts +736 -77
- package/lib/esm/test-helpers/query-fixtures.js +44 -0
- package/lib/esm/test-helpers/query-fixtures.js.map +1 -1
- package/lib/esm/utils/LinkedStorage.d.ts +7 -7
- package/lib/esm/utils/LinkedStorage.js +4 -3
- package/lib/esm/utils/LinkedStorage.js.map +1 -1
- package/package.json +7 -3
- package/lib/cjs/interfaces/IQueryParser.d.ts +0 -13
- package/lib/cjs/interfaces/IQueryParser.js +0 -10
- package/lib/cjs/interfaces/IQueryParser.js.map +0 -1
- package/lib/esm/interfaces/IQueryParser.d.ts +0 -13
- package/lib/esm/interfaces/IQueryParser.js +0 -7
- package/lib/esm/interfaces/IQueryParser.js.map +0 -1
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import { NodeReferenceValue } from './QueryFactory.js';
|
|
2
|
+
export type IRDirection = 'ASC' | 'DESC';
|
|
3
|
+
export type IRAlias = string;
|
|
4
|
+
export type IRValue = string | number | boolean | null;
|
|
5
|
+
export type IRQuery = IRSelectQuery | IRCreateMutation | IRUpdateMutation | IRDeleteMutation;
|
|
6
|
+
export type IRSelectQuery = {
|
|
7
|
+
kind: 'select';
|
|
8
|
+
root: IRShapeScanPattern;
|
|
9
|
+
patterns: IRGraphPattern[];
|
|
10
|
+
projection: IRProjectionItem[];
|
|
11
|
+
where?: IRExpression;
|
|
12
|
+
orderBy?: IROrderByItem[];
|
|
13
|
+
limit?: number;
|
|
14
|
+
offset?: number;
|
|
15
|
+
subjectId?: string;
|
|
16
|
+
singleResult?: boolean;
|
|
17
|
+
resultMap?: IRResultMapEntry[];
|
|
18
|
+
};
|
|
19
|
+
export type IRProjectionItem = {
|
|
20
|
+
alias: IRAlias;
|
|
21
|
+
expression: IRExpression;
|
|
22
|
+
};
|
|
23
|
+
export type IROrderByItem = {
|
|
24
|
+
expression: IRExpression;
|
|
25
|
+
direction: IRDirection;
|
|
26
|
+
};
|
|
27
|
+
export type IRResultMapEntry = {
|
|
28
|
+
key: string;
|
|
29
|
+
alias: IRAlias;
|
|
30
|
+
};
|
|
31
|
+
export type IRGraphPattern = IRShapeScanPattern | IRTraversePattern | IRJoinPattern | IROptionalPattern | IRUnionPattern | IRExistsPattern;
|
|
32
|
+
export type IRShapeScanPattern = {
|
|
33
|
+
kind: 'shape_scan';
|
|
34
|
+
shape: string;
|
|
35
|
+
alias: IRAlias;
|
|
36
|
+
};
|
|
37
|
+
export type IRTraversePattern = {
|
|
38
|
+
kind: 'traverse';
|
|
39
|
+
from: IRAlias;
|
|
40
|
+
to: IRAlias;
|
|
41
|
+
property: string;
|
|
42
|
+
filter?: IRExpression;
|
|
43
|
+
};
|
|
44
|
+
export type IRJoinPattern = {
|
|
45
|
+
kind: 'join';
|
|
46
|
+
patterns: IRGraphPattern[];
|
|
47
|
+
};
|
|
48
|
+
export type IROptionalPattern = {
|
|
49
|
+
kind: 'optional';
|
|
50
|
+
pattern: IRGraphPattern;
|
|
51
|
+
};
|
|
52
|
+
export type IRUnionPattern = {
|
|
53
|
+
kind: 'union';
|
|
54
|
+
branches: IRGraphPattern[];
|
|
55
|
+
};
|
|
56
|
+
export type IRExistsPattern = {
|
|
57
|
+
kind: 'exists';
|
|
58
|
+
pattern: IRGraphPattern;
|
|
59
|
+
};
|
|
60
|
+
export type IRExpression = IRLiteralExpression | IRReferenceExpression | IRAliasExpression | IRPropertyExpression | IRContextPropertyExpression | IRBinaryExpression | IRLogicalExpression | IRNotExpression | IRFunctionExpression | IRAggregateExpression | IRExistsExpression;
|
|
61
|
+
export type IRLiteralExpression = {
|
|
62
|
+
kind: 'literal_expr';
|
|
63
|
+
value: IRValue;
|
|
64
|
+
};
|
|
65
|
+
export type IRReferenceExpression = {
|
|
66
|
+
kind: 'reference_expr';
|
|
67
|
+
value: string;
|
|
68
|
+
};
|
|
69
|
+
export type IRAliasExpression = {
|
|
70
|
+
kind: 'alias_expr';
|
|
71
|
+
alias: IRAlias;
|
|
72
|
+
};
|
|
73
|
+
export type IRPropertyExpression = {
|
|
74
|
+
kind: 'property_expr';
|
|
75
|
+
sourceAlias: IRAlias;
|
|
76
|
+
property: string;
|
|
77
|
+
};
|
|
78
|
+
export type IRContextPropertyExpression = {
|
|
79
|
+
kind: 'context_property_expr';
|
|
80
|
+
contextIri: string;
|
|
81
|
+
property: string;
|
|
82
|
+
};
|
|
83
|
+
export type IRBinaryOperator = '=' | '!=' | '>' | '>=' | '<' | '<=';
|
|
84
|
+
export type IRBinaryExpression = {
|
|
85
|
+
kind: 'binary_expr';
|
|
86
|
+
operator: IRBinaryOperator;
|
|
87
|
+
left: IRExpression;
|
|
88
|
+
right: IRExpression;
|
|
89
|
+
};
|
|
90
|
+
export type IRLogicalOperator = 'and' | 'or';
|
|
91
|
+
export type IRLogicalExpression = {
|
|
92
|
+
kind: 'logical_expr';
|
|
93
|
+
operator: IRLogicalOperator;
|
|
94
|
+
expressions: IRExpression[];
|
|
95
|
+
};
|
|
96
|
+
export type IRNotExpression = {
|
|
97
|
+
kind: 'not_expr';
|
|
98
|
+
expression: IRExpression;
|
|
99
|
+
};
|
|
100
|
+
export type IRFunctionExpression = {
|
|
101
|
+
kind: 'function_expr';
|
|
102
|
+
name: string;
|
|
103
|
+
args: IRExpression[];
|
|
104
|
+
};
|
|
105
|
+
export type IRAggregateExpression = {
|
|
106
|
+
kind: 'aggregate_expr';
|
|
107
|
+
name: 'count' | 'sum' | 'avg' | 'min' | 'max';
|
|
108
|
+
args: IRExpression[];
|
|
109
|
+
};
|
|
110
|
+
export type IRExistsExpression = {
|
|
111
|
+
kind: 'exists_expr';
|
|
112
|
+
pattern: IRGraphPattern;
|
|
113
|
+
filter?: IRExpression;
|
|
114
|
+
};
|
|
115
|
+
export type IRCreateMutation = {
|
|
116
|
+
kind: 'create';
|
|
117
|
+
shape: string;
|
|
118
|
+
data: IRNodeData;
|
|
119
|
+
};
|
|
120
|
+
export type IRUpdateMutation = {
|
|
121
|
+
kind: 'update';
|
|
122
|
+
shape: string;
|
|
123
|
+
id: string;
|
|
124
|
+
data: IRNodeData;
|
|
125
|
+
};
|
|
126
|
+
export type IRDeleteMutation = {
|
|
127
|
+
kind: 'delete';
|
|
128
|
+
shape: string;
|
|
129
|
+
ids: NodeReferenceValue[];
|
|
130
|
+
};
|
|
131
|
+
export type IRNodeData = {
|
|
132
|
+
shape: string;
|
|
133
|
+
fields: IRFieldUpdate[];
|
|
134
|
+
id?: string;
|
|
135
|
+
};
|
|
136
|
+
export type IRFieldUpdate = {
|
|
137
|
+
property: string;
|
|
138
|
+
value: IRFieldValue;
|
|
139
|
+
};
|
|
140
|
+
export type IRSetModificationValue = {
|
|
141
|
+
add?: IRFieldValue[];
|
|
142
|
+
remove?: NodeReferenceValue[];
|
|
143
|
+
};
|
|
144
|
+
export type IRFieldValue = IRValue | Date | NodeReferenceValue | IRNodeData | IRSetModificationValue | IRFieldValue[] | undefined;
|
|
145
|
+
/**
|
|
146
|
+
* A single result row — an object with a node id and dynamic fields.
|
|
147
|
+
* Used in select and create results.
|
|
148
|
+
*/
|
|
149
|
+
export type ResultRow = {
|
|
150
|
+
id: string;
|
|
151
|
+
[key: string]: ResultFieldValue;
|
|
152
|
+
};
|
|
153
|
+
/**
|
|
154
|
+
* Possible field values in a select or create result row.
|
|
155
|
+
*/
|
|
156
|
+
export type ResultFieldValue = string | number | boolean | Date | null | undefined | ResultRow | ResultRow[];
|
|
157
|
+
/**
|
|
158
|
+
* What `selectQuery` should return.
|
|
159
|
+
*
|
|
160
|
+
* - Array of rows for multi-result queries (the default).
|
|
161
|
+
* - A single row when `query.singleResult` is true (`.one()` or subject-targeted query).
|
|
162
|
+
* - `null` when `singleResult` is true and the target node doesn't exist.
|
|
163
|
+
*/
|
|
164
|
+
export type SelectResult = ResultRow[] | ResultRow | null;
|
|
165
|
+
/**
|
|
166
|
+
* What `createQuery` should return.
|
|
167
|
+
*
|
|
168
|
+
* A single row with the generated `id` and the created field values.
|
|
169
|
+
* Nested creates appear as nested `ResultRow` objects (with their own ids).
|
|
170
|
+
* Array fields (e.g. friends) appear as `ResultRow[]`.
|
|
171
|
+
*/
|
|
172
|
+
export type CreateResult = ResultRow;
|
|
173
|
+
/**
|
|
174
|
+
* When a set property is fully overwritten, the result contains `updatedTo`
|
|
175
|
+
* with the new complete set of values.
|
|
176
|
+
*/
|
|
177
|
+
export type SetOverwriteResult = {
|
|
178
|
+
updatedTo: ResultRow[];
|
|
179
|
+
};
|
|
180
|
+
/**
|
|
181
|
+
* When a set property is incrementally modified with `{add, remove}`,
|
|
182
|
+
* the result contains the added and removed entries.
|
|
183
|
+
*/
|
|
184
|
+
export type SetModificationResult = {
|
|
185
|
+
added: ResultRow[];
|
|
186
|
+
removed: ResultRow[];
|
|
187
|
+
};
|
|
188
|
+
/**
|
|
189
|
+
* Possible field values in an update result row.
|
|
190
|
+
* Extends `ResultFieldValue` with set modification shapes.
|
|
191
|
+
*/
|
|
192
|
+
export type UpdateFieldValue = ResultFieldValue | SetOverwriteResult | SetModificationResult;
|
|
193
|
+
/**
|
|
194
|
+
* What `updateQuery` should return.
|
|
195
|
+
*
|
|
196
|
+
* A single row with the target node's `id` and only the changed fields.
|
|
197
|
+
* Fields not included in the update are omitted (not returned).
|
|
198
|
+
*
|
|
199
|
+
* Field value shapes depend on the type of update:
|
|
200
|
+
* - Literal fields: the new value (string, number, boolean, Date).
|
|
201
|
+
* - Single object fields: a `ResultRow` with the referenced/created node.
|
|
202
|
+
* - Set overwrite (passing an array): `{updatedTo: ResultRow[]}`.
|
|
203
|
+
* - Set add/remove (passing `{add, remove}`): `{added: ResultRow[], removed: ResultRow[]}`.
|
|
204
|
+
* - Unset single field (passing `undefined` or `null`): field is `undefined`.
|
|
205
|
+
* - Unset multi-value field (passing `undefined`): empty array `[]`.
|
|
206
|
+
*/
|
|
207
|
+
export type UpdateResult = {
|
|
208
|
+
id: string;
|
|
209
|
+
[key: string]: UpdateFieldValue;
|
|
210
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IntermediateRepresentation.js","sourceRoot":"","sources":["../../../src/queries/IntermediateRepresentation.ts"],"names":[],"mappings":""}
|
|
@@ -21,7 +21,6 @@ class MutationQueryFactory extends QueryFactory_js_1.QueryFactory {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
isSetModification(obj, shape) {
|
|
24
|
-
// return obj.add || obj.remove;
|
|
25
24
|
let hasAdd = obj.add;
|
|
26
25
|
let hasRemove = obj.remove;
|
|
27
26
|
let numKeysExpected = (hasAdd ? 1 : 0) + (hasRemove ? 1 : 0);
|
|
@@ -77,6 +76,12 @@ class MutationQueryFactory extends QueryFactory_js_1.QueryFactory {
|
|
|
77
76
|
//but we should not include it in the fields
|
|
78
77
|
delete obj.__id;
|
|
79
78
|
}
|
|
79
|
+
else if (obj && 'id' in obj) {
|
|
80
|
+
//if the object has an id key alongside other data properties,
|
|
81
|
+
//treat it as a nested create with a predefined ID
|
|
82
|
+
id = obj.id.toString();
|
|
83
|
+
delete obj.id;
|
|
84
|
+
}
|
|
80
85
|
for (var key in obj) {
|
|
81
86
|
let propShape = props.find((p) => p.label === key);
|
|
82
87
|
if (!propShape) {
|
|
@@ -169,33 +174,14 @@ class MutationQueryFactory extends QueryFactory_js_1.QueryFactory {
|
|
|
169
174
|
else {
|
|
170
175
|
return this.convertNodeDescription(value, valueShape);
|
|
171
176
|
}
|
|
172
|
-
// //check if the property shape allows a single value
|
|
173
|
-
// if(propShape.maxCount === 1) {
|
|
174
|
-
// //if yes, then the object should be seen as a node description
|
|
175
|
-
// return this.convertNodeDescription(value,propShape.valueShape);
|
|
176
|
-
// } else {
|
|
177
|
-
// if(this.isSetModification(value,propShape)) {
|
|
178
|
-
// //but if multiple values are allowed, the value should either be an Array of node descriptions
|
|
179
|
-
// //OR an object with add or remove keys
|
|
180
|
-
// return this.convertSetModification(value,propShape);
|
|
181
|
-
// } else {
|
|
182
|
-
// //it must be a set overwrite, and it must be coming from an array
|
|
183
|
-
// if(!allowArrays) {
|
|
184
|
-
// return this.convertNodeDescription(value,propShape.valueShape);
|
|
185
|
-
// } else {
|
|
186
|
-
// throw new Error("Invalid array value. Should be a node reference or node description")
|
|
187
|
-
// }
|
|
188
|
-
// }
|
|
189
|
-
// }
|
|
190
177
|
}
|
|
191
178
|
}
|
|
192
179
|
throw new Error(`Unsupported update value type: ${typeof value}`);
|
|
193
180
|
}
|
|
194
181
|
isNodeReference(obj) {
|
|
195
|
-
//check if obj is an object with an id property
|
|
196
|
-
//if
|
|
197
|
-
return typeof obj === 'object' && obj !== null && 'id' in obj
|
|
198
|
-
//and id is the only property
|
|
182
|
+
//check if obj is an object with only an id property
|
|
183
|
+
//if additional data properties are present, it's a nested create with predefined ID
|
|
184
|
+
return typeof obj === 'object' && obj !== null && 'id' in obj && Object.keys(obj).length === 1;
|
|
199
185
|
}
|
|
200
186
|
convertNodeReferences(input) {
|
|
201
187
|
if (Array.isArray(input)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationQuery.js","sourceRoot":"","sources":["../../../src/queries/MutationQuery.ts"],"names":[],"mappings":";;;AAAA,uDAW2B;AAC3B,iDAA4D;AAE5D,0DAAqD;AAIrD,MAAa,oBAAqB,SAAQ,8BAAY;IAC1C,mBAAmB,CAC3B,GAAG,EACH,KAAgB,EAChB,kBAA2B,KAAK;QAEhC,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,YAAY,IAAI,CAAC,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACtE,IAAI,CAAC,eAAe,IAAI,IAAI,IAAI,GAAG,EAAE,CAAC;gBACpC,MAAM,IAAI,KAAK,CACb,wDAAwD,CACzD,CAAC;YACJ,CAAC;YACD,OAAO,IAAI,CAAC,sBAAsB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACjD,CAAC;aAAM,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE,CAAC;YACrC,MAAM;YACN,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,uBAAuB,CAAC,CAAC;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AO,CAAC,IAAI,CAAC,4BAA4B,CAAC,KAAK,CAAC,CAAC,CAAC;QACpD,CAAC;IACH,CAAC;IAES,4BAA4B,CACpC,CAAwB;QAExB,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO,EAAC,EAAE,EAAE,CAAC,EAAC,CAAC;QACjB,CAAC;aAAM,IAAI,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,EAAE,CAAC;YACnC,OAAO,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,2BAA2B,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAClE,CAAC;IACH,CAAC;IAES,oBAAoB,CAAC,GAAiB;QAC9C,oDAAoD;QACpD,mCAAmC;QACnC,IAAI;QACJ,qFAAqF;QACrF,IAAI;QACJ,OAAO,EAAC,EAAE,EAAE,GAAG,CAAC,EAAE,EAAC,CAAC;IACtB,CAAC;CACF;AA7PD,oDA6PC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { LinkedQuery } from './SelectQuery.js';
|
|
2
1
|
import { NodeShape, PropertyShape } from '../shapes/SHACL.js';
|
|
3
2
|
import { Shape } from '../shapes/Shape.js';
|
|
4
3
|
import { ShapeSet } from '../collections/ShapeSet.js';
|
|
@@ -76,7 +75,6 @@ export type ShapeReferenceValue = {
|
|
|
76
75
|
export { toNodeReference } from '../utils/NodeReference.js';
|
|
77
76
|
export type { NodeReferenceValue };
|
|
78
77
|
export declare abstract class QueryFactory {
|
|
79
|
-
getQueryObject(): LinkedQuery | Promise<LinkedQuery>;
|
|
80
78
|
}
|
|
81
79
|
export declare function isSetModificationValue(value: any): value is SetModificationValue;
|
|
82
80
|
/**
|
|
@@ -6,9 +6,6 @@ exports.checkNewCount = checkNewCount;
|
|
|
6
6
|
var NodeReference_js_1 = require("../utils/NodeReference.js");
|
|
7
7
|
Object.defineProperty(exports, "toNodeReference", { enumerable: true, get: function () { return NodeReference_js_1.toNodeReference; } });
|
|
8
8
|
class QueryFactory {
|
|
9
|
-
getQueryObject() {
|
|
10
|
-
return null;
|
|
11
|
-
}
|
|
12
9
|
}
|
|
13
10
|
exports.QueryFactory = QueryFactory;
|
|
14
11
|
function isSetModificationValue(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryFactory.js","sourceRoot":"","sources":["../../../src/queries/QueryFactory.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"QueryFactory.js","sourceRoot":"","sources":["../../../src/queries/QueryFactory.ts"],"names":[],"mappings":";;;AAuKA,wDAcC;AAQD,sCAeC;AA1CD,8DAA0D;AAAlD,mHAAA,eAAe,OAAA;AAGvB,MAAsB,YAAY;CAAG;AAArC,oCAAqC;AAErC,SAAgB,sBAAsB,CACpC,KAAU;IAEV,IAAI,CAAC,CAAC,OAAO,KAAK,KAAK,QAAQ,CAAC;QAAE,OAAO,KAAK,CAAC;IAE/C,IAAI,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC;IAC3B,IAAI,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC;IACjC,IAAI,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC;IACxC,mBAAmB;IACnB,OAAO,CACL,CAAC,SAAS,IAAI,YAAY,IAAI,OAAO,KAAK,CAAC,CAAC;QAC5C,CAAC,SAAS,IAAI,OAAO,KAAK,CAAC,CAAC;QAC5B,CAAC,YAAY,IAAI,OAAO,KAAK,CAAC,CAAC,CAChC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,SAAwB,EAAE,SAAiB;IACvE,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;QACvB,IAAI,SAAS,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,iCAAiC,SAAS,CAAC,KAAK,mBAAmB,SAAS,CAAC,QAAQ,4BAA4B,SAAS,EAAE,CAC7H,CAAC;QACJ,CAAC;IACH,CAAC;IACD,IAAI,SAAS,CAAC,QAAQ,EAAE,CAAC;QACvB,IAAI,SAAS,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CACb,gCAAgC,SAAS,CAAC,KAAK,mBAAmB,SAAS,CAAC,QAAQ,4BAA4B,SAAS,EAAE,CAC5H,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1,9 +1,14 @@
|
|
|
1
1
|
import { GetQueryResponseType, QueryResponseToResultType, SelectQueryFactory } from './SelectQuery.js';
|
|
2
2
|
import { AddId, NodeReferenceValue, UpdatePartial } from './QueryFactory.js';
|
|
3
|
-
import { Shape } from '../shapes/Shape.js';
|
|
3
|
+
import type { Shape } from '../shapes/Shape.js';
|
|
4
4
|
import { CreateResponse } from './CreateQuery.js';
|
|
5
5
|
import { DeleteResponse } from './DeleteQuery.js';
|
|
6
6
|
import { NodeId } from './MutationQuery.js';
|
|
7
|
+
/**
|
|
8
|
+
* Bridges the DSL layer (Shape.select/create/update/delete) to the storage
|
|
9
|
+
* layer (LinkedStorage → IQuadStore). Each method builds the IR from a
|
|
10
|
+
* factory and routes it to the appropriate store.
|
|
11
|
+
*/
|
|
7
12
|
export declare class QueryParser {
|
|
8
13
|
static selectQuery<ShapeType extends Shape, ResponseType, Source, ResultType = QueryResponseToResultType<GetQueryResponseType<SelectQueryFactory<ShapeType, ResponseType>>, ShapeType>[]>(query: SelectQueryFactory<ShapeType, ResponseType, Source>): Promise<ResultType>;
|
|
9
14
|
static updateQuery<ShapeType extends Shape, U extends UpdatePartial<ShapeType>>(id: string | NodeReferenceValue, updateObjectOrFn: U, shapeClass: typeof Shape): Promise<AddId<U>>;
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -16,18 +10,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
16
10
|
};
|
|
17
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
12
|
exports.QueryParser = void 0;
|
|
19
|
-
const IQueryParser_js_1 = require("../interfaces/IQueryParser.js");
|
|
20
|
-
const Shape_js_1 = require("../shapes/Shape.js");
|
|
21
13
|
const LinkedStorage_js_1 = require("../utils/LinkedStorage.js");
|
|
22
14
|
const UpdateQuery_js_1 = require("./UpdateQuery.js");
|
|
23
15
|
const CreateQuery_js_1 = require("./CreateQuery.js");
|
|
24
16
|
const DeleteQuery_js_1 = require("./DeleteQuery.js");
|
|
25
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Bridges the DSL layer (Shape.select/create/update/delete) to the storage
|
|
19
|
+
* layer (LinkedStorage → IQuadStore). Each method builds the IR from a
|
|
20
|
+
* factory and routes it to the appropriate store.
|
|
21
|
+
*/
|
|
22
|
+
class QueryParser {
|
|
26
23
|
static selectQuery(query) {
|
|
27
24
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
25
|
try {
|
|
29
|
-
|
|
30
|
-
return LinkedStorage_js_1.LinkedStorage.selectQuery(queryObject);
|
|
26
|
+
return LinkedStorage_js_1.LinkedStorage.selectQuery(query.build());
|
|
31
27
|
}
|
|
32
28
|
catch (e) {
|
|
33
29
|
return Promise.reject(e);
|
|
@@ -36,14 +32,14 @@ let QueryParser = class QueryParser {
|
|
|
36
32
|
}
|
|
37
33
|
static updateQuery(id, updateObjectOrFn, shapeClass) {
|
|
38
34
|
const query = new UpdateQuery_js_1.UpdateQueryFactory(shapeClass, id, updateObjectOrFn);
|
|
39
|
-
|
|
40
|
-
return LinkedStorage_js_1.LinkedStorage.updateQuery(
|
|
35
|
+
const irQuery = query.build();
|
|
36
|
+
return LinkedStorage_js_1.LinkedStorage.updateQuery(irQuery);
|
|
41
37
|
}
|
|
42
38
|
static createQuery(updateObjectOrFn, shapeClass) {
|
|
43
39
|
try {
|
|
44
40
|
const query = new CreateQuery_js_1.CreateQueryFactory(shapeClass, updateObjectOrFn);
|
|
45
|
-
|
|
46
|
-
return LinkedStorage_js_1.LinkedStorage.createQuery(
|
|
41
|
+
const irQuery = query.build();
|
|
42
|
+
return LinkedStorage_js_1.LinkedStorage.createQuery(irQuery);
|
|
47
43
|
}
|
|
48
44
|
catch (e) {
|
|
49
45
|
console.warn(e);
|
|
@@ -51,13 +47,9 @@ let QueryParser = class QueryParser {
|
|
|
51
47
|
}
|
|
52
48
|
static deleteQuery(id, shapeClass) {
|
|
53
49
|
const query = new DeleteQuery_js_1.DeleteQueryFactory(shapeClass, id);
|
|
54
|
-
|
|
55
|
-
return LinkedStorage_js_1.LinkedStorage.deleteQuery(
|
|
50
|
+
const irQuery = query.build();
|
|
51
|
+
return LinkedStorage_js_1.LinkedStorage.deleteQuery(irQuery);
|
|
56
52
|
}
|
|
57
|
-
}
|
|
53
|
+
}
|
|
58
54
|
exports.QueryParser = QueryParser;
|
|
59
|
-
exports.QueryParser = QueryParser = __decorate([
|
|
60
|
-
(0, IQueryParser_js_1.staticImplements)() /* this class implements this interface with static methods */
|
|
61
|
-
], QueryParser);
|
|
62
|
-
Shape_js_1.Shape.queryParser = QueryParser;
|
|
63
55
|
//# sourceMappingURL=QueryParser.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryParser.js","sourceRoot":"","sources":["../../../src/queries/QueryParser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryParser.js","sourceRoot":"","sources":["../../../src/queries/QueryParser.ts"],"names":[],"mappings":";;;;;;;;;;;;AAOA,gEAAwD;AACxD,qDAAoD;AACpD,qDAAoE;AACpE,qDAAoE;AAGpE;;;;GAIG;AACH,MAAa,WAAW;IACtB,MAAM,CAAO,WAAW,CAStB,KAA0D;;YAE1D,IAAI,CAAC;gBACH,OAAO,gCAAa,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC;YAClD,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;YAC3B,CAAC;QACH,CAAC;KAAA;IAED,MAAM,CAAC,WAAW,CAIhB,EAA+B,EAC/B,gBAAmB,EACnB,UAAwB;QAExB,MAAM,KAAK,GAAG,IAAI,mCAAkB,CAClC,UAAU,EACV,EAAE,EACF,gBAAgB,CACjB,CAAC;QACF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9B,OAAO,gCAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,WAAW,CAGhB,gBAAmB,EAAE,UAAwB;QAC7C,IAAI,CAAC;YACH,MAAM,KAAK,GAAG,IAAI,mCAAkB,CAClC,UAAU,EACV,gBAAgB,CACjB,CAAC;YACF,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;YAC9B,OAAO,gCAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,MAAM,CAAC,WAAW,CAChB,EAA4C,EAC5C,UAAwB;QAExB,MAAM,KAAK,GAAG,IAAI,mCAAkB,CAAY,UAAU,EAAE,EAAE,CAAC,CAAC;QAChE,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC;QAC9B,OAAO,gCAAa,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC5C,CAAC;CACF;AA5DD,kCA4DC"}
|
|
@@ -4,6 +4,13 @@ import { ShapeSet } from '../collections/ShapeSet.js';
|
|
|
4
4
|
import { CoreSet } from '../collections/CoreSet.js';
|
|
5
5
|
import { CoreMap } from '../collections/CoreMap.js';
|
|
6
6
|
import { NodeReferenceValue, Prettify, QueryFactory, ShapeReferenceValue } from './QueryFactory.js';
|
|
7
|
+
import type { RawSelectInput } from './IRDesugar.js';
|
|
8
|
+
import type { IRSelectQuery } from './IntermediateRepresentation.js';
|
|
9
|
+
/**
|
|
10
|
+
* The canonical SelectQuery type — an IR AST node representing a select query.
|
|
11
|
+
* This is the type received by IQuadStore.selectQuery().
|
|
12
|
+
*/
|
|
13
|
+
export type SelectQuery = IRSelectQuery;
|
|
7
14
|
/**
|
|
8
15
|
* ###################################
|
|
9
16
|
* #### TYPES FOR QUERY BUILDING ####
|
|
@@ -29,34 +36,11 @@ export type SortByPath = {
|
|
|
29
36
|
paths: QueryPath[];
|
|
30
37
|
direction: 'ASC' | 'DESC';
|
|
31
38
|
};
|
|
32
|
-
/**
|
|
33
|
-
* A LinkedQuery is used to build a query, when complete it can be turned into a LinkedQueryObject
|
|
34
|
-
* that is used to send across the network as it can be serialized to JSON
|
|
35
|
-
* @todo add | UpdateQuery and others
|
|
36
|
-
*/
|
|
37
|
-
export interface LinkedQuery {
|
|
38
|
-
type: string;
|
|
39
|
-
}
|
|
40
39
|
export type SubQueryPaths = SelectPath;
|
|
41
40
|
/**
|
|
42
41
|
* A QueryPath is an array of QuerySteps, representing the path of properties that were requested to reach a certain value
|
|
43
42
|
*/
|
|
44
43
|
export type QueryPath = (QueryStep | SubQueryPaths)[] | WherePath;
|
|
45
|
-
/**
|
|
46
|
-
* A plain JS object that represents a LinkedQuery created by a Shape.select(...) call
|
|
47
|
-
* It can be sent across the network.
|
|
48
|
-
* @see LinkedQuery
|
|
49
|
-
*/
|
|
50
|
-
export interface SelectQuery<S extends Shape = Shape, ResultType = any> extends LinkedQuery {
|
|
51
|
-
select: SelectPath;
|
|
52
|
-
where?: WherePath;
|
|
53
|
-
sortBy?: SortByPath;
|
|
54
|
-
subject?: S | QResult<S>;
|
|
55
|
-
limit?: number;
|
|
56
|
-
offset?: number;
|
|
57
|
-
shape?: ShapeType<S>;
|
|
58
|
-
singleResult?: boolean;
|
|
59
|
-
}
|
|
60
44
|
/**
|
|
61
45
|
* Much like a querypath, except it can only contain QuerySteps
|
|
62
46
|
*/
|
|
@@ -79,8 +63,7 @@ export type WhereAndOr = {
|
|
|
79
63
|
andOr: AndOrQueryToken[];
|
|
80
64
|
};
|
|
81
65
|
/**
|
|
82
|
-
* A WhereQuery is a (sub)query that is used to filter down the results of its parent query
|
|
83
|
-
* Hence it extends LinkedQuery and can do anything a normal query can
|
|
66
|
+
* A WhereQuery is a (sub)query that is used to filter down the results of its parent query.
|
|
84
67
|
*/
|
|
85
68
|
export type AndOrQueryToken = {
|
|
86
69
|
and?: WherePath;
|
|
@@ -97,6 +80,9 @@ export declare enum WhereMethods {
|
|
|
97
80
|
export type QueryShapeProps<T extends Shape, Source, Property extends string | number | symbol = any> = {
|
|
98
81
|
[P in keyof T]: ToQueryBuilderObject<T[P], QShape<T, Source, Property>, P>;
|
|
99
82
|
};
|
|
83
|
+
export type SelectAllQueryResponse<T extends Shape> = Array<QueryShapeProps<T, null, ''>[Exclude<Extract<{
|
|
84
|
+
[K in keyof T]-?: T[K] extends (...args: any[]) => any ? never : K;
|
|
85
|
+
}[keyof T], string>, Extract<keyof Shape, string>>]>;
|
|
100
86
|
/**
|
|
101
87
|
* This type states that the ShapeSet has access to the same methods as the shape of all the items in the set
|
|
102
88
|
* (this is enabled with the QueryShapeSet.proxifyShapeSet method)
|
|
@@ -271,6 +257,7 @@ export declare class QueryShapeSet<S extends Shape = Shape, Source = any, Proper
|
|
|
271
257
|
size(): SetSize<this>;
|
|
272
258
|
where(validation: WhereClause<S>): this;
|
|
273
259
|
select<QF = unknown>(subQueryFn: QueryBuildFn<S, QF>): SelectQueryFactory<S, QF, QueryShapeSet<S, Source, Property>>;
|
|
260
|
+
selectAll(): SelectQueryFactory<S, SelectAllQueryResponse<S>, QueryShapeSet<S, Source, Property>>;
|
|
274
261
|
some(validation: WhereClause<S>): SetEvaluation;
|
|
275
262
|
every(validation: WhereClause<S>): SetEvaluation;
|
|
276
263
|
private someOrEvery;
|
|
@@ -286,6 +273,7 @@ export declare class QueryShape<S extends Shape = Shape, Source = any, Property
|
|
|
286
273
|
as<ShapeClass extends typeof Shape>(shape: ShapeClass): QShape<InstanceType<ShapeClass>, Source, Property>;
|
|
287
274
|
equals(otherValue: NodeReferenceValue | QShape<any>): Evaluation;
|
|
288
275
|
select<QF = unknown>(subQueryFn: QueryBuildFn<S, QF>): SelectQueryFactory<S, QF, QueryShape<S, Source, Property>>;
|
|
276
|
+
selectAll(): SelectQueryFactory<S, SelectAllQueryResponse<S>, QueryShape<S, Source, Property>>;
|
|
289
277
|
}
|
|
290
278
|
export declare class Evaluation {
|
|
291
279
|
value: QueryBuilderObject | QueryPrimitiveSet;
|
|
@@ -364,9 +352,12 @@ export declare class SelectQueryFactory<S extends Shape, ResponseType = any, Sou
|
|
|
364
352
|
where(validation: WhereClause<S>): this;
|
|
365
353
|
exec(): Promise<QueryResponseToResultType<ResponseType>[]>;
|
|
366
354
|
/**
|
|
367
|
-
*
|
|
355
|
+
* Returns the raw pipeline input for this query.
|
|
356
|
+
* Used internally by build() and by test helpers that need
|
|
357
|
+
* to feed factory state into individual pipeline stages.
|
|
368
358
|
*/
|
|
369
|
-
|
|
359
|
+
toRawInput(): RawSelectInput;
|
|
360
|
+
build(): SelectQuery;
|
|
370
361
|
getSubject(): {
|
|
371
362
|
id: string;
|
|
372
363
|
} | S | ShapeSet<S>;
|