@shaclmate/shacl-ast 4.0.22 → 4.0.24

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.
@@ -129,16 +129,16 @@ export class AbstractShapesGraph {
129
129
  for (const object of objects) {
130
130
  switch (object.$type) {
131
131
  case "NodeShape":
132
- this.nodeShapesByIdentifier.set(object.$identifier, object);
132
+ this.nodeShapesByIdentifier.set(object.$identifier(), object);
133
133
  break;
134
134
  case "Ontology":
135
- this.ontologiesByIdentifier.set(object.$identifier, object);
135
+ this.ontologiesByIdentifier.set(object.$identifier(), object);
136
136
  break;
137
137
  case "PropertyGroup":
138
- this.propertyGroupsByIdentifier.set(object.$identifier, object);
138
+ this.propertyGroupsByIdentifier.set(object.$identifier(), object);
139
139
  break;
140
140
  case "PropertyShape":
141
- this.propertyShapesByIdentifier.set(object.$identifier, object);
141
+ this.propertyShapesByIdentifier.set(object.$identifier(), object);
142
142
  break;
143
143
  }
144
144
  }
@@ -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";
@@ -88,7 +89,7 @@ export type $ToRdfResourceValuesFunction<ValueT, ReturnT extends BlankNode | Lit
88
89
  resourceSet: ResourceSet;
89
90
  }) => ReturnT[];
90
91
  export interface PropertyShape {
91
- readonly $identifier: PropertyShape.$Identifier;
92
+ readonly $identifier: () => PropertyShape.$Identifier;
92
93
  readonly $type: "PropertyShape";
93
94
  readonly and: Maybe<readonly (BlankNode | NamedNode)[]>;
94
95
  readonly classes: readonly NamedNode[];
@@ -125,7 +126,7 @@ export interface PropertyShape {
125
126
  }
126
127
  export declare namespace PropertyShape {
127
128
  function $create(parameters: {
128
- readonly $identifier?: (BlankNode | NamedNode) | string;
129
+ readonly $identifier?: (() => PropertyShape.$Identifier) | (BlankNode | NamedNode) | string;
129
130
  readonly and?: Maybe<readonly (BlankNode | NamedNode)[]> | readonly (BlankNode | NamedNode)[] | readonly string[];
130
131
  readonly classes?: readonly NamedNode[] | readonly string[];
131
132
  readonly comment?: Maybe<string> | string;
@@ -589,16 +590,19 @@ 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
- readonly $identifier: PropertyGroup.$Identifier;
598
+ readonly $identifier: () => PropertyGroup.$Identifier;
595
599
  readonly $type: "PropertyGroup";
596
600
  readonly comment: Maybe<string>;
597
601
  readonly label: Maybe<string>;
598
602
  }
599
603
  export declare namespace PropertyGroup {
600
604
  function $create(parameters?: {
601
- readonly $identifier?: (BlankNode | NamedNode) | string;
605
+ readonly $identifier?: (() => PropertyGroup.$Identifier) | (BlankNode | NamedNode) | string;
602
606
  readonly comment?: Maybe<string> | string;
603
607
  readonly label?: Maybe<string> | string;
604
608
  }): PropertyGroup;
@@ -661,16 +665,19 @@ 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
- readonly $identifier: Ontology.$Identifier;
673
+ readonly $identifier: () => Ontology.$Identifier;
667
674
  readonly $type: "Ontology";
668
675
  readonly comment: Maybe<string>;
669
676
  readonly label: Maybe<string>;
670
677
  }
671
678
  export declare namespace Ontology {
672
679
  function $create(parameters?: {
673
- readonly $identifier?: (BlankNode | NamedNode) | string;
680
+ readonly $identifier?: (() => Ontology.$Identifier) | (BlankNode | NamedNode) | string;
674
681
  readonly comment?: Maybe<string> | string;
675
682
  readonly label?: Maybe<string> | string;
676
683
  }): Ontology;
@@ -733,9 +740,12 @@ 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
- readonly $identifier: NodeShape.$Identifier;
748
+ readonly $identifier: () => NodeShape.$Identifier;
739
749
  readonly $type: "NodeShape";
740
750
  readonly and: Maybe<readonly (BlankNode | NamedNode)[]>;
741
751
  readonly classes: readonly NamedNode[];
@@ -770,7 +780,7 @@ export interface NodeShape {
770
780
  }
771
781
  export declare namespace NodeShape {
772
782
  function $create(parameters?: {
773
- readonly $identifier?: (BlankNode | NamedNode) | string;
783
+ readonly $identifier?: (() => NodeShape.$Identifier) | (BlankNode | NamedNode) | string;
774
784
  readonly and?: Maybe<readonly (BlankNode | NamedNode)[]> | readonly (BlankNode | NamedNode)[] | readonly string[];
775
785
  readonly classes?: readonly NamedNode[] | readonly string[];
776
786
  readonly closed?: Maybe<boolean> | boolean;
@@ -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?: {
@@ -3161,14 +3176,14 @@ export declare class $RdfjsDatasetObjectSet implements $ObjectSet {
3161
3176
  objects(query?: $ObjectSet.Query<$Object.$Filter, $Object.$Identifier>): Promise<Either<Error, readonly $Object[]>>;
3162
3177
  objectsSync(query?: $ObjectSet.Query<$Object.$Filter, $Object.$Identifier>): Either<Error, readonly $Object[]>;
3163
3178
  protected $objectsSync<ObjectT extends {
3164
- readonly $identifier: ObjectIdentifierT;
3179
+ readonly $identifier: () => ObjectIdentifierT;
3165
3180
  }, ObjectFilterT, ObjectIdentifierT extends BlankNode | NamedNode>(namedObjectType: {
3166
3181
  $filter: (filter: ObjectFilterT, value: ObjectT) => boolean;
3167
3182
  $fromRdfResource: $FromRdfResourceFunction<ObjectT>;
3168
3183
  $fromRdfTypes: readonly NamedNode[];
3169
3184
  }, query?: $ObjectSet.Query<ObjectFilterT, ObjectIdentifierT>): Either<Error, readonly ObjectT[]>;
3170
3185
  protected $objectUnionsSync<ObjectT extends {
3171
- readonly $identifier: ObjectIdentifierT;
3186
+ readonly $identifier: () => ObjectIdentifierT;
3172
3187
  }, ObjectFilterT, ObjectIdentifierT extends BlankNode | NamedNode>(namedObjectTypes: readonly {
3173
3188
  $filter: (filter: ObjectFilterT, value: ObjectT) => boolean;
3174
3189
  $fromRdfResource: $FromRdfResourceFunction<ObjectT>;
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) {
@@ -235,18 +247,23 @@ function $shaclPropertyFromRdf({ graph, propertySchema, resource, typeFromRdf, }
235
247
  export var PropertyShape;
236
248
  (function (PropertyShape) {
237
249
  function $create(parameters) {
250
+ const $identifierParameter = parameters.$identifier;
238
251
  let $identifier;
239
- if (typeof parameters.$identifier === "object") {
240
- $identifier = parameters.$identifier;
252
+ if (typeof $identifierParameter === "function") {
253
+ $identifier = $identifierParameter;
254
+ }
255
+ else if (typeof $identifierParameter === "object") {
256
+ $identifier = () => $identifierParameter;
241
257
  }
242
- else if (typeof parameters.$identifier === "string") {
243
- $identifier = dataFactory.namedNode(parameters.$identifier);
258
+ else if (typeof $identifierParameter === "string") {
259
+ $identifier = () => dataFactory.namedNode($identifierParameter);
244
260
  }
245
- else if (parameters.$identifier === undefined) {
246
- $identifier = dataFactory.blankNode();
261
+ else if ($identifierParameter === undefined) {
262
+ const $eagerIdentifier = dataFactory.blankNode();
263
+ $identifier = () => $eagerIdentifier;
247
264
  }
248
265
  else {
249
- $identifier = parameters.$identifier;
266
+ $identifier = $identifierParameter;
250
267
  }
251
268
  const $type = "PropertyShape";
252
269
  let and;
@@ -811,7 +828,7 @@ export var PropertyShape;
811
828
  })($Identifier = PropertyShape.$Identifier || (PropertyShape.$Identifier = {}));
812
829
  function $filter(filter, value) {
813
830
  if (filter.$identifier !== undefined &&
814
- !$filterIdentifier(filter.$identifier, value.$identifier)) {
831
+ !$filterIdentifier(filter.$identifier, value.$identifier())) {
815
832
  return false;
816
833
  }
817
834
  if (filter.and !== undefined &&
@@ -956,7 +973,7 @@ export var PropertyShape;
956
973
  ignoreRdfType,
957
974
  objectSet,
958
975
  preferredLanguages,
959
- });
976
+ }).map($create);
960
977
  };
961
978
  PropertyShape.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
962
979
  .toResource()
@@ -1964,7 +1981,7 @@ export var PropertyShape;
1964
1981
  dataFactory: dataFactory,
1965
1982
  dataset: datasetFactory.dataset(),
1966
1983
  });
1967
- const resource = resourceSet.resource(_propertyShape.$identifier);
1984
+ const resource = resourceSet.resource(_propertyShape.$identifier());
1968
1985
  if (!options?.ignoreRdfType) {
1969
1986
  resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyShape"), options?.graph);
1970
1987
  }
@@ -1975,7 +1992,7 @@ export var PropertyShape;
1975
1992
  currentSubListResource = listResource;
1976
1993
  }
1977
1994
  else {
1978
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
1995
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
1979
1996
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
1980
1997
  currentSubListResource = newSubListResource;
1981
1998
  }
@@ -1986,7 +2003,7 @@ export var PropertyShape;
1986
2003
  return { currentSubListResource, listResource };
1987
2004
  }, {
1988
2005
  currentSubListResource: null,
1989
- listResource: resourceSet.resource(dataFactory.blankNode()),
2006
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
1990
2007
  }).listResource.identifier
1991
2008
  : $RdfVocabularies.rdf.nil,
1992
2009
  ]), options?.graph);
@@ -2014,7 +2031,7 @@ export var PropertyShape;
2014
2031
  currentSubListResource = listResource;
2015
2032
  }
2016
2033
  else {
2017
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
2034
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2018
2035
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
2019
2036
  currentSubListResource = newSubListResource;
2020
2037
  }
@@ -2025,7 +2042,7 @@ export var PropertyShape;
2025
2042
  return { currentSubListResource, listResource };
2026
2043
  }, {
2027
2044
  currentSubListResource: null,
2028
- listResource: resourceSet.resource(dataFactory.blankNode()),
2045
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
2029
2046
  }).listResource.identifier
2030
2047
  : $RdfVocabularies.rdf.nil,
2031
2048
  ]), options?.graph);
@@ -2040,7 +2057,7 @@ export var PropertyShape;
2040
2057
  currentSubListResource = listResource;
2041
2058
  }
2042
2059
  else {
2043
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
2060
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2044
2061
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
2045
2062
  currentSubListResource = newSubListResource;
2046
2063
  }
@@ -2051,7 +2068,7 @@ export var PropertyShape;
2051
2068
  return { currentSubListResource, listResource };
2052
2069
  }, {
2053
2070
  currentSubListResource: null,
2054
- listResource: resourceSet.resource(dataFactory.blankNode()),
2071
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
2055
2072
  }).listResource.identifier
2056
2073
  : $RdfVocabularies.rdf.nil,
2057
2074
  ]), options?.graph);
@@ -2092,7 +2109,7 @@ export var PropertyShape;
2092
2109
  currentSubListResource = listResource;
2093
2110
  }
2094
2111
  else {
2095
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
2112
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2096
2113
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
2097
2114
  currentSubListResource = newSubListResource;
2098
2115
  }
@@ -2103,7 +2120,7 @@ export var PropertyShape;
2103
2120
  return { currentSubListResource, listResource };
2104
2121
  }, {
2105
2122
  currentSubListResource: null,
2106
- listResource: resourceSet.resource(dataFactory.blankNode()),
2123
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
2107
2124
  }).listResource.identifier
2108
2125
  : $RdfVocabularies.rdf.nil,
2109
2126
  ]), options?.graph);
@@ -2131,7 +2148,7 @@ export var PropertyShape;
2131
2148
  currentSubListResource = listResource;
2132
2149
  }
2133
2150
  else {
2134
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
2151
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
2135
2152
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
2136
2153
  currentSubListResource = newSubListResource;
2137
2154
  }
@@ -2142,29 +2159,47 @@ export var PropertyShape;
2142
2159
  return { currentSubListResource, listResource };
2143
2160
  }, {
2144
2161
  currentSubListResource: null,
2145
- listResource: resourceSet.resource(dataFactory.blankNode()),
2162
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
2146
2163
  }).listResource.identifier
2147
2164
  : $RdfVocabularies.rdf.nil,
2148
2165
  ]), options?.graph);
2149
2166
  return resource;
2150
2167
  }
2151
2168
  PropertyShape.$toRdfResource = $toRdfResource;
2169
+ function $propertiesToStrings(_propertyShape) {
2170
+ return $compactRecord({
2171
+ $identifier: _propertyShape.$identifier().toString(),
2172
+ label: _propertyShape.label.map((item) => item.toString()).extract(),
2173
+ name: _propertyShape.name.map((item) => item.toString()).extract(),
2174
+ path: $PropertyPath.$toString(_propertyShape.path),
2175
+ });
2176
+ }
2177
+ PropertyShape.$propertiesToStrings = $propertiesToStrings;
2178
+ function $toString(_propertyShape) {
2179
+ return `PropertyShape(${JSON.stringify($propertiesToStrings((_propertyShape ?? this)))})`;
2180
+ }
2181
+ PropertyShape.$toString = $toString;
2152
2182
  })(PropertyShape || (PropertyShape = {}));
2153
2183
  export var PropertyGroup;
2154
2184
  (function (PropertyGroup) {
2155
2185
  function $create(parameters) {
2186
+ const $identifierParameter = parameters?.$identifier;
2156
2187
  let $identifier;
2157
- if (typeof parameters?.$identifier === "object") {
2158
- $identifier = parameters?.$identifier;
2188
+ if (typeof $identifierParameter === "function") {
2189
+ $identifier = $identifierParameter;
2190
+ }
2191
+ else if (typeof $identifierParameter === "object") {
2192
+ $identifier = () => $identifierParameter;
2159
2193
  }
2160
- else if (typeof parameters?.$identifier === "string") {
2161
- $identifier = dataFactory.namedNode(parameters?.$identifier);
2194
+ else if (typeof $identifierParameter === "string") {
2195
+ $identifier = () => dataFactory.namedNode($identifierParameter);
2162
2196
  }
2163
- else if (parameters?.$identifier === undefined) {
2164
- $identifier = dataFactory.blankNode();
2197
+ else if ($identifierParameter === undefined) {
2198
+ const $eagerIdentifier = dataFactory.blankNode();
2199
+ $identifier = () => $eagerIdentifier;
2165
2200
  }
2166
2201
  else {
2167
- $identifier = parameters?.$identifier;
2202
+ $identifier = $identifierParameter;
2168
2203
  }
2169
2204
  const $type = "PropertyGroup";
2170
2205
  let comment;
@@ -2203,7 +2238,7 @@ export var PropertyGroup;
2203
2238
  })($Identifier = PropertyGroup.$Identifier || (PropertyGroup.$Identifier = {}));
2204
2239
  function $filter(filter, value) {
2205
2240
  if (filter.$identifier !== undefined &&
2206
- !$filterIdentifier(filter.$identifier, value.$identifier)) {
2241
+ !$filterIdentifier(filter.$identifier, value.$identifier())) {
2207
2242
  return false;
2208
2243
  }
2209
2244
  if (filter.comment !== undefined &&
@@ -2228,7 +2263,7 @@ export var PropertyGroup;
2228
2263
  ignoreRdfType,
2229
2264
  objectSet,
2230
2265
  preferredLanguages,
2231
- });
2266
+ }).map($create);
2232
2267
  };
2233
2268
  PropertyGroup.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
2234
2269
  .toResource()
@@ -2337,7 +2372,7 @@ export var PropertyGroup;
2337
2372
  dataFactory: dataFactory,
2338
2373
  dataset: datasetFactory.dataset(),
2339
2374
  });
2340
- const resource = resourceSet.resource(_propertyGroup.$identifier);
2375
+ const resource = resourceSet.resource(_propertyGroup.$identifier());
2341
2376
  if (!options?.ignoreRdfType) {
2342
2377
  resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#PropertyGroup"), options?.graph);
2343
2378
  }
@@ -2350,22 +2385,38 @@ export var PropertyGroup;
2350
2385
  return resource;
2351
2386
  }
2352
2387
  PropertyGroup.$toRdfResource = $toRdfResource;
2388
+ function $propertiesToStrings(_propertyGroup) {
2389
+ return $compactRecord({
2390
+ $identifier: _propertyGroup.$identifier().toString(),
2391
+ label: _propertyGroup.label.map((item) => item.toString()).extract(),
2392
+ });
2393
+ }
2394
+ PropertyGroup.$propertiesToStrings = $propertiesToStrings;
2395
+ function $toString(_propertyGroup) {
2396
+ return `PropertyGroup(${JSON.stringify($propertiesToStrings((_propertyGroup ?? this)))})`;
2397
+ }
2398
+ PropertyGroup.$toString = $toString;
2353
2399
  })(PropertyGroup || (PropertyGroup = {}));
2354
2400
  export var Ontology;
2355
2401
  (function (Ontology) {
2356
2402
  function $create(parameters) {
2403
+ const $identifierParameter = parameters?.$identifier;
2357
2404
  let $identifier;
2358
- if (typeof parameters?.$identifier === "object") {
2359
- $identifier = parameters?.$identifier;
2405
+ if (typeof $identifierParameter === "function") {
2406
+ $identifier = $identifierParameter;
2407
+ }
2408
+ else if (typeof $identifierParameter === "object") {
2409
+ $identifier = () => $identifierParameter;
2360
2410
  }
2361
- else if (typeof parameters?.$identifier === "string") {
2362
- $identifier = dataFactory.namedNode(parameters?.$identifier);
2411
+ else if (typeof $identifierParameter === "string") {
2412
+ $identifier = () => dataFactory.namedNode($identifierParameter);
2363
2413
  }
2364
- else if (parameters?.$identifier === undefined) {
2365
- $identifier = dataFactory.blankNode();
2414
+ else if ($identifierParameter === undefined) {
2415
+ const $eagerIdentifier = dataFactory.blankNode();
2416
+ $identifier = () => $eagerIdentifier;
2366
2417
  }
2367
2418
  else {
2368
- $identifier = parameters?.$identifier;
2419
+ $identifier = $identifierParameter;
2369
2420
  }
2370
2421
  const $type = "Ontology";
2371
2422
  let comment;
@@ -2404,7 +2455,7 @@ export var Ontology;
2404
2455
  })($Identifier = Ontology.$Identifier || (Ontology.$Identifier = {}));
2405
2456
  function $filter(filter, value) {
2406
2457
  if (filter.$identifier !== undefined &&
2407
- !$filterIdentifier(filter.$identifier, value.$identifier)) {
2458
+ !$filterIdentifier(filter.$identifier, value.$identifier())) {
2408
2459
  return false;
2409
2460
  }
2410
2461
  if (filter.comment !== undefined &&
@@ -2429,7 +2480,7 @@ export var Ontology;
2429
2480
  ignoreRdfType,
2430
2481
  objectSet,
2431
2482
  preferredLanguages,
2432
- });
2483
+ }).map($create);
2433
2484
  };
2434
2485
  Ontology.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
2435
2486
  .toResource()
@@ -2538,7 +2589,7 @@ export var Ontology;
2538
2589
  dataFactory: dataFactory,
2539
2590
  dataset: datasetFactory.dataset(),
2540
2591
  });
2541
- const resource = resourceSet.resource(_ontology.$identifier);
2592
+ const resource = resourceSet.resource(_ontology.$identifier());
2542
2593
  if (!options?.ignoreRdfType) {
2543
2594
  resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/2002/07/owl#Ontology"), options?.graph);
2544
2595
  }
@@ -2551,22 +2602,38 @@ export var Ontology;
2551
2602
  return resource;
2552
2603
  }
2553
2604
  Ontology.$toRdfResource = $toRdfResource;
2605
+ function $propertiesToStrings(_ontology) {
2606
+ return $compactRecord({
2607
+ $identifier: _ontology.$identifier().toString(),
2608
+ label: _ontology.label.map((item) => item.toString()).extract(),
2609
+ });
2610
+ }
2611
+ Ontology.$propertiesToStrings = $propertiesToStrings;
2612
+ function $toString(_ontology) {
2613
+ return `Ontology(${JSON.stringify($propertiesToStrings((_ontology ?? this)))})`;
2614
+ }
2615
+ Ontology.$toString = $toString;
2554
2616
  })(Ontology || (Ontology = {}));
2555
2617
  export var NodeShape;
2556
2618
  (function (NodeShape) {
2557
2619
  function $create(parameters) {
2620
+ const $identifierParameter = parameters?.$identifier;
2558
2621
  let $identifier;
2559
- if (typeof parameters?.$identifier === "object") {
2560
- $identifier = parameters?.$identifier;
2622
+ if (typeof $identifierParameter === "function") {
2623
+ $identifier = $identifierParameter;
2561
2624
  }
2562
- else if (typeof parameters?.$identifier === "string") {
2563
- $identifier = dataFactory.namedNode(parameters?.$identifier);
2625
+ else if (typeof $identifierParameter === "object") {
2626
+ $identifier = () => $identifierParameter;
2564
2627
  }
2565
- else if (parameters?.$identifier === undefined) {
2566
- $identifier = dataFactory.blankNode();
2628
+ else if (typeof $identifierParameter === "string") {
2629
+ $identifier = () => dataFactory.namedNode($identifierParameter);
2630
+ }
2631
+ else if ($identifierParameter === undefined) {
2632
+ const $eagerIdentifier = dataFactory.blankNode();
2633
+ $identifier = () => $eagerIdentifier;
2567
2634
  }
2568
2635
  else {
2569
- $identifier = parameters?.$identifier;
2636
+ $identifier = $identifierParameter;
2570
2637
  }
2571
2638
  const $type = "NodeShape";
2572
2639
  let and;
@@ -3102,7 +3169,7 @@ export var NodeShape;
3102
3169
  })($Identifier = NodeShape.$Identifier || (NodeShape.$Identifier = {}));
3103
3170
  function $filter(filter, value) {
3104
3171
  if (filter.$identifier !== undefined &&
3105
- !$filterIdentifier(filter.$identifier, value.$identifier)) {
3172
+ !$filterIdentifier(filter.$identifier, value.$identifier())) {
3106
3173
  return false;
3107
3174
  }
3108
3175
  if (filter.and !== undefined &&
@@ -3239,7 +3306,7 @@ export var NodeShape;
3239
3306
  ignoreRdfType,
3240
3307
  objectSet,
3241
3308
  preferredLanguages,
3242
- });
3309
+ }).map($create);
3243
3310
  };
3244
3311
  NodeShape.$fromRdfResourceValues = (values, options) => values.chain((values) => values.chainMap((value) => value
3245
3312
  .toResource()
@@ -4178,7 +4245,7 @@ export var NodeShape;
4178
4245
  dataFactory: dataFactory,
4179
4246
  dataset: datasetFactory.dataset(),
4180
4247
  });
4181
- const resource = resourceSet.resource(_nodeShape.$identifier);
4248
+ const resource = resourceSet.resource(_nodeShape.$identifier());
4182
4249
  if (!options?.ignoreRdfType) {
4183
4250
  resource.add($RdfVocabularies.rdf.type, dataFactory.namedNode("http://www.w3.org/ns/shacl#NodeShape"), options?.graph);
4184
4251
  }
@@ -4189,7 +4256,7 @@ export var NodeShape;
4189
4256
  currentSubListResource = listResource;
4190
4257
  }
4191
4258
  else {
4192
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
4259
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4193
4260
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4194
4261
  currentSubListResource = newSubListResource;
4195
4262
  }
@@ -4200,7 +4267,7 @@ export var NodeShape;
4200
4267
  return { currentSubListResource, listResource };
4201
4268
  }, {
4202
4269
  currentSubListResource: null,
4203
- listResource: resourceSet.resource(dataFactory.blankNode()),
4270
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4204
4271
  }).listResource.identifier
4205
4272
  : $RdfVocabularies.rdf.nil,
4206
4273
  ]), options?.graph);
@@ -4228,7 +4295,7 @@ export var NodeShape;
4228
4295
  currentSubListResource = listResource;
4229
4296
  }
4230
4297
  else {
4231
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
4298
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4232
4299
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4233
4300
  currentSubListResource = newSubListResource;
4234
4301
  }
@@ -4239,7 +4306,7 @@ export var NodeShape;
4239
4306
  return { currentSubListResource, listResource };
4240
4307
  }, {
4241
4308
  currentSubListResource: null,
4242
- listResource: resourceSet.resource(dataFactory.blankNode()),
4309
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4243
4310
  }).listResource.identifier
4244
4311
  : $RdfVocabularies.rdf.nil,
4245
4312
  ]), options?.graph);
@@ -4250,7 +4317,7 @@ export var NodeShape;
4250
4317
  currentSubListResource = listResource;
4251
4318
  }
4252
4319
  else {
4253
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
4320
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4254
4321
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4255
4322
  currentSubListResource = newSubListResource;
4256
4323
  }
@@ -4261,7 +4328,7 @@ export var NodeShape;
4261
4328
  return { currentSubListResource, listResource };
4262
4329
  }, {
4263
4330
  currentSubListResource: null,
4264
- listResource: resourceSet.resource(dataFactory.blankNode()),
4331
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4265
4332
  }).listResource.identifier
4266
4333
  : $RdfVocabularies.rdf.nil,
4267
4334
  ]), options?.graph);
@@ -4276,7 +4343,7 @@ export var NodeShape;
4276
4343
  currentSubListResource = listResource;
4277
4344
  }
4278
4345
  else {
4279
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
4346
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4280
4347
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4281
4348
  currentSubListResource = newSubListResource;
4282
4349
  }
@@ -4287,7 +4354,7 @@ export var NodeShape;
4287
4354
  return { currentSubListResource, listResource };
4288
4355
  }, {
4289
4356
  currentSubListResource: null,
4290
- listResource: resourceSet.resource(dataFactory.blankNode()),
4357
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4291
4358
  }).listResource.identifier
4292
4359
  : $RdfVocabularies.rdf.nil,
4293
4360
  ]), options?.graph);
@@ -4325,7 +4392,7 @@ export var NodeShape;
4325
4392
  currentSubListResource = listResource;
4326
4393
  }
4327
4394
  else {
4328
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
4395
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4329
4396
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4330
4397
  currentSubListResource = newSubListResource;
4331
4398
  }
@@ -4336,7 +4403,7 @@ export var NodeShape;
4336
4403
  return { currentSubListResource, listResource };
4337
4404
  }, {
4338
4405
  currentSubListResource: null,
4339
- listResource: resourceSet.resource(dataFactory.blankNode()),
4406
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4340
4407
  }).listResource.identifier
4341
4408
  : $RdfVocabularies.rdf.nil,
4342
4409
  ]), options?.graph);
@@ -4351,7 +4418,7 @@ export var NodeShape;
4351
4418
  currentSubListResource = listResource;
4352
4419
  }
4353
4420
  else {
4354
- const newSubListResource = resourceSet.resource(dataFactory.blankNode());
4421
+ const newSubListResource = resourceSet.resource((() => dataFactory.blankNode())());
4355
4422
  currentSubListResource.add($RdfVocabularies.rdf.rest, newSubListResource.identifier, options?.graph);
4356
4423
  currentSubListResource = newSubListResource;
4357
4424
  }
@@ -4362,19 +4429,30 @@ export var NodeShape;
4362
4429
  return { currentSubListResource, listResource };
4363
4430
  }, {
4364
4431
  currentSubListResource: null,
4365
- listResource: resourceSet.resource(dataFactory.blankNode()),
4432
+ listResource: resourceSet.resource((() => dataFactory.blankNode())()),
4366
4433
  }).listResource.identifier
4367
4434
  : $RdfVocabularies.rdf.nil,
4368
4435
  ]), options?.graph);
4369
4436
  return resource;
4370
4437
  }
4371
4438
  NodeShape.$toRdfResource = $toRdfResource;
4439
+ function $propertiesToStrings(_nodeShape) {
4440
+ return $compactRecord({
4441
+ $identifier: _nodeShape.$identifier().toString(),
4442
+ label: _nodeShape.label.map((item) => item.toString()).extract(),
4443
+ });
4444
+ }
4445
+ NodeShape.$propertiesToStrings = $propertiesToStrings;
4446
+ function $toString(_nodeShape) {
4447
+ return `NodeShape(${JSON.stringify($propertiesToStrings((_nodeShape ?? this)))})`;
4448
+ }
4449
+ NodeShape.$toString = $toString;
4372
4450
  })(NodeShape || (NodeShape = {}));
4373
4451
  export var Shape;
4374
4452
  (function (Shape) {
4375
4453
  Shape.$filter = (filter, value) => {
4376
4454
  if (filter.$identifier !== undefined &&
4377
- !$filterIdentifier(filter.$identifier, value.$identifier)) {
4455
+ !$filterIdentifier(filter.$identifier, value.$identifier())) {
4378
4456
  return false;
4379
4457
  }
4380
4458
  if (filter.on?.["NodeShape"] !== undefined &&
@@ -4690,6 +4768,15 @@ export var Shape;
4690
4768
  }
4691
4769
  throw new Error("unable to serialize to RDF");
4692
4770
  });
4771
+ Shape.$toString = (value) => {
4772
+ if (NodeShape.isNodeShape(value)) {
4773
+ return NodeShape.$toString(value);
4774
+ }
4775
+ if (PropertyShape.isPropertyShape(value)) {
4776
+ return PropertyShape.$toString(value);
4777
+ }
4778
+ throw new Error("unable to serialize to string");
4779
+ };
4693
4780
  function isShape(object) {
4694
4781
  return (NodeShape.isNodeShape(object) || PropertyShape.isPropertyShape(object));
4695
4782
  }
@@ -4699,7 +4786,7 @@ export var $Object;
4699
4786
  (function ($Object) {
4700
4787
  $Object.$filter = (filter, value) => {
4701
4788
  if (filter.$identifier !== undefined &&
4702
- !$filterIdentifier(filter.$identifier, value.$identifier)) {
4789
+ !$filterIdentifier(filter.$identifier, value.$identifier())) {
4703
4790
  return false;
4704
4791
  }
4705
4792
  if (filter.on?.["NodeShape"] !== undefined &&
@@ -4871,6 +4958,21 @@ export var $Object;
4871
4958
  }
4872
4959
  throw new Error("unable to serialize to RDF");
4873
4960
  });
4961
+ $Object.$toString = (value) => {
4962
+ if (NodeShape.isNodeShape(value)) {
4963
+ return NodeShape.$toString(value);
4964
+ }
4965
+ if (Ontology.isOntology(value)) {
4966
+ return Ontology.$toString(value);
4967
+ }
4968
+ if (PropertyGroup.isPropertyGroup(value)) {
4969
+ return PropertyGroup.$toString(value);
4970
+ }
4971
+ if (PropertyShape.isPropertyShape(value)) {
4972
+ return PropertyShape.$toString(value);
4973
+ }
4974
+ throw new Error("unable to serialize to string");
4975
+ };
4874
4976
  })($Object || ($Object = {}));
4875
4977
  export class $RdfjsDatasetObjectSet {
4876
4978
  $graph;
@@ -4910,7 +5012,7 @@ export class $RdfjsDatasetObjectSet {
4910
5012
  return this.nodeShapeIdentifiersSync(query);
4911
5013
  }
4912
5014
  nodeShapeIdentifiersSync(query) {
4913
- return this.nodeShapesSync(query).map((objects) => objects.map((object) => object.$identifier));
5015
+ return this.nodeShapesSync(query).map((objects) => objects.map((object) => object.$identifier()));
4914
5016
  }
4915
5017
  async nodeShapes(query) {
4916
5018
  return this.nodeShapesSync(query);
@@ -4941,7 +5043,7 @@ export class $RdfjsDatasetObjectSet {
4941
5043
  return this.ontologyIdentifiersSync(query);
4942
5044
  }
4943
5045
  ontologyIdentifiersSync(query) {
4944
- return this.ontologiesSync(query).map((objects) => objects.map((object) => object.$identifier));
5046
+ return this.ontologiesSync(query).map((objects) => objects.map((object) => object.$identifier()));
4945
5047
  }
4946
5048
  async ontologies(query) {
4947
5049
  return this.ontologiesSync(query);
@@ -4972,7 +5074,7 @@ export class $RdfjsDatasetObjectSet {
4972
5074
  return this.propertyGroupIdentifiersSync(query);
4973
5075
  }
4974
5076
  propertyGroupIdentifiersSync(query) {
4975
- return this.propertyGroupsSync(query).map((objects) => objects.map((object) => object.$identifier));
5077
+ return this.propertyGroupsSync(query).map((objects) => objects.map((object) => object.$identifier()));
4976
5078
  }
4977
5079
  async propertyGroups(query) {
4978
5080
  return this.propertyGroupsSync(query);
@@ -5003,7 +5105,7 @@ export class $RdfjsDatasetObjectSet {
5003
5105
  return this.propertyShapeIdentifiersSync(query);
5004
5106
  }
5005
5107
  propertyShapeIdentifiersSync(query) {
5006
- return this.propertyShapesSync(query).map((objects) => objects.map((object) => object.$identifier));
5108
+ return this.propertyShapesSync(query).map((objects) => objects.map((object) => object.$identifier()));
5007
5109
  }
5008
5110
  async propertyShapes(query) {
5009
5111
  return this.propertyShapesSync(query);
@@ -5034,7 +5136,7 @@ export class $RdfjsDatasetObjectSet {
5034
5136
  return this.shapeIdentifiersSync(query);
5035
5137
  }
5036
5138
  shapeIdentifiersSync(query) {
5037
- return this.shapesSync(query).map((objects) => objects.map((object) => object.$identifier));
5139
+ return this.shapesSync(query).map((objects) => objects.map((object) => object.$identifier()));
5038
5140
  }
5039
5141
  async shapes(query) {
5040
5142
  return this.shapesSync(query);
@@ -5072,7 +5174,7 @@ export class $RdfjsDatasetObjectSet {
5072
5174
  return this.objectIdentifiersSync(query);
5073
5175
  }
5074
5176
  objectIdentifiersSync(query) {
5075
- return this.objectsSync(query).map((objects) => objects.map((object) => object.$identifier));
5177
+ return this.objectsSync(query).map((objects) => objects.map((object) => object.$identifier()));
5076
5178
  }
5077
5179
  async objects(query) {
5078
5180
  return this.objectsSync(query);
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.24"
48
48
  }