@shaclmate/compiler 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.
Files changed (50) hide show
  1. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -0
  2. package/dist/ast/ObjectType.d.ts +6 -1
  3. package/dist/ast/ObjectType.js +6 -1
  4. package/dist/generators/ts/AbstractLazyObjectType.d.ts +1 -0
  5. package/dist/generators/ts/AbstractLazyObjectType.js +7 -0
  6. package/dist/generators/ts/AbstractNamedUnionType.d.ts +3 -2
  7. package/dist/generators/ts/AbstractNamedUnionType.js +23 -9
  8. package/dist/generators/ts/AbstractTermType.d.ts +1 -0
  9. package/dist/generators/ts/AbstractTermType.js +3 -0
  10. package/dist/generators/ts/AbstractType.d.ts +12 -4
  11. package/dist/generators/ts/AbstractUnionType.d.ts +1 -0
  12. package/dist/generators/ts/AbstractUnionType.js +10 -0
  13. package/dist/generators/ts/AnonymousUnionType.d.ts +2 -1
  14. package/dist/generators/ts/AnonymousUnionType.js +6 -3
  15. package/dist/generators/ts/DefaultValueType.d.ts +2 -1
  16. package/dist/generators/ts/DefaultValueType.js +6 -3
  17. package/dist/generators/ts/ListType.d.ts +1 -0
  18. package/dist/generators/ts/ListType.js +3 -0
  19. package/dist/generators/ts/NamedObjectType.d.ts +1 -0
  20. package/dist/generators/ts/NamedObjectType.js +11 -0
  21. package/dist/generators/ts/OptionType.d.ts +1 -0
  22. package/dist/generators/ts/OptionType.js +3 -0
  23. package/dist/generators/ts/SetType.d.ts +1 -0
  24. package/dist/generators/ts/SetType.js +3 -0
  25. package/dist/generators/ts/TypeFactory.js +1 -0
  26. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +13 -5
  27. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +2 -1
  28. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -6
  29. package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.d.ts +2 -1
  30. package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.js +4 -1
  31. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +2 -1
  32. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +5 -2
  33. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +2 -9
  34. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +11 -2
  35. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +4 -0
  36. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +62 -0
  37. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +5 -2
  38. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +24 -9
  39. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +5 -3
  40. package/dist/generators/ts/_snippets/snippets_compactRecord.d.ts +2 -0
  41. package/dist/generators/ts/_snippets/snippets_compactRecord.js +16 -0
  42. package/dist/generators/ts/_snippets/{parseIri.d.ts → snippets_parseIri.d.ts} +1 -1
  43. package/dist/generators/ts/_snippets/{parseIri.js → snippets_parseIri.js} +1 -1
  44. package/dist/generators/ts/imports.d.ts +1 -1
  45. package/dist/generators/ts/imports.js +1 -1
  46. package/dist/generators/ts/snippets.d.ts +1 -0
  47. package/dist/generators/ts/snippets.js +3 -1
  48. package/dist/input/generated.d.ts +94 -3
  49. package/dist/input/generated.js +183 -21
  50. package/package.json +2 -2
@@ -1,11 +1,10 @@
1
- import { Maybe } from "purify-ts";
2
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
3
1
  import { code, def, joinCode } from "../ts-poet-wrapper.js";
4
2
  import { tsComment } from "../tsComment.js";
5
3
  import { NamedObjectType_equalsFunctionOrMethodDeclaration } from "./NamedObjectType_equalsFunctionOrMethodDeclaration.js";
6
4
  import { NamedObjectType_hashFunctionOrMethodDeclarations } from "./NamedObjectType_hashFunctionOrMethodDeclarations.js";
7
5
  import { NamedObjectType_toJsonFunctionOrMethodDeclaration } from "./NamedObjectType_toJsonFunctionOrMethodDeclaration.js";
8
6
  import { NamedObjectType_toRdfResourceFunctionOrMethodDeclaration } from "./NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js";
7
+ import { NamedObjectType_toStringFunctionOrMethodDeclarations } from "./NamedObjectType_toStringFunctionOrMethodDeclaration.js";
9
8
  function NamedObjectType_constructorDeclaration() {
10
9
  const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParametersSignature.toList());
11
10
  const parametersType = [];
@@ -56,14 +55,8 @@ ${joinCode([
56
55
  ...NamedObjectType_hashFunctionOrMethodDeclarations.call(this),
57
56
  ...NamedObjectType_toJsonFunctionOrMethodDeclaration.call(this).toList(),
58
57
  ...NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.call(this).toList(),
59
- ...NamedObjectType_toStringMethodDeclaration.call(this).toList(),
58
+ ...NamedObjectType_toStringFunctionOrMethodDeclarations.call(this),
60
59
  ], { on: "\n\n" })}
61
60
  }`;
62
61
  }
63
- function NamedObjectType_toStringMethodDeclaration() {
64
- if (!this.features.has("json")) {
65
- return Maybe.empty();
66
- }
67
- return Maybe.of(code `${this.parentObjectTypes.length > 0 ? "override " : ""}toString(): string { return JSON.stringify(this.${syntheticNamePrefix}toJson()); }`);
68
- }
69
62
  //# sourceMappingURL=NamedObjectType_classDeclaration.js.map
@@ -12,13 +12,22 @@ export function NamedObjectType_jsonSchemaFunctionDeclaration() {
12
12
  }
13
13
  if (this.properties.length > 0) {
14
14
  properties = properties.concat(this.properties
15
- .flatMap((property) => property.jsonZchema.toList())
15
+ .flatMap((property) => property.jsonSchema.toList())
16
16
  .map(({ key, schema }) => code `"${key}": ${schema}`));
17
17
  }
18
+ const meta = {
19
+ id: this.name,
20
+ };
21
+ this.comment.ifJust((description) => {
22
+ meta["description"] = description;
23
+ });
24
+ this.label.ifJust((label) => {
25
+ meta["title"] = label;
26
+ });
18
27
  // ${this.properties.every((property) => !property.mutable) ? `.readonly()` : ""}
19
28
  return Maybe.of(code `\
20
29
  export function schema() {
21
- return ${imports.z}.object({${joinCode(properties, { on: "," })}}) satisfies ${imports.z}.ZodType<${syntheticNamePrefix}Json>;
30
+ return ${imports.z}.object({${joinCode(properties, { on: "," })}}).meta(${meta}) satisfies ${imports.z}.ZodType<${syntheticNamePrefix}Json>;
22
31
  }`);
23
32
  }
24
33
  //# sourceMappingURL=NamedObjectType_jsonSchemaFunctionDeclaration.js.map
@@ -0,0 +1,4 @@
1
+ import type { NamedObjectType } from "../NamedObjectType.js";
2
+ import { type Code } from "../ts-poet-wrapper.js";
3
+ export declare function NamedObjectType_toStringFunctionOrMethodDeclarations(this: NamedObjectType): readonly Code[];
4
+ //# sourceMappingURL=NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts.map
@@ -0,0 +1,62 @@
1
+ import { snippets } from "../snippets.js";
2
+ import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
3
+ import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
4
+ export function NamedObjectType_toStringFunctionOrMethodDeclarations() {
5
+ const propertiesToStringRecordProperties = [];
6
+ if (this.parentObjectTypes.length > 0) {
7
+ switch (this.declarationType) {
8
+ case "class": {
9
+ propertiesToStringRecordProperties.push(code `...super.${syntheticNamePrefix}propertiesToStrings()`);
10
+ break;
11
+ }
12
+ case "interface": {
13
+ for (const parentObjectType of this.parentObjectTypes) {
14
+ propertiesToStringRecordProperties.push(code `...${parentObjectType.staticModuleName}.${syntheticNamePrefix}propertiesToStrings(${this.thisVariable})`);
15
+ }
16
+ break;
17
+ }
18
+ }
19
+ }
20
+ for (const ownProperty of this.ownProperties) {
21
+ ownProperty
22
+ .toStringExpression({
23
+ variables: { value: code `${this.thisVariable}.${ownProperty.name}` },
24
+ })
25
+ .ifJust((ownPropertyToStringExpression) => {
26
+ propertiesToStringRecordProperties.push(code `${literalOf(ownProperty.name)}: ${ownPropertyToStringExpression}`);
27
+ });
28
+ }
29
+ const propertiesToStringsReturnExpression = code `${snippets.compactRecord}({${joinCode(propertiesToStringRecordProperties, { on: "," })}})`;
30
+ const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
31
+ switch (this.declarationType) {
32
+ case "class": {
33
+ let propertiesToStringsPreamble = "";
34
+ let toStringPreamble = "";
35
+ if (this.parentObjectTypes.length > 0) {
36
+ propertiesToStringsPreamble = "override ";
37
+ toStringPreamble = "override ";
38
+ }
39
+ propertiesToStringsPreamble = `protected ${propertiesToStringsPreamble}`;
40
+ return [
41
+ code `${propertiesToStringsPreamble}${syntheticNamePrefix}propertiesToStrings(): Record<string, string> { return ${propertiesToStringsReturnExpression}; }`,
42
+ code `${toStringPreamble}toString(): string { return ${toStringReturnExpression(code `this.${syntheticNamePrefix}propertiesToStrings()`)}; }`,
43
+ ];
44
+ }
45
+ case "interface": {
46
+ return [
47
+ // Use overloads to allow the function to be attached to an instance or used freestanding
48
+ code `\
49
+ export function ${syntheticNamePrefix}propertiesToStrings(${this.thisVariable}: ${this.name}): Record<string, string> {
50
+ return ${propertiesToStringsReturnExpression};
51
+ }`,
52
+ code `\
53
+ export function ${syntheticNamePrefix}toString(this: ${this.name}): string;
54
+ export function ${syntheticNamePrefix}toString(${this.thisVariable}: ${this.name}): string;
55
+ export function ${syntheticNamePrefix}toString(this: ${this.name} | undefined, ${this.thisVariable}?: ${this.name}): string {
56
+ return ${toStringReturnExpression(code `${syntheticNamePrefix}propertiesToStrings((${this.thisVariable} ?? this)!)`)};
57
+ }`,
58
+ ];
59
+ }
60
+ }
61
+ }
62
+ //# sourceMappingURL=NamedObjectType_toStringFunctionOrMethodDeclaration.js.map
@@ -6,14 +6,16 @@ import { AbstractProperty } from "./AbstractProperty.js";
6
6
  export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<TypeT> {
7
7
  private readonly comment;
8
8
  private readonly description;
9
+ private readonly display;
9
10
  private readonly label;
10
11
  readonly kind = "ShaclProperty";
11
12
  readonly mutable: boolean;
12
13
  readonly path: PropertyPath;
13
14
  readonly recursive: boolean;
14
- constructor({ comment, description, label, mutable, path, recursive, ...superParameters }: {
15
+ constructor({ comment, description, display, label, mutable, path, recursive, ...superParameters }: {
15
16
  comment: Maybe<string>;
16
17
  description: Maybe<string>;
18
+ display: boolean;
17
19
  label: Maybe<string>;
18
20
  mutable: boolean;
19
21
  path: PropertyPath;
@@ -28,8 +30,8 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
28
30
  }>;
29
31
  get getAccessorDeclaration(): Maybe<Code>;
30
32
  get graphqlField(): AbstractProperty<TypeT>["graphqlField"];
33
+ get jsonSchema(): AbstractProperty<TypeT>["jsonSchema"];
31
34
  get jsonSignature(): Maybe<Code>;
32
- get jsonZchema(): AbstractProperty<TypeT>["jsonZchema"];
33
35
  protected get schemaObject(): {
34
36
  path: Code | undefined;
35
37
  kind: Code;
@@ -44,6 +46,7 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
44
46
  sparqlWherePatternsExpression({ variables, }: Parameters<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>[0]): ReturnType<AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>;
45
47
  toJsonObjectMemberExpression(parameters: Parameters<AbstractProperty<TypeT>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
46
48
  toRdfRdfResourceValuesStatements({ variables, }: Parameters<AbstractProperty<TypeT>["toRdfRdfResourceValuesStatements"]>[0]): readonly Code[];
49
+ toStringExpression(parameters: Parameters<AbstractProperty<TypeT>["toStringExpression"]>[0]): Maybe<Code>;
47
50
  private propertyPathToCode;
48
51
  }
49
52
  //# sourceMappingURL=ShaclProperty.d.ts.map
@@ -16,15 +16,17 @@ import { AbstractProperty } from "./AbstractProperty.js";
16
16
  export class ShaclProperty extends AbstractProperty {
17
17
  comment;
18
18
  description;
19
+ display;
19
20
  label;
20
21
  kind = "ShaclProperty";
21
22
  mutable;
22
23
  path;
23
24
  recursive;
24
- constructor({ comment, description, label, mutable, path, recursive, ...superParameters }) {
25
+ constructor({ comment, description, display, label, mutable, path, recursive, ...superParameters }) {
25
26
  super(superParameters);
26
27
  this.comment = comment;
27
28
  this.description = description;
29
+ this.display = display;
28
30
  this.label = label;
29
31
  this.mutable = mutable;
30
32
  this.path = path;
@@ -85,22 +87,29 @@ export class ShaclProperty extends AbstractProperty {
85
87
  type: this.type.graphqlType.name,
86
88
  });
87
89
  }
88
- get jsonSignature() {
89
- const typeJsonType = this.type.jsonType();
90
- return Maybe.of(code `${!this.mutable ? "readonly " : ""}${this.name}${typeJsonType.optional ? "?" : ""}: ${typeJsonType.requiredName}`);
91
- }
92
- get jsonZchema() {
90
+ get jsonSchema() {
93
91
  let schema = this.type.jsonSchema({
94
92
  context: "property",
95
93
  });
94
+ const meta = {
95
+ id: this.name,
96
+ };
96
97
  this.comment.alt(this.description).ifJust((description) => {
97
- schema = code `${schema}.describe(${literalOf(description)})`;
98
+ meta["description"] = description;
99
+ });
100
+ this.label.ifJust((label) => {
101
+ meta["title"] = label;
98
102
  });
103
+ schema = code `${schema}.meta(${meta})`;
99
104
  return Maybe.of({
100
105
  key: this.name,
101
106
  schema,
102
107
  });
103
108
  }
109
+ get jsonSignature() {
110
+ const typeJsonType = this.type.jsonType();
111
+ return Maybe.of(code `${!this.mutable ? "readonly " : ""}${this.name}${typeJsonType.optional ? "?" : ""}: ${typeJsonType.requiredName}`);
112
+ }
104
113
  get schemaObject() {
105
114
  return {
106
115
  ...super.schemaObject,
@@ -228,6 +237,12 @@ export class ShaclProperty extends AbstractProperty {
228
237
  })}, ${variables.graph});`,
229
238
  ];
230
239
  }
240
+ toStringExpression(parameters) {
241
+ if (!this.display) {
242
+ return Maybe.empty();
243
+ }
244
+ return Maybe.of(this.type.toStringExpression(parameters));
245
+ }
231
246
  propertyPathToCode(propertyPath) {
232
247
  switch (propertyPath.termType) {
233
248
  case "AlternativePath":
@@ -260,8 +275,8 @@ __decorate([
260
275
  ], ShaclProperty.prototype, "graphqlField", null);
261
276
  __decorate([
262
277
  Memoize()
263
- ], ShaclProperty.prototype, "jsonSignature", null);
278
+ ], ShaclProperty.prototype, "jsonSchema", null);
264
279
  __decorate([
265
280
  Memoize()
266
- ], ShaclProperty.prototype, "jsonZchema", null);
281
+ ], ShaclProperty.prototype, "jsonSignature", null);
267
282
  //# sourceMappingURL=ShaclProperty.js.map
@@ -8,7 +8,7 @@ import { snippets_ToRdfResourceFunction } from "./snippets_ToRdfResourceFunction
8
8
  * Adapter between generated code and the rdfjs-resource PropertyPath.
9
9
  */
10
10
  export const snippets_PropertyPath = conditionalOutput(`${syntheticNamePrefix}PropertyPath`, code `\
11
- export type ${syntheticNamePrefix}PropertyPath = ${imports.RdfjsResourcePropertyPath};
11
+ export type ${syntheticNamePrefix}PropertyPath = ${imports.RdfxResourcePropertyPath};
12
12
 
13
13
  export namespace ${syntheticNamePrefix}PropertyPath {
14
14
  export type $Filter = object;
@@ -17,7 +17,7 @@ export namespace ${syntheticNamePrefix}PropertyPath {
17
17
  return true;
18
18
  }
19
19
 
20
- export const ${syntheticNamePrefix}fromRdfResource: ${snippets_FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfjsResourcePropertyPath}.fromResource;
20
+ export const ${syntheticNamePrefix}fromRdfResource: ${snippets_FromRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.fromResource;
21
21
 
22
22
  export const $fromRdfResourceValues: ${snippets_FromRdfResourceValuesFunction}<${syntheticNamePrefix}PropertyPath> = (values, options) =>
23
23
  values.chain((values) =>
@@ -30,6 +30,8 @@ export namespace ${syntheticNamePrefix}PropertyPath {
30
30
 
31
31
  export const $schema: Readonly<object> = {};
32
32
 
33
- export const ${syntheticNamePrefix}toRdfResource: ${snippets_ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfjsResourcePropertyPath}.toResource;
33
+ export const ${syntheticNamePrefix}toRdfResource: ${snippets_ToRdfResourceFunction}<${syntheticNamePrefix}PropertyPath> = ${imports.RdfxResourcePropertyPath}.toResource;
34
+
35
+ export const ${syntheticNamePrefix}toString = ${imports.RdfxResourcePropertyPath}.toString;
34
36
  }`);
35
37
  //# sourceMappingURL=snippets_PropertyPath.js.map
@@ -0,0 +1,2 @@
1
+ export declare const snippets_compactRecord: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
2
+ //# sourceMappingURL=snippets_compactRecord.d.ts.map
@@ -0,0 +1,16 @@
1
+ import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
2
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
3
+ export const snippets_compactRecord = conditionalOutput(`${syntheticNamePrefix}compactRecord`, code `\
4
+ /**
5
+ * Remove undefined values from a record.
6
+ */
7
+ function ${syntheticNamePrefix}compactRecord<KeyT extends string, ValueT extends {}>(record: Record<KeyT, ValueT | undefined>): Record<KeyT, ValueT> {
8
+ return \
9
+ Object.entries(record).reduce((definedProperties, [propertyName, propertyValue]) => {
10
+ if (propertyValue !== undefined) {
11
+ definedProperties[propertyName as KeyT] = propertyValue as ValueT;
12
+ }
13
+ return definedProperties;
14
+ }, {} as Record<KeyT, ValueT>);
15
+ }`);
16
+ //# sourceMappingURL=snippets_compactRecord.js.map
@@ -1,2 +1,2 @@
1
1
  export declare const snippets_parseIri: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
2
- //# sourceMappingURL=parseIri.d.ts.map
2
+ //# sourceMappingURL=snippets_parseIri.d.ts.map
@@ -9,4 +9,4 @@ export function ${syntheticNamePrefix}parseIri(identifier: string): ${imports.Ei
9
9
  .chain((identifier) => (identifier.termType === "NamedNode") ? ${imports.Right}(identifier) : ${imports.Left}(new Error("expected identifier to be NamedNode"))) \
10
10
  as ${imports.Either}<Error, ${imports.NamedNode}>;
11
11
  }`);
12
- //# sourceMappingURL=parseIri.js.map
12
+ //# sourceMappingURL=snippets_parseIri.js.map
@@ -29,7 +29,7 @@ export declare const imports: {
29
29
  readonly NTriplesTerm: import("ts-poet/build/Import.js").Import;
30
30
  readonly Quad: import("ts-poet/build/Import.js").Import;
31
31
  readonly Quad_Graph: import("ts-poet/build/Import.js").Import;
32
- readonly RdfjsResourcePropertyPath: import("ts-poet/build/Import.js").Import;
32
+ readonly RdfxResourcePropertyPath: import("ts-poet/build/Import.js").Import;
33
33
  readonly Resource: import("ts-poet/build/Import.js").Import;
34
34
  readonly ResourceSet: import("ts-poet/build/Import.js").Import;
35
35
  readonly Right: import("ts-poet/build/Import.js").Import;
@@ -30,7 +30,7 @@ export const imports = {
30
30
  NTriplesTerm: imp("NTriplesTerm@@rdfx/string"),
31
31
  Quad: imp("Quad@@rdfjs/types"),
32
32
  Quad_Graph: imp("Quad_Graph@@rdfjs/types"),
33
- RdfjsResourcePropertyPath: imp("PropertyPath:RdfjsResourcePropertyPath@@rdfx/resource"),
33
+ RdfxResourcePropertyPath: imp("PropertyPath:RdfxResourcePropertyPath@@rdfx/resource"),
34
34
  Resource: imp("Resource@@rdfx/resource"),
35
35
  ResourceSet: imp("ResourceSet@@rdfx/resource"),
36
36
  Right: imp("Right@purify-ts"),
@@ -12,6 +12,7 @@ export declare const snippets: {
12
12
  booleanSparqlWherePatterns: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
13
13
  CollectionFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
14
14
  CollectionSchema: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
15
+ compactRecord: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
15
16
  dateEquals: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
16
17
  DateFilter: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
17
18
  DateSchema: import("ts-poet/build/ConditionalOutput.js").ConditionalOutput;
@@ -1,4 +1,3 @@
1
- import { snippets_parseIri } from "./_snippets/parseIri.js";
2
1
  import { snippets_arrayEquals } from "./_snippets/snippets_arrayEquals.js";
3
2
  import { snippets_arrayIntersection } from "./_snippets/snippets_arrayIntersection.js";
4
3
  import { snippets_BlankNodeFilter } from "./_snippets/snippets_BlankNodeFilter.js";
@@ -12,6 +11,7 @@ import { snippets_booleanEquals } from "./_snippets/snippets_booleanEquals.js";
12
11
  import { snippets_booleanSparqlWherePatterns } from "./_snippets/snippets_booleanSparqlWherePatterns.js";
13
12
  import { snippets_CollectionFilter } from "./_snippets/snippets_CollectionFilter.js";
14
13
  import { snippets_CollectionSchema } from "./_snippets/snippets_CollectionSchema.js";
14
+ import { snippets_compactRecord } from "./_snippets/snippets_compactRecord.js";
15
15
  import { snippets_DateFilter } from "./_snippets/snippets_DateFilter.js";
16
16
  import { snippets_DateSchema } from "./_snippets/snippets_DateSchema.js";
17
17
  import { snippets_DefaultValueSchema } from "./_snippets/snippets_DefaultValueSchema.js";
@@ -76,6 +76,7 @@ import { snippets_PropertiesFromRdfResourceFunction } from "./_snippets/snippets
76
76
  import { snippets_PropertyPath } from "./_snippets/snippets_PropertyPath.js";
77
77
  import { snippets_parseBlankNode } from "./_snippets/snippets_parseBlankNode.js";
78
78
  import { snippets_parseIdentifier } from "./_snippets/snippets_parseIdentifier.js";
79
+ import { snippets_parseIri } from "./_snippets/snippets_parseIri.js";
79
80
  import { snippets_RdfVocabularies } from "./_snippets/snippets_RdfVocabularies.js";
80
81
  import { snippets_ShaclPropertySchema } from "./_snippets/snippets_ShaclPropertySchema.js";
81
82
  import { snippets_SparqlFilterPattern } from "./_snippets/snippets_SparqlFilterPattern.js";
@@ -118,6 +119,7 @@ export const snippets = {
118
119
  booleanSparqlWherePatterns: snippets_booleanSparqlWherePatterns,
119
120
  CollectionFilter: snippets_CollectionFilter,
120
121
  CollectionSchema: snippets_CollectionSchema,
122
+ compactRecord: snippets_compactRecord,
121
123
  dateEquals: snippets_dateEquals,
122
124
  DateFilter: snippets_DateFilter,
123
125
  DateSchema: snippets_DateSchema,
@@ -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 {
@@ -9,6 +9,43 @@ type $CollectionFilter<ItemFilterT> = ItemFilterT & {
9
9
  readonly $maxCount?: number;
10
10
  readonly $minCount?: number;
11
11
  };
12
+ export type $EqualsResult = Either<$EqualsResult.Unequal, true>;
13
+ export declare namespace $EqualsResult {
14
+ const Equal: $EqualsResult;
15
+ function fromBooleanEqualsResult(left: any, right: any, equalsResult: boolean | $EqualsResult): $EqualsResult;
16
+ type Unequal = {
17
+ readonly left: {
18
+ readonly array: readonly any[];
19
+ readonly element: any;
20
+ readonly elementIndex: number;
21
+ };
22
+ readonly right: {
23
+ readonly array: readonly any[];
24
+ readonly unequals: readonly Unequal[];
25
+ };
26
+ readonly type: "array-element";
27
+ } | {
28
+ readonly left: readonly any[];
29
+ readonly right: readonly any[];
30
+ readonly type: "array-length";
31
+ } | {
32
+ readonly left: any;
33
+ readonly right: any;
34
+ readonly type: "boolean";
35
+ } | {
36
+ readonly right: any;
37
+ readonly type: "left-null";
38
+ } | {
39
+ readonly left: any;
40
+ readonly right: any;
41
+ readonly propertyName: string;
42
+ readonly propertyValuesUnequal: Unequal;
43
+ readonly type: "property";
44
+ } | {
45
+ readonly left: any;
46
+ readonly type: "right-null";
47
+ };
48
+ }
12
49
  export type $FromRdfResourceFunction<T> = (resource: Resource, options?: {
13
50
  context?: unknown;
14
51
  graph?: Exclude<Quad_Graph, Variable>;
@@ -50,7 +87,7 @@ type $PropertiesFromRdfResourceFunction<T> = (resource: Resource, options: {
50
87
  objectSet: $ObjectSet;
51
88
  preferredLanguages?: readonly string[];
52
89
  }) => Either<Error, T>;
53
- export type $PropertyPath = RdfjsResourcePropertyPath;
90
+ export type $PropertyPath = RdfxResourcePropertyPath;
54
91
  export declare namespace $PropertyPath {
55
92
  type $Filter = object;
56
93
  function $filter(_filter: $Filter, _value: $PropertyPath): boolean;
@@ -58,6 +95,7 @@ export declare namespace $PropertyPath {
58
95
  const $fromRdfResourceValues: $FromRdfResourceValuesFunction<$PropertyPath>;
59
96
  const $schema: Readonly<object>;
60
97
  const $toRdfResource: $ToRdfResourceFunction<$PropertyPath>;
98
+ const $toString: typeof RdfxResourcePropertyPath.toString;
61
99
  }
62
100
  export interface $ShaclPropertySchema<TypeSchemaT = object> {
63
101
  readonly kind: "Shacl";
@@ -96,7 +134,10 @@ export interface PropertyShape {
96
134
  readonly datatype: Maybe<NamedNode>;
97
135
  readonly deactivated: Maybe<boolean>;
98
136
  readonly defaultValue: Maybe<NamedNode | Literal>;
99
- readonly description: Maybe<string>;
137
+ readonly description: Maybe<string> /**
138
+ * Whether to include this property in a toString()-type display, defaults to false
139
+ */;
140
+ readonly display: boolean;
100
141
  readonly flags: readonly string[];
101
142
  readonly groups: readonly (BlankNode | NamedNode)[];
102
143
  readonly hasValues: readonly (NamedNode | Literal)[];
@@ -137,6 +178,7 @@ export declare namespace PropertyShape {
137
178
  readonly deactivated?: Maybe<boolean> | boolean;
138
179
  readonly defaultValue?: Maybe<NamedNode | Literal> | bigint | boolean | Date | number | string | (NamedNode | Literal);
139
180
  readonly description?: Maybe<string> | string;
181
+ readonly display?: boolean;
140
182
  readonly flags?: readonly string[];
141
183
  readonly groups?: readonly (BlankNode | NamedNode)[] | readonly string[];
142
184
  readonly hasValues?: readonly (NamedNode | Literal)[] | readonly bigint[] | readonly boolean[] | readonly number[] | readonly string[];
@@ -182,6 +224,7 @@ export declare namespace PropertyShape {
182
224
  readonly deactivated?: $MaybeFilter<$BooleanFilter>;
183
225
  readonly defaultValue?: $MaybeFilter<$TermFilter>;
184
226
  readonly description?: $MaybeFilter<$StringFilter>;
227
+ readonly display?: $BooleanFilter;
185
228
  readonly flags?: $CollectionFilter<$StringFilter>;
186
229
  readonly groups?: $CollectionFilter<$IdentifierFilter>;
187
230
  readonly hasValues?: $CollectionFilter<$TermFilter>;
@@ -226,6 +269,7 @@ export declare namespace PropertyShape {
226
269
  deactivated: Maybe<boolean>;
227
270
  defaultValue: Maybe<NamedNode | Literal>;
228
271
  description: Maybe<string>;
272
+ display: boolean;
229
273
  flags: readonly string[];
230
274
  groups: readonly (BlankNode | NamedNode)[];
231
275
  hasValues: readonly (NamedNode | Literal)[];
@@ -344,6 +388,17 @@ export declare namespace PropertyShape {
344
388
  };
345
389
  readonly path: import("@rdfx/data-factory/dist/NamedNode.js").NamedNode<"http://www.w3.org/ns/shacl#description">;
346
390
  };
391
+ readonly display: {
392
+ readonly kind: "Shacl";
393
+ readonly type: () => {
394
+ kind: "DefaultValue";
395
+ item: () => {
396
+ kind: "Boolean";
397
+ };
398
+ defaultValue: import("@rdfx/data-factory/dist/Literal.js").Literal;
399
+ };
400
+ readonly path: import("@rdfx/data-factory/dist/NamedNode.js").NamedNode<"http://purl.org/shaclmate/ontology#display">;
401
+ };
347
402
  readonly flags: {
348
403
  readonly kind: "Shacl";
349
404
  readonly type: () => {
@@ -646,6 +701,9 @@ export declare namespace PropertyShape {
646
701
  };
647
702
  };
648
703
  function $toRdfResource(_propertyShape: PropertyShape, options?: Parameters<$ToRdfResourceFunction<PropertyShape>>[1]): Resource;
704
+ function $propertiesToStrings(_propertyShape: PropertyShape): Record<string, string>;
705
+ function $toString(this: PropertyShape): string;
706
+ function $toString(_propertyShape: PropertyShape): string;
649
707
  }
650
708
  export interface PropertyGroup {
651
709
  readonly $identifier: PropertyGroup.$Identifier;
@@ -718,6 +776,9 @@ export declare namespace PropertyGroup {
718
776
  };
719
777
  };
720
778
  function $toRdfResource(_propertyGroup: PropertyGroup, options?: Parameters<$ToRdfResourceFunction<PropertyGroup>>[1]): Resource;
779
+ function $propertiesToStrings(_propertyGroup: PropertyGroup): Record<string, string>;
780
+ function $toString(this: PropertyGroup): string;
781
+ function $toString(_propertyGroup: PropertyGroup): string;
721
782
  }
722
783
  export interface Ontology {
723
784
  readonly $identifier: Ontology.$Identifier;
@@ -849,6 +910,9 @@ export declare namespace Ontology {
849
910
  };
850
911
  };
851
912
  function $toRdfResource(_ontology: Ontology, options?: Parameters<$ToRdfResourceFunction<Ontology>>[1]): Resource;
913
+ function $propertiesToStrings(_ontology: Ontology): Record<string, string>;
914
+ function $toString(this: Ontology): string;
915
+ function $toString(_ontology: Ontology): string;
852
916
  }
853
917
  export interface NodeShape {
854
918
  readonly $identifier: NodeShape.$Identifier;
@@ -1518,6 +1582,9 @@ export declare namespace NodeShape {
1518
1582
  };
1519
1583
  };
1520
1584
  function $toRdfResource(_nodeShape: NodeShape, options?: Parameters<$ToRdfResourceFunction<NodeShape>>[1]): Resource;
1585
+ function $propertiesToStrings(_nodeShape: NodeShape): Record<string, string>;
1586
+ function $toString(this: NodeShape): string;
1587
+ function $toString(_nodeShape: NodeShape): string;
1521
1588
  }
1522
1589
  export type Shape = NodeShape | PropertyShape;
1523
1590
  export declare namespace Shape {
@@ -2102,6 +2169,17 @@ export declare namespace Shape {
2102
2169
  };
2103
2170
  readonly path: import("@rdfx/data-factory/dist/NamedNode.js").NamedNode<"http://www.w3.org/ns/shacl#description">;
2104
2171
  };
2172
+ readonly display: {
2173
+ readonly kind: "Shacl";
2174
+ readonly type: () => {
2175
+ kind: "DefaultValue";
2176
+ item: () => {
2177
+ kind: "Boolean";
2178
+ };
2179
+ defaultValue: import("@rdfx/data-factory/dist/Literal.js").Literal;
2180
+ };
2181
+ readonly path: import("@rdfx/data-factory/dist/NamedNode.js").NamedNode<"http://purl.org/shaclmate/ontology#display">;
2182
+ };
2105
2183
  readonly flags: {
2106
2184
  readonly kind: "Shacl";
2107
2185
  readonly type: () => {
@@ -2702,6 +2780,7 @@ export declare namespace Shape {
2702
2780
  resource: Resource;
2703
2781
  resourceSet: ResourceSet;
2704
2782
  }) => (BlankNode | NamedNode)[];
2783
+ const $toString: (value: Shape) => string;
2705
2784
  function isShape(object: $Object): object is Shape;
2706
2785
  }
2707
2786
  export type $Object = NodeShape | Ontology | PropertyGroup | PropertyShape;
@@ -3412,6 +3491,17 @@ export declare namespace $Object {
3412
3491
  };
3413
3492
  readonly path: import("@rdfx/data-factory/dist/NamedNode.js").NamedNode<"http://www.w3.org/ns/shacl#description">;
3414
3493
  };
3494
+ readonly display: {
3495
+ readonly kind: "Shacl";
3496
+ readonly type: () => {
3497
+ kind: "DefaultValue";
3498
+ item: () => {
3499
+ kind: "Boolean";
3500
+ };
3501
+ defaultValue: import("@rdfx/data-factory/dist/Literal.js").Literal;
3502
+ };
3503
+ readonly path: import("@rdfx/data-factory/dist/NamedNode.js").NamedNode<"http://purl.org/shaclmate/ontology#display">;
3504
+ };
3415
3505
  readonly flags: {
3416
3506
  readonly kind: "Shacl";
3417
3507
  readonly type: () => {
@@ -3746,6 +3836,7 @@ export declare namespace $Object {
3746
3836
  resource: Resource;
3747
3837
  resourceSet: ResourceSet;
3748
3838
  }) => (BlankNode | NamedNode)[];
3839
+ const $toString: (value: $Object) => string;
3749
3840
  }
3750
3841
  export interface $ObjectSet {
3751
3842
  nodeShape(identifier: NodeShape.$Identifier, options?: {