@shaclmate/compiler 4.0.90 → 4.0.92

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 (49) hide show
  1. package/dist/generators/ts/AbstractNumericType.d.ts +1 -0
  2. package/dist/generators/ts/AbstractPrimitiveType.d.ts +0 -7
  3. package/dist/generators/ts/AbstractPrimitiveType.js +0 -7
  4. package/dist/generators/ts/BigDecimalType.d.ts +6 -8
  5. package/dist/generators/ts/BigDecimalType.js +27 -10
  6. package/dist/generators/ts/BigIntType.d.ts +2 -0
  7. package/dist/generators/ts/BigIntType.js +26 -0
  8. package/dist/generators/ts/BooleanType.d.ts +2 -0
  9. package/dist/generators/ts/BooleanType.js +2 -0
  10. package/dist/generators/ts/DefaultValueType.d.ts +2 -1
  11. package/dist/generators/ts/FloatType.d.ts +2 -0
  12. package/dist/generators/ts/FloatType.js +2 -0
  13. package/dist/generators/ts/IntType.d.ts +2 -0
  14. package/dist/generators/ts/IntType.js +2 -0
  15. package/dist/generators/ts/ObjectType.d.ts +7 -6
  16. package/dist/generators/ts/ObjectType.js +19 -18
  17. package/dist/generators/ts/Snippets.d.ts +2 -0
  18. package/dist/generators/ts/Snippets.js +14 -0
  19. package/dist/generators/ts/StringType.d.ts +3 -1
  20. package/dist/generators/ts/StringType.js +5 -3
  21. package/dist/generators/ts/TypeFactory.js +12 -2
  22. package/dist/generators/ts/_AbstractDiscriminatedUnionType/AbstractDiscriminatedUnionType_conversionFunctionExpression.js +2 -0
  23. package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.d.ts +39 -21
  24. package/dist/generators/ts/_ObjectType/ObjectType_AbstractProperty.js +1 -13
  25. package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.d.ts +14 -22
  26. package/dist/generators/ts/_ObjectType/ObjectType_DiscriminantProperty.js +27 -29
  27. package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.d.ts +19 -14
  28. package/dist/generators/ts/_ObjectType/ObjectType_IdentifierProperty.js +24 -12
  29. package/dist/generators/ts/_ObjectType/ObjectType_Property.d.ts +2 -1
  30. package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.d.ts +37 -0
  31. package/dist/generators/ts/_ObjectType/ObjectType_RdfTypeProperty.js +118 -0
  32. package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.d.ts +21 -17
  33. package/dist/generators/ts/_ObjectType/ObjectType_ShaclProperty.js +26 -8
  34. package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.js +6 -9
  35. package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +11 -2
  36. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionExpression.js +1 -12
  37. package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionExpression.js +8 -46
  38. package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +7 -3
  39. package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +1 -7
  40. package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +0 -3
  41. package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +1 -3
  42. package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.js +1 -8
  43. package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +3 -0
  44. package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +5 -0
  45. package/dist/generators/ts/_snippets/snippets_convertToBigInt.d.ts +3 -0
  46. package/dist/generators/ts/_snippets/snippets_convertToBigInt.js +5 -0
  47. package/dist/input/input.shaclmate.d.ts +45 -18
  48. package/dist/input/input.shaclmate.js +54 -32
  49. package/package.json +8 -2
@@ -0,0 +1,118 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
8
+ import { Maybe } from "purify-ts";
9
+ import { Memoize } from "typescript-memoize";
10
+ import { code, joinCode } from "../ts-poet-wrapper.js";
11
+ import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
12
+ export class ObjectType_RdfTypeProperty extends ObjectType_AbstractProperty {
13
+ constructorParameter = Maybe.empty();
14
+ declaration = Maybe.empty();
15
+ filterProperty = Maybe.empty();
16
+ fromRdfType;
17
+ graphqlField = Maybe.empty();
18
+ hashFunctionParameter = Maybe.empty();
19
+ jsonSchema = Maybe.empty();
20
+ jsonSignature = Maybe.empty();
21
+ kind = "RdfType";
22
+ mutable = false;
23
+ recursive = false;
24
+ toRdfTypes;
25
+ constructor({ configuration, fromRdfType, toRdfTypes, ...superParameters }) {
26
+ super({
27
+ ...superParameters,
28
+ configuration,
29
+ name: `${configuration.syntheticNamePrefix}rdfType`,
30
+ });
31
+ this.fromRdfType = fromRdfType;
32
+ this.toRdfTypes = toRdfTypes;
33
+ }
34
+ get schema() {
35
+ return Maybe.of(code `${{ fromRdfType: this.rdfjsTermExpression(this.fromRdfType), kind: this.kind, toRdfTypes: this.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)) }}`);
36
+ }
37
+ get schemaType() {
38
+ return Maybe.of(code `${{ fromRdfType: code `${this.reusables.imports.NamedNode}`, kind: this.kind, toRdfTypes: code `readonly ${this.reusables.imports.NamedNode}[]` }}`);
39
+ }
40
+ constructorInitializer() {
41
+ return Maybe.empty();
42
+ }
43
+ equalsExpression() {
44
+ return Maybe.empty();
45
+ }
46
+ filterExpression() {
47
+ return Maybe.empty();
48
+ }
49
+ fromJsonInitializer() {
50
+ return Maybe.empty();
51
+ }
52
+ fromRdfResourceValuesInitializer() {
53
+ return Maybe.empty();
54
+ }
55
+ hashStatements() {
56
+ return [];
57
+ }
58
+ jsonUiSchemaElement() {
59
+ return Maybe.empty();
60
+ }
61
+ sparqlConstructTriplesExpression({ variables, }) {
62
+ const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
63
+ const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
64
+ return Maybe.of(code `${variables.ignoreRdfType} ? [] : [${joinCode([
65
+ code `{ subject: ${variables.focusIdentifier}, predicate: ${this.rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} }`,
66
+ code `{ subject: ${rdfTypeVariable}, predicate: ${this.rdfjsTermExpression(rdfs.subClassOf)}, object: ${rdfClassVariable} }`,
67
+ ], {
68
+ on: ",",
69
+ })}]`);
70
+ }
71
+ sparqlWherePatternsExpression({ variables, }) {
72
+ const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
73
+ const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
74
+ return Maybe.of({
75
+ patterns: code `${variables.ignoreRdfType} ? [] : [${joinCode([
76
+ code `${this.reusables.snippets.sparqlInstancesOfPattern}({ rdfType: ${variables.schema.map((schema) => code `${schema}.properties.${this.name}.fromRdfType`).orDefault(this.rdfjsTermExpression(this.fromRdfType))}, subject: ${variables.focusIdentifier} })`,
77
+ code `{ triples: [{ subject: ${variables.focusIdentifier}, predicate: ${this.rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} }], type: "bgp" as const }`,
78
+ code `{
79
+ patterns: [
80
+ {
81
+ triples: [
82
+ {
83
+ subject: ${rdfTypeVariable},
84
+ predicate: {
85
+ items: [${this.rdfjsTermExpression(rdfs.subClassOf)}],
86
+ pathType: "+" as const,
87
+ type: "path" as const
88
+ },
89
+ object: ${rdfClassVariable}
90
+ }
91
+ ],
92
+ type: "bgp" as const
93
+ }
94
+ ],
95
+ type: "optional" as const
96
+ }`,
97
+ ], {
98
+ on: ",",
99
+ })}]`,
100
+ });
101
+ }
102
+ toJsonInitializer() {
103
+ return Maybe.empty();
104
+ }
105
+ toRdfRdfResourceValuesStatements() {
106
+ return [];
107
+ }
108
+ toStringInitializer() {
109
+ return Maybe.empty();
110
+ }
111
+ }
112
+ __decorate([
113
+ Memoize()
114
+ ], ObjectType_RdfTypeProperty.prototype, "equalsExpression", null);
115
+ __decorate([
116
+ Memoize()
117
+ ], ObjectType_RdfTypeProperty.prototype, "filterExpression", null);
118
+ //# sourceMappingURL=ObjectType_RdfTypeProperty.js.map
@@ -3,7 +3,7 @@ import { Maybe } from "purify-ts";
3
3
  import type { Type } from "../Type.js";
4
4
  import { type Code } from "../ts-poet-wrapper.js";
5
5
  import { ObjectType_AbstractProperty } from "./ObjectType_AbstractProperty.js";
6
- export declare class ObjectType_ShaclProperty<TypeT extends Type> extends ObjectType_AbstractProperty<TypeT> {
6
+ export declare class ObjectType_ShaclProperty<TypeT extends Type> extends ObjectType_AbstractProperty {
7
7
  private readonly comment;
8
8
  private readonly description;
9
9
  private readonly display;
@@ -12,7 +12,8 @@ export declare class ObjectType_ShaclProperty<TypeT extends Type> extends Object
12
12
  readonly mutable: boolean;
13
13
  readonly path: PropertyPath;
14
14
  readonly recursive: boolean;
15
- constructor({ comment, description, display, label, mutable, path, recursive, ...superParameters }: {
15
+ readonly type: TypeT;
16
+ constructor({ comment, description, display, label, mutable, path, recursive, type, ...superParameters }: {
16
17
  comment: Maybe<string>;
17
18
  description: Maybe<string>;
18
19
  display: boolean;
@@ -20,34 +21,37 @@ export declare class ObjectType_ShaclProperty<TypeT extends Type> extends Object
20
21
  mutable: boolean;
21
22
  path: PropertyPath;
22
23
  recursive: boolean;
23
- } & ConstructorParameters<typeof ObjectType_AbstractProperty<TypeT>>[0]);
24
+ type: TypeT;
25
+ } & ConstructorParameters<typeof ObjectType_AbstractProperty>[0]);
24
26
  get constructorParameter(): Maybe<{
25
27
  hasQuestionToken: boolean;
26
28
  signature: Code;
27
29
  }>;
28
- get declaration(): Code;
30
+ get declaration(): Maybe<Code>;
29
31
  get filterProperty(): Maybe<{
30
32
  name: string;
31
33
  type: Code;
32
34
  }>;
33
- get graphqlField(): ObjectType_AbstractProperty<TypeT>["graphqlField"];
34
- get hashFunctionParameter(): Code;
35
- get jsonSchema(): ObjectType_AbstractProperty<TypeT>["jsonSchema"];
35
+ get graphqlField(): ObjectType_AbstractProperty["graphqlField"];
36
+ get hashFunctionParameter(): Maybe<Code>;
37
+ get jsonSchema(): ObjectType_AbstractProperty["jsonSchema"];
36
38
  get jsonSignature(): Maybe<Code>;
37
39
  get schema(): Maybe<Code>;
38
40
  get schemaType(): Maybe<Code>;
39
41
  private get schemaVariable();
40
42
  private get typeSchemaVariable();
41
- constructorInitializer({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["constructorInitializer"]>[0]): Maybe<Code>;
42
- fromJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["fromJsonInitializer"]>[0]): Maybe<Code>;
43
- fromRdfResourceValuesInitializer({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["fromRdfResourceValuesInitializer"]>[0]): Maybe<Code>;
44
- hashStatements({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["hashStatements"]>[0]): readonly Code[];
45
- jsonUiSchemaElement({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
46
- sparqlConstructTriplesExpression({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["sparqlConstructTriplesExpression"]>[0]): Maybe<Code>;
47
- sparqlWherePatternsExpression({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>[0]): ReturnType<ObjectType_AbstractProperty<TypeT>["sparqlWherePatternsExpression"]>;
48
- toJsonInitializer(parameters: Parameters<ObjectType_AbstractProperty<TypeT>["toJsonInitializer"]>[0]): Maybe<Code>;
49
- toRdfRdfResourceValuesStatements({ variables, }: Parameters<ObjectType_AbstractProperty<TypeT>["toRdfRdfResourceValuesStatements"]>[0]): readonly Code[];
50
- toStringInitializer(parameters: Parameters<ObjectType_AbstractProperty<TypeT>["toStringInitializer"]>[0]): Maybe<Code>;
43
+ constructorInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["constructorInitializer"]>[0]): Maybe<Code>;
44
+ equalsExpression({ variables, }: Parameters<ObjectType_AbstractProperty["equalsExpression"]>[0]): Maybe<Code>;
45
+ filterExpression({ variables, }: Parameters<ObjectType_AbstractProperty["filterExpression"]>[0]): Maybe<Code>;
46
+ fromJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["fromJsonInitializer"]>[0]): Maybe<Code>;
47
+ fromRdfResourceValuesInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["fromRdfResourceValuesInitializer"]>[0]): Maybe<Code>;
48
+ hashStatements({ variables, }: Parameters<ObjectType_AbstractProperty["hashStatements"]>[0]): readonly Code[];
49
+ jsonUiSchemaElement({ variables, }: Parameters<ObjectType_AbstractProperty["jsonUiSchemaElement"]>[0]): Maybe<Code>;
50
+ sparqlConstructTriplesExpression({ variables, }: Parameters<ObjectType_AbstractProperty["sparqlConstructTriplesExpression"]>[0]): Maybe<Code>;
51
+ sparqlWherePatternsExpression({ variables, }: Parameters<ObjectType_AbstractProperty["sparqlWherePatternsExpression"]>[0]): ReturnType<ObjectType_AbstractProperty["sparqlWherePatternsExpression"]>;
52
+ toJsonInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["toJsonInitializer"]>[0]): Maybe<Code>;
53
+ toRdfRdfResourceValuesStatements({ variables, }: Parameters<ObjectType_AbstractProperty["toRdfRdfResourceValuesStatements"]>[0]): readonly Code[];
54
+ toStringInitializer({ variables, }: Parameters<ObjectType_AbstractProperty["toStringInitializer"]>[0]): Maybe<Code>;
51
55
  private propertyPathToCode;
52
56
  }
53
57
  //# sourceMappingURL=ObjectType_ShaclProperty.d.ts.map
@@ -18,7 +18,8 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
18
18
  mutable;
19
19
  path;
20
20
  recursive;
21
- constructor({ comment, description, display, label, mutable, path, recursive, ...superParameters }) {
21
+ type;
22
+ constructor({ comment, description, display, label, mutable, path, recursive, type, ...superParameters }) {
22
23
  super(superParameters);
23
24
  this.comment = comment;
24
25
  this.description = description;
@@ -27,6 +28,7 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
27
28
  this.mutable = mutable;
28
29
  this.path = path;
29
30
  this.recursive = recursive;
31
+ this.type = type;
30
32
  }
31
33
  get constructorParameter() {
32
34
  const conversionFunction = this.type.conversionFunction.extract();
@@ -60,7 +62,7 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
60
62
  .ifJust((comment) => {
61
63
  declaration = code `${comment}${declaration}`;
62
64
  });
63
- return declaration;
65
+ return Maybe.of(declaration);
64
66
  }
65
67
  get filterProperty() {
66
68
  return Maybe.of({
@@ -161,6 +163,16 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
161
163
  }
162
164
  return Maybe.of(code `${this.name}: ${rhs}`);
163
165
  }
166
+ equalsExpression({ variables, }) {
167
+ return Maybe.of(code `${this.reusables.snippets.propertyEquals}(
168
+ { equalsFunction: ${this.type.equalsFunction}, name: ${literalOf(this.name)} },
169
+ [left, ${variables.leftObject}.${this.name}],
170
+ [right, ${variables.rightObject}.${this.name}],
171
+ )`);
172
+ }
173
+ filterExpression({ variables, }) {
174
+ return Maybe.of(code `${this.type.filterFunction}(${variables.filter}.${this.name}, ${variables.object}.${this.name})`);
175
+ }
164
176
  fromJsonInitializer({ variables, }) {
165
177
  return Maybe.of(code `${this.name}: ${this.type.fromJsonExpression({
166
178
  variables: { value: code `${variables.jsonObject}["${this.name}"]` },
@@ -178,7 +190,7 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
178
190
  }
179
191
  hashStatements({ variables, }) {
180
192
  return [
181
- code `${this.type.hashFunction}(${variables.hasher}, ${variables.value});`,
193
+ code `${this.type.hashFunction}(${variables.hasher}, ${variables.object}.${this.name});`,
182
194
  ];
183
195
  }
184
196
  jsonUiSchemaElement({ variables, }) {
@@ -216,8 +228,8 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
216
228
  }})`,
217
229
  });
218
230
  }
219
- toJsonInitializer(parameters) {
220
- return Maybe.of(code `${this.name}: ${this.type.toJsonExpression(parameters)}`);
231
+ toJsonInitializer({ variables, }) {
232
+ return Maybe.of(code `${this.name}: ${this.type.toJsonExpression({ variables: { value: code `${variables.object}.${this.name}` } })}`);
221
233
  }
222
234
  toRdfRdfResourceValuesStatements({ variables, }) {
223
235
  switch (this.path.termType) {
@@ -234,17 +246,23 @@ export class ObjectType_ShaclProperty extends ObjectType_AbstractProperty {
234
246
  const propertyPath = this.objectType.name
235
247
  .map(() => code `${this.schemaVariable}.path`)
236
248
  .orDefault(this.propertyPathToCode(this.path));
249
+ const { object: objectVariable, ...otherVariables } = variables;
237
250
  return [
238
251
  code `${variables.resource}.add(${propertyPath}, ${this.type.toRdfResourceValuesExpression({
239
- variables: { ...variables, propertyPath },
252
+ variables: {
253
+ ...otherVariables,
254
+ propertyPath,
255
+ value: code `${objectVariable}.${this.name}`,
256
+ },
240
257
  })}, ${variables.graph});`,
241
258
  ];
242
259
  }
243
- toStringInitializer(parameters) {
260
+ toStringInitializer({ variables, }) {
244
261
  if (!this.display) {
245
262
  return Maybe.empty();
246
263
  }
247
- return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression(parameters)}`);
264
+ const { object: objectVariable, ...otherVariables } = variables;
265
+ return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression({ variables: { ...otherVariables, value: code `${objectVariable}.${this.name}` } })}`);
248
266
  }
249
267
  propertyPathToCode(propertyPath) {
250
268
  switch (propertyPath.termType) {
@@ -1,15 +1,12 @@
1
- import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
1
+ import { code, joinCode } from "../ts-poet-wrapper.js";
2
+ const variables = {
3
+ leftObject: code `left`,
4
+ rightObject: code `right`,
5
+ };
2
6
  export function ObjectType_equalsFunctionExpression() {
3
7
  const chain = [];
4
8
  for (const property of this.properties) {
5
- if (property.kind === "Discriminant") {
6
- continue;
7
- }
8
- chain.push(code `${this.reusables.snippets.propertyEquals}(
9
- { equalsFunction: ${property.type.equalsFunction}, name: ${literalOf(property.name)} },
10
- [left, ${property.accessExpression({ variables: { object: code `left` } })}],
11
- [right, ${property.accessExpression({ variables: { object: code `right` } })}],
12
- )`);
9
+ chain.push(...property.equalsExpression({ variables }).toList());
13
10
  }
14
11
  return code `\
15
12
  ((left, right) =>
@@ -1,9 +1,18 @@
1
1
  import { code, joinCode } from "../ts-poet-wrapper.js";
2
+ const variables = {
3
+ filter: code `filter`,
4
+ object: code `value`,
5
+ };
2
6
  export function ObjectType_filterFunctionExpression() {
3
7
  const statements = [];
4
8
  for (const property of this.properties) {
5
- property.filterProperty.ifJust(({ name }) => {
6
- statements.push(code `if (filter.${name} !== undefined && !${property.type.filterFunction}(filter.${name}, ${property.accessExpression({ variables: { object: code `value` } })})) { return false; }`);
9
+ property
10
+ .filterExpression({
11
+ variables,
12
+ })
13
+ .ifJust((filterExpression) => {
14
+ const filterProperty = property.filterProperty.unsafeCoerce();
15
+ statements.push(code `if (${variables.filter}.${filterProperty.name} !== undefined && !${filterExpression}) { return false; }`);
7
16
  });
8
17
  }
9
18
  statements.push(code `return true;`);
@@ -1,24 +1,13 @@
1
- import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
2
1
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
2
  const variables = {
4
3
  filter: code `parameters.filter`,
5
4
  focusIdentifier: code `parameters.focusIdentifier`,
5
+ ignoreRdfType: code `parameters.ignoreRdfType`,
6
6
  variablePrefix: code `parameters.variablePrefix`,
7
7
  };
8
8
  export function ObjectType_focusSparqlConstructTriplesFunctionExpression() {
9
- const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
10
- const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
11
9
  let triplesVariableDeclarationKeyword = "const";
12
10
  const statements = [];
13
- if (this.fromRdfType.isJust()) {
14
- statements.push(code `\
15
- if (!parameters?.ignoreRdfType) {
16
- triples.push(
17
- { subject: ${variables.focusIdentifier}, predicate: ${this.rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} },
18
- { subject: ${rdfTypeVariable}, predicate: ${this.rdfjsTermExpression(rdfs.subClassOf)}, object: ${rdfClassVariable} }
19
- );
20
- }`);
21
- }
22
11
  for (const property of this.properties) {
23
12
  if (property.recursive) {
24
13
  continue;
@@ -1,53 +1,15 @@
1
- import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
2
1
  import { code, joinCode } from "../ts-poet-wrapper.js";
3
- const variables = {
4
- filter: code `parameters.filter`,
5
- preferredLanguages: code `parameters.preferredLanguages`,
6
- focusIdentifier: code `parameters.focusIdentifier`,
7
- variablePrefix: code `parameters.variablePrefix`,
8
- };
9
2
  export function ObjectType_focusSparqlWherePatternsFunctionExpression() {
10
- const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
11
- const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
12
3
  let patternsVariableDeclarationKeyword = "const";
13
4
  const statements = [];
14
- this.fromRdfTypeVariable.ifJust((fromRdfTypeVariable) => {
15
- statements.push(code `const rdfTypeVariable = ${rdfTypeVariable};`, code `\
16
- if (!parameters?.ignoreRdfType) {
17
- patterns.push(
18
- ${code `${this.reusables.snippets.sparqlInstancesOfPattern}({ rdfType: ${fromRdfTypeVariable}, subject: ${variables.focusIdentifier} }),`}
19
- {
20
- triples: [
21
- {
22
- subject: ${variables.focusIdentifier},
23
- predicate: ${this.rdfjsTermExpression(rdf.type)},
24
- object: rdfTypeVariable
25
- }
26
- ],
27
- type: "bgp" as const
28
- },
29
- {
30
- patterns: [
31
- {
32
- triples: [
33
- {
34
- subject: rdfTypeVariable,
35
- predicate: {
36
- items: [${this.rdfjsTermExpression(rdfs.subClassOf)}],
37
- pathType: "+" as const,
38
- type: "path" as const
39
- },
40
- object: ${rdfClassVariable}
41
- }
42
- ],
43
- type: "bgp" as const
44
- }
45
- ],
46
- type: "optional" as const
47
- }
48
- );
49
- }`);
50
- });
5
+ const variables = {
6
+ filter: code `parameters.filter`,
7
+ preferredLanguages: code `parameters.preferredLanguages`,
8
+ focusIdentifier: code `parameters.focusIdentifier`,
9
+ ignoreRdfType: code `parameters.ignoreRdfType`,
10
+ schema: this.name.map((name) => code `${name}.schema`),
11
+ variablePrefix: code `parameters.variablePrefix`,
12
+ };
51
13
  for (const property of this.properties) {
52
14
  if (property.recursive) {
53
15
  continue;
@@ -8,16 +8,20 @@ export function ObjectType_hashFunctionExpression() {
8
8
  const propertyHashStatements = property.hashStatements({
9
9
  variables: {
10
10
  hasher: hasherVariable,
11
- value: code `${this.thisVariable}.${property.name}`,
11
+ object: code `${this.thisVariable}`,
12
12
  },
13
13
  });
14
14
  if (propertyHashStatements.length === 0) {
15
15
  continue;
16
16
  }
17
17
  statements = statements.concat(propertyHashStatements);
18
- if (!codeEquals(property.hashFunctionParameter, property.declaration)) {
18
+ const declaration = property.declaration.extract();
19
+ const hashFunctionParameter = property.hashFunctionParameter.extract();
20
+ if (declaration &&
21
+ hashFunctionParameter &&
22
+ !codeEquals(hashFunctionParameter, declaration)) {
19
23
  replacePropertyDeclarations[property.name] =
20
- code `${property.hashFunctionParameter}`;
24
+ code `${hashFunctionParameter}`;
21
25
  }
22
26
  }
23
27
  statements.push(code `return ${hasherVariable};`);
@@ -1,10 +1,7 @@
1
1
  import { invariant } from "ts-invariant";
2
- import { arrayOf, code } from "../ts-poet-wrapper.js";
2
+ import { code } from "../ts-poet-wrapper.js";
3
3
  export function ObjectType_schemaExpression() {
4
4
  const schema = {};
5
- this.fromRdfType.ifJust((fromRdfType) => {
6
- schema["fromRdfType"] = this.rdfjsTermExpression(fromRdfType);
7
- });
8
5
  const properties = {};
9
6
  for (const property of this.properties) {
10
7
  property.schema.ifJust((propertySchema) => {
@@ -13,9 +10,6 @@ export function ObjectType_schemaExpression() {
13
10
  }
14
11
  invariant(Object.keys(properties).length > 0);
15
12
  schema["properties"] = properties;
16
- if (this.toRdfTypes.length > 0) {
17
- schema["toRdfTypes"] = arrayOf(...this.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)));
18
- }
19
13
  return code `${schema} as const`;
20
14
  }
21
15
  //# sourceMappingURL=ObjectType_schemaExpression.js.map
@@ -2,9 +2,6 @@ import { invariant } from "ts-invariant";
2
2
  import { code } from "../ts-poet-wrapper.js";
3
3
  export function ObjectType_schemaTypeExpression() {
4
4
  const schemaType = {};
5
- this.fromRdfType.ifJust(() => {
6
- schemaType["fromRdfType"] = code `${this.reusables.imports.NamedNode}`;
7
- });
8
5
  const properties = {};
9
6
  for (const property of this.properties) {
10
7
  property.schemaType.ifJust((propertySchemaType) => {
@@ -4,9 +4,7 @@ export function ObjectType_toJsonFunctionExpression() {
4
4
  ((${this.thisVariable}) => JSON.parse(JSON.stringify({ ${joinCode(this.properties.flatMap((property) => property
5
5
  .toJsonInitializer({
6
6
  variables: {
7
- value: property.accessExpression({
8
- variables: { object: this.thisVariable },
9
- }),
7
+ object: this.thisVariable,
10
8
  },
11
9
  })
12
10
  .toList()), { on: "," })} } satisfies ${this.jsonType().expression})))`;
@@ -7,14 +7,7 @@ export function ObjectType_toRdfResourceFunctionExpression() {
7
7
  });
8
8
  for (const property of this.properties) {
9
9
  statements.push(...property.toRdfRdfResourceValuesStatements({
10
- variables: {
11
- graph: variables.graph,
12
- resource: variables.resource,
13
- resourceSet: variables.resourceSet,
14
- value: property.accessExpression({
15
- variables: { object: variables.object },
16
- }),
17
- },
10
+ variables,
18
11
  }));
19
12
  }
20
13
  statements.push(code `return ${variables.resource};`);
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToBigDecimal: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToBigDecimal.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToBigDecimal = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToBigDecimal`, code `\
3
+ const ${syntheticNamePrefix}convertToBigDecimal: ${snippets.ConversionFunction}<number | string | ${imports.BigDecimal}, ${imports.BigDecimal}> = (value) =>
4
+ ${imports.Either}.encase(() => new ${imports.BigDecimal}(value));`);
5
+ //# sourceMappingURL=snippets_convertToBigDecimal.js.map
@@ -0,0 +1,3 @@
1
+ import type { SnippetFactory } from "../SnippetFactory.js";
2
+ export declare const snippets_convertToBigInt: SnippetFactory;
3
+ //# sourceMappingURL=snippets_convertToBigInt.d.ts.map
@@ -0,0 +1,5 @@
1
+ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
2
+ export const snippets_convertToBigInt = ({ imports, snippets, syntheticNamePrefix, }) => conditionalOutput(`${syntheticNamePrefix}convertToBigInt`, code `\
3
+ const ${syntheticNamePrefix}convertToBigInt: ${snippets.ConversionFunction}<bigint | number | string, bigint> = (value) =>
4
+ ${imports.Either}.encase(() => BigInt(value));`);
5
+ //# sourceMappingURL=snippets_convertToBigInt.js.map