-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
IQueryOperationResult.ts
165 lines (152 loc) 路 4.71 KB
/
IQueryOperationResult.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
import type * as RDF from '@rdfjs/types';
import type { AsyncIterator } from 'asynciterator';
import type { BindingsStream } from './Bindings';
import type { IActionContext } from './IActionContext';
import type { IMetadata, MetadataQuads, MetadataBindings } from './IMetadata';
export interface IQueryOperationResultBase {
/**
* The type of output.
*/
type: string;
/**
* The resulting action context.
*/
context?: IActionContext;
}
/**
* Super interface for query operation results that represent some for of stream.
* @see IQueryableResultBindings, IQueryableResultQuads
*/
export interface IQueryOperationResultStream<
M extends IMetadata<OrderItemsType>,
OrderItemsType extends RDF.Variable | RDF.QuadTermName,
> extends IQueryOperationResultBase {
/**
* Callback that returns a promise that resolves to the metadata about the stream.
*
* This can contain things like the estimated number of total stream elements,
* or the order in which the bindings appear.
*
* This callback can be invoked multiple times.
* Each invocation can return a different metadata object,
* if the previous one would have become invalidated (see `metadata.state`).
* The actors that return this metadata will make sure that multiple calls properly cache this promise,
* and that the cached object is properly invalidated if needed.
* Metadata will not be collected until this callback is invoked.
*
* This callback should resolve quickly, so it is safe to call and immediately `await` it.
*/
metadata: () => Promise<M>;
}
/**
* Query operation output for a bindings stream.
* For example: SPARQL SELECT results
*/
export interface IQueryOperationResultBindings extends IQueryOperationResultStream<MetadataBindings, RDF.Variable> {
/**
* The type of output.
*/
type: 'bindings';
/**
* The stream of bindings resulting from the given operation.
*/
bindingsStream: BindingsStream;
}
/**
* Query operation output for quads.
* For example: SPARQL CONSTRUCT results
*/
export interface IQueryOperationResultQuads extends IQueryOperationResultStream<MetadataQuads, RDF.QuadTermName> {
/**
* The type of output.
*/
type: 'quads';
/**
* The stream of quads.
*/
quadStream: RDF.Stream & AsyncIterator<RDF.Quad> & RDF.ResultStream<RDF.Quad>;
}
/**
* Query operation output for boolean results.
* For example: SPARQL ASK results
*/
export interface IQueryOperationResultBoolean extends IQueryOperationResultBase {
/**
* The type of output.
*/
type: 'boolean';
/**
* An async function resolving to the boolean output of the operation.
*/
execute: () => Promise<boolean>;
}
/**
* Query operation output for boolean results.
* For example: SPARQL UPDATE results
*/
export interface IQueryOperationResultVoid extends IQueryOperationResultBase {
/**
* The type of output.
*/
type: 'void';
/**
* An async function resolving when the update has finished.
*/
execute: () => Promise<void>;
}
/**
* Query operation output.
* @see IQueryableResultBindings, IQueryableResultQuads, IQueryableResultBoolean, IQueryableResultVoid
*/
export type IQueryOperationResult =
IQueryOperationResultBindings |
IQueryOperationResultQuads |
IQueryOperationResultBoolean |
IQueryOperationResultVoid;
/**
* Enhanced query operation output for a bindings stream.
* For example: SPARQL SELECT results
*/
export interface IQueryBindingsEnhanced extends QueryBindings {
// Override with more specific return type
execute: (opts?: RDF.QueryExecuteOptions<RDF.Variable>) => Promise<BindingsStream>;
}
/**
* Enhanced query operation output for quads.
* For example: SPARQL CONSTRUCT results
*/
export interface IQueryQuadsEnhanced extends QueryQuads {
// Override with more specific return type
execute: (opts?: RDF.QueryExecuteOptions<RDF.QuadTermName>)
=> Promise<AsyncIterator<RDF.Quad> & RDF.ResultStream<RDF.Quad>>;
}
export type QueryBindings = RDF.QueryBindings<RDF.AllMetadataSupport>;
export type QueryQuads = RDF.QueryQuads<RDF.AllMetadataSupport>;
/**
* Enhanced query operation output.
* @see IQueryableResultBindingsEnhanced, IQueryableResultQuadsEnhanced, IQueryableResultBoolean, IQueryableResultVoid
*/
export type QueryEnhanced =
IQueryBindingsEnhanced |
IQueryQuadsEnhanced |
RDF.QueryBoolean |
RDF.QueryVoid;
/**
* Different manners in which a query can be explained.
*/
export type QueryExplainMode = 'parsed' | 'logical' | 'physical';
/**
* An interface marking an explained query.
* WARNING: this API is experimental, and might be changed inbetween major versions.
*/
export interface IQueryExplained {
explain: true;
/**
* The mode of explanation
*/
type: QueryExplainMode;
/**
* The raw explanation data
*/
data: any;
}