@shaclmate/compiler 4.0.98 → 4.0.100

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 (96) hide show
  1. package/dist/generators/ts/AbstractBuiltinType.d.ts +23 -0
  2. package/dist/generators/ts/AbstractBuiltinType.js +18 -0
  3. package/dist/generators/ts/AbstractCollectionType.d.ts +2 -1
  4. package/dist/generators/ts/AbstractCollectionType.js +10 -5
  5. package/dist/generators/ts/AbstractCompoundType.d.ts +11 -8
  6. package/dist/generators/ts/AbstractCompoundType.js +5 -2
  7. package/dist/generators/ts/AbstractContainerType.d.ts +11 -11
  8. package/dist/generators/ts/AbstractContainerType.js +21 -15
  9. package/dist/generators/ts/AbstractDateType.d.ts +7 -6
  10. package/dist/generators/ts/AbstractDateType.js +16 -6
  11. package/dist/generators/ts/AbstractDiscriminatedUnionType.d.ts +2 -3
  12. package/dist/generators/ts/AbstractDiscriminatedUnionType.js +25 -7
  13. package/dist/generators/ts/AbstractIntersectionType.d.ts +2 -2
  14. package/dist/generators/ts/AbstractIntersectionType.js +19 -8
  15. package/dist/generators/ts/AbstractLazyType.d.ts +23 -23
  16. package/dist/generators/ts/AbstractLazyType.js +21 -19
  17. package/dist/generators/ts/AbstractNumericType.d.ts +4 -3
  18. package/dist/generators/ts/AbstractNumericType.js +12 -7
  19. package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -2
  20. package/dist/generators/ts/AbstractPrimitiveType.js +4 -4
  21. package/dist/generators/ts/AbstractTermType.d.ts +17 -16
  22. package/dist/generators/ts/AbstractTermType.js +21 -11
  23. package/dist/generators/ts/AbstractType.d.ts +6 -15
  24. package/dist/generators/ts/AbstractType.js +14 -33
  25. package/dist/generators/ts/AbstractTypedLiteralType.d.ts +2 -1
  26. package/dist/generators/ts/AbstractTypedLiteralType.js +20 -2
  27. package/dist/generators/ts/{AbstractStructuredType.d.ts → AbstractUserDefinedType.d.ts} +6 -6
  28. package/dist/generators/ts/{AbstractStructuredType.js → AbstractUserDefinedType.js} +38 -26
  29. package/dist/generators/ts/BigDecimalType.d.ts +12 -11
  30. package/dist/generators/ts/BigDecimalType.js +28 -11
  31. package/dist/generators/ts/BigIntType.js +6 -6
  32. package/dist/generators/ts/BlankNodeType.d.ts +11 -10
  33. package/dist/generators/ts/BlankNodeType.js +27 -10
  34. package/dist/generators/ts/BooleanType.d.ts +6 -5
  35. package/dist/generators/ts/BooleanType.js +18 -8
  36. package/dist/generators/ts/{ReferenceCallable.d.ts → BuiltinCallable.d.ts} +3 -3
  37. package/dist/generators/ts/{ReferenceCallable.js → BuiltinCallable.js} +3 -3
  38. package/dist/generators/ts/Callable.d.ts +2 -2
  39. package/dist/generators/ts/DateTimeType.d.ts +6 -6
  40. package/dist/generators/ts/DateTimeType.js +6 -6
  41. package/dist/generators/ts/DateType.d.ts +6 -6
  42. package/dist/generators/ts/DateType.js +6 -6
  43. package/dist/generators/ts/DefaultValueType.d.ts +2 -2
  44. package/dist/generators/ts/DefaultValueType.js +18 -8
  45. package/dist/generators/ts/FloatType.js +4 -4
  46. package/dist/generators/ts/IdentifierType.d.ts +11 -10
  47. package/dist/generators/ts/IdentifierType.js +27 -10
  48. package/dist/generators/ts/IntType.js +4 -4
  49. package/dist/generators/ts/IriType.d.ts +5 -5
  50. package/dist/generators/ts/IriType.js +27 -22
  51. package/dist/generators/ts/LangStringType.d.ts +10 -10
  52. package/dist/generators/ts/LangStringType.js +21 -13
  53. package/dist/generators/ts/ListType.js +7 -7
  54. package/dist/generators/ts/LiteralType.d.ts +10 -10
  55. package/dist/generators/ts/LiteralType.js +21 -13
  56. package/dist/generators/ts/ObjectType.d.ts +13 -15
  57. package/dist/generators/ts/ObjectType.js +32 -9
  58. package/dist/generators/ts/OptionType.d.ts +2 -1
  59. package/dist/generators/ts/OptionType.js +16 -11
  60. package/dist/generators/ts/SchemaObject.d.ts +98 -0
  61. package/dist/generators/ts/SchemaObject.js +143 -0
  62. package/dist/generators/ts/SetType.d.ts +2 -1
  63. package/dist/generators/ts/SetType.js +22 -10
  64. package/dist/generators/ts/Snippets.d.ts +1 -0
  65. package/dist/generators/ts/Snippets.js +7 -0
  66. package/dist/generators/ts/StringType.d.ts +6 -6
  67. package/dist/generators/ts/StringType.js +20 -17
  68. package/dist/generators/ts/TermType.d.ts +7 -7
  69. package/dist/generators/ts/TermType.js +18 -13
  70. package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_fromJsonObjectFunction.js +1 -1
  71. package/dist/generators/ts/_AbstractType/AbstractType_JsonType.d.ts +39 -16
  72. package/dist/generators/ts/_AbstractType/AbstractType_JsonType.js +49 -33
  73. package/dist/generators/ts/_ObjectDiscriminatedUnionType/ObjectDiscriminatedUnionType_focusSparqlWherePatternsFunction.js +1 -1
  74. package/dist/generators/ts/_ObjectIntersectionType/ObjectIntersectionType_fromRdfResourceValuesFunction.js +1 -1
  75. package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.d.ts +4 -7
  76. package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.js +1 -3
  77. package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.d.ts +0 -1
  78. package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.js +0 -1
  79. package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.d.ts +3 -2
  80. package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.js +30 -10
  81. package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.d.ts +3 -2
  82. package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.js +26 -10
  83. package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.d.ts +3 -2
  84. package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.js +46 -22
  85. package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunction.js +1 -1
  86. package/dist/generators/ts/_ObjectType/ObjectType_jsonObjectType.d.ts +4 -0
  87. package/dist/generators/ts/_ObjectType/ObjectType_jsonObjectType.js +26 -0
  88. package/dist/generators/ts/_snippets/snippets_LazySchema.d.ts +3 -0
  89. package/dist/generators/ts/_snippets/snippets_LazySchema.js +7 -0
  90. package/package.json +14 -12
  91. package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.d.ts +0 -5
  92. package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.js +0 -11
  93. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +0 -4
  94. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +0 -15
  95. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +0 -4
  96. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +0 -15
@@ -9,6 +9,7 @@ import { rdf } from "@tpluscode/rdf-ns-builders";
9
9
  import { Maybe } from "purify-ts";
10
10
  import { invariant } from "ts-invariant";
11
11
  import { Memoize } from "typescript-memoize";
12
+ import { SchemaObject } from "../SchemaObject.js";
12
13
  import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
13
14
  import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
14
15
  export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
@@ -78,13 +79,23 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
78
79
  });
79
80
  }
80
81
  get schema() {
81
- return Maybe.of(code `{ ${joinCode([code `kind: ${literalOf(this.kind)}`, code `type: ${this.type.schema}`], { on: ", " })} }`);
82
- }
83
- get schemaType() {
84
- return Maybe.of(code `{ ${joinCode([
85
- code `readonly kind: ${literalOf(this.kind)}`,
86
- code `readonly type: ${this.type.schemaType}`,
87
- ], { on: ", " })} }`);
82
+ return Maybe.of(this._schema);
83
+ }
84
+ get _schema() {
85
+ return new SchemaObject({
86
+ properties: {
87
+ kind: code `kind: ${literalOf(this.kind)}`,
88
+ type: code `type: ${this.type.schema.expression}`,
89
+ },
90
+ type: new SchemaObject.UserDefinedType({
91
+ members: {
92
+ kind: code `readonly kind: ${literalOf(this.kind)}`,
93
+ type: code `readonly type: ${this.type.schema.type.expression}`,
94
+ },
95
+ name: Maybe.empty(),
96
+ }),
97
+ variable: this.schemaVariable,
98
+ });
88
99
  }
89
100
  get typeExpression() {
90
101
  return this.objectType.name
@@ -92,9 +103,9 @@ export class ObjectType_IdentifierProperty extends ObjectType_AbstractProperty {
92
103
  .orDefault(this.type.expression);
93
104
  }
94
105
  get typeSchemaVariable() {
95
- return this.objectType.name
96
- .map((name) => code `${name}.schema.properties.${this.name}.type`)
97
- .orDefaultLazy(() => this.type.schema);
106
+ return this.schemaVariable
107
+ .map((schemaVariable) => code `${schemaVariable}.type`)
108
+ .orDefault(this.type.schema.expression);
98
109
  }
99
110
  createInitializer({ variables, }) {
100
111
  const nodeKinds = this.type.nodeKinds;
@@ -203,7 +214,16 @@ __decorate([
203
214
  __decorate([
204
215
  Memoize()
205
216
  ], ObjectType_IdentifierProperty.prototype, "jsonObjectMember", null);
217
+ __decorate([
218
+ Memoize()
219
+ ], ObjectType_IdentifierProperty.prototype, "schema", null);
220
+ __decorate([
221
+ Memoize()
222
+ ], ObjectType_IdentifierProperty.prototype, "_schema", null);
206
223
  __decorate([
207
224
  Memoize()
208
225
  ], ObjectType_IdentifierProperty.prototype, "typeExpression", null);
226
+ __decorate([
227
+ Memoize()
228
+ ], ObjectType_IdentifierProperty.prototype, "typeSchemaVariable", null);
209
229
  //# sourceMappingURL=ObjectType_IdentifierProperty.js.map
@@ -1,5 +1,6 @@
1
1
  import type { NamedNode } from "@rdfjs/types";
2
2
  import { Maybe } from "purify-ts";
3
+ import { SchemaObject } from "../SchemaObject.js";
3
4
  import { type Code } from "../ts-poet-wrapper.js";
4
5
  import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
5
6
  export declare class ObjectType_RdfTypeProperty extends ObjectType_AbstractProperty {
@@ -17,9 +18,9 @@ export declare class ObjectType_RdfTypeProperty extends ObjectType_AbstractPrope
17
18
  fromRdfType: NamedNode;
18
19
  toRdfTypes: readonly NamedNode[];
19
20
  } & Omit<ConstructorParameters<typeof ObjectType_AbstractProperty>[0], "name">);
20
- get schema(): Maybe<Code>;
21
21
  get jsonObjectMember(): ObjectType_AbstractProperty["jsonObjectMember"];
22
- get schemaType(): Maybe<Code>;
22
+ get schema(): Maybe<SchemaObject<SchemaObject.UserDefinedType>>;
23
+ private get _schema();
23
24
  createInitializer(): Maybe<Code>;
24
25
  equalsExpression(): Maybe<Code>;
25
26
  filterExpression(): Maybe<Code>;
@@ -7,6 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
8
8
  import { Maybe } from "purify-ts";
9
9
  import { Memoize } from "typescript-memoize";
10
+ import { SchemaObject } from "../SchemaObject.js";
10
11
  import { arrayOf, code, joinCode, literalOf, } from "../ts-poet-wrapper.js";
11
12
  import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
12
13
  export class ObjectType_RdfTypeProperty extends ObjectType_AbstractProperty {
@@ -29,9 +30,6 @@ export class ObjectType_RdfTypeProperty extends ObjectType_AbstractProperty {
29
30
  this.fromRdfType = fromRdfType;
30
31
  this.toRdfTypes = toRdfTypes;
31
32
  }
32
- get schema() {
33
- return Maybe.of(code `${{ fromRdfType: this.rdfjsTermExpression(this.fromRdfType), kind: this.kind, toRdfTypes: this.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)) }}`);
34
- }
35
33
  get jsonObjectMember() {
36
34
  return Maybe.of({
37
35
  description: Maybe.empty(),
@@ -47,8 +45,26 @@ export class ObjectType_RdfTypeProperty extends ObjectType_AbstractProperty {
47
45
  uiSchemaElement: Maybe.empty(),
48
46
  });
49
47
  }
50
- get schemaType() {
51
- return Maybe.of(code `${{ fromRdfType: code `${this.reusables.imports.NamedNode}`, kind: this.kind, toRdfTypes: code `readonly ${this.reusables.imports.NamedNode}[]` }}`);
48
+ get schema() {
49
+ return Maybe.of(this._schema);
50
+ }
51
+ get _schema() {
52
+ return new SchemaObject({
53
+ properties: {
54
+ fromRdfType: code `fromRdfType: ${this.rdfjsTermExpression(this.fromRdfType)}`,
55
+ kind: code `kind: ${literalOf(this.kind)}`,
56
+ toRdfTypes: code `toRdfTypes: ${arrayOf(...this.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)))}`,
57
+ },
58
+ type: new SchemaObject.UserDefinedType({
59
+ members: {
60
+ fromRdfType: code `fromRdfType: ${this.reusables.imports.NamedNode}`,
61
+ kind: code `kind: ${literalOf(this.kind)}`,
62
+ toRdfTypes: code `toRdfTypes: readonly ${this.reusables.imports.NamedNode}[]`,
63
+ },
64
+ name: Maybe.empty(),
65
+ }),
66
+ variable: this.schemaVariable,
67
+ });
52
68
  }
53
69
  createInitializer() {
54
70
  return Maybe.empty();
@@ -63,7 +79,7 @@ export class ObjectType_RdfTypeProperty extends ObjectType_AbstractProperty {
63
79
  return Maybe.empty();
64
80
  }
65
81
  fromRdfResourceValuesInitializer({ variables, }) {
66
- return Maybe.of(code `${this.name}: !${variables.ignoreRdfType} ? ${this.reusables.snippets.ensureRdfResourceType}(${variables.focusResource}, ${arrayOf(code `(${this.schemaVariable}).fromRdfType`)}, ${{ graph: variables.graph }}) : ${this.reusables.imports.Right}(true as const)`);
82
+ return Maybe.of(code `${this.name}: !${variables.ignoreRdfType} ? ${this.reusables.snippets.ensureRdfResourceType}(${variables.focusResource}, ${arrayOf(code `(${this._schema.expression}).fromRdfType`)}, ${{ graph: variables.graph }}) : ${this.reusables.imports.Right}(true as const)`);
67
83
  }
68
84
  hashStatements() {
69
85
  return [];
@@ -122,7 +138,7 @@ type: "optional" as const
122
138
  return [
123
139
  code `\
124
140
  if (!${variables.ignoreRdfType}) {
125
- ${variables.resource}.add(${this.rdfjsTermExpression(rdf.type)}, ${this.schemaVariable}.toRdfTypes, ${variables.graph});
141
+ ${variables.resource}.add(${this.rdfjsTermExpression(rdf.type)}, ${this._schema.expression}.toRdfTypes, ${variables.graph});
126
142
  }`,
127
143
  ];
128
144
  }
@@ -132,13 +148,13 @@ if (!${variables.ignoreRdfType}) {
132
148
  }
133
149
  __decorate([
134
150
  Memoize()
135
- ], ObjectType_RdfTypeProperty.prototype, "schema", null);
151
+ ], ObjectType_RdfTypeProperty.prototype, "jsonObjectMember", null);
136
152
  __decorate([
137
153
  Memoize()
138
- ], ObjectType_RdfTypeProperty.prototype, "jsonObjectMember", null);
154
+ ], ObjectType_RdfTypeProperty.prototype, "schema", null);
139
155
  __decorate([
140
156
  Memoize()
141
- ], ObjectType_RdfTypeProperty.prototype, "schemaType", null);
157
+ ], ObjectType_RdfTypeProperty.prototype, "_schema", null);
142
158
  __decorate([
143
159
  Memoize()
144
160
  ], ObjectType_RdfTypeProperty.prototype, "equalsExpression", null);
@@ -1,5 +1,6 @@
1
1
  import type { PropertyPath } from "@rdfx/resource";
2
2
  import { Maybe } from "purify-ts";
3
+ import { SchemaObject } from "../SchemaObject.js";
3
4
  import type { Type } from "../Type.js";
4
5
  import { type Code } from "../ts-poet-wrapper.js";
5
6
  import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
@@ -37,8 +38,8 @@ export declare class ObjectType_ShaclProperty<TypeT extends Type> extends Object
37
38
  get graphqlField(): ObjectType_AbstractProperty["graphqlField"];
38
39
  get hashFunctionParameter(): Maybe<Code>;
39
40
  get jsonObjectMember(): ObjectType_AbstractProperty["jsonObjectMember"];
40
- get schema(): Maybe<Code>;
41
- get schemaType(): Maybe<Code>;
41
+ get schema(): Maybe<SchemaObject<SchemaObject.UserDefinedType>>;
42
+ private get _schema();
42
43
  private get typeSchemaVariable();
43
44
  createInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["createInitializer"]>[0]): Maybe<Code>;
44
45
  equalsExpression({ variables, }: Parameters<ObjectType_AbstractProperty["equalsExpression"]>[0]): Maybe<Code>;
@@ -6,6 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
+ import { SchemaObject } from "../SchemaObject.js";
9
10
  import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
10
11
  import { tsComment } from "../tsComment.js";
11
12
  import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
@@ -106,33 +107,50 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
106
107
  });
107
108
  }
108
109
  get schema() {
109
- const initializers = [code `kind: ${literalOf(this.kind)}`];
110
+ return Maybe.of(this._schema);
111
+ }
112
+ get _schema() {
113
+ // if (
114
+ // this.objectType.name.extract() === "DirectRecursiveStruct" ||
115
+ // this.objectType.name.extract() === "IndirectRecursiveStruct"
116
+ // ) {
117
+ // console.log("test");
118
+ // }
119
+ const properties = {
120
+ kind: code `kind: ${literalOf(this.kind)}`,
121
+ };
122
+ const typeMembers = {
123
+ kind: code `readonly kind: ${literalOf(this.kind)}`,
124
+ };
110
125
  if (this.configuration.features.has("Object.fromRdf") ||
111
126
  this.configuration.features.has("Object.toRdf")) {
112
- initializers.push(code `path: ${this.propertyPathToCode(this.path)}`);
127
+ properties["path"] = code `path: ${this.propertyPathToCode(this.path)}`;
128
+ typeMembers["path"] =
129
+ code `readonly path: ${this.reusables.snippets.PropertyPath}`;
113
130
  }
114
131
  // Use a getter if the type is recursive or the type is an object type, which may have forward references in the file
115
132
  if (this.recursive || this.type.referencesNamedType) {
116
- initializers.push(code `get type() { return ${this.type.schema}; }`);
133
+ properties["type"] = () => code `get type() { return ${this.type.schema.expression}; }`;
134
+ typeMembers["type"] = () => code `readonly type: ${this.type.schema.type.expression}`;
117
135
  }
118
136
  else {
119
- initializers.push(code `type: ${this.type.schema}`);
120
- }
121
- return Maybe.of(code `{ ${joinCode(initializers, { on: ", " })} }`);
122
- }
123
- get schemaType() {
124
- const initializers = [code `readonly kind: ${literalOf(this.kind)}`];
125
- if (this.configuration.features.has("Object.fromRdf") ||
126
- this.configuration.features.has("Object.toRdf")) {
127
- initializers.push(code `readonly path: ${this.reusables.snippets.PropertyPath}`);
137
+ properties["type"] = code `type: ${this.type.schema.expression}`;
138
+ typeMembers["type"] =
139
+ code `readonly type: ${this.type.schema.type.expression}`;
128
140
  }
129
- initializers.push(code `readonly type: ${this.type.schemaType}`);
130
- return Maybe.of(code `{ ${joinCode(initializers, { on: ", " })} }`);
141
+ return new SchemaObject({
142
+ properties,
143
+ type: new SchemaObject.UserDefinedType({
144
+ members: typeMembers,
145
+ name: Maybe.empty(),
146
+ }),
147
+ variable: this.schemaVariable,
148
+ });
131
149
  }
132
150
  get typeSchemaVariable() {
133
- return this.objectType.name
134
- .map((name) => code `${name}.schema.properties.${this.name}.type`)
135
- .orDefaultLazy(() => this.type.schema);
151
+ return this.schemaVariable
152
+ .map((schemaVariable) => code `${schemaVariable}.type`)
153
+ .orDefaultLazy(() => this.type.schema.expression);
136
154
  }
137
155
  createInitializer({ variables, }) {
138
156
  const parameterVariable = code `${variables.parameters}.${this.name}`;
@@ -169,11 +187,11 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
169
187
  }
170
188
  fromRdfResourceValuesInitializer({ variables, }) {
171
189
  return Maybe.of(code `${this.name}:
172
- ${this.reusables.snippets.shaclPropertyFromRdf}<${this.type.expression}, ${this.type.schemaType}>({
190
+ ${this.reusables.snippets.shaclPropertyFromRdf}<${this.type.expression}, ${this.type.schema.type.expression}>({
173
191
  ...${variables.options},
174
192
  focusResource: ${variables.focusResource},
175
193
  ignoreRdfType: true,
176
- propertySchema: ${this.schemaVariable},
194
+ propertySchema: ${this._schema.expression},
177
195
  typeFromRdfResourceValues: ${this.type.fromRdfResourceValuesFunction.unannotatedUsage}
178
196
  })`);
179
197
  }
@@ -190,7 +208,7 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
190
208
  focusIdentifier: variables.focusIdentifier,
191
209
  ignoreRdfType: true,
192
210
  propertyName: this.name,
193
- propertySchema: this.schemaVariable,
211
+ propertySchema: this._schema.expression,
194
212
  typeSparqlConstructTriples: this.type.valueSparqlConstructTriplesFunction.unannotatedUsage,
195
213
  variablePrefix: variables.variablePrefix,
196
214
  }})`);
@@ -205,7 +223,7 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
205
223
  ignoreRdfType: true,
206
224
  preferredLanguages: variables.preferredLanguages,
207
225
  propertyName: this.name,
208
- propertySchema: this.schemaVariable,
226
+ propertySchema: this._schema.expression,
209
227
  typeSparqlWherePatterns: this.type.valueSparqlWherePatternsFunction.unannotatedUsage,
210
228
  variablePrefix: variables.variablePrefix,
211
229
  }})`,
@@ -231,7 +249,7 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
231
249
  return [];
232
250
  }
233
251
  const propertyPath = this.objectType.name
234
- .map(() => code `${this.schemaVariable}.path`)
252
+ .map(() => code `${this._schema.expression}.path`)
235
253
  .orDefault(this.propertyPathToCode(this.path));
236
254
  const { object: objectVariable, ...otherVariables } = variables;
237
255
  return [
@@ -281,6 +299,12 @@ __decorate([
281
299
  __decorate([
282
300
  Memoize()
283
301
  ], ObjectType_ShaclProperty.prototype, "jsonObjectMember", null);
302
+ __decorate([
303
+ Memoize()
304
+ ], ObjectType_ShaclProperty.prototype, "schema", null);
305
+ __decorate([
306
+ Memoize()
307
+ ], ObjectType_ShaclProperty.prototype, "_schema", null);
284
308
  __decorate([
285
309
  Memoize()
286
310
  ], ObjectType_ShaclProperty.prototype, "typeSchemaVariable", null);
@@ -3,6 +3,6 @@ export function ObjectType_fromRdfResourceValuesFunctionExpression() {
3
3
  return code `(values, options) => values.chainMap(value => value.toResource().chain(resource => ${this.fromRdfResourceFunction.annotatedUsage}(resource, options)))`;
4
4
  }
5
5
  export function ObjectType_fromRdfResourceValuesFunctionType() {
6
- return code `${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.discriminatedType.map((discriminatedType) => discriminatedType.expression).orDefault(this.expression)}, ${this.schemaType}>`;
6
+ return code `${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.discriminatedType.map((discriminatedType) => discriminatedType.expression).orDefault(this.expression)}, ${this.schema.type.expression}>`;
7
7
  }
8
8
  //# sourceMappingURL=ObjectType_fromRdfResourceValuesFunction.js.map
@@ -0,0 +1,4 @@
1
+ import type { AbstractUserDefinedType } from "../AbstractUserDefinedType.js";
2
+ import type { ObjectType } from "../ObjectType.js";
3
+ export declare function ObjectType_jsonObjectType(this: ObjectType): AbstractUserDefinedType["jsonObjectType"];
4
+ //# sourceMappingURL=ObjectType_jsonObjectType.d.ts.map
@@ -0,0 +1,26 @@
1
+ import { InlineCallable } from "../InlineCallable.js";
2
+ import { code, literalOf } from "../ts-poet-wrapper.js";
3
+ export function ObjectType_jsonObjectType() {
4
+ // If the JSON object type is { "@id": string }, allow a shorthand of string => that type.
5
+ let shorthand;
6
+ this.identifierProperty.ifJust((identifierProperty) => {
7
+ const fromJsonObjectInitializerParameters = {
8
+ variables: { context: code ``, jsonObject: code ``, options: code `` },
9
+ };
10
+ if (this.properties.some((property) => !Object.is(property, identifierProperty) &&
11
+ property
12
+ .fromJsonObjectInitializer(fromJsonObjectInitializerParameters)
13
+ .isJust())) {
14
+ return;
15
+ }
16
+ shorthand = {
17
+ transformer: new InlineCallable(code `(id) => ({ ${literalOf(identifierProperty.jsonObjectMember.unsafeCoerce().name)}: id })`),
18
+ type: identifierProperty.type.jsonValueType,
19
+ };
20
+ });
21
+ return this.jsonTypeFactory.createJsonObjectType(this.properties.flatMap((property) => property.jsonObjectMember.toList()), {
22
+ name: this.name.map((name) => [name, "Json"]).extract(),
23
+ shorthand,
24
+ });
25
+ }
26
+ //# sourceMappingURL=ObjectType_jsonObjectType.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_LazySchema: SnippetFactory;
3
+ //# sourceMappingURL=snippets_LazySchema.d.ts.map
@@ -0,0 +1,7 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_LazySchema = ({ syntheticNamePrefix }) => conditionalOutput(`${syntheticNamePrefix}LazySchema`, code `\
3
+ interface ${syntheticNamePrefix}LazySchema<PartialSchemaT>{
4
+ readonly kind: "Lazy" | "LazyOption" | "LazySet";
5
+ readonly partialType: PartialSchemaT;
6
+ }`);
7
+ //# sourceMappingURL=snippets_LazySchema.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/shacl-ast": "4.0.98",
3
+ "@shaclmate/shacl-ast": "4.0.100",
4
4
  "@rdfjs/types": "~2.0.1",
5
5
  "@rdfx/collection": "0.0.59",
6
6
  "@rdfx/curie": "0.0.59",
@@ -136,6 +136,8 @@
136
136
  "dist/generators/index.js",
137
137
  "dist/generators/transformAstToLabeledPropertyGraph.d.ts",
138
138
  "dist/generators/transformAstToLabeledPropertyGraph.js",
139
+ "dist/generators/ts/AbstractBuiltinType.d.ts",
140
+ "dist/generators/ts/AbstractBuiltinType.js",
139
141
  "dist/generators/ts/AbstractCallable.d.ts",
140
142
  "dist/generators/ts/AbstractCallable.js",
141
143
  "dist/generators/ts/AbstractCollectionType.d.ts",
@@ -164,14 +166,14 @@
164
166
  "dist/generators/ts/AbstractObjectSetType.js",
165
167
  "dist/generators/ts/AbstractPrimitiveType.d.ts",
166
168
  "dist/generators/ts/AbstractPrimitiveType.js",
167
- "dist/generators/ts/AbstractStructuredType.d.ts",
168
- "dist/generators/ts/AbstractStructuredType.js",
169
169
  "dist/generators/ts/AbstractTermType.d.ts",
170
170
  "dist/generators/ts/AbstractTermType.js",
171
171
  "dist/generators/ts/AbstractType.d.ts",
172
172
  "dist/generators/ts/AbstractType.js",
173
173
  "dist/generators/ts/AbstractTypedLiteralType.d.ts",
174
174
  "dist/generators/ts/AbstractTypedLiteralType.js",
175
+ "dist/generators/ts/AbstractUserDefinedType.d.ts",
176
+ "dist/generators/ts/AbstractUserDefinedType.js",
175
177
  "dist/generators/ts/BigDecimalType.d.ts",
176
178
  "dist/generators/ts/BigDecimalType.js",
177
179
  "dist/generators/ts/BigIntType.d.ts",
@@ -180,6 +182,8 @@
180
182
  "dist/generators/ts/BlankNodeType.js",
181
183
  "dist/generators/ts/BooleanType.d.ts",
182
184
  "dist/generators/ts/BooleanType.js",
185
+ "dist/generators/ts/BuiltinCallable.d.ts",
186
+ "dist/generators/ts/BuiltinCallable.js",
183
187
  "dist/generators/ts/Callable.d.ts",
184
188
  "dist/generators/ts/Callable.js",
185
189
  "dist/generators/ts/CodeThunk.d.ts",
@@ -234,10 +238,10 @@
234
238
  "dist/generators/ts/OptionType.js",
235
239
  "dist/generators/ts/RdfjsDatasetObjectSetType.d.ts",
236
240
  "dist/generators/ts/RdfjsDatasetObjectSetType.js",
237
- "dist/generators/ts/ReferenceCallable.d.ts",
238
- "dist/generators/ts/ReferenceCallable.js",
239
241
  "dist/generators/ts/Reusables.d.ts",
240
242
  "dist/generators/ts/Reusables.js",
243
+ "dist/generators/ts/SchemaObject.d.ts",
244
+ "dist/generators/ts/SchemaObject.js",
241
245
  "dist/generators/ts/Service.d.ts",
242
246
  "dist/generators/ts/Service.js",
243
247
  "dist/generators/ts/SetType.d.ts",
@@ -288,8 +292,6 @@
288
292
  "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inferDiscriminant.js",
289
293
  "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inlineExpression.d.ts",
290
294
  "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_inlineExpression.js",
291
- "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.d.ts",
292
- "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_schemaTypeExpression.js",
293
295
  "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toJsonObjectFunction.d.ts",
294
296
  "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toJsonObjectFunction.js",
295
297
  "dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_toLoggableFunction.d.ts",
@@ -412,12 +414,10 @@
412
414
  "dist/generators/ts/_ObjectType/ObjectType_hashFunction.js",
413
415
  "dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts",
414
416
  "dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.js",
417
+ "dist/generators/ts/_ObjectType/ObjectType_jsonObjectType.d.ts",
418
+ "dist/generators/ts/_ObjectType/ObjectType_jsonObjectType.js",
415
419
  "dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts",
416
420
  "dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.js",
417
- "dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts",
418
- "dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js",
419
- "dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts",
420
- "dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js",
421
421
  "dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunction.d.ts",
422
422
  "dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunction.js",
423
423
  "dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunction.d.ts",
@@ -500,6 +500,8 @@
500
500
  "dist/generators/ts/_snippets/snippets_Lazy.js",
501
501
  "dist/generators/ts/_snippets/snippets_LazyOption.d.ts",
502
502
  "dist/generators/ts/_snippets/snippets_LazyOption.js",
503
+ "dist/generators/ts/_snippets/snippets_LazySchema.d.ts",
504
+ "dist/generators/ts/_snippets/snippets_LazySchema.js",
503
505
  "dist/generators/ts/_snippets/snippets_LazySet.d.ts",
504
506
  "dist/generators/ts/_snippets/snippets_LazySet.js",
505
507
  "dist/generators/ts/_snippets/snippets_LiteralFilter.d.ts",
@@ -976,5 +978,5 @@
976
978
  },
977
979
  "type": "module",
978
980
  "types": "./dist/index.d.ts",
979
- "version": "4.0.98"
981
+ "version": "4.0.100"
980
982
  }
@@ -1,5 +0,0 @@
1
- import type { AbstractDiscriminatedUnionType } from "../AbstractDiscriminatedUnionType.js";
2
- import type { Type } from "../Type.js";
3
- import { type Code } from "../ts-poet-wrapper.js";
4
- export declare function AbstractDiscriminatedUnionType_schemaTypeExpression<MemberTypeT extends Type>(this: AbstractDiscriminatedUnionType<MemberTypeT>): Code;
5
- //# sourceMappingURL=AbstractDiscriminatedUnionType_schemaTypeExpression.d.ts.map
@@ -1,11 +0,0 @@
1
- import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
2
- export function AbstractDiscriminatedUnionType_schemaTypeExpression() {
3
- return code `${{
4
- kind: this.kind,
5
- members: code `{ ${joinCode(this.members.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}: ${{
6
- discriminantValues: code `readonly (number | string)[]`,
7
- type: type.schemaType,
8
- }}`), { on: ";" })} }`,
9
- }}`;
10
- }
11
- //# sourceMappingURL=AbstractDiscriminatedUnionType_schemaTypeExpression.js.map
@@ -1,4 +0,0 @@
1
- import type { ObjectType } from "../ObjectType.js";
2
- import { type Code } from "../ts-poet-wrapper.js";
3
- export declare function ObjectType_schemaExpression(this: ObjectType): Code;
4
- //# sourceMappingURL=ObjectType_schemaExpression.d.ts.map
@@ -1,15 +0,0 @@
1
- import { invariant } from "ts-invariant";
2
- import { code } from "../ts-poet-wrapper.js";
3
- export function ObjectType_schemaExpression() {
4
- const schema = {};
5
- const properties = {};
6
- for (const property of this.properties) {
7
- property.schema.ifJust((propertySchema) => {
8
- properties[property.name] = propertySchema;
9
- });
10
- }
11
- invariant(Object.keys(properties).length > 0);
12
- schema["properties"] = properties;
13
- return code `${schema} as const`;
14
- }
15
- //# sourceMappingURL=ObjectType_schemaExpression.js.map
@@ -1,4 +0,0 @@
1
- import type { ObjectType } from "../ObjectType.js";
2
- import { type Code } from "../ts-poet-wrapper.js";
3
- export declare function ObjectType_schemaTypeExpression(this: ObjectType): Code;
4
- //# sourceMappingURL=ObjectType_schemaTypeExpression.d.ts.map
@@ -1,15 +0,0 @@
1
- import { invariant } from "ts-invariant";
2
- import { code } from "../ts-poet-wrapper.js";
3
- export function ObjectType_schemaTypeExpression() {
4
- const schemaType = {};
5
- const properties = {};
6
- for (const property of this.properties) {
7
- property.schemaType.ifJust((propertySchemaType) => {
8
- properties[property.name] = propertySchemaType;
9
- });
10
- }
11
- invariant(Object.keys(properties).length > 0);
12
- schemaType["properties"] = properties;
13
- return code `${schemaType}`;
14
- }
15
- //# sourceMappingURL=ObjectType_schemaTypeExpression.js.map