@shaclmate/compiler 4.0.52 → 4.0.53

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 (55) hide show
  1. package/dist/generators/ts/AbstractContainerType.d.ts +2 -1
  2. package/dist/generators/ts/AbstractContainerType.js +1 -0
  3. package/dist/generators/ts/AbstractDateType.d.ts +8 -8
  4. package/dist/generators/ts/AbstractDateType.js +7 -16
  5. package/dist/generators/ts/AbstractLiteralType.d.ts +3 -4
  6. package/dist/generators/ts/AbstractLiteralType.js +3 -5
  7. package/dist/generators/ts/AbstractNumericType.d.ts +0 -2
  8. package/dist/generators/ts/AbstractNumericType.js +1 -20
  9. package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -13
  10. package/dist/generators/ts/AbstractPrimitiveType.js +22 -19
  11. package/dist/generators/ts/AbstractTypedLiteralType.d.ts +32 -0
  12. package/dist/generators/ts/AbstractTypedLiteralType.js +36 -0
  13. package/dist/generators/ts/BigDecimalType.d.ts +4 -2
  14. package/dist/generators/ts/BigDecimalType.js +6 -11
  15. package/dist/generators/ts/BigIntType.js +20 -9
  16. package/dist/generators/ts/BooleanType.d.ts +0 -2
  17. package/dist/generators/ts/BooleanType.js +0 -15
  18. package/dist/generators/ts/DateTimeType.d.ts +1 -1
  19. package/dist/generators/ts/DateTimeType.js +4 -4
  20. package/dist/generators/ts/DateType.d.ts +1 -2
  21. package/dist/generators/ts/DateType.js +4 -4
  22. package/dist/generators/ts/DefaultValueType.d.ts +3 -0
  23. package/dist/generators/ts/LangStringType.d.ts +31 -0
  24. package/dist/generators/ts/LangStringType.js +67 -0
  25. package/dist/generators/ts/ListType.d.ts +2 -1
  26. package/dist/generators/ts/ListType.js +1 -0
  27. package/dist/generators/ts/LiteralType.d.ts +4 -0
  28. package/dist/generators/ts/LiteralType.js +5 -0
  29. package/dist/generators/ts/Snippets.d.ts +4 -1
  30. package/dist/generators/ts/Snippets.js +28 -7
  31. package/dist/generators/ts/StringType.d.ts +5 -2
  32. package/dist/generators/ts/StringType.js +9 -17
  33. package/dist/generators/ts/Type.d.ts +2 -1
  34. package/dist/generators/ts/TypeFactory.js +32 -81
  35. package/dist/generators/ts/UnionType.d.ts +1 -1
  36. package/dist/generators/ts/_snippets/snippets_LangStringSchema.d.ts +3 -0
  37. package/dist/generators/ts/_snippets/snippets_LangStringSchema.js +4 -0
  38. package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +1 -0
  39. package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +1 -1
  40. package/dist/generators/ts/_snippets/snippets_convertToLangString.d.ts +3 -0
  41. package/dist/generators/ts/_snippets/snippets_convertToLangString.js +15 -0
  42. package/dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.d.ts +3 -0
  43. package/dist/generators/ts/_snippets/snippets_langStringFromRdfResourceValues.js +6 -0
  44. package/dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.d.ts +3 -0
  45. package/dist/generators/ts/_snippets/snippets_langStringSparqlWherePatterns.js +5 -0
  46. package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +1 -1
  47. package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +1 -1
  48. package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.js +4 -1
  49. package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +2 -2
  50. package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +1 -1
  51. package/dist/generators/ts/rdfjsTermExpression.js +1 -0
  52. package/dist/input/input.shaclmate.js +3 -3
  53. package/package.json +19 -8
  54. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.d.ts +0 -3
  55. package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.js +0 -9
@@ -10,6 +10,7 @@ import type { FloatType } from "./FloatType.js";
10
10
  import type { IdentifierType } from "./IdentifierType.js";
11
11
  import type { IntType } from "./IntType.js";
12
12
  import type { IriType } from "./IriType.js";
13
+ import type { LangStringType } from "./LangStringType.js";
13
14
  import type { ListType } from "./ListType.js";
14
15
  import type { LiteralType } from "./LiteralType.js";
15
16
  import type { ObjectType } from "./ObjectType.js";
@@ -45,7 +46,7 @@ export declare namespace AbstractContainerType {
45
46
  type DiscriminantProperty = AbstractType.DiscriminantProperty;
46
47
  const GraphqlType: typeof AbstractType.GraphqlType;
47
48
  type GraphqlType = AbstractType.GraphqlType;
48
- type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
49
+ type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | LangStringType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
49
50
  function isItemType(type: Type): type is ItemType;
50
51
  const JsonType: typeof AbstractType.JsonType;
51
52
  type JsonType = AbstractType.JsonType;
@@ -74,6 +74,7 @@ __decorate([
74
74
  case "Identifier":
75
75
  case "Int":
76
76
  case "Iri":
77
+ case "LangString":
77
78
  case "List":
78
79
  case "Literal":
79
80
  case "Object":
@@ -1,7 +1,9 @@
1
- import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
1
+ import { Maybe } from "purify-ts";
2
+ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
2
3
  import { type Code } from "./ts-poet-wrapper.js";
3
- export declare abstract class AbstractDateType extends AbstractPrimitiveType<Date> {
4
+ export declare abstract class AbstractDateType extends AbstractTypedLiteralType<Date> {
4
5
  protected readonly inlineExpression: Code;
6
+ readonly conversionFunction: Maybe<AbstractTypedLiteralType.ConversionFunction>;
5
7
  readonly equalsFunction: Code;
6
8
  readonly filterFunction: Code;
7
9
  readonly filterType: Code;
@@ -9,15 +11,13 @@ export declare abstract class AbstractDateType extends AbstractPrimitiveType<Dat
9
11
  readonly instanceof: "Date";
10
12
  readonly typeof: "object";
11
13
  }];
12
- abstract readonly kind: "DateTime" | "Date";
13
- readonly mutable = false;
14
14
  readonly schemaType: Code;
15
15
  readonly valueSparqlWherePatternsFunction: Code;
16
- fromJsonExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromJsonExpression"]>[0]): Code;
17
- jsonType(): AbstractPrimitiveType.JsonType;
18
- toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["toRdfResourceValuesExpression"]>[0]): Code;
16
+ fromJsonExpression({ variables, }: Parameters<AbstractTypedLiteralType<Date>["fromJsonExpression"]>[0]): Code;
17
+ jsonType(): AbstractTypedLiteralType.JsonType;
18
+ toRdfResourceValuesExpression({ variables, }: Parameters<AbstractTypedLiteralType<Date>["toRdfResourceValuesExpression"]>[0]): Code;
19
19
  }
20
20
  export declare namespace AbstractDateType {
21
- type ConversionFunction = AbstractPrimitiveType.ConversionFunction;
21
+ type ConversionFunction = AbstractTypedLiteralType.ConversionFunction;
22
22
  }
23
23
  //# sourceMappingURL=AbstractDateType.d.ts.map
@@ -1,14 +1,9 @@
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 { Memoize } from "typescript-memoize";
8
- import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
9
- import { code } from "./ts-poet-wrapper.js";
10
- export class AbstractDateType extends AbstractPrimitiveType {
1
+ import { Maybe } from "purify-ts";
2
+ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
3
+ import { code, literalOf } from "./ts-poet-wrapper.js";
4
+ export class AbstractDateType extends AbstractTypedLiteralType {
11
5
  inlineExpression = code `Date`;
6
+ conversionFunction = Maybe.empty();
12
7
  equalsFunction = code `${this.reusables.snippets.dateEquals}`;
13
8
  filterFunction = code `${this.reusables.snippets.filterDate}`;
14
9
  filterType = code `${this.reusables.snippets.DateFilter}`;
@@ -18,20 +13,16 @@ export class AbstractDateType extends AbstractPrimitiveType {
18
13
  typeof: "object",
19
14
  },
20
15
  ];
21
- mutable = false;
22
16
  schemaType = code `${this.reusables.snippets.DateSchema}`;
23
17
  valueSparqlWherePatternsFunction = code `${this.reusables.snippets.dateSparqlWherePatterns}`;
24
18
  fromJsonExpression({ variables, }) {
25
- return code `${this.reusables.imports.Either}.of<Error, Date>(new Date(${variables.value}))`;
19
+ return code `${this.reusables.imports.Either}.of<Error, Date>(new Date(${variables.value}["@value"]))`;
26
20
  }
27
21
  jsonType() {
28
- return new AbstractPrimitiveType.JsonType(code `string`);
22
+ return new AbstractTypedLiteralType.JsonType(code `{ readonly "@type": ${literalOf(this.datatype.value)}, readonly "@value": string }`);
29
23
  }
30
24
  toRdfResourceValuesExpression({ variables, }) {
31
25
  return code `[${this.reusables.snippets.literalFactory}.date(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
32
26
  }
33
27
  }
34
- __decorate([
35
- Memoize()
36
- ], AbstractDateType.prototype, "jsonType", null);
37
28
  //# sourceMappingURL=AbstractDateType.js.map
@@ -1,12 +1,11 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
2
  import { AbstractTermType } from "./AbstractTermType.js";
3
3
  import type { Code } from "./ts-poet-wrapper.js";
4
+ /**
5
+ * Abstract base class of all types that are literals in RDF.
6
+ */
4
7
  export declare abstract class AbstractLiteralType extends AbstractTermType<Literal, Literal> {
5
- protected readonly languageIn: readonly string[];
6
8
  readonly nodeKinds: ReadonlySet<"Literal">;
7
- constructor({ languageIn, ...superParameters }: {
8
- languageIn: readonly string[];
9
- } & ConstructorParameters<typeof AbstractTermType<Literal, Literal>>[0]);
10
9
  /**
11
10
  * An expression that converts a compile-time RDF/JS Literal into a runtime TypeScript literal.
12
11
  *
@@ -1,11 +1,9 @@
1
1
  import { AbstractTermType } from "./AbstractTermType.js";
2
+ /**
3
+ * Abstract base class of all types that are literals in RDF.
4
+ */
2
5
  export class AbstractLiteralType extends AbstractTermType {
3
- languageIn;
4
6
  nodeKinds = nodeKinds;
5
- constructor({ languageIn, ...superParameters }) {
6
- super(superParameters);
7
- this.languageIn = languageIn;
8
- }
9
7
  }
10
8
  (function (AbstractLiteralType) {
11
9
  AbstractLiteralType.GraphqlType = AbstractTermType.GraphqlType;
@@ -10,8 +10,6 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
10
10
  get filterType(): Code;
11
11
  get schemaType(): Code;
12
12
  get valueSparqlWherePatternsFunction(): Code;
13
- protected get inlineExpression(): Code;
14
- jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
15
13
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
16
14
  }
17
15
  export declare namespace AbstractNumericType {
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6
6
  };
7
7
  import { Memoize } from "typescript-memoize";
8
8
  import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
9
- import { code, joinCode } from "./ts-poet-wrapper.js";
9
+ import { code } from "./ts-poet-wrapper.js";
10
10
  /**
11
11
  * Abstract base class for TypeScript numeric types (bigint | number).
12
12
  */
@@ -24,22 +24,6 @@ export class AbstractNumericType extends AbstractPrimitiveType {
24
24
  get valueSparqlWherePatternsFunction() {
25
25
  return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.expression}>`;
26
26
  }
27
- get inlineExpression() {
28
- if (this.primitiveIn.length > 0) {
29
- return code `${joinCode(this.primitiveIn.map((value) => this.literalValueExpression(value)), { on: " | " })}`;
30
- }
31
- return code `${this.jsTypes[0].typeof}`;
32
- }
33
- jsonSchema(_parameters) {
34
- switch (this.primitiveIn.length) {
35
- case 0:
36
- return code `${this.reusables.imports.z}.${this.jsTypes[0].typeof}()`;
37
- case 1:
38
- return code `${this.reusables.imports.z}.literal(${this.literalValueExpression(this.primitiveIn[0])})`;
39
- default:
40
- return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalValueExpression(value)})`), { on: "," })}])`;
41
- }
42
- }
43
27
  toRdfResourceValuesExpression({ variables, }) {
44
28
  return code `[${this.reusables.snippets.literalFactory}.${this.jsTypes[0].typeof}(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
45
29
  }
@@ -56,9 +40,6 @@ __decorate([
56
40
  __decorate([
57
41
  Memoize()
58
42
  ], AbstractNumericType.prototype, "valueSparqlWherePatternsFunction", null);
59
- __decorate([
60
- Memoize()
61
- ], AbstractNumericType.prototype, "inlineExpression", null);
62
43
  (function (AbstractNumericType) {
63
44
  AbstractNumericType.JsonType = AbstractPrimitiveType.JsonType;
64
45
  })(AbstractNumericType || (AbstractNumericType = {}));
@@ -1,23 +1,18 @@
1
- import type { Literal, NamedNode } from "@rdfjs/types";
1
+ import type { Primitive } from "@rdfx/literal";
2
2
  import { Maybe } from "purify-ts";
3
3
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
4
+ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
4
5
  import { type Code } from "./ts-poet-wrapper.js";
5
- export declare abstract class AbstractPrimitiveType<ValueT extends bigint | boolean | Date | string | number> extends AbstractLiteralType {
6
- protected readonly datatype: NamedNode;
6
+ /**
7
+ * Abstract base class of typed literals whose datatype corresponds to a JavaScript primitive type.
8
+ */
9
+ export declare abstract class AbstractPrimitiveType<ValueT extends Primitive> extends AbstractTypedLiteralType<ValueT> {
7
10
  readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
8
11
  readonly equalsFunction: Code;
9
- abstract readonly kind: "BigInt" | "Boolean" | "DateTime" | "Date" | "Float" | "Int" | "NumberType" | "String";
10
- readonly primitiveIn: readonly ValueT[];
11
- constructor({ datatype, primitiveIn, ...superParameters }: {
12
- datatype: NamedNode;
13
- primitiveIn: readonly ValueT[];
14
- } & ConstructorParameters<typeof AbstractLiteralType>[0]);
15
- get discriminantProperty(): Maybe<AbstractLiteralType.DiscriminantProperty>;
16
- protected get schemaInitializers(): readonly Code[];
12
+ protected get inlineExpression(): Code;
17
13
  fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
18
- graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
14
+ jsonSchema(_parameters: Parameters<AbstractTypedLiteralType<ValueT>["jsonSchema"]>[0]): Code;
19
15
  jsonType(): AbstractLiteralType.JsonType;
20
- abstract literalValueExpression(literal: Literal | ValueT): Code;
21
16
  toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
22
17
  }
23
18
  export declare namespace AbstractPrimitiveType {
@@ -7,32 +7,32 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
10
- import { arrayOf, code } from "./ts-poet-wrapper.js";
11
- export class AbstractPrimitiveType extends AbstractLiteralType {
12
- datatype;
10
+ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
11
+ import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
12
+ /**
13
+ * Abstract base class of typed literals whose datatype corresponds to a JavaScript primitive type.
14
+ */
15
+ export class AbstractPrimitiveType extends AbstractTypedLiteralType {
13
16
  conversionFunction = Maybe.empty();
14
17
  equalsFunction = code `${this.reusables.snippets.strictEquals}`;
15
- primitiveIn;
16
- constructor({ datatype, primitiveIn, ...superParameters }) {
17
- super(superParameters);
18
- this.datatype = datatype;
19
- this.primitiveIn = primitiveIn;
20
- }
21
- get discriminantProperty() {
22
- return Maybe.empty();
23
- }
24
- get schemaInitializers() {
25
- let initializers = super.schemaInitializers;
26
- if (this.primitiveIn.length > 0) {
27
- initializers = initializers.concat(code `in: ${arrayOf(...this.primitiveIn.map((in_) => this.literalValueExpression(in_)))} as const`);
18
+ get inlineExpression() {
19
+ if (this.decodedIn.length > 0) {
20
+ return code `${joinCode(this.decodedIn.map((value) => this.literalValueExpression(value)), { on: " | " })}`;
28
21
  }
29
- return initializers;
22
+ return code `${this.jsTypes[0].typeof}`;
30
23
  }
31
24
  fromJsonExpression({ variables, }) {
32
25
  return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${variables.value})`;
33
26
  }
34
- graphqlResolveExpression({ variables, }) {
35
- return variables.value;
27
+ jsonSchema(_parameters) {
28
+ switch (this.decodedIn.length) {
29
+ case 0:
30
+ return code `${this.reusables.imports.z}.${this.jsTypes[0].typeof}()`;
31
+ case 1:
32
+ return code `${this.reusables.imports.z}.literal(${this.literalValueExpression(this.decodedIn[0])})`;
33
+ default:
34
+ return code `${this.reusables.imports.z}.union(${arrayOf(...this.decodedIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalValueExpression(value)})`))})`;
35
+ }
36
36
  }
37
37
  jsonType() {
38
38
  return new AbstractLiteralType.JsonType(this.expression);
@@ -41,6 +41,9 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
41
41
  return variables.value;
42
42
  }
43
43
  }
44
+ __decorate([
45
+ Memoize()
46
+ ], AbstractPrimitiveType.prototype, "inlineExpression", null);
44
47
  __decorate([
45
48
  Memoize()
46
49
  ], AbstractPrimitiveType.prototype, "jsonType", null);
@@ -0,0 +1,32 @@
1
+ import type { Literal, NamedNode } from "@rdfjs/types";
2
+ import { Maybe } from "purify-ts";
3
+ import { AbstractLiteralType } from "./AbstractLiteralType.js";
4
+ import { AbstractTermType } from "./AbstractTermType.js";
5
+ import { type Code } from "./ts-poet-wrapper.js";
6
+ /**
7
+ * Abstract base class of all types that are typed literals in RDF. In RDF every literal is either
8
+ * - a language-tagged string literal (datatype = rdf:langString, language = not empty)
9
+ * - a typed literal (datatype = anything else, language = empty)
10
+ */
11
+ export declare abstract class AbstractTypedLiteralType<ValueT> extends AbstractLiteralType {
12
+ readonly datatype: NamedNode;
13
+ readonly decodedIn: readonly ValueT[];
14
+ constructor({ datatype, decodedIn, ...superParameters }: {
15
+ datatype: NamedNode;
16
+ readonly decodedIn: readonly ValueT[];
17
+ } & ConstructorParameters<typeof AbstractLiteralType>[0]);
18
+ get discriminantProperty(): Maybe<AbstractLiteralType.DiscriminantProperty>;
19
+ protected get schemaInitializers(): readonly Code[];
20
+ graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
21
+ abstract literalValueExpression(literal: Literal | ValueT): Code;
22
+ }
23
+ export declare namespace AbstractTypedLiteralType {
24
+ type ConversionFunction = AbstractTermType.ConversionFunction;
25
+ type DiscriminantProperty = AbstractTermType.DiscriminantProperty;
26
+ const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
27
+ type GraphqlType = AbstractTermType.GraphqlType;
28
+ type JsType = AbstractTermType.JsType;
29
+ const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
30
+ type JsonType = AbstractTermType.JsonType;
31
+ }
32
+ //# sourceMappingURL=AbstractTypedLiteralType.d.ts.map
@@ -0,0 +1,36 @@
1
+ import { Maybe } from "purify-ts";
2
+ import { AbstractLiteralType } from "./AbstractLiteralType.js";
3
+ import { AbstractTermType } from "./AbstractTermType.js";
4
+ import { arrayOf, code } from "./ts-poet-wrapper.js";
5
+ /**
6
+ * Abstract base class of all types that are typed literals in RDF. In RDF every literal is either
7
+ * - a language-tagged string literal (datatype = rdf:langString, language = not empty)
8
+ * - a typed literal (datatype = anything else, language = empty)
9
+ */
10
+ export class AbstractTypedLiteralType extends AbstractLiteralType {
11
+ datatype;
12
+ decodedIn;
13
+ constructor({ datatype, decodedIn, ...superParameters }) {
14
+ super(superParameters);
15
+ this.datatype = datatype;
16
+ this.decodedIn = decodedIn;
17
+ }
18
+ get discriminantProperty() {
19
+ return Maybe.empty();
20
+ }
21
+ get schemaInitializers() {
22
+ let initializers = super.schemaInitializers;
23
+ if (this.decodedIn.length > 0) {
24
+ initializers = initializers.concat(code `in: ${arrayOf(...this.decodedIn.map((in_) => this.literalValueExpression(in_)))} as const`);
25
+ }
26
+ return initializers;
27
+ }
28
+ graphqlResolveExpression({ variables, }) {
29
+ return variables.value;
30
+ }
31
+ }
32
+ (function (AbstractTypedLiteralType) {
33
+ AbstractTypedLiteralType.GraphqlType = AbstractTermType.GraphqlType;
34
+ AbstractTypedLiteralType.JsonType = AbstractTermType.JsonType;
35
+ })(AbstractTypedLiteralType || (AbstractTypedLiteralType = {}));
36
+ //# sourceMappingURL=AbstractTypedLiteralType.js.map
@@ -1,8 +1,10 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
+ import type { Decimal } from "decimal.js";
2
3
  import { Maybe } from "purify-ts";
3
4
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
5
+ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
4
6
  import { type Code } from "./ts-poet-wrapper.js";
5
- export declare class BigDecimalType extends AbstractLiteralType {
7
+ export declare class BigDecimalType extends AbstractTypedLiteralType<Decimal> {
6
8
  protected readonly inlineExpression: Code;
7
9
  readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
8
10
  readonly filterFunction: Code;
@@ -22,7 +24,7 @@ export declare class BigDecimalType extends AbstractLiteralType {
22
24
  jsonSchema(): Code;
23
25
  jsonType(): AbstractLiteralType.JsonType;
24
26
  literalValueExpression(literal: Literal): Code;
25
- toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
27
+ toJsonExpression({ variables, }: Parameters<AbstractTypedLiteralType<Decimal>["toJsonExpression"]>[0]): Code;
26
28
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractLiteralType["toRdfResourceValuesExpression"]>[0]): Code;
27
29
  }
28
30
  //# sourceMappingURL=BigDecimalType.d.ts.map
@@ -7,8 +7,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { Maybe } from "purify-ts";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractLiteralType } from "./AbstractLiteralType.js";
10
+ import { AbstractTypedLiteralType } from "./AbstractTypedLiteralType.js";
10
11
  import { code, literalOf } from "./ts-poet-wrapper.js";
11
- export class BigDecimalType extends AbstractLiteralType {
12
+ export class BigDecimalType extends AbstractTypedLiteralType {
12
13
  inlineExpression = code `${this.reusables.imports.BigDecimal}`;
13
14
  conversionFunction = Maybe.empty();
14
15
  filterFunction = code `${this.reusables.snippets.filterBigDecimal}`;
@@ -25,22 +26,22 @@ export class BigDecimalType extends AbstractLiteralType {
25
26
  return new AbstractLiteralType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
26
27
  }
27
28
  fromJsonExpression({ variables, }) {
28
- return code `${this.reusables.imports.Either}.encase<Error, ${this.expression}>(() => new ${this.expression}(${variables.value}))`;
29
+ return code `${this.reusables.imports.Either}.encase<Error, ${this.expression}>(() => new ${this.expression}(${variables.value}["@value"]))`;
29
30
  }
30
31
  graphqlResolveExpression({ variables, }) {
31
32
  return code `${variables.value}.toFixed()`;
32
33
  }
33
34
  jsonSchema() {
34
- return code `${this.reusables.imports.z}.string()`;
35
+ return code `${this.reusables.imports.z}.object({ "@type": ${this.reusables.imports.z}.literal(${literalOf(this.datatype.value)}), "@value": ${this.reusables.imports.z}.string() })`;
35
36
  }
36
37
  jsonType() {
37
- return new AbstractLiteralType.JsonType(code `string`);
38
+ return new AbstractLiteralType.JsonType(code `{ readonly "@type": ${literalOf(this.datatype.value)}, readonly "@value": string }`);
38
39
  }
39
40
  literalValueExpression(literal) {
40
41
  return code `new ${this.reusables.imports.BigDecimal}(${literalOf(literal.value)})`;
41
42
  }
42
43
  toJsonExpression({ variables, }) {
43
- return code `${variables.value}.toFixed()`;
44
+ return code `{ "@type": ${literalOf(this.datatype.value)} as const, "@value": ${variables.value}.toFixed() }`;
44
45
  }
45
46
  toRdfResourceValuesExpression({ variables, }) {
46
47
  return code `[${this.reusables.snippets.bigDecimalLiteral}(${variables.value})]`;
@@ -49,10 +50,4 @@ export class BigDecimalType extends AbstractLiteralType {
49
50
  __decorate([
50
51
  Memoize()
51
52
  ], BigDecimalType.prototype, "graphqlType", null);
52
- __decorate([
53
- Memoize()
54
- ], BigDecimalType.prototype, "jsonSchema", null);
55
- __decorate([
56
- Memoize()
57
- ], BigDecimalType.prototype, "jsonType", null);
58
53
  //# sourceMappingURL=BigDecimalType.js.map
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { LiteralDecoder } from "@rdfx/literal";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractNumericType } from "./AbstractNumericType.js";
10
- import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
10
+ import { arrayOf, code, joinCode, literalOf, } from "./ts-poet-wrapper.js";
11
11
  export class BigIntType extends AbstractNumericType {
12
12
  jsTypes = [{ typeof: "bigint" }];
13
13
  kind = "BigInt";
@@ -18,30 +18,41 @@ export class BigIntType extends AbstractNumericType {
18
18
  return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLBigInt}`, this.reusables);
19
19
  }
20
20
  fromJsonExpression({ variables, }) {
21
- let expression = code `BigInt(${variables.value})`;
22
- if (this.primitiveIn.length > 0) {
21
+ let expression = code `BigInt(${variables.value}["@value"])`;
22
+ if (this.decodedIn.length > 0) {
23
23
  expression = code `${expression} as ${this.expression}`;
24
24
  }
25
25
  return code `${this.reusables.imports.Either}.encase<Error, ${this.expression}>(() => ${expression})`;
26
26
  }
27
27
  jsonSchema(_parameters) {
28
- switch (this.primitiveIn.length) {
28
+ let valueJsonSchema;
29
+ switch (this.decodedIn.length) {
29
30
  case 0:
30
- return code `${this.reusables.imports.z}.string()`;
31
+ valueJsonSchema = code `${this.reusables.imports.z}.string()`;
32
+ break;
31
33
  case 1:
32
- return code `${this.reusables.imports.z}.literal(${literalOf(this.primitiveIn[0].toString())})`;
34
+ valueJsonSchema = code `${this.reusables.imports.z}.literal(${literalOf(this.decodedIn[0].toString())})`;
35
+ break;
33
36
  default:
34
- return code `${this.reusables.imports.z}.enum([${joinCode(this.primitiveIn.map((value) => code `${literalOf(value.toString())}`), { on: "," })}])`;
37
+ valueJsonSchema = code `${this.reusables.imports.z}.enum(${arrayOf(...this.decodedIn.map((value) => code `${literalOf(value.toString())}`))})`;
38
+ break;
35
39
  }
40
+ return code `${this.reusables.imports.z}.object({ "@type": ${this.reusables.imports.z}.literal(${literalOf(this.datatype.value)}), "@value": ${valueJsonSchema} })`;
36
41
  }
37
42
  jsonType() {
38
- return new AbstractNumericType.JsonType(code `string`);
43
+ return new AbstractNumericType.JsonType(code `{ readonly "@type": ${literalOf(this.datatype.value)}, readonly "@value": ${this.decodedIn.length === 0
44
+ ? "string"
45
+ : joinCode(this.decodedIn.map((in_) => code `${literalOf(in_.toString())}`), { on: " | " })} }`);
39
46
  }
40
47
  literalValueExpression(literal) {
41
48
  return code `${typeof literal === "bigint" ? literal : LiteralDecoder.decodeBigIntLiteral(literal).unsafeCoerce()}n`;
42
49
  }
43
50
  toJsonExpression({ variables, }) {
44
- return code `${variables.value}.toString()`;
51
+ let valueExpression = code `${variables.value}.toString()`;
52
+ if (this.decodedIn.length > 0) {
53
+ valueExpression = code `${valueExpression} as ${joinCode(this.decodedIn.map((in_) => code `${literalOf(in_.toString())}`), { on: " | " })}`;
54
+ }
55
+ return code `{ "@type": ${literalOf(this.datatype.value)} as const, "@value": ${valueExpression} }`;
45
56
  }
46
57
  }
47
58
  __decorate([
@@ -13,8 +13,6 @@ export declare class BooleanType extends AbstractPrimitiveType<boolean> {
13
13
  readonly valueSparqlWherePatternsFunction: Code;
14
14
  get fromRdfResourceValuesFunction(): Code;
15
15
  get schemaType(): Code;
16
- protected get inlineExpression(): Code;
17
- jsonSchema(_parameters: Parameters<AbstractPrimitiveType<number>["jsonSchema"]>[0]): Code;
18
16
  literalValueExpression(literal: boolean | Literal): Code;
19
17
  toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<boolean>["toRdfResourceValuesExpression"]>[0]): Code;
20
18
  }
@@ -22,18 +22,6 @@ export class BooleanType extends AbstractPrimitiveType {
22
22
  get schemaType() {
23
23
  return code `${this.reusables.snippets.BooleanSchema}<${this.expression}>`;
24
24
  }
25
- get inlineExpression() {
26
- if (this.primitiveIn.length > 0) {
27
- return code `${this.primitiveIn.map((value) => value.toString()).join(" | ")}`;
28
- }
29
- return code `boolean`;
30
- }
31
- jsonSchema(_parameters) {
32
- if (this.primitiveIn.length === 1) {
33
- return code `${this.reusables.imports.z}.literal(${this.primitiveIn[0]})`;
34
- }
35
- return code `${this.reusables.imports.z}.boolean()`;
36
- }
37
25
  literalValueExpression(literal) {
38
26
  return code `${typeof literal === "boolean" ? literal : LiteralDecoder.decodeBooleanLiteral(literal).unsafeCoerce()}`;
39
27
  }
@@ -47,7 +35,4 @@ __decorate([
47
35
  __decorate([
48
36
  Memoize()
49
37
  ], BooleanType.prototype, "schemaType", null);
50
- __decorate([
51
- Memoize()
52
- ], BooleanType.prototype, "inlineExpression", null);
53
38
  //# sourceMappingURL=BooleanType.js.map
@@ -6,7 +6,7 @@ export declare class DateTimeType extends AbstractDateType {
6
6
  readonly hashFunction: Code;
7
7
  readonly kind = "DateTime";
8
8
  get fromRdfResourceValuesFunction(): Code;
9
- jsonSchema(_parameters: Parameters<AbstractDateType["jsonSchema"]>[0]): Code;
9
+ jsonSchema(): Code;
10
10
  literalValueExpression(literal: Date | Literal): Code;
11
11
  toJsonExpression({ variables, }: Parameters<AbstractDateType["toJsonExpression"]>[0]): Code;
12
12
  }
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  import { LiteralDecoder } from "@rdfx/literal";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractDateType } from "./AbstractDateType.js";
10
- import { code } from "./ts-poet-wrapper.js";
10
+ import { code, literalOf } from "./ts-poet-wrapper.js";
11
11
  export class DateTimeType extends AbstractDateType {
12
12
  graphqlType = new DateTimeType.GraphqlType(code `${this.reusables.imports.GraphQLDateTime}`, this.reusables);
13
13
  hashFunction = code `${this.reusables.snippets.hashDateTime}`;
@@ -15,14 +15,14 @@ export class DateTimeType extends AbstractDateType {
15
15
  get fromRdfResourceValuesFunction() {
16
16
  return code `${this.reusables.snippets.dateTimeFromRdfResourceValues}`;
17
17
  }
18
- jsonSchema(_parameters) {
19
- return code `${this.reusables.imports.z}.iso.datetime()`;
18
+ jsonSchema() {
19
+ return code `${this.reusables.imports.z}.object({ "@type": ${this.reusables.imports.z}.literal(${literalOf(this.datatype.value)}), "@value": ${this.reusables.imports.z}.iso.datetime() })`;
20
20
  }
21
21
  literalValueExpression(literal) {
22
22
  return code `new Date("${(literal instanceof Date ? literal : LiteralDecoder.decodeDateTimeLiteral(literal).unsafeCoerce()).toISOString()}")`;
23
23
  }
24
24
  toJsonExpression({ variables, }) {
25
- return code `${variables.value}.toISOString()`;
25
+ return code `{ "@type": ${literalOf(this.datatype.value)} as const, "@value": ${variables.value}.toISOString() }`;
26
26
  }
27
27
  }
28
28
  __decorate([
@@ -1,13 +1,12 @@
1
1
  import type { Literal } from "@rdfjs/types";
2
2
  import { AbstractDateType } from "./AbstractDateType.js";
3
- import { DateTimeType } from "./DateTimeType.js";
4
3
  import { type Code } from "./ts-poet-wrapper.js";
5
4
  export declare class DateType extends AbstractDateType {
6
5
  readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
7
6
  readonly hashFunction: Code;
8
7
  readonly kind = "Date";
9
8
  get fromRdfResourceValuesFunction(): Code;
10
- jsonSchema(_parameters: Parameters<DateTimeType["jsonSchema"]>[0]): Code;
9
+ jsonSchema(): Code;
11
10
  literalValueExpression(literal: Date | Literal): Code;
12
11
  toJsonExpression({ variables, }: Parameters<AbstractDateType["toJsonExpression"]>[0]): Code;
13
12
  }
@@ -8,7 +8,7 @@ import { LiteralDecoder } from "@rdfx/literal";
8
8
  import { Memoize } from "typescript-memoize";
9
9
  import { AbstractDateType } from "./AbstractDateType.js";
10
10
  import { DateTimeType } from "./DateTimeType.js";
11
- import { code } from "./ts-poet-wrapper.js";
11
+ import { code, literalOf } from "./ts-poet-wrapper.js";
12
12
  export class DateType extends AbstractDateType {
13
13
  graphqlType = new DateTimeType.GraphqlType(code `${this.reusables.imports.GraphQLDate}`, this.reusables);
14
14
  hashFunction = code `${this.reusables.snippets.hashDate}`;
@@ -16,14 +16,14 @@ export class DateType extends AbstractDateType {
16
16
  get fromRdfResourceValuesFunction() {
17
17
  return code `${this.reusables.snippets.dateFromRdfResourceValues}`;
18
18
  }
19
- jsonSchema(_parameters) {
20
- return code `${this.reusables.imports.z}.iso.date()`;
19
+ jsonSchema() {
20
+ return code `${this.reusables.imports.z}.object({ "@type": ${this.reusables.imports.z}.literal(${literalOf(this.datatype.value)}), "@value": ${this.reusables.imports.z}.iso.date() })`;
21
21
  }
22
22
  literalValueExpression(literal) {
23
23
  return code `new Date("${(literal instanceof Date ? literal : LiteralDecoder.decodeDateLiteral(literal).unsafeCoerce()).toISOString()}")`;
24
24
  }
25
25
  toJsonExpression({ variables, }) {
26
- return code `${this.reusables.snippets.toIsoDateString}(${variables.value})`;
26
+ return code `{ "@type": ${literalOf(this.datatype.value)} as const, "@value": ${this.reusables.snippets.toIsoDateString}(${variables.value}) }`;
27
27
  }
28
28
  }
29
29
  __decorate([
@@ -38,6 +38,9 @@ export declare class DefaultValueType<ItemTypeT extends DefaultValueType.ItemTyp
38
38
  }] | readonly [{
39
39
  readonly instanceof: "Object";
40
40
  readonly typeof: "object";
41
+ }] | readonly [{
42
+ readonly instanceof: "Object";
43
+ readonly typeof: "object";
41
44
  }] | readonly [{
42
45
  readonly typeof: "string";
43
46
  }] | readonly [{