@shaclmate/compiler 2.0.22 → 2.0.24
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.
- package/dist/ShapesGraphToAstTransformer.d.ts +6 -5
- package/dist/ShapesGraphToAstTransformer.js +61 -17
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +2 -0
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +2 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +15 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +5 -5
- package/dist/_ShapesGraphToAstTransformer/index.js +5 -5
- package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +175 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +185 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +32 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +46 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +12 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +24 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +14 -0
- package/dist/ast/Ast.d.ts +0 -1
- package/dist/ast/Curie.d.ts +14 -0
- package/dist/ast/Curie.js +21 -0
- package/dist/ast/IdentifierType.d.ts +3 -2
- package/dist/ast/ListType.d.ts +2 -1
- package/dist/ast/LiteralType.d.ts +1 -1
- package/dist/ast/Name.d.ts +40 -5
- package/dist/ast/ObjectCompositeType.d.ts +11 -0
- package/dist/ast/ObjectType.d.ts +18 -13
- package/dist/ast/ObjectUnionType.d.ts +0 -11
- package/dist/ast/OptionType.d.ts +2 -4
- package/dist/ast/SetType.d.ts +2 -7
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +26 -4
- package/dist/generators/ts/BooleanType.d.ts +4 -2
- package/dist/generators/ts/BooleanType.js +12 -3
- package/dist/generators/ts/DateTimeType.d.ts +9 -8
- package/dist/generators/ts/DateTimeType.js +32 -8
- package/dist/generators/ts/DateType.d.ts +5 -2
- package/dist/generators/ts/DateType.js +15 -1
- package/dist/generators/ts/DeclaredType.d.ts +2 -2
- package/dist/generators/ts/DeclaredType.js +2 -2
- package/dist/generators/ts/FloatType.d.ts +6 -0
- package/dist/generators/ts/FloatType.js +18 -0
- package/dist/generators/ts/IdentifierType.d.ts +17 -7
- package/dist/generators/ts/IdentifierType.js +112 -18
- package/dist/generators/ts/Import.d.ts +2 -0
- package/dist/generators/ts/Import.js +10 -0
- package/dist/generators/ts/IntType.d.ts +6 -0
- package/dist/generators/ts/IntType.js +18 -0
- package/dist/generators/ts/ListType.d.ts +15 -12
- package/dist/generators/ts/ListType.js +113 -61
- package/dist/generators/ts/LiteralType.d.ts +17 -9
- package/dist/generators/ts/LiteralType.js +92 -17
- package/dist/generators/ts/NumberType.d.ts +3 -2
- package/dist/generators/ts/NumberType.js +8 -3
- package/dist/generators/ts/ObjectType.d.ts +65 -43
- package/dist/generators/ts/ObjectType.js +143 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +50 -8
- package/dist/generators/ts/ObjectUnionType.js +303 -101
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +62 -34
- package/dist/generators/ts/PrimitiveType.d.ts +23 -5
- package/dist/generators/ts/PrimitiveType.js +34 -6
- package/dist/generators/ts/SetType.d.ts +17 -13
- package/dist/generators/ts/SetType.js +76 -44
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +226 -101
- package/dist/generators/ts/StringType.d.ts +4 -2
- package/dist/generators/ts/StringType.js +20 -8
- package/dist/generators/ts/TermType.d.ts +29 -33
- package/dist/generators/ts/TermType.js +89 -68
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +26 -12
- package/dist/generators/ts/Type.d.ts +100 -32
- package/dist/generators/ts/Type.js +58 -54
- package/dist/generators/ts/TypeFactory.d.ts +12 -5
- package/dist/generators/ts/TypeFactory.js +380 -226
- package/dist/generators/ts/UnionType.d.ts +14 -10
- package/dist/generators/ts/UnionType.js +319 -142
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +31 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +59 -46
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +198 -140
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +100 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +315 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +47 -46
- package/dist/generators/ts/_ObjectType/Property.js +1 -10
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +120 -85
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
- package/dist/generators/ts/_ObjectType/classDeclaration.js +22 -17
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +26 -13
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +8 -5
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +49 -0
- package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
- package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
- package/dist/generators/ts/_ObjectType/index.js +9 -7
- package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +144 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +6 -5
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +109 -37
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +33 -24
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
- package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
- package/dist/generators/ts/objectSetDeclarations.js +59 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
- package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
- package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
- package/dist/generators/ts/rdfjsTermExpression.js +57 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
- package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
- package/dist/generators/ts/syntheticNamePrefix.js +2 -0
- package/dist/generators/ts/tsName.js +27 -13
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
- package/dist/input/NodeShape.d.ts +6 -8
- package/dist/input/NodeShape.js +20 -44
- package/dist/input/Ontology.d.ts +0 -3
- package/dist/input/Ontology.js +0 -9
- package/dist/input/PropertyPath.d.ts +5 -5
- package/dist/input/PropertyPath.js +14 -24
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -8
- package/dist/input/generated.d.ts +967 -107
- package/dist/input/generated.js +2548 -1046
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +0 -13
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +0 -200
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +0 -29
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +0 -43
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +0 -14
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +0 -21
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +0 -60
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
- package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { StructureKind } from "ts-morph";
|
|
2
|
-
const variables = {
|
|
3
|
-
jsonObject: "_jsonObject",
|
|
4
|
-
};
|
|
5
|
-
export function fromJsonFunctionDeclarations() {
|
|
6
|
-
if (!this.features.has("fromJson")) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
if (this.extern) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
const initializers = [];
|
|
13
|
-
const propertyReturnTypeSignatures = [];
|
|
14
|
-
const propertiesFromJsonFunctionReturnType = [];
|
|
15
|
-
const propertiesFromJsonFunctionStatements = [];
|
|
16
|
-
propertiesFromJsonFunctionStatements.push(`const _jsonSafeParseResult = ${this.jsonZodSchemaFunctionName}().safeParse(_json);`, "if (!_jsonSafeParseResult.success) { return purify.Left(_jsonSafeParseResult.error); }", `const ${variables.jsonObject} = _jsonSafeParseResult.data;`);
|
|
17
|
-
this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
|
|
18
|
-
propertiesFromJsonFunctionStatements.push(`const _super${parentObjectTypeI}Either = ${parentObjectType.name}._propertiesFromJson(${variables.jsonObject});`, `if (_super${parentObjectTypeI}Either.isLeft()) { return _super${parentObjectTypeI}Either; }`, `const _super${parentObjectTypeI} = _super${parentObjectTypeI}Either.unsafeCoerce()`);
|
|
19
|
-
initializers.push(`..._super${parentObjectTypeI}`);
|
|
20
|
-
propertiesFromJsonFunctionReturnType.push(`UnwrapR<ReturnType<typeof ${parentObjectType.name}._propertiesFromJson>>`);
|
|
21
|
-
});
|
|
22
|
-
for (const property of this.properties) {
|
|
23
|
-
const propertyFromJsonStatements = property.fromJsonStatements({
|
|
24
|
-
variables,
|
|
25
|
-
});
|
|
26
|
-
if (propertyFromJsonStatements.length > 0) {
|
|
27
|
-
propertiesFromJsonFunctionStatements.push(...propertyFromJsonStatements);
|
|
28
|
-
initializers.push(property.name);
|
|
29
|
-
propertyReturnTypeSignatures.push(`${property.name}: ${property.type.name};`);
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
propertiesFromJsonFunctionStatements.push(`return purify.Either.of({ ${initializers.join(", ")} })`);
|
|
33
|
-
if (propertyReturnTypeSignatures.length > 0) {
|
|
34
|
-
propertiesFromJsonFunctionReturnType.splice(0, 0, `{ ${propertyReturnTypeSignatures.join(" ")} }`);
|
|
35
|
-
}
|
|
36
|
-
const fromJsonFunctionDeclarations = [];
|
|
37
|
-
fromJsonFunctionDeclarations.push({
|
|
38
|
-
isExported: true,
|
|
39
|
-
kind: StructureKind.Function,
|
|
40
|
-
name: "_propertiesFromJson",
|
|
41
|
-
parameters: [
|
|
42
|
-
{
|
|
43
|
-
name: "_json",
|
|
44
|
-
type: "unknown",
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
returnType: `purify.Either<zod.ZodError, ${propertiesFromJsonFunctionReturnType.join(" & ")}>`,
|
|
48
|
-
statements: propertiesFromJsonFunctionStatements,
|
|
49
|
-
});
|
|
50
|
-
if (!this.abstract) {
|
|
51
|
-
let fromJsonStatements;
|
|
52
|
-
switch (this.declarationType) {
|
|
53
|
-
case "class":
|
|
54
|
-
fromJsonStatements = [
|
|
55
|
-
`return ${this.name}._propertiesFromJson(json).map(properties => new ${this.name}(properties));`,
|
|
56
|
-
];
|
|
57
|
-
break;
|
|
58
|
-
case "interface":
|
|
59
|
-
fromJsonStatements = [`return ${this.name}._propertiesFromJson(json);`];
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
fromJsonFunctionDeclarations.push({
|
|
63
|
-
isExported: true,
|
|
64
|
-
kind: StructureKind.Function,
|
|
65
|
-
name: "fromJson",
|
|
66
|
-
parameters: [
|
|
67
|
-
{
|
|
68
|
-
name: "json",
|
|
69
|
-
type: "unknown",
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
returnType: `purify.Either<zod.ZodError, ${this.name}>`,
|
|
73
|
-
statements: fromJsonStatements,
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return fromJsonFunctionDeclarations;
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=fromJsonFunctionDeclarations.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { type FunctionDeclarationStructure } from "ts-morph";
|
|
2
|
-
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
-
export declare function fromRdfFunctionDeclarations(this: ObjectType): readonly FunctionDeclarationStructure[];
|
|
4
|
-
//# sourceMappingURL=fromRdfFunctionDeclarations.d.ts.map
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
import { StructureKind } from "ts-morph";
|
|
2
|
-
import { objectInitializer } from "../objectInitializer.js";
|
|
3
|
-
const variables = {
|
|
4
|
-
context: "_context",
|
|
5
|
-
ignoreRdfType: "_ignoreRdfType",
|
|
6
|
-
languageIn: "_languageIn",
|
|
7
|
-
resource: "_resource",
|
|
8
|
-
};
|
|
9
|
-
export function fromRdfFunctionDeclarations() {
|
|
10
|
-
if (!this.features.has("fromRdf")) {
|
|
11
|
-
return [];
|
|
12
|
-
}
|
|
13
|
-
if (this.extern) {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
const initializers = [];
|
|
17
|
-
const propertySignatures = [];
|
|
18
|
-
const propertiesFromRdfFunctionReturnType = [];
|
|
19
|
-
const propertiesFromRdfFunctionStatements = [];
|
|
20
|
-
this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
|
|
21
|
-
propertiesFromRdfFunctionStatements.push(`const _super${parentObjectTypeI}Either = ${parentObjectType.name}._propertiesFromRdf({ ...${variables.context}, ignoreRdfType: true, languageIn: ${variables.languageIn}, resource: ${variables.resource} });`, `if (_super${parentObjectTypeI}Either.isLeft()) { return _super${parentObjectTypeI}Either; }`, `const _super${parentObjectTypeI} = _super${parentObjectTypeI}Either.unsafeCoerce()`);
|
|
22
|
-
initializers.push(`..._super${parentObjectTypeI}`);
|
|
23
|
-
propertiesFromRdfFunctionReturnType.push(`UnwrapR<ReturnType<typeof ${parentObjectType.name}._propertiesFromRdf>>`);
|
|
24
|
-
});
|
|
25
|
-
this.fromRdfType.ifJust((rdfType) => {
|
|
26
|
-
propertiesFromRdfFunctionStatements.push(`if (!${variables.ignoreRdfType} && !${variables.resource}.isInstanceOf(${this.rdfjsTermExpression(rdfType)})) { return purify.Left(new rdfjsResource.Resource.ValueError(${objectInitializer({ focusResource: variables.resource, message: `\`\${rdfjsResource.Resource.Identifier.toString(${variables.resource}.identifier)} has unexpected RDF type\``, predicate: this.rdfjsTermExpression(rdfType) })})); }`);
|
|
27
|
-
});
|
|
28
|
-
const propertyFromRdfVariables = {
|
|
29
|
-
context: variables.context,
|
|
30
|
-
languageIn: variables.languageIn,
|
|
31
|
-
resource: variables.resource,
|
|
32
|
-
};
|
|
33
|
-
for (const property of this.properties) {
|
|
34
|
-
const propertyFromRdfStatements = property.fromRdfStatements({
|
|
35
|
-
variables: propertyFromRdfVariables,
|
|
36
|
-
});
|
|
37
|
-
if (propertyFromRdfStatements.length > 0) {
|
|
38
|
-
propertiesFromRdfFunctionStatements.push(...propertyFromRdfStatements);
|
|
39
|
-
initializers.push(property.name);
|
|
40
|
-
propertySignatures.push(`${property.name}: ${property.type.name};`);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
propertiesFromRdfFunctionStatements.push(`return purify.Either.of({ ${initializers.join(", ")} })`);
|
|
44
|
-
if (propertySignatures.length > 0) {
|
|
45
|
-
propertiesFromRdfFunctionReturnType.splice(0, 0, `{ ${propertySignatures.join(" ")} }`);
|
|
46
|
-
}
|
|
47
|
-
const fromRdfFunctionDeclarations = [];
|
|
48
|
-
fromRdfFunctionDeclarations.push({
|
|
49
|
-
isExported: true,
|
|
50
|
-
kind: StructureKind.Function,
|
|
51
|
-
name: "_propertiesFromRdf",
|
|
52
|
-
parameters: [
|
|
53
|
-
{
|
|
54
|
-
name: `{ ignoreRdfType: ${variables.ignoreRdfType}, languageIn: ${variables.languageIn}, resource: ${variables.resource},\n// @ts-ignore\n...${variables.context} }`,
|
|
55
|
-
type: `{ [_index: string]: any; ignoreRdfType?: boolean; languageIn?: readonly string[]; resource: ${this.rdfjsResourceType().name}; }`,
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
returnType: `purify.Either<rdfjsResource.Resource.ValueError, ${propertiesFromRdfFunctionReturnType.join(" & ")}>`,
|
|
59
|
-
statements: propertiesFromRdfFunctionStatements,
|
|
60
|
-
});
|
|
61
|
-
if (!this.abstract) {
|
|
62
|
-
let fromRdfStatements;
|
|
63
|
-
switch (this.declarationType) {
|
|
64
|
-
case "class":
|
|
65
|
-
fromRdfStatements = [
|
|
66
|
-
`return ${this.name}._propertiesFromRdf(parameters).map(properties => new ${this.name}(properties));`,
|
|
67
|
-
];
|
|
68
|
-
break;
|
|
69
|
-
case "interface":
|
|
70
|
-
fromRdfStatements = [
|
|
71
|
-
`return ${this.name}._propertiesFromRdf(parameters);`,
|
|
72
|
-
];
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
fromRdfFunctionDeclarations.push({
|
|
76
|
-
isExported: true,
|
|
77
|
-
kind: StructureKind.Function,
|
|
78
|
-
name: "fromRdf",
|
|
79
|
-
parameters: [
|
|
80
|
-
{
|
|
81
|
-
name: "parameters",
|
|
82
|
-
type: `Parameters<typeof ${this.name}._propertiesFromRdf>[0]`,
|
|
83
|
-
},
|
|
84
|
-
],
|
|
85
|
-
returnType: `purify.Either<rdfjsResource.Resource.ValueError, ${this.name}>`,
|
|
86
|
-
statements: fromRdfStatements,
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return fromRdfFunctionDeclarations;
|
|
90
|
-
}
|
|
91
|
-
//# sourceMappingURL=fromRdfFunctionDeclarations.js.map
|
|
@@ -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 jsonSchemaFunctionDeclaration(this: ObjectType): Maybe<FunctionDeclarationStructure>;
|
|
5
|
-
//# sourceMappingURL=jsonSchemaFunctionDeclaration.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { StructureKind } from "ts-morph";
|
|
3
|
-
export function jsonSchemaFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("jsonSchema")) {
|
|
5
|
-
return Maybe.empty();
|
|
6
|
-
}
|
|
7
|
-
if (this.extern) {
|
|
8
|
-
return Maybe.empty();
|
|
9
|
-
}
|
|
10
|
-
return Maybe.of({
|
|
11
|
-
isExported: true,
|
|
12
|
-
kind: StructureKind.Function,
|
|
13
|
-
name: "jsonSchema",
|
|
14
|
-
statements: [
|
|
15
|
-
`return zodToJsonSchema(${this.jsonZodSchemaFunctionName}());`,
|
|
16
|
-
],
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=jsonSchemaFunctionDeclaration.js.map
|
|
@@ -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 jsonUiSchemaFunctionDeclaration(this: ObjectType): Maybe<FunctionDeclarationStructure>;
|
|
5
|
-
//# sourceMappingURL=jsonUiSchemaFunctionDeclaration.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { StructureKind } from "ts-morph";
|
|
3
|
-
export function jsonUiSchemaFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("jsonUiSchema")) {
|
|
5
|
-
return Maybe.empty();
|
|
6
|
-
}
|
|
7
|
-
if (this.extern) {
|
|
8
|
-
return Maybe.empty();
|
|
9
|
-
}
|
|
10
|
-
const variables = { scopePrefix: "scopePrefix" };
|
|
11
|
-
const elements = this.parentObjectTypes
|
|
12
|
-
.map((parentObjectType) => `${parentObjectType.name}.${parentObjectType.jsonUiSchemaFunctionName}({ scopePrefix })`)
|
|
13
|
-
.concat(this.ownProperties.flatMap((property) => property.jsonUiSchemaElement({ variables }).toList()));
|
|
14
|
-
return Maybe.of({
|
|
15
|
-
isExported: true,
|
|
16
|
-
kind: StructureKind.Function,
|
|
17
|
-
name: this.jsonUiSchemaFunctionName,
|
|
18
|
-
parameters: [
|
|
19
|
-
{
|
|
20
|
-
hasQuestionToken: true,
|
|
21
|
-
name: "parameters",
|
|
22
|
-
type: "{ scopePrefix?: string }",
|
|
23
|
-
},
|
|
24
|
-
],
|
|
25
|
-
statements: [
|
|
26
|
-
'const scopePrefix = parameters?.scopePrefix ?? "#";',
|
|
27
|
-
`return { "elements": [ ${elements.join(", ")} ], label: "${this.label.orDefault(this.name)}", type: "Group" }`,
|
|
28
|
-
],
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=jsonUiSchemaFunctionDeclaration.js.map
|
|
@@ -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 jsonZodSchemaFunctionDeclaration(this: ObjectType): Maybe<FunctionDeclarationStructure>;
|
|
5
|
-
//# sourceMappingURL=jsonZodSchemaFunctionDeclaration.d.ts.map
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { StructureKind } from "ts-morph";
|
|
3
|
-
export function jsonZodSchemaFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("fromJson") && !this.features.has("jsonSchema")) {
|
|
5
|
-
return Maybe.empty();
|
|
6
|
-
}
|
|
7
|
-
if (this.extern) {
|
|
8
|
-
return Maybe.empty();
|
|
9
|
-
}
|
|
10
|
-
const variables = { zod: "zod" };
|
|
11
|
-
const mergeZodObjectSchemas = [];
|
|
12
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
13
|
-
mergeZodObjectSchemas.push(`${parentObjectType.jsonZodSchema({ variables })}`);
|
|
14
|
-
}
|
|
15
|
-
if (this.properties.length > 0) {
|
|
16
|
-
mergeZodObjectSchemas.push(`${variables.zod}.object({ ${this.properties
|
|
17
|
-
.flatMap((property) => property.jsonZodSchema({ variables }).toList())
|
|
18
|
-
.map(({ key, schema }) => `"${key}": ${schema}`)
|
|
19
|
-
.join(",")} })`);
|
|
20
|
-
}
|
|
21
|
-
return Maybe.of({
|
|
22
|
-
isExported: true,
|
|
23
|
-
kind: StructureKind.Function,
|
|
24
|
-
name: this.jsonZodSchemaFunctionName,
|
|
25
|
-
statements: [
|
|
26
|
-
`return ${mergeZodObjectSchemas.length > 0
|
|
27
|
-
? mergeZodObjectSchemas.reduce((merged, zodObjectSchema) => {
|
|
28
|
-
if (merged.length === 0) {
|
|
29
|
-
return zodObjectSchema;
|
|
30
|
-
}
|
|
31
|
-
return `${merged}.merge(${zodObjectSchema})`;
|
|
32
|
-
}, "")
|
|
33
|
-
: `${variables.zod}.object()`};`,
|
|
34
|
-
],
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
//# sourceMappingURL=jsonZodSchemaFunctionDeclaration.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { BlankNode, Literal, NamedNode, Variable } from "@rdfjs/types";
|
|
2
|
-
export declare function rdfjsTermExpression({ dataFactoryVariable, rdfjsTerm, }: {
|
|
3
|
-
dataFactoryVariable: string;
|
|
4
|
-
rdfjsTerm: Omit<BlankNode, "equals"> | Omit<Literal, "equals"> | Omit<NamedNode, "equals"> | Omit<Variable, "equals">;
|
|
5
|
-
}): string;
|
|
6
|
-
//# sourceMappingURL=rdfjsTermExpression.d.ts.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { xsd } from "@tpluscode/rdf-ns-builders";
|
|
2
|
-
export function rdfjsTermExpression({ dataFactoryVariable, rdfjsTerm, }) {
|
|
3
|
-
switch (rdfjsTerm.termType) {
|
|
4
|
-
case "BlankNode":
|
|
5
|
-
return `${dataFactoryVariable}.blankNode("${rdfjsTerm.value}")`;
|
|
6
|
-
case "Literal":
|
|
7
|
-
if (rdfjsTerm.datatype.equals(xsd.string)) {
|
|
8
|
-
return `${dataFactoryVariable}.literal("${rdfjsTerm.value}", "${rdfjsTerm.language}")`;
|
|
9
|
-
}
|
|
10
|
-
return `${dataFactoryVariable}.literal("${rdfjsTerm.value}", ${dataFactoryVariable}.namedNode("${rdfjsTerm.datatype.value}"))`;
|
|
11
|
-
case "NamedNode":
|
|
12
|
-
return `${dataFactoryVariable}.namedNode("${rdfjsTerm.value}")`;
|
|
13
|
-
case "Variable":
|
|
14
|
-
return `${dataFactoryVariable}.variable!("${rdfjsTerm.value}")`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=rdfjsTermExpression.js.map
|
|
@@ -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 toJsonFunctionDeclaration(this: ObjectType): Maybe<FunctionDeclarationStructure>;
|
|
5
|
-
//# sourceMappingURL=toJsonFunctionDeclaration.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { StructureKind } from "ts-morph";
|
|
3
|
-
import { toJsonFunctionOrMethodDeclaration } from "./toJsonFunctionOrMethodDeclaration.js";
|
|
4
|
-
export function toJsonFunctionDeclaration() {
|
|
5
|
-
if (this.declarationType !== "interface") {
|
|
6
|
-
return Maybe.empty();
|
|
7
|
-
}
|
|
8
|
-
if (this.extern) {
|
|
9
|
-
return Maybe.empty();
|
|
10
|
-
}
|
|
11
|
-
return toJsonFunctionOrMethodDeclaration
|
|
12
|
-
.bind(this)()
|
|
13
|
-
.map((toJsonFunctionOrMethodDeclaration) => ({
|
|
14
|
-
...toJsonFunctionOrMethodDeclaration,
|
|
15
|
-
isExported: true,
|
|
16
|
-
kind: StructureKind.Function,
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=toJsonFunctionDeclaration.js.map
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export function toJsonReturnType() {
|
|
2
|
-
const typeMembers = [];
|
|
3
|
-
if (this.ownProperties.length > 0) {
|
|
4
|
-
typeMembers.push(`{ ${this.ownProperties
|
|
5
|
-
.flatMap((property) => property.jsonPropertySignature.toList())
|
|
6
|
-
.map((propertySignature) => `readonly "${propertySignature.name}": ${propertySignature.type}`)
|
|
7
|
-
.join("; ")} }`);
|
|
8
|
-
}
|
|
9
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
10
|
-
typeMembers.push(parentObjectType.jsonName);
|
|
11
|
-
}
|
|
12
|
-
if (typeMembers.length === 0) {
|
|
13
|
-
return "object";
|
|
14
|
-
}
|
|
15
|
-
return typeMembers.join(" & ");
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=toJsonReturnType.js.map
|
|
@@ -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 toRdfFunctionDeclaration(this: ObjectType): Maybe<FunctionDeclarationStructure>;
|
|
5
|
-
//# sourceMappingURL=toRdfFunctionDeclaration.d.ts.map
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { StructureKind } from "ts-morph";
|
|
3
|
-
import { toRdfFunctionOrMethodDeclaration } from "./toRdfFunctionOrMethodDeclaration.js";
|
|
4
|
-
export function toRdfFunctionDeclaration() {
|
|
5
|
-
if (this.declarationType !== "interface") {
|
|
6
|
-
return Maybe.empty();
|
|
7
|
-
}
|
|
8
|
-
if (this.extern) {
|
|
9
|
-
return Maybe.empty();
|
|
10
|
-
}
|
|
11
|
-
return toRdfFunctionOrMethodDeclaration
|
|
12
|
-
.bind(this)()
|
|
13
|
-
.map((toRdfFunctionOrMethodDeclaration) => ({
|
|
14
|
-
...toRdfFunctionOrMethodDeclaration,
|
|
15
|
-
isExported: true,
|
|
16
|
-
kind: StructureKind.Function,
|
|
17
|
-
}));
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=toRdfFunctionDeclaration.js.map
|