flowquery 1.0.86 → 1.0.87
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/README.md +101 -0
- package/dist/compute/flowquery.d.ts +18 -0
- package/dist/compute/flowquery.d.ts.map +1 -1
- package/dist/compute/flowquery.js +26 -0
- package/dist/compute/flowquery.js.map +1 -1
- package/dist/compute/runner.d.ts +29 -0
- package/dist/compute/runner.d.ts.map +1 -1
- package/dist/compute/runner.js +111 -3
- package/dist/compute/runner.js.map +1 -1
- package/dist/extensibility.d.ts +4 -1
- package/dist/extensibility.d.ts.map +1 -1
- package/dist/extensibility.js +14 -1
- package/dist/extensibility.js.map +1 -1
- package/dist/flowquery.min.js +1 -1
- package/dist/graph/data.d.ts +1 -0
- package/dist/graph/data.d.ts.map +1 -1
- package/dist/graph/data.js +3 -0
- package/dist/graph/data.js.map +1 -1
- package/dist/graph/data_cache.d.ts +3 -1
- package/dist/graph/data_cache.d.ts.map +1 -1
- package/dist/graph/data_cache.js +5 -4
- package/dist/graph/data_cache.js.map +1 -1
- package/dist/graph/data_resolver.d.ts +13 -0
- package/dist/graph/data_resolver.d.ts.map +1 -1
- package/dist/graph/data_resolver.js +52 -0
- package/dist/graph/data_resolver.js.map +1 -1
- package/dist/graph/database.d.ts +19 -0
- package/dist/graph/database.d.ts.map +1 -1
- package/dist/graph/database.js +76 -0
- package/dist/graph/database.js.map +1 -1
- package/dist/graph/node.d.ts +21 -0
- package/dist/graph/node.d.ts.map +1 -1
- package/dist/graph/node.js +147 -0
- package/dist/graph/node.js.map +1 -1
- package/dist/graph/pattern.d.ts +19 -1
- package/dist/graph/pattern.d.ts.map +1 -1
- package/dist/graph/pattern.js +279 -1
- package/dist/graph/pattern.js.map +1 -1
- package/dist/graph/pattern_expression.d.ts +3 -1
- package/dist/graph/pattern_expression.d.ts.map +1 -1
- package/dist/graph/pattern_expression.js +8 -3
- package/dist/graph/pattern_expression.js.map +1 -1
- package/dist/graph/patterns.d.ts +2 -1
- package/dist/graph/patterns.d.ts.map +1 -1
- package/dist/graph/patterns.js +3 -3
- package/dist/graph/patterns.js.map +1 -1
- package/dist/graph/physical_node.d.ts +10 -1
- package/dist/graph/physical_node.d.ts.map +1 -1
- package/dist/graph/physical_node.js +19 -2
- package/dist/graph/physical_node.js.map +1 -1
- package/dist/graph/physical_relationship.d.ts +10 -1
- package/dist/graph/physical_relationship.d.ts.map +1 -1
- package/dist/graph/physical_relationship.js +21 -2
- package/dist/graph/physical_relationship.js.map +1 -1
- package/dist/graph/relationship.d.ts +25 -1
- package/dist/graph/relationship.d.ts.map +1 -1
- package/dist/graph/relationship.js +135 -0
- package/dist/graph/relationship.js.map +1 -1
- package/dist/graph/relationship_match_collector.d.ts +1 -1
- package/dist/graph/relationship_match_collector.d.ts.map +1 -1
- package/dist/graph/relationship_match_collector.js +29 -3
- package/dist/graph/relationship_match_collector.js.map +1 -1
- package/dist/graph/relationship_reference.d.ts.map +1 -1
- package/dist/graph/relationship_reference.js +1 -2
- package/dist/graph/relationship_reference.js.map +1 -1
- package/dist/graph/source_access.d.ts +107 -0
- package/dist/graph/source_access.d.ts.map +1 -0
- package/dist/graph/source_access.js +726 -0
- package/dist/graph/source_access.js.map +1 -0
- package/dist/graph/source_context.d.ts +101 -0
- package/dist/graph/source_context.d.ts.map +1 -0
- package/dist/graph/source_context.js +392 -0
- package/dist/graph/source_context.js.map +1 -0
- package/dist/graph/source_provider.d.ts +263 -0
- package/dist/graph/source_provider.d.ts.map +1 -0
- package/dist/graph/source_provider.js +306 -0
- package/dist/graph/source_provider.js.map +1 -0
- package/dist/graph/statement_source.d.ts +27 -0
- package/dist/graph/statement_source.d.ts.map +1 -0
- package/dist/graph/statement_source.js +117 -0
- package/dist/graph/statement_source.js.map +1 -0
- package/dist/graph/virtual_statement.d.ts +19 -1
- package/dist/graph/virtual_statement.d.ts.map +1 -1
- package/dist/graph/virtual_statement.js +197 -5
- package/dist/graph/virtual_statement.js.map +1 -1
- package/dist/index.browser.d.ts +3 -0
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +14 -0
- package/dist/index.browser.js.map +1 -1
- package/dist/index.node.d.ts +3 -0
- package/dist/index.node.d.ts.map +1 -1
- package/dist/index.node.js +14 -1
- package/dist/index.node.js.map +1 -1
- package/dist/parsing/operations/aggregated_return.d.ts +2 -0
- package/dist/parsing/operations/aggregated_return.d.ts.map +1 -1
- package/dist/parsing/operations/aggregated_return.js +6 -0
- package/dist/parsing/operations/aggregated_return.js.map +1 -1
- package/dist/parsing/operations/aggregated_with.d.ts +2 -0
- package/dist/parsing/operations/aggregated_with.d.ts.map +1 -1
- package/dist/parsing/operations/aggregated_with.js +6 -0
- package/dist/parsing/operations/aggregated_with.js.map +1 -1
- package/dist/parsing/operations/create_node.d.ts +5 -1
- package/dist/parsing/operations/create_node.d.ts.map +1 -1
- package/dist/parsing/operations/create_node.js +20 -1
- package/dist/parsing/operations/create_node.js.map +1 -1
- package/dist/parsing/operations/create_relationship.d.ts +5 -1
- package/dist/parsing/operations/create_relationship.d.ts.map +1 -1
- package/dist/parsing/operations/create_relationship.js +21 -1
- package/dist/parsing/operations/create_relationship.js.map +1 -1
- package/dist/parsing/operations/limit.d.ts +1 -0
- package/dist/parsing/operations/limit.d.ts.map +1 -1
- package/dist/parsing/operations/limit.js +3 -0
- package/dist/parsing/operations/limit.js.map +1 -1
- package/dist/parsing/operations/match.d.ts +16 -0
- package/dist/parsing/operations/match.d.ts.map +1 -1
- package/dist/parsing/operations/match.js +104 -8
- package/dist/parsing/operations/match.js.map +1 -1
- package/dist/parsing/operations/operation.d.ts +6 -0
- package/dist/parsing/operations/operation.d.ts.map +1 -1
- package/dist/parsing/operations/operation.js +8 -0
- package/dist/parsing/operations/operation.js.map +1 -1
- package/dist/parsing/operations/return.d.ts +10 -0
- package/dist/parsing/operations/return.d.ts.map +1 -1
- package/dist/parsing/operations/return.js +23 -0
- package/dist/parsing/operations/return.js.map +1 -1
- package/dist/parsing/operations/unwind.d.ts +1 -0
- package/dist/parsing/operations/unwind.d.ts.map +1 -1
- package/dist/parsing/operations/unwind.js +9 -2
- package/dist/parsing/operations/unwind.js.map +1 -1
- package/dist/parsing/operations/where.d.ts +1 -0
- package/dist/parsing/operations/where.d.ts.map +1 -1
- package/dist/parsing/operations/where.js +4 -0
- package/dist/parsing/operations/where.js.map +1 -1
- package/dist/parsing/operations/with.d.ts +1 -0
- package/dist/parsing/operations/with.d.ts.map +1 -1
- package/dist/parsing/operations/with.js +4 -0
- package/dist/parsing/operations/with.js.map +1 -1
- package/dist/parsing/parser.d.ts.map +1 -1
- package/dist/parsing/parser.js +20 -2
- package/dist/parsing/parser.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Backend-neutral source provider contract (version 1).
|
|
3
|
+
*
|
|
4
|
+
* A source provider exposes the rows of a virtual node label or
|
|
5
|
+
* relationship type to FlowQuery and declares, through explicit
|
|
6
|
+
* capabilities, which logical operations it can execute natively
|
|
7
|
+
* (lookup by id, adjacency expansion, predicate filtering, paging).
|
|
8
|
+
* FlowQuery plans against these declared operations only; it never
|
|
9
|
+
* inspects what kind of backend sits behind a provider.
|
|
10
|
+
*
|
|
11
|
+
* Rows always describe the *virtual definition*: node rows carry an `id`
|
|
12
|
+
* plus properties, relationship rows carry `left_id`, `right_id` plus
|
|
13
|
+
* properties, exactly as a `CREATE VIRTUAL` definition would return them.
|
|
14
|
+
* Ids are scoped to their label (or relationship type); they do not need
|
|
15
|
+
* to be globally unique.
|
|
16
|
+
*
|
|
17
|
+
* Correctness rule: a provider may return a *superset* of the rows that
|
|
18
|
+
* satisfy a request — FlowQuery always re-applies every constraint
|
|
19
|
+
* locally — but it must never drop a row that satisfies the request.
|
|
20
|
+
*/
|
|
21
|
+
export declare const SOURCE_CONTRACT_VERSION = 1;
|
|
22
|
+
export type SourceRow = Record<string, any>;
|
|
23
|
+
/** Comparison operators that can appear in a {@link SourcePredicate}. */
|
|
24
|
+
export type PredicateOperator = "eq" | "gt" | "gte" | "lt" | "lte" | "in";
|
|
25
|
+
export declare const PREDICATE_OPERATORS: readonly PredicateOperator[];
|
|
26
|
+
/**
|
|
27
|
+
* Structured, versioned predicate over the columns of the virtual
|
|
28
|
+
* definition. Semantics (identical in the TypeScript and Python
|
|
29
|
+
* implementations):
|
|
30
|
+
*
|
|
31
|
+
* - `eq`: the property is present and equal to `value` (host-language
|
|
32
|
+
* equality on primitives). `value` is never `null`.
|
|
33
|
+
* - `gt`/`gte`/`lt`/`lte`: a row may only be excluded when its property
|
|
34
|
+
* value is a non-null primitive of the same type as `value` (number or
|
|
35
|
+
* string) that fails the comparison. Rows whose value is missing,
|
|
36
|
+
* `null`, or of another type must be returned. String bounds are only
|
|
37
|
+
* sent to sources declaring `stringOrdering: "binary"`.
|
|
38
|
+
* - `in`: the property is present and equal to one of `values`. `values`
|
|
39
|
+
* is de-duplicated, contains only primitives and never contains `null`;
|
|
40
|
+
* it may be empty (no row matches).
|
|
41
|
+
* - `and`: every term holds. FlowQuery never sends `or` or negation.
|
|
42
|
+
*/
|
|
43
|
+
export type SourcePredicate = {
|
|
44
|
+
op: "and";
|
|
45
|
+
terms: SourcePredicate[];
|
|
46
|
+
} | {
|
|
47
|
+
op: "eq" | "gt" | "gte" | "lt" | "lte";
|
|
48
|
+
property: string;
|
|
49
|
+
value: any;
|
|
50
|
+
} | {
|
|
51
|
+
op: "in";
|
|
52
|
+
property: string;
|
|
53
|
+
values: any[];
|
|
54
|
+
};
|
|
55
|
+
export interface PredicateCapabilities {
|
|
56
|
+
/** Operators the source can evaluate. `and` is always implied. */
|
|
57
|
+
operators: PredicateOperator[];
|
|
58
|
+
/** Restrict push-down to these definition columns. Omit for any column. */
|
|
59
|
+
properties?: string[];
|
|
60
|
+
/**
|
|
61
|
+
* String ordering used for range operators. Only `"binary"`
|
|
62
|
+
* (code-unit order) matches FlowQuery and enables string range
|
|
63
|
+
* push-down; numeric ranges are always eligible.
|
|
64
|
+
*/
|
|
65
|
+
stringOrdering?: "binary";
|
|
66
|
+
}
|
|
67
|
+
interface BaseSourceCapabilities {
|
|
68
|
+
/** Contract version; must be {@link SOURCE_CONTRACT_VERSION}. */
|
|
69
|
+
version: number;
|
|
70
|
+
/** Predicate push-down support. Omit when the source ignores predicates. */
|
|
71
|
+
predicates?: PredicateCapabilities;
|
|
72
|
+
/**
|
|
73
|
+
* Results are produced incrementally as pages (async iterables). For
|
|
74
|
+
* statement-backed definitions this also enables streaming execution
|
|
75
|
+
* of eligible inner queries.
|
|
76
|
+
*/
|
|
77
|
+
streaming?: boolean;
|
|
78
|
+
/** Repeated identical reads within one query return the same rows and may be cached. */
|
|
79
|
+
cacheable?: boolean;
|
|
80
|
+
/** Maximum number of ids per lookup/expand request (default: unlimited). */
|
|
81
|
+
maxBatchSize?: number;
|
|
82
|
+
}
|
|
83
|
+
export interface NodeSourceCapabilities extends BaseSourceCapabilities {
|
|
84
|
+
/** The source implements {@link NodeSourceProvider.lookup} (batched lookup by id). */
|
|
85
|
+
lookup?: boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface RelationshipSourceCapabilities extends BaseSourceCapabilities {
|
|
88
|
+
/**
|
|
89
|
+
* Adjacency expansion support. `left: true` means relationships can be
|
|
90
|
+
* fetched by `left_id`, `right: true` by `right_id`.
|
|
91
|
+
*/
|
|
92
|
+
expand?: {
|
|
93
|
+
left?: boolean;
|
|
94
|
+
right?: boolean;
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
interface BaseSourceRequest {
|
|
98
|
+
version: number;
|
|
99
|
+
/** Pushed-down predicate over definition columns, or `null`. */
|
|
100
|
+
predicate: SourcePredicate | null;
|
|
101
|
+
/**
|
|
102
|
+
* The legacy `$args` equality map built from the pattern's own
|
|
103
|
+
* property constraints (unchanged shape), or `null`. Never contains
|
|
104
|
+
* correlation ids.
|
|
105
|
+
*/
|
|
106
|
+
args: Record<string, any> | null;
|
|
107
|
+
/** Preferred page size. Sources may return smaller or larger pages. */
|
|
108
|
+
pageSize: number;
|
|
109
|
+
}
|
|
110
|
+
export interface NodeScanRequest extends BaseSourceRequest {
|
|
111
|
+
operation: "scan";
|
|
112
|
+
label: string;
|
|
113
|
+
}
|
|
114
|
+
export interface NodeLookupRequest extends BaseSourceRequest {
|
|
115
|
+
operation: "lookup";
|
|
116
|
+
label: string;
|
|
117
|
+
/** Distinct ids to fetch; at most `maxBatchSize` entries. */
|
|
118
|
+
ids: any[];
|
|
119
|
+
}
|
|
120
|
+
export interface RelationshipScanRequest extends BaseSourceRequest {
|
|
121
|
+
operation: "scan";
|
|
122
|
+
type: string;
|
|
123
|
+
sourceLabel: string | null;
|
|
124
|
+
targetLabel: string | null;
|
|
125
|
+
}
|
|
126
|
+
export interface RelationshipExpandRequest extends BaseSourceRequest {
|
|
127
|
+
operation: "expand";
|
|
128
|
+
type: string;
|
|
129
|
+
sourceLabel: string | null;
|
|
130
|
+
targetLabel: string | null;
|
|
131
|
+
/** Which stored endpoint the anchor ids constrain (`left` → `left_id`). */
|
|
132
|
+
side: "left" | "right";
|
|
133
|
+
/** Distinct anchor ids; at most `maxBatchSize` entries. */
|
|
134
|
+
ids: any[];
|
|
135
|
+
}
|
|
136
|
+
export type NodeSourceRequest = NodeScanRequest | NodeLookupRequest;
|
|
137
|
+
export type RelationshipSourceRequest = RelationshipScanRequest | RelationshipExpandRequest;
|
|
138
|
+
/**
|
|
139
|
+
* Per-query read context passed to every provider call.
|
|
140
|
+
*/
|
|
141
|
+
export interface SourceReadContext {
|
|
142
|
+
/** Aborted when the query completes, fails, is cancelled or abandons the read. */
|
|
143
|
+
signal: AbortSignal;
|
|
144
|
+
/** Value returned by the provider's `openReadContext`, or `undefined`. */
|
|
145
|
+
snapshot: unknown;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Result of a provider call: a single page (array or promise of array),
|
|
149
|
+
* or a sync/async iterable of pages. Empty pages are allowed and do not
|
|
150
|
+
* signal completion; completion is the end of the iteration.
|
|
151
|
+
*/
|
|
152
|
+
export type SourceResult = SourceRow[] | Promise<SourceRow[]> | AsyncIterable<SourceRow[]> | Iterable<SourceRow[]>;
|
|
153
|
+
interface BaseSourceProvider {
|
|
154
|
+
/**
|
|
155
|
+
* Optional query-scoped read context (e.g. a snapshot or transaction).
|
|
156
|
+
* Opened lazily on first use and closed when the query ends.
|
|
157
|
+
*/
|
|
158
|
+
openReadContext?(): unknown | Promise<unknown>;
|
|
159
|
+
closeReadContext?(snapshot: unknown): void | Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
export interface NodeSourceProvider extends BaseSourceProvider {
|
|
162
|
+
readonly capabilities: NodeSourceCapabilities;
|
|
163
|
+
/** Required: return all rows (optionally filtered by `request.predicate`). */
|
|
164
|
+
scan(request: NodeScanRequest, context: SourceReadContext): SourceResult;
|
|
165
|
+
/** Return rows whose `id` is in `request.ids`. Required when `capabilities.lookup`. */
|
|
166
|
+
lookup?(request: NodeLookupRequest, context: SourceReadContext): SourceResult;
|
|
167
|
+
/** Optional cardinality estimate used to rank start points (lower is better). */
|
|
168
|
+
estimate?(request: NodeScanRequest): number | undefined;
|
|
169
|
+
}
|
|
170
|
+
export interface RelationshipSourceProvider extends BaseSourceProvider {
|
|
171
|
+
readonly capabilities: RelationshipSourceCapabilities;
|
|
172
|
+
/** Required: return all rows (optionally filtered by `request.predicate`). */
|
|
173
|
+
scan(request: RelationshipScanRequest, context: SourceReadContext): SourceResult;
|
|
174
|
+
/** Return rows whose `side` endpoint is in `request.ids`. Required when `capabilities.expand`. */
|
|
175
|
+
expand?(request: RelationshipExpandRequest, context: SourceReadContext): SourceResult;
|
|
176
|
+
}
|
|
177
|
+
/** Base class of all source-related errors. */
|
|
178
|
+
export declare class SourceError extends Error {
|
|
179
|
+
readonly source: string;
|
|
180
|
+
readonly operation: string;
|
|
181
|
+
readonly cause?: unknown;
|
|
182
|
+
constructor(message: string, source?: string, operation?: string, cause?: unknown);
|
|
183
|
+
}
|
|
184
|
+
/** Invalid capability declaration or provider registration. */
|
|
185
|
+
export declare class SourceCapabilityError extends SourceError {
|
|
186
|
+
constructor(message: string, source?: string);
|
|
187
|
+
}
|
|
188
|
+
/** Malformed provider response (non-array page, missing ids, invalid cursor...). */
|
|
189
|
+
export declare class SourceResponseError extends SourceError {
|
|
190
|
+
constructor(message: string, source?: string, operation?: string);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Thrown by a provider to decline an optional operation at runtime.
|
|
194
|
+
* FlowQuery then uses its documented fallback (a scan). Any other
|
|
195
|
+
* error propagates to the caller of the query.
|
|
196
|
+
*/
|
|
197
|
+
export declare class SourceUnsupportedError extends SourceError {
|
|
198
|
+
constructor(message?: string, source?: string, operation?: string);
|
|
199
|
+
}
|
|
200
|
+
/** Raised when a query is cancelled through `Runner.cancel()`. */
|
|
201
|
+
export declare class QueryCancelledError extends Error {
|
|
202
|
+
constructor(message?: string);
|
|
203
|
+
}
|
|
204
|
+
/** Validate a node provider; throws {@link SourceCapabilityError} with an actionable message. */
|
|
205
|
+
export declare function validateNodeProvider(provider: NodeSourceProvider, name: string): void;
|
|
206
|
+
/** Validate a relationship provider; throws {@link SourceCapabilityError} with an actionable message. */
|
|
207
|
+
export declare function validateRelationshipProvider(provider: RelationshipSourceProvider, name: string): void;
|
|
208
|
+
/**
|
|
209
|
+
* Turn a continuation-token API into a page iterator. Tokens stay opaque
|
|
210
|
+
* to FlowQuery; a token repeated twice in a row is reported as an invalid
|
|
211
|
+
* cursor instead of looping forever.
|
|
212
|
+
*
|
|
213
|
+
* @example
|
|
214
|
+
* ```typescript
|
|
215
|
+
* scan(req, ctx) {
|
|
216
|
+
* return cursorPages((cursor) => backend.query(req, cursor, req.pageSize));
|
|
217
|
+
* }
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
220
|
+
export declare function cursorPages(fetchPage: (cursor: string | null) => Promise<{
|
|
221
|
+
rows: SourceRow[];
|
|
222
|
+
cursor?: string | null;
|
|
223
|
+
}>): AsyncGenerator<SourceRow[], void, unknown>;
|
|
224
|
+
/**
|
|
225
|
+
* Reference implementation of {@link SourcePredicate} semantics for
|
|
226
|
+
* in-memory providers and tests. Returns `true` when the row must be
|
|
227
|
+
* returned by a source receiving this predicate.
|
|
228
|
+
*/
|
|
229
|
+
export declare function matchesPredicate(predicate: SourcePredicate | null, row: SourceRow): boolean;
|
|
230
|
+
/** Options for {@link inMemoryNodeSource} and {@link inMemoryRelationshipSource}. */
|
|
231
|
+
export interface InMemorySourceOptions {
|
|
232
|
+
/** Declare the source cacheable (default `true`). */
|
|
233
|
+
cacheable?: boolean;
|
|
234
|
+
/** Maximum ids per lookup/expand request (default: unlimited). */
|
|
235
|
+
maxBatchSize?: number;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* A ready-made node source over an in-memory array of rows (each with an
|
|
239
|
+
* `id`). It supports lookup, every predicate operator and paging, which
|
|
240
|
+
* makes it handy for tests, examples and small reference data sets. The
|
|
241
|
+
* array is read on every request, so later mutations are visible.
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* FlowQuery.registerNodeSource("Person", inMemoryNodeSource([{ id: 1, name: "Ada" }]));
|
|
246
|
+
* ```
|
|
247
|
+
*/
|
|
248
|
+
export declare function inMemoryNodeSource(rows: SourceRow[], options?: InMemorySourceOptions): NodeSourceProvider;
|
|
249
|
+
/**
|
|
250
|
+
* A ready-made relationship source over an in-memory array of rows (each
|
|
251
|
+
* with `left_id` and `right_id`), supporting expansion from both sides.
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```typescript
|
|
255
|
+
* FlowQuery.registerRelationshipSource(
|
|
256
|
+
* "KNOWS", "Person", "Person",
|
|
257
|
+
* inMemoryRelationshipSource([{ left_id: 1, right_id: 2, since: 2020 }])
|
|
258
|
+
* );
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
export declare function inMemoryRelationshipSource(rows: SourceRow[], options?: InMemorySourceOptions): RelationshipSourceProvider;
|
|
262
|
+
export {};
|
|
263
|
+
//# sourceMappingURL=source_provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source_provider.d.ts","sourceRoot":"","sources":["../../src/graph/source_provider.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,eAAO,MAAM,uBAAuB,IAAI,CAAC;AAEzC,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAE5C,yEAAyE;AACzE,MAAM,MAAM,iBAAiB,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,CAAC;AAE1E,eAAO,MAAM,mBAAmB,EAAE,SAAS,iBAAiB,EAO3D,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,eAAe,GACrB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,eAAe,EAAE,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,IAAI,GAAG,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,KAAK,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,GACxE;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,GAAG,EAAE,CAAA;CAAE,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IAClC,mEAAmE;IACnE,SAAS,EAAE,iBAAiB,EAAE,CAAC;IAC/B,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,EAAE,CAAC;IACtB;;;;OAIG;IACH,cAAc,CAAC,EAAE,QAAQ,CAAC;CAC7B;AAED,UAAU,sBAAsB;IAC5B,iEAAiE;IACjE,OAAO,EAAE,MAAM,CAAC;IAChB,6EAA6E;IAC7E,UAAU,CAAC,EAAE,qBAAqB,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;;;;;;;GAWG;AACH,wBAAuB,WAAW,CAC9B,SAAS,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,KAAK,OAAO,CAAC;IAAE,IAAI,EAAE,SAAS,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,GAC7F,cAAc,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,OAAO,CAAC,CAiB5C;AAwBD;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,EAAE,GAAG,EAAE,SAAS,GAAG,OAAO,CAyB3F;AAED,qFAAqF;AACrF,MAAM,WAAW,qBAAqB;IAClC,qDAAqD;IACrD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kEAAkE;IAClE,YAAY,CAAC,EAAE,MAAM,CAAC;CACzB;AAkCD;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAC9B,IAAI,EAAE,SAAS,EAAE,EACjB,OAAO,GAAE,qBAA0B,GACpC,kBAAkB,CAMpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,0BAA0B,CACtC,IAAI,EAAE,SAAS,EAAE,EACjB,OAAO,GAAE,qBAA0B,GACpC,0BAA0B,CAkB5B"}
|
|
@@ -0,0 +1,306 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Backend-neutral source provider contract (version 1).
|
|
4
|
+
*
|
|
5
|
+
* A source provider exposes the rows of a virtual node label or
|
|
6
|
+
* relationship type to FlowQuery and declares, through explicit
|
|
7
|
+
* capabilities, which logical operations it can execute natively
|
|
8
|
+
* (lookup by id, adjacency expansion, predicate filtering, paging).
|
|
9
|
+
* FlowQuery plans against these declared operations only; it never
|
|
10
|
+
* inspects what kind of backend sits behind a provider.
|
|
11
|
+
*
|
|
12
|
+
* Rows always describe the *virtual definition*: node rows carry an `id`
|
|
13
|
+
* plus properties, relationship rows carry `left_id`, `right_id` plus
|
|
14
|
+
* properties, exactly as a `CREATE VIRTUAL` definition would return them.
|
|
15
|
+
* Ids are scoped to their label (or relationship type); they do not need
|
|
16
|
+
* to be globally unique.
|
|
17
|
+
*
|
|
18
|
+
* Correctness rule: a provider may return a *superset* of the rows that
|
|
19
|
+
* satisfy a request — FlowQuery always re-applies every constraint
|
|
20
|
+
* locally — but it must never drop a row that satisfies the request.
|
|
21
|
+
*/
|
|
22
|
+
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
23
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
24
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
25
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
26
|
+
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
27
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
28
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
29
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
30
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
31
|
+
function fulfill(value) { resume("next", value); }
|
|
32
|
+
function reject(value) { resume("throw", value); }
|
|
33
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.QueryCancelledError = exports.SourceUnsupportedError = exports.SourceResponseError = exports.SourceCapabilityError = exports.SourceError = exports.PREDICATE_OPERATORS = exports.SOURCE_CONTRACT_VERSION = void 0;
|
|
37
|
+
exports.validateNodeProvider = validateNodeProvider;
|
|
38
|
+
exports.validateRelationshipProvider = validateRelationshipProvider;
|
|
39
|
+
exports.cursorPages = cursorPages;
|
|
40
|
+
exports.matchesPredicate = matchesPredicate;
|
|
41
|
+
exports.inMemoryNodeSource = inMemoryNodeSource;
|
|
42
|
+
exports.inMemoryRelationshipSource = inMemoryRelationshipSource;
|
|
43
|
+
exports.SOURCE_CONTRACT_VERSION = 1;
|
|
44
|
+
exports.PREDICATE_OPERATORS = [
|
|
45
|
+
"eq",
|
|
46
|
+
"gt",
|
|
47
|
+
"gte",
|
|
48
|
+
"lt",
|
|
49
|
+
"lte",
|
|
50
|
+
"in",
|
|
51
|
+
];
|
|
52
|
+
/** Base class of all source-related errors. */
|
|
53
|
+
class SourceError extends Error {
|
|
54
|
+
constructor(message, source = "", operation = "", cause) {
|
|
55
|
+
super(message);
|
|
56
|
+
this.name = "SourceError";
|
|
57
|
+
this.source = source;
|
|
58
|
+
this.operation = operation;
|
|
59
|
+
this.cause = cause;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
exports.SourceError = SourceError;
|
|
63
|
+
/** Invalid capability declaration or provider registration. */
|
|
64
|
+
class SourceCapabilityError extends SourceError {
|
|
65
|
+
constructor(message, source = "") {
|
|
66
|
+
super(message, source, "register");
|
|
67
|
+
this.name = "SourceCapabilityError";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.SourceCapabilityError = SourceCapabilityError;
|
|
71
|
+
/** Malformed provider response (non-array page, missing ids, invalid cursor...). */
|
|
72
|
+
class SourceResponseError extends SourceError {
|
|
73
|
+
constructor(message, source = "", operation = "") {
|
|
74
|
+
super(message, source, operation);
|
|
75
|
+
this.name = "SourceResponseError";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.SourceResponseError = SourceResponseError;
|
|
79
|
+
/**
|
|
80
|
+
* Thrown by a provider to decline an optional operation at runtime.
|
|
81
|
+
* FlowQuery then uses its documented fallback (a scan). Any other
|
|
82
|
+
* error propagates to the caller of the query.
|
|
83
|
+
*/
|
|
84
|
+
class SourceUnsupportedError extends SourceError {
|
|
85
|
+
constructor(message = "Operation not supported", source = "", operation = "") {
|
|
86
|
+
super(message, source, operation);
|
|
87
|
+
this.name = "SourceUnsupportedError";
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.SourceUnsupportedError = SourceUnsupportedError;
|
|
91
|
+
/** Raised when a query is cancelled through `Runner.cancel()`. */
|
|
92
|
+
class QueryCancelledError extends Error {
|
|
93
|
+
constructor(message = "Query cancelled") {
|
|
94
|
+
super(message);
|
|
95
|
+
this.name = "QueryCancelledError";
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.QueryCancelledError = QueryCancelledError;
|
|
99
|
+
function validateBase(caps, name) {
|
|
100
|
+
if (caps === null || typeof caps !== "object") {
|
|
101
|
+
throw new SourceCapabilityError(`Source ${name}: capabilities object is required`, name);
|
|
102
|
+
}
|
|
103
|
+
if (caps.version !== exports.SOURCE_CONTRACT_VERSION) {
|
|
104
|
+
throw new SourceCapabilityError(`Source ${name}: unsupported capability version ${JSON.stringify(caps.version)}; expected ${exports.SOURCE_CONTRACT_VERSION}`, name);
|
|
105
|
+
}
|
|
106
|
+
if (caps.maxBatchSize !== undefined &&
|
|
107
|
+
(!Number.isInteger(caps.maxBatchSize) || caps.maxBatchSize < 1)) {
|
|
108
|
+
throw new SourceCapabilityError(`Source ${name}: maxBatchSize must be a positive integer`, name);
|
|
109
|
+
}
|
|
110
|
+
if (caps.predicates !== undefined) {
|
|
111
|
+
const p = caps.predicates;
|
|
112
|
+
if (p === null || typeof p !== "object" || !Array.isArray(p.operators)) {
|
|
113
|
+
throw new SourceCapabilityError(`Source ${name}: predicates.operators must be an array`, name);
|
|
114
|
+
}
|
|
115
|
+
for (const op of p.operators) {
|
|
116
|
+
if (!exports.PREDICATE_OPERATORS.includes(op)) {
|
|
117
|
+
throw new SourceCapabilityError(`Source ${name}: unknown predicate operator ${JSON.stringify(op)}; supported: ${exports.PREDICATE_OPERATORS.join(", ")}`, name);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
if (p.properties !== undefined && !Array.isArray(p.properties)) {
|
|
121
|
+
throw new SourceCapabilityError(`Source ${name}: predicates.properties must be an array of column names`, name);
|
|
122
|
+
}
|
|
123
|
+
if (p.stringOrdering !== undefined && p.stringOrdering !== "binary") {
|
|
124
|
+
throw new SourceCapabilityError(`Source ${name}: predicates.stringOrdering must be "binary" when set`, name);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
/** Validate a node provider; throws {@link SourceCapabilityError} with an actionable message. */
|
|
129
|
+
function validateNodeProvider(provider, name) {
|
|
130
|
+
if (provider === null || typeof provider !== "object") {
|
|
131
|
+
throw new SourceCapabilityError(`Source ${name}: provider object is required`, name);
|
|
132
|
+
}
|
|
133
|
+
validateBase(provider.capabilities, name);
|
|
134
|
+
if (typeof provider.scan !== "function") {
|
|
135
|
+
throw new SourceCapabilityError(`Source ${name}: provider must implement scan()`, name);
|
|
136
|
+
}
|
|
137
|
+
if (provider.capabilities.lookup && typeof provider.lookup !== "function") {
|
|
138
|
+
throw new SourceCapabilityError(`Source ${name}: capabilities.lookup is true but lookup() is not implemented`, name);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/** Validate a relationship provider; throws {@link SourceCapabilityError} with an actionable message. */
|
|
142
|
+
function validateRelationshipProvider(provider, name) {
|
|
143
|
+
if (provider === null || typeof provider !== "object") {
|
|
144
|
+
throw new SourceCapabilityError(`Source ${name}: provider object is required`, name);
|
|
145
|
+
}
|
|
146
|
+
validateBase(provider.capabilities, name);
|
|
147
|
+
if (typeof provider.scan !== "function") {
|
|
148
|
+
throw new SourceCapabilityError(`Source ${name}: provider must implement scan()`, name);
|
|
149
|
+
}
|
|
150
|
+
const expand = provider.capabilities.expand;
|
|
151
|
+
if (expand !== undefined) {
|
|
152
|
+
if (expand === null || typeof expand !== "object") {
|
|
153
|
+
throw new SourceCapabilityError(`Source ${name}: capabilities.expand must be an object like { left: true, right: true }`, name);
|
|
154
|
+
}
|
|
155
|
+
if ((expand.left || expand.right) && typeof provider.expand !== "function") {
|
|
156
|
+
throw new SourceCapabilityError(`Source ${name}: capabilities.expand is declared but expand() is not implemented`, name);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Turn a continuation-token API into a page iterator. Tokens stay opaque
|
|
162
|
+
* to FlowQuery; a token repeated twice in a row is reported as an invalid
|
|
163
|
+
* cursor instead of looping forever.
|
|
164
|
+
*
|
|
165
|
+
* @example
|
|
166
|
+
* ```typescript
|
|
167
|
+
* scan(req, ctx) {
|
|
168
|
+
* return cursorPages((cursor) => backend.query(req, cursor, req.pageSize));
|
|
169
|
+
* }
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
function cursorPages(fetchPage) {
|
|
173
|
+
return __asyncGenerator(this, arguments, function* cursorPages_1() {
|
|
174
|
+
var _a;
|
|
175
|
+
let cursor = null;
|
|
176
|
+
while (true) {
|
|
177
|
+
const page = yield __await(fetchPage(cursor));
|
|
178
|
+
if (page === null || typeof page !== "object" || !Array.isArray(page.rows)) {
|
|
179
|
+
throw new SourceResponseError("Cursor page must be an object with a rows array");
|
|
180
|
+
}
|
|
181
|
+
yield yield __await(page.rows);
|
|
182
|
+
const next = (_a = page.cursor) !== null && _a !== void 0 ? _a : null;
|
|
183
|
+
if (next === null) {
|
|
184
|
+
return yield __await(void 0);
|
|
185
|
+
}
|
|
186
|
+
if (next === cursor) {
|
|
187
|
+
throw new SourceResponseError(`Invalid continuation token: ${String(next)} repeated`);
|
|
188
|
+
}
|
|
189
|
+
cursor = next;
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
function isRangeComparable(value, bound) {
|
|
194
|
+
return (value !== null &&
|
|
195
|
+
value !== undefined &&
|
|
196
|
+
(typeof bound === "number" || typeof bound === "string") &&
|
|
197
|
+
typeof value === typeof bound);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* A source may only drop a row for an equality/IN term when the property
|
|
201
|
+
* is absent or holds a number/string that differs from every value;
|
|
202
|
+
* other values (booleans, lists, maps...) must be returned and are
|
|
203
|
+
* re-checked by FlowQuery.
|
|
204
|
+
*/
|
|
205
|
+
function matchesEquality(row, property, values) {
|
|
206
|
+
if (!(property in row))
|
|
207
|
+
return false;
|
|
208
|
+
const value = row[property];
|
|
209
|
+
if (typeof value !== "number" && typeof value !== "string")
|
|
210
|
+
return true;
|
|
211
|
+
return values.includes(value);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Reference implementation of {@link SourcePredicate} semantics for
|
|
215
|
+
* in-memory providers and tests. Returns `true` when the row must be
|
|
216
|
+
* returned by a source receiving this predicate.
|
|
217
|
+
*/
|
|
218
|
+
function matchesPredicate(predicate, row) {
|
|
219
|
+
if (predicate === null)
|
|
220
|
+
return true;
|
|
221
|
+
switch (predicate.op) {
|
|
222
|
+
case "and":
|
|
223
|
+
return predicate.terms.every((t) => matchesPredicate(t, row));
|
|
224
|
+
case "eq":
|
|
225
|
+
return matchesEquality(row, predicate.property, [predicate.value]);
|
|
226
|
+
case "in":
|
|
227
|
+
return matchesEquality(row, predicate.property, predicate.values);
|
|
228
|
+
default: {
|
|
229
|
+
const value = row[predicate.property];
|
|
230
|
+
if (!isRangeComparable(value, predicate.value))
|
|
231
|
+
return true;
|
|
232
|
+
switch (predicate.op) {
|
|
233
|
+
case "gt":
|
|
234
|
+
return value > predicate.value;
|
|
235
|
+
case "gte":
|
|
236
|
+
return value >= predicate.value;
|
|
237
|
+
case "lt":
|
|
238
|
+
return value < predicate.value;
|
|
239
|
+
case "lte":
|
|
240
|
+
return value <= predicate.value;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return true;
|
|
245
|
+
}
|
|
246
|
+
function* pagesOf(rows, pageSize) {
|
|
247
|
+
const size = Number.isInteger(pageSize) && pageSize > 0 ? pageSize : rows.length || 1;
|
|
248
|
+
for (let i = 0; i < rows.length; i += size) {
|
|
249
|
+
yield rows.slice(i, i + size);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
function filterRows(rows, predicate, field, ids) {
|
|
253
|
+
const wanted = ids === null ? null : new Set(ids);
|
|
254
|
+
return rows.filter((row) => (wanted === null || (field !== null && wanted.has(row[field]))) &&
|
|
255
|
+
matchesPredicate(predicate, row));
|
|
256
|
+
}
|
|
257
|
+
function inMemoryCapabilities(options) {
|
|
258
|
+
var _a;
|
|
259
|
+
const caps = {
|
|
260
|
+
version: exports.SOURCE_CONTRACT_VERSION,
|
|
261
|
+
cacheable: (_a = options.cacheable) !== null && _a !== void 0 ? _a : true,
|
|
262
|
+
streaming: true,
|
|
263
|
+
predicates: { operators: [...exports.PREDICATE_OPERATORS], stringOrdering: "binary" },
|
|
264
|
+
};
|
|
265
|
+
if (options.maxBatchSize !== undefined)
|
|
266
|
+
caps.maxBatchSize = options.maxBatchSize;
|
|
267
|
+
return caps;
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* A ready-made node source over an in-memory array of rows (each with an
|
|
271
|
+
* `id`). It supports lookup, every predicate operator and paging, which
|
|
272
|
+
* makes it handy for tests, examples and small reference data sets. The
|
|
273
|
+
* array is read on every request, so later mutations are visible.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```typescript
|
|
277
|
+
* FlowQuery.registerNodeSource("Person", inMemoryNodeSource([{ id: 1, name: "Ada" }]));
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
function inMemoryNodeSource(rows, options = {}) {
|
|
281
|
+
return {
|
|
282
|
+
capabilities: Object.assign(Object.assign({}, inMemoryCapabilities(options)), { lookup: true }),
|
|
283
|
+
scan: (req) => pagesOf(filterRows(rows, req.predicate, null, null), req.pageSize),
|
|
284
|
+
lookup: (req) => pagesOf(filterRows(rows, req.predicate, "id", req.ids), req.pageSize),
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* A ready-made relationship source over an in-memory array of rows (each
|
|
289
|
+
* with `left_id` and `right_id`), supporting expansion from both sides.
|
|
290
|
+
*
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* FlowQuery.registerRelationshipSource(
|
|
294
|
+
* "KNOWS", "Person", "Person",
|
|
295
|
+
* inMemoryRelationshipSource([{ left_id: 1, right_id: 2, since: 2020 }])
|
|
296
|
+
* );
|
|
297
|
+
* ```
|
|
298
|
+
*/
|
|
299
|
+
function inMemoryRelationshipSource(rows, options = {}) {
|
|
300
|
+
return {
|
|
301
|
+
capabilities: Object.assign(Object.assign({}, inMemoryCapabilities(options)), { expand: { left: true, right: true } }),
|
|
302
|
+
scan: (req) => pagesOf(filterRows(rows, req.predicate, null, null), req.pageSize),
|
|
303
|
+
expand: (req) => pagesOf(filterRows(rows, req.predicate, req.side === "left" ? "left_id" : "right_id", req.ids), req.pageSize),
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
//# sourceMappingURL=source_provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"source_provider.js","sourceRoot":"","sources":["../../src/graph/source_provider.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;;;;;;;;;;;;;;AA2RH,oDAcC;AAGD,oEA0BC;AAcD,kCAmBC;AA6BD,4CAyBC;AAqDD,gDASC;AAcD,gEAqBC;AA5fY,QAAA,uBAAuB,GAAG,CAAC,CAAC;AAO5B,QAAA,mBAAmB,GAAiC;IAC7D,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;CACP,CAAC;AAkKF,+CAA+C;AAC/C,MAAa,WAAY,SAAQ,KAAK;IAIlC,YAAY,OAAe,EAAE,SAAiB,EAAE,E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C,SAAS,EAAE,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC;KACzF,CAAC;AACN,CAAC;AAED;;;;;;;;;;;GAWG;AACH,SAAgB,0BAA0B,CACtC,IAAiB,EACjB,UAAiC,EAAE;IAEnC,OAAO;QACH,YAAY,EAAE,gCACP,oBAAoB,CAAC,OAAO,CAAC,KAChC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,GACJ;QACnC,IAAI,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,GAAG,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC;QACjF,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CACZ,OAAO,CACH,UAAU,CACN,IAAI,EACJ,GAAG,CAAC,SAAS,EACb,GAAG,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,EAC5C,GAAG,CAAC,GAAG,CACV,EACD,GAAG,CAAC,QAAQ,CACf;KACR,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import SourceContext from "./source_context";
|
|
2
|
+
import { NodeSourceCapabilities, RelationshipSourceCapabilities, SourceReadContext, SourceRow } from "./source_provider";
|
|
3
|
+
import type VirtualStatement from "./virtual_statement";
|
|
4
|
+
/**
|
|
5
|
+
* Adapts a `CREATE VIRTUAL` definition to the source provider contract.
|
|
6
|
+
*
|
|
7
|
+
* The definition is opted in with explicit capabilities; every request
|
|
8
|
+
* runs the inner statement with `$request` bound to the request envelope
|
|
9
|
+
* (`operation`, `label`/`type`, `ids`, `side`, `predicate`, `pageSize`)
|
|
10
|
+
* while `$args` keeps its legacy meaning. Statements that ignore part
|
|
11
|
+
* of the request remain correct because FlowQuery re-checks every row.
|
|
12
|
+
*/
|
|
13
|
+
export declare class StatementSourceProvider {
|
|
14
|
+
private readonly _virtual;
|
|
15
|
+
readonly capabilities: NodeSourceCapabilities & RelationshipSourceCapabilities;
|
|
16
|
+
constructor(_virtual: VirtualStatement, capabilities: NodeSourceCapabilities & RelationshipSourceCapabilities);
|
|
17
|
+
private _run;
|
|
18
|
+
scan(request: any, context: SourceReadContext): any;
|
|
19
|
+
lookup(request: any, context: SourceReadContext): any;
|
|
20
|
+
expand(request: any, context: SourceReadContext): any;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Fully read a provider's scan (legacy eager paths: schema
|
|
24
|
+
* introspection, pattern expressions and mixed legacy/provider patterns).
|
|
25
|
+
*/
|
|
26
|
+
export declare function materializeScan(provider: any, kind: "node" | "relationship", name: string, base: Record<string, any>, args: Record<string, any> | null, ctx: SourceContext | null): Promise<SourceRow[]>;
|
|
27
|
+
//# sourceMappingURL=statement_source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"statement_source.d.ts","sourceRoot":"","sources":["../../src/graph/statement_source.ts"],"names":[],"mappings":"AAAA,OAAO,aAA4B,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACH,sBAAsB,EACtB,8BAA8B,EAC9B,iBAAiB,EACjB,SAAS,EACZ,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAC;AAExD;;;;;;;;GAQG;AACH,qBAAa,uBAAuB;IAE5B,OAAO,CAAC,QAAQ,CAAC,QAAQ;aACT,YAAY,EAAE,sBAAsB,GAAG,8BAA8B;gBADpE,QAAQ,EAAE,gBAAgB,EAC3B,YAAY,EAAE,sBAAsB,GAAG,8BAA8B;IAEzF,OAAO,CAAC,IAAI;IAOL,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,GAAG;IAGnD,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,GAAG;IAGrD,MAAM,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,iBAAiB,GAAG,GAAG;CAG/D;AAED;;;GAGG;AACH,wBAAsB,eAAe,CACjC,QAAQ,EAAE,GAAG,EACb,IAAI,EAAE,MAAM,GAAG,cAAc,EAC7B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EACzB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,IAAI,EAChC,GAAG,EAAE,aAAa,GAAG,IAAI,GAC1B,OAAO,CAAC,SAAS,EAAE,CAAC,CAkBtB"}
|