@shaclmate/compiler 4.0.24 → 4.0.25

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 (87) hide show
  1. package/dist/Compiler.d.ts +1 -1
  2. package/dist/ShapesGraphToAstTransformer.d.ts +1 -1
  3. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +1 -1
  4. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +5 -2
  5. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +0 -6
  6. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -2
  7. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +14 -32
  8. package/dist/ast/AbstractCompoundType.d.ts +1 -1
  9. package/dist/ast/ObjectType.d.ts +3 -23
  10. package/dist/ast/ObjectType.js +2 -20
  11. package/dist/generators/ts/AbstractContainerType.d.ts +0 -1
  12. package/dist/generators/ts/AbstractContainerType.js +0 -1
  13. package/dist/generators/ts/AbstractLazyObjectType.d.ts +0 -1
  14. package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
  15. package/dist/generators/ts/AbstractNamedUnionType.d.ts +1 -2
  16. package/dist/generators/ts/AbstractNamedUnionType.js +16 -19
  17. package/dist/generators/ts/AbstractTermType.d.ts +0 -1
  18. package/dist/generators/ts/AbstractTermType.js +0 -1
  19. package/dist/generators/ts/AbstractType.d.ts +0 -4
  20. package/dist/generators/ts/AbstractUnionType.d.ts +1 -10
  21. package/dist/generators/ts/AbstractUnionType.js +26 -39
  22. package/dist/generators/ts/LazyObjectOptionType.js +3 -2
  23. package/dist/generators/ts/LazyObjectSetType.js +2 -1
  24. package/dist/generators/ts/LazyObjectType.js +2 -1
  25. package/dist/generators/ts/NamedObjectType.d.ts +2 -13
  26. package/dist/generators/ts/NamedObjectType.js +33 -104
  27. package/dist/generators/ts/NamedObjectUnionType.js +13 -24
  28. package/dist/generators/ts/TypeFactory.js +10 -28
  29. package/dist/generators/ts/ZodGenerator.js +2 -2
  30. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +1 -7
  31. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +1 -6
  32. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +0 -1
  33. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +4 -31
  34. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -17
  35. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +2 -2
  36. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +5 -0
  37. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +25 -0
  38. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +1 -1
  39. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
  40. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
  41. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -4
  42. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +1 -4
  43. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -4
  44. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +4 -0
  45. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +49 -0
  46. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +0 -3
  47. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
  48. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
  49. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +2 -2
  50. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
  51. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +1 -1
  52. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +1 -2
  53. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
  54. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
  55. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -2
  56. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  57. package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toJsonFunctionOrMethodDeclaration.js → NamedObjectType_toJsonFunctionDeclaration.js} +5 -27
  58. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  59. package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js → NamedObjectType_toRdfResourceFunctionDeclaration.js} +4 -25
  60. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +4 -0
  61. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +40 -0
  62. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
  63. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
  64. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +6 -28
  65. package/dist/generators/ts/objectSetDeclarations.js +1 -3
  66. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -4
  67. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +1 -1
  68. package/dist/input/ShapesGraph.d.ts +1 -1
  69. package/dist/input/generated.d.ts +0 -134
  70. package/dist/input/generated.js +12 -239
  71. package/package.json +2 -4
  72. package/dist/enums/TsObjectDeclarationType.d.ts +0 -9
  73. package/dist/enums/TsObjectDeclarationType.js +0 -16
  74. package/dist/enums/Visibility.d.ts +0 -6
  75. package/dist/enums/Visibility.js +0 -18
  76. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +0 -4
  77. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +0 -61
  78. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
  79. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +0 -52
  80. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
  81. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +0 -77
  82. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
  83. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
  84. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +0 -4
  85. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +0 -66
  86. /package/dist/{enums → generators/ts}/TsFeature.d.ts +0 -0
  87. /package/dist/{enums → generators/ts}/TsFeature.js +0 -0
@@ -1,52 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import { snippets } from "../snippets.js";
3
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
4
- import { code, joinCode } from "../ts-poet-wrapper.js";
5
- export function NamedObjectType_equalsFunctionOrMethodDeclaration() {
6
- if (!this.features.has("equals")) {
7
- return Maybe.empty();
8
- }
9
- const chain = [];
10
- let leftVariable;
11
- let parameters;
12
- let preamble;
13
- let rightVariable;
14
- switch (this.declarationType) {
15
- case "class":
16
- if (this.properties.length === 0) {
17
- // If there's a parent class and no properties in this class, can skip overriding equals
18
- return Maybe.empty();
19
- }
20
- leftVariable = code `this`;
21
- parameters = code `other: ${this.name}`;
22
- if (this.parentObjectTypes.length > 0) {
23
- chain.push(code `super.${syntheticNamePrefix}equals(other)`);
24
- preamble = "override ";
25
- }
26
- else {
27
- preamble = "";
28
- }
29
- rightVariable = code `other`;
30
- break;
31
- case "interface":
32
- // For every parent, find the nearest equals implementation
33
- for (const parentObjectType of this.parentObjectTypes) {
34
- chain.push(code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}equals(left, right)`);
35
- }
36
- leftVariable = code `left`;
37
- parameters = code `left: ${this.name}, right: ${this.name}`;
38
- preamble = "export function ";
39
- rightVariable = code `right`;
40
- }
41
- for (const property of this.properties) {
42
- if (property.kind === "DiscriminantProperty") {
43
- continue;
44
- }
45
- chain.push(code `(${property.type.equalsFunction})(${property.accessExpression({ variables: { object: leftVariable } })}, ${property.accessExpression({ variables: { object: rightVariable } })}).mapLeft(propertyValuesUnequal => ({ left: ${leftVariable}, right: ${rightVariable}, propertyName: "${property.name}", propertyValuesUnequal, type: "property" as const }))`);
46
- }
47
- return Maybe.of(code `\
48
- ${preamble}${syntheticNamePrefix}equals(${parameters}): ${snippets.EqualsResult} {
49
- return ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
50
- }`);
51
- }
52
- //# sourceMappingURL=NamedObjectType_equalsFunctionOrMethodDeclaration.js.map
@@ -1,4 +0,0 @@
1
- import type { NamedObjectType } from "../NamedObjectType.js";
2
- import { type Code } from "../ts-poet-wrapper.js";
3
- export declare function NamedObjectType_hashFunctionOrMethodDeclarations(this: NamedObjectType): readonly Code[];
4
- //# sourceMappingURL=NamedObjectType_hashFunctionOrMethodDeclarations.d.ts.map
@@ -1,77 +0,0 @@
1
- import { snippets } from "../snippets.js";
2
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
3
- import { code, joinCode } from "../ts-poet-wrapper.js";
4
- const hasherVariable = code `_hasher`;
5
- export function NamedObjectType_hashFunctionOrMethodDeclarations() {
6
- if (!this.features.has("hash")) {
7
- return [];
8
- }
9
- const hashOwnShaclPropertiesStatements = this.properties.flatMap((property) => property.kind === "ShaclProperty"
10
- ? property.hashStatements({
11
- depth: 0,
12
- variables: {
13
- hasher: hasherVariable,
14
- value: property.accessExpression({
15
- variables: { object: this.thisVariable },
16
- }),
17
- },
18
- })
19
- : []);
20
- if (this.declarationType === "class" &&
21
- this.parentObjectTypes.length > 0 &&
22
- hashOwnShaclPropertiesStatements.length === 0) {
23
- // If there's a parent class and no hash statements in this class, can skip overriding hash
24
- return [];
25
- }
26
- const hashShaclPropertiesStatements = [];
27
- const hashStatements = [];
28
- const parameters = []; // Same between the two functions
29
- let hashPreamble = "";
30
- let hashShaclPropertiesPreamble = "";
31
- switch (this.declarationType) {
32
- case "class": {
33
- if (this.parentObjectTypes.length > 0) {
34
- hashShaclPropertiesStatements.push(code `super.${syntheticNamePrefix}hashShaclProperties(${hasherVariable});`);
35
- hashShaclPropertiesPreamble = "override ";
36
- hashPreamble = "override ";
37
- }
38
- hashShaclPropertiesPreamble = `protected ${hashShaclPropertiesPreamble}`;
39
- hashStatements.push(code `this.${syntheticNamePrefix}hashShaclProperties(${hasherVariable});`);
40
- break;
41
- }
42
- case "interface": {
43
- for (const parentObjectType of this.parentObjectTypes) {
44
- hashShaclPropertiesStatements.push(code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
45
- }
46
- parameters.push(code `${this.thisVariable}: ${this.name}`);
47
- hashPreamble = hashShaclPropertiesPreamble = "export function ";
48
- hashStatements.push(code `${this.staticModuleName}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
49
- break;
50
- }
51
- }
52
- parameters.push(code `${hasherVariable}: HasherT`);
53
- const parametersCode = joinCode(parameters, { on: "," });
54
- hashShaclPropertiesStatements.push(...hashOwnShaclPropertiesStatements);
55
- hashShaclPropertiesStatements.push(code `return ${hasherVariable};`);
56
- hashStatements.push(...this.properties
57
- .filter((property) => property.kind !== "ShaclProperty")
58
- .flatMap((property) => property.hashStatements({
59
- depth: 0,
60
- variables: {
61
- hasher: hasherVariable,
62
- value: code `${property.accessExpression({ variables: { object: this.thisVariable } })}`,
63
- },
64
- })));
65
- hashStatements.push(code `return ${hasherVariable};`);
66
- return [
67
- code `\
68
- ${hashPreamble}${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(${parametersCode}): HasherT {
69
- ${joinCode(hashStatements)}
70
- }`,
71
- code `\
72
- ${hashShaclPropertiesPreamble}${syntheticNamePrefix}hashShaclProperties<HasherT extends ${snippets.Hasher}>(${parametersCode}): HasherT {
73
- ${joinCode(hashShaclPropertiesStatements)}
74
- }`,
75
- ];
76
- }
77
- //# sourceMappingURL=NamedObjectType_hashFunctionOrMethodDeclarations.js.map
@@ -1,5 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import type { NamedObjectType } from "../NamedObjectType.js";
3
- import { type Code } from "../ts-poet-wrapper.js";
4
- export declare function NamedObjectType_toJsonFunctionOrMethodDeclaration(this: NamedObjectType): Maybe<Code>;
5
- //# sourceMappingURL=NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts.map
@@ -1,5 +0,0 @@
1
- import { Maybe } from "purify-ts";
2
- import type { NamedObjectType } from "../NamedObjectType.js";
3
- import { type Code } from "../ts-poet-wrapper.js";
4
- export declare function NamedObjectType_toRdfResourceFunctionOrMethodDeclaration(this: NamedObjectType): Maybe<Code>;
5
- //# sourceMappingURL=NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts.map
@@ -1,4 +0,0 @@
1
- import type { NamedObjectType } from "../NamedObjectType.js";
2
- import { type Code } from "../ts-poet-wrapper.js";
3
- export declare function NamedObjectType_toStringFunctionOrMethodDeclarations(this: NamedObjectType): readonly Code[];
4
- //# sourceMappingURL=NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts.map
@@ -1,66 +0,0 @@
1
- import { snippets } from "../snippets.js";
2
- import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
3
- import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
4
- export function NamedObjectType_toStringFunctionOrMethodDeclarations() {
5
- const propertiesToStringRecordProperties = [];
6
- if (this.parentObjectTypes.length > 0) {
7
- switch (this.declarationType) {
8
- case "class": {
9
- propertiesToStringRecordProperties.push(code `...super.${syntheticNamePrefix}propertiesToStrings()`);
10
- break;
11
- }
12
- case "interface": {
13
- for (const parentObjectType of this.parentObjectTypes) {
14
- propertiesToStringRecordProperties.push(code `...${parentObjectType.staticModuleName}.${syntheticNamePrefix}propertiesToStrings(${this.thisVariable})`);
15
- }
16
- break;
17
- }
18
- }
19
- }
20
- for (const property of this.properties) {
21
- property
22
- .toStringExpression({
23
- variables: {
24
- value: property.accessExpression({
25
- variables: { object: this.thisVariable },
26
- }),
27
- },
28
- })
29
- .ifJust((propertyToStringExpression) => {
30
- propertiesToStringRecordProperties.push(code `${literalOf(property.name)}: ${propertyToStringExpression}`);
31
- });
32
- }
33
- const propertiesToStringsReturnExpression = code `${snippets.compactRecord}({${joinCode(propertiesToStringRecordProperties, { on: "," })}})`;
34
- const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
35
- switch (this.declarationType) {
36
- case "class": {
37
- let propertiesToStringsPreamble = "";
38
- let toStringPreamble = "";
39
- if (this.parentObjectTypes.length > 0) {
40
- propertiesToStringsPreamble = "override ";
41
- toStringPreamble = "override ";
42
- }
43
- propertiesToStringsPreamble = `protected ${propertiesToStringsPreamble}`;
44
- return [
45
- code `${propertiesToStringsPreamble}${syntheticNamePrefix}propertiesToStrings(): Record<string, string> { return ${propertiesToStringsReturnExpression}; }`,
46
- code `${toStringPreamble}toString(): string { return ${toStringReturnExpression(code `this.${syntheticNamePrefix}propertiesToStrings()`)}; }`,
47
- ];
48
- }
49
- case "interface": {
50
- return [
51
- // Use overloads to allow the function to be attached to an instance or used freestanding
52
- code `\
53
- export function ${syntheticNamePrefix}propertiesToStrings(${this.thisVariable}: ${this.name}): Record<string, string> {
54
- return ${propertiesToStringsReturnExpression};
55
- }`,
56
- code `\
57
- export function ${syntheticNamePrefix}toString(this: ${this.name}): string;
58
- export function ${syntheticNamePrefix}toString(${this.thisVariable}: ${this.name}): string;
59
- export function ${syntheticNamePrefix}toString(this: ${this.name} | undefined, ${this.thisVariable}?: ${this.name}): string {
60
- return ${toStringReturnExpression(code `${syntheticNamePrefix}propertiesToStrings((${this.thisVariable} ?? this)!)`)};
61
- }`,
62
- ];
63
- }
64
- }
65
- }
66
- //# sourceMappingURL=NamedObjectType_toStringFunctionOrMethodDeclaration.js.map
File without changes
File without changes