@shaclmate/compiler 4.0.53 → 4.0.55

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.
@@ -6,7 +6,7 @@ import type * as ast from "./ast/index.js";
6
6
  import type * as input from "./input/index.js";
7
7
  export declare class ShapesGraphToAstTransformer {
8
8
  protected readonly cachedAstTypesByShapeIdentifier: TermMap<BlankNode | NamedNode, ast.Type>;
9
- protected readonly syntheticAstStructTypesByName: Map<string, ast.StructType>;
9
+ protected readonly syntheticAstStructTypes: ast.StructType[];
10
10
  protected readonly logger: Logger;
11
11
  protected readonly shapesGraph: input.ShapesGraph;
12
12
  constructor({ logger, shapesGraph, }: {
@@ -5,7 +5,7 @@ import { transformShapeToAstType } from "./_ShapesGraphToAstTransformer/transfor
5
5
  export class ShapesGraphToAstTransformer {
6
6
  // Members are protected so they're accessible to functions in other files
7
7
  cachedAstTypesByShapeIdentifier = new TermMap();
8
- syntheticAstStructTypesByName = new Map();
8
+ syntheticAstStructTypes = [];
9
9
  logger;
10
10
  shapesGraph;
11
11
  constructor({ logger, shapesGraph, }) {
@@ -41,9 +41,7 @@ export class ShapesGraphToAstTransformer {
41
41
  return acc;
42
42
  }
43
43
  }, 0),
44
- namedTypes: astNamedTypes.concat([
45
- ...this.syntheticAstStructTypesByName.values(),
46
- ]),
44
+ namedTypes: astNamedTypes.concat(this.syntheticAstStructTypes),
47
45
  });
48
46
  }
49
47
  }
@@ -1,5 +1,5 @@
1
1
  import { NodeKind } from "@shaclmate/shacl-ast";
2
- import { Either, Left } from "purify-ts";
2
+ import { Either, Left, Maybe } from "purify-ts";
3
3
  import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
4
4
  const defaultPropertyShapeNodeKinds = new Set([
5
5
  "BlankNode",
@@ -90,6 +90,28 @@ export function shapeNodeKinds(shape, options) {
90
90
  .orDefault([]),
91
91
  },
92
92
  ],
93
+ [
94
+ "sh:node",
95
+ {
96
+ includeNodeKinds: shape.node
97
+ .chain((node) => this.shapesGraph.nodeShape(node).toMaybe())
98
+ .chain((nodeShape) => shapeNodeKinds.call(this, nodeShape).toMaybe())
99
+ .map((nodeKinds) => [...nodeKinds])
100
+ .orDefault([]),
101
+ },
102
+ ],
103
+ [
104
+ "shaclmate:resolve",
105
+ {
106
+ includeNodeKinds: (shape.$type === "PropertyShape"
107
+ ? shape.resolve
108
+ : Maybe.empty())
109
+ .chain((resolve) => this.shapesGraph.nodeShape(resolve).toMaybe())
110
+ .chain((nodeShape) => shapeNodeKinds.call(this, nodeShape).toMaybe())
111
+ .map((nodeKinds) => [...nodeKinds])
112
+ .orDefault([]),
113
+ },
114
+ ],
93
115
  ]) {
94
116
  for (const excludeNodeKind of excludeNodeKinds ?? []) {
95
117
  if (explicitNodeKinds.size > 0 &&
@@ -60,7 +60,8 @@ function synthesizePartialAstStructType({ identifierType, }) {
60
60
  syntheticName = "NamedDefaultPartial";
61
61
  break;
62
62
  }
63
- let partialAstStructType = this.syntheticAstStructTypesByName.get(syntheticName);
63
+ let partialAstStructType = this.syntheticAstStructTypes.find((syntheticAstStructType) => syntheticAstStructType.name.extract() === syntheticName &&
64
+ ast.Type.equals(syntheticAstStructType.identifierType, identifierType));
64
65
  if (partialAstStructType) {
65
66
  return partialAstStructType;
66
67
  }
@@ -76,7 +77,7 @@ function synthesizePartialAstStructType({ identifierType, }) {
76
77
  toRdfTypes: [],
77
78
  tsImports: [],
78
79
  });
79
- this.syntheticAstStructTypesByName.set(syntheticName, partialAstStructType);
80
+ this.syntheticAstStructTypes.push(partialAstStructType);
80
81
  return partialAstStructType;
81
82
  }
82
83
  function transformPropertyShapeToAstType(propertyShape, shapeStack) {
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/shacl-ast": "4.0.53",
3
+ "@shaclmate/shacl-ast": "4.0.55",
4
4
  "@rdfjs/dataset": "~2.0.2",
5
5
  "@rdfjs/prefix-map": "~0.1.2",
6
6
  "@rdfjs/term-map": "~2.0.2",
7
7
  "@rdfjs/term-set": "~2.0.3",
8
8
  "@rdfjs/types": "~2.0.1",
9
- "@rdfx/data-factory": "0.0.24",
10
- "@rdfx/literal": "0.0.24",
11
- "@rdfx/resource": "0.0.24",
12
- "@rdfx/string": "0.0.24",
9
+ "@rdfx/data-factory": "0.0.25",
10
+ "@rdfx/literal": "0.0.25",
11
+ "@rdfx/resource": "0.0.25",
12
+ "@rdfx/string": "0.0.25",
13
13
  "@sindresorhus/base62": "~0.1.0",
14
14
  "@tpluscode/rdf-ns-builders": "~4.3.0",
15
15
  "@types/rdfjs__dataset": "~2.0.7",
@@ -660,5 +660,5 @@
660
660
  },
661
661
  "type": "module",
662
662
  "types": "./dist/index.d.ts",
663
- "version": "4.0.53"
663
+ "version": "4.0.55"
664
664
  }