@_linked/core 2.12.0 → 2.13.0
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 +6 -0
- package/lib/esm/queries/IRPipeline.d.ts +7 -1
- package/lib/esm/queries/IRPipeline.js +20 -6
- package/lib/esm/queries/IRPipeline.js.map +1 -1
- package/lib/esm/queries/queryDispatch.js +12 -2
- package/lib/esm/queries/queryDispatch.js.map +1 -1
- package/package.json +10 -13
- package/lib/cjs/collections/CoreSet.d.ts +0 -47
- package/lib/cjs/collections/CoreSet.js +0 -136
- package/lib/cjs/collections/CoreSet.js.map +0 -1
- package/lib/cjs/collections/ShapeSet.d.ts +0 -6
- package/lib/cjs/collections/ShapeSet.js +0 -20
- package/lib/cjs/collections/ShapeSet.js.map +0 -1
- package/lib/cjs/expressions/Expr.d.ts +0 -29
- package/lib/cjs/expressions/Expr.js +0 -80
- package/lib/cjs/expressions/Expr.js.map +0 -1
- package/lib/cjs/expressions/ExpressionMethods.d.ts +0 -85
- package/lib/cjs/expressions/ExpressionMethods.js +0 -3
- package/lib/cjs/expressions/ExpressionMethods.js.map +0 -1
- package/lib/cjs/expressions/ExpressionNode.d.ts +0 -144
- package/lib/cjs/expressions/ExpressionNode.js +0 -432
- package/lib/cjs/expressions/ExpressionNode.js.map +0 -1
- package/lib/cjs/index.d.ts +0 -29
- package/lib/cjs/index.js +0 -65
- package/lib/cjs/index.js.map +0 -1
- package/lib/cjs/interfaces/ICoreIterable.d.ts +0 -14
- package/lib/cjs/interfaces/ICoreIterable.js +0 -3
- package/lib/cjs/interfaces/ICoreIterable.js.map +0 -1
- package/lib/cjs/interfaces/IDataset.d.ts +0 -26
- package/lib/cjs/interfaces/IDataset.js +0 -3
- package/lib/cjs/interfaces/IDataset.js.map +0 -1
- package/lib/cjs/interfaces/IFileStore.d.ts +0 -16
- package/lib/cjs/interfaces/IFileStore.js +0 -3
- package/lib/cjs/interfaces/IFileStore.js.map +0 -1
- package/lib/cjs/ontologies/linked-core.d.ts +0 -15
- package/lib/cjs/ontologies/linked-core.js +0 -38
- package/lib/cjs/ontologies/linked-core.js.map +0 -1
- package/lib/cjs/ontologies/npm.d.ts +0 -6
- package/lib/cjs/ontologies/npm.js +0 -15
- package/lib/cjs/ontologies/npm.js.map +0 -1
- package/lib/cjs/ontologies/owl.d.ts +0 -14
- package/lib/cjs/ontologies/owl.js +0 -21
- package/lib/cjs/ontologies/owl.js.map +0 -1
- package/lib/cjs/ontologies/rdf.d.ts +0 -13
- package/lib/cjs/ontologies/rdf.js +0 -27
- package/lib/cjs/ontologies/rdf.js.map +0 -1
- package/lib/cjs/ontologies/rdfs.d.ts +0 -16
- package/lib/cjs/ontologies/rdfs.js +0 -33
- package/lib/cjs/ontologies/rdfs.js.map +0 -1
- package/lib/cjs/ontologies/shacl.d.ts +0 -103
- package/lib/cjs/ontologies/shacl.js +0 -152
- package/lib/cjs/ontologies/shacl.js.map +0 -1
- package/lib/cjs/ontologies/xsd.d.ts +0 -19
- package/lib/cjs/ontologies/xsd.js +0 -41
- package/lib/cjs/ontologies/xsd.js.map +0 -1
- package/lib/cjs/package.d.ts +0 -4
- package/lib/cjs/package.js +0 -6
- package/lib/cjs/package.js.map +0 -1
- package/lib/cjs/package.json +0 -9
- package/lib/cjs/paths/PropertyPathExpr.d.ts +0 -38
- package/lib/cjs/paths/PropertyPathExpr.js +0 -221
- package/lib/cjs/paths/PropertyPathExpr.js.map +0 -1
- package/lib/cjs/paths/normalizePropertyPath.d.ts +0 -23
- package/lib/cjs/paths/normalizePropertyPath.js +0 -75
- package/lib/cjs/paths/normalizePropertyPath.js.map +0 -1
- package/lib/cjs/paths/pathExprToSparql.d.ts +0 -14
- package/lib/cjs/paths/pathExprToSparql.js +0 -136
- package/lib/cjs/paths/pathExprToSparql.js.map +0 -1
- package/lib/cjs/queries/ContextRef.d.ts +0 -32
- package/lib/cjs/queries/ContextRef.js +0 -69
- package/lib/cjs/queries/ContextRef.js.map +0 -1
- package/lib/cjs/queries/CreateBuilder.d.ts +0 -59
- package/lib/cjs/queries/CreateBuilder.js +0 -138
- package/lib/cjs/queries/CreateBuilder.js.map +0 -1
- package/lib/cjs/queries/CreateQuery.d.ts +0 -20
- package/lib/cjs/queries/CreateQuery.js +0 -3
- package/lib/cjs/queries/CreateQuery.js.map +0 -1
- package/lib/cjs/queries/DeleteBuilder.d.ts +0 -56
- package/lib/cjs/queries/DeleteBuilder.js +0 -172
- package/lib/cjs/queries/DeleteBuilder.js.map +0 -1
- package/lib/cjs/queries/DeleteQuery.d.ts +0 -37
- package/lib/cjs/queries/DeleteQuery.js +0 -3
- package/lib/cjs/queries/DeleteQuery.js.map +0 -1
- package/lib/cjs/queries/DslJsonExpression.d.ts +0 -68
- package/lib/cjs/queries/DslJsonExpression.js +0 -427
- package/lib/cjs/queries/DslJsonExpression.js.map +0 -1
- package/lib/cjs/queries/FieldSet.d.ts +0 -310
- package/lib/cjs/queries/FieldSet.js +0 -802
- package/lib/cjs/queries/FieldSet.js.map +0 -1
- package/lib/cjs/queries/IRAliasScope.d.ts +0 -20
- package/lib/cjs/queries/IRAliasScope.js +0 -52
- package/lib/cjs/queries/IRAliasScope.js.map +0 -1
- package/lib/cjs/queries/IRCanonicalize.d.ts +0 -19
- package/lib/cjs/queries/IRCanonicalize.js +0 -19
- package/lib/cjs/queries/IRCanonicalize.js.map +0 -1
- package/lib/cjs/queries/IRDesugar.d.ts +0 -123
- package/lib/cjs/queries/IRDesugar.js +0 -261
- package/lib/cjs/queries/IRDesugar.js.map +0 -1
- package/lib/cjs/queries/IRLower.d.ts +0 -25
- package/lib/cjs/queries/IRLower.js +0 -398
- package/lib/cjs/queries/IRLower.js.map +0 -1
- package/lib/cjs/queries/IRMutation.d.ts +0 -53
- package/lib/cjs/queries/IRMutation.js +0 -130
- package/lib/cjs/queries/IRMutation.js.map +0 -1
- package/lib/cjs/queries/IRPipeline.d.ts +0 -8
- package/lib/cjs/queries/IRPipeline.js +0 -25
- package/lib/cjs/queries/IRPipeline.js.map +0 -1
- package/lib/cjs/queries/IRProjection.d.ts +0 -39
- package/lib/cjs/queries/IRProjection.js +0 -105
- package/lib/cjs/queries/IRProjection.js.map +0 -1
- package/lib/cjs/queries/IntermediateRepresentation.d.ts +0 -282
- package/lib/cjs/queries/IntermediateRepresentation.js +0 -3
- package/lib/cjs/queries/IntermediateRepresentation.js.map +0 -1
- package/lib/cjs/queries/MutationQuery.d.ts +0 -50
- package/lib/cjs/queries/MutationQuery.js +0 -334
- package/lib/cjs/queries/MutationQuery.js.map +0 -1
- package/lib/cjs/queries/MutationSerialization.d.ts +0 -102
- package/lib/cjs/queries/MutationSerialization.js +0 -207
- package/lib/cjs/queries/MutationSerialization.js.map +0 -1
- package/lib/cjs/queries/MutationThenable.d.ts +0 -18
- package/lib/cjs/queries/MutationThenable.js +0 -32
- package/lib/cjs/queries/MutationThenable.js.map +0 -1
- package/lib/cjs/queries/PropertyPath.d.ts +0 -38
- package/lib/cjs/queries/PropertyPath.js +0 -82
- package/lib/cjs/queries/PropertyPath.js.map +0 -1
- package/lib/cjs/queries/ProxiedPathBuilder.d.ts +0 -14
- package/lib/cjs/queries/ProxiedPathBuilder.js +0 -29
- package/lib/cjs/queries/ProxiedPathBuilder.js.map +0 -1
- package/lib/cjs/queries/QueryBuilder.d.ts +0 -193
- package/lib/cjs/queries/QueryBuilder.js +0 -519
- package/lib/cjs/queries/QueryBuilder.js.map +0 -1
- package/lib/cjs/queries/QueryBuilderSerialization.d.ts +0 -31
- package/lib/cjs/queries/QueryBuilderSerialization.js +0 -68
- package/lib/cjs/queries/QueryBuilderSerialization.js.map +0 -1
- package/lib/cjs/queries/QueryContext.d.ts +0 -50
- package/lib/cjs/queries/QueryContext.js +0 -147
- package/lib/cjs/queries/QueryContext.js.map +0 -1
- package/lib/cjs/queries/QueryFactory.d.ts +0 -80
- package/lib/cjs/queries/QueryFactory.js +0 -21
- package/lib/cjs/queries/QueryFactory.js.map +0 -1
- package/lib/cjs/queries/SelectQuery.d.ts +0 -302
- package/lib/cjs/queries/SelectQuery.js +0 -761
- package/lib/cjs/queries/SelectQuery.js.map +0 -1
- package/lib/cjs/queries/UpdateBuilder.d.ts +0 -69
- package/lib/cjs/queries/UpdateBuilder.js +0 -199
- package/lib/cjs/queries/UpdateBuilder.js.map +0 -1
- package/lib/cjs/queries/UpdateQuery.d.ts +0 -18
- package/lib/cjs/queries/UpdateQuery.js +0 -3
- package/lib/cjs/queries/UpdateQuery.js.map +0 -1
- package/lib/cjs/queries/fromJSON.d.ts +0 -16
- package/lib/cjs/queries/fromJSON.js +0 -41
- package/lib/cjs/queries/fromJSON.js.map +0 -1
- package/lib/cjs/queries/lower.d.ts +0 -28
- package/lib/cjs/queries/lower.js +0 -114
- package/lib/cjs/queries/lower.js.map +0 -1
- package/lib/cjs/queries/lowerMutationJSON.d.ts +0 -25
- package/lib/cjs/queries/lowerMutationJSON.js +0 -173
- package/lib/cjs/queries/lowerMutationJSON.js.map +0 -1
- package/lib/cjs/queries/mutationLowerSpec.d.ts +0 -32
- package/lib/cjs/queries/mutationLowerSpec.js +0 -8
- package/lib/cjs/queries/mutationLowerSpec.js.map +0 -1
- package/lib/cjs/queries/queryDispatch.d.ts +0 -33
- package/lib/cjs/queries/queryDispatch.js +0 -33
- package/lib/cjs/queries/queryDispatch.js.map +0 -1
- package/lib/cjs/queries/resolveShape.d.ts +0 -10
- package/lib/cjs/queries/resolveShape.js +0 -23
- package/lib/cjs/queries/resolveShape.js.map +0 -1
- package/lib/cjs/queries/wireVersion.d.ts +0 -7
- package/lib/cjs/queries/wireVersion.js +0 -25
- package/lib/cjs/queries/wireVersion.js.map +0 -1
- package/lib/cjs/shapes/List.d.ts +0 -35
- package/lib/cjs/shapes/List.js +0 -72
- package/lib/cjs/shapes/List.js.map +0 -1
- package/lib/cjs/shapes/PathNode.d.ts +0 -20
- package/lib/cjs/shapes/PathNode.js +0 -68
- package/lib/cjs/shapes/PathNode.js.map +0 -1
- package/lib/cjs/shapes/SHACL.d.ts +0 -300
- package/lib/cjs/shapes/SHACL.js +0 -612
- package/lib/cjs/shapes/SHACL.js.map +0 -1
- package/lib/cjs/shapes/Shape.d.ts +0 -74
- package/lib/cjs/shapes/Shape.js +0 -124
- package/lib/cjs/shapes/Shape.js.map +0 -1
- package/lib/cjs/shapes/serializePathToNodeData.d.ts +0 -24
- package/lib/cjs/shapes/serializePathToNodeData.js +0 -67
- package/lib/cjs/shapes/serializePathToNodeData.js.map +0 -1
- package/lib/cjs/shapes/syncShapes.d.ts +0 -38
- package/lib/cjs/shapes/syncShapes.js +0 -214
- package/lib/cjs/shapes/syncShapes.js.map +0 -1
- package/lib/cjs/sparql/SparqlAlgebra.d.ts +0 -190
- package/lib/cjs/sparql/SparqlAlgebra.js +0 -4
- package/lib/cjs/sparql/SparqlAlgebra.js.map +0 -1
- package/lib/cjs/sparql/SparqlDataset.d.ts +0 -60
- package/lib/cjs/sparql/SparqlDataset.js +0 -117
- package/lib/cjs/sparql/SparqlDataset.js.map +0 -1
- package/lib/cjs/sparql/algebraToString.d.ts +0 -13
- package/lib/cjs/sparql/algebraToString.js +0 -385
- package/lib/cjs/sparql/algebraToString.js.map +0 -1
- package/lib/cjs/sparql/index.d.ts +0 -9
- package/lib/cjs/sparql/index.js +0 -41
- package/lib/cjs/sparql/index.js.map +0 -1
- package/lib/cjs/sparql/irToAlgebra.d.ts +0 -79
- package/lib/cjs/sparql/irToAlgebra.js +0 -2042
- package/lib/cjs/sparql/irToAlgebra.js.map +0 -1
- package/lib/cjs/sparql/resultMapping.d.ts +0 -36
- package/lib/cjs/sparql/resultMapping.js +0 -563
- package/lib/cjs/sparql/resultMapping.js.map +0 -1
- package/lib/cjs/sparql/sparqlUtils.d.ts +0 -53
- package/lib/cjs/sparql/sparqlUtils.js +0 -154
- package/lib/cjs/sparql/sparqlUtils.js.map +0 -1
- package/lib/cjs/utils/LinkedErrorLogging.d.ts +0 -13
- package/lib/cjs/utils/LinkedErrorLogging.js +0 -22
- package/lib/cjs/utils/LinkedErrorLogging.js.map +0 -1
- package/lib/cjs/utils/LinkedFileStorage.d.ts +0 -23
- package/lib/cjs/utils/LinkedFileStorage.js +0 -62
- package/lib/cjs/utils/LinkedFileStorage.js.map +0 -1
- package/lib/cjs/utils/LinkedStorage.d.ts +0 -40
- package/lib/cjs/utils/LinkedStorage.js +0 -148
- package/lib/cjs/utils/LinkedStorage.js.map +0 -1
- package/lib/cjs/utils/NameSpace.d.ts +0 -2
- package/lib/cjs/utils/NameSpace.js +0 -8
- package/lib/cjs/utils/NameSpace.js.map +0 -1
- package/lib/cjs/utils/NodeReference.d.ts +0 -30
- package/lib/cjs/utils/NodeReference.js +0 -54
- package/lib/cjs/utils/NodeReference.js.map +0 -1
- package/lib/cjs/utils/Package.d.ts +0 -153
- package/lib/cjs/utils/Package.js +0 -419
- package/lib/cjs/utils/Package.js.map +0 -1
- package/lib/cjs/utils/Prefix.d.ts +0 -22
- package/lib/cjs/utils/Prefix.js +0 -104
- package/lib/cjs/utils/Prefix.js.map +0 -1
- package/lib/cjs/utils/ShapeClass.d.ts +0 -30
- package/lib/cjs/utils/ShapeClass.js +0 -180
- package/lib/cjs/utils/ShapeClass.js.map +0 -1
- package/lib/cjs/utils/URI.d.ts +0 -18
- package/lib/cjs/utils/URI.js +0 -42
- package/lib/cjs/utils/URI.js.map +0 -1
- package/lib/cjs/utils/cached.d.ts +0 -14
- package/lib/cjs/utils/cached.js +0 -71
- package/lib/cjs/utils/cached.js.map +0 -1
- package/lib/cjs/utils/loadStores.d.ts +0 -34
- package/lib/cjs/utils/loadStores.js +0 -105
- package/lib/cjs/utils/loadStores.js.map +0 -1
- package/lib/cjs/utils/parseDatasetsConfig.d.ts +0 -49
- package/lib/cjs/utils/parseDatasetsConfig.js +0 -110
- package/lib/cjs/utils/parseDatasetsConfig.js.map +0 -1
- package/lib/esm/package.json +0 -9
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { type QShape } from './SelectQuery.js';
|
|
2
|
-
import { Shape } from '../shapes/Shape.js';
|
|
3
|
-
/**
|
|
4
|
-
* A live reference returned by getQueryContext when the context hasn't been set yet.
|
|
5
|
-
* Its `id` getter resolves lazily from the global context map, so queries built with
|
|
6
|
-
* a PendingQueryContext will pick up the value once it's set (e.g. after auth completes).
|
|
7
|
-
*/
|
|
8
|
-
export declare class PendingQueryContext {
|
|
9
|
-
readonly contextName: string;
|
|
10
|
-
constructor(contextName: string);
|
|
11
|
-
get id(): string | undefined;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Thrown when a query carrying a context reference is lowered but the context
|
|
15
|
-
* isn't set in the current process. A context ref is carried in DSL-JSON and
|
|
16
|
-
* resolves at lowering time against whatever context map is available (e.g.
|
|
17
|
-
* server-side auth); if it can't resolve, lowering throws this rather than
|
|
18
|
-
* silently producing a subject-less query.
|
|
19
|
-
*/
|
|
20
|
-
export declare class UnresolvedContextError extends Error {
|
|
21
|
-
readonly contextName: string;
|
|
22
|
-
constructor(contextName: string);
|
|
23
|
-
}
|
|
24
|
-
/** Listener notified (with the changed context name) whenever a context is set or cleared. */
|
|
25
|
-
export type QueryContextListener = (name: string) => void;
|
|
26
|
-
/**
|
|
27
|
-
* Subscribe to query-context changes. Returns an unsubscribe function.
|
|
28
|
-
*
|
|
29
|
-
* This is the primitive that makes context resolution reactive: a consuming layer
|
|
30
|
-
* (e.g. React components) subscribes and re-runs affected queries when the context
|
|
31
|
-
* lands — so a query that resolved to `null` while the context was unset simply
|
|
32
|
-
* re-runs and resolves once it's available ("waiting"), and re-runs again on any
|
|
33
|
-
* later change ("auto re-resolve"). Core only emits the change; re-execution is the
|
|
34
|
-
* consumer's responsibility.
|
|
35
|
-
*/
|
|
36
|
-
export declare function subscribeQueryContext(listener: QueryContextListener): () => void;
|
|
37
|
-
/**
|
|
38
|
-
* Normalize any query-context value to a {@link PendingQueryContext} carrying its name,
|
|
39
|
-
* or return `undefined` if the value is not a context reference.
|
|
40
|
-
*
|
|
41
|
-
* A context appears in two runtime forms: a `PendingQueryContext` (the context was unset
|
|
42
|
-
* when `getQueryContext()` was called) or a resolved `QueryShape` stamped with
|
|
43
|
-
* `__queryContextName` (it was already set). Both must be treated as the same `{@ctx}`
|
|
44
|
-
* reference wherever a node value/id is accepted (mutation field values, delete ids), so
|
|
45
|
-
* that context-bound mutations behave identically whether the context is set or unset at
|
|
46
|
-
* build time — resolution always happens at lowering.
|
|
47
|
-
*/
|
|
48
|
-
export declare function asContextRef(value: unknown): PendingQueryContext | undefined;
|
|
49
|
-
export declare function getQueryContext<T extends Shape>(name: string): QShape<T>;
|
|
50
|
-
export declare function setQueryContext(name: string, value: any, shapeType?: any): void;
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnresolvedContextError = exports.PendingQueryContext = void 0;
|
|
4
|
-
exports.subscribeQueryContext = subscribeQueryContext;
|
|
5
|
-
exports.asContextRef = asContextRef;
|
|
6
|
-
exports.getQueryContext = getQueryContext;
|
|
7
|
-
exports.setQueryContext = setQueryContext;
|
|
8
|
-
const SelectQuery_js_1 = require("./SelectQuery.js");
|
|
9
|
-
const Shape_js_1 = require("../shapes/Shape.js");
|
|
10
|
-
const queryContext = new Map();
|
|
11
|
-
/**
|
|
12
|
-
* A live reference returned by getQueryContext when the context hasn't been set yet.
|
|
13
|
-
* Its `id` getter resolves lazily from the global context map, so queries built with
|
|
14
|
-
* a PendingQueryContext will pick up the value once it's set (e.g. after auth completes).
|
|
15
|
-
*/
|
|
16
|
-
class PendingQueryContext {
|
|
17
|
-
constructor(contextName) {
|
|
18
|
-
this.contextName = contextName;
|
|
19
|
-
}
|
|
20
|
-
get id() {
|
|
21
|
-
var _a;
|
|
22
|
-
return (_a = queryContext.get(this.contextName)) === null || _a === void 0 ? void 0 : _a.id;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
exports.PendingQueryContext = PendingQueryContext;
|
|
26
|
-
/**
|
|
27
|
-
* Thrown when a query carrying a context reference is lowered but the context
|
|
28
|
-
* isn't set in the current process. A context ref is carried in DSL-JSON and
|
|
29
|
-
* resolves at lowering time against whatever context map is available (e.g.
|
|
30
|
-
* server-side auth); if it can't resolve, lowering throws this rather than
|
|
31
|
-
* silently producing a subject-less query.
|
|
32
|
-
*/
|
|
33
|
-
class UnresolvedContextError extends Error {
|
|
34
|
-
constructor(contextName) {
|
|
35
|
-
super(`Query context "${contextName}" is not set and could not be resolved at lowering time.`);
|
|
36
|
-
this.contextName = contextName;
|
|
37
|
-
this.name = 'UnresolvedContextError';
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
exports.UnresolvedContextError = UnresolvedContextError;
|
|
41
|
-
const contextListeners = new Set();
|
|
42
|
-
/**
|
|
43
|
-
* Subscribe to query-context changes. Returns an unsubscribe function.
|
|
44
|
-
*
|
|
45
|
-
* This is the primitive that makes context resolution reactive: a consuming layer
|
|
46
|
-
* (e.g. React components) subscribes and re-runs affected queries when the context
|
|
47
|
-
* lands — so a query that resolved to `null` while the context was unset simply
|
|
48
|
-
* re-runs and resolves once it's available ("waiting"), and re-runs again on any
|
|
49
|
-
* later change ("auto re-resolve"). Core only emits the change; re-execution is the
|
|
50
|
-
* consumer's responsibility.
|
|
51
|
-
*/
|
|
52
|
-
function subscribeQueryContext(listener) {
|
|
53
|
-
contextListeners.add(listener);
|
|
54
|
-
return () => contextListeners.delete(listener);
|
|
55
|
-
}
|
|
56
|
-
function notifyContextChange(name) {
|
|
57
|
-
// Snapshot so a listener that (un)subscribes or re-sets a context during
|
|
58
|
-
// notification can't mutate the set mid-iteration.
|
|
59
|
-
for (const listener of [...contextListeners])
|
|
60
|
-
listener(name);
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Normalize any query-context value to a {@link PendingQueryContext} carrying its name,
|
|
64
|
-
* or return `undefined` if the value is not a context reference.
|
|
65
|
-
*
|
|
66
|
-
* A context appears in two runtime forms: a `PendingQueryContext` (the context was unset
|
|
67
|
-
* when `getQueryContext()` was called) or a resolved `QueryShape` stamped with
|
|
68
|
-
* `__queryContextName` (it was already set). Both must be treated as the same `{@ctx}`
|
|
69
|
-
* reference wherever a node value/id is accepted (mutation field values, delete ids), so
|
|
70
|
-
* that context-bound mutations behave identically whether the context is set or unset at
|
|
71
|
-
* build time — resolution always happens at lowering.
|
|
72
|
-
*/
|
|
73
|
-
function asContextRef(value) {
|
|
74
|
-
var _a;
|
|
75
|
-
if (value instanceof PendingQueryContext)
|
|
76
|
-
return value;
|
|
77
|
-
if (!value || typeof value !== 'object')
|
|
78
|
-
return undefined;
|
|
79
|
-
// A resolved context is a QueryShape proxy wrapping a Shape stamped with
|
|
80
|
-
// `__queryContextName`. Read it via `originalValue` (a known QueryShape field)
|
|
81
|
-
// so we don't trip the proxy's "undecorated property" guard (it now throws);
|
|
82
|
-
// a bare Shape
|
|
83
|
-
// carries the stamp directly.
|
|
84
|
-
const v = value;
|
|
85
|
-
const source = (_a = v.originalValue) !== null && _a !== void 0 ? _a : v;
|
|
86
|
-
const name = source.__queryContextName;
|
|
87
|
-
if (typeof name === 'string')
|
|
88
|
-
return new PendingQueryContext(name);
|
|
89
|
-
return undefined;
|
|
90
|
-
}
|
|
91
|
-
function getQueryContext(name) {
|
|
92
|
-
if (queryContext.has(name)) {
|
|
93
|
-
return queryContext.get(name);
|
|
94
|
-
}
|
|
95
|
-
// Return a live reference that resolves lazily when the context is set.
|
|
96
|
-
// This avoids the timing issue where module-level queries capture null
|
|
97
|
-
// because the context hasn't been set yet (e.g. useEffect hasn't fired).
|
|
98
|
-
return new PendingQueryContext(name);
|
|
99
|
-
}
|
|
100
|
-
function setQueryContext(name, value, shapeType) {
|
|
101
|
-
// Clearing a context entry
|
|
102
|
-
if (!value) {
|
|
103
|
-
queryContext.delete(name);
|
|
104
|
-
notifyContextChange(name);
|
|
105
|
-
return;
|
|
106
|
-
}
|
|
107
|
-
// Already a QShape — stamp the underlying shape and store as-is. (Checked before
|
|
108
|
-
// the plain-`{id}` branch below: a QueryShape's `.id` getter is also a string, so
|
|
109
|
-
// testing for `{id}` first would wrongly require a shapeType and no-op.)
|
|
110
|
-
if (value instanceof SelectQuery_js_1.QueryShape) {
|
|
111
|
-
const orig = value.originalValue;
|
|
112
|
-
if (orig) {
|
|
113
|
-
orig.__queryContextName = name;
|
|
114
|
-
if (typeof orig.id === 'string')
|
|
115
|
-
orig.__queryContextId = orig.id;
|
|
116
|
-
}
|
|
117
|
-
queryContext.set(name, value);
|
|
118
|
-
notifyContextChange(name);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
// A Shape instance — stamp it and wrap as a QShape. Needs no shapeType (it is one).
|
|
122
|
-
if (value instanceof Shape_js_1.Shape) {
|
|
123
|
-
value.__queryContextName = name;
|
|
124
|
-
if (typeof value.id === 'string')
|
|
125
|
-
value.__queryContextId = value.id;
|
|
126
|
-
queryContext.set(name, new SelectQuery_js_1.QueryShape(value));
|
|
127
|
-
notifyContextChange(name);
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
// A plain QResult `{id}` — materialize a shape (requires shapeType).
|
|
131
|
-
if (typeof value.id === 'string') {
|
|
132
|
-
if (!shapeType) {
|
|
133
|
-
// A silent no-op here is a trap: the context never sets and the caller
|
|
134
|
-
// gets no signal. A `{id}` value cannot be materialized without its shape.
|
|
135
|
-
throw new Error(`setQueryContext('${name}'): a {id} value requires a shapeType so the shape can be materialized. Pass the Shape class as the third argument.`);
|
|
136
|
-
}
|
|
137
|
-
const shape = new shapeType();
|
|
138
|
-
shape.id = value.id;
|
|
139
|
-
shape.__queryContextId = value.id;
|
|
140
|
-
shape.__queryContextName = name;
|
|
141
|
-
queryContext.set(name, SelectQuery_js_1.QueryShape.create(shape));
|
|
142
|
-
notifyContextChange(name);
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
throw new Error(`setQueryContext('${name}'): value is not a QueryShape, Shape, or {id} result. Got ${typeof value}. Pass a Shape instance, a query-context shape, or a {id} result (with its shapeType).`);
|
|
146
|
-
}
|
|
147
|
-
//# sourceMappingURL=QueryContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryContext.js","sourceRoot":"","sources":["../../../src/queries/QueryContext.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import type { NodeShape, PropertyShape } from '../shapes/SHACL.js';
|
|
2
|
-
import { Shape } from '../shapes/Shape.js';
|
|
3
|
-
import { ShapeSet } from '../collections/ShapeSet.js';
|
|
4
|
-
import type { NodeReferenceValue } from '../utils/NodeReference.js';
|
|
5
|
-
import { ExpressionNode } from '../expressions/ExpressionNode.js';
|
|
6
|
-
export type Prettify<T> = T extends infer R ? {
|
|
7
|
-
[K in keyof R]: R[K];
|
|
8
|
-
} : never;
|
|
9
|
-
type WithId<U> = U & {
|
|
10
|
-
id: string;
|
|
11
|
-
};
|
|
12
|
-
type IsPlainObject<T> = T extends object ? T extends any[] ? false : T extends Function ? false : T extends Date ? false : T extends RegExp ? false : T extends Error ? false : T extends null ? false : T extends undefined ? false : T extends object ? true : false : false;
|
|
13
|
-
type RecursiveTransform<T, IsCreate = false> = T extends string | number | boolean | Date | null | undefined ? T : T extends Array<infer U> ? UpdatedSet<Prettify<RecursiveTransform<U>>, IsCreate> : IsSetModification<T> extends true ? ModifiedSet<T, IsCreate> : IsPlainObject<T> extends true ? WithId<{
|
|
14
|
-
[K in keyof T]: Prettify<RecursiveTransform<T[K], IsCreate>>;
|
|
15
|
-
}> : T;
|
|
16
|
-
type UpdatedSet<U, IsCreate> = IsCreate extends true ? U[] : {
|
|
17
|
-
updatedTo: U[];
|
|
18
|
-
};
|
|
19
|
-
type IsSetModification<T> = T extends {
|
|
20
|
-
add?: any;
|
|
21
|
-
remove?: any;
|
|
22
|
-
} ? true : false;
|
|
23
|
-
type AddedType<T> = T extends {
|
|
24
|
-
add: (infer U)[];
|
|
25
|
-
} ? U : T extends {
|
|
26
|
-
add: infer U;
|
|
27
|
-
} ? U : never;
|
|
28
|
-
type RemovedType<T> = T extends {
|
|
29
|
-
remove: (infer U)[];
|
|
30
|
-
} ? U : T extends {
|
|
31
|
-
remove: infer U;
|
|
32
|
-
} ? U : never;
|
|
33
|
-
type ModifiedSet<T, IsCreate = false> = {
|
|
34
|
-
added: AddId<AddedType<T>, IsCreate>[];
|
|
35
|
-
removed: AddId<RemovedType<T>, IsCreate>[];
|
|
36
|
-
};
|
|
37
|
-
export type AddId<T, IsCreate = false> = Prettify<RecursiveTransform<T, IsCreate>>;
|
|
38
|
-
export type UpdatePartial<S = Shape> = UpdateNodeDescription<S> | NodeReferenceValue;
|
|
39
|
-
type UpdateNodeDescription<Shape> = Partial<Omit<{
|
|
40
|
-
[P in KeysWithoutFunctions<Shape>]: ShapePropValueToUpdatePartial<Shape[P]>;
|
|
41
|
-
}, 'node' | 'nodeShape' | 'namedNode' | 'targetClass'>>;
|
|
42
|
-
type KeysWithoutFunctions<T> = {
|
|
43
|
-
[K in keyof T]: T[K] extends Function ? never : K;
|
|
44
|
-
}[keyof T];
|
|
45
|
-
type ShapePropValueToUpdatePartial<ShapeProperty> = ShapeProperty extends Shape ? UpdatePartial<ShapeProperty> : ShapeProperty extends ShapeSet<infer SSType> ? SetUpdateValue<SSType> : ShapeProperty | ExpressionNode;
|
|
46
|
-
type SetUpdateValue<SSType> = UpdatePartial<SSType>[] | SetModification<SSType>;
|
|
47
|
-
export type SetModification<SSType> = {
|
|
48
|
-
add?: UpdatePartial<SSType>[] | UpdatePartial<SSType>;
|
|
49
|
-
remove?: UpdatePartial<SSType>[] | UpdatePartial<SSType>;
|
|
50
|
-
};
|
|
51
|
-
export type SetModificationValue = {
|
|
52
|
-
$add?: UpdatePartial[];
|
|
53
|
-
$remove?: NodeReferenceValue[];
|
|
54
|
-
};
|
|
55
|
-
type UnsetValue = undefined;
|
|
56
|
-
export type LiteralUpdateValue = string | number | boolean | Date;
|
|
57
|
-
export type PropUpdateValue = SinglePropertyUpdateValue | SinglePropertyUpdateValue[] | SetModificationValue;
|
|
58
|
-
export type SinglePropertyUpdateValue = NodeDescriptionValue | NodeReferenceValue | LiteralUpdateValue | UnsetValue;
|
|
59
|
-
export type NodeDescriptionValue = {
|
|
60
|
-
shape: NodeShape;
|
|
61
|
-
fields: UpdateNodePropertyValue[];
|
|
62
|
-
/**
|
|
63
|
-
* The id of the node to be created.
|
|
64
|
-
* Optional, if not provided a new id will be generated.
|
|
65
|
-
*/
|
|
66
|
-
__id?: string;
|
|
67
|
-
};
|
|
68
|
-
export type UpdateNodePropertyValue = {
|
|
69
|
-
prop: PropertyShape;
|
|
70
|
-
val: PropUpdateValue;
|
|
71
|
-
};
|
|
72
|
-
export type ShapeReferenceValue = {
|
|
73
|
-
id: string;
|
|
74
|
-
shape: NodeReferenceValue;
|
|
75
|
-
};
|
|
76
|
-
export { toNodeReference } from '../utils/NodeReference.js';
|
|
77
|
-
export type { NodeReferenceValue };
|
|
78
|
-
export declare abstract class QueryFactory {
|
|
79
|
-
}
|
|
80
|
-
export declare function isSetModificationValue(value: any): value is SetModificationValue;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.QueryFactory = exports.toNodeReference = void 0;
|
|
4
|
-
exports.isSetModificationValue = isSetModificationValue;
|
|
5
|
-
var NodeReference_js_1 = require("../utils/NodeReference.js");
|
|
6
|
-
Object.defineProperty(exports, "toNodeReference", { enumerable: true, get: function () { return NodeReference_js_1.toNodeReference; } });
|
|
7
|
-
class QueryFactory {
|
|
8
|
-
}
|
|
9
|
-
exports.QueryFactory = QueryFactory;
|
|
10
|
-
function isSetModificationValue(value) {
|
|
11
|
-
if (value === null || typeof value !== 'object')
|
|
12
|
-
return false;
|
|
13
|
-
let hasAddKey = value.$add;
|
|
14
|
-
let hasRemoveKey = value.$remove;
|
|
15
|
-
let numKeys = Object.keys(value).length;
|
|
16
|
-
//has no other keys
|
|
17
|
-
return ((hasAddKey && hasRemoveKey && numKeys === 2) ||
|
|
18
|
-
(hasAddKey && numKeys === 1) ||
|
|
19
|
-
(hasRemoveKey && numKeys === 1));
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=QueryFactory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"QueryFactory.js","sourceRoot":"","sources":["../../../src/queries/QueryFactory.ts"],"names":[],"mappings":";;;AAwKA,wDAcC;AAnBD,8DAA0D;AAAlD,mHAAA,eAAe,OAAA;AAGvB,MAAsB,YAAY;CAAG;AAArC,oCAAqC;AAErC,SAAgB,sBAAsB,CACpC,KAAU;IAEV,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAE9D,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"}
|
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
import { Shape, type ShapeConstructor } from '../shapes/Shape.js';
|
|
2
|
-
import type { NodeShape, PropertyShape } from '../shapes/SHACL.js';
|
|
3
|
-
import type { RawSelectInput } from './IRDesugar.js';
|
|
4
|
-
import { ShapeSet } from '../collections/ShapeSet.js';
|
|
5
|
-
import { CoreSet } from '../collections/CoreSet.js';
|
|
6
|
-
import { NodeReferenceValue, type Prettify, type ShapeReferenceValue } from './QueryFactory.js';
|
|
7
|
-
import { FieldSet } from './FieldSet.js';
|
|
8
|
-
import { PropertyPath } from './PropertyPath.js';
|
|
9
|
-
import type { QueryBuilder, QueryBuilderJSON } from './QueryBuilder.js';
|
|
10
|
-
import { ExpressionNode, ExistsCondition } from '../expressions/ExpressionNode.js';
|
|
11
|
-
import { PendingQueryContext } from './QueryContext.js';
|
|
12
|
-
/**
|
|
13
|
-
* The closed, read-only select query a dataset receives (implemented by
|
|
14
|
-
* `SelectBuilder`). It exposes the wire form (`toJSON`), the routing key
|
|
15
|
-
* (`shape`), and the read-only lowering hook (`toRawInput`) — but none of the
|
|
16
|
-
* fluent mutators, so a store cannot keep building on it. The IR algebra is
|
|
17
|
-
* `IRSelectQuery`, produced on demand by `lower(query)`.
|
|
18
|
-
*/
|
|
19
|
-
export interface SelectQuery {
|
|
20
|
-
readonly __queryKind: 'select';
|
|
21
|
-
readonly shape: NodeShape;
|
|
22
|
-
toJSON(): QueryBuilderJSON;
|
|
23
|
-
toRawInput(): RawSelectInput;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* ###################################
|
|
27
|
-
* #### TYPES FOR QUERY BUILDING ####
|
|
28
|
-
* ###################################
|
|
29
|
-
*/
|
|
30
|
-
export type JSPrimitive = JSNonNullPrimitive | null | undefined;
|
|
31
|
-
export type JSNonNullPrimitive = string | number | boolean | Date;
|
|
32
|
-
export type SingleResult<ResultType> = ResultType extends Array<infer R> ? R : ResultType extends Set<infer R> ? R : ResultType;
|
|
33
|
-
/**
|
|
34
|
-
* All the possible types that a regular get/set method of a Shape can return
|
|
35
|
-
*/
|
|
36
|
-
export type AccessorReturnValue = Shape | ShapeSet | JSPrimitive | NodeReferenceValue;
|
|
37
|
-
export type WhereClause<S extends Shape | AccessorReturnValue> = ExpressionNode | ExistsCondition | ((s: ToQueryBuilderObject<S>) => ExpressionNode | ExistsCondition);
|
|
38
|
-
export type QueryBuildFn<T extends Shape, ResponseType> = (p: ToQueryBuilderObject<T>) => ResponseType;
|
|
39
|
-
export type SortByPath = {
|
|
40
|
-
paths: PropertyPath[];
|
|
41
|
-
/** Per-path sort direction (parallel to `paths`). */
|
|
42
|
-
directions: ('ASC' | 'DESC')[];
|
|
43
|
-
};
|
|
44
|
-
/**
|
|
45
|
-
* A property-only query path, used by where/sort proxy tracing.
|
|
46
|
-
*/
|
|
47
|
-
export type QueryPropertyPath = QueryStep[];
|
|
48
|
-
/**
|
|
49
|
-
* A QueryStep is a single step in a query path.
|
|
50
|
-
*/
|
|
51
|
-
export type QueryStep = PropertyQueryStep | SizeStep | ShapeReferenceValue;
|
|
52
|
-
export type SizeStep = {
|
|
53
|
-
count: QueryPropertyPath;
|
|
54
|
-
label?: string;
|
|
55
|
-
};
|
|
56
|
-
export type PropertyQueryStep = {
|
|
57
|
-
property: PropertyShape;
|
|
58
|
-
where?: WherePath;
|
|
59
|
-
};
|
|
60
|
-
/**
|
|
61
|
-
* Maps all the return types of get/set methods of a Shape and maps their return types to QueryBuilderObjects
|
|
62
|
-
*/
|
|
63
|
-
export type QueryShapeProps<T extends Shape, Source, Property extends string | number | symbol = any> = {
|
|
64
|
-
[P in keyof T]: ToQueryBuilderObject<T[P], QShape<T, Source, Property>, P>;
|
|
65
|
-
};
|
|
66
|
-
export type SelectAllQueryResponse<T extends Shape> = Array<QueryShapeProps<T, null, ''>[Exclude<Extract<{
|
|
67
|
-
[K in keyof T]-?: T[K] extends (...args: any[]) => any ? never : K;
|
|
68
|
-
}[keyof T], string>, Extract<keyof Shape, string>>]>;
|
|
69
|
-
/**
|
|
70
|
-
* This type states that the ShapeSet has access to the same methods as the shape of all the items in the set
|
|
71
|
-
* (this is enabled with the QueryShapeSet.proxifyShapeSet method)
|
|
72
|
-
* Each value of the shape is converted to a QueryBuilderObject
|
|
73
|
-
*/
|
|
74
|
-
export type QueryShapeSetProps<SourceShapeSet, Shape> = {
|
|
75
|
-
[P in keyof Shape]: ToQueryBuilderObject<Shape[P], SourceShapeSet, P>;
|
|
76
|
-
};
|
|
77
|
-
/**
|
|
78
|
-
* ShapeSets are converted to QueryShapeSets, but also inherit all the properties of the shape that each item in the set has (with converted result types)
|
|
79
|
-
*/
|
|
80
|
-
export type QShapeSet<ShapeSetType extends Shape, Source = null, Property extends string | number | symbol = null> = QueryShapeSet<ShapeSetType, Source, Property> & QueryShapeSetProps<QueryShapeSet<ShapeSetType, Source, Property>, ShapeSetType>;
|
|
81
|
-
/**
|
|
82
|
-
* Shapes are converted to QueryShapes, but also inherit all the properties of the shape (with converted result types)
|
|
83
|
-
*/
|
|
84
|
-
export type QShape<T extends Shape, Source = any, Property extends string | number | symbol = any> = QueryShape<T, Source, Property> & QueryShapeProps<T, Source, Property>;
|
|
85
|
-
export type ToQueryBuilderObject<T, Source = null, Property extends string | number | symbol = ''> = T extends ShapeSet<infer ShapeSetType> ? QShapeSet<ShapeSetType, Source, Property> : T extends Shape ? QShape<T, Source, Property> : T extends string | number | Date | boolean ? ToQueryPrimitive<T, Source, Property> : T extends Array<infer AT> ? AT extends Date | string | number ? QueryPrimitiveSet<ToQueryPrimitive<AT, Source, Property>> : AT extends boolean ? QueryPrimitive<boolean> : AT[] : T extends NodeReferenceValue ? QShape<Shape, Source, Property> : QueryBuilderObject<T, Source, Property>;
|
|
86
|
-
export type ToQueryPrimitive<T extends string | number | Date | boolean, Source, Property extends string | number | symbol = ''> = T extends string ? QueryPrimitive<string, Source, Property> : T extends number ? QueryPrimitive<number, Source, Property> : T extends Date ? QueryPrimitive<Date, Source, Property> : T extends boolean ? QueryPrimitive<boolean, Source, Property> : never & {
|
|
87
|
-
__error: 'ToQueryPrimitive: no matching primitive type';
|
|
88
|
-
};
|
|
89
|
-
export type WhereExpressionPath = {
|
|
90
|
-
expressionNode: ExpressionNode;
|
|
91
|
-
};
|
|
92
|
-
export type WhereExistsPath = {
|
|
93
|
-
existsCondition: ExistsCondition;
|
|
94
|
-
};
|
|
95
|
-
export type WherePath = WhereExpressionPath | WhereExistsPath;
|
|
96
|
-
/**
|
|
97
|
-
* An argument can be a direct reference to a node, a js primitive (boolean,number), a path to resolve (like from a query context variables)
|
|
98
|
-
* Or a wherePath in the case of some() or every() (e.g. x.where(x.friends.some(f => f.age > 18) -> the argument is a wherePath)
|
|
99
|
-
*/
|
|
100
|
-
export type QueryComponentLike<ShapeType extends Shape, CompQueryResult> = {
|
|
101
|
-
query: QueryBuilder<ShapeType> | FieldSet | Record<string, QueryBuilder<ShapeType>>;
|
|
102
|
-
fields?: FieldSet;
|
|
103
|
-
};
|
|
104
|
-
/**
|
|
105
|
-
* Interface that linked components (e.g. from `@_linked/react`'s `linkedComponent()`)
|
|
106
|
-
* must satisfy to participate in preloadFor.
|
|
107
|
-
*
|
|
108
|
-
* Components expose their data requirements as a QueryBuilder,
|
|
109
|
-
* and optionally a FieldSet for declarative field access.
|
|
110
|
-
*/
|
|
111
|
-
export interface LinkedComponentInterface<S extends Shape = Shape, R = any> {
|
|
112
|
-
/** The component's data query (QueryBuilder template, not executed). */
|
|
113
|
-
query: QueryBuilder<S, any, R>;
|
|
114
|
-
/** The component's field requirements as a FieldSet. */
|
|
115
|
-
fields?: FieldSet;
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* ###################################
|
|
119
|
-
* #### QUERY RESULT TYPES ####
|
|
120
|
-
* ###################################
|
|
121
|
-
*/
|
|
122
|
-
export type QResult<ShapeType extends Shape = Shape, Object = {}> = Object & {
|
|
123
|
-
id: string;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* MAIN ENTRY to convert the response of a query into a result object
|
|
127
|
-
*/
|
|
128
|
-
export type QueryResponseToResultType<T, QShapeType extends Shape = null, HasName = false> = T extends QueryBuilderObject ? GetQueryObjectResultType<T, {}, false, HasName> : T extends FieldSet<infer Response, infer Source> ? GetNestedQueryResultType<Response, Source> : T extends Array<infer Type> ? UnionToIntersection<QueryResponseToResultType<Type>> : T extends ExpressionNode ? boolean : T extends Object ? QResult<QShapeType, Prettify<ObjectToPlainResult<T>>> : never & {
|
|
129
|
-
__error: 'QueryResponseToResultType: unmatched query response type';
|
|
130
|
-
};
|
|
131
|
-
/**
|
|
132
|
-
* Turns a QueryBuilderObject into a plain JS object
|
|
133
|
-
* @param QV the query value type
|
|
134
|
-
* @param SubProperties to add extra properties into the result object (used to merge arrays into objects for example)
|
|
135
|
-
* @param SourceOverwrite if the source of the query value should be overwritten
|
|
136
|
-
*/
|
|
137
|
-
export type GetQueryObjectResultType<QV, SubProperties = {}, PrimitiveArray = false, HasName = false> = QV extends SetSize<infer Source> ? SetSizeToQueryResult<Source, HasName> : QV extends QueryPrimitive<infer Primitive, infer Source, infer Property> ? CreateQResult<Source, PrimitiveArray extends true ? Primitive[] : Primitive, Property, {}, HasName> : QV extends QueryShape<infer ShapeType, infer Source, infer Property> ? CreateQResult<Source, ShapeType, Property, SubProperties, HasName> : QV extends BoundComponent<infer Source, infer CompQueryResult> ? GetQueryObjectResultType<Source, SubProperties & QueryResponseToResultType<CompQueryResult>, PrimitiveArray, HasName> : QV extends QueryShapeSet<infer ShapeType, infer Source, infer Property> ? CreateShapeSetQResult<ShapeType, Source, Property, SubProperties, HasName> : QV extends QueryPrimitiveSet<infer QPrim extends QueryPrimitive<any>> ? GetQueryObjectResultType<QPrim, null, null, true> : QV extends Array<infer Type> ? UnionToIntersection<QueryResponseToResultType<Type>> : QV extends QueryPrimitive<boolean, any, any> ? 'bool' : never & {
|
|
138
|
-
__error: 'GetQueryObjectResultType: unmatched query value type';
|
|
139
|
-
};
|
|
140
|
-
export type SetSizeToQueryResult<Source, HasName = false> = Source extends QueryShapeSet<infer ShapeType, infer ParentSource, infer SourceProperty> ? HasName extends false ? CreateQResult<ParentSource, number, SourceProperty> : number : number;
|
|
141
|
-
/**
|
|
142
|
-
* If the source is an object (it extends shape)
|
|
143
|
-
* then the result is a plain JS Object, with Property as its key, with type Value
|
|
144
|
-
*/
|
|
145
|
-
export type CreateQResult<Source, Value = undefined, Property extends string | number | symbol = '', SubProperties = {}, HasName = false> = Source extends QueryShape<infer SourceShapeType, infer ParentSource, infer SourceProperty> ? ParentSource extends null ? HasName extends true ? Value : Value extends null ? QResult<SourceShapeType, {
|
|
146
|
-
[P in Property]: CreateQResult<Value, Value>;
|
|
147
|
-
} & SubProperties> : QResult<SourceShapeType, {
|
|
148
|
-
[P in Property]: CreateQResult<Value, Value, '', SubProperties>;
|
|
149
|
-
}> : CreateQResult<ParentSource, QResult<SourceShapeType, {
|
|
150
|
-
[P in Property]: CreateQResult<Value, Value>;
|
|
151
|
-
} & SubProperties>, SourceProperty, {}, HasName> : Source extends QueryShapeSet<infer ShapeType, infer ParentSource, infer SourceProperty> ? CreateQResult<ParentSource, QResult<ShapeType, {
|
|
152
|
-
[P in Property]: CreateQResult<Value, Value, null, SubProperties>;
|
|
153
|
-
}>[], SourceProperty, {}, HasName> : Value extends Shape ? QResult<Value, SubProperties> : NormaliseBoolean<Value>;
|
|
154
|
-
type NormaliseBoolean<T> = [T] extends [boolean] ? boolean : T;
|
|
155
|
-
export type CreateShapeSetQResult<ShapeType = undefined, Source = undefined, Property extends string | number | symbol = '', SubProperties = {}, HasName = false> = Source extends QueryShape<infer SourceShapeType, infer ParentSource> ? [
|
|
156
|
-
HasName,
|
|
157
|
-
ParentSource
|
|
158
|
-
] extends [true, null] ? CreateQResult<Source, null, null>[] : ParentSource extends null ? QResult<SourceShapeType, {
|
|
159
|
-
[P in Property]: CreateQResult<Source, null, null, SubProperties>[];
|
|
160
|
-
}> : CreateQResult<Source, null, null, {
|
|
161
|
-
[P in Property]: (ShapeType extends Shape ? QResult<ShapeType, SubProperties> : QResult<Shape, SubProperties>)[];
|
|
162
|
-
}> : Source extends QueryShapeSet<infer ShapeType, infer ParentSource, infer SourceProperty> ? CreateQResult<ParentSource, QResult<ShapeType, {
|
|
163
|
-
[P in Property]: CreateQResult<ShapeType>[];
|
|
164
|
-
}>[], SourceProperty, {}, HasName> : CreateQResult<ShapeType>;
|
|
165
|
-
/**
|
|
166
|
-
* Ignores the source and property, and returns the converted value
|
|
167
|
-
*/
|
|
168
|
-
export type ObjectToPlainResult<T> = {
|
|
169
|
-
[P in keyof T]: QueryResponseToResultType<T[P], null, true>;
|
|
170
|
-
};
|
|
171
|
-
type GetNestedQueryResultType<Response, Source> = Source extends QueryBuilderObject ? GetQueryObjectResultType<Source, QueryResponseToResultType<Response>> : QueryResponseToResultType<Response>[];
|
|
172
|
-
type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
|
173
|
-
/**
|
|
174
|
-
* ###################################
|
|
175
|
-
* #### QUERY BUILDING CLASSES ####
|
|
176
|
-
* ###################################
|
|
177
|
-
*/
|
|
178
|
-
export declare class QueryBuilderObject<OriginalValue = any, Source = any, Property extends string | number | symbol = any> {
|
|
179
|
-
property?: PropertyShape;
|
|
180
|
-
subject?: QueryShape<any> | QueryShapeSet<any> | QueryPrimitiveSet;
|
|
181
|
-
wherePath?: WherePath;
|
|
182
|
-
protected originalValue?: OriginalValue;
|
|
183
|
-
protected source: Source;
|
|
184
|
-
protected prop: Property;
|
|
185
|
-
constructor(property?: PropertyShape, subject?: QueryShape<any> | QueryShapeSet<any> | QueryPrimitiveSet);
|
|
186
|
-
/**
|
|
187
|
-
* Create a Query Builder Object based on the requested PropertyShape
|
|
188
|
-
*/
|
|
189
|
-
static generatePathValue(property: PropertyShape, subject: QueryShape<any> | QueryShapeSet<any> | QueryShape<any>): QueryBuilderObject;
|
|
190
|
-
getOriginalValue(): OriginalValue;
|
|
191
|
-
getPropertyStep(): QueryStep;
|
|
192
|
-
preloadFor<ShapeType extends Shape, CompQueryRes>(component: QueryComponentLike<ShapeType, CompQueryRes>): BoundComponent<this, CompQueryRes>;
|
|
193
|
-
/**
|
|
194
|
-
* Pagination is applied to a nested *select*, not to a bare traversal — use
|
|
195
|
-
* `p.friends.select(f => f.name).limit(n)`. Calling `.limit()` directly on a
|
|
196
|
-
* traversal would silently do nothing, so we fail loudly instead.
|
|
197
|
-
* (Top-level result pagination lives on the outer query builder.)
|
|
198
|
-
*/
|
|
199
|
-
limit(lim: number): never;
|
|
200
|
-
/**
|
|
201
|
-
* Returns the path of properties that were requested to reach this value
|
|
202
|
-
*/
|
|
203
|
-
getPropertyPath(currentPath?: QueryPropertyPath): QueryPropertyPath;
|
|
204
|
-
}
|
|
205
|
-
export declare class BoundComponent<Source extends QueryBuilderObject, CompQueryResult = any> extends QueryBuilderObject {
|
|
206
|
-
originalValue: QueryComponentLike<any, CompQueryResult>;
|
|
207
|
-
source: Source;
|
|
208
|
-
constructor(originalValue: QueryComponentLike<any, CompQueryResult>, source: Source);
|
|
209
|
-
}
|
|
210
|
-
export declare const processWhereClause: (validation: WhereClause<any>, shape?: any) => WherePath;
|
|
211
|
-
/**
|
|
212
|
-
* Evaluate a sort callback through the proxy and extract a SortByPath.
|
|
213
|
-
* This is a standalone helper that replaces the need for the former SelectQueryFactory.sortBy().
|
|
214
|
-
*/
|
|
215
|
-
export declare const evaluateSortCallback: <S extends Shape>(shape: ShapeConstructor<S>, sortFn: (p: any) => any, direction?: "ASC" | "DESC") => SortByPath;
|
|
216
|
-
export declare class QueryShapeSet<S extends Shape = Shape, Source = any, Property extends string | number | symbol = any> extends QueryBuilderObject<ShapeSet<S>, Source, Property> {
|
|
217
|
-
queryShapes: CoreSet<QueryShape>;
|
|
218
|
-
private proxy;
|
|
219
|
-
constructor(_originalValue?: ShapeSet<S>, property?: PropertyShape, subject?: QueryShape<any> | QueryShapeSet<any>);
|
|
220
|
-
static create<S extends Shape = Shape>(originalValue: ShapeSet<S>, property: PropertyShape, subject: QueryShape<any> | QueryShapeSet<any>): any;
|
|
221
|
-
static proxifyShapeSet<T extends Shape = Shape>(queryShapeSet: QueryShapeSet<T>): any;
|
|
222
|
-
as<ShapeClass extends typeof Shape>(shape: ShapeClass): QShapeSet<InstanceType<ShapeClass>, Source, Property>;
|
|
223
|
-
add(item: any): void;
|
|
224
|
-
concat(other: QueryShapeSet): QueryShapeSet;
|
|
225
|
-
getOriginalValue(): ShapeSet<S>;
|
|
226
|
-
callPropertyShapeAccessor(propertyShape: PropertyShape): QueryShapeSet | QueryPrimitiveSet;
|
|
227
|
-
size(): SetSize<this>;
|
|
228
|
-
where(validation: WhereClause<S>): this;
|
|
229
|
-
select<QF = unknown>(subQueryFn: QueryBuildFn<S, QF>): FieldSet<QF, QueryShapeSet<S, Source, Property>>;
|
|
230
|
-
selectAll(): FieldSet<SelectAllQueryResponse<S>, QueryShapeSet<S, Source, Property>>;
|
|
231
|
-
some(validation: WhereClause<S>): ExistsCondition;
|
|
232
|
-
every(validation: WhereClause<S>): ExistsCondition;
|
|
233
|
-
none(validation: WhereClause<S>): ExistsCondition;
|
|
234
|
-
private buildPredicateExpression;
|
|
235
|
-
}
|
|
236
|
-
export declare class QueryShape<S extends Shape = Shape, Source = any, Property extends string | number | symbol = any> extends QueryBuilderObject<S, Source, Property> {
|
|
237
|
-
originalValue: S;
|
|
238
|
-
private proxy;
|
|
239
|
-
constructor(originalValue: S, property?: PropertyShape, subject?: QueryShape<any> | QueryShapeSet<any>);
|
|
240
|
-
get id(): string;
|
|
241
|
-
static create(original: Shape, property?: PropertyShape, subject?: QueryShape<any> | QueryShapeSet<any>): any;
|
|
242
|
-
private static proxifyQueryShape;
|
|
243
|
-
as<ShapeClass extends typeof Shape>(shape: ShapeClass): QShape<InstanceType<ShapeClass>, Source, Property>;
|
|
244
|
-
equals(otherValue: NodeReferenceValue | QShape<any> | PendingQueryContext): ExpressionNode;
|
|
245
|
-
oneOf(values: (NodeReferenceValue | QShape<any>)[]): ExpressionNode;
|
|
246
|
-
notOneOf(values: (NodeReferenceValue | QShape<any>)[]): ExpressionNode;
|
|
247
|
-
select<QF = unknown>(subQueryFn: QueryBuildFn<S, QF>): FieldSet<QF, QueryShape<S, Source, Property>>;
|
|
248
|
-
selectAll(): FieldSet<SelectAllQueryResponse<S>, QueryShape<S, Source, Property>>;
|
|
249
|
-
}
|
|
250
|
-
/**
|
|
251
|
-
* Concrete query wrapper for JS primitive values (string, number, boolean, Date).
|
|
252
|
-
*
|
|
253
|
-
* Replaces the former abstract class + subclasses (QueryString, QueryNumber,
|
|
254
|
-
* QueryBoolean, QueryDate) — the type parameter T carries the primitive type,
|
|
255
|
-
* so separate subclasses are unnecessary.
|
|
256
|
-
*/
|
|
257
|
-
export declare class QueryPrimitive<T, Source = any, Property extends string | number | symbol = any> extends QueryBuilderObject<T, Source, Property> {
|
|
258
|
-
originalValue?: T;
|
|
259
|
-
property?: PropertyShape;
|
|
260
|
-
subject?: QueryShape<any> | QueryShapeSet<any> | QueryPrimitiveSet;
|
|
261
|
-
constructor(originalValue?: T, property?: PropertyShape, subject?: QueryShape<any> | QueryShapeSet<any> | QueryPrimitiveSet);
|
|
262
|
-
equals(otherValue: JSPrimitive | QueryBuilderObject): ExpressionNode;
|
|
263
|
-
oneOf(values: (JSPrimitive | QueryBuilderObject)[]): ExpressionNode;
|
|
264
|
-
notOneOf(values: (JSPrimitive | QueryBuilderObject)[]): ExpressionNode;
|
|
265
|
-
where(validation: WhereClause<string>): this;
|
|
266
|
-
}
|
|
267
|
-
export declare class QueryPrimitiveSet<QPrimitive extends QueryPrimitive<any> = null> extends QueryBuilderObject<any, any, any> {
|
|
268
|
-
originalValue?: JSNonNullPrimitive[];
|
|
269
|
-
property?: PropertyShape;
|
|
270
|
-
subject?: QueryShapeSet<any> | QueryShape<any>;
|
|
271
|
-
contents: CoreSet<QPrimitive>;
|
|
272
|
-
constructor(originalValue?: JSNonNullPrimitive[], property?: PropertyShape, subject?: QueryShapeSet<any> | QueryShape<any>, items?: any);
|
|
273
|
-
add(item: any): void;
|
|
274
|
-
values(): QPrimitive[];
|
|
275
|
-
createNew(...args: any[]): this;
|
|
276
|
-
equals(other: any): ExpressionNode;
|
|
277
|
-
getPropertyStep(): QueryStep;
|
|
278
|
-
getPropertyPath(): QueryPropertyPath;
|
|
279
|
-
size(): SetSize<this>;
|
|
280
|
-
}
|
|
281
|
-
export declare class SetSize<Source = null> extends QueryPrimitive<number, Source> {
|
|
282
|
-
subject: QueryShapeSet | QueryShape | QueryPrimitiveSet;
|
|
283
|
-
countable?: QueryBuilderObject;
|
|
284
|
-
label?: string;
|
|
285
|
-
constructor(subject: QueryShapeSet | QueryShape | QueryPrimitiveSet, countable?: QueryBuilderObject, label?: string);
|
|
286
|
-
private toCountExpr;
|
|
287
|
-
equals(v: any): ExpressionNode;
|
|
288
|
-
eq(v: any): ExpressionNode;
|
|
289
|
-
neq(v: any): ExpressionNode;
|
|
290
|
-
notEquals(v: any): ExpressionNode;
|
|
291
|
-
gt(v: any): ExpressionNode;
|
|
292
|
-
greaterThan(v: any): ExpressionNode;
|
|
293
|
-
gte(v: any): ExpressionNode;
|
|
294
|
-
greaterThanOrEqual(v: any): ExpressionNode;
|
|
295
|
-
lt(v: any): ExpressionNode;
|
|
296
|
-
lessThan(v: any): ExpressionNode;
|
|
297
|
-
lte(v: any): ExpressionNode;
|
|
298
|
-
lessThanOrEqual(v: any): ExpressionNode;
|
|
299
|
-
as(label: string): this;
|
|
300
|
-
getPropertyPath(): QueryPropertyPath;
|
|
301
|
-
}
|
|
302
|
-
export {};
|