@shaclmate/compiler 2.0.18 → 2.0.19

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 (46) hide show
  1. package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +10 -0
  2. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -0
  3. package/dist/ast/ObjectType.d.ts +8 -0
  4. package/dist/enums/IdentifierMintingStrategy.d.ts +1 -1
  5. package/dist/generators/ts/ListType.js +3 -2
  6. package/dist/generators/ts/ObjectType.d.ts +4 -0
  7. package/dist/generators/ts/ObjectType.js +46 -7
  8. package/dist/generators/ts/ObjectUnionType.js +1 -1
  9. package/dist/generators/ts/TypeFactory.js +84 -35
  10. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +34 -0
  11. package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +98 -0
  12. package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +4 -6
  13. package/dist/generators/ts/_ObjectType/IdentifierProperty.js +53 -71
  14. package/dist/generators/ts/_ObjectType/Property.d.ts +7 -6
  15. package/dist/generators/ts/_ObjectType/Property.js +0 -6
  16. package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +3 -3
  17. package/dist/generators/ts/_ObjectType/ShaclProperty.js +7 -7
  18. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +6 -4
  19. package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +12 -9
  20. package/dist/generators/ts/_ObjectType/classDeclaration.js +4 -9
  21. package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +5 -5
  22. package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +6 -6
  23. package/dist/generators/ts/_ObjectType/hashFunctionDeclarations.d.ts +4 -0
  24. package/dist/generators/ts/_ObjectType/hashFunctionDeclarations.js +18 -0
  25. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.d.ts +13 -0
  26. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +97 -0
  27. package/dist/generators/ts/_ObjectType/index.d.ts +2 -1
  28. package/dist/generators/ts/_ObjectType/index.js +2 -1
  29. package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
  30. package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +1 -1
  31. package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +5 -5
  32. package/dist/generators/ts/_ObjectType/toJsonReturnType.js +2 -4
  33. package/dist/input/NodeShape.d.ts +1 -0
  34. package/dist/input/NodeShape.js +11 -8
  35. package/dist/input/Ontology.d.ts +2 -0
  36. package/dist/input/Ontology.js +8 -2
  37. package/dist/input/PropertyShape.js +3 -3
  38. package/dist/input/generated.d.ts +67 -63
  39. package/dist/input/generated.js +181 -159
  40. package/dist/input/tsFeatures.d.ts +1 -1
  41. package/dist/input/tsFeatures.js +14 -14
  42. package/package.json +7 -7
  43. package/dist/generators/ts/_ObjectType/hashFunctionDeclaration.d.ts +0 -5
  44. package/dist/generators/ts/_ObjectType/hashFunctionDeclaration.js +0 -20
  45. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.d.ts +0 -11
  46. package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.js +0 -64
@@ -1,7 +1,7 @@
1
1
  import type * as rdfjs from "@rdfjs/types";
2
2
  import { Maybe } from "purify-ts";
3
3
  import { TsFeature } from "../enums/index.js";
4
- type TsFeatureIri = rdfjs.NamedNode<"http://minorg.github.io/shaclmate/ns#_TsFeature_All" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Create" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Equals" | "http://minorg.github.io/shaclmate/ns#_TsFeature_FromJson" | "http://minorg.github.io/shaclmate/ns#_TsFeature_FromRdf" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Json" | "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonSchema" | "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonUiSchema" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Hash" | "http://minorg.github.io/shaclmate/ns#_TsFeature_None" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Rdf" | "http://minorg.github.io/shaclmate/ns#_TsFeature_Sparql" | "http://minorg.github.io/shaclmate/ns#_TsFeature_ToJson" | "http://minorg.github.io/shaclmate/ns#_TsFeature_ToRdf">;
4
+ type TsFeatureIri = rdfjs.NamedNode<"http://purl.org/shaclmate/ontology#_TsFeature_All" | "http://purl.org/shaclmate/ontology#_TsFeature_Create" | "http://purl.org/shaclmate/ontology#_TsFeature_Equals" | "http://purl.org/shaclmate/ontology#_TsFeature_FromJson" | "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Json" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema" | "http://purl.org/shaclmate/ontology#_TsFeature_Hash" | "http://purl.org/shaclmate/ontology#_TsFeature_None" | "http://purl.org/shaclmate/ontology#_TsFeature_Rdf" | "http://purl.org/shaclmate/ontology#_TsFeature_Sparql" | "http://purl.org/shaclmate/ontology#_TsFeature_ToJson" | "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf">;
5
5
  export declare function tsFeatures(generated: {
6
6
  readonly tsFeatureExcludes: readonly TsFeatureIri[];
7
7
  readonly tsFeatureIncludes: readonly TsFeatureIri[];
@@ -2,33 +2,33 @@ import { Maybe } from "purify-ts";
2
2
  import { TsFeature } from "../enums/index.js";
3
3
  function iriToTsFeatures(iri) {
4
4
  switch (iri.value) {
5
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_All":
5
+ case "http://purl.org/shaclmate/ontology#_TsFeature_All":
6
6
  return TsFeature.MEMBERS;
7
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_Create":
7
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Create":
8
8
  return ["create"];
9
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_Equals":
9
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Equals":
10
10
  return ["equals"];
11
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_FromJson":
11
+ case "http://purl.org/shaclmate/ontology#_TsFeature_FromJson":
12
12
  return ["fromJson"];
13
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_FromRdf":
13
+ case "http://purl.org/shaclmate/ontology#_TsFeature_FromRdf":
14
14
  return ["fromRdf"];
15
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_Hash":
15
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Hash":
16
16
  return ["hash"];
17
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_Json":
17
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Json":
18
18
  return ["fromJson", "jsonSchema", "jsonUiSchema", "toJson"];
19
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonSchema":
19
+ case "http://purl.org/shaclmate/ontology#_TsFeature_JsonSchema":
20
20
  return ["jsonSchema"];
21
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_JsonUiSchema":
21
+ case "http://purl.org/shaclmate/ontology#_TsFeature_JsonUiSchema":
22
22
  return ["jsonUiSchema"];
23
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_None":
23
+ case "http://purl.org/shaclmate/ontology#_TsFeature_None":
24
24
  return [];
25
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_Sparql":
25
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Sparql":
26
26
  return ["sparql"];
27
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_Rdf":
27
+ case "http://purl.org/shaclmate/ontology#_TsFeature_Rdf":
28
28
  return ["fromRdf", "toRdf"];
29
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_ToJson":
29
+ case "http://purl.org/shaclmate/ontology#_TsFeature_ToJson":
30
30
  return ["toJson"];
31
- case "http://minorg.github.io/shaclmate/ns#_TsFeature_ToRdf":
31
+ case "http://purl.org/shaclmate/ontology#_TsFeature_ToRdf":
32
32
  return ["toRdf"];
33
33
  }
34
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "dependencies": {
3
- "@shaclmate/shacl-ast": "2.0.18",
3
+ "@shaclmate/shacl-ast": "2.0.19",
4
4
  "@rdfjs/prefix-map": "^0.1.2",
5
5
  "@rdfjs/term-map": "^2.0.2",
6
6
  "@rdfjs/term-set": "^2.0.3",
@@ -20,7 +20,7 @@
20
20
  "typescript-memoize": "^1.1.1"
21
21
  },
22
22
  "devDependencies": {
23
- "@shaclmate/runtime": "2.0.18",
23
+ "@shaclmate/runtime": "2.0.19",
24
24
  "oxigraph": "^0.4.0"
25
25
  },
26
26
  "exports": {
@@ -51,6 +51,10 @@
51
51
  ],
52
52
  "license": "Apache-2.0",
53
53
  "name": "@shaclmate/compiler",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/minorg/shaclmate"
57
+ },
54
58
  "scripts": {
55
59
  "build": "tsc -b",
56
60
  "check": "biome check",
@@ -72,10 +76,6 @@
72
76
  "watch": "tsc -w --preserveWatchOutput",
73
77
  "watch:noEmit": "tsc --noEmit -w --preserveWatchOutput"
74
78
  },
75
- "repository": {
76
- "type": "git",
77
- "url": "git+https://github.com/minorg/shaclmate"
78
- },
79
79
  "type": "module",
80
- "version": "2.0.18"
80
+ "version": "2.0.19"
81
81
  }
@@ -1,5 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import { type FunctionDeclarationStructure } from "ts-morph";
3
- import type { ObjectType } from "../ObjectType.js";
4
- export declare function hashFunctionDeclaration(this: ObjectType): Maybe<FunctionDeclarationStructure>;
5
- //# sourceMappingURL=hashFunctionDeclaration.d.ts.map
@@ -1,20 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import { StructureKind } from "ts-morph";
3
- import { hashFunctionOrMethodDeclaration } from "./hashFunctionOrMethodDeclaration.js";
4
- export function hashFunctionDeclaration() {
5
- if (this.declarationType !== "interface") {
6
- return Maybe.empty();
7
- }
8
- if (this.extern) {
9
- return Maybe.empty();
10
- }
11
- return hashFunctionOrMethodDeclaration
12
- .bind(this)()
13
- .map((hashFunctionOrMethodDeclaration) => ({
14
- ...hashFunctionOrMethodDeclaration,
15
- isExported: true,
16
- kind: StructureKind.Function,
17
- name: this.hashFunctionName,
18
- }));
19
- }
20
- //# sourceMappingURL=hashFunctionDeclaration.js.map
@@ -1,11 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import type { OptionalKind, ParameterDeclarationStructure, TypeParameterDeclarationStructure } from "ts-morph";
3
- import type { ObjectType } from "../ObjectType.js";
4
- export declare const hasherTypeConstraint = "{ update: (message: string | number[] | ArrayBuffer | Uint8Array) => void; }";
5
- export declare function hashFunctionOrMethodDeclaration(this: ObjectType): Maybe<{
6
- parameters: OptionalKind<ParameterDeclarationStructure>[];
7
- returnType: string;
8
- statements: string[];
9
- typeParameters: OptionalKind<TypeParameterDeclarationStructure>[];
10
- }>;
11
- //# sourceMappingURL=hashFunctionOrMethodDeclaration.d.ts.map
@@ -1,64 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- const hasherVariable = "_hasher";
3
- export const hasherTypeConstraint = "{ update: (message: string | number[] | ArrayBuffer | Uint8Array) => void; }";
4
- export function hashFunctionOrMethodDeclaration() {
5
- if (!this.features.has("hash")) {
6
- return Maybe.empty();
7
- }
8
- const propertyHashStatements = this.properties.flatMap((property) => property.hashStatements({
9
- depth: 0,
10
- variables: {
11
- hasher: hasherVariable,
12
- value: `${this.thisVariable}.${property.name}`,
13
- },
14
- }));
15
- if (this.declarationType === "class" &&
16
- this.parentObjectTypes.length > 0 &&
17
- propertyHashStatements.length === 0) {
18
- // If there's a parent class and no hash statements in this class, can skip overriding hash
19
- return Maybe.empty();
20
- }
21
- const parameters = [];
22
- if (this.declarationType === "interface") {
23
- parameters.push({
24
- name: this.thisVariable,
25
- type: this.name,
26
- });
27
- }
28
- parameters.push({
29
- name: hasherVariable,
30
- type: "HasherT",
31
- });
32
- const statements = [];
33
- let hasOverrideKeyword = false;
34
- if (this.parentObjectTypes.length > 0) {
35
- switch (this.declarationType) {
36
- case "class": {
37
- statements.push(`super.hash(${hasherVariable});`);
38
- hasOverrideKeyword = true;
39
- break;
40
- }
41
- case "interface": {
42
- for (const parentObjectType of this.parentObjectTypes) {
43
- statements.push(`${parentObjectType.name}.${parentObjectType.hashFunctionName}(${this.thisVariable}, ${hasherVariable});`);
44
- }
45
- break;
46
- }
47
- }
48
- }
49
- statements.push(...propertyHashStatements);
50
- statements.push(`return ${hasherVariable};`);
51
- return Maybe.of({
52
- hasOverrideKeyword,
53
- parameters,
54
- returnType: "HasherT",
55
- statements,
56
- typeParameters: [
57
- {
58
- name: "HasherT",
59
- constraint: hasherTypeConstraint,
60
- },
61
- ],
62
- });
63
- }
64
- //# sourceMappingURL=hashFunctionOrMethodDeclaration.js.map