@shaclmate/compiler 4.0.21 → 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 (53) 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_toRdfResourceFunctionOrMethodDeclaration.js +1 -1
  36. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +4 -0
  37. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +62 -0
  38. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +5 -2
  39. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +24 -9
  40. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +5 -3
  41. package/dist/generators/ts/_snippets/snippets_compactRecord.d.ts +2 -0
  42. package/dist/generators/ts/_snippets/snippets_compactRecord.js +16 -0
  43. package/dist/generators/ts/_snippets/{parseIri.d.ts → snippets_parseIri.d.ts} +1 -1
  44. package/dist/generators/ts/_snippets/{parseIri.js → snippets_parseIri.js} +1 -1
  45. package/dist/generators/ts/imports.d.ts +1 -1
  46. package/dist/generators/ts/imports.js +1 -1
  47. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +1 -1
  48. package/dist/generators/ts/snippets.d.ts +1 -0
  49. package/dist/generators/ts/snippets.js +3 -1
  50. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +1 -1
  51. package/dist/input/generated.d.ts +110 -7
  52. package/dist/input/generated.js +203 -26
  53. package/package.json +6 -6
@@ -252,6 +252,7 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
252
252
  return Either.of(new ast.ObjectType.Property({
253
253
  comment: propertyShape.comment,
254
254
  description: propertyShape.description,
255
+ display: propertyShape.display,
255
256
  label: propertyShape.label,
256
257
  mutable: propertyShape.mutable.orDefault(false),
257
258
  name: propertyName.call(this, objectType, propertyShape),
@@ -133,6 +133,10 @@ export declare namespace ObjectType {
133
133
  * Description from sh:description.
134
134
  */
135
135
  readonly description: Maybe<string>;
136
+ /**
137
+ * Should the property and its value be displayed in a toString()-type representation?
138
+ */
139
+ readonly display: boolean;
136
140
  /**
137
141
  * Human-readable label from rdfs:label.
138
142
  */
@@ -170,9 +174,10 @@ export declare namespace ObjectType {
170
174
  * Visibility: private, protected, public.
171
175
  */
172
176
  readonly visibility: Visibility;
173
- constructor({ comment, description, label, mutable, name, objectType, order, path, shapeIdentifier, type, visibility, }: {
177
+ constructor({ comment, description, display, label, mutable, name, objectType, order, path, shapeIdentifier, type, visibility, }: {
174
178
  comment: Maybe<string>;
175
179
  description: Maybe<string>;
180
+ display: boolean;
176
181
  label: Maybe<string>;
177
182
  mutable: boolean;
178
183
  name: string;
@@ -193,6 +193,10 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
193
193
  * Description from sh:description.
194
194
  */
195
195
  description;
196
+ /**
197
+ * Should the property and its value be displayed in a toString()-type representation?
198
+ */
199
+ display;
196
200
  /**
197
201
  * Human-readable label from rdfs:label.
198
202
  */
@@ -230,9 +234,10 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
230
234
  * Visibility: private, protected, public.
231
235
  */
232
236
  visibility;
233
- constructor({ comment, description, label, mutable, name, objectType, order, path, shapeIdentifier, type, visibility, }) {
237
+ constructor({ comment, description, display, label, mutable, name, objectType, order, path, shapeIdentifier, type, visibility, }) {
234
238
  this.comment = comment;
235
239
  this.description = description;
240
+ this.display = display;
236
241
  this.label = label;
237
242
  this.mutable = mutable;
238
243
  this.name = name;
@@ -45,6 +45,7 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
45
45
  jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
46
46
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
47
47
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
48
+ toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
48
49
  protected resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }: {
49
50
  resolvedNamedObjectUnionType: NamedObjectUnionType;
50
51
  partialNamedObjectUnionType: NamedObjectUnionType;
@@ -113,6 +113,13 @@ export class AbstractLazyObjectType extends AbstractType {
113
113
  },
114
114
  });
115
115
  }
116
+ toStringExpression({ variables, }) {
117
+ return this.partialType.toStringExpression({
118
+ variables: {
119
+ value: code `${variables.value}.${this.runtimeClass.partialPropertyName}`,
120
+ },
121
+ });
122
+ }
116
123
  resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }) {
117
124
  invariant(resolvedNamedObjectUnionType.members.length ===
118
125
  partialNamedObjectUnionType.members.length);
@@ -15,8 +15,8 @@ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> e
15
15
  get equalsFunction(): Code;
16
16
  get filterFunction(): Code;
17
17
  get filterType(): Code;
18
- get jsonTypeAliasDeclaration(): Code;
19
18
  get jsonSchemaFunctionDeclaration(): Code;
19
+ get jsonTypeAliasDeclaration(): Code;
20
20
  get name(): string;
21
21
  get staticModuleName(): string;
22
22
  get valueSparqlConstructTriplesFunction(): Code;
@@ -25,9 +25,10 @@ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> e
25
25
  fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
26
26
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
27
27
  hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
28
- jsonType(): AbstractType.JsonType;
29
28
  jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
29
+ jsonType(): AbstractType.JsonType;
30
30
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
31
31
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
32
+ toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
32
33
  }
33
34
  //# sourceMappingURL=AbstractNamedUnionType.d.ts.map
@@ -47,12 +47,21 @@ ${joinCode(staticModuleDeclarations
47
47
  get filterType() {
48
48
  return code `${this.staticModuleName}.${syntheticNamePrefix}Filter`;
49
49
  }
50
+ get jsonSchemaFunctionDeclaration() {
51
+ const meta = {
52
+ id: this.name,
53
+ };
54
+ this.comment.ifJust((description) => {
55
+ meta["description"] = description;
56
+ });
57
+ this.label.ifJust((label) => {
58
+ meta["title"] = label;
59
+ });
60
+ return code `export const schema = () => ${this.inlineJsonSchema}.meta(${meta});`;
61
+ }
50
62
  get jsonTypeAliasDeclaration() {
51
63
  return code `export type ${syntheticNamePrefix}Json = ${this.inlineJsonType.name}`;
52
64
  }
53
- get jsonSchemaFunctionDeclaration() {
54
- return code `export const schema = () => ${this.inlineJsonSchema};`;
55
- }
56
65
  get name() {
57
66
  return this._name;
58
67
  }
@@ -115,6 +124,8 @@ export namespace ${syntheticNamePrefix}Json {
115
124
  staticModuleDeclarations[`${syntheticNamePrefix}valueSparqlWherePatterns`] =
116
125
  code `export const ${syntheticNamePrefix}valueSparqlWherePatterns: ${snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
117
126
  }
127
+ staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
128
+ code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
118
129
  return staticModuleDeclarations;
119
130
  }
120
131
  fromJsonExpression({ variables, }) {
@@ -138,12 +149,6 @@ export namespace ${syntheticNamePrefix}Json {
138
149
  }
139
150
  return this.inlineHashStatements({ depth, variables });
140
151
  }
141
- jsonType() {
142
- if (this.features.has("json")) {
143
- return new AbstractType.JsonType(`${this.staticModuleName}.${syntheticNamePrefix}Json`);
144
- }
145
- return this.inlineJsonType;
146
- }
147
152
  jsonSchema({ context, }) {
148
153
  if (this.features.has("json")) {
149
154
  const expression = code `${this.staticModuleName}.${syntheticNamePrefix}Json.schema()`;
@@ -154,6 +159,12 @@ export namespace ${syntheticNamePrefix}Json {
154
159
  }
155
160
  return this.inlineJsonSchema;
156
161
  }
162
+ jsonType() {
163
+ if (this.features.has("json")) {
164
+ return new AbstractType.JsonType(`${this.staticModuleName}.${syntheticNamePrefix}Json`);
165
+ }
166
+ return this.inlineJsonType;
167
+ }
157
168
  toJsonExpression({ variables, }) {
158
169
  if (this.features.has("json")) {
159
170
  return code `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
@@ -167,6 +178,9 @@ export namespace ${syntheticNamePrefix}Json {
167
178
  }
168
179
  return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
169
180
  }
181
+ toStringExpression({ variables, }) {
182
+ return code `${this.staticModuleName}.${syntheticNamePrefix}toString(${variables.value})`;
183
+ }
170
184
  }
171
185
  __decorate([
172
186
  Memoize()
@@ -38,6 +38,7 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
38
38
  hashStatements({ variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
39
39
  jsonUiSchemaElement(): Maybe<Code>;
40
40
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
41
+ toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
41
42
  /**
42
43
  * The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
43
44
  *
@@ -127,6 +127,9 @@ export class AbstractTermType extends AbstractType {
127
127
  toRdfResourceValuesExpression({ variables, }) {
128
128
  return code `[${variables.value}]`;
129
129
  }
130
+ toStringExpression({ variables, }) {
131
+ return code `${variables.value}.toString()`;
132
+ }
130
133
  /**
131
134
  * The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
132
135
  *
@@ -79,6 +79,10 @@ export declare abstract class AbstractType {
79
79
  * TypeScript type describing .schema.
80
80
  */
81
81
  abstract readonly schemaType: Code;
82
+ /**
83
+ * The type(s) of the array elements produced by the toRdfResourceValuesExpression.
84
+ */
85
+ abstract readonly toRdfResourceValueTypes: ReadonlySet<"BlankNode" | "NamedNode" | "Literal">;
82
86
  /**
83
87
  * JavaScript typeof(s) the type.
84
88
  */
@@ -217,10 +221,6 @@ export declare abstract class AbstractType {
217
221
  value: Code;
218
222
  };
219
223
  }): Code;
220
- /**
221
- * The type(s) of the array elements produced by the toRdfResourceValuesExpression.
222
- */
223
- abstract readonly toRdfResourceValueTypes: ReadonlySet<"BlankNode" | "NamedNode" | "Literal">;
224
224
  /**
225
225
  * An expression that converts a property value of this type to a value or an array of values that can be .add'd to a Resource with
226
226
  * resource.add(predicate, convertedValue, graph)
@@ -241,6 +241,14 @@ export declare abstract class AbstractType {
241
241
  value: Code;
242
242
  };
243
243
  }): Code;
244
+ /**
245
+ * An expression that converts a value of this type to a human-readable string (toString).
246
+ */
247
+ abstract toStringExpression(parameters: {
248
+ variables: {
249
+ value: Code;
250
+ };
251
+ }): Code;
244
252
  }
245
253
  export declare namespace AbstractType {
246
254
  interface Conversion {
@@ -37,6 +37,7 @@ export declare abstract class AbstractUnionType<MemberTypeT extends Type> extend
37
37
  protected get inlineName(): Code;
38
38
  protected get inlineToJsonFunction(): Code;
39
39
  protected get inlineToRdfResourceValuesFunction(): Code;
40
+ protected get inlineToStringFunction(): Code;
40
41
  protected get inlineValueSparqlConstructTriplesFunction(): Code;
41
42
  protected get inlineValueSparqlWherePatternsFunction(): Code;
42
43
  protected get schemaObject(): {
@@ -430,6 +430,16 @@ ${joinCode(this.concreteMembers.map(({ type, unwrap, typeCheck }) => code `if ($
430
430
 
431
431
  throw new Error("unable to serialize to RDF");
432
432
  }) satisfies ${snippets.ToRdfResourceValuesFunction}<${this.name}>)`;
433
+ }
434
+ get inlineToStringFunction() {
435
+ return code `\
436
+ ((value: ${this.name}): string => {
437
+ ${joinCode(this.concreteMembers.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `value`)}) { return ${type.toStringExpression({
438
+ variables: { value: unwrap(code `value`) },
439
+ })}; }`))}
440
+
441
+ throw new Error("unable to serialize to string");
442
+ })`;
433
443
  }
434
444
  get inlineValueSparqlConstructTriplesFunction() {
435
445
  return code `\
@@ -18,9 +18,10 @@ export declare class AnonymousUnionType extends AbstractUnionType<Type> {
18
18
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
19
19
  graphqlResolveExpression(_parameters: Parameters<AbstractType["graphqlResolveExpression"]>[0]): Code;
20
20
  hashStatements(parameters: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
21
- jsonType(): AbstractType.JsonType;
22
21
  jsonSchema(_parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
22
+ jsonType(): AbstractType.JsonType;
23
23
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
24
24
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
25
+ toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
25
26
  }
26
27
  //# sourceMappingURL=AnonymousUnionType.d.ts.map
@@ -39,12 +39,12 @@ export class AnonymousUnionType extends AbstractUnionType {
39
39
  hashStatements(parameters) {
40
40
  return this.inlineHashStatements(parameters);
41
41
  }
42
- jsonType() {
43
- return this.inlineJsonType;
44
- }
45
42
  jsonSchema(_parameters) {
46
43
  return this.inlineJsonSchema;
47
44
  }
45
+ jsonType() {
46
+ return this.inlineJsonType;
47
+ }
48
48
  toJsonExpression({ variables, }) {
49
49
  return code `${this.inlineToJsonFunction}(${variables.value})`;
50
50
  }
@@ -52,5 +52,8 @@ export class AnonymousUnionType extends AbstractUnionType {
52
52
  const { value: valueVariable, ...otherVariables } = variables;
53
53
  return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
54
54
  }
55
+ toStringExpression({ variables, }) {
56
+ return code `${this.inlineToStringFunction}(${variables.value})`;
57
+ }
55
58
  }
56
59
  //# sourceMappingURL=AnonymousUnionType.js.map
@@ -35,11 +35,12 @@ export declare class DefaultValueType<ItemTypeT extends DefaultValueType.ItemTyp
35
35
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
36
36
  graphqlResolveExpression(parameters: Parameters<AbstractContainerType<ItemTypeT>["graphqlResolveExpression"]>[0]): Code;
37
37
  hashStatements(parameters: Parameters<AbstractContainerType<ItemTypeT>["hashStatements"]>[0]): readonly Code[];
38
+ jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
38
39
  jsonType(parameters?: Parameters<AbstractContainerType<ItemTypeT>["jsonType"]>[0]): AbstractType.JsonType;
39
40
  jsonUiSchemaElement(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
40
- jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
41
41
  toJsonExpression(parameters: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
42
42
  toRdfResourceValuesExpression(parameters: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
43
+ toStringExpression(parameters: Parameters<AbstractType["toStringExpression"]>[0]): Code;
43
44
  }
44
45
  export declare namespace DefaultValueType {
45
46
  type ItemType = Exclude<AbstractContainerType.ItemType, BlankNodeType>;
@@ -133,15 +133,15 @@ export class DefaultValueType extends AbstractContainerType {
133
133
  hashStatements(parameters) {
134
134
  return this.itemType.hashStatements(parameters);
135
135
  }
136
+ jsonSchema(parameters) {
137
+ return this.itemType.jsonSchema(parameters);
138
+ }
136
139
  jsonType(parameters) {
137
140
  return this.itemType.jsonType(parameters);
138
141
  }
139
142
  jsonUiSchemaElement(parameters) {
140
143
  return this.itemType.jsonUiSchemaElement(parameters);
141
144
  }
142
- jsonSchema(parameters) {
143
- return this.itemType.jsonSchema(parameters);
144
- }
145
145
  toJsonExpression(parameters) {
146
146
  return this.itemType.toJsonExpression(parameters);
147
147
  }
@@ -151,6 +151,9 @@ export class DefaultValueType extends AbstractContainerType {
151
151
  .map((defaultValuePrimitiveExpression) => code `${this.itemType.equalsFunction}(${variables.value}, ${defaultValuePrimitiveExpression}).isLeft() ? ${this.itemType.toRdfResourceValuesExpression(parameters)} : []`)
152
152
  .orDefault(code `${this.itemType.toRdfResourceValuesExpression(parameters)}.filter(value => !value.equals(${this.defaultValueTermExpression}))`);
153
153
  }
154
+ toStringExpression(parameters) {
155
+ return this.itemType.toStringExpression(parameters);
156
+ }
154
157
  }
155
158
  __decorate([
156
159
  Memoize()
@@ -36,6 +36,7 @@ export declare class ListType<ItemTypeT extends ListType.ItemType> extends Abstr
36
36
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
37
37
  jsonType(): AbstractCollectionType.JsonType;
38
38
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toRdfResourceValuesExpression"]>[0]): Code;
39
+ toStringExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toStringExpression"]>[0]): Code;
39
40
  }
40
41
  export declare namespace ListType {
41
42
  type ItemType = AnonymousUnionType | BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | LiteralType | NamedObjectUnionType | NamedUnionType | NamedObjectType | StringType | TermType;
@@ -108,6 +108,9 @@ export class ListType extends AbstractCollectionType {
108
108
  },
109
109
  ).listResource.identifier : ${rdfjsTermExpression(rdf.nil, { logger: this.logger })}]`;
110
110
  }
111
+ toStringExpression({ variables, }) {
112
+ return code `\`[\${${variables.value}.map(item => (${this.itemType.toStringExpression({ variables: { value: code `item` } })}))}]\``;
113
+ }
111
114
  }
112
115
  __decorate([
113
116
  Memoize()
@@ -97,6 +97,7 @@ export declare class NamedObjectType extends AbstractType {
97
97
  parameters: Code;
98
98
  }): Code;
99
99
  toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
100
+ toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
100
101
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
101
102
  protected ensureAtMostOneSuperObjectType(): void;
102
103
  private readonly lazyAncestorObjectTypes;
@@ -39,6 +39,7 @@ import { NamedObjectType_sparqlConstructQueryFunctionDeclaration } from "./_Name
39
39
  import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
40
40
  import { NamedObjectType_toJsonFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js";
41
41
  import { NamedObjectType_toRdfResourceFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js";
42
+ import { NamedObjectType_toStringFunctionOrMethodDeclarations } from "./_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js";
42
43
  import { NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js";
43
44
  import { NamedObjectType_valueSparqlWherePatternsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js";
44
45
  import { ShaclProperty as _ShaclProperty } from "./_NamedObjectType/ShaclProperty.js";
@@ -135,6 +136,8 @@ export class NamedObjectType extends AbstractType {
135
136
  ? NamedObjectType_toJsonFunctionOrMethodDeclaration.call(this).toList()
136
137
  : []), ...(this.declarationType === "interface"
137
138
  ? NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.call(this).toList()
139
+ : []), ...(this.declarationType === "interface"
140
+ ? NamedObjectType_toStringFunctionOrMethodDeclarations.call(this)
138
141
  : []), ...NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.bind(this)().toList());
139
142
  if (staticModuleDeclarations.length > 0) {
140
143
  declarations.push(code `\
@@ -307,6 +310,14 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
307
310
  return code `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
308
311
  }
309
312
  }
313
+ toStringExpression({ variables, }) {
314
+ switch (this.declarationType) {
315
+ case "class":
316
+ return code `${variables.value}.toString()`;
317
+ case "interface":
318
+ return code `${this.staticModuleName}.${syntheticNamePrefix}toString(${variables.value})`;
319
+ }
320
+ }
310
321
  toRdfResourceValuesExpression({ variables, }) {
311
322
  switch (this.declarationType) {
312
323
  case "class":
@@ -29,6 +29,7 @@ export declare class OptionType<ItemTypeT extends OptionType.ItemType> extends A
29
29
  jsonSchema(parameters: Parameters<AbstractContainerType<ItemTypeT>["jsonSchema"]>[0]): Code;
30
30
  toJsonExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["toJsonExpression"]>[0]): Code;
31
31
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["toRdfResourceValuesExpression"]>[0]): Code;
32
+ toStringExpression({ variables, }: Parameters<AbstractContainerType<ItemTypeT>["toStringExpression"]>[0]): Code;
32
33
  }
33
34
  export declare namespace OptionType {
34
35
  type ItemType = AbstractContainerType.ItemType;
@@ -138,6 +138,9 @@ export class OptionType extends AbstractContainerType {
138
138
  }
139
139
  return toRdfExpression;
140
140
  }
141
+ toStringExpression({ variables, }) {
142
+ return code `${variables.value}.map(item => (${this.itemType.toStringExpression({ variables: { value: code `item` } })})).extract()`;
143
+ }
141
144
  }
142
145
  __decorate([
143
146
  Memoize()
@@ -9,6 +9,7 @@ export declare class SetType<ItemTypeT extends SetType.ItemType> extends Abstrac
9
9
  fromRdfResourceValuesExpression(parameters: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
10
10
  jsonType(): AbstractCollectionType.JsonType;
11
11
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toRdfResourceValuesExpression"]>[0]): Code;
12
+ toStringExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toStringExpression"]>[0]): Code;
12
13
  }
13
14
  export declare namespace SetType {
14
15
  type ItemType = AbstractCollectionType.ItemType;
@@ -57,6 +57,9 @@ export class SetType extends AbstractCollectionType {
57
57
  variables: { ...variables, value: code `item` },
58
58
  })})`;
59
59
  }
60
+ toStringExpression({ variables, }) {
61
+ return code `(${variables.value}.length > 0 ? \`[\${${variables.value}.map(item => (${this.itemType.toStringExpression({ variables: { value: code `item` } })}))}]\` : undefined)`;
62
+ }
60
63
  }
61
64
  __decorate([
62
65
  Memoize()
@@ -455,6 +455,7 @@ export class TypeFactory {
455
455
  const property = new NamedObjectType.ShaclProperty({
456
456
  comment: astObjectTypeProperty.comment,
457
457
  description: astObjectTypeProperty.description,
458
+ display: astObjectTypeProperty.display,
458
459
  label: astObjectTypeProperty.label,
459
460
  logger: this.logger,
460
461
  mutable: astObjectTypeProperty.mutable,
@@ -42,17 +42,17 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
42
42
  resolve: Code;
43
43
  type: Code;
44
44
  }>;
45
- /**
46
- * Signature of the property when serialized to JSON (the type of toJsonObjectMember).
47
- */
48
- abstract readonly jsonSignature: Maybe<Code>;
49
45
  /**
50
46
  * zod Object key: schema pair on the property serialized by toJsonObjectMember.
51
47
  */
52
- abstract readonly jsonZchema: Maybe<{
48
+ abstract readonly jsonSchema: Maybe<{
53
49
  readonly key: string;
54
50
  readonly schema: Code;
55
51
  }>;
52
+ /**
53
+ * Signature of the property when serialized to JSON (the type of toJsonObjectMember).
54
+ */
55
+ abstract readonly jsonSignature: Maybe<Code>;
56
56
  /**
57
57
  * Property type discriminator e.g., "ShaclProperty".
58
58
  */
@@ -190,5 +190,13 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
190
190
  abstract toRdfRdfResourceValuesStatements(parameters: {
191
191
  variables: Omit<Parameters<Type["toRdfResourceValuesExpression"]>[0]["variables"], "propertyPath">;
192
192
  }): readonly Code[];
193
+ /**
194
+ * Expression to serialize this property to a human-readable string (toString).
195
+ */
196
+ abstract toStringExpression(parameters: {
197
+ variables: {
198
+ value: Code;
199
+ };
200
+ }): Maybe<Code>;
193
201
  }
194
202
  //# sourceMappingURL=AbstractProperty.d.ts.map
@@ -14,8 +14,8 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
14
14
  type: DiscriminantProperty.Type;
15
15
  } & ConstructorParameters<typeof AbstractProperty>[0]);
16
16
  get declaration(): Maybe<Code>;
17
+ get jsonSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonSchema"];
17
18
  get jsonSignature(): Maybe<Code>;
18
- get jsonZchema(): AbstractProperty<DiscriminantProperty.Type>["jsonZchema"];
19
19
  private get abstract();
20
20
  private get initializer();
21
21
  private get override();
@@ -28,6 +28,7 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
28
28
  sparqlWherePatternsExpression(): ReturnType<AbstractProperty<DiscriminantProperty.Type>["sparqlWherePatternsExpression"]>;
29
29
  toJsonObjectMemberExpression({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
30
30
  toRdfRdfResourceValuesStatements(): readonly Code[];
31
+ toStringExpression(): Maybe<Code>;
31
32
  }
32
33
  export declare namespace DiscriminantProperty {
33
34
  class Type {
@@ -36,10 +36,7 @@ export class DiscriminantProperty extends AbstractProperty {
36
36
  throw new Error("should never reach this point");
37
37
  }
38
38
  }
39
- get jsonSignature() {
40
- return Maybe.of(code `readonly ${this.name}: ${this.type.name}`);
41
- }
42
- get jsonZchema() {
39
+ get jsonSchema() {
43
40
  return Maybe.of({
44
41
  key: this.name,
45
42
  schema: this.type.values.length > 1
@@ -47,6 +44,9 @@ export class DiscriminantProperty extends AbstractProperty {
47
44
  : code `${imports.z}.literal(${literalOf(this.type.values[0])})`,
48
45
  });
49
46
  }
47
+ get jsonSignature() {
48
+ return Maybe.of(code `readonly ${this.name}: ${this.type.name}`);
49
+ }
50
50
  get abstract() {
51
51
  return this.namedObjectType.abstract;
52
52
  }
@@ -98,13 +98,16 @@ export class DiscriminantProperty extends AbstractProperty {
98
98
  toRdfRdfResourceValuesStatements() {
99
99
  return [];
100
100
  }
101
+ toStringExpression() {
102
+ return Maybe.empty();
103
+ }
101
104
  }
102
105
  __decorate([
103
106
  Memoize()
104
- ], DiscriminantProperty.prototype, "jsonSignature", null);
107
+ ], DiscriminantProperty.prototype, "jsonSchema", null);
105
108
  __decorate([
106
109
  Memoize()
107
- ], DiscriminantProperty.prototype, "jsonZchema", null);
110
+ ], DiscriminantProperty.prototype, "jsonSignature", null);
108
111
  (function (DiscriminantProperty) {
109
112
  class Type {
110
113
  filterFunction = code `nonextant`;
@@ -6,8 +6,8 @@ export declare class IdentifierPrefixProperty extends AbstractProperty<StringTyp
6
6
  private readonly own;
7
7
  readonly filterProperty: AbstractProperty<StringType>["filterProperty"];
8
8
  readonly graphqlField: AbstractProperty<StringType>["graphqlField"];
9
+ readonly jsonSchema: AbstractProperty<StringType>["jsonSchema"];
9
10
  readonly jsonSignature: Maybe<Code>;
10
- readonly jsonZchema: AbstractProperty<StringType>["jsonZchema"];
11
11
  readonly kind = "IdentifierPrefixProperty";
12
12
  readonly mutable = false;
13
13
  readonly recursive = false;
@@ -28,5 +28,6 @@ export declare class IdentifierPrefixProperty extends AbstractProperty<StringTyp
28
28
  sparqlWherePatternsExpression(): ReturnType<AbstractProperty<StringType>["sparqlWherePatternsExpression"]>;
29
29
  toJsonObjectMemberExpression(): Maybe<Code>;
30
30
  toRdfRdfResourceValuesStatements(): readonly Code[];
31
+ toStringExpression(): Maybe<Code>;
31
32
  }
32
33
  //# sourceMappingURL=IdentifierPrefixProperty.d.ts.map
@@ -15,8 +15,8 @@ export class IdentifierPrefixProperty extends AbstractProperty {
15
15
  own;
16
16
  filterProperty = Maybe.empty();
17
17
  graphqlField = Maybe.empty();
18
+ jsonSchema = Maybe.empty();
18
19
  jsonSignature = Maybe.empty();
19
- jsonZchema = Maybe.empty();
20
20
  kind = "IdentifierPrefixProperty";
21
21
  mutable = false;
22
22
  recursive = false;
@@ -82,6 +82,9 @@ protected ${!this.own ? "override " : ""} get ${this.name}(): ${this.type.name}
82
82
  toRdfRdfResourceValuesStatements() {
83
83
  return [];
84
84
  }
85
+ toStringExpression() {
86
+ return Maybe.empty();
87
+ }
85
88
  }
86
89
  __decorate([
87
90
  Memoize()
@@ -28,13 +28,14 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
28
28
  get getAccessorDeclaration(): Maybe<Code>;
29
29
  get graphqlField(): AbstractProperty<IdentifierType>["graphqlField"];
30
30
  get jsonSignature(): Maybe<Code>;
31
- get jsonZchema(): AbstractProperty<IdentifierType>["jsonZchema"];
31
+ get jsonSchema(): AbstractProperty<IdentifierType>["jsonSchema"];
32
32
  private get abstract();
33
33
  private get declarationModifiers();
34
34
  private get declarationName();
35
35
  private get override();
36
36
  constructorStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorStatements"]>[0]): readonly Code[];
37
37
  fromJsonStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonStatements"]>[0]): readonly Code[];
38
+ toStringExpression(parameters: Parameters<AbstractProperty<IdentifierType>["toStringExpression"]>[0]): Maybe<Code>;
38
39
  fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromRdfResourceValuesExpression"]>[0]): Maybe<Code>;
39
40
  hashStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["hashStatements"]>[0]): readonly Code[];
40
41
  jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
@@ -147,7 +147,7 @@ export class IdentifierProperty extends AbstractProperty {
147
147
  }
148
148
  return Maybe.of(code `readonly "@id": string`);
149
149
  }
150
- get jsonZchema() {
150
+ get jsonSchema() {
151
151
  let schema;
152
152
  if (this.type.in_.length > 0 && this.type.kind === "IriType") {
153
153
  // Treat sh:in as a union of the IRIs
@@ -279,6 +279,9 @@ export class IdentifierProperty extends AbstractProperty {
279
279
  code `const ${this.name} = ${this.type.fromJsonExpression({ variables: { value: variables.jsonObject } })};`,
280
280
  ];
281
281
  }
282
+ toStringExpression(parameters) {
283
+ return Maybe.of(this.type.toStringExpression(parameters));
284
+ }
282
285
  fromRdfResourceValuesExpression({ variables, }) {
283
286
  return Maybe.of(code `${this.type.fromRdfResourceValuesExpression({
284
287
  variables: {
@@ -358,7 +361,7 @@ __decorate([
358
361
  ], IdentifierProperty.prototype, "jsonSignature", null);
359
362
  __decorate([
360
363
  Memoize()
361
- ], IdentifierProperty.prototype, "jsonZchema", null);
364
+ ], IdentifierProperty.prototype, "jsonSchema", null);
362
365
  __decorate([
363
366
  Memoize()
364
367
  ], IdentifierProperty.prototype, "declarationModifiers", null);