@_linked/core 2.2.0-next.20260313111743 → 2.2.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +253 -0
  2. package/lib/cjs/ontologies/shacl.d.ts +5 -0
  3. package/lib/cjs/ontologies/shacl.js +10 -0
  4. package/lib/cjs/ontologies/shacl.js.map +1 -1
  5. package/lib/cjs/paths/PropertyPathExpr.d.ts +38 -0
  6. package/lib/cjs/paths/PropertyPathExpr.js +221 -0
  7. package/lib/cjs/paths/PropertyPathExpr.js.map +1 -0
  8. package/lib/cjs/paths/normalizePropertyPath.d.ts +23 -0
  9. package/lib/cjs/paths/normalizePropertyPath.js +75 -0
  10. package/lib/cjs/paths/normalizePropertyPath.js.map +1 -0
  11. package/lib/cjs/paths/pathExprToSparql.d.ts +14 -0
  12. package/lib/cjs/paths/pathExprToSparql.js +136 -0
  13. package/lib/cjs/paths/pathExprToSparql.js.map +1 -0
  14. package/lib/cjs/paths/serializePathToSHACL.d.ts +22 -0
  15. package/lib/cjs/paths/serializePathToSHACL.js +126 -0
  16. package/lib/cjs/paths/serializePathToSHACL.js.map +1 -0
  17. package/lib/cjs/queries/IRDesugar.d.ts +2 -0
  18. package/lib/cjs/queries/IRDesugar.js +24 -8
  19. package/lib/cjs/queries/IRDesugar.js.map +1 -1
  20. package/lib/cjs/queries/IRLower.js +9 -5
  21. package/lib/cjs/queries/IRLower.js.map +1 -1
  22. package/lib/cjs/queries/IRProjection.d.ts +2 -1
  23. package/lib/cjs/queries/IRProjection.js +7 -3
  24. package/lib/cjs/queries/IRProjection.js.map +1 -1
  25. package/lib/cjs/queries/IntermediateRepresentation.d.ts +3 -0
  26. package/lib/cjs/queries/QueryBuilder.js +3 -2
  27. package/lib/cjs/queries/QueryBuilder.js.map +1 -1
  28. package/lib/cjs/shapes/SHACL.d.ts +62 -24
  29. package/lib/cjs/shapes/SHACL.js +30 -26
  30. package/lib/cjs/shapes/SHACL.js.map +1 -1
  31. package/lib/cjs/sparql/SparqlAlgebra.d.ts +4 -0
  32. package/lib/cjs/sparql/algebraToString.js +6 -0
  33. package/lib/cjs/sparql/algebraToString.js.map +1 -1
  34. package/lib/cjs/sparql/irToAlgebra.js +13 -3
  35. package/lib/cjs/sparql/irToAlgebra.js.map +1 -1
  36. package/lib/cjs/utils/NodeReference.d.ts +24 -0
  37. package/lib/cjs/utils/NodeReference.js +41 -1
  38. package/lib/cjs/utils/NodeReference.js.map +1 -1
  39. package/lib/cjs/utils/ShapeClass.js +3 -1
  40. package/lib/cjs/utils/ShapeClass.js.map +1 -1
  41. package/lib/esm/ontologies/shacl.d.ts +5 -0
  42. package/lib/esm/ontologies/shacl.js +10 -0
  43. package/lib/esm/ontologies/shacl.js.map +1 -1
  44. package/lib/esm/paths/PropertyPathExpr.d.ts +38 -0
  45. package/lib/esm/paths/PropertyPathExpr.js +215 -0
  46. package/lib/esm/paths/PropertyPathExpr.js.map +1 -0
  47. package/lib/esm/paths/normalizePropertyPath.d.ts +23 -0
  48. package/lib/esm/paths/normalizePropertyPath.js +71 -0
  49. package/lib/esm/paths/normalizePropertyPath.js.map +1 -0
  50. package/lib/esm/paths/pathExprToSparql.d.ts +14 -0
  51. package/lib/esm/paths/pathExprToSparql.js +132 -0
  52. package/lib/esm/paths/pathExprToSparql.js.map +1 -0
  53. package/lib/esm/paths/serializePathToSHACL.d.ts +22 -0
  54. package/lib/esm/paths/serializePathToSHACL.js +122 -0
  55. package/lib/esm/paths/serializePathToSHACL.js.map +1 -0
  56. package/lib/esm/queries/IRDesugar.d.ts +2 -0
  57. package/lib/esm/queries/IRDesugar.js +24 -8
  58. package/lib/esm/queries/IRDesugar.js.map +1 -1
  59. package/lib/esm/queries/IRLower.js +9 -5
  60. package/lib/esm/queries/IRLower.js.map +1 -1
  61. package/lib/esm/queries/IRProjection.d.ts +2 -1
  62. package/lib/esm/queries/IRProjection.js +7 -3
  63. package/lib/esm/queries/IRProjection.js.map +1 -1
  64. package/lib/esm/queries/IntermediateRepresentation.d.ts +3 -0
  65. package/lib/esm/queries/QueryBuilder.js +3 -2
  66. package/lib/esm/queries/QueryBuilder.js.map +1 -1
  67. package/lib/esm/shapes/SHACL.d.ts +62 -24
  68. package/lib/esm/shapes/SHACL.js +30 -26
  69. package/lib/esm/shapes/SHACL.js.map +1 -1
  70. package/lib/esm/sparql/SparqlAlgebra.d.ts +4 -0
  71. package/lib/esm/sparql/algebraToString.js +6 -0
  72. package/lib/esm/sparql/algebraToString.js.map +1 -1
  73. package/lib/esm/sparql/irToAlgebra.js +13 -3
  74. package/lib/esm/sparql/irToAlgebra.js.map +1 -1
  75. package/lib/esm/utils/NodeReference.d.ts +24 -0
  76. package/lib/esm/utils/NodeReference.js +39 -1
  77. package/lib/esm/utils/NodeReference.js.map +1 -1
  78. package/lib/esm/utils/ShapeClass.js +3 -1
  79. package/lib/esm/utils/ShapeClass.js.map +1 -1
  80. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,43 @@
2
2
 
3
3
  ## 2.2.0
4
4
 
5
+ ### Patch Changes
6
+
7
+ - [#34](https://github.com/Semantu/linked/pull/34) [`e2ae4a2`](https://github.com/Semantu/linked/commit/e2ae4a28e5be28716e1634ca81d9c379a291cbc6) Thanks [@flyon](https://github.com/flyon)! - ### SHACL property path support
8
+
9
+ Property decorators now accept full SPARQL property path syntax:
10
+
11
+ ```ts
12
+ @literalProperty({path: 'foaf:knows/foaf:name'}) // sequence
13
+ @literalProperty({path: '<http://ex.org/a>|<http://ex.org/b>'}) // alternative
14
+ @literalProperty({path: '^foaf:knows'}) // inverse
15
+ @literalProperty({path: 'foaf:knows*'}) // zeroOrMore
16
+ ```
17
+
18
+ New exports from `src/paths/`:
19
+
20
+ - `PathExpr`, `PathRef` — AST types for property paths
21
+ - `parsePropertyPath(input): PathExpr` — parser for SPARQL property path strings
22
+ - `normalizePropertyPath(input): PathExpr` — normalizes any input form to canonical AST
23
+ - `pathExprToSparql(expr): string` — renders PathExpr to SPARQL syntax
24
+ - `serializePathToSHACL(expr): SHACLPathResult` — serializes to SHACL RDF triples
25
+
26
+ `PropertyShape.path` is now typed as `PathExpr` (was opaque). Complex paths flow through the full IR pipeline and emit correct SPARQL property path syntax in generated queries.
27
+
28
+ ### Strict prefix resolution in query API
29
+
30
+ `QueryBuilder.for()` and `.forAll()` now throw on unregistered prefixes instead of silently passing through. New export:
31
+
32
+ - `resolveUriOrThrow(str): string` — strict prefix resolution (throws on unknown prefix)
33
+
34
+ ### SHACL constraint field fixes
35
+
36
+ - `hasValue` and `in` config fields now correctly handle literal values (`string`, `number`, `boolean`) — previously all values were wrapped as IRI nodes
37
+ - `lessThan` and `lessThanOrEquals` config fields are now wired into `createPropertyShape` and exposed via `getResult()`
38
+ - New `PropertyShapeResult` interface provides typed access to `getResult()` output
39
+
40
+ ## 2.1.0
41
+
5
42
  ### Minor Changes
6
43
 
7
44
  - [#31](https://github.com/Semantu/linked/pull/31) [`eb88865`](https://github.com/Semantu/linked/commit/eb8886564f2c9663805c4308a834ca615f9a1dab) Thanks [@flyon](https://github.com/flyon)! - Properties in `select()` and `update()` now support expressions — you can compute values dynamically instead of just reading or writing raw fields.
@@ -51,6 +88,222 @@
51
88
 
52
89
  See the [README](./README.md#computed-expressions) for the full method reference and more examples.
53
90
 
91
+ ## 2.0.1
92
+
93
+ ### Patch Changes
94
+
95
+ - [#27](https://github.com/Semantu/linked/pull/27) [`d3c1e91`](https://github.com/Semantu/linked/commit/d3c1e918b2a63240ddbf3cb550ec43fa1e019c35) Thanks [@flyon](https://github.com/flyon)! - Add MINUS support on QueryBuilder with multiple call styles:
96
+
97
+ - `.minus(Shape)` — exclude by shape type
98
+ - `.minus(p => p.prop.equals(val))` — exclude by condition
99
+ - `.minus(p => p.prop)` — exclude by property existence
100
+ - `.minus(p => [p.prop1, p.nested.prop2])` — exclude by multi-property existence with nested path support
101
+
102
+ Add bulk delete operations:
103
+
104
+ - `Shape.deleteAll()` / `DeleteBuilder.from(Shape).all()` — delete all instances with schema-aware blank node cleanup
105
+ - `Shape.deleteWhere(fn)` / `DeleteBuilder.from(Shape).where(fn)` — conditional delete
106
+
107
+ Add conditional update operations:
108
+
109
+ - `.update(data).where(fn)` — update matching instances
110
+ - `.update(data).forAll()` — update all instances
111
+
112
+ API cleanup:
113
+
114
+ - Deprecate `sortBy()` in favor of `orderBy()`
115
+ - Remove `DeleteBuilder.for()` — use `DeleteBuilder.from(shape, ids)` instead
116
+ - Require `data` parameter in `Shape.update(data)`
117
+
118
+ ## 2.0.0
119
+
120
+ ### Major Changes
121
+
122
+ - [#23](https://github.com/Semantu/linked/pull/23) [`d2d1eca`](https://github.com/Semantu/linked/commit/d2d1eca3517af11f39348dc83ba5e60703ef86d2) Thanks [@flyon](https://github.com/flyon)! - ## Breaking Changes
123
+
124
+ ### `Shape.select()` and `Shape.update()` no longer accept an ID as the first argument
125
+
126
+ Use `.for(id)` to target a specific entity instead.
127
+
128
+ **Select:**
129
+
130
+ ```typescript
131
+ // Before
132
+ const result = await Person.select({ id: "..." }, (p) => p.name);
133
+
134
+ // After
135
+ const result = await Person.select((p) => p.name).for({ id: "..." });
136
+ ```
137
+
138
+ `.for(id)` unwraps the result type from array to single object, matching the old single-subject overload behavior.
139
+
140
+ **Update:**
141
+
142
+ ```typescript
143
+ // Before
144
+ const result = await Person.update({ id: "..." }, { name: "Alice" });
145
+
146
+ // After
147
+ const result = await Person.update({ name: "Alice" }).for({ id: "..." });
148
+ ```
149
+
150
+ `Shape.selectAll(id)` also no longer accepts an id — use `Person.selectAll().for(id)`.
151
+
152
+ ### `ShapeType` renamed to `ShapeConstructor`
153
+
154
+ The type alias for concrete Shape subclass constructors has been renamed. Update any imports or references:
155
+
156
+ ```typescript
157
+ // Before
158
+ import type { ShapeType } from "@_linked/core/shapes/Shape";
159
+
160
+ // After
161
+ import type { ShapeConstructor } from "@_linked/core/shapes/Shape";
162
+ ```
163
+
164
+ ### `QueryString`, `QueryNumber`, `QueryBoolean`, `QueryDate` classes removed
165
+
166
+ These have been consolidated into a single generic `QueryPrimitive<T>` class. If you were using `instanceof` checks against these classes, use `instanceof QueryPrimitive` instead and check the value's type.
167
+
168
+ ### Internal IR types removed
169
+
170
+ The following types and functions have been removed from `SelectQuery`. These were internal pipeline types — if you were using them for custom store integrations, the replacement is `FieldSetEntry[]` (available from `FieldSet`):
171
+
172
+ - Types: `SelectPath`, `QueryPath`, `CustomQueryObject`, `SubQueryPaths`, `ComponentQueryPath`
173
+ - Functions: `fieldSetToSelectPath()`, `entryToQueryPath()`
174
+ - Methods: `QueryBuilder.getQueryPaths()`, `BoundComponent.getComponentQueryPaths()`
175
+ - `RawSelectInput.select` field renamed to `RawSelectInput.entries` (type changed from `SelectPath` to `FieldSetEntry[]`)
176
+
177
+ ### `getPackageShape()` return type is now nullable
178
+
179
+ Returns `ShapeConstructor | undefined` instead of `typeof Shape`. Code that didn't null-check the return value will now get TypeScript errors.
180
+
181
+ ## New Features
182
+
183
+ ### `.for(id)` and `.forAll(ids)` chaining
184
+
185
+ Consistent API for targeting entities across select and update operations:
186
+
187
+ ```typescript
188
+ // Single entity (result is unwrapped, not an array)
189
+ await Person.select((p) => p.name).for({ id: "..." });
190
+ await Person.select((p) => p.name).for("https://...");
191
+
192
+ // Multiple specific entities
193
+ await QueryBuilder.from(Person)
194
+ .select((p) => p.name)
195
+ .forAll([{ id: "..." }, { id: "..." }]);
196
+
197
+ // All instances (default — no .for() needed)
198
+ await Person.select((p) => p.name);
199
+ ```
200
+
201
+ ### Dynamic Query Building with `QueryBuilder` and `FieldSet`
202
+
203
+ Build queries programmatically at runtime — for CMS dashboards, API endpoints, configurable reports. See the [Dynamic Query Building](./README.md#dynamic-query-building) section in the README for full documentation and examples.
204
+
205
+ Key capabilities:
206
+
207
+ - `QueryBuilder.from(Person)` or `QueryBuilder.from('https://schema.org/Person')` — fluent, chainable, immutable query construction
208
+ - `FieldSet.for(Person, ['name', 'knows'])` — composable field selections with `.add()`, `.remove()`, `.pick()`, `FieldSet.merge()`
209
+ - `FieldSet.all(Person, {depth: 2})` — select all decorated properties with optional depth
210
+ - JSON serialization: `query.toJSON()` / `QueryBuilder.fromJSON(json)` and `fieldSet.toJSON()` / `FieldSet.fromJSON(json)`
211
+ - All builders are `PromiseLike` — `await` them directly or call `.build()` to inspect the IR
212
+
213
+ ### Mutation Builders
214
+
215
+ `CreateBuilder`, `UpdateBuilder`, and `DeleteBuilder` provide the programmatic equivalent of `Person.create()`, `Person.update()`, and `Person.delete()`, accepting Shape classes or shape IRI strings. See the [Mutation Builders](./README.md#mutation-builders) section in the README.
216
+
217
+ ### `PropertyPath` exported
218
+
219
+ The `PropertyPath` value object is now a public export — a type-safe representation of a sequence of property traversals through a shape graph.
220
+
221
+ ```typescript
222
+ import { PropertyPath, walkPropertyPath } from "@_linked/core";
223
+ ```
224
+
225
+ ### `ShapeConstructor<S>` type
226
+
227
+ New concrete constructor type for Shape subclasses. Eliminates ~30 `as any` casts across the codebase and provides better type safety at runtime boundaries (builder `.from()` methods, Shape static methods).
228
+
229
+ ## 1.3.0
230
+
231
+ ### Minor Changes
232
+
233
+ - [#20](https://github.com/Semantu/linked/pull/20) [`33e9fb0`](https://github.com/Semantu/linked/commit/33e9fb0205343eca8c84723cbabc3f3342e40be5) Thanks [@flyon](https://github.com/flyon)! - **Breaking:** `QueryParser` has been removed. If you imported `QueryParser` directly, replace with `getQueryDispatch()` from `@_linked/core/queries/queryDispatch`. The Shape DSL (`Shape.select()`, `.create()`, `.update()`, `.delete()`) and `SelectQuery.exec()` are unchanged.
234
+
235
+ **New:** `getQueryDispatch()` and `setQueryDispatch()` are now exported, allowing custom query dispatch implementations (e.g. for testing or alternative storage backends) without subclassing `LinkedStorage`.
236
+
237
+ ## 1.2.1
238
+
239
+ ### Patch Changes
240
+
241
+ - [#17](https://github.com/Semantu/linked/pull/17) [`0654780`](https://github.com/Semantu/linked/commit/06547807a7bae56e992eba73263f83e092b7788b) Thanks [@flyon](https://github.com/flyon)! - Preserve nested array sub-select branches in canonical IR so `build()` emits complete traversals, projection fields, and `resultMap` entries for nested selections.
242
+
243
+ This fixes cases where nested branches present in `toRawInput().select` were dropped during desugar/lowering (for example nested `friends.select([name, hobby])` branches under another sub-select).
244
+
245
+ Also adds regression coverage for desugar preservation, IR lowering completeness, and updated SPARQL golden output for nested query fixtures.
246
+
247
+ ## 1.2.0
248
+
249
+ ### Minor Changes
250
+
251
+ - [#9](https://github.com/Semantu/linked/pull/9) [`381067b`](https://github.com/Semantu/linked/commit/381067b0fbc25f4a0446c5f8cc0eec57ddded466) Thanks [@flyon](https://github.com/flyon)! - Replaced internal query representation with a canonical backend-agnostic IR AST. `SelectQuery`, `CreateQuery`, `UpdateQuery`, and `DeleteQuery` are now typed IR objects with `kind` discriminators, compact shape/property ID references, and expression trees — replacing the previous ad-hoc nested arrays. The public Shape DSL is unchanged; what changed is what `IQuadStore` implementations receive. Store result types (`ResultRow`, `SelectResult`, `CreateResult`, `UpdateResult`) are now exported. All factories expose `build()` as the primary method. See `documentation/intermediate-representation.md` for the full IR reference and migration guidance.
252
+
253
+ - [#14](https://github.com/Semantu/linked/pull/14) [`b65e156`](https://github.com/Semantu/linked/commit/b65e15688ac173478e58e1dbb9f26dbaf5fc5a37) Thanks [@flyon](https://github.com/flyon)! - Add SPARQL conversion layer — compiles Linked IR queries into executable SPARQL and maps results back to typed DSL objects.
254
+
255
+ **New exports from `@_linked/core/sparql`:**
256
+
257
+ - **`SparqlStore`** — abstract base class for SPARQL-backed stores. Extend it and implement two methods to connect any SPARQL 1.1 endpoint:
258
+
259
+ ```ts
260
+ import { SparqlStore } from "@_linked/core/sparql";
261
+
262
+ class MyStore extends SparqlStore {
263
+ protected async executeSparqlSelect(
264
+ sparql: string
265
+ ): Promise<SparqlJsonResults> {
266
+ /* ... */
267
+ }
268
+ protected async executeSparqlUpdate(sparql: string): Promise<void> {
269
+ /* ... */
270
+ }
271
+ }
272
+ ```
273
+
274
+ - **IR → SPARQL string** convenience functions (full pipeline in one call):
275
+
276
+ - `selectToSparql(query, options?)` — SelectQuery → SPARQL string
277
+ - `createToSparql(query, options?)` — CreateQuery → SPARQL string
278
+ - `updateToSparql(query, options?)` — UpdateQuery → SPARQL string
279
+ - `deleteToSparql(query, options?)` — DeleteQuery → SPARQL string
280
+
281
+ - **IR → SPARQL algebra** (for stores that want to inspect/optimize the algebra before serialization):
282
+
283
+ - `selectToAlgebra(query, options?)` — returns `SparqlSelectPlan`
284
+ - `createToAlgebra(query, options?)` — returns `SparqlInsertDataPlan`
285
+ - `updateToAlgebra(query, options?)` — returns `SparqlDeleteInsertPlan`
286
+ - `deleteToAlgebra(query, options?)` — returns `SparqlDeleteInsertPlan`
287
+
288
+ - **Algebra → SPARQL string** serialization:
289
+
290
+ - `selectPlanToSparql(plan, options?)`, `insertDataPlanToSparql(plan, options?)`, `deleteInsertPlanToSparql(plan, options?)`, `deleteWherePlanToSparql(plan, options?)`
291
+ - `serializeAlgebraNode(node)`, `serializeExpression(expr)`, `serializeTerm(term)`
292
+
293
+ - **Result mapping** (SPARQL JSON results → typed DSL objects):
294
+
295
+ - `mapSparqlSelectResult(json, query)` — handles flat/nested/aggregated results with XSD type coercion
296
+ - `mapSparqlCreateResult(uri, query)` — echoes created fields with generated URI
297
+ - `mapSparqlUpdateResult(query)` — echoes updated fields
298
+
299
+ - **All algebra types** re-exported: `SparqlTerm`, `SparqlTriple`, `SparqlAlgebraNode`, `SparqlExpression`, `SparqlSelectPlan`, `SparqlInsertDataPlan`, `SparqlDeleteInsertPlan`, `SparqlDeleteWherePlan`, `SparqlPlan`, `SparqlOptions`, etc.
300
+
301
+ **Bug fixes included:**
302
+
303
+ - Fixed `isNodeReference()` in MutationQuery.ts — nested creates with predefined IDs (e.g., `{id: '...', name: 'Bestie'}`) now correctly insert entity data instead of only creating the link.
304
+
305
+ See [SPARQL Algebra Layer docs](./documentation/sparql-algebra.md) for the full type reference, conversion rules, and store implementation guide.
306
+
54
307
  ## 1.1.0
55
308
 
56
309
  ### Minor Changes
@@ -88,4 +88,9 @@ export declare const shacl: {
88
88
  MaxLengthConstraintComponent: NodeReferenceValue;
89
89
  AbstractResult: NodeReferenceValue;
90
90
  result: NodeReferenceValue;
91
+ alternativePath: NodeReferenceValue;
92
+ inversePath: NodeReferenceValue;
93
+ zeroOrMorePath: NodeReferenceValue;
94
+ oneOrMorePath: NodeReferenceValue;
95
+ zeroOrOnePath: NodeReferenceValue;
91
96
  };
@@ -30,6 +30,11 @@ const targetNode = (0, exports.ns)('targetNode');
30
30
  const node = (0, exports.ns)('node');
31
31
  const nodeKind = (0, exports.ns)('nodeKind');
32
32
  const Shape = (0, exports.ns)('Shape');
33
+ const alternativePath = (0, exports.ns)('alternativePath');
34
+ const inversePath = (0, exports.ns)('inversePath');
35
+ const zeroOrMorePath = (0, exports.ns)('zeroOrMorePath');
36
+ const oneOrMorePath = (0, exports.ns)('oneOrMorePath');
37
+ const zeroOrOnePath = (0, exports.ns)('zeroOrOnePath');
33
38
  const BlankNode = (0, exports.ns)('BlankNode');
34
39
  const IRI = (0, exports.ns)('IRI');
35
40
  const Literal = (0, exports.ns)('Literal');
@@ -124,5 +129,10 @@ exports.shacl = {
124
129
  MaxLengthConstraintComponent: exports.MaxLengthConstraintComponent,
125
130
  AbstractResult: exports.AbstractResult,
126
131
  result: exports.result,
132
+ alternativePath,
133
+ inversePath,
134
+ zeroOrMorePath,
135
+ oneOrMorePath,
136
+ zeroOrOnePath,
127
137
  };
128
138
  //# sourceMappingURL=shacl.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"shacl.js","sourceRoot":"","sources":["../../../src/ontologies/shacl.ts"],"names":[],"mappings":";;;AAMA,kDAA0C;AAC1C,wDAAsD;AAEtD,MAAM,IAAI,GAAG,6BAA6B,CAAC;AAC9B,QAAA,iBAAiB,GAAuB,EAAC,EAAE,EAAE,IAAI,EAAC,CAAC;AAChE,kBAAM,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;AAEb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O;IACP,SAAS,EAAT,iBAAS;IACT,yBAAyB,EAAzB,iCAAyB;IACzB,wBAAwB,EAAxB,gCAAwB;IACxB,uBAAuB,EAAvB,+BAAuB;IACvB,2BAA2B,EAA3B,mCAA2B;IAC3B,4BAA4B,EAA5B,oCAA4B;IAC5B,4BAA4B,EAA5B,oCAA4B;IAC5B,cAAc,EAAd,sBAAc;IACd,MAAM,EAAN,cAAM;IACN,eAAe;IACf,WAAW;IACX,cAAc;IACd,aAAa;IACb,aAAa;CACd,CAAC"}
@@ -0,0 +1,38 @@
1
+ /** A simple path reference — either a raw string (prefixed/IRI) or a node ref. */
2
+ export type PathRef = string | {
3
+ id: string;
4
+ };
5
+ /** Discriminated-object union for all SPARQL property path forms. */
6
+ export type PathExpr = PathRef | {
7
+ seq: PathExpr[];
8
+ } | {
9
+ alt: PathExpr[];
10
+ } | {
11
+ inv: PathExpr;
12
+ } | {
13
+ zeroOrMore: PathExpr;
14
+ } | {
15
+ oneOrMore: PathExpr;
16
+ } | {
17
+ zeroOrOne: PathExpr;
18
+ } | {
19
+ negatedPropertySet: (PathRef | {
20
+ inv: PathRef;
21
+ })[];
22
+ };
23
+ export declare const isPathRef: (expr: PathExpr) => expr is PathRef;
24
+ export declare const isComplexPathExpr: (expr: PathExpr) => boolean;
25
+ /**
26
+ * Characters that signal a string contains path operators and should be parsed.
27
+ * Used by the normalizer to decide whether to invoke the parser.
28
+ */
29
+ export declare const PATH_OPERATOR_CHARS: RegExp;
30
+ /**
31
+ * Parse a SPARQL property path string into a PathExpr AST.
32
+ *
33
+ * Supports: sequence (/), alternative (|), inverse (^), zeroOrMore (*),
34
+ * oneOrMore (+), zeroOrOne (?), negatedPropertySet (!), and grouping (()).
35
+ *
36
+ * Does NOT resolve prefixes — raw strings are preserved in the AST.
37
+ */
38
+ export declare function parsePropertyPath(input: string): PathExpr;
@@ -0,0 +1,221 @@
1
+ "use strict";
2
+ /*
3
+ * This Source Code Form is subject to the terms of the Mozilla Public
4
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
5
+ * file, You can obtain one at https://mozilla.org/MPL/2.0/.
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.PATH_OPERATOR_CHARS = exports.isComplexPathExpr = exports.isPathRef = void 0;
9
+ exports.parsePropertyPath = parsePropertyPath;
10
+ // ---------------------------------------------------------------------------
11
+ // Type guards
12
+ // ---------------------------------------------------------------------------
13
+ const isPathRef = (expr) => typeof expr === 'string' || (typeof expr === 'object' && expr !== null && 'id' in expr && Object.keys(expr).length === 1);
14
+ exports.isPathRef = isPathRef;
15
+ const isComplexPathExpr = (expr) => !(0, exports.isPathRef)(expr);
16
+ exports.isComplexPathExpr = isComplexPathExpr;
17
+ // ---------------------------------------------------------------------------
18
+ // Parser — recursive-descent for SPARQL property path grammar
19
+ // ---------------------------------------------------------------------------
20
+ /**
21
+ * Characters that signal a string contains path operators and should be parsed.
22
+ * Used by the normalizer to decide whether to invoke the parser.
23
+ */
24
+ exports.PATH_OPERATOR_CHARS = /[/|^*+?()!<]/;
25
+ class PathParser {
26
+ constructor(input) {
27
+ this.pos = 0;
28
+ this.input = input;
29
+ }
30
+ parse() {
31
+ this.skipWhitespace();
32
+ const result = this.parseAlt();
33
+ this.skipWhitespace();
34
+ if (this.pos < this.input.length) {
35
+ this.error(`Unexpected character '${this.input[this.pos]}'`);
36
+ }
37
+ return result;
38
+ }
39
+ // alt = seq ( '|' seq )*
40
+ parseAlt() {
41
+ const first = this.parseSeq();
42
+ const branches = [first];
43
+ while (this.peek() === '|') {
44
+ this.advance(); // consume '|'
45
+ this.skipWhitespace();
46
+ branches.push(this.parseSeq());
47
+ }
48
+ return branches.length === 1 ? branches[0] : { alt: branches };
49
+ }
50
+ // seq = unary ( '/' unary )*
51
+ parseSeq() {
52
+ const first = this.parseUnary();
53
+ const steps = [first];
54
+ while (this.peek() === '/') {
55
+ this.advance(); // consume '/'
56
+ this.skipWhitespace();
57
+ steps.push(this.parseUnary());
58
+ }
59
+ return steps.length === 1 ? steps[0] : { seq: steps };
60
+ }
61
+ // unary = '^' unary | primary ( '*' | '+' | '?' )?
62
+ parseUnary() {
63
+ this.skipWhitespace();
64
+ if (this.peek() === '^') {
65
+ this.advance(); // consume '^'
66
+ this.skipWhitespace();
67
+ const inner = this.parseUnary();
68
+ return { inv: inner };
69
+ }
70
+ let expr = this.parsePrimary();
71
+ this.skipWhitespace();
72
+ const postfix = this.peek();
73
+ if (postfix === '*') {
74
+ this.advance();
75
+ expr = { zeroOrMore: expr };
76
+ }
77
+ else if (postfix === '+') {
78
+ this.advance();
79
+ expr = { oneOrMore: expr };
80
+ }
81
+ else if (postfix === '?') {
82
+ this.advance();
83
+ expr = { zeroOrOne: expr };
84
+ }
85
+ this.skipWhitespace();
86
+ return expr;
87
+ }
88
+ // primary = '(' alt ')' | '!' negatedPropertySet | iri
89
+ parsePrimary() {
90
+ this.skipWhitespace();
91
+ const ch = this.peek();
92
+ // Grouped expression
93
+ if (ch === '(') {
94
+ this.advance(); // consume '('
95
+ this.skipWhitespace();
96
+ const inner = this.parseAlt();
97
+ this.skipWhitespace();
98
+ if (this.peek() !== ')') {
99
+ this.error("Expected ')'");
100
+ }
101
+ this.advance(); // consume ')'
102
+ return inner;
103
+ }
104
+ // Negated property set
105
+ if (ch === '!') {
106
+ this.advance(); // consume '!'
107
+ this.skipWhitespace();
108
+ return this.parseNegatedPropertySet();
109
+ }
110
+ // IRI or prefixed name
111
+ return this.parseIri();
112
+ }
113
+ // negatedPropertySet = '(' negatedItem ( '|' negatedItem )* ')' | negatedItem
114
+ parseNegatedPropertySet() {
115
+ this.skipWhitespace();
116
+ if (this.peek() === '(') {
117
+ this.advance(); // consume '('
118
+ this.skipWhitespace();
119
+ const items = this.parseNegatedItems();
120
+ this.skipWhitespace();
121
+ if (this.peek() !== ')') {
122
+ this.error("Expected ')' in negated property set");
123
+ }
124
+ this.advance(); // consume ')'
125
+ return { negatedPropertySet: items };
126
+ }
127
+ // Single negated item
128
+ const item = this.parseNegatedItem();
129
+ return { negatedPropertySet: [item] };
130
+ }
131
+ parseNegatedItems() {
132
+ const items = [this.parseNegatedItem()];
133
+ while (this.peek() === '|') {
134
+ this.advance(); // consume '|'
135
+ this.skipWhitespace();
136
+ items.push(this.parseNegatedItem());
137
+ }
138
+ return items;
139
+ }
140
+ parseNegatedItem() {
141
+ this.skipWhitespace();
142
+ if (this.peek() === '^') {
143
+ this.advance(); // consume '^'
144
+ this.skipWhitespace();
145
+ const ref = this.parseIri();
146
+ return { inv: ref };
147
+ }
148
+ return this.parseIri();
149
+ }
150
+ // iri = '<' chars '>' | prefixedName
151
+ parseIri() {
152
+ this.skipWhitespace();
153
+ if (this.peek() === '<') {
154
+ this.advance(); // consume '<'
155
+ const start = this.pos;
156
+ while (this.pos < this.input.length && this.input[this.pos] !== '>') {
157
+ this.pos++;
158
+ }
159
+ if (this.pos >= this.input.length) {
160
+ this.error("Expected '>' to close IRI");
161
+ }
162
+ const iri = this.input.slice(start, this.pos);
163
+ this.advance(); // consume '>'
164
+ return iri;
165
+ }
166
+ return this.parsePrefixedName();
167
+ }
168
+ // prefixedName = PNAME_NS PNAME_LOCAL | PNAME_NS
169
+ // We accept any characters until we hit a path operator or whitespace or end
170
+ parsePrefixedName() {
171
+ this.skipWhitespace();
172
+ const start = this.pos;
173
+ while (this.pos < this.input.length && !this.isTerminator(this.input[this.pos])) {
174
+ this.pos++;
175
+ }
176
+ if (this.pos === start) {
177
+ this.error('Expected IRI or prefixed name');
178
+ }
179
+ return this.input.slice(start, this.pos);
180
+ }
181
+ isTerminator(ch) {
182
+ return ch === '/' || ch === '|' || ch === '*' || ch === '+' || ch === '?' ||
183
+ ch === '(' || ch === ')' || ch === '^' || ch === '!' || ch === ' ' ||
184
+ ch === '\t' || ch === '\n' || ch === '\r';
185
+ }
186
+ peek() {
187
+ return this.pos < this.input.length ? this.input[this.pos] : undefined;
188
+ }
189
+ advance() {
190
+ this.pos++;
191
+ }
192
+ skipWhitespace() {
193
+ while (this.pos < this.input.length) {
194
+ const ch = this.input[this.pos];
195
+ if (ch === ' ' || ch === '\t' || ch === '\n' || ch === '\r') {
196
+ this.pos++;
197
+ }
198
+ else {
199
+ break;
200
+ }
201
+ }
202
+ }
203
+ error(message) {
204
+ throw new Error(`Property path parse error at position ${this.pos}: ${message} (input: "${this.input}")`);
205
+ }
206
+ }
207
+ /**
208
+ * Parse a SPARQL property path string into a PathExpr AST.
209
+ *
210
+ * Supports: sequence (/), alternative (|), inverse (^), zeroOrMore (*),
211
+ * oneOrMore (+), zeroOrOne (?), negatedPropertySet (!), and grouping (()).
212
+ *
213
+ * Does NOT resolve prefixes — raw strings are preserved in the AST.
214
+ */
215
+ function parsePropertyPath(input) {
216
+ if (!input || input.trim().length === 0) {
217
+ throw new Error('Property path input must not be empty');
218
+ }
219
+ return new PathParser(input.trim()).parse();
220
+ }
221
+ //# sourceMappingURL=PropertyPathExpr.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PropertyPathExpr.js","sourceRoot":"","sources":["../../../src/paths/PropertyPathExpr.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAyPH,8CAKC;AA1OD,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAEvE,MAAM,SAAS,GAAG,CAAC,IAAc,EAAmB,EAAE,CAC3D,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,IAAI,IAAI,IAAI,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC;AAD/G,QAAA,SAAS,aACsG;AAErH,MAAM,iBAAiB,GAAG,CAAC,IAAc,EAAW,EAAE,CAAC,CAAC,IAAA,iBAAS,EAAC,IAAI,CAAC,CAAC;AAAlE,QAAA,iBAAiB,qBAAiD;AAE/E,8EAA8E;AAC9E,8DAA8D;AAC9D,8EAA8E;AAE9E;;;GAGG;AACU,QAAA,mBAAmB,GAAG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AAC,CAAC;IAC3D,CAAC;IACD,OAAO,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;AAC9C,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { PathExpr } from './PropertyPathExpr.js';
2
+ /**
3
+ * Input type for property path decorators.
4
+ * Accepts all forms: string, {id}, array (sequence shorthand), or PathExpr.
5
+ */
6
+ export type PropertyPathDecoratorInput = string | {
7
+ id: string;
8
+ } | PropertyPathDecoratorInput[] | PathExpr;
9
+ /**
10
+ * Normalize any property path decorator input into a canonical PathExpr.
11
+ *
12
+ * - `string` without path operators → preserved as-is (a PathRef)
13
+ * - `string` with operators → parsed via `parsePropertyPath`
14
+ * - `{id: string}` → preserved as PathRef
15
+ * - `PathExpr` structured object → passed through
16
+ * - `Array` → converted to `{seq: [...]}`
17
+ */
18
+ export declare function normalizePropertyPath(input: PropertyPathDecoratorInput): PathExpr;
19
+ /**
20
+ * Check whether a PathExpr is a simple single-IRI path (backward-compatible form).
21
+ * Returns the IRI string if simple, or null if complex.
22
+ */
23
+ export declare function getSimplePathId(expr: PathExpr): string | null;