@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
@@ -13,6 +13,7 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
13
13
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
14
14
  }
15
15
  export declare namespace AbstractNumericType {
16
+ type ConversionFunction = AbstractPrimitiveType.ConversionFunction;
16
17
  const JsonType: typeof import("./_AbstractType/AbstractType_JsonType.js").AbstractType_JsonType;
17
18
  type JsonType = AbstractPrimitiveType.JsonType;
18
19
  }
@@ -1,5 +1,4 @@
1
1
  import type { Primitive } from "@rdfx/literal";
2
- import { Maybe } from "purify-ts";
3
2
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
4
3
  import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
5
4
  import { type Code } from "./ts-poet-wrapper.js";
@@ -7,12 +6,6 @@ import { type Code } from "./ts-poet-wrapper.js";
7
6
  * Abstract base class of typed literals whose datatype corresponds to a JavaScript primitive type.
8
7
  */
9
8
  export declare abstract class AbstractPrimitiveType<ValueT extends Primitive> extends AbstractTypedLiteralType<ValueT> {
10
- /**
11
- * Primitive types have no conversion functions to avoid source type overlap with other primitive types.
12
- *
13
- * A property that can take on multiple primitive types should be a union.
14
- */
15
- readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
16
9
  readonly equalsFunction: Code;
17
10
  protected get inlineExpression(): Code;
18
11
  fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
@@ -4,7 +4,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
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
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { Maybe } from "purify-ts";
8
7
  import { Memoize } from "typescript-memoize";
9
8
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
10
9
  import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
@@ -13,12 +12,6 @@ import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
13
12
  * Abstract base class of typed literals whose datatype corresponds to a JavaScript primitive type.
14
13
  */
15
14
  export class AbstractPrimitiveType extends AbstractTypedLiteralType {
16
- /**
17
- * Primitive types have no conversion functions to avoid source type overlap with other primitive types.
18
- *
19
- * A property that can take on multiple primitive types should be a union.
20
- */
21
- conversionFunction = Maybe.empty();
22
15
  equalsFunction = code `${this.reusables.snippets.strictEquals}`;
23
16
  get inlineExpression() {
24
17
  if (this.in_.length > 0) {
@@ -6,18 +6,16 @@ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
6
6
  import { type Code } from "./ts-poet-wrapper.js";
7
7
  export declare class BigDecimalType extends AbstractTypedLiteralType<Decimal> {
8
8
  protected readonly inlineExpression: Code;
9
- /**
10
- * BigDecimal has no conversion function to avoid source type overlap with other types (e.g., string).
11
- */
9
+ readonly jsTypes: readonly [{
10
+ readonly className: Code;
11
+ readonly instanceof: "class";
12
+ readonly typeof: "object";
13
+ }];
12
14
  readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
13
15
  readonly filterFunction: Code;
14
16
  readonly filterType: Code;
15
17
  readonly fromRdfResourceValuesFunction: Code;
16
18
  readonly hashFunction: Code;
17
- readonly jsTypes: readonly [{
18
- readonly instanceof: "Object";
19
- readonly typeof: "object";
20
- }];
21
19
  readonly kind = "BigDecimal";
22
20
  readonly schemaType: Code;
23
21
  readonly valueSparqlWherePatternsFunction: Code;
@@ -26,8 +24,8 @@ export declare class BigDecimalType extends AbstractTypedLiteralType<Decimal> {
26
24
  graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
27
25
  jsonSchema(): Code;
28
26
  jsonType(): AbstractLiteralType.JsonType;
29
- valueExpression(literal: Literal): Code;
30
27
  toJsonExpression({ variables, }: Parameters<AbstractTypedLiteralType<Decimal>["toJsonExpression"]>[0]): Code;
31
28
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractLiteralType["toRdfResourceValuesExpression"]>[0]): Code;
29
+ valueExpression(literal: Literal): Code;
32
30
  }
33
31
  //# sourceMappingURL=BigDecimalType.d.ts.map
@@ -11,17 +11,34 @@ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
11
11
  import { code, literalOf } from "./ts-poet-wrapper.js";
12
12
  export class BigDecimalType extends AbstractTypedLiteralType {
13
13
  inlineExpression = code `${this.reusables.imports.BigDecimal}`;
14
- /**
15
- * BigDecimal has no conversion function to avoid source type overlap with other types (e.g., string).
16
- */
17
- conversionFunction = Maybe.empty();
14
+ jsTypes = [
15
+ {
16
+ className: code `${this.reusables.imports.BigDecimal}`,
17
+ instanceof: "class",
18
+ typeof: "object",
19
+ },
20
+ ];
21
+ conversionFunction = Maybe.of({
22
+ code: code `${this.reusables.snippets.convertToBigDecimal}`,
23
+ sourceTypes: [
24
+ {
25
+ expression: code `${this.reusables.imports.BigDecimal}`,
26
+ jsType: this.jsTypes[0],
27
+ },
28
+ {
29
+ expression: code `number`,
30
+ jsType: { typeof: "number" },
31
+ },
32
+ {
33
+ expression: code `string`,
34
+ jsType: { typeof: "string" },
35
+ },
36
+ ],
37
+ });
18
38
  filterFunction = code `${this.reusables.snippets.filterBigDecimal}`;
19
39
  filterType = code `${this.reusables.snippets.NumericFilter}<${this.reusables.imports.BigDecimal}>`;
20
40
  fromRdfResourceValuesFunction = code `${this.reusables.snippets.bigDecimalFromRdfResourceValues}`;
21
41
  hashFunction = code `${this.reusables.snippets.hashBigDecimal}`;
22
- jsTypes = [
23
- { instanceof: "Object", typeof: "object" },
24
- ];
25
42
  kind = "BigDecimal";
26
43
  schemaType = code `${this.reusables.snippets.NumericSchema}<${this.reusables.imports.BigDecimal}>`;
27
44
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.bigDecimalSparqlWherePatterns}`;
@@ -40,15 +57,15 @@ export class BigDecimalType extends AbstractTypedLiteralType {
40
57
  jsonType() {
41
58
  return new AbstractLiteralType.JsonType(code `{ readonly "@type": ${literalOf(this.datatype.value)}, readonly "@value": string }`);
42
59
  }
43
- valueExpression(literal) {
44
- return code `new ${this.reusables.imports.BigDecimal}(${literalOf(literal.value)})`;
45
- }
46
60
  toJsonExpression({ variables, }) {
47
61
  return code `{ "@type": ${literalOf(this.datatype.value)} as const, "@value": ${variables.value}.toFixed() }`;
48
62
  }
49
63
  toRdfResourceValuesExpression({ variables, }) {
50
64
  return code `[${this.reusables.snippets.bigDecimalLiteral}(${variables.value})]`;
51
65
  }
66
+ valueExpression(literal) {
67
+ return code `new ${this.reusables.imports.BigDecimal}(${literalOf(literal.value)})`;
68
+ }
52
69
  }
53
70
  __decorate([
54
71
  Memoize()
@@ -1,4 +1,5 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
2
3
  import { AbstractNumericType } from "./AbstractNumericType.js";
3
4
  import { type Code } from "./ts-poet-wrapper.js";
4
5
  export declare class BigIntType extends AbstractNumericType<bigint> {
@@ -6,6 +7,7 @@ export declare class BigIntType extends AbstractNumericType<bigint> {
6
7
  readonly typeof: "bigint";
7
8
  }[];
8
9
  readonly kind = "BigInt";
10
+ get conversionFunction(): Maybe<AbstractNumericType.ConversionFunction>;
9
11
  get fromRdfResourceValuesFunction(): Code;
10
12
  get graphqlType(): import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
11
13
  private get decodedIn();
@@ -5,12 +5,35 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { LiteralDecoder } from "@rdfx/literal";
8
+ import { Maybe } from "purify-ts";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractNumericType } from "./AbstractNumericType.js";
10
11
  import { arrayOf, code, joinCode, literalOf, } from "./ts-poet-wrapper.js";
11
12
  export class BigIntType extends AbstractNumericType {
12
13
  jsTypes = [{ typeof: "bigint" }];
13
14
  kind = "BigInt";
15
+ get conversionFunction() {
16
+ if (this.in_.length > 0) {
17
+ return Maybe.empty();
18
+ }
19
+ return Maybe.of({
20
+ code: code `${this.reusables.snippets.convertToBigInt}`,
21
+ sourceTypes: [
22
+ {
23
+ expression: code `bigint`,
24
+ jsType: this.jsTypes[0],
25
+ },
26
+ {
27
+ expression: code `number`,
28
+ jsType: { typeof: "number" },
29
+ },
30
+ {
31
+ expression: code `string`,
32
+ jsType: { typeof: "string" },
33
+ },
34
+ ],
35
+ });
36
+ }
14
37
  get fromRdfResourceValuesFunction() {
15
38
  return code `${this.reusables.snippets.bigIntFromRdfResourceValues}<${this.expression}>`;
16
39
  }
@@ -58,6 +81,9 @@ export class BigIntType extends AbstractNumericType {
58
81
  return code `${typeof literal === "bigint" ? literal : LiteralDecoder.decodeBigIntLiteral(literal).unsafeCoerce()}n`;
59
82
  }
60
83
  }
84
+ __decorate([
85
+ Memoize()
86
+ ], BigIntType.prototype, "conversionFunction", null);
61
87
  __decorate([
62
88
  Memoize()
63
89
  ], BigIntType.prototype, "fromRdfResourceValuesFunction", null);
@@ -1,7 +1,9 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
2
3
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
3
4
  import { type Code } from "./ts-poet-wrapper.js";
4
5
  export declare class BooleanType extends AbstractPrimitiveType<boolean> {
6
+ readonly conversionFunction: Maybe<AbstractPrimitiveType.ConversionFunction>;
5
7
  readonly filterFunction: Code;
6
8
  readonly filterType: Code;
7
9
  readonly graphqlType: import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
@@ -5,10 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { LiteralDecoder } from "@rdfx/literal";
8
+ import { Maybe } from "purify-ts";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
10
11
  import { code } from "./ts-poet-wrapper.js";
11
12
  export class BooleanType extends AbstractPrimitiveType {
13
+ conversionFunction = Maybe.empty();
12
14
  filterFunction = code `${this.reusables.snippets.filterBoolean}`;
13
15
  filterType = code `${this.reusables.snippets.BooleanFilter}`;
14
16
  graphqlType = new AbstractPrimitiveType.GraphqlType(code `${this.reusables.imports.GraphQLBoolean}`, this.reusables);
@@ -19,7 +19,8 @@ export declare class DefaultValueType<ItemTypeT extends DefaultValueType.ItemTyp
19
19
  readonly instanceof: "Object";
20
20
  readonly typeof: "object";
21
21
  }] | readonly [{
22
- readonly instanceof: "Object";
22
+ readonly className: Code;
23
+ readonly instanceof: "class";
23
24
  readonly typeof: "object";
24
25
  }] | {
25
26
  readonly typeof: "bigint";
@@ -1,7 +1,9 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
2
3
  import { AbstractNumericType } from "./AbstractNumericType.js";
3
4
  import { type Code } from "./ts-poet-wrapper.js";
4
5
  export declare class FloatType extends AbstractNumericType<number> {
6
+ readonly conversionFunction: Maybe<AbstractNumericType.ConversionFunction>;
5
7
  readonly jsTypes: readonly [{
6
8
  readonly typeof: "number";
7
9
  }];
@@ -5,10 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { LiteralDecoder } from "@rdfx/literal";
8
+ import { Maybe } from "purify-ts";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractNumericType } from "./AbstractNumericType.js";
10
11
  import { code } from "./ts-poet-wrapper.js";
11
12
  export class FloatType extends AbstractNumericType {
13
+ conversionFunction = Maybe.empty();
12
14
  jsTypes = [{ typeof: "number" }];
13
15
  kind = "Float";
14
16
  get fromRdfResourceValuesFunction() {
@@ -1,7 +1,9 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
2
3
  import { AbstractNumericType } from "./AbstractNumericType.js";
3
4
  import { type Code } from "./ts-poet-wrapper.js";
4
5
  export declare class IntType extends AbstractNumericType<number> {
6
+ readonly conversionFunction: Maybe<AbstractNumericType.ConversionFunction>;
5
7
  readonly jsTypes: readonly [{
6
8
  readonly typeof: "number";
7
9
  }];
@@ -5,10 +5,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { LiteralDecoder } from "@rdfx/literal";
8
+ import { Maybe } from "purify-ts";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractNumericType } from "./AbstractNumericType.js";
10
11
  import { code } from "./ts-poet-wrapper.js";
11
12
  export class IntType extends AbstractNumericType {
13
+ conversionFunction = Maybe.empty();
12
14
  jsTypes = [{ typeof: "number" }];
13
15
  kind = "Int";
14
16
  get fromRdfResourceValuesFunction() {
@@ -1,8 +1,8 @@
1
- import type { NamedNode } from "@rdfjs/types";
2
1
  import { Maybe } from "purify-ts";
3
2
  import { ObjectType_DiscriminantProperty } from "./_ObjectType/ObjectType_DiscriminantProperty.js";
4
3
  import { ObjectType_IdentifierProperty } from "./_ObjectType/ObjectType_IdentifierProperty.js";
5
4
  import type { ObjectType_Property } from "./_ObjectType/ObjectType_Property.js";
5
+ import { ObjectType_RdfTypeProperty } from "./_ObjectType/ObjectType_RdfTypeProperty.js";
6
6
  import { ObjectType_ShaclProperty } from "./_ObjectType/ObjectType_ShaclProperty.js";
7
7
  import { AbstractType } from "./AbstractType.js";
8
8
  import type { BlankNodeType } from "./BlankNodeType.js";
@@ -11,10 +11,8 @@ import type { IriType } from "./IriType.js";
11
11
  import type { Type } from "./Type.js";
12
12
  import { type Code } from "./ts-poet-wrapper.js";
13
13
  export declare class ObjectType extends AbstractType {
14
- protected readonly toRdfTypes: readonly NamedNode[];
15
14
  readonly discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
16
15
  readonly extern: boolean;
17
- readonly fromRdfType: Maybe<NamedNode>;
18
16
  readonly graphqlArgs: AbstractType["graphqlArgs"];
19
17
  readonly identifierType: BlankNodeType | IdentifierType | IriType;
20
18
  readonly jsTypes: readonly [{
@@ -22,20 +20,20 @@ export declare class ObjectType extends AbstractType {
22
20
  readonly typeof: "object";
23
21
  }];
24
22
  readonly kind = "Object";
23
+ readonly rdfTypeProperty: Maybe<ObjectType.RdfTypeProperty>;
25
24
  readonly recursive: boolean;
26
25
  readonly synthetic: boolean;
27
26
  readonly validationFunction: Maybe<Code>;
28
- constructor({ discriminantProperty, extern, fromRdfType, identifierType, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }: {
27
+ constructor({ discriminantProperty, extern, identifierType, lazyProperties, rdfTypeProperty, recursive, synthetic, ...superParameters }: {
29
28
  discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
30
29
  comment: Maybe<string>;
31
30
  extern: boolean;
32
- fromRdfType: Maybe<NamedNode>;
33
31
  identifierType: BlankNodeType | IdentifierType | IriType;
34
32
  label: Maybe<string>;
35
33
  lazyProperties: (objectType: ObjectType) => readonly ObjectType.Property[];
34
+ rdfTypeProperty: Maybe<ObjectType.RdfTypeProperty>;
36
35
  recursive: boolean;
37
36
  synthetic: boolean;
38
- toRdfTypes: readonly NamedNode[];
39
37
  } & ConstructorParameters<typeof AbstractType>[0]);
40
38
  get conversionFunction(): Maybe<AbstractType.ConversionFunction>;
41
39
  protected staticModuleDeclarations(name: string): Record<string, Code>;
@@ -53,6 +51,7 @@ export declare class ObjectType extends AbstractType {
53
51
  get properties(): readonly ObjectType.Property[];
54
52
  get referencesNamedType(): boolean;
55
53
  get schemaExpression(): Code;
54
+ get schemaVariable(): Maybe<Code>;
56
55
  get schemaType(): Code;
57
56
  get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
58
57
  get toRdfjsResourceType(): Code;
@@ -102,5 +101,7 @@ export declare namespace ObjectType {
102
101
  type ShaclProperty<TypeT extends Type> = ObjectType_ShaclProperty<TypeT>;
103
102
  const DiscriminantProperty: typeof ObjectType_DiscriminantProperty;
104
103
  type DiscriminantProperty = ObjectType_DiscriminantProperty;
104
+ const RdfTypeProperty: typeof ObjectType_RdfTypeProperty;
105
+ type RdfTypeProperty = ObjectType_RdfTypeProperty;
105
106
  }
106
107
  //# sourceMappingURL=ObjectType.d.ts.map
@@ -27,6 +27,7 @@ import { ObjectType_jsonSchemaExpression } from "./_ObjectType/ObjectType_jsonSc
27
27
  import { ObjectType_jsonTypeExpression } from "./_ObjectType/ObjectType_jsonTypeExpression.js";
28
28
  import { ObjectType_jsonUiSchemaFunctionExpression } from "./_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js";
29
29
  import { ObjectType_objectSetMethodNames } from "./_ObjectType/ObjectType_objectSetMethodNames.js";
30
+ import { ObjectType_RdfTypeProperty } from "./_ObjectType/ObjectType_RdfTypeProperty.js";
30
31
  import { ObjectType_ShaclProperty } from "./_ObjectType/ObjectType_ShaclProperty.js";
31
32
  import { ObjectType_schemaExpression } from "./_ObjectType/ObjectType_schemaExpression.js";
32
33
  import { ObjectType_schemaTypeExpression } from "./_ObjectType/ObjectType_schemaTypeExpression.js";
@@ -42,30 +43,28 @@ import { ObjectType_valueSparqlWherePatternsFunctionExpression } from "./_Object
42
43
  import { AbstractType } from "./AbstractType.js";
43
44
  import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
44
45
  export class ObjectType extends AbstractType {
45
- toRdfTypes;
46
46
  discriminantProperty;
47
47
  extern;
48
- fromRdfType;
49
48
  graphqlArgs = Maybe.empty();
50
49
  identifierType;
51
50
  jsTypes = [
52
51
  { instanceof: "Object", typeof: "object" },
53
52
  ];
54
53
  kind = "Object";
54
+ rdfTypeProperty;
55
55
  recursive;
56
56
  synthetic;
57
57
  validationFunction = Maybe.empty();
58
- constructor({ discriminantProperty, extern, fromRdfType, identifierType, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }) {
58
+ constructor({ discriminantProperty, extern, identifierType, lazyProperties, rdfTypeProperty, recursive, synthetic, ...superParameters }) {
59
59
  super(superParameters);
60
60
  this.discriminantProperty = discriminantProperty;
61
61
  this.extern = extern;
62
- this.fromRdfType = fromRdfType;
63
62
  this.identifierType = identifierType;
64
63
  // Lazily initialize some members in getters to avoid recursive construction
65
64
  this.lazyProperties = lazyProperties;
65
+ this.rdfTypeProperty = rdfTypeProperty;
66
66
  this.recursive = recursive;
67
67
  this.synthetic = synthetic;
68
- this.toRdfTypes = toRdfTypes;
69
68
  }
70
69
  get conversionFunction() {
71
70
  if (this.name.isJust()) {
@@ -260,9 +259,9 @@ export class ObjectType extends AbstractType {
260
259
  .orDefaultLazy(() => code `((values, options) => values.chainMap(value => value.toResource().chain(resource => ${ObjectType_fromRdfResourceFunctionExpression.call(this)}(resource, options))))`);
261
260
  }
262
261
  get fromRdfTypeVariable() {
263
- return this.fromRdfType.map((fromRdfType) => this.name
264
- .map((name) => code `${name}.schema.fromRdfType`)
265
- .orDefaultLazy(() => this.rdfjsTermExpression(fromRdfType)));
262
+ return this.rdfTypeProperty.map((rdfTypeProperty) => this.name
263
+ .map((name) => code `${name}.schema.properties.${rdfTypeProperty.name}.fromRdfType`)
264
+ .orDefaultLazy(() => this.rdfjsTermExpression(rdfTypeProperty.fromRdfType)));
266
265
  }
267
266
  get graphqlType() {
268
267
  return new AbstractType.GraphqlType(this.name
@@ -306,6 +305,9 @@ export class ObjectType extends AbstractType {
306
305
  get schemaExpression() {
307
306
  return ObjectType_schemaExpression.call(this);
308
307
  }
308
+ get schemaVariable() {
309
+ return this.name.map((name) => code `${name}.schema`);
310
+ }
309
311
  get schemaType() {
310
312
  return this.name
311
313
  .map((name) => code `${name}.Schema`)
@@ -369,12 +371,9 @@ export class ObjectType extends AbstractType {
369
371
  .orDefaultLazy(() => ObjectType_toJsonFunctionExpression.call(this));
370
372
  }
371
373
  get toRdfTypesVariable() {
372
- if (this.toRdfTypes.length === 0) {
373
- return Maybe.empty();
374
- }
375
- return Maybe.of(this.name
376
- .map((name) => code `${name}.schema.toRdfTypes`)
377
- .orDefaultLazy(() => code `${arrayOf(...this.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)))}`));
374
+ return this.rdfTypeProperty.map((rdfTypeProperty) => this.schemaVariable
375
+ .map((schemaVariable) => code `${schemaVariable}.properties.${rdfTypeProperty.name}.toRdfTypes`)
376
+ .orDefaultLazy(() => code `${arrayOf(...rdfTypeProperty.toRdfTypes.map((toRdfType) => this.rdfjsTermExpression(toRdfType)))}`));
378
377
  }
379
378
  get toStringFunction() {
380
379
  return this.name
@@ -382,7 +381,7 @@ export class ObjectType extends AbstractType {
382
381
  .orDefaultLazy(() => ObjectType_toStringFunctionExpression.call(this));
383
382
  }
384
383
  get inlineExpression() {
385
- return code `{ ${joinCode(this.properties.map((property) => property.declaration), { on: "\n\n" })} }`;
384
+ return code `{ ${joinCode(this.properties.flatMap((property) => property.declaration.toList()), { on: "\n\n" })} }`;
386
385
  }
387
386
  fromJsonExpression({ variables, }) {
388
387
  // Assumes the JSON object has been recursively validated already.
@@ -434,9 +433,7 @@ export class ObjectType extends AbstractType {
434
433
  return code `${this.reusables.snippets.compactRecord}({${joinCode(this.properties.flatMap((property) => property
435
434
  .toStringInitializer({
436
435
  variables: {
437
- value: property.accessExpression({
438
- variables: { object: variables.value },
439
- }),
436
+ object: variables.value,
440
437
  },
441
438
  })
442
439
  .toList()), { on: "," })}})`;
@@ -485,6 +482,9 @@ __decorate([
485
482
  __decorate([
486
483
  Memoize()
487
484
  ], ObjectType.prototype, "schemaExpression", null);
485
+ __decorate([
486
+ Memoize()
487
+ ], ObjectType.prototype, "schemaVariable", null);
488
488
  __decorate([
489
489
  Memoize()
490
490
  ], ObjectType.prototype, "schemaType", null);
@@ -528,5 +528,6 @@ __decorate([
528
528
  ObjectType.IdentifierProperty = ObjectType_IdentifierProperty;
529
529
  ObjectType.ShaclProperty = ObjectType_ShaclProperty;
530
530
  ObjectType.DiscriminantProperty = ObjectType_DiscriminantProperty;
531
+ ObjectType.RdfTypeProperty = ObjectType_RdfTypeProperty;
531
532
  })(ObjectType || (ObjectType = {}));
532
533
  //# sourceMappingURL=ObjectType.js.map
@@ -77,6 +77,8 @@ export declare class Snippets {
77
77
  get booleanSparqlWherePatterns(): Snippet;
78
78
  get compactRecord(): Snippet;
79
79
  get convertToArraySet(): Snippet;
80
+ get convertToBigDecimal(): Snippet;
81
+ get convertToBigInt(): Snippet;
80
82
  get convertToBlankNode(): Snippet;
81
83
  get convertToBlankNodeIdentifierProperty(): Snippet;
82
84
  get convertToIdentifier(): Snippet;
@@ -28,6 +28,8 @@ import { snippets_CollectionSchema } from "./_snippets/snippets_CollectionSchema
28
28
  import { snippets_ConversionFunction } from "./_snippets/snippets_ConversionFunction.js";
29
29
  import { snippets_compactRecord } from "./_snippets/snippets_compactRecord.js";
30
30
  import { snippets_convertToArraySet } from "./_snippets/snippets_convertToArraySet.js";
31
+ import { snippets_convertToBigDecimal } from "./_snippets/snippets_convertToBigDecimal.js";
32
+ import { snippets_convertToBigInt } from "./_snippets/snippets_convertToBigInt.js";
31
33
  import { snippets_convertToBlankNode } from "./_snippets/snippets_convertToBlankNode.js";
32
34
  import { snippets_convertToBlankNodeIdentifierProperty } from "./_snippets/snippets_convertToBlankNodeIdentifierProperty.js";
33
35
  import { snippets_convertToIdentifier } from "./_snippets/snippets_convertToIdentifier.js";
@@ -383,6 +385,12 @@ export class Snippets {
383
385
  get convertToArraySet() {
384
386
  return this.snippet(snippets_convertToArraySet);
385
387
  }
388
+ get convertToBigDecimal() {
389
+ return this.snippet(snippets_convertToBigDecimal);
390
+ }
391
+ get convertToBigInt() {
392
+ return this.snippet(snippets_convertToBigInt);
393
+ }
386
394
  get convertToBlankNode() {
387
395
  return this.snippet(snippets_convertToBlankNode);
388
396
  }
@@ -933,6 +941,12 @@ __decorate([
933
941
  __decorate([
934
942
  Memoize()
935
943
  ], Snippets.prototype, "convertToArraySet", null);
944
+ __decorate([
945
+ Memoize()
946
+ ], Snippets.prototype, "convertToBigDecimal", null);
947
+ __decorate([
948
+ Memoize()
949
+ ], Snippets.prototype, "convertToBigInt", null);
936
950
  __decorate([
937
951
  Memoize()
938
952
  ], Snippets.prototype, "convertToBlankNode", null);
@@ -1,8 +1,10 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
2
3
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
3
4
  import { type Code } from "./ts-poet-wrapper.js";
4
5
  export declare class StringType extends AbstractPrimitiveType<string> {
5
6
  private readonly languageIn;
7
+ readonly conversionFunction: Maybe<AbstractPrimitiveType.ConversionFunction>;
6
8
  readonly filterFunction: Code;
7
9
  readonly filterType: Code;
8
10
  readonly graphqlType: import("./_AbstractType/AbstractType_GraphqlType.js").AbstractType_GraphqlType;
@@ -19,7 +21,7 @@ export declare class StringType extends AbstractPrimitiveType<string> {
19
21
  get schemaType(): Code;
20
22
  protected get schemaInitializers(): readonly Code[];
21
23
  jsonSchema(parameters: Parameters<AbstractPrimitiveType<string>["jsonSchema"]>[0]): Code;
22
- valueExpression(literal: Literal | string): Code;
23
24
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
25
+ valueExpression(literal: Literal | string): Code;
24
26
  }
25
27
  //# sourceMappingURL=StringType.d.ts.map
@@ -5,11 +5,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
7
  import { xsd } from "@tpluscode/rdf-ns-builders";
8
+ import { Maybe } from "purify-ts";
8
9
  import { Memoize } from "typescript-memoize";
9
10
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
10
11
  import { arrayOf, code, literalOf } from "./ts-poet-wrapper.js";
11
12
  export class StringType extends AbstractPrimitiveType {
12
13
  languageIn;
14
+ conversionFunction = Maybe.empty();
13
15
  filterFunction = code `${this.reusables.snippets.filterString}`;
14
16
  filterType = code `${this.reusables.snippets.StringFilter}`;
15
17
  graphqlType = new AbstractPrimitiveType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
@@ -51,12 +53,12 @@ export class StringType extends AbstractPrimitiveType {
51
53
  }
52
54
  return super.jsonSchema(parameters);
53
55
  }
54
- valueExpression(literal) {
55
- return code `${literalOf(typeof literal === "string" ? literal : literal.value)}`;
56
- }
57
56
  toRdfResourceValuesExpression({ variables, }) {
58
57
  return code `[${this.reusables.snippets.literalFactory}.string(${variables.value}${!this.datatype.equals(xsd.string) ? `, ${this.rdfjsTermExpression(this.datatype)}` : ""})]`;
59
58
  }
59
+ valueExpression(literal) {
60
+ return code `${literalOf(typeof literal === "string" ? literal : literal.value)}`;
61
+ }
60
62
  }
61
63
  __decorate([
62
64
  Memoize()
@@ -56,13 +56,20 @@ export class TypeFactory {
56
56
  reusables: this.reusables,
57
57
  value: name,
58
58
  }));
59
+ const rdfTypeProperty = astType.fromRdfType.map((fromRdfType) => new ObjectType.RdfTypeProperty({
60
+ configuration: this.configuration,
61
+ fromRdfType,
62
+ logger: this.logger,
63
+ objectType: { name: astType.name },
64
+ reusables: this.reusables,
65
+ toRdfTypes: astType.toRdfTypes,
66
+ }));
59
67
  const identifierType = this.createIdentifierType(astType.identifierType);
60
68
  const objectType = new ObjectType({
61
69
  discriminantProperty,
62
70
  comment: astType.comment,
63
71
  configuration: this.configuration,
64
72
  extern: astType.extern,
65
- fromRdfType: astType.fromRdfType,
66
73
  identifierType,
67
74
  label: astType.label,
68
75
  lazyProperties: (objectType) => {
@@ -83,6 +90,9 @@ export class TypeFactory {
83
90
  discriminantProperty.ifJust((discriminantProperty) => {
84
91
  properties.splice(0, 0, discriminantProperty);
85
92
  });
93
+ rdfTypeProperty.ifJust((rdfTypeProperty) => {
94
+ properties.splice(0, 0, rdfTypeProperty);
95
+ });
86
96
  properties.splice(0, 0, new ObjectType.IdentifierProperty({
87
97
  configuration: this.configuration,
88
98
  logger: this.logger,
@@ -95,11 +105,11 @@ export class TypeFactory {
95
105
  },
96
106
  logger: this.logger,
97
107
  name: astType.name.map((name) => this.tsName(name, { synthetic: astType.synthetic })),
108
+ rdfTypeProperty,
98
109
  recursive: astType.recursive,
99
110
  reusables: this.reusables,
100
111
  shapeIdentifier: astType.shapeIdentifier,
101
112
  synthetic: astType.synthetic,
102
- toRdfTypes: astType.toRdfTypes,
103
113
  });
104
114
  this.cachedObjectTypesByShapeIdentifier.set(astType.shapeIdentifier, objectType);
105
115
  return objectType;
@@ -5,6 +5,8 @@ import { code, joinCode } from "../ts-poet-wrapper.js";
5
5
  export function AbstractDiscriminatedUnionType_conversionFunctionExpression() {
6
6
  if (this.discriminant.kind === "Typeof") {
7
7
  // If the members are discriminated by typeof, they can all be used as source types.
8
+ // Don't consider the member types' conversion functions, since the source types might overlap.
9
+ // Only consider the member types' declared type(s) (e.g., type.jsTypes).
8
10
  return Maybe.of({
9
11
  code: code `${this.reusables.snippets.identityConversionFunction}`,
10
12
  sourceTypes: this.members.flatMap(({ type }) => type.jsTypes.map((jsType) => ({