@shaclmate/compiler 4.0.23 → 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 (117) hide show
  1. package/dist/Compiler.d.ts +1 -1
  2. package/dist/ShapesGraphToAstTransformer.d.ts +1 -1
  3. package/dist/ShapesGraphToAstTransformer.js +16 -16
  4. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +1 -1
  5. package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +5 -2
  6. package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +6 -5
  7. package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +1 -1
  8. package/dist/_ShapesGraphToAstTransformer/shapeOntology.js +4 -3
  9. package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +11 -17
  10. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +3 -3
  11. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +6 -11
  12. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +21 -40
  13. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
  14. package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
  15. package/dist/ast/AbstractCompoundType.d.ts +1 -1
  16. package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
  17. package/dist/ast/ListType.d.ts +1 -8
  18. package/dist/ast/ListType.js +1 -6
  19. package/dist/ast/ObjectType.d.ts +3 -30
  20. package/dist/ast/ObjectType.js +2 -26
  21. package/dist/generators/ts/AbstractContainerType.d.ts +0 -1
  22. package/dist/generators/ts/AbstractContainerType.js +0 -1
  23. package/dist/generators/ts/AbstractLazyObjectType.d.ts +0 -1
  24. package/dist/generators/ts/AbstractLazyObjectType.js +2 -2
  25. package/dist/generators/ts/AbstractNamedUnionType.d.ts +1 -2
  26. package/dist/generators/ts/AbstractNamedUnionType.js +16 -19
  27. package/dist/generators/ts/AbstractTermType.d.ts +0 -1
  28. package/dist/generators/ts/AbstractTermType.js +0 -1
  29. package/dist/generators/ts/AbstractType.d.ts +0 -4
  30. package/dist/generators/ts/AbstractUnionType.d.ts +1 -10
  31. package/dist/generators/ts/AbstractUnionType.js +27 -40
  32. package/dist/generators/ts/LazyObjectOptionType.js +3 -2
  33. package/dist/generators/ts/LazyObjectSetType.js +2 -1
  34. package/dist/generators/ts/LazyObjectType.js +2 -1
  35. package/dist/generators/ts/ListType.d.ts +1 -5
  36. package/dist/generators/ts/ListType.js +8 -27
  37. package/dist/generators/ts/NamedObjectType.d.ts +2 -21
  38. package/dist/generators/ts/NamedObjectType.js +33 -132
  39. package/dist/generators/ts/NamedObjectUnionType.js +14 -25
  40. package/dist/generators/ts/TypeFactory.js +11 -67
  41. package/dist/generators/ts/ZodGenerator.js +2 -2
  42. package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +11 -17
  43. package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +7 -6
  44. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +1 -4
  45. package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +19 -34
  46. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +5 -15
  47. package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +31 -212
  48. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +2 -2
  49. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +5 -0
  50. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +25 -0
  51. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +4 -4
  52. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +1 -1
  53. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +2 -2
  54. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +2 -2
  55. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -8
  56. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +5 -13
  57. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -4
  58. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +4 -0
  59. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +49 -0
  60. package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
  61. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +0 -3
  62. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
  63. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +2 -2
  64. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +2 -2
  65. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +2 -2
  66. package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
  67. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +2 -2
  68. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +1 -2
  69. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
  70. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
  71. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -2
  72. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +5 -0
  73. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +41 -0
  74. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
  75. package/dist/generators/ts/_NamedObjectType/{NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js → NamedObjectType_toRdfResourceFunctionDeclaration.js} +8 -27
  76. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +4 -0
  77. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +40 -0
  78. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
  79. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
  80. package/dist/generators/ts/_NamedObjectType/Property.d.ts +1 -2
  81. package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -3
  82. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +8 -39
  83. package/dist/generators/ts/_snippets/snippets_LazyObject.js +2 -2
  84. package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +2 -2
  85. package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +2 -2
  86. package/dist/generators/ts/imports.d.ts +0 -2
  87. package/dist/generators/ts/imports.js +0 -2
  88. package/dist/generators/ts/objectSetDeclarations.js +1 -3
  89. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +4 -6
  90. package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
  91. package/dist/input/ShapesGraph.d.ts +1 -1
  92. package/dist/input/generated.d.ts +10 -181
  93. package/dist/input/generated.js +116 -392
  94. package/package.json +2 -4
  95. package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.d.ts +0 -6
  96. package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.js +0 -32
  97. package/dist/enums/IdentifierMintingStrategy.d.ts +0 -9
  98. package/dist/enums/IdentifierMintingStrategy.js +0 -18
  99. package/dist/enums/TsObjectDeclarationType.d.ts +0 -9
  100. package/dist/enums/TsObjectDeclarationType.js +0 -16
  101. package/dist/enums/Visibility.d.ts +0 -6
  102. package/dist/enums/Visibility.js +0 -18
  103. package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.d.ts +0 -33
  104. package/dist/generators/ts/_NamedObjectType/IdentifierPrefixProperty.js +0 -92
  105. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +0 -4
  106. package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.js +0 -62
  107. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
  108. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js +0 -51
  109. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
  110. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js +0 -73
  111. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
  112. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js +0 -59
  113. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +0 -5
  114. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.d.ts +0 -4
  115. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionOrMethodDeclaration.js +0 -62
  116. /package/dist/{enums → generators/ts}/TsFeature.d.ts +0 -0
  117. /package/dist/{enums → generators/ts}/TsFeature.js +0 -0
@@ -0,0 +1,25 @@
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_equalsFunctionDeclaration() {
6
+ if (!this.features.has("equals")) {
7
+ return Maybe.empty();
8
+ }
9
+ const chain = [];
10
+ // For every parent, find the nearest equals implementation
11
+ for (const parentObjectType of this.parentObjectTypes) {
12
+ chain.push(code `${parentObjectType.name}.${syntheticNamePrefix}equals(left, right)`);
13
+ }
14
+ for (const property of this.properties) {
15
+ if (property.kind === "DiscriminantProperty") {
16
+ continue;
17
+ }
18
+ chain.push(code `(${property.type.equalsFunction})(${property.accessExpression({ variables: { object: code `left` } })}, ${property.accessExpression({ variables: { object: code `right` } })}).mapLeft(propertyValuesUnequal => ({ left, right, propertyName: "${property.name}", propertyValuesUnequal, type: "property" as const }))`);
19
+ }
20
+ return Maybe.of(code `\
21
+ export function ${syntheticNamePrefix}equals(left: ${this.name}, right: ${this.name}): ${snippets.EqualsResult} {
22
+ return ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
23
+ }`);
24
+ }
25
+ //# sourceMappingURL=NamedObjectType_equalsFunctionDeclaration.js.map
@@ -5,10 +5,10 @@ export function NamedObjectType_filterFunctionDeclaration() {
5
5
  for (const parentObjectType of this.parentObjectTypes) {
6
6
  statements.push(code `if (!${parentObjectType.filterFunction}(filter, value)) { return false; }`);
7
7
  }
8
- if (this.ownProperties.length > 0) {
9
- for (const ownProperty of this.ownProperties) {
10
- ownProperty.filterProperty.ifJust(({ name }) => {
11
- statements.push(code `if (filter.${name} !== undefined && !${ownProperty.type.filterFunction}(filter.${name}, value.${ownProperty.name})) { return false; }`);
8
+ if (this.properties.length > 0) {
9
+ for (const property of this.properties) {
10
+ property.filterProperty.ifJust(({ name }) => {
11
+ statements.push(code `if (filter.${name} !== undefined && !${property.type.filterFunction}(filter.${name}, ${property.accessExpression({ variables: { object: code `value` } })})) { return false; }`);
12
12
  });
13
13
  }
14
14
  }
@@ -14,7 +14,7 @@ export function NamedObjectType_filterTypeDeclaration() {
14
14
  }
15
15
  }
16
16
  for (const parentObjectType of this.parentObjectTypes) {
17
- members.push(code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}Filter`);
17
+ members.push(code `${parentObjectType.name}.${syntheticNamePrefix}Filter`);
18
18
  }
19
19
  return code `\
20
20
  export type ${syntheticNamePrefix}Filter = ${members.length > 0 ? joinCode(members, { on: " & " }) : "object"};`;
@@ -19,7 +19,7 @@ export function NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration()
19
19
  let triplesVariableDeclarationKeyword = "const";
20
20
  const statements = [];
21
21
  for (const parentObjectType of this.parentObjectTypes) {
22
- statements.push(code `triples = triples.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}focusSparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
22
+ statements.push(code `triples = triples.concat(${parentObjectType.name}.${syntheticNamePrefix}focusSparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
23
23
  triplesVariableDeclarationKeyword = "let";
24
24
  }
25
25
  if (this.fromRdfType.isJust()) {
@@ -31,7 +31,7 @@ if (!parameters?.ignoreRdfType) {
31
31
  );
32
32
  }`);
33
33
  }
34
- for (const property of this.ownProperties) {
34
+ for (const property of this.properties) {
35
35
  if (property.recursive) {
36
36
  continue;
37
37
  }
@@ -21,7 +21,7 @@ export function NamedObjectType_focusSparqlWherePatternsFunctionDeclaration() {
21
21
  const statements = [];
22
22
  for (const parentObjectType of this.parentObjectTypes) {
23
23
  statements.push(code `\
24
- patterns = patterns.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}focusSparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, preferredLanguages: variables.preferredLanguages, variablePrefix: variables.variablePrefix }}));`);
24
+ patterns = patterns.concat(${parentObjectType.name}.${syntheticNamePrefix}focusSparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, preferredLanguages: variables.preferredLanguages, variablePrefix: variables.variablePrefix }}));`);
25
25
  patternsVariableDeclarationKeyword = "let";
26
26
  }
27
27
  if (this.fromRdfType.isJust()) {
@@ -75,7 +75,7 @@ if (!parameters?.ignoreRdfType) {
75
75
  );
76
76
  }`);
77
77
  }
78
- for (const property of this.ownProperties) {
78
+ for (const property of this.properties) {
79
79
  if (property.recursive) {
80
80
  continue;
81
81
  }
@@ -5,16 +5,9 @@ export function NamedObjectType_fromJsonFunctionDeclaration() {
5
5
  if (!this.features.has("json")) {
6
6
  return Maybe.empty();
7
7
  }
8
- if (this.abstract) {
9
- return Maybe.empty();
10
- }
11
- let returnExpression = code `${syntheticNamePrefix}propertiesFromJson(json)`;
12
- if (this.declarationType === "class") {
13
- returnExpression = code `new ${this.name}(${returnExpression})`;
14
- }
15
8
  return Maybe.of(code `\
16
9
  export function ${syntheticNamePrefix}fromJson(json: ${this.jsonType().name}): ${this.name} {
17
- return ${returnExpression};
10
+ return ${syntheticNamePrefix}create(${syntheticNamePrefix}propertiesFromJson(json));
18
11
  }`);
19
12
  }
20
13
  //# sourceMappingURL=NamedObjectType_fromJsonFunctionDeclaration.js.map
@@ -6,21 +6,13 @@ export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
6
6
  if (!this.features.has("rdf")) {
7
7
  return Maybe.empty();
8
8
  }
9
- if (this.abstract) {
10
- return Maybe.empty();
11
- }
12
- const statements = [
13
- code `let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages } = (options ?? {});`,
14
- code `if (!objectSet) { objectSet = new ${syntheticNamePrefix}RdfjsDatasetObjectSet(resource.dataset); }`,
15
- ];
16
- let propertiesFromRdfExpression = code `${this.staticModuleName}.${syntheticNamePrefix}propertiesFromRdfResource(resource, { context, graph, ignoreRdfType, objectSet, preferredLanguages })`;
17
- if (this.declarationType === "class") {
18
- propertiesFromRdfExpression = code `${propertiesFromRdfExpression}.map(properties => new ${this.name}(properties))`;
19
- }
20
- statements.push(code `return ${propertiesFromRdfExpression};`);
21
9
  return Maybe.of(code `\
22
10
  export const ${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFunction}<${this.name}> = (resource, options) => {
23
- ${joinCode(statements)}
11
+ ${joinCode([
12
+ code `let { context, graph, ignoreRdfType = false, objectSet, preferredLanguages } = (options ?? {});`,
13
+ code `if (!objectSet) { objectSet = new ${syntheticNamePrefix}RdfjsDatasetObjectSet(resource.dataset); }`,
14
+ code `return ${code `${this.name}.${syntheticNamePrefix}propertiesFromRdfResource(resource, { context, graph, ignoreRdfType, objectSet, preferredLanguages }).map(${syntheticNamePrefix}create)`};`,
15
+ ])}
24
16
  };`);
25
17
  }
26
18
  //# sourceMappingURL=NamedObjectType_fromRdfResourceFunctionDeclaration.js.map
@@ -6,14 +6,11 @@ export function NamedObjectType_fromRdfResourceValuesFunctionDeclaration() {
6
6
  if (!this.features.has("rdf")) {
7
7
  return Maybe.empty();
8
8
  }
9
- if (this.abstract) {
10
- return Maybe.empty();
11
- }
12
9
  return Maybe.of(code `\
13
10
  export const ${syntheticNamePrefix}fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${this.name}> = (values, options) =>
14
11
  values.chain(
15
12
  values => values.chainMap(
16
- value => value.toResource().chain(resource => ${this.staticModuleName}.${syntheticNamePrefix}fromRdfResource(resource, options))
13
+ value => value.toResource().chain(resource => ${this.name}.${syntheticNamePrefix}fromRdfResource(resource, options))
17
14
  )
18
15
  );`);
19
16
  }
@@ -0,0 +1,4 @@
1
+ import type { NamedObjectType } from "../NamedObjectType.js";
2
+ import { type Code } from "../ts-poet-wrapper.js";
3
+ export declare function NamedObjectType_hashFunctionDeclarations(this: NamedObjectType): readonly Code[];
4
+ //# sourceMappingURL=NamedObjectType_hashFunctionDeclarations.d.ts.map
@@ -0,0 +1,49 @@
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_hashFunctionDeclarations() {
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
+ const hashShaclPropertiesStatements = [];
21
+ const hashStatements = [];
22
+ for (const parentObjectType of this.parentObjectTypes) {
23
+ hashShaclPropertiesStatements.push(code `${parentObjectType.name}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
24
+ }
25
+ hashStatements.push(code `${this.name}.${syntheticNamePrefix}hashShaclProperties(${this.thisVariable}, ${hasherVariable});`);
26
+ hashShaclPropertiesStatements.push(...hashOwnShaclPropertiesStatements);
27
+ hashShaclPropertiesStatements.push(code `return ${hasherVariable};`);
28
+ hashStatements.push(...this.properties
29
+ .filter((property) => property.kind !== "ShaclProperty")
30
+ .flatMap((property) => property.hashStatements({
31
+ depth: 0,
32
+ variables: {
33
+ hasher: hasherVariable,
34
+ value: code `${property.accessExpression({ variables: { object: this.thisVariable } })}`,
35
+ },
36
+ })));
37
+ hashStatements.push(code `return ${hasherVariable};`);
38
+ return [
39
+ code `\
40
+ export function ${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(${this.thisVariable}: ${this.name}, ${hasherVariable}: HasherT): HasherT {
41
+ ${joinCode(hashStatements)}
42
+ }`,
43
+ code `\
44
+ export function ${syntheticNamePrefix}hashShaclProperties<HasherT extends ${snippets.Hasher}>(${this.thisVariable}: ${this.name}, ${hasherVariable}: HasherT): HasherT {
45
+ ${joinCode(hashShaclPropertiesStatements)}
46
+ }`,
47
+ ];
48
+ }
49
+ //# sourceMappingURL=NamedObjectType_hashFunctionDeclarations.js.map
@@ -10,7 +10,7 @@ ${this.comment
10
10
  .map((parentObjectType) => parentObjectType.name)
11
11
  .join(", ")}`
12
12
  : ""} {
13
- ${joinCode(this.properties.flatMap((property) => property.declaration.toList()))}
13
+ ${joinCode(this.properties.map((property) => property.declaration))}
14
14
  }`;
15
15
  }
16
16
  //# sourceMappingURL=NamedObjectType_interfaceDeclaration.js.map
@@ -6,9 +6,6 @@ export function NamedObjectType_jsonParseFunctionDeclaration() {
6
6
  if (!this.features.has("json")) {
7
7
  return Maybe.empty();
8
8
  }
9
- if (this.abstract) {
10
- return Maybe.empty();
11
- }
12
9
  return Maybe.of(code `\
13
10
  export function parse(json: unknown): ${imports.Either}<Error, ${syntheticNamePrefix}Json> {
14
11
  const jsonSafeParseResult = schema().safeParse(json);
@@ -16,7 +16,7 @@ export function NamedObjectType_jsonSchemaFunctionDeclaration() {
16
16
  .map(({ key, schema }) => code `"${key}": ${schema}`));
17
17
  }
18
18
  const meta = {
19
- id: this.name,
19
+ // id: this.name,
20
20
  };
21
21
  this.comment.ifJust((description) => {
22
22
  meta["description"] = description;
@@ -6,8 +6,8 @@ export function NamedObjectType_jsonTypeAliasDeclaration() {
6
6
  return Maybe.empty();
7
7
  }
8
8
  const members = [];
9
- if (this.ownProperties.length > 0) {
10
- members.push(code `{ ${joinCode(this.ownProperties.flatMap((property) => property.jsonSignature.toList()), { on: ";" })} }`);
9
+ if (this.properties.length > 0) {
10
+ members.push(code `{ ${joinCode(this.properties.flatMap((property) => property.jsonSignature.toList()), { on: ";" })} }`);
11
11
  }
12
12
  for (const parentObjectType of this.parentObjectTypes) {
13
13
  members.push(code `${parentObjectType.jsonType().name}`);
@@ -7,8 +7,8 @@ export function NamedObjectType_jsonUiSchemaFunctionDeclaration() {
7
7
  }
8
8
  const variables = { scopePrefix: code `scopePrefix` };
9
9
  const elements = this.parentObjectTypes
10
- .map((parentObjectType) => code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}Json.uiSchema({ scopePrefix })`)
11
- .concat(this.ownProperties.flatMap((property) => property.jsonUiSchemaElement({ variables }).toList()));
10
+ .map((parentObjectType) => code `${parentObjectType.name}.${syntheticNamePrefix}Json.uiSchema({ scopePrefix })`)
11
+ .concat(this.properties.flatMap((property) => property.jsonUiSchemaElement({ variables }).toList()));
12
12
  return Maybe.of(code `\
13
13
  export function uiSchema(parameters?: { scopePrefix?: string }): any {
14
14
  const scopePrefix = parameters?.scopePrefix ?? "#";
@@ -13,8 +13,8 @@ export function NamedObjectType_propertiesFromJsonFunctionDeclaration() {
13
13
  const propertyReturnTypeSignatures = [];
14
14
  const returnType = [];
15
15
  this.parentObjectTypes.forEach((parentObjectType) => {
16
- initializers.push(code `...${parentObjectType.staticModuleName}.${syntheticNamePrefix}propertiesFromJson(${variables.jsonObject})`);
17
- returnType.push(code `ReturnType<typeof ${parentObjectType.staticModuleName}.${syntheticNamePrefix}propertiesFromJson>`);
16
+ initializers.push(code `...${parentObjectType.name}.${syntheticNamePrefix}propertiesFromJson(${variables.jsonObject})`);
17
+ returnType.push(code `ReturnType<typeof ${parentObjectType.name}.${syntheticNamePrefix}propertiesFromJson>`);
18
18
  });
19
19
  for (const property of this.properties) {
20
20
  const propertyFromJsonStatements = property.fromJsonStatements({
@@ -24,11 +24,11 @@ export function NamedObjectType_propertiesFromRdfResourceFunctionDeclaration() {
24
24
  const returnType = [];
25
25
  this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
26
26
  chains.push({
27
- expression: code `${parentObjectType.staticModuleName}.${syntheticNamePrefix}propertiesFromRdfResource(${variables.resource}, { ...${optionsVariable}, ignoreRdfType: true })`,
27
+ expression: code `${parentObjectType.name}.${syntheticNamePrefix}propertiesFromRdfResource(${variables.resource}, { ...${optionsVariable}, ignoreRdfType: true })`,
28
28
  variable: `${syntheticNamePrefix}super${parentObjectTypeI}`,
29
29
  });
30
30
  initializers.push(code `...${syntheticNamePrefix}super${parentObjectTypeI}`);
31
- returnType.push(code `${snippets.UnwrapR}<ReturnType<typeof ${parentObjectType.staticModuleName}.${syntheticNamePrefix}propertiesFromRdfResource>>`);
31
+ returnType.push(code `${snippets.UnwrapR}<ReturnType<typeof ${parentObjectType.name}.${syntheticNamePrefix}propertiesFromRdfResource>>`);
32
32
  });
33
33
  this.fromRdfType.ifJust((fromRdfType) => {
34
34
  const fromRdfTypeVariable = this.fromRdfTypeVariable.unsafeCoerce();
@@ -3,7 +3,7 @@ import { code, joinCode } from "../ts-poet-wrapper.js";
3
3
  export function NamedObjectType_schemaVariableStatement() {
4
4
  return code `\
5
5
  export const ${syntheticNamePrefix}schema = { properties: { ${joinCode(this.parentObjectTypes
6
- .map((parentObjectType) => code `...${parentObjectType.staticModuleName}.${syntheticNamePrefix}schema.properties`)
7
- .concat(this.ownProperties.map((property) => code `${property.name}: ${property.schema}`)), { on: ", " })} } } as const;`;
6
+ .map((parentObjectType) => code `...${parentObjectType.name}.${syntheticNamePrefix}schema.properties`)
7
+ .concat(this.properties.map((property) => code `${property.name}: ${property.schema}`)), { on: ", " })} } } as const;`;
8
8
  }
9
9
  //# sourceMappingURL=NamedObjectType_schemaVariableStatement.js.map
@@ -1,10 +1,9 @@
1
1
  import { Maybe } from "purify-ts";
2
- import type { TsFeature } from "../../../enums/TsFeature.js";
2
+ import type { TsFeature } from "../TsFeature.js";
3
3
  import { type Code } from "../ts-poet-wrapper.js";
4
4
  export declare function NamedObjectType_sparqlConstructQueryFunctionDeclaration(this: {
5
5
  readonly features: ReadonlySet<TsFeature>;
6
6
  readonly filterType: Code;
7
7
  readonly name: string;
8
- readonly staticModuleName: string;
9
8
  }): Maybe<Code>;
10
9
  //# sourceMappingURL=NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts.map
@@ -17,7 +17,7 @@ export function ${syntheticNamePrefix}sparqlConstructQuery({ filter, ignoreRdfTy
17
17
  prefixes: prefixes ?? {},
18
18
  queryType: "CONSTRUCT",
19
19
  template: (queryParameters.template ?? []).concat(
20
- ${this.staticModuleName}.${syntheticNamePrefix}focusSparqlConstructTriples({
20
+ ${this.name}.${syntheticNamePrefix}focusSparqlConstructTriples({
21
21
  filter,
22
22
  focusIdentifier: subject,
23
23
  ignoreRdfType: !!ignoreRdfType,
@@ -27,7 +27,7 @@ export function ${syntheticNamePrefix}sparqlConstructQuery({ filter, ignoreRdfTy
27
27
  type: "query",
28
28
  where: (queryParameters.where ?? []).concat(
29
29
  ${snippets.normalizeSparqlWherePatterns}(
30
- ${this.staticModuleName}.${syntheticNamePrefix}focusSparqlWherePatterns({
30
+ ${this.name}.${syntheticNamePrefix}focusSparqlWherePatterns({
31
31
  filter,
32
32
  focusIdentifier: subject,
33
33
  ignoreRdfType: !!ignoreRdfType,
@@ -1,9 +1,9 @@
1
1
  import { Maybe } from "purify-ts";
2
- import type { TsFeature } from "../../../enums/TsFeature.js";
2
+ import type { TsFeature } from "../TsFeature.js";
3
3
  import { type Code } from "../ts-poet-wrapper.js";
4
4
  export declare function NamedObjectType_sparqlConstructQueryStringFunctionDeclaration(this: {
5
5
  readonly features: ReadonlySet<TsFeature>;
6
6
  readonly filterType: Code;
7
- readonly staticModuleName: string;
7
+ readonly name: string;
8
8
  }): Maybe<Code>;
9
9
  //# sourceMappingURL=NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts.map
@@ -7,8 +7,8 @@ export function NamedObjectType_sparqlConstructQueryStringFunctionDeclaration()
7
7
  return Maybe.empty();
8
8
  }
9
9
  return Maybe.of(code `\
10
- export function ${syntheticNamePrefix}sparqlConstructQueryString(parameters: Parameters<typeof ${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery>[0] & ${imports.sparqljs}.GeneratorOptions): string {
11
- return new ${imports.sparqljs}.Generator(parameters).stringify(${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery(parameters));
10
+ export function ${syntheticNamePrefix}sparqlConstructQueryString(parameters: Parameters<typeof ${this.name}.${syntheticNamePrefix}sparqlConstructQuery>[0] & ${imports.sparqljs}.GeneratorOptions): string {
11
+ return new ${imports.sparqljs}.Generator(parameters).stringify(${this.name}.${syntheticNamePrefix}sparqlConstructQuery(parameters));
12
12
  }`);
13
13
  }
14
14
  //# sourceMappingURL=NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js.map
@@ -0,0 +1,5 @@
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_toJsonFunctionDeclaration(this: NamedObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=NamedObjectType_toJsonFunctionDeclaration.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { Maybe } from "purify-ts";
2
+ import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
3
+ import { code, joinCode } from "../ts-poet-wrapper.js";
4
+ export function NamedObjectType_toJsonFunctionDeclaration() {
5
+ if (!this.features.has("json")) {
6
+ return Maybe.empty();
7
+ }
8
+ const jsonObjectMembers = [];
9
+ for (const parentObjectType of this.parentObjectTypes) {
10
+ jsonObjectMembers.push(code `...${parentObjectType.name}.${syntheticNamePrefix}toJson(${this.thisVariable})`);
11
+ }
12
+ if (this.properties.length > 0) {
13
+ jsonObjectMembers.push(...this.properties.flatMap((property) => property
14
+ .toJsonObjectMemberExpression({
15
+ variables: {
16
+ value: property.accessExpression({
17
+ variables: { object: this.thisVariable },
18
+ }),
19
+ },
20
+ })
21
+ .toList()));
22
+ }
23
+ // 20241220: don't add @type until we're doing JSON-LD
24
+ // switch (this.toRdfTypes.length) {
25
+ // case 0:
26
+ // break;
27
+ // case 1:
28
+ // jsonObjectMembers.push(`"@type": "${this.toRdfTypes[0].value}"`);
29
+ // break;
30
+ // default:
31
+ // jsonObjectMembers.push(
32
+ // `"@type": ${JSON.stringify(this.toRdfTypes.map((rdfType) => rdfType.value))}`,
33
+ // );
34
+ // break;
35
+ // }
36
+ return Maybe.of(code `\
37
+ export function ${syntheticNamePrefix}toJson(${this.thisVariable}: ${this.name}): ${this.jsonType().name} {
38
+ return JSON.parse(JSON.stringify({ ${joinCode(jsonObjectMembers, { on: "," })} } satisfies ${this.jsonType().name}));
39
+ }`);
40
+ }
41
+ //# sourceMappingURL=NamedObjectType_toJsonFunctionDeclaration.js.map
@@ -0,0 +1,5 @@
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_toRdfResourceFunctionDeclaration(this: NamedObjectType): Maybe<Code>;
5
+ //# sourceMappingURL=NamedObjectType_toRdfResourceFunctionDeclaration.d.ts.map
@@ -5,39 +5,18 @@ import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
5
5
  import { snippets } from "../snippets.js";
6
6
  import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
7
7
  import { code, joinCode } from "../ts-poet-wrapper.js";
8
- export function NamedObjectType_toRdfResourceFunctionOrMethodDeclaration() {
8
+ export function NamedObjectType_toRdfResourceFunctionDeclaration() {
9
9
  if (!this.features.has("rdf")) {
10
10
  return Maybe.empty();
11
11
  }
12
- this.ensureAtMostOneSuperObjectType();
13
- let preamble = "";
14
- if (this.declarationType === "interface") {
15
- preamble = "export function ";
16
- }
17
- const parameters = [];
18
- if (this.declarationType === "interface") {
19
- parameters.push(code `${this.thisVariable}: ${this.name}`);
20
- }
21
- parameters.push(code `options?: Parameters<${snippets.ToRdfResourceFunction}<${this.name}>>[1]`);
22
12
  const statements = [
23
13
  code `const ${variables.resourceSet} = options?.${variables.resourceSet} ?? new ${imports.ResourceSet}({ dataFactory: ${imports.dataFactory}, dataset: ${imports.datasetFactory}.dataset() });`,
24
14
  ];
25
15
  if (this.parentObjectTypes.length > 0) {
26
- const superToRdfOptions = code `{ ${variables.ignoreRdfType}: true, ${variables.graph}: options?.${variables.graph}, ${variables.resourceSet} }`;
27
- let superToRdfCall;
28
- switch (this.declarationType) {
29
- case "class":
30
- preamble = "override ";
31
- superToRdfCall = code `super.${syntheticNamePrefix}toRdfResource(${superToRdfOptions})`;
32
- break;
33
- case "interface":
34
- superToRdfCall = code `${this.parentObjectTypes[0].staticModuleName}.${syntheticNamePrefix}toRdfResource(${this.thisVariable}, ${superToRdfOptions})`;
35
- break;
36
- }
37
- statements.push(code `const ${variables.resource} = ${superToRdfCall};`);
16
+ statements.push(code `const ${variables.resource} = ${this.parentObjectTypes[0].name}.${syntheticNamePrefix}toRdfResource(${this.thisVariable}, { ${variables.ignoreRdfType}: true, ${variables.graph}: options?.${variables.graph}, ${variables.resourceSet} });`);
38
17
  }
39
18
  else {
40
- statements.push(code `const ${variables.resource} = ${variables.resourceSet}.resource(${this.thisVariable}.${this.identifierProperty.name});`);
19
+ statements.push(code `const ${variables.resource} = ${variables.resourceSet}.resource(${this.thisVariable}.${syntheticNamePrefix}identifier());`);
41
20
  }
42
21
  if (this.toRdfTypes.length > 0) {
43
22
  statements.push(code `if (!options?.${variables.ignoreRdfType}) { ${joinCode(this.toRdfTypes.map((toRdfType) => code `${variables.resource}.add(${rdfjsTermExpression(rdf.type, { logger: this.logger })}, ${imports.dataFactory}.namedNode("${toRdfType.value}"), options?.${variables.graph});`), { on: " " })} }`);
@@ -48,13 +27,15 @@ export function NamedObjectType_toRdfResourceFunctionOrMethodDeclaration() {
48
27
  graph: code `options?.${variables.graph}`,
49
28
  resource: variables.resource,
50
29
  resourceSet: variables.resourceSet,
51
- value: code `${this.thisVariable}.${property.name}`,
30
+ value: property.accessExpression({
31
+ variables: { object: this.thisVariable },
32
+ }),
52
33
  },
53
34
  }));
54
35
  }
55
36
  statements.push(code `return ${variables.resource};`);
56
37
  return Maybe.of(code `\
57
- ${preamble}${syntheticNamePrefix}toRdfResource(${joinCode(parameters, { on: "," })}): ${this.toRdfjsResourceType} {
38
+ export function ${syntheticNamePrefix}toRdfResource(${this.thisVariable}: ${this.name}, options?: Parameters<${snippets.ToRdfResourceFunction}<${this.name}>>[1]): ${this.toRdfjsResourceType} {
58
39
  ${joinCode(statements)}
59
40
  }`);
60
41
  }
@@ -64,4 +45,4 @@ const variables = {
64
45
  resource: code `resource`,
65
46
  resourceSet: code `resourceSet`,
66
47
  };
67
- //# sourceMappingURL=NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js.map
48
+ //# sourceMappingURL=NamedObjectType_toRdfResourceFunctionDeclaration.js.map
@@ -0,0 +1,4 @@
1
+ import type { NamedObjectType } from "../NamedObjectType.js";
2
+ import { type Code } from "../ts-poet-wrapper.js";
3
+ export declare function NamedObjectType_toStringFunctionDeclarations(this: NamedObjectType): readonly Code[];
4
+ //# sourceMappingURL=NamedObjectType_toStringFunctionDeclarations.d.ts.map
@@ -0,0 +1,40 @@
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_toStringFunctionDeclarations() {
5
+ const propertiesToStringRecordProperties = [];
6
+ if (this.parentObjectTypes.length > 0) {
7
+ for (const parentObjectType of this.parentObjectTypes) {
8
+ propertiesToStringRecordProperties.push(code `...${parentObjectType.name}.${syntheticNamePrefix}propertiesToStrings(${this.thisVariable})`);
9
+ }
10
+ }
11
+ for (const property of this.properties) {
12
+ property
13
+ .toStringExpression({
14
+ variables: {
15
+ value: property.accessExpression({
16
+ variables: { object: this.thisVariable },
17
+ }),
18
+ },
19
+ })
20
+ .ifJust((propertyToStringExpression) => {
21
+ propertiesToStringRecordProperties.push(code `${literalOf(property.name)}: ${propertyToStringExpression}`);
22
+ });
23
+ }
24
+ const propertiesToStringsReturnExpression = code `${snippets.compactRecord}({${joinCode(propertiesToStringRecordProperties, { on: "," })}})`;
25
+ const toStringReturnExpression = (propertiesToStrings) => code `\`${this.name}(\${JSON.stringify(${propertiesToStrings})})\``;
26
+ return [
27
+ // Use overloads to allow the function to be attached to an instance or used freestanding
28
+ code `\
29
+ export function ${syntheticNamePrefix}propertiesToStrings(${this.thisVariable}: ${this.name}): Record<string, string> {
30
+ return ${propertiesToStringsReturnExpression};
31
+ }`,
32
+ code `\
33
+ export function ${syntheticNamePrefix}toString(this: ${this.name}): string;
34
+ export function ${syntheticNamePrefix}toString(${this.thisVariable}: ${this.name}): string;
35
+ export function ${syntheticNamePrefix}toString(this: ${this.name} | undefined, ${this.thisVariable}?: ${this.name}): string {
36
+ return ${toStringReturnExpression(code `${syntheticNamePrefix}propertiesToStrings((${this.thisVariable} ?? this)!)`)};
37
+ }`,
38
+ ];
39
+ }
40
+ //# sourceMappingURL=NamedObjectType_toStringFunctionDeclarations.js.map
@@ -8,6 +8,6 @@ export function NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration()
8
8
  }
9
9
  return Maybe.of(code `\
10
10
  export const ${syntheticNamePrefix}valueSparqlConstructTriples: ${snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ({ filter, ignoreRdfType, valueVariable, variablePrefix }) =>
11
- ${this.staticModuleName}.${syntheticNamePrefix}focusSparqlConstructTriples({ filter, focusIdentifier: valueVariable, ignoreRdfType, variablePrefix });`);
11
+ ${this.name}.${syntheticNamePrefix}focusSparqlConstructTriples({ filter, focusIdentifier: valueVariable, ignoreRdfType, variablePrefix });`);
12
12
  }
13
13
  //# sourceMappingURL=NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js.map
@@ -9,7 +9,7 @@ export function NamedObjectType_valueSparqlWherePatternsFunctionDeclaration() {
9
9
  return Maybe.of(code `\
10
10
  export const ${syntheticNamePrefix}valueSparqlWherePatterns: ${snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ({ filter, ignoreRdfType, preferredLanguages, propertyPatterns, valueVariable, variablePrefix }) =>
11
11
  (propertyPatterns as readonly ${snippets.SparqlPattern}[]).concat(
12
- ${this.staticModuleName}.${syntheticNamePrefix}focusSparqlWherePatterns({ filter, focusIdentifier: valueVariable, ignoreRdfType, preferredLanguages, variablePrefix })
12
+ ${this.name}.${syntheticNamePrefix}focusSparqlWherePatterns({ filter, focusIdentifier: valueVariable, ignoreRdfType, preferredLanguages, variablePrefix })
13
13
  );`);
14
14
  }
15
15
  //# sourceMappingURL=NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js.map
@@ -1,7 +1,6 @@
1
1
  import type { Type } from "../Type.js";
2
2
  import type { DiscriminantProperty } from "./DiscriminantProperty.js";
3
- import type { IdentifierPrefixProperty } from "./IdentifierPrefixProperty.js";
4
3
  import type { IdentifierProperty } from "./IdentifierProperty.js";
5
4
  import type { ShaclProperty } from "./ShaclProperty.js";
6
- export type Property = IdentifierProperty | IdentifierPrefixProperty | ShaclProperty<Type> | DiscriminantProperty;
5
+ export type Property = IdentifierProperty | ShaclProperty<Type> | DiscriminantProperty;
7
6
  //# sourceMappingURL=Property.d.ts.map
@@ -22,13 +22,11 @@ export declare class ShaclProperty<TypeT extends Type> extends AbstractProperty<
22
22
  recursive: boolean;
23
23
  } & ConstructorParameters<typeof AbstractProperty<TypeT>>[0]);
24
24
  get constructorParametersSignature(): Maybe<Code>;
25
- get declaration(): Maybe<Code>;
26
- get equalsFunction(): Maybe<Code>;
25
+ get declaration(): Code;
27
26
  get filterProperty(): Maybe<{
28
27
  name: string;
29
28
  type: Code;
30
29
  }>;
31
- get getAccessorDeclaration(): Maybe<Code>;
32
30
  get graphqlField(): AbstractProperty<TypeT>["graphqlField"];
33
31
  get jsonSchema(): AbstractProperty<TypeT>["jsonSchema"];
34
32
  get jsonSignature(): Maybe<Code>;