rdfjs-resource 3.0.6 → 3.0.7

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.
@@ -5,7 +5,7 @@ export class MissingValueError extends ValueError {
5
5
  constructor({ focusResource, propertyPath, }) {
6
6
  super({
7
7
  focusResource,
8
- message: `${Identifier.toString(focusResource.identifier)} missing ${PropertyPath.$toString(propertyPath)}`,
8
+ message: `${Identifier.toString(focusResource.identifier)} missing ${PropertyPath.toString(propertyPath)}`,
9
9
  propertyPath,
10
10
  });
11
11
  }
@@ -7,7 +7,7 @@ export class MistypedPrimitiveValueError extends MistypedValueError {
7
7
  actualValue,
8
8
  expectedValueType,
9
9
  focusResource,
10
- message: `expected ${Identifier.toString(focusResource.identifier)} ${PropertyPath.$toString(propertyPath)} to be a ${expectedValueType}, was ${typeof actualValue}`,
10
+ message: `expected ${Identifier.toString(focusResource.identifier)} ${PropertyPath.toString(propertyPath)} to be a ${expectedValueType}, was ${typeof actualValue}`,
11
11
  propertyPath,
12
12
  });
13
13
  }
@@ -7,7 +7,7 @@ export class MistypedTermValueError extends MistypedValueError {
7
7
  actualValue,
8
8
  expectedValueType,
9
9
  focusResource,
10
- message: `expected ${Identifier.toString(focusResource.identifier)} ${PropertyPath.$toString(propertyPath)} to be a ${expectedValueType}, was ${actualValue.termType}`,
10
+ message: `expected ${Identifier.toString(focusResource.identifier)} ${PropertyPath.toString(propertyPath)} to be a ${expectedValueType}, was ${actualValue.termType}`,
11
11
  propertyPath,
12
12
  });
13
13
  }
@@ -33,18 +33,14 @@ interface ZeroOrOnePath {
33
33
  export type PropertyPath = AlternativePath | InversePath | OneOrMorePath | PredicatePath | SequencePath | ZeroOrMorePath | ZeroOrOnePath;
34
34
  export declare namespace PropertyPath {
35
35
  function equals(left: PropertyPath, right: PropertyPath): boolean;
36
- function $fromRdf(resource: Resource, options?: {
37
- [index: string]: unknown;
36
+ function fromResource(resource: Resource, options?: {
38
37
  graph?: Exclude<Quad_Graph, Variable>;
39
38
  }): Either<Error, PropertyPath>;
40
- type $Filter = object;
41
- function $filter(_filter: $Filter, _value: PropertyPath): boolean;
42
- const $schema: Readonly<object>;
43
- function $toString(propertyPath: PropertyPath): string;
44
- function $toRdf(propertyPath: PropertyPath, options?: {
39
+ function toResource(propertyPath: PropertyPath, options?: {
45
40
  graph?: Exclude<Quad_Graph, Variable>;
46
41
  resourceSet?: ResourceSet;
47
42
  }): Resource;
43
+ function toString(propertyPath: PropertyPath): string;
48
44
  }
49
45
  export {};
50
46
  //# sourceMappingURL=PropertyPath.d.ts.map
@@ -34,7 +34,7 @@ export var PropertyPath;
34
34
  }
35
35
  }
36
36
  PropertyPath.equals = equals;
37
- function $fromRdf(resource, options) {
37
+ function fromResource(resource, options) {
38
38
  // Predicate path
39
39
  // sh:path ex:parent
40
40
  if (resource.identifier.termType === "NamedNode") {
@@ -49,7 +49,7 @@ export var PropertyPath;
49
49
  if (resource.isNothing()) {
50
50
  return Left(new Error("non-identifier in property path list"));
51
51
  }
52
- const member = PropertyPath.$fromRdf(resource.unsafeCoerce());
52
+ const member = PropertyPath.fromResource(resource.unsafeCoerce(), options);
53
53
  if (member.isLeft()) {
54
54
  return member;
55
55
  }
@@ -89,27 +89,27 @@ export var PropertyPath;
89
89
  // Inverse path
90
90
  // sh:path: [ sh:inversePath ex:parent ]
91
91
  if (quad.predicate.equals(sh.inversePath)) {
92
- return PropertyPath.$fromRdf(objectResource).map((path) => ({
92
+ return PropertyPath.fromResource(objectResource, options).map((path) => ({
93
93
  termType: "InversePath",
94
94
  path,
95
95
  }));
96
96
  }
97
97
  // One or more path
98
98
  if (quad.predicate.equals(sh.oneOrMorePath)) {
99
- return PropertyPath.$fromRdf(objectResource).map((path) => ({
99
+ return PropertyPath.fromResource(objectResource, options).map((path) => ({
100
100
  termType: "OneOrMorePath",
101
101
  path,
102
102
  }));
103
103
  }
104
104
  // Zero or more path
105
105
  if (quad.predicate.equals(sh.zeroOrMorePath)) {
106
- return PropertyPath.$fromRdf(objectResource).map((path) => ({
106
+ return PropertyPath.fromResource(objectResource).map((path) => ({
107
107
  termType: "ZeroOrMorePath",
108
108
  path,
109
109
  }));
110
110
  }
111
111
  if (quad.predicate.equals(sh.zeroOrOnePath)) {
112
- return PropertyPath.$fromRdf(objectResource).map((path) => ({
112
+ return PropertyPath.fromResource(objectResource).map((path) => ({
113
113
  termType: "ZeroOrOnePath",
114
114
  path,
115
115
  }));
@@ -117,28 +117,8 @@ export var PropertyPath;
117
117
  }
118
118
  return Left(new Error(`unrecognized or ill-formed SHACL property path ${Resource.Identifier.toString(resource.identifier)}`));
119
119
  }
120
- PropertyPath.$fromRdf = $fromRdf;
121
- function $filter(_filter, _value) {
122
- return true;
123
- }
124
- PropertyPath.$filter = $filter;
125
- PropertyPath.$schema = {};
126
- function $toString(propertyPath) {
127
- switch (propertyPath.termType) {
128
- case "AlternativePath":
129
- case "SequencePath":
130
- return `${propertyPath.termType}([${propertyPath.members.map(PropertyPath.toString).join(", ")}])`;
131
- case "InversePath":
132
- case "OneOrMorePath":
133
- case "ZeroOrMorePath":
134
- case "ZeroOrOnePath":
135
- return `${propertyPath.termType}(${PropertyPath.$toString(propertyPath.path)})`;
136
- case "NamedNode":
137
- return `PredicatePath(${propertyPath.value})`;
138
- }
139
- }
140
- PropertyPath.$toString = $toString;
141
- function $toRdf(propertyPath, options) {
120
+ PropertyPath.fromResource = fromResource;
121
+ function toResource(propertyPath, options) {
142
122
  const graph = options?.graph;
143
123
  const resourceSet = options?.resourceSet ??
144
124
  new ResourceSet(datasetFactory.dataset(), { dataFactory: dataFactory });
@@ -149,7 +129,7 @@ export var PropertyPath;
149
129
  switch (propertyPath.termType) {
150
130
  case "AlternativePath":
151
131
  case "SequencePath": {
152
- const members = propertyPath.members.map((member) => PropertyPath.$toRdf(member, { graph, resourceSet }).identifier);
132
+ const members = propertyPath.members.map((member) => PropertyPath.toResource(member, { graph, resourceSet }).identifier);
153
133
  if (propertyPath.termType === "AlternativePath") {
154
134
  resource.addList(sh.alternativePath, members, { graph });
155
135
  }
@@ -174,9 +154,26 @@ export var PropertyPath;
174
154
  predicate = sh.zeroOrOnePath;
175
155
  break;
176
156
  }
177
- resource.add(predicate, PropertyPath.$toRdf(propertyPath.path, { graph, resourceSet }).identifier, graph);
157
+ resource.add(predicate, PropertyPath.toResource(propertyPath.path, { graph, resourceSet })
158
+ .identifier, graph);
178
159
  return resource;
179
160
  }
180
- PropertyPath.$toRdf = $toRdf;
161
+ PropertyPath.toResource = toResource;
162
+ // biome-ignore lint/suspicious/noShadowRestrictedNames: intentional
163
+ function toString(propertyPath) {
164
+ switch (propertyPath.termType) {
165
+ case "AlternativePath":
166
+ case "SequencePath":
167
+ return `${propertyPath.termType}([${propertyPath.members.map(PropertyPath.toString).join(", ")}])`;
168
+ case "InversePath":
169
+ case "OneOrMorePath":
170
+ case "ZeroOrMorePath":
171
+ case "ZeroOrOnePath":
172
+ return `${propertyPath.termType}(${PropertyPath.toString(propertyPath.path)})`;
173
+ case "NamedNode":
174
+ return `PredicatePath(${propertyPath.value})`;
175
+ }
176
+ }
177
+ PropertyPath.toString = toString;
181
178
  })(PropertyPath || (PropertyPath = {}));
182
179
  //# sourceMappingURL=PropertyPath.js.map
package/package.json CHANGED
@@ -47,5 +47,5 @@
47
47
  },
48
48
  "type": "module",
49
49
  "types": "dist/index.d.ts",
50
- "version": "3.0.6"
50
+ "version": "3.0.7"
51
51
  }