@shaclmate/shacl-ast 4.0.22 → 4.0.23

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.
@@ -1,5 +1,5 @@
1
1
  import type { BlankNode, DatasetCore, Literal, NamedNode, Quad_Graph, Variable } from "@rdfjs/types";
2
- import { PropertyPath as RdfjsResourcePropertyPath, Resource, ResourceSet } from "@rdfx/resource";
2
+ import { PropertyPath as RdfxResourcePropertyPath, Resource, ResourceSet } from "@rdfx/resource";
3
3
  import { NTriplesTerm } from "@rdfx/string";
4
4
  import { Either, Maybe } from "purify-ts";
5
5
  interface $BooleanFilter {
@@ -50,7 +50,7 @@ type $PropertiesFromRdfResourceFunction<T> = (resource: Resource, options: {
50
50
  objectSet: $ObjectSet;
51
51
  preferredLanguages?: readonly string[];
52
52
  }) => Either<Error, T>;
53
- export type $PropertyPath = RdfjsResourcePropertyPath;
53
+ export type $PropertyPath = RdfxResourcePropertyPath;
54
54
  export declare namespace $PropertyPath {
55
55
  type $Filter = object;
56
56
  function $filter(_filter: $Filter, _value: $PropertyPath): boolean;
@@ -58,6 +58,7 @@ export declare namespace $PropertyPath {
58
58
  const $fromRdfResourceValues: $FromRdfResourceValuesFunction<$PropertyPath>;
59
59
  const $schema: Readonly<object>;
60
60
  const $toRdfResource: $ToRdfResourceFunction<$PropertyPath>;
61
+ const $toString: typeof RdfxResourcePropertyPath.toString;
61
62
  }
62
63
  export interface $ShaclPropertySchema<TypeSchemaT = object> {
63
64
  readonly kind: "Shacl";
@@ -589,6 +590,9 @@ export declare namespace PropertyShape {
589
590
  };
590
591
  };
591
592
  function $toRdfResource(_propertyShape: PropertyShape, options?: Parameters<$ToRdfResourceFunction<PropertyShape>>[1]): Resource;
593
+ function $propertiesToStrings(_propertyShape: PropertyShape): Record<string, string>;
594
+ function $toString(this: PropertyShape): string;
595
+ function $toString(_propertyShape: PropertyShape): string;
592
596
  }
593
597
  export interface PropertyGroup {
594
598
  readonly $identifier: PropertyGroup.$Identifier;
@@ -661,6 +665,9 @@ export declare namespace PropertyGroup {
661
665
  };
662
666
  };
663
667
  function $toRdfResource(_propertyGroup: PropertyGroup, options?: Parameters<$ToRdfResourceFunction<PropertyGroup>>[1]): Resource;
668
+ function $propertiesToStrings(_propertyGroup: PropertyGroup): Record<string, string>;
669
+ function $toString(this: PropertyGroup): string;
670
+ function $toString(_propertyGroup: PropertyGroup): string;
664
671
  }
665
672
  export interface Ontology {
666
673
  readonly $identifier: Ontology.$Identifier;
@@ -733,6 +740,9 @@ export declare namespace Ontology {
733
740
  };
734
741
  };
735
742
  function $toRdfResource(_ontology: Ontology, options?: Parameters<$ToRdfResourceFunction<Ontology>>[1]): Resource;
743
+ function $propertiesToStrings(_ontology: Ontology): Record<string, string>;
744
+ function $toString(this: Ontology): string;
745
+ function $toString(_ontology: Ontology): string;
736
746
  }
737
747
  export interface NodeShape {
738
748
  readonly $identifier: NodeShape.$Identifier;
@@ -1216,6 +1226,9 @@ export declare namespace NodeShape {
1216
1226
  };
1217
1227
  };
1218
1228
  function $toRdfResource(_nodeShape: NodeShape, options?: Parameters<$ToRdfResourceFunction<NodeShape>>[1]): Resource;
1229
+ function $propertiesToStrings(_nodeShape: NodeShape): Record<string, string>;
1230
+ function $toString(this: NodeShape): string;
1231
+ function $toString(_nodeShape: NodeShape): string;
1219
1232
  }
1220
1233
  export type Shape = NodeShape | PropertyShape;
1221
1234
  export declare namespace Shape {
@@ -2205,6 +2218,7 @@ export declare namespace Shape {
2205
2218
  resource: Resource;
2206
2219
  resourceSet: ResourceSet;
2207
2220
  }) => (BlankNode | NamedNode)[];
2221
+ const $toString: (value: Shape) => string;
2208
2222
  function isShape(object: $Object): object is Shape;
2209
2223
  }
2210
2224
  export type $Object = NodeShape | Ontology | PropertyGroup | PropertyShape;
@@ -3031,6 +3045,7 @@ export declare namespace $Object {
3031
3045
  resource: Resource;
3032
3046
  resourceSet: ResourceSet;
3033
3047
  }) => (BlankNode | NamedNode)[];
3048
+ const $toString: (value: $Object) => string;
3034
3049
  }
3035
3050
  export interface $ObjectSet {
3036
3051
  nodeShape(identifier: NodeShape.$Identifier, options?: {
package/dist/generated.js CHANGED
@@ -1,9 +1,20 @@
1
1
  import datasetFactory from "@rdfjs/dataset";
2
2
  import dataFactory from "@rdfx/data-factory";
3
3
  import { LiteralFactory } from "@rdfx/literal";
4
- import { PropertyPath as RdfjsResourcePropertyPath, Resource, ResourceSet, } from "@rdfx/resource";
4
+ import { PropertyPath as RdfxResourcePropertyPath, Resource, ResourceSet, } from "@rdfx/resource";
5
5
  import { NTriplesIdentifier, NTriplesTerm } from "@rdfx/string";
6
6
  import { Either, Left, Maybe, Right } from "purify-ts";
7
+ /**
8
+ * Remove undefined values from a record.
9
+ */
10
+ function $compactRecord(record) {
11
+ return Object.entries(record).reduce((definedProperties, [propertyName, propertyValue]) => {
12
+ if (propertyValue !== undefined) {
13
+ definedProperties[propertyName] = propertyValue;
14
+ }
15
+ return definedProperties;
16
+ }, {});
17
+ }
7
18
  function $filterArray(filterItem) {
8
19
  return (filter, values) => {
9
20
  for (const value of values) {
@@ -184,12 +195,13 @@ export var $PropertyPath;
184
195
  return true;
185
196
  }
186
197
  $PropertyPath.$filter = $filter;
187
- $PropertyPath.$fromRdfResource = RdfjsResourcePropertyPath.fromResource;
198
+ $PropertyPath.$fromRdfResource = RdfxResourcePropertyPath.fromResource;
188
199
  $PropertyPath.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
189
200
  .toResource()
190
201
  .chain((resource) => $PropertyPath.$fromRdfResource(resource, options))));
191
202
  $PropertyPath.$schema = {};
192
- $PropertyPath.$toRdfResource = RdfjsResourcePropertyPath.toResource;
203
+ $PropertyPath.$toRdfResource = RdfxResourcePropertyPath.toResource;
204
+ $PropertyPath.$toString = RdfxResourcePropertyPath.toString;
193
205
  })($PropertyPath || ($PropertyPath = {}));
194
206
  var $RdfVocabularies;
195
207
  (function ($RdfVocabularies) {
@@ -2149,6 +2161,19 @@ export var PropertyShape;
2149
2161
  return resource;
2150
2162
  }
2151
2163
  PropertyShape.$toRdfResource = $toRdfResource;
2164
+ function $propertiesToStrings(_propertyShape) {
2165
+ return $compactRecord({
2166
+ $identifier: _propertyShape.$identifier.toString(),
2167
+ label: _propertyShape.label.map((item) => item.toString()).extract(),
2168
+ name: _propertyShape.name.map((item) => item.toString()).extract(),
2169
+ path: $PropertyPath.$toString(_propertyShape.path),
2170
+ });
2171
+ }
2172
+ PropertyShape.$propertiesToStrings = $propertiesToStrings;
2173
+ function $toString(_propertyShape) {
2174
+ return `PropertyShape(${JSON.stringify($propertiesToStrings((_propertyShape ?? this)))})`;
2175
+ }
2176
+ PropertyShape.$toString = $toString;
2152
2177
  })(PropertyShape || (PropertyShape = {}));
2153
2178
  export var PropertyGroup;
2154
2179
  (function (PropertyGroup) {
@@ -2350,6 +2375,17 @@ export var PropertyGroup;
2350
2375
  return resource;
2351
2376
  }
2352
2377
  PropertyGroup.$toRdfResource = $toRdfResource;
2378
+ function $propertiesToStrings(_propertyGroup) {
2379
+ return $compactRecord({
2380
+ $identifier: _propertyGroup.$identifier.toString(),
2381
+ label: _propertyGroup.label.map((item) => item.toString()).extract(),
2382
+ });
2383
+ }
2384
+ PropertyGroup.$propertiesToStrings = $propertiesToStrings;
2385
+ function $toString(_propertyGroup) {
2386
+ return `PropertyGroup(${JSON.stringify($propertiesToStrings((_propertyGroup ?? this)))})`;
2387
+ }
2388
+ PropertyGroup.$toString = $toString;
2353
2389
  })(PropertyGroup || (PropertyGroup = {}));
2354
2390
  export var Ontology;
2355
2391
  (function (Ontology) {
@@ -2551,6 +2587,17 @@ export var Ontology;
2551
2587
  return resource;
2552
2588
  }
2553
2589
  Ontology.$toRdfResource = $toRdfResource;
2590
+ function $propertiesToStrings(_ontology) {
2591
+ return $compactRecord({
2592
+ $identifier: _ontology.$identifier.toString(),
2593
+ label: _ontology.label.map((item) => item.toString()).extract(),
2594
+ });
2595
+ }
2596
+ Ontology.$propertiesToStrings = $propertiesToStrings;
2597
+ function $toString(_ontology) {
2598
+ return `Ontology(${JSON.stringify($propertiesToStrings((_ontology ?? this)))})`;
2599
+ }
2600
+ Ontology.$toString = $toString;
2554
2601
  })(Ontology || (Ontology = {}));
2555
2602
  export var NodeShape;
2556
2603
  (function (NodeShape) {
@@ -4369,6 +4416,17 @@ export var NodeShape;
4369
4416
  return resource;
4370
4417
  }
4371
4418
  NodeShape.$toRdfResource = $toRdfResource;
4419
+ function $propertiesToStrings(_nodeShape) {
4420
+ return $compactRecord({
4421
+ $identifier: _nodeShape.$identifier.toString(),
4422
+ label: _nodeShape.label.map((item) => item.toString()).extract(),
4423
+ });
4424
+ }
4425
+ NodeShape.$propertiesToStrings = $propertiesToStrings;
4426
+ function $toString(_nodeShape) {
4427
+ return `NodeShape(${JSON.stringify($propertiesToStrings((_nodeShape ?? this)))})`;
4428
+ }
4429
+ NodeShape.$toString = $toString;
4372
4430
  })(NodeShape || (NodeShape = {}));
4373
4431
  export var Shape;
4374
4432
  (function (Shape) {
@@ -4690,6 +4748,15 @@ export var Shape;
4690
4748
  }
4691
4749
  throw new Error("unable to serialize to RDF");
4692
4750
  });
4751
+ Shape.$toString = (value) => {
4752
+ if (NodeShape.isNodeShape(value)) {
4753
+ return NodeShape.$toString(value);
4754
+ }
4755
+ if (PropertyShape.isPropertyShape(value)) {
4756
+ return PropertyShape.$toString(value);
4757
+ }
4758
+ throw new Error("unable to serialize to string");
4759
+ };
4693
4760
  function isShape(object) {
4694
4761
  return (NodeShape.isNodeShape(object) || PropertyShape.isPropertyShape(object));
4695
4762
  }
@@ -4871,6 +4938,21 @@ export var $Object;
4871
4938
  }
4872
4939
  throw new Error("unable to serialize to RDF");
4873
4940
  });
4941
+ $Object.$toString = (value) => {
4942
+ if (NodeShape.isNodeShape(value)) {
4943
+ return NodeShape.$toString(value);
4944
+ }
4945
+ if (Ontology.isOntology(value)) {
4946
+ return Ontology.$toString(value);
4947
+ }
4948
+ if (PropertyGroup.isPropertyGroup(value)) {
4949
+ return PropertyGroup.$toString(value);
4950
+ }
4951
+ if (PropertyShape.isPropertyShape(value)) {
4952
+ return PropertyShape.$toString(value);
4953
+ }
4954
+ throw new Error("unable to serialize to string");
4955
+ };
4874
4956
  })($Object || ($Object = {}));
4875
4957
  export class $RdfjsDatasetObjectSet {
4876
4958
  $graph;
package/package.json CHANGED
@@ -44,5 +44,5 @@
44
44
  },
45
45
  "type": "module",
46
46
  "types": "./dist/index.d.ts",
47
- "version": "4.0.22"
47
+ "version": "4.0.23"
48
48
  }