@_linked/core 1.0.0 → 1.2.0-next.20260302120536
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 +72 -0
- package/README.md +321 -43
- package/lib/cjs/index.js +4 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/IQuadStore.d.ts +19 -7
- package/lib/cjs/queries/CreateQuery.d.ts +7 -8
- package/lib/cjs/queries/CreateQuery.js +4 -4
- package/lib/cjs/queries/CreateQuery.js.map +1 -1
- package/lib/cjs/queries/DeleteQuery.d.ts +7 -8
- package/lib/cjs/queries/DeleteQuery.js +4 -4
- package/lib/cjs/queries/DeleteQuery.js.map +1 -1
- package/lib/cjs/queries/IRAliasScope.d.ts +20 -0
- package/lib/cjs/queries/IRAliasScope.js +52 -0
- package/lib/cjs/queries/IRAliasScope.js.map +1 -0
- package/lib/cjs/queries/IRCanonicalize.d.ts +36 -0
- package/lib/cjs/queries/IRCanonicalize.js +121 -0
- package/lib/cjs/queries/IRCanonicalize.js.map +1 -0
- package/lib/cjs/queries/IRDesugar.d.ts +98 -0
- package/lib/cjs/queries/IRDesugar.js +244 -0
- package/lib/cjs/queries/IRDesugar.js.map +1 -0
- package/lib/cjs/queries/IRLower.d.ts +8 -0
- package/lib/cjs/queries/IRLower.js +272 -0
- package/lib/cjs/queries/IRLower.js.map +1 -0
- package/lib/cjs/queries/IRMutation.d.ts +23 -0
- package/lib/cjs/queries/IRMutation.js +77 -0
- package/lib/cjs/queries/IRMutation.js.map +1 -0
- package/lib/cjs/queries/IRPipeline.d.ts +8 -0
- package/lib/cjs/queries/IRPipeline.js +25 -0
- package/lib/cjs/queries/IRPipeline.js.map +1 -0
- package/lib/cjs/queries/IRProjection.d.ts +38 -0
- package/lib/cjs/queries/IRProjection.js +98 -0
- package/lib/cjs/queries/IRProjection.js.map +1 -0
- package/lib/cjs/queries/IntermediateRepresentation.d.ts +210 -0
- package/lib/cjs/queries/IntermediateRepresentation.js +3 -0
- package/lib/cjs/queries/IntermediateRepresentation.js.map +1 -0
- package/lib/cjs/queries/MutationQuery.js +9 -23
- package/lib/cjs/queries/MutationQuery.js.map +1 -1
- package/lib/cjs/queries/QueryFactory.d.ts +0 -2
- package/lib/cjs/queries/QueryFactory.js +0 -3
- package/lib/cjs/queries/QueryFactory.js.map +1 -1
- package/lib/cjs/queries/QueryParser.d.ts +6 -1
- package/lib/cjs/queries/QueryParser.js +14 -22
- package/lib/cjs/queries/QueryParser.js.map +1 -1
- package/lib/cjs/queries/SelectQuery.d.ts +18 -27
- package/lib/cjs/queries/SelectQuery.js +54 -45
- package/lib/cjs/queries/SelectQuery.js.map +1 -1
- package/lib/cjs/queries/UpdateQuery.d.ts +8 -9
- package/lib/cjs/queries/UpdateQuery.js +4 -4
- package/lib/cjs/queries/UpdateQuery.js.map +1 -1
- package/lib/cjs/shapes/SHACL.d.ts +1 -0
- package/lib/cjs/shapes/SHACL.js +82 -2
- package/lib/cjs/shapes/SHACL.js.map +1 -1
- package/lib/cjs/shapes/Shape.d.ts +11 -10
- package/lib/cjs/shapes/Shape.js +11 -5
- package/lib/cjs/shapes/Shape.js.map +1 -1
- package/lib/cjs/sparql/SparqlAlgebra.d.ts +158 -0
- package/lib/cjs/sparql/SparqlAlgebra.js +4 -0
- package/lib/cjs/sparql/SparqlAlgebra.js.map +1 -0
- package/lib/cjs/sparql/SparqlStore.d.ts +52 -0
- package/lib/cjs/sparql/SparqlStore.js +81 -0
- package/lib/cjs/sparql/SparqlStore.js.map +1 -0
- package/lib/cjs/sparql/algebraToString.d.ts +13 -0
- package/lib/cjs/sparql/algebraToString.js +298 -0
- package/lib/cjs/sparql/algebraToString.js.map +1 -0
- package/lib/cjs/sparql/index.d.ts +9 -0
- package/lib/cjs/sparql/index.js +40 -0
- package/lib/cjs/sparql/index.js.map +1 -0
- package/lib/cjs/sparql/irToAlgebra.d.ts +39 -0
- package/lib/cjs/sparql/irToAlgebra.js +927 -0
- package/lib/cjs/sparql/irToAlgebra.js.map +1 -0
- package/lib/cjs/sparql/resultMapping.d.ts +36 -0
- package/lib/cjs/sparql/resultMapping.js +501 -0
- package/lib/cjs/sparql/resultMapping.js.map +1 -0
- package/lib/cjs/sparql/sparqlUtils.d.ts +32 -0
- package/lib/cjs/sparql/sparqlUtils.js +89 -0
- package/lib/cjs/sparql/sparqlUtils.js.map +1 -0
- package/lib/cjs/test-helpers/FusekiStore.d.ts +29 -0
- package/lib/cjs/test-helpers/FusekiStore.js +82 -0
- package/lib/cjs/test-helpers/FusekiStore.js.map +1 -0
- package/lib/cjs/test-helpers/fuseki-test-store.d.ts +43 -0
- package/lib/cjs/test-helpers/fuseki-test-store.js +144 -0
- package/lib/cjs/test-helpers/fuseki-test-store.js.map +1 -0
- package/lib/cjs/test-helpers/query-capture-store.d.ts +5 -0
- package/lib/cjs/test-helpers/query-capture-store.js +59 -0
- package/lib/cjs/test-helpers/query-capture-store.js.map +1 -0
- package/lib/cjs/test-helpers/query-fixtures.d.ts +700 -117
- package/lib/cjs/test-helpers/query-fixtures.js +39 -1
- package/lib/cjs/test-helpers/query-fixtures.js.map +1 -1
- package/lib/cjs/utils/LinkedStorage.d.ts +7 -7
- package/lib/cjs/utils/LinkedStorage.js +4 -3
- package/lib/cjs/utils/LinkedStorage.js.map +1 -1
- package/lib/esm/index.js +4 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/IQuadStore.d.ts +19 -7
- package/lib/esm/queries/CreateQuery.d.ts +7 -8
- package/lib/esm/queries/CreateQuery.js +4 -4
- package/lib/esm/queries/CreateQuery.js.map +1 -1
- package/lib/esm/queries/DeleteQuery.d.ts +7 -8
- package/lib/esm/queries/DeleteQuery.js +4 -4
- package/lib/esm/queries/DeleteQuery.js.map +1 -1
- package/lib/esm/queries/IRAliasScope.d.ts +20 -0
- package/lib/esm/queries/IRAliasScope.js +47 -0
- package/lib/esm/queries/IRAliasScope.js.map +1 -0
- package/lib/esm/queries/IRCanonicalize.d.ts +36 -0
- package/lib/esm/queries/IRCanonicalize.js +116 -0
- package/lib/esm/queries/IRCanonicalize.js.map +1 -0
- package/lib/esm/queries/IRDesugar.d.ts +98 -0
- package/lib/esm/queries/IRDesugar.js +240 -0
- package/lib/esm/queries/IRDesugar.js.map +1 -0
- package/lib/esm/queries/IRLower.d.ts +8 -0
- package/lib/esm/queries/IRLower.js +268 -0
- package/lib/esm/queries/IRLower.js.map +1 -0
- package/lib/esm/queries/IRMutation.d.ts +23 -0
- package/lib/esm/queries/IRMutation.js +71 -0
- package/lib/esm/queries/IRMutation.js.map +1 -0
- package/lib/esm/queries/IRPipeline.d.ts +8 -0
- package/lib/esm/queries/IRPipeline.js +21 -0
- package/lib/esm/queries/IRPipeline.js.map +1 -0
- package/lib/esm/queries/IRProjection.d.ts +38 -0
- package/lib/esm/queries/IRProjection.js +92 -0
- package/lib/esm/queries/IRProjection.js.map +1 -0
- package/lib/esm/queries/IntermediateRepresentation.d.ts +210 -0
- package/lib/esm/queries/IntermediateRepresentation.js +2 -0
- package/lib/esm/queries/IntermediateRepresentation.js.map +1 -0
- package/lib/esm/queries/MutationQuery.js +9 -23
- package/lib/esm/queries/MutationQuery.js.map +1 -1
- package/lib/esm/queries/QueryFactory.d.ts +0 -2
- package/lib/esm/queries/QueryFactory.js +0 -3
- package/lib/esm/queries/QueryFactory.js.map +1 -1
- package/lib/esm/queries/QueryParser.d.ts +6 -1
- package/lib/esm/queries/QueryParser.js +14 -23
- package/lib/esm/queries/QueryParser.js.map +1 -1
- package/lib/esm/queries/SelectQuery.d.ts +18 -27
- package/lib/esm/queries/SelectQuery.js +54 -45
- package/lib/esm/queries/SelectQuery.js.map +1 -1
- package/lib/esm/queries/UpdateQuery.d.ts +8 -9
- package/lib/esm/queries/UpdateQuery.js +4 -4
- package/lib/esm/queries/UpdateQuery.js.map +1 -1
- package/lib/esm/shapes/SHACL.d.ts +1 -0
- package/lib/esm/shapes/SHACL.js +82 -2
- package/lib/esm/shapes/SHACL.js.map +1 -1
- package/lib/esm/shapes/Shape.d.ts +11 -10
- package/lib/esm/shapes/Shape.js +11 -5
- package/lib/esm/shapes/Shape.js.map +1 -1
- package/lib/esm/sparql/SparqlAlgebra.d.ts +158 -0
- package/lib/esm/sparql/SparqlAlgebra.js +3 -0
- package/lib/esm/sparql/SparqlAlgebra.js.map +1 -0
- package/lib/esm/sparql/SparqlStore.d.ts +52 -0
- package/lib/esm/sparql/SparqlStore.js +77 -0
- package/lib/esm/sparql/SparqlStore.js.map +1 -0
- package/lib/esm/sparql/algebraToString.d.ts +13 -0
- package/lib/esm/sparql/algebraToString.js +289 -0
- package/lib/esm/sparql/algebraToString.js.map +1 -0
- package/lib/esm/sparql/index.d.ts +9 -0
- package/lib/esm/sparql/index.js +13 -0
- package/lib/esm/sparql/index.js.map +1 -0
- package/lib/esm/sparql/irToAlgebra.d.ts +39 -0
- package/lib/esm/sparql/irToAlgebra.js +917 -0
- package/lib/esm/sparql/irToAlgebra.js.map +1 -0
- package/lib/esm/sparql/resultMapping.d.ts +36 -0
- package/lib/esm/sparql/resultMapping.js +496 -0
- package/lib/esm/sparql/resultMapping.js.map +1 -0
- package/lib/esm/sparql/sparqlUtils.d.ts +32 -0
- package/lib/esm/sparql/sparqlUtils.js +82 -0
- package/lib/esm/sparql/sparqlUtils.js.map +1 -0
- package/lib/esm/test-helpers/FusekiStore.d.ts +29 -0
- package/lib/esm/test-helpers/FusekiStore.js +78 -0
- package/lib/esm/test-helpers/FusekiStore.js.map +1 -0
- package/lib/esm/test-helpers/fuseki-test-store.d.ts +43 -0
- package/lib/esm/test-helpers/fuseki-test-store.js +135 -0
- package/lib/esm/test-helpers/fuseki-test-store.js.map +1 -0
- package/lib/esm/test-helpers/query-capture-store.d.ts +5 -0
- package/lib/esm/test-helpers/query-capture-store.js +55 -0
- package/lib/esm/test-helpers/query-capture-store.js.map +1 -0
- package/lib/esm/test-helpers/query-fixtures.d.ts +700 -117
- package/lib/esm/test-helpers/query-fixtures.js +38 -0
- package/lib/esm/test-helpers/query-fixtures.js.map +1 -1
- package/lib/esm/utils/LinkedStorage.d.ts +7 -7
- package/lib/esm/utils/LinkedStorage.js +4 -3
- package/lib/esm/utils/LinkedStorage.js.map +1 -1
- package/package.json +7 -3
- package/lib/cjs/interfaces/IQueryParser.d.ts +0 -13
- package/lib/cjs/interfaces/IQueryParser.js +0 -10
- package/lib/cjs/interfaces/IQueryParser.js.map +0 -1
- package/lib/esm/interfaces/IQueryParser.d.ts +0 -13
- package/lib/esm/interfaces/IQueryParser.js +0 -7
- package/lib/esm/interfaces/IQueryParser.js.map +0 -1
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Shape } from '../shapes/Shape.js';
|
|
2
|
-
import { NodeShape } from '../shapes/SHACL.js';
|
|
3
|
-
import { LinkedQuery } from './SelectQuery.js';
|
|
4
2
|
import { NodeReferenceValue, UpdatePartial } from './QueryFactory.js';
|
|
5
3
|
import { MutationQueryFactory, NodeId } from './MutationQuery.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { IRDeleteMutation } from './IntermediateRepresentation.js';
|
|
5
|
+
/**
|
|
6
|
+
* The canonical DeleteQuery type — an IR AST node representing a delete mutation.
|
|
7
|
+
* This is the type received by IQuadStore.deleteQuery().
|
|
8
|
+
*/
|
|
9
|
+
export type DeleteQuery = IRDeleteMutation;
|
|
11
10
|
export type DeleteResponse = {
|
|
12
11
|
/**
|
|
13
12
|
* The IDs of the items that were successfully deleted.
|
|
@@ -31,5 +30,5 @@ export declare class DeleteQueryFactory<ShapeType extends Shape, U extends Updat
|
|
|
31
30
|
readonly id: string;
|
|
32
31
|
readonly ids: NodeReferenceValue[];
|
|
33
32
|
constructor(shapeClass: typeof Shape, ids: NodeId[] | NodeId);
|
|
34
|
-
|
|
33
|
+
build(): DeleteQuery;
|
|
35
34
|
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DeleteQueryFactory = void 0;
|
|
4
4
|
const MutationQuery_js_1 = require("./MutationQuery.js");
|
|
5
|
+
const IRMutation_js_1 = require("./IRMutation.js");
|
|
5
6
|
class DeleteQueryFactory extends MutationQuery_js_1.MutationQueryFactory {
|
|
6
7
|
constructor(shapeClass, ids) {
|
|
7
8
|
super();
|
|
8
9
|
this.shapeClass = shapeClass;
|
|
9
10
|
this.ids = this.convertNodeReferences(ids);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
type: 'delete',
|
|
12
|
+
build() {
|
|
13
|
+
return (0, IRMutation_js_1.buildCanonicalDeleteMutationIR)({
|
|
14
14
|
shape: this.shapeClass.shape,
|
|
15
15
|
ids: this.ids,
|
|
16
|
-
};
|
|
16
|
+
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.DeleteQueryFactory = DeleteQueryFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeleteQuery.js","sourceRoot":"","sources":["../../../src/queries/DeleteQuery.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"DeleteQuery.js","sourceRoot":"","sources":["../../../src/queries/DeleteQuery.ts"],"names":[],"mappings":";;;AAEA,yDAAgE;AAEhE,mDAA+D;AA2B/D,MAAa,kBAGX,SAAQ,uCAAoB;IAI5B,YACS,UAAwB,EAC/B,GAAsB;QAEtB,KAAK,EAAE,CAAC;QAHD,eAAU,GAAV,UAAU,CAAc;QAI/B,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC7C,CAAC;IAED,KAAK;QACH,OAAO,IAAA,8CAA8B,EAAC;YACpC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;YAC5B,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAC;IACL,CAAC;CACF;AArBD,gDAqBC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** A named alias binding in a scope, tracking its source and nesting depth. */
|
|
2
|
+
export type IRAliasBinding = {
|
|
3
|
+
alias: string;
|
|
4
|
+
source: string;
|
|
5
|
+
scopeDepth: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class IRAliasScope {
|
|
8
|
+
readonly scopeName: string;
|
|
9
|
+
private readonly parent?;
|
|
10
|
+
private bindings;
|
|
11
|
+
private generatedCount;
|
|
12
|
+
constructor(scopeName: string, parent?: IRAliasScope);
|
|
13
|
+
get depth(): number;
|
|
14
|
+
registerAlias(alias: string, source: string): IRAliasBinding;
|
|
15
|
+
generateAlias(source: string): IRAliasBinding;
|
|
16
|
+
resolveAlias(alias: string): IRAliasBinding;
|
|
17
|
+
createChildScope(name: string): IRAliasScope;
|
|
18
|
+
}
|
|
19
|
+
/** Validates that an alias exists in the current scope chain, throwing if not found. */
|
|
20
|
+
export declare const validateAliasReference: (alias: string, currentScope: IRAliasScope) => IRAliasBinding;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateAliasReference = exports.IRAliasScope = void 0;
|
|
4
|
+
class IRAliasScope {
|
|
5
|
+
constructor(scopeName, parent) {
|
|
6
|
+
this.scopeName = scopeName;
|
|
7
|
+
this.parent = parent;
|
|
8
|
+
this.bindings = new Map();
|
|
9
|
+
this.generatedCount = 0;
|
|
10
|
+
}
|
|
11
|
+
get depth() {
|
|
12
|
+
return this.parent ? this.parent.depth + 1 : 0;
|
|
13
|
+
}
|
|
14
|
+
registerAlias(alias, source) {
|
|
15
|
+
if (this.bindings.has(alias)) {
|
|
16
|
+
throw new Error(`Alias already exists in scope: ${alias}`);
|
|
17
|
+
}
|
|
18
|
+
const binding = {
|
|
19
|
+
alias,
|
|
20
|
+
source,
|
|
21
|
+
scopeDepth: this.depth,
|
|
22
|
+
};
|
|
23
|
+
this.bindings.set(alias, binding);
|
|
24
|
+
return binding;
|
|
25
|
+
}
|
|
26
|
+
generateAlias(source) {
|
|
27
|
+
let alias;
|
|
28
|
+
do {
|
|
29
|
+
alias = `a${this.generatedCount++}`;
|
|
30
|
+
} while (this.bindings.has(alias));
|
|
31
|
+
return this.registerAlias(alias, source);
|
|
32
|
+
}
|
|
33
|
+
resolveAlias(alias) {
|
|
34
|
+
if (this.bindings.has(alias)) {
|
|
35
|
+
return this.bindings.get(alias);
|
|
36
|
+
}
|
|
37
|
+
if (this.parent) {
|
|
38
|
+
return this.parent.resolveAlias(alias);
|
|
39
|
+
}
|
|
40
|
+
throw new Error(`Alias not found in scope chain: ${alias}`);
|
|
41
|
+
}
|
|
42
|
+
createChildScope(name) {
|
|
43
|
+
return new IRAliasScope(name, this);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.IRAliasScope = IRAliasScope;
|
|
47
|
+
/** Validates that an alias exists in the current scope chain, throwing if not found. */
|
|
48
|
+
const validateAliasReference = (alias, currentScope) => {
|
|
49
|
+
return currentScope.resolveAlias(alias);
|
|
50
|
+
};
|
|
51
|
+
exports.validateAliasReference = validateAliasReference;
|
|
52
|
+
//# sourceMappingURL=IRAliasScope.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRAliasScope.js","sourceRoot":"","sources":["../../../src/queries/IRAliasScope.ts"],"names":[],"mappings":";;;AAOA,MAAa,YAAY;IAIvB,YACkB,SAAiB,EAChB,MAAqB;QADtB,cAAS,GAAT,SAAS,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAe;QALhC,aAAQ,GAAG,IAAI,GAAG,EAA0B,CAAC;QAC7C,mBAAc,GAAG,CAAC,CAAC;IAKxB,CAAC;IAEJ,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,aAAa,CAAC,KAAa,EAAE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Y,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC,CAAC;AALW,QAAA,sBAAsB,0BAKjC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DesugaredSelectionPath, DesugaredSelectQuery, DesugaredWhere, DesugaredWhereArg } from './IRDesugar.js';
|
|
2
|
+
import { WhereMethods } from './SelectQuery.js';
|
|
3
|
+
export type CanonicalWhereComparison = {
|
|
4
|
+
kind: 'where_binary';
|
|
5
|
+
operator: WhereMethods;
|
|
6
|
+
left: DesugaredSelectionPath;
|
|
7
|
+
right: DesugaredWhereArg[];
|
|
8
|
+
};
|
|
9
|
+
export type CanonicalWhereLogical = {
|
|
10
|
+
kind: 'where_logical';
|
|
11
|
+
operator: 'and' | 'or';
|
|
12
|
+
expressions: CanonicalWhereExpression[];
|
|
13
|
+
};
|
|
14
|
+
export type CanonicalWhereExists = {
|
|
15
|
+
kind: 'where_exists';
|
|
16
|
+
path: DesugaredSelectionPath;
|
|
17
|
+
predicate: CanonicalWhereExpression;
|
|
18
|
+
};
|
|
19
|
+
export type CanonicalWhereNot = {
|
|
20
|
+
kind: 'where_not';
|
|
21
|
+
expression: CanonicalWhereExpression;
|
|
22
|
+
};
|
|
23
|
+
export type CanonicalWhereExpression = CanonicalWhereComparison | CanonicalWhereLogical | CanonicalWhereExists | CanonicalWhereNot;
|
|
24
|
+
export type CanonicalDesugaredSelectQuery = Omit<DesugaredSelectQuery, 'where'> & {
|
|
25
|
+
where?: CanonicalWhereExpression;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Recursively rewrites a desugared where-clause into canonical form:
|
|
29
|
+
* flattens nested AND/OR groups, converts quantifiers (some/every) to exists patterns.
|
|
30
|
+
*/
|
|
31
|
+
export declare const canonicalizeWhere: (where: DesugaredWhere) => CanonicalWhereExpression;
|
|
32
|
+
/**
|
|
33
|
+
* Canonicalizes a desugared select query by normalizing its where-clause.
|
|
34
|
+
* All other fields pass through unchanged.
|
|
35
|
+
*/
|
|
36
|
+
export declare const canonicalizeDesugaredSelectQuery: (query: DesugaredSelectQuery) => CanonicalDesugaredSelectQuery;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canonicalizeDesugaredSelectQuery = exports.canonicalizeWhere = void 0;
|
|
4
|
+
const SelectQuery_js_1 = require("./SelectQuery.js");
|
|
5
|
+
const toComparison = (comparison) => {
|
|
6
|
+
return {
|
|
7
|
+
kind: 'where_binary',
|
|
8
|
+
operator: comparison.operator,
|
|
9
|
+
left: comparison.left,
|
|
10
|
+
right: comparison.right,
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
const isDesugaredWhere = (arg) => {
|
|
14
|
+
return (typeof arg === 'object' &&
|
|
15
|
+
!!arg &&
|
|
16
|
+
'kind' in arg &&
|
|
17
|
+
(arg.kind === 'where_comparison' ||
|
|
18
|
+
arg.kind === 'where_boolean'));
|
|
19
|
+
};
|
|
20
|
+
const toExists = (comparison) => {
|
|
21
|
+
const nested = comparison.right.find(isDesugaredWhere);
|
|
22
|
+
if (!nested) {
|
|
23
|
+
return toComparison(comparison);
|
|
24
|
+
}
|
|
25
|
+
const nestedExpr = (0, exports.canonicalizeWhere)(nested);
|
|
26
|
+
if (comparison.operator === SelectQuery_js_1.WhereMethods.SOME) {
|
|
27
|
+
return {
|
|
28
|
+
kind: 'where_exists',
|
|
29
|
+
path: comparison.left,
|
|
30
|
+
predicate: nestedExpr,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (comparison.operator === SelectQuery_js_1.WhereMethods.EVERY) {
|
|
34
|
+
return {
|
|
35
|
+
kind: 'where_not',
|
|
36
|
+
expression: {
|
|
37
|
+
kind: 'where_exists',
|
|
38
|
+
path: comparison.left,
|
|
39
|
+
predicate: {
|
|
40
|
+
kind: 'where_not',
|
|
41
|
+
expression: nestedExpr,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
return toComparison(comparison);
|
|
47
|
+
};
|
|
48
|
+
const canonicalizeComparison = (comparison) => {
|
|
49
|
+
if (comparison.operator === SelectQuery_js_1.WhereMethods.SOME ||
|
|
50
|
+
comparison.operator === SelectQuery_js_1.WhereMethods.EVERY ||
|
|
51
|
+
comparison.operator === 'some' ||
|
|
52
|
+
comparison.operator === 'every') {
|
|
53
|
+
return toExists(comparison);
|
|
54
|
+
}
|
|
55
|
+
return toComparison(comparison);
|
|
56
|
+
};
|
|
57
|
+
const flattenLogical = (operator, left, right) => {
|
|
58
|
+
const expressions = [];
|
|
59
|
+
if (left.kind === 'where_logical' && left.operator === operator) {
|
|
60
|
+
expressions.push(...left.expressions);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
expressions.push(left);
|
|
64
|
+
}
|
|
65
|
+
if (right.kind === 'where_logical' && right.operator === operator) {
|
|
66
|
+
expressions.push(...right.expressions);
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
expressions.push(right);
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
kind: 'where_logical',
|
|
73
|
+
operator,
|
|
74
|
+
expressions,
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Recursively rewrites a desugared where-clause into canonical form:
|
|
79
|
+
* flattens nested AND/OR groups, converts quantifiers (some/every) to exists patterns.
|
|
80
|
+
*/
|
|
81
|
+
const canonicalizeWhere = (where) => {
|
|
82
|
+
if (where.kind === 'where_comparison') {
|
|
83
|
+
if (where.operator === SelectQuery_js_1.WhereMethods.EQUALS) {
|
|
84
|
+
const nestedQuantifier = where.right.find((arg) => isDesugaredWhere(arg) &&
|
|
85
|
+
arg.kind === 'where_comparison' &&
|
|
86
|
+
(arg.operator === SelectQuery_js_1.WhereMethods.SOME ||
|
|
87
|
+
arg.operator === SelectQuery_js_1.WhereMethods.EVERY));
|
|
88
|
+
if (nestedQuantifier) {
|
|
89
|
+
return (0, exports.canonicalizeWhere)(nestedQuantifier);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (where.operator === SelectQuery_js_1.WhereMethods.SOME ||
|
|
93
|
+
where.operator === SelectQuery_js_1.WhereMethods.EVERY ||
|
|
94
|
+
where.operator === 'some' ||
|
|
95
|
+
where.operator === 'every') {
|
|
96
|
+
return toExists(where);
|
|
97
|
+
}
|
|
98
|
+
return toComparison(where);
|
|
99
|
+
}
|
|
100
|
+
const grouped = where;
|
|
101
|
+
let current = canonicalizeComparison(grouped.first);
|
|
102
|
+
grouped.andOr.forEach((token) => {
|
|
103
|
+
if (token.and) {
|
|
104
|
+
current = flattenLogical('and', current, (0, exports.canonicalizeWhere)(token.and));
|
|
105
|
+
}
|
|
106
|
+
else if (token.or) {
|
|
107
|
+
current = flattenLogical('or', current, (0, exports.canonicalizeWhere)(token.or));
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
return current;
|
|
111
|
+
};
|
|
112
|
+
exports.canonicalizeWhere = canonicalizeWhere;
|
|
113
|
+
/**
|
|
114
|
+
* Canonicalizes a desugared select query by normalizing its where-clause.
|
|
115
|
+
* All other fields pass through unchanged.
|
|
116
|
+
*/
|
|
117
|
+
const canonicalizeDesugaredSelectQuery = (query) => {
|
|
118
|
+
return Object.assign(Object.assign({}, query), { where: query.where ? (0, exports.canonicalizeWhere)(query.where) : undefined });
|
|
119
|
+
};
|
|
120
|
+
exports.canonicalizeDesugaredSelectQuery = canonicalizeDesugaredSelectQuery;
|
|
121
|
+
//# sourceMappingURL=IRCanonicalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRCanonicalize.js","sourceRoot":"","sources":["../../../src/queries/IRCanonicalize.ts"],"names":[],"mappings":";;;AAQA,qDAA8C;AAoC9C,MAAM,YAAY,GAAG,CACnB,UAAoC,EACV,EAAE;IAC5B,OAAO;QACL,IAAI,EAAE,cAAc;QACpB,QAAQ,EAAE,UAAU,CAAC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AxCW,QAAA,iBAAiB,qBAwC5B;AAEF;;;GAGG;AACI,MAAM,gCAAgC,GAAG,CAC9C,KAA2B,EACI,EAAE;IACjC,uCACK,KAAK,KACR,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,yBAAiB,EAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,IAC/D;AACJ,CAAC,CAAC;AAPW,QAAA,gCAAgC,oCAO3C"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { JSNonNullPrimitive, SelectPath, SortByPath, WhereMethods, WherePath } from './SelectQuery.js';
|
|
2
|
+
import { NodeReferenceValue, ShapeReferenceValue } from './QueryFactory.js';
|
|
3
|
+
/**
|
|
4
|
+
* Internal pipeline input type — captures exactly what the desugar pass
|
|
5
|
+
* needs from a select query factory. Replaces the old LegacySelectQuery
|
|
6
|
+
* as the pipeline entry point.
|
|
7
|
+
*/
|
|
8
|
+
export type RawSelectInput = {
|
|
9
|
+
select: SelectPath;
|
|
10
|
+
where?: WherePath;
|
|
11
|
+
sortBy?: SortByPath;
|
|
12
|
+
subject?: unknown;
|
|
13
|
+
shape?: unknown;
|
|
14
|
+
limit?: number;
|
|
15
|
+
offset?: number;
|
|
16
|
+
singleResult?: boolean;
|
|
17
|
+
};
|
|
18
|
+
export type DesugaredPropertyStep = {
|
|
19
|
+
kind: 'property_step';
|
|
20
|
+
propertyShapeId: string;
|
|
21
|
+
where?: DesugaredWhere;
|
|
22
|
+
};
|
|
23
|
+
export type DesugaredCountStep = {
|
|
24
|
+
kind: 'count_step';
|
|
25
|
+
path: DesugaredPropertyStep[];
|
|
26
|
+
label?: string;
|
|
27
|
+
};
|
|
28
|
+
export type DesugaredTypeCastStep = {
|
|
29
|
+
kind: 'type_cast_step';
|
|
30
|
+
shapeId: string;
|
|
31
|
+
};
|
|
32
|
+
export type DesugaredStep = DesugaredPropertyStep | DesugaredCountStep | DesugaredTypeCastStep;
|
|
33
|
+
export type DesugaredSelectionPath = {
|
|
34
|
+
kind: 'selection_path';
|
|
35
|
+
steps: DesugaredStep[];
|
|
36
|
+
};
|
|
37
|
+
export type DesugaredSubSelect = {
|
|
38
|
+
kind: 'sub_select';
|
|
39
|
+
parentPath: DesugaredStep[];
|
|
40
|
+
selections: DesugaredSelection;
|
|
41
|
+
};
|
|
42
|
+
export type DesugaredCustomObjectSelect = {
|
|
43
|
+
kind: 'custom_object_select';
|
|
44
|
+
entries: DesugaredCustomObjectEntry[];
|
|
45
|
+
};
|
|
46
|
+
export type DesugaredCustomObjectEntry = {
|
|
47
|
+
key: string;
|
|
48
|
+
value: DesugaredSelection;
|
|
49
|
+
};
|
|
50
|
+
export type DesugaredEvaluationSelect = {
|
|
51
|
+
kind: 'evaluation_select';
|
|
52
|
+
where: DesugaredWhere;
|
|
53
|
+
};
|
|
54
|
+
export type DesugaredMultiSelection = {
|
|
55
|
+
kind: 'multi_selection';
|
|
56
|
+
selections: DesugaredSelectionPath[];
|
|
57
|
+
};
|
|
58
|
+
export type DesugaredSelection = DesugaredSelectionPath | DesugaredSubSelect | DesugaredCustomObjectSelect | DesugaredEvaluationSelect | DesugaredMultiSelection;
|
|
59
|
+
export type DesugaredWhereComparison = {
|
|
60
|
+
kind: 'where_comparison';
|
|
61
|
+
operator: WhereMethods;
|
|
62
|
+
left: DesugaredSelectionPath;
|
|
63
|
+
right: DesugaredWhereArg[];
|
|
64
|
+
};
|
|
65
|
+
export type DesugaredWhereBoolean = {
|
|
66
|
+
kind: 'where_boolean';
|
|
67
|
+
first: DesugaredWhereComparison;
|
|
68
|
+
andOr: Array<{
|
|
69
|
+
and?: DesugaredWhere;
|
|
70
|
+
or?: DesugaredWhere;
|
|
71
|
+
}>;
|
|
72
|
+
};
|
|
73
|
+
export type DesugaredWhere = DesugaredWhereComparison | DesugaredWhereBoolean;
|
|
74
|
+
export type DesugaredSortBy = {
|
|
75
|
+
direction: 'ASC' | 'DESC';
|
|
76
|
+
paths: DesugaredSelectionPath[];
|
|
77
|
+
};
|
|
78
|
+
export type DesugaredWhereArg = JSNonNullPrimitive | NodeReferenceValue | ShapeReferenceValue | {
|
|
79
|
+
kind: 'arg_path';
|
|
80
|
+
subject?: ShapeReferenceValue;
|
|
81
|
+
path: DesugaredSelectionPath;
|
|
82
|
+
} | DesugaredWhere;
|
|
83
|
+
export type DesugaredSelectQuery = {
|
|
84
|
+
kind: 'desugared_select';
|
|
85
|
+
shapeId?: string;
|
|
86
|
+
subjectId?: string;
|
|
87
|
+
singleResult?: boolean;
|
|
88
|
+
limit?: number;
|
|
89
|
+
offset?: number;
|
|
90
|
+
selections: DesugaredSelection[];
|
|
91
|
+
sortBy?: DesugaredSortBy;
|
|
92
|
+
where?: DesugaredWhere;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Converts a RawSelectInput (DSL-level query) into a flat DesugaredSelectQuery
|
|
96
|
+
* by walking proxy-traced select/where/sortBy paths and extracting property steps.
|
|
97
|
+
*/
|
|
98
|
+
export declare const desugarSelectQuery: (query: RawSelectInput) => DesugaredSelectQuery;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.desugarSelectQuery = void 0;
|
|
4
|
+
const SelectQuery_js_1 = require("./SelectQuery.js");
|
|
5
|
+
const isPropertyQueryStep = (step) => {
|
|
6
|
+
var _a;
|
|
7
|
+
return !!step && typeof step === 'object' && 'property' in step &&
|
|
8
|
+
!!((_a = step.property) === null || _a === void 0 ? void 0 : _a.id);
|
|
9
|
+
};
|
|
10
|
+
const isSizeStep = (step) => {
|
|
11
|
+
return !!step && typeof step === 'object' && 'count' in step;
|
|
12
|
+
};
|
|
13
|
+
const isShapeRef = (value) => !!value && typeof value === 'object' && 'id' in value && 'shape' in value;
|
|
14
|
+
const isNodeRef = (value) => typeof value === 'object' && value !== null && 'id' in value;
|
|
15
|
+
const isCustomQueryObject = (value) => !!value && typeof value === 'object' && !Array.isArray(value) &&
|
|
16
|
+
!('property' in value) && !('count' in value) && !('id' in value) &&
|
|
17
|
+
!('args' in value) && !('firstPath' in value) && !('method' in value);
|
|
18
|
+
const toStep = (step) => {
|
|
19
|
+
if (isSizeStep(step)) {
|
|
20
|
+
return {
|
|
21
|
+
kind: 'count_step',
|
|
22
|
+
path: step.count.map((s) => toPropertyStepOnly(s)),
|
|
23
|
+
label: step.label,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
if (isShapeRef(step)) {
|
|
27
|
+
return {
|
|
28
|
+
kind: 'type_cast_step',
|
|
29
|
+
shapeId: step.id,
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (isPropertyQueryStep(step)) {
|
|
33
|
+
const result = {
|
|
34
|
+
kind: 'property_step',
|
|
35
|
+
propertyShapeId: step.property.id,
|
|
36
|
+
};
|
|
37
|
+
if (step.where) {
|
|
38
|
+
result.where = toWhere(step.where);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
// CustomQueryObject step — this appears in preload and sub-select paths
|
|
43
|
+
if (isCustomQueryObject(step)) {
|
|
44
|
+
// Return a property_step placeholder; the parent path handler will pick up sub-selects
|
|
45
|
+
// This is an edge case for preload where the sub-query object is pushed into the path
|
|
46
|
+
return {
|
|
47
|
+
kind: 'property_step',
|
|
48
|
+
propertyShapeId: '__sub_query',
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
throw new Error('Unsupported query step in desugar pass: ' + JSON.stringify(step));
|
|
52
|
+
};
|
|
53
|
+
const toPropertyStepOnly = (step) => {
|
|
54
|
+
if (isPropertyQueryStep(step)) {
|
|
55
|
+
return {
|
|
56
|
+
kind: 'property_step',
|
|
57
|
+
propertyShapeId: step.property.id,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
throw new Error('Expected property step in count path');
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Converts a SelectPath (QueryPath[] or CustomQueryObject) to desugared selections.
|
|
64
|
+
*/
|
|
65
|
+
const toSelections = (select) => {
|
|
66
|
+
if (Array.isArray(select)) {
|
|
67
|
+
return select.map((path) => toSelection(path));
|
|
68
|
+
}
|
|
69
|
+
// CustomQueryObject at top level
|
|
70
|
+
return [toCustomObjectSelect(select)];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Converts a single QueryPath to a DesugaredSelection.
|
|
74
|
+
* A QueryPath can be:
|
|
75
|
+
* - (QueryStep | SubQueryPaths)[] — a flat or nested array of steps
|
|
76
|
+
* - WherePath — a where evaluation used as a selection (e.g. p.bestFriend.equals(...))
|
|
77
|
+
*/
|
|
78
|
+
const toSelection = (path) => {
|
|
79
|
+
// WherePath used as a selection (e.g. customResultEqualsBoolean)
|
|
80
|
+
if (!Array.isArray(path)) {
|
|
81
|
+
if ((0, SelectQuery_js_1.isWhereEvaluationPath)(path) || 'firstPath' in path) {
|
|
82
|
+
return {
|
|
83
|
+
kind: 'evaluation_select',
|
|
84
|
+
where: toWhere(path),
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
throw new Error('Unsupported non-array path in desugar selection pass');
|
|
88
|
+
}
|
|
89
|
+
// Check if the last element is a sub-query (nested array or custom object)
|
|
90
|
+
const lastElement = path[path.length - 1];
|
|
91
|
+
if (Array.isArray(lastElement)) {
|
|
92
|
+
// Sub-select: parent path steps + nested selections
|
|
93
|
+
const parentSteps = path.slice(0, -1).map((step) => toStep(step));
|
|
94
|
+
const nestedSelect = lastElement;
|
|
95
|
+
return {
|
|
96
|
+
kind: 'sub_select',
|
|
97
|
+
parentPath: parentSteps,
|
|
98
|
+
selections: toSubSelections(nestedSelect),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
if (lastElement && typeof lastElement === 'object' && isCustomQueryObject(lastElement)) {
|
|
102
|
+
// Sub-select with custom object: parent path steps + custom object selections
|
|
103
|
+
const parentSteps = path.slice(0, -1).map((step) => toStep(step));
|
|
104
|
+
return {
|
|
105
|
+
kind: 'sub_select',
|
|
106
|
+
parentPath: parentSteps,
|
|
107
|
+
selections: toCustomObjectSelect(lastElement),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
// Flat selection path
|
|
111
|
+
return {
|
|
112
|
+
kind: 'selection_path',
|
|
113
|
+
steps: path.map((step) => toStep(step)),
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Converts sub-select contents (which can be QueryPath[] or CustomQueryObject).
|
|
118
|
+
*/
|
|
119
|
+
const toSubSelections = (select) => {
|
|
120
|
+
if (Array.isArray(select)) {
|
|
121
|
+
// Array of paths — could be a single path or multiple paths
|
|
122
|
+
if (select.length === 0) {
|
|
123
|
+
return { kind: 'selection_path', steps: [] };
|
|
124
|
+
}
|
|
125
|
+
const selections = select.map((path) => toSelection(path));
|
|
126
|
+
if (selections.length === 1) {
|
|
127
|
+
return selections[0];
|
|
128
|
+
}
|
|
129
|
+
// Multiple selections in a sub-select
|
|
130
|
+
return {
|
|
131
|
+
kind: 'multi_selection',
|
|
132
|
+
selections: selections.filter((s) => s.kind === 'selection_path'),
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return toCustomObjectSelect(select);
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Converts a CustomQueryObject to a DesugaredCustomObjectSelect.
|
|
139
|
+
*/
|
|
140
|
+
const toCustomObjectSelect = (obj) => {
|
|
141
|
+
const entries = Object.keys(obj).map((key) => ({
|
|
142
|
+
key,
|
|
143
|
+
value: toSelection(obj[key]),
|
|
144
|
+
}));
|
|
145
|
+
return {
|
|
146
|
+
kind: 'custom_object_select',
|
|
147
|
+
entries,
|
|
148
|
+
};
|
|
149
|
+
};
|
|
150
|
+
const toSelectionPath = (path) => {
|
|
151
|
+
if (!Array.isArray(path)) {
|
|
152
|
+
throw new Error('Unsupported non-array path in desugar selection pass');
|
|
153
|
+
}
|
|
154
|
+
return {
|
|
155
|
+
kind: 'selection_path',
|
|
156
|
+
steps: path.map((step) => toStep(step)),
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
const toWhereArg = (arg) => {
|
|
160
|
+
if (typeof arg === 'string' ||
|
|
161
|
+
typeof arg === 'number' ||
|
|
162
|
+
typeof arg === 'boolean' ||
|
|
163
|
+
arg instanceof Date) {
|
|
164
|
+
return arg;
|
|
165
|
+
}
|
|
166
|
+
if (isShapeRef(arg)) {
|
|
167
|
+
return arg;
|
|
168
|
+
}
|
|
169
|
+
if (isNodeRef(arg)) {
|
|
170
|
+
return arg;
|
|
171
|
+
}
|
|
172
|
+
if (arg && typeof arg === 'object') {
|
|
173
|
+
if ((0, SelectQuery_js_1.isWhereEvaluationPath)(arg) || 'firstPath' in arg) {
|
|
174
|
+
return toWhere(arg);
|
|
175
|
+
}
|
|
176
|
+
if ('path' in arg) {
|
|
177
|
+
const pathArg = arg;
|
|
178
|
+
return {
|
|
179
|
+
kind: 'arg_path',
|
|
180
|
+
subject: pathArg.subject,
|
|
181
|
+
path: toSelectionPath(pathArg.path),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
throw new Error('Unsupported where argument in desugar pass');
|
|
186
|
+
};
|
|
187
|
+
const toWhereComparison = (path) => {
|
|
188
|
+
if (!(0, SelectQuery_js_1.isWhereEvaluationPath)(path)) {
|
|
189
|
+
throw new Error('Expected where evaluation path');
|
|
190
|
+
}
|
|
191
|
+
return {
|
|
192
|
+
kind: 'where_comparison',
|
|
193
|
+
operator: path.method,
|
|
194
|
+
left: toSelectionPath(path.path),
|
|
195
|
+
right: (path.args || []).map(toWhereArg),
|
|
196
|
+
};
|
|
197
|
+
};
|
|
198
|
+
const toWhere = (path) => {
|
|
199
|
+
if (path.firstPath) {
|
|
200
|
+
const grouped = path;
|
|
201
|
+
return {
|
|
202
|
+
kind: 'where_boolean',
|
|
203
|
+
first: toWhereComparison(grouped.firstPath),
|
|
204
|
+
andOr: grouped.andOr.map((token) => ({
|
|
205
|
+
and: token.and ? toWhere(token.and) : undefined,
|
|
206
|
+
or: token.or ? toWhere(token.or) : undefined,
|
|
207
|
+
})),
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
return toWhereComparison(path);
|
|
211
|
+
};
|
|
212
|
+
const toSortBy = (query) => {
|
|
213
|
+
if (!query.sortBy) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
return {
|
|
217
|
+
direction: query.sortBy.direction,
|
|
218
|
+
paths: query.sortBy.paths.map((path) => toSelectionPath(path)),
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
/**
|
|
222
|
+
* Converts a RawSelectInput (DSL-level query) into a flat DesugaredSelectQuery
|
|
223
|
+
* by walking proxy-traced select/where/sortBy paths and extracting property steps.
|
|
224
|
+
*/
|
|
225
|
+
const desugarSelectQuery = (query) => {
|
|
226
|
+
var _a, _b, _c;
|
|
227
|
+
const selections = toSelections(query.select);
|
|
228
|
+
const subjectId = query.subject && typeof query.subject === 'object' && 'id' in query.subject
|
|
229
|
+
? query.subject.id
|
|
230
|
+
: undefined;
|
|
231
|
+
return {
|
|
232
|
+
kind: 'desugared_select',
|
|
233
|
+
shapeId: ((_b = (_a = query.shape) === null || _a === void 0 ? void 0 : _a.shape) === null || _b === void 0 ? void 0 : _b.id) || ((_c = query.shape) === null || _c === void 0 ? void 0 : _c.id),
|
|
234
|
+
subjectId,
|
|
235
|
+
singleResult: query.singleResult,
|
|
236
|
+
limit: query.limit,
|
|
237
|
+
offset: query.offset,
|
|
238
|
+
selections,
|
|
239
|
+
sortBy: toSortBy(query),
|
|
240
|
+
where: query.where ? toWhere(query.where) : undefined,
|
|
241
|
+
};
|
|
242
|
+
};
|
|
243
|
+
exports.desugarSelectQuery = desugarSelectQuery;
|
|
244
|
+
//# sourceMappingURL=IRDesugar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRDesugar.js","sourceRoot":"","sources":["../../../src/queries/IRDesugar.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C,YAAY;QAChC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,UAAU;QACV,MAAM,EAAE,QAAQ,CAAC,KAAK,CAAC;QACvB,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS;KACtD,CAAC;AACJ,CAAC,CAAC;AAnBW,QAAA,kBAAkB,sBAmB7B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CanonicalDesugaredSelectQuery } from './IRCanonicalize.js';
|
|
2
|
+
import { IRSelectQuery } from './IntermediateRepresentation.js';
|
|
3
|
+
/**
|
|
4
|
+
* Lowers a canonical desugared select query into the final IRSelectQuery.
|
|
5
|
+
* Introduces aliases, graph patterns (shape scans, traversals), and
|
|
6
|
+
* converts selection paths and where-clauses into IR expressions.
|
|
7
|
+
*/
|
|
8
|
+
export declare const lowerSelectQuery: (canonical: CanonicalDesugaredSelectQuery) => IRSelectQuery;
|