@_linked/core 1.0.0-next.20260216062729 → 1.0.0-next.20260225020512
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/README.md +40 -1
- package/lib/cjs/index.js +2 -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 +112 -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 +238 -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 +27 -0
- package/lib/cjs/queries/IRProjection.js +84 -0
- package/lib/cjs/queries/IRProjection.js.map +1 -0
- package/lib/cjs/queries/IntermediateRepresentation.d.ts +200 -0
- package/lib/cjs/queries/IntermediateRepresentation.js +3 -0
- package/lib/cjs/queries/IntermediateRepresentation.js.map +1 -0
- 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 +13 -27
- package/lib/cjs/queries/SelectQuery.js +40 -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/Shape.d.ts +0 -11
- package/lib/cjs/shapes/Shape.js +5 -5
- package/lib/cjs/shapes/Shape.js.map +1 -1
- 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 +72 -72
- 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 +2 -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 +107 -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 +234 -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 +27 -0
- package/lib/esm/queries/IRProjection.js +78 -0
- package/lib/esm/queries/IRProjection.js.map +1 -0
- package/lib/esm/queries/IntermediateRepresentation.d.ts +200 -0
- package/lib/esm/queries/IntermediateRepresentation.js +2 -0
- package/lib/esm/queries/IntermediateRepresentation.js.map +1 -0
- 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 +13 -27
- package/lib/esm/queries/SelectQuery.js +40 -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/Shape.d.ts +0 -11
- package/lib/esm/shapes/Shape.js +5 -5
- package/lib/esm/shapes/Shape.js.map +1 -1
- 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 +72 -72
- 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 +1 -1
- 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
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
### Minor Changes
|
|
10
10
|
|
|
11
|
+
- [#9](https://github.com/Semantu/linked/pull/9) [`381067b`](https://github.com/Semantu/linked/commit/381067b0fbc25f4a0446c5f8cc0eec57ddded466) Thanks [@flyon](https://github.com/flyon)! - Introduce canonical Intermediate Representation (IR) support for query and mutation objects.
|
|
12
|
+
|
|
13
|
+
- Add select-query IR pipeline stages (desugar, canonicalize, projection, alias scope, pipeline helpers) and expose `getCanonicalIR()` on select factories.
|
|
14
|
+
- Add canonical mutation IR conversion for create/update/delete query objects.
|
|
15
|
+
- Add IR documentation and parity/golden test coverage for select and mutation conversion behavior.
|
|
16
|
+
|
|
11
17
|
- [#4](https://github.com/Semantu/linked/pull/4) [`c35e686`](https://github.com/Semantu/linked/commit/c35e6861600d7aa8683b4b288fc4d1dc74c4aff2) Thanks [@flyon](https://github.com/flyon)! - - Added `Shape.selectAll()` plus nested `selectAll()` support on sub-queries.
|
|
12
18
|
- Added inherited property deduplication via `NodeShape.getUniquePropertyShapes()` so subclass overrides win by label and are selected once.
|
|
13
19
|
- Improved `selectAll()` type inference (including nested queries) and excluded base `Shape` keys from inferred results.
|
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# @_linked/core
|
|
2
2
|
Core Linked package for the query DSL, SHACL shape decorators/metadata, and package registration.
|
|
3
3
|
|
|
4
|
-
Linked core gives you a type-safe, schema-parameterized query language and SHACL-driven Shape classes for linked data. It compiles queries into a
|
|
4
|
+
Linked core gives you a type-safe, schema-parameterized query language and SHACL-driven Shape classes for linked data. It compiles queries into a normalized [Intermediate Representation (IR)](./documentation/intermediate-representation.md) that can be executed by any store.
|
|
5
5
|
|
|
6
6
|
## Linked core offers
|
|
7
7
|
|
|
@@ -27,6 +27,10 @@ import {linkedPackage} from '@_linked/core/utils/Package';
|
|
|
27
27
|
- `@_linked/rdf-mem-store`: in-memory RDF store that implements `IQuadStore`.
|
|
28
28
|
- `@_linked/react`: React bindings for Linked queries and shapes.
|
|
29
29
|
|
|
30
|
+
## Documentation
|
|
31
|
+
|
|
32
|
+
- [Intermediate Representation (IR)](./documentation/intermediate-representation.md)
|
|
33
|
+
|
|
30
34
|
## Linked Package Setup
|
|
31
35
|
|
|
32
36
|
Linked packages expose shapes, utilities, and ontologies through a small `package.ts` file. This makes module exports discoverable across Linked modules and enables linked decorators.
|
|
@@ -428,6 +432,41 @@ Override behavior:
|
|
|
428
432
|
- Allow `preloadFor` to accept another query (not just a component).
|
|
429
433
|
- Make and expose functions for auto syncing shapes to the graph.
|
|
430
434
|
|
|
435
|
+
## Intermediate Representation (IR)
|
|
436
|
+
|
|
437
|
+
Every Linked query compiles to a plain, JSON-serializable JavaScript object — the **Intermediate Representation**. This IR is the contract between the DSL and any storage backend. A store receives these objects and translates them into its native query language (SPARQL, SQL, etc.).
|
|
438
|
+
|
|
439
|
+
For example, this DSL call:
|
|
440
|
+
|
|
441
|
+
```typescript
|
|
442
|
+
const names = await Person.select((p) => p.name);
|
|
443
|
+
```
|
|
444
|
+
|
|
445
|
+
produces the following IR object, which is passed to your store's `selectQuery()` method:
|
|
446
|
+
|
|
447
|
+
```json
|
|
448
|
+
{
|
|
449
|
+
"kind": "select",
|
|
450
|
+
"root": {"kind": "shape_scan", "shape": "https://schema.org/Person", "alias": "a0"},
|
|
451
|
+
"patterns": [],
|
|
452
|
+
"projection": [
|
|
453
|
+
{
|
|
454
|
+
"alias": "a1",
|
|
455
|
+
"expression": {"kind": "property_expr", "sourceAlias": "a0", "property": "https://schema.org/name"}
|
|
456
|
+
}
|
|
457
|
+
],
|
|
458
|
+
"resultMap": [{"key": "name", "alias": "a1"}],
|
|
459
|
+
"singleResult": false
|
|
460
|
+
}
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
All IR types are available from `@_linked/core/queries/IntermediateRepresentation`. See the full [Intermediate Representation docs](./documentation/intermediate-representation.md) for the complete type reference, examples, and a store implementer guide.
|
|
464
|
+
|
|
465
|
+
**Store packages:**
|
|
466
|
+
|
|
467
|
+
- `@_linked/sparql-store` — SPARQL endpoint store (coming soon)
|
|
468
|
+
- `@_linked/rdf-mem-store` — in-memory RDF store
|
|
469
|
+
|
|
431
470
|
## Changelog
|
|
432
471
|
|
|
433
472
|
See [CHANGELOG.md](./CHANGELOG.md).
|
package/lib/cjs/index.js
CHANGED
|
@@ -61,6 +61,7 @@ const DeleteQuery = __importStar(require("./queries/DeleteQuery.js"));
|
|
|
61
61
|
const CreateQuery = __importStar(require("./queries/CreateQuery.js"));
|
|
62
62
|
const QueryParser = __importStar(require("./queries/QueryParser.js"));
|
|
63
63
|
const QueryFactory = __importStar(require("./queries/QueryFactory.js"));
|
|
64
|
+
const IntermediateRepresentation = __importStar(require("./queries/IntermediateRepresentation.js"));
|
|
64
65
|
const NameSpace = __importStar(require("./utils/NameSpace.js"));
|
|
65
66
|
const ShapeClass = __importStar(require("./utils/ShapeClass.js"));
|
|
66
67
|
const cached = __importStar(require("./utils/cached.js"));
|
|
@@ -103,6 +104,7 @@ function initModularApp() {
|
|
|
103
104
|
CreateQuery,
|
|
104
105
|
QueryParser,
|
|
105
106
|
QueryFactory,
|
|
107
|
+
IntermediateRepresentation,
|
|
106
108
|
SHACLShapes,
|
|
107
109
|
rdf,
|
|
108
110
|
rdfs,
|
package/lib/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,wCAgDC;AAzFD;;;;GAIG;AACH,4DAA8C;AAC9C,kFAAoE;AACpE,gFAAkE;AAClE,wEAA0D;AAC1D,kEAAoD;AACpD,kEAAoD;AACpD,yDAA2C;AAC3C,+DAAiD;AACjD,oEAAsD;AACtD,0DAA4C;AAC5C,oDAAsC;AACtC,sEAAwD;AACxD,sEAAwD;AACxD,0EAA4D;AAC5D,sEAAwD;AACxD,sEAAwD;AACxD,sEAAwD;AACxD,wEAA0D;AAC1D,oGAAsF;AACtF,gEAAkD;AAClD,kEAAoD;AACpD,0DAA4C;AAC5C,uDAAyC;AACzC,6EAA+D;AAC/D,uEAAyD;AACzD,uEAAyD;AACzD,yDAA2C;AAC3C,2DAA6C;AAC7C,yDAA2C;AAC3C,6DAA+C;AAC/C,6DAA+C;AAC/C,yDAA2C;AAC3C,yDAA2C;AAC3C,0DAAiC;AACzB,mBADD,mBAAQ,CACC;AAEhB,SAAgB,cAAc;IAC5B,IAAI,WAAW,GAAG;QAChB,OAAO;QACP,kBAAkB;QAClB,iBAAiB;QACjB,aAAa;QACb,OAAO;QACP,OAAO;QACP,KAAK;QACL,QAAQ;QACR,MAAM;QACN,SAAS;QACT,MAAM;QACN,GAAG;QACH,UAAU;QACV,IAAI;QACJ,aAAa;QACb,UAAU;QACV,UAAU;QACV,WAAW;QACX,WAAW;QACX,aAAa;QACb,WAAW;QACX,WAAW;QACX,WAAW;QACX,YAAY;QACZ,0BAA0B;QAC1B,WAAW;QACX,GAAG;QACH,IAAI;QACJ,GAAG;QACH,KAAK;QACL,KAAK;QACL,GAAG;QACH,GAAG;KACJ,CAAC;IACF,IAAI,WAAW,GAAG,EAAE,CAAC;IACrB,KAAK,IAAI,OAAO,IAAI,WAAW,EAAE,CAAC;QAChC,IAAI,eAAe,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAC3C,KAAK,IAAI,SAAS,IAAI,eAAe,EAAE,CAAC;YACtC,WAAW,CAAC,SAAS,CAAC,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;IAC9C,CAAC;SAAM,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QACzC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import type { SelectQuery } from '../queries/SelectQuery.js';
|
|
2
|
+
import type { CreateQuery } from '../queries/CreateQuery.js';
|
|
3
|
+
import type { UpdateQuery } from '../queries/UpdateQuery.js';
|
|
4
|
+
import type { DeleteQuery, DeleteResponse } from '../queries/DeleteQuery.js';
|
|
5
|
+
import type { SelectResult, CreateResult, UpdateResult } from '../queries/IntermediateRepresentation.js';
|
|
6
|
+
/**
|
|
7
|
+
* Store interface for executing IR queries.
|
|
8
|
+
*
|
|
9
|
+
* Implement this interface to back Linked with a custom storage engine
|
|
10
|
+
* (SPARQL endpoint, SQL database, in-memory store, etc.).
|
|
11
|
+
*
|
|
12
|
+
* Each method receives a canonical IR query object and returns the result.
|
|
13
|
+
* The calling layer (LinkedStorage / QueryParser) threads the precise
|
|
14
|
+
* DSL-level TypeScript result type back to the caller — the store only
|
|
15
|
+
* needs to produce data that matches the structural result types.
|
|
16
|
+
*/
|
|
5
17
|
export interface IQuadStore {
|
|
6
18
|
/**
|
|
7
19
|
* Prepares the store to be used.
|
|
8
20
|
*/
|
|
9
21
|
init?(): Promise<any>;
|
|
10
|
-
selectQuery
|
|
11
|
-
updateQuery
|
|
12
|
-
createQuery
|
|
22
|
+
selectQuery(query: SelectQuery): Promise<SelectResult>;
|
|
23
|
+
updateQuery?(query: UpdateQuery): Promise<UpdateResult>;
|
|
24
|
+
createQuery?(query: CreateQuery): Promise<CreateResult>;
|
|
13
25
|
deleteQuery?(query: DeleteQuery): Promise<DeleteResponse>;
|
|
14
26
|
}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { Shape } from '../shapes/Shape.js';
|
|
2
|
-
import { NodeShape } from '../shapes/SHACL.js';
|
|
3
|
-
import { LinkedQuery } from './SelectQuery.js';
|
|
4
2
|
import { AddId, NodeDescriptionValue, UpdatePartial } from './QueryFactory.js';
|
|
5
3
|
import { MutationQueryFactory } from './MutationQuery.js';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { IRCreateMutation } from './IntermediateRepresentation.js';
|
|
5
|
+
/**
|
|
6
|
+
* The canonical CreateQuery type — an IR AST node representing a create mutation.
|
|
7
|
+
* This is the type received by IQuadStore.createQuery().
|
|
8
|
+
*/
|
|
9
|
+
export type CreateQuery = IRCreateMutation;
|
|
11
10
|
export type CreateResponse<U> = AddId<U, true>;
|
|
12
11
|
export declare class CreateQueryFactory<ShapeType extends Shape, U extends UpdatePartial<ShapeType>> extends MutationQueryFactory {
|
|
13
12
|
shapeClass: typeof Shape;
|
|
14
13
|
readonly id: string;
|
|
15
14
|
readonly description: NodeDescriptionValue;
|
|
16
15
|
constructor(shapeClass: typeof Shape, updateObjectOrFn: U);
|
|
17
|
-
|
|
16
|
+
build(): CreateQuery;
|
|
18
17
|
}
|
|
@@ -2,18 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CreateQueryFactory = void 0;
|
|
4
4
|
const MutationQuery_js_1 = require("./MutationQuery.js");
|
|
5
|
+
const IRMutation_js_1 = require("./IRMutation.js");
|
|
5
6
|
class CreateQueryFactory extends MutationQuery_js_1.MutationQueryFactory {
|
|
6
7
|
constructor(shapeClass, updateObjectOrFn) {
|
|
7
8
|
super();
|
|
8
9
|
this.shapeClass = shapeClass;
|
|
9
10
|
this.description = this.convertUpdateObject(updateObjectOrFn, this.shapeClass.shape, true);
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
-
return {
|
|
13
|
-
type: 'create',
|
|
12
|
+
build() {
|
|
13
|
+
return (0, IRMutation_js_1.buildCanonicalCreateMutationIR)({
|
|
14
14
|
shape: this.shapeClass.shape,
|
|
15
15
|
description: this.description,
|
|
16
|
-
};
|
|
16
|
+
});
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
exports.CreateQueryFactory = CreateQueryFactory;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateQuery.js","sourceRoot":"","sources":["../../../src/queries/CreateQuery.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"CreateQuery.js","sourceRoot":"","sources":["../../../src/queries/CreateQuery.ts"],"names":[],"mappings":";;;AAEA,yDAAwD;AAExD,mDAA+D;AAU/D,MAAa,kBAGX,SAAQ,uCAAoB;IAI5B,YACS,UAAwB,EAC/B,gBAAmB;QAEnB,KAAK,EAAE,CAAC;QAHD,eAAU,GAAV,UAAU,CAAc;QAI/B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,mBAAmB,CACzC,gBAAgB,EAChB,IAAI,CAAC,UAAU,CAAC,KAAK,EACrB,IAAI,CACL,CAAC;IACJ,CAAC;IAED,KAAK;QACH,OAAO,IAAA,8CAA8B,EAAC;YACpC,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,KAAK;YAC5B,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;IACL,CAAC;CACF;AAzBD,gDAyBC"}
|
|
@@ -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,MAAc;QACzC,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,EAAE,CAAC,CAAC;QAC7D,CAAC;QACD,MAAM,OAAO,GAAmB;YAC9B,KAAK;YACL,MAAM;YACN,UAAU,EAAE,IAAI,CAAC,KAAK;SACvB,CAAC;QACF,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAClC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,aAAa,CAAC,MAAc;QAC1B,IAAI,KAAa,CAAC;QAClB,GAAG,CAAC;YACF,KAAK,GAAG,IAAI,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC;QACtC,CAAC,QAAQ,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACnC,OAAO,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,YAAY,CAAC,KAAa;QACxB,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACzC,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,mCAAmC,KAAK,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,gBAAgB,CAAC,IAAY;QAC3B,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACtC,CAAC;CACF;AA/CD,oCA+CC;AAED,wFAAwF;AACjF,MAAM,sBAAsB,GAAG,CACpC,KAAa,EACb,YAA0B,EACV,EAAE;IAClB,OAAO,YAAY,CAAC,YAAY,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,112 @@
|
|
|
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 flattenLogical = (operator, left, right) => {
|
|
49
|
+
const expressions = [];
|
|
50
|
+
if (left.kind === 'where_logical' && left.operator === operator) {
|
|
51
|
+
expressions.push(...left.expressions);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
expressions.push(left);
|
|
55
|
+
}
|
|
56
|
+
if (right.kind === 'where_logical' && right.operator === operator) {
|
|
57
|
+
expressions.push(...right.expressions);
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
expressions.push(right);
|
|
61
|
+
}
|
|
62
|
+
return {
|
|
63
|
+
kind: 'where_logical',
|
|
64
|
+
operator,
|
|
65
|
+
expressions,
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Recursively rewrites a desugared where-clause into canonical form:
|
|
70
|
+
* flattens nested AND/OR groups, converts quantifiers (some/every) to exists patterns.
|
|
71
|
+
*/
|
|
72
|
+
const canonicalizeWhere = (where) => {
|
|
73
|
+
if (where.kind === 'where_comparison') {
|
|
74
|
+
if (where.operator === SelectQuery_js_1.WhereMethods.EQUALS) {
|
|
75
|
+
const nestedQuantifier = where.right.find((arg) => isDesugaredWhere(arg) &&
|
|
76
|
+
arg.kind === 'where_comparison' &&
|
|
77
|
+
(arg.operator === SelectQuery_js_1.WhereMethods.SOME ||
|
|
78
|
+
arg.operator === SelectQuery_js_1.WhereMethods.EVERY));
|
|
79
|
+
if (nestedQuantifier) {
|
|
80
|
+
return (0, exports.canonicalizeWhere)(nestedQuantifier);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (where.operator === SelectQuery_js_1.WhereMethods.SOME ||
|
|
84
|
+
where.operator === SelectQuery_js_1.WhereMethods.EVERY ||
|
|
85
|
+
where.operator === 'some' ||
|
|
86
|
+
where.operator === 'every') {
|
|
87
|
+
return toExists(where);
|
|
88
|
+
}
|
|
89
|
+
return toComparison(where);
|
|
90
|
+
}
|
|
91
|
+
const grouped = where;
|
|
92
|
+
let current = toComparison(grouped.first);
|
|
93
|
+
grouped.andOr.forEach((token) => {
|
|
94
|
+
if (token.and) {
|
|
95
|
+
current = flattenLogical('and', current, (0, exports.canonicalizeWhere)(token.and));
|
|
96
|
+
}
|
|
97
|
+
else if (token.or) {
|
|
98
|
+
current = flattenLogical('or', current, (0, exports.canonicalizeWhere)(token.or));
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return current;
|
|
102
|
+
};
|
|
103
|
+
exports.canonicalizeWhere = canonicalizeWhere;
|
|
104
|
+
/**
|
|
105
|
+
* Canonicalizes a desugared select query by normalizing its where-clause.
|
|
106
|
+
* All other fields pass through unchanged.
|
|
107
|
+
*/
|
|
108
|
+
const canonicalizeDesugaredSelectQuery = (query) => {
|
|
109
|
+
return Object.assign(Object.assign({}, query), { where: query.where ? (0, exports.canonicalizeWhere)(query.where) : undefined });
|
|
110
|
+
};
|
|
111
|
+
exports.canonicalizeDesugaredSelectQuery = canonicalizeDesugaredSelectQuery;
|
|
112
|
+
//# sourceMappingURL=IRCanonicalize.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRCanonicalize.js","sourceRoot":"","sources":["../../../src/queries/IRCanonicalize.ts"],"names":[],"mappings":"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"}
|
|
@@ -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;
|