@shaclmate/compiler 4.0.7 → 4.0.9
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/Compiler.d.ts +1 -4
- package/dist/Compiler.js +1 -5
- package/dist/ShapesGraphToAstTransformer.d.ts +2 -11
- package/dist/ShapesGraphToAstTransformer.js +25 -27
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.d.ts +3 -0
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.js +5 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.d.ts +4 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +27 -0
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +74 -19
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +45 -91
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +11 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +146 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +7 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +182 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +9 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +3 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +33 -10
- package/dist/ast/AbstractCompoundType.d.ts +26 -8
- package/dist/ast/AbstractCompoundType.js +84 -16
- package/dist/ast/AbstractContainerType.d.ts +2 -4
- package/dist/ast/AbstractContainerType.js +3 -4
- package/dist/ast/AbstractLazyObjectType.d.ts +1 -0
- package/dist/ast/AbstractLazyObjectType.js +3 -0
- package/dist/ast/AbstractTermType.d.ts +1 -0
- package/dist/ast/AbstractTermType.js +1 -0
- package/dist/ast/AbstractType.d.ts +16 -1
- package/dist/ast/AbstractType.js +11 -1
- package/dist/ast/Ast.d.ts +4 -4
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/DefaultValueType.d.ts +1 -2
- package/dist/ast/DefaultValueType.js +2 -0
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/IntersectionType.d.ts +7 -2
- package/dist/ast/IntersectionType.js +8 -0
- package/dist/ast/ListType.d.ts +2 -9
- package/dist/ast/ListType.js +1 -9
- package/dist/ast/LiteralType.d.ts +1 -0
- package/dist/ast/LiteralType.js +26 -0
- package/dist/ast/ObjectCompoundType.d.ts +12 -0
- package/dist/ast/ObjectCompoundType.js +88 -0
- package/dist/ast/ObjectIntersectionType.d.ts +3 -7
- package/dist/ast/ObjectIntersectionType.js +1 -7
- package/dist/ast/ObjectType.d.ts +14 -31
- package/dist/ast/ObjectType.js +41 -73
- package/dist/ast/ObjectUnionType.d.ts +3 -7
- package/dist/ast/ObjectUnionType.js +1 -7
- package/dist/ast/OptionType.d.ts +1 -2
- package/dist/ast/OptionType.js +2 -0
- package/dist/ast/SetType.d.ts +1 -2
- package/dist/ast/SetType.js +2 -0
- package/dist/ast/Type.d.ts +1 -4
- package/dist/ast/Type.js +0 -6
- package/dist/ast/UnionType.d.ts +11 -6
- package/dist/ast/UnionType.js +6 -4
- package/dist/ast/index.d.ts +1 -2
- package/dist/ast/index.js +1 -2
- package/dist/generators/json/AstJsonGenerator.js +16 -14
- package/dist/generators/ts/AbstractCollectionType.js +8 -10
- package/dist/generators/ts/AbstractContainerType.d.ts +8 -3
- package/dist/generators/ts/AbstractContainerType.js +9 -2
- package/dist/generators/ts/AbstractDateType.d.ts +2 -2
- package/dist/generators/ts/AbstractDateType.js +2 -2
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractIdentifierType.js +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +11 -8
- package/dist/generators/ts/AbstractLazyObjectType.js +19 -14
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +33 -0
- package/dist/generators/ts/AbstractNamedUnionType.js +193 -0
- package/dist/generators/ts/AbstractNumericType.d.ts +2 -2
- package/dist/generators/ts/AbstractNumericType.js +3 -3
- package/dist/generators/ts/AbstractTermType.d.ts +7 -4
- package/dist/generators/ts/AbstractTermType.js +7 -4
- package/dist/generators/ts/AbstractType.d.ts +29 -14
- package/dist/generators/ts/AbstractUnionType.d.ts +80 -0
- package/dist/generators/ts/AbstractUnionType.js +514 -0
- package/dist/generators/ts/AnonymousUnionType.d.ts +26 -0
- package/dist/generators/ts/AnonymousUnionType.js +56 -0
- package/dist/generators/ts/BigDecimalType.d.ts +3 -3
- package/dist/generators/ts/BigDecimalType.js +3 -3
- package/dist/generators/ts/BlankNodeType.d.ts +1 -1
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.d.ts +2 -2
- package/dist/generators/ts/BooleanType.js +2 -2
- package/dist/generators/ts/DefaultValueType.d.ts +4 -4
- package/dist/generators/ts/DefaultValueType.js +14 -13
- package/dist/generators/ts/IdentifierType.d.ts +1 -1
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +1 -1
- package/dist/generators/ts/IriType.js +1 -1
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +9 -9
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +7 -7
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +7 -8
- package/dist/generators/ts/ListType.d.ts +8 -7
- package/dist/generators/ts/ListType.js +14 -13
- package/dist/generators/ts/LiteralType.d.ts +1 -1
- package/dist/generators/ts/LiteralType.js +2 -2
- package/dist/generators/ts/NamedObjectUnionType.d.ts +35 -0
- package/dist/generators/ts/NamedObjectUnionType.js +221 -0
- package/dist/generators/ts/NamedUnionType.d.ts +11 -0
- package/dist/generators/ts/NamedUnionType.js +13 -0
- package/dist/generators/ts/ObjectType.d.ts +34 -25
- package/dist/generators/ts/ObjectType.js +62 -52
- package/dist/generators/ts/OptionType.d.ts +4 -4
- package/dist/generators/ts/OptionType.js +10 -10
- package/dist/generators/ts/SetType.d.ts +4 -4
- package/dist/generators/ts/SetType.js +13 -11
- package/dist/generators/ts/StringType.d.ts +2 -2
- package/dist/generators/ts/StringType.js +2 -2
- package/dist/generators/ts/TermType.d.ts +1 -1
- package/dist/generators/ts/TermType.js +2 -2
- package/dist/generators/ts/TsGenerator.js +23 -15
- package/dist/generators/ts/Type.d.ts +4 -3
- package/dist/generators/ts/TypeFactory.d.ts +7 -5
- package/dist/generators/ts/TypeFactory.js +117 -90
- package/dist/generators/ts/ZodGenerator.js +6 -6
- package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +3 -3
- package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.d.ts → DiscriminantProperty.d.ts} +14 -14
- package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.js → DiscriminantProperty.js} +10 -10
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +2 -2
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +7 -4
- package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.js +8 -8
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_sparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +6 -5
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_sparqlWherePatternsFunctionDeclarations.js → ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_fromRdfFunctionDeclaration.js → ObjectType_fromRdfResourceFunctionDeclaration.js} +6 -7
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.js +38 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_propertiesFromRdfFunctionDeclaration.js → ObjectType_propertiesFromRdfResourceFunctionDeclaration.js} +16 -15
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +1 -2
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_toRdfFunctionOrMethodDeclaration.js → ObjectType_toRdfResourceFunctionOrMethodDeclaration.js} +10 -8
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +13 -0
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +15 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +6 -6
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.js +12 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.js +14 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +17 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.d.ts +5 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +35 -0
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.js +7 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.js +13 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_booleanEquals.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +2 -3
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +4 -3
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +4 -3
- package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +3 -2
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +4 -4
- package/dist/generators/ts/imports.d.ts +1 -1
- package/dist/generators/ts/imports.js +1 -1
- package/dist/generators/ts/objectSetDeclarations.d.ts +3 -3
- package/dist/generators/ts/objectSetDeclarations.js +15 -15
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +3 -3
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +2 -2
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +16 -17
- package/dist/generators/ts/snippets.d.ts +10 -6
- package/dist/generators/ts/snippets.js +20 -12
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +7 -8
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +2 -2
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +9 -4
- package/dist/input/NodeShape.d.ts +5 -6
- package/dist/input/NodeShape.js +19 -22
- package/dist/input/Ontology.d.ts +4 -4
- package/dist/input/Ontology.js +10 -10
- package/dist/input/PropertyShape.d.ts +4 -4
- package/dist/input/PropertyShape.js +10 -10
- package/dist/input/ShapesGraph.d.ts +3 -2
- package/dist/input/ShapesGraph.js +13 -8
- package/dist/input/generated.d.ts +2551 -2040
- package/dist/input/generated.js +2806 -2346
- package/package.json +3 -5
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.js +0 -45
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +0 -3
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.js +0 -2
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/index.js +0 -6
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.d.ts +0 -5
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.js +0 -9
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +0 -11
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +0 -338
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.js +0 -31
- package/dist/ast/AbstractObjectCompoundType.d.ts +0 -45
- package/dist/ast/AbstractObjectCompoundType.js +0 -180
- package/dist/ast/Curie.d.ts +0 -21
- package/dist/ast/Curie.js +0 -29
- package/dist/ast/PlaceholderType.d.ts +0 -15
- package/dist/ast/PlaceholderType.js +0 -19
- package/dist/generators/codeName.d.ts +0 -6
- package/dist/generators/codeName.js +0 -66
- package/dist/generators/ts/AbstractDeclaredType.d.ts +0 -23
- package/dist/generators/ts/AbstractDeclaredType.js +0 -17
- package/dist/generators/ts/ObjectUnionType.d.ts +0 -65
- package/dist/generators/ts/ObjectUnionType.js +0 -257
- package/dist/generators/ts/UnionType.d.ts +0 -40
- package/dist/generators/ts/UnionType.js +0 -527
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.js +0 -66
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/MemberType.d.ts +0 -34
- package/dist/generators/ts/_ObjectUnionType/MemberType.js +0 -105
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.js +0 -29
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js +0 -20
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.js +0 -18
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.js +0 -28
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.js +0 -9
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.js +0 -13
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.js +0 -37
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js +0 -35
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js +0 -26
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.js +0 -43
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.js +0 -5
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.js +0 -5
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.js +0 -12
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.js +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@shaclmate/shacl-ast": "4.0.
|
|
3
|
+
"@shaclmate/shacl-ast": "4.0.9",
|
|
4
4
|
"@rdfjs/data-model": "~2.1.1",
|
|
5
5
|
"@rdfjs/dataset": "~2.0.2",
|
|
6
6
|
"@rdfjs/prefix-map": "~0.1.2",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"pino": "~9.1.0",
|
|
20
20
|
"plur": "~5.1.0",
|
|
21
21
|
"purify-ts": "~2.1.4",
|
|
22
|
-
"rdfjs-resource": "3.0.
|
|
22
|
+
"rdfjs-resource": "3.0.7",
|
|
23
23
|
"reserved-identifiers": "~1.0.0",
|
|
24
24
|
"toposort": "2.0.2",
|
|
25
25
|
"ts-invariant": "~0.10.3",
|
|
@@ -53,8 +53,6 @@
|
|
|
53
53
|
"dist/generators/ts/*.js",
|
|
54
54
|
"dist/generators/ts/_ObjectType/*.d.ts",
|
|
55
55
|
"dist/generators/ts/_ObjectType/*.js",
|
|
56
|
-
"dist/generators/ts/_ObjectUnionType/*.d.ts",
|
|
57
|
-
"dist/generators/ts/_ObjectUnionType/*.js",
|
|
58
56
|
"dist/generators/ts/_snippets/*.d.ts",
|
|
59
57
|
"dist/generators/ts/_snippets/*.js",
|
|
60
58
|
"dist/input/*.d.ts",
|
|
@@ -80,5 +78,5 @@
|
|
|
80
78
|
},
|
|
81
79
|
"type": "module",
|
|
82
80
|
"types": "./dist/index.d.ts",
|
|
83
|
-
"version": "4.0.
|
|
81
|
+
"version": "4.0.9"
|
|
84
82
|
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type PrefixMap from "@rdfjs/prefix-map/PrefixMap.js";
|
|
2
|
-
import type { NamedNode } from "@rdfjs/types";
|
|
3
|
-
import { Maybe } from "purify-ts";
|
|
4
|
-
import { Curie } from "../ast/Curie.js";
|
|
5
|
-
/**
|
|
6
|
-
* Factory for Compact URIs (CURIEs). Tracks whether the reference part of the CURIE is unique.
|
|
7
|
-
*/
|
|
8
|
-
export declare class CurieFactory {
|
|
9
|
-
private readonly prefixMap;
|
|
10
|
-
private readonly referenceCounts;
|
|
11
|
-
constructor({ prefixMap }: {
|
|
12
|
-
prefixMap: PrefixMap;
|
|
13
|
-
});
|
|
14
|
-
create(namedNode: NamedNode): Maybe<Curie>;
|
|
15
|
-
}
|
|
16
|
-
//# sourceMappingURL=CurieFactory.d.ts.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { Maybe } from "purify-ts";
|
|
2
|
-
import { invariant } from "ts-invariant";
|
|
3
|
-
import { Curie } from "../ast/Curie.js";
|
|
4
|
-
import { logger } from "../logger.js";
|
|
5
|
-
/**
|
|
6
|
-
* Factory for Compact URIs (CURIEs). Tracks whether the reference part of the CURIE is unique.
|
|
7
|
-
*/
|
|
8
|
-
export class CurieFactory {
|
|
9
|
-
prefixMap;
|
|
10
|
-
referenceCounts = {};
|
|
11
|
-
constructor({ prefixMap }) {
|
|
12
|
-
this.prefixMap = prefixMap;
|
|
13
|
-
}
|
|
14
|
-
create(namedNode) {
|
|
15
|
-
return Maybe.fromNullable(this.prefixMap.shrink(namedNode)?.value).map((value) => {
|
|
16
|
-
const split = value.split(":", 2);
|
|
17
|
-
invariant(split.length === 2);
|
|
18
|
-
const prefix = split[0];
|
|
19
|
-
const reference = split[1];
|
|
20
|
-
if (this.referenceCounts[reference] === undefined) {
|
|
21
|
-
this.referenceCounts[reference] = {};
|
|
22
|
-
}
|
|
23
|
-
if (this.referenceCounts[reference][prefix] === undefined) {
|
|
24
|
-
this.referenceCounts[reference][prefix] = 1;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
this.referenceCounts[reference][prefix] += 1;
|
|
28
|
-
}
|
|
29
|
-
return new Curie({
|
|
30
|
-
hasUniqueReference: () => {
|
|
31
|
-
const referenceCounts = this.referenceCounts[reference];
|
|
32
|
-
if (Object.entries(referenceCounts).length === 1) {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
logger.debug(`duplicate local part ${reference} in ${JSON.stringify(referenceCounts)}`);
|
|
36
|
-
return false;
|
|
37
|
-
},
|
|
38
|
-
prefix: split[0],
|
|
39
|
-
reference: split[1],
|
|
40
|
-
value: namedNode.value,
|
|
41
|
-
});
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=CurieFactory.js.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from "./NodeShapeAstType.js";
|
|
2
|
-
export * from "./shapeIdentifier.js";
|
|
3
|
-
export * from "./transformNodeShapeToAstType.js";
|
|
4
|
-
export * from "./transformPropertyShapeToAstObjectTypeProperty.js";
|
|
5
|
-
export * from "./transformShapeToAstType.js";
|
|
6
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export * from "./NodeShapeAstType.js";
|
|
2
|
-
export * from "./shapeIdentifier.js";
|
|
3
|
-
export * from "./transformNodeShapeToAstType.js";
|
|
4
|
-
export * from "./transformPropertyShapeToAstObjectTypeProperty.js";
|
|
5
|
-
export * from "./transformShapeToAstType.js";
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
2
|
-
import type * as input from "../input/index.js";
|
|
3
|
-
import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
|
|
4
|
-
export declare function shapeIdentifier(this: ShapesGraphToAstTransformer, shape: input.Shape): BlankNode | NamedNode;
|
|
5
|
-
//# sourceMappingURL=shapeIdentifier.d.ts.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export function shapeIdentifier(shape) {
|
|
2
|
-
switch (shape.identifier.termType) {
|
|
3
|
-
case "BlankNode":
|
|
4
|
-
return shape.identifier;
|
|
5
|
-
case "NamedNode":
|
|
6
|
-
return (this.curieFactory.create(shape.identifier).extract() ?? shape.identifier);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=shapeIdentifier.js.map
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { Either } from "purify-ts";
|
|
2
|
-
import * as ast from "../ast/index.js";
|
|
3
|
-
import type * as input from "../input/index.js";
|
|
4
|
-
import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
|
|
5
|
-
import type { NodeShapeAstType } from "./NodeShapeAstType.js";
|
|
6
|
-
export declare function transformNodeShapeToAstObjectCompoundType(this: ShapesGraphToAstTransformer, { export_, nodeShape, }: {
|
|
7
|
-
export_: boolean;
|
|
8
|
-
nodeShape: input.NodeShape;
|
|
9
|
-
}): Either<Error, ast.ObjectIntersectionType | ast.ObjectUnionType>;
|
|
10
|
-
export declare function transformNodeShapeToAstType(this: ShapesGraphToAstTransformer, nodeShape: input.NodeShape): Either<Error, NodeShapeAstType>;
|
|
11
|
-
//# sourceMappingURL=transformNodeShapeToAstType.d.ts.map
|
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import dataFactory from "@rdfjs/data-model";
|
|
2
|
-
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
3
|
-
import { Either, Left, Maybe } from "purify-ts";
|
|
4
|
-
import { invariant } from "ts-invariant";
|
|
5
|
-
import * as ast from "../ast/index.js";
|
|
6
|
-
import { Eithers } from "../Eithers.js";
|
|
7
|
-
import { nodeShapeIdentifierMintingStrategy } from "./nodeShapeIdentifierMintingStrategy.js";
|
|
8
|
-
import { nodeShapeTsFeatures } from "./nodeShapeTsFeatures.js";
|
|
9
|
-
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
10
|
-
const defaultNodeShapeNodeKinds = new Set([
|
|
11
|
-
"BlankNode",
|
|
12
|
-
"IRI",
|
|
13
|
-
]);
|
|
14
|
-
function isObjectTypePropertyRequired(property) {
|
|
15
|
-
switch (property.type.kind) {
|
|
16
|
-
case "DefaultValueType":
|
|
17
|
-
return false;
|
|
18
|
-
case "LazyObjectOptionType":
|
|
19
|
-
return false;
|
|
20
|
-
case "LazyObjectSetType":
|
|
21
|
-
return property.type.partialType.minCount > 0;
|
|
22
|
-
case "OptionType":
|
|
23
|
-
return false;
|
|
24
|
-
case "SetType":
|
|
25
|
-
return property.type.minCount > 0;
|
|
26
|
-
case "UnionType":
|
|
27
|
-
return property.type.memberTypes.every((memberType) => isObjectTypePropertyRequired({ type: memberType }));
|
|
28
|
-
case "BlankNodeType":
|
|
29
|
-
case "IdentifierType":
|
|
30
|
-
case "IriType":
|
|
31
|
-
case "LazyObjectType":
|
|
32
|
-
case "ListType":
|
|
33
|
-
case "LiteralType":
|
|
34
|
-
case "ObjectType":
|
|
35
|
-
case "ObjectUnionType":
|
|
36
|
-
case "PlaceholderType":
|
|
37
|
-
case "TermType":
|
|
38
|
-
return true;
|
|
39
|
-
case "IntersectionType":
|
|
40
|
-
case "ObjectIntersectionType":
|
|
41
|
-
throw new Error("unsupported");
|
|
42
|
-
default:
|
|
43
|
-
property.type;
|
|
44
|
-
throw new Error("should never reach this point");
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
const listPropertiesObjectType = new ast.ObjectType({
|
|
48
|
-
abstract: false,
|
|
49
|
-
export_: false,
|
|
50
|
-
extern: false,
|
|
51
|
-
comment: Maybe.empty(),
|
|
52
|
-
label: Maybe.empty(),
|
|
53
|
-
identifierMintingStrategy: Maybe.empty(),
|
|
54
|
-
identifierType: new ast.IdentifierType({
|
|
55
|
-
comment: Maybe.empty(),
|
|
56
|
-
label: Maybe.empty(),
|
|
57
|
-
}),
|
|
58
|
-
fromRdfType: Maybe.empty(),
|
|
59
|
-
name: Maybe.empty(),
|
|
60
|
-
toRdfTypes: [],
|
|
61
|
-
tsFeatures: new Set([]),
|
|
62
|
-
tsObjectDeclarationType: "class",
|
|
63
|
-
shapeIdentifier: dataFactory.blankNode(),
|
|
64
|
-
synthetic: true,
|
|
65
|
-
tsImports: [],
|
|
66
|
-
});
|
|
67
|
-
/**
|
|
68
|
-
* Is an ast.ObjectType actually the shape of an RDF list?
|
|
69
|
-
* If so, return the type of its rdf:first.
|
|
70
|
-
*/
|
|
71
|
-
function transformNodeShapeToAstListType(nodeShape) {
|
|
72
|
-
invariant(nodeShape.isList);
|
|
73
|
-
return Eithers.chain3(nodeShapeIdentifierMintingStrategy(nodeShape), shapeNodeKinds(nodeShape, { defaultNodeShapeNodeKinds }), nodeShape.constraints.xone).chain(([identifierMintingStrategy, nodeKinds, xone]) => {
|
|
74
|
-
// Put a placeholder in the cache to deal with cyclic references
|
|
75
|
-
// Remove the placeholder if the transformation fails.
|
|
76
|
-
const listType = new ast.ListType({
|
|
77
|
-
comment: nodeShape.comment,
|
|
78
|
-
identifierNodeKind: nodeKinds.has("BlankNode") ? "BlankNode" : "IRI",
|
|
79
|
-
itemType: ast.PlaceholderType.instance,
|
|
80
|
-
label: nodeShape.label,
|
|
81
|
-
mutable: nodeShape.mutable.orDefault(false),
|
|
82
|
-
identifierMintingStrategy,
|
|
83
|
-
shapeIdentifier: this.shapeIdentifier(nodeShape),
|
|
84
|
-
toRdfTypes: nodeShape.toRdfTypes,
|
|
85
|
-
});
|
|
86
|
-
this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, listType);
|
|
87
|
-
return (() => {
|
|
88
|
-
let emptyListShape;
|
|
89
|
-
let nonEmptyListShape;
|
|
90
|
-
for (const shape of xone) {
|
|
91
|
-
if (shape.constraints.hasValues.length === 1 &&
|
|
92
|
-
shape.constraints.hasValues[0].equals(rdf.nil)) {
|
|
93
|
-
emptyListShape = shape;
|
|
94
|
-
}
|
|
95
|
-
else if (shape.kind === "NodeShape" &&
|
|
96
|
-
shape.constraints.properties.orDefault([]).length >= 2) {
|
|
97
|
-
nonEmptyListShape = shape;
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
if (!emptyListShape || !nonEmptyListShape) {
|
|
101
|
-
return Left(new Error(`${nodeShape} does not have an sh:xone with exactly two shapes, one for the empty list and one for the non-empty list`));
|
|
102
|
-
}
|
|
103
|
-
return nonEmptyListShape.constraints.properties.chain((nonEmptyListShapeProperties) => {
|
|
104
|
-
let firstPropertyShape;
|
|
105
|
-
let restPropertyShape;
|
|
106
|
-
for (const propertyShape of nonEmptyListShapeProperties) {
|
|
107
|
-
if (propertyShape.path.termType !== "NamedNode") {
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
if (propertyShape.path.equals(rdf.first)) {
|
|
111
|
-
firstPropertyShape = propertyShape;
|
|
112
|
-
}
|
|
113
|
-
else if (propertyShape.path.equals(rdf.rest)) {
|
|
114
|
-
restPropertyShape = propertyShape;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
if (!firstPropertyShape) {
|
|
118
|
-
return Left(new Error(`${nodeShape} has a non-empty list shape without an sh:property shape whose sh:path is rdf:first`));
|
|
119
|
-
}
|
|
120
|
-
if (firstPropertyShape.constraints.maxCount.extract() !== 1 ||
|
|
121
|
-
firstPropertyShape.constraints.minCount.extract() !== 1) {
|
|
122
|
-
return Left(new Error(`${nodeShape} non-empty list shape rdf:first property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
|
|
123
|
-
}
|
|
124
|
-
if (!restPropertyShape) {
|
|
125
|
-
return Left(new Error(`${nodeShape} has a non-empty list shape without an sh:property shape whose sh:path is rdf:rest`));
|
|
126
|
-
}
|
|
127
|
-
if (restPropertyShape.constraints.maxCount.extract() !== 1 ||
|
|
128
|
-
restPropertyShape.constraints.minCount.extract() !== 1) {
|
|
129
|
-
return Left(new Error(`${nodeShape} non-empty list shape rdf:rest property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
|
|
130
|
-
}
|
|
131
|
-
return this.transformPropertyShapeToAstObjectTypeProperty({
|
|
132
|
-
// Just need a dummy ast.ObjectType here to get the properties transformed.
|
|
133
|
-
objectType: listPropertiesObjectType,
|
|
134
|
-
propertyShape: firstPropertyShape,
|
|
135
|
-
}).chain((firstProperty) => {
|
|
136
|
-
if (!ast.ListType.isItemType(firstProperty.type)) {
|
|
137
|
-
return Left(new Error(`${nodeShape}: ${firstProperty.type.kind} is not a valid list item type`));
|
|
138
|
-
}
|
|
139
|
-
listType.itemType = firstProperty.type;
|
|
140
|
-
return this.transformPropertyShapeToAstObjectTypeProperty({
|
|
141
|
-
// Just need a dummy ast.ObjectType here to get the properties transformed.
|
|
142
|
-
objectType: listPropertiesObjectType,
|
|
143
|
-
propertyShape: restPropertyShape,
|
|
144
|
-
}).chain((restProperty) => {
|
|
145
|
-
if (restProperty.type.kind !== "ListType" ||
|
|
146
|
-
!restProperty.type.shapeIdentifier.equals(nodeShape.identifier)) {
|
|
147
|
-
return Left(new Error(`${nodeShape} rdf:rest property is not recursive into the node shape`));
|
|
148
|
-
}
|
|
149
|
-
return Either.of(listType);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
})().ifLeft(() => {
|
|
154
|
-
this.nodeShapeAstTypesByIdentifier.delete(nodeShape.identifier);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
export function transformNodeShapeToAstObjectCompoundType({ export_, nodeShape, }) {
|
|
159
|
-
return Eithers.chain3(nodeShape.constraints.and, nodeShapeTsFeatures.bind(this)(nodeShape), nodeShape.constraints.xone).chain(([andShapes, tsFeatures, xoneShapes]) => {
|
|
160
|
-
let compoundTypeShapes;
|
|
161
|
-
let compoundTypeKind;
|
|
162
|
-
if (andShapes.length > 0) {
|
|
163
|
-
compoundTypeShapes = andShapes;
|
|
164
|
-
compoundTypeKind = "ObjectIntersectionType";
|
|
165
|
-
}
|
|
166
|
-
else if (xoneShapes.length > 0) {
|
|
167
|
-
compoundTypeShapes = xoneShapes;
|
|
168
|
-
compoundTypeKind = "ObjectUnionType";
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
throw new Error("should never be reached");
|
|
172
|
-
}
|
|
173
|
-
const compoundTypeNodeShapes = [];
|
|
174
|
-
for (const compoundTypeShape of compoundTypeShapes) {
|
|
175
|
-
if (compoundTypeShape.kind !== "NodeShape") {
|
|
176
|
-
return Left(new Error(`${nodeShape} has non-NodeShape in its logical constraint`));
|
|
177
|
-
}
|
|
178
|
-
compoundTypeNodeShapes.push(compoundTypeShape);
|
|
179
|
-
}
|
|
180
|
-
if (compoundTypeNodeShapes.length === 0) {
|
|
181
|
-
return Left(new Error(`${nodeShape} has no NodeShapes in its logical constraint`));
|
|
182
|
-
}
|
|
183
|
-
// Put a placeholder in the cache to deal with cyclic references
|
|
184
|
-
const compoundType = new (compoundTypeKind === "ObjectIntersectionType"
|
|
185
|
-
? ast.ObjectIntersectionType
|
|
186
|
-
: ast.ObjectUnionType)({
|
|
187
|
-
comment: nodeShape.comment,
|
|
188
|
-
export_,
|
|
189
|
-
label: nodeShape.label,
|
|
190
|
-
name: nodeShape.shaclmateName,
|
|
191
|
-
shapeIdentifier: this.shapeIdentifier(nodeShape),
|
|
192
|
-
tsFeatures,
|
|
193
|
-
});
|
|
194
|
-
this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, compoundType);
|
|
195
|
-
return Either.sequence(compoundTypeNodeShapes.map((memberNodeShape) => this.transformNodeShapeToAstType(memberNodeShape).chain((memberType) => compoundType.addMemberType(memberType))))
|
|
196
|
-
.map(() => compoundType)
|
|
197
|
-
.ifLeft(() => {
|
|
198
|
-
this.nodeShapeAstTypesByIdentifier.delete(nodeShape.identifier);
|
|
199
|
-
});
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
export function transformNodeShapeToAstType(nodeShape) {
|
|
203
|
-
{
|
|
204
|
-
const type = this.nodeShapeAstTypesByIdentifier.get(nodeShape.identifier);
|
|
205
|
-
if (type) {
|
|
206
|
-
return Either.of(type);
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
if (nodeShape.isList) {
|
|
210
|
-
return transformNodeShapeToAstListType.bind(this)(nodeShape);
|
|
211
|
-
}
|
|
212
|
-
return Eithers.chain11(nodeShape.ancestorNodeShapes, nodeShape.childNodeShapes, nodeShape.descendantNodeShapes, nodeShape.parentNodeShapes, nodeShape.constraints.and, nodeShapeIdentifierMintingStrategy(nodeShape), shapeNodeKinds(nodeShape, { defaultNodeShapeNodeKinds }), nodeShape.constraints.properties, nodeShapeTsFeatures.bind(this)(nodeShape), nodeShape.tsObjectDeclarationType.isJust()
|
|
213
|
-
? Either.of(nodeShape.tsObjectDeclarationType)
|
|
214
|
-
: nodeShape.isDefinedBy.map((ontology) => ontology.chain((ontology) => ontology.tsObjectDeclarationType)), nodeShape.constraints.xone).chain(([ancestorNodeShapes, childNodeShapes, descendantNodeShapes, parentNodeShapes, andShapes, identifierMintingStrategy, nodeKinds, propertyShapes, tsFeatures, tsObjectDeclarationType, xoneShapes,]) => {
|
|
215
|
-
const abstract = nodeShape.abstract.orDefault(false);
|
|
216
|
-
const export_ = nodeShape.export.orDefault(true);
|
|
217
|
-
if (andShapes.length > 0 || xoneShapes.length > 0) {
|
|
218
|
-
return transformNodeShapeToAstObjectCompoundType.bind(this)({
|
|
219
|
-
export_,
|
|
220
|
-
nodeShape,
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
let fromRdfType;
|
|
224
|
-
let toRdfTypes;
|
|
225
|
-
if (!abstract) {
|
|
226
|
-
fromRdfType = nodeShape.fromRdfType.alt(nodeShape.rdfType);
|
|
227
|
-
if (nodeShape.isClass &&
|
|
228
|
-
nodeShape.identifier.termType === "NamedNode") {
|
|
229
|
-
fromRdfType = fromRdfType.alt(Maybe.of(nodeShape.identifier));
|
|
230
|
-
}
|
|
231
|
-
toRdfTypes = nodeShape.toRdfTypes.concat();
|
|
232
|
-
if (toRdfTypes.length === 0) {
|
|
233
|
-
toRdfTypes.push(...nodeShape.rdfType.toList());
|
|
234
|
-
}
|
|
235
|
-
// Ensure toRdfTypes has fromRdfType
|
|
236
|
-
fromRdfType.ifJust((fromRdfType) => {
|
|
237
|
-
if (!toRdfTypes.some((toRdfType) => toRdfType.equals(fromRdfType))) {
|
|
238
|
-
toRdfTypes.push(fromRdfType);
|
|
239
|
-
}
|
|
240
|
-
});
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
fromRdfType = Maybe.empty();
|
|
244
|
-
toRdfTypes = [];
|
|
245
|
-
}
|
|
246
|
-
if (nodeKinds.has("Literal")) {
|
|
247
|
-
return Left(new Error(`${nodeShape} should not have a nodeKind "Literal"`));
|
|
248
|
-
}
|
|
249
|
-
let identifierType;
|
|
250
|
-
if (nodeKinds.size === 2) {
|
|
251
|
-
invariant(nodeShape.identifierIn.length === 0);
|
|
252
|
-
identifierType = new ast.IdentifierType({
|
|
253
|
-
comment: Maybe.empty(),
|
|
254
|
-
label: Maybe.empty(),
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
else {
|
|
258
|
-
switch ([...nodeKinds][0]) {
|
|
259
|
-
case "BlankNode":
|
|
260
|
-
invariant(nodeShape.identifierIn.length === 0);
|
|
261
|
-
identifierType = new ast.BlankNodeType({
|
|
262
|
-
comment: Maybe.empty(),
|
|
263
|
-
label: Maybe.empty(),
|
|
264
|
-
});
|
|
265
|
-
break;
|
|
266
|
-
case "IRI":
|
|
267
|
-
identifierType = new ast.IriType({
|
|
268
|
-
comment: Maybe.empty(),
|
|
269
|
-
hasValues: [],
|
|
270
|
-
in_: nodeShape.identifierIn,
|
|
271
|
-
label: Maybe.empty(),
|
|
272
|
-
});
|
|
273
|
-
break;
|
|
274
|
-
case "Literal":
|
|
275
|
-
throw new Error("should never happen");
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
// Put a placeholder in the cache to deal with cyclic references
|
|
279
|
-
// Remove the placeholder if the transformation fails.
|
|
280
|
-
// If this node shape's properties (directly or indirectly) refer to the node shape itself,
|
|
281
|
-
// we'll return this placeholder.
|
|
282
|
-
const objectType = new ast.ObjectType({
|
|
283
|
-
abstract,
|
|
284
|
-
comment: nodeShape.comment,
|
|
285
|
-
export_: export_,
|
|
286
|
-
extern: nodeShape.extern.orDefault(false),
|
|
287
|
-
fromRdfType,
|
|
288
|
-
label: nodeShape.label,
|
|
289
|
-
identifierType,
|
|
290
|
-
identifierMintingStrategy,
|
|
291
|
-
name: nodeShape.shaclmateName,
|
|
292
|
-
shapeIdentifier: this.shapeIdentifier(nodeShape),
|
|
293
|
-
synthetic: false,
|
|
294
|
-
toRdfTypes,
|
|
295
|
-
tsFeatures,
|
|
296
|
-
tsImports: nodeShape.tsImports,
|
|
297
|
-
tsObjectDeclarationType: tsObjectDeclarationType.orDefault("class"),
|
|
298
|
-
});
|
|
299
|
-
this.nodeShapeAstTypesByIdentifier.set(nodeShape.identifier, objectType);
|
|
300
|
-
return (() => {
|
|
301
|
-
// Populate ancestor and descendant object types
|
|
302
|
-
const relatedObjectTypes = (relatedNodeShapes) => {
|
|
303
|
-
return relatedNodeShapes.flatMap((relatedNodeShape) => this.transformNodeShapeToAstType(relatedNodeShape)
|
|
304
|
-
.toMaybe()
|
|
305
|
-
.filter((astType) => astType.kind === "ObjectType")
|
|
306
|
-
.toList());
|
|
307
|
-
};
|
|
308
|
-
objectType.addAncestorObjectTypes(...relatedObjectTypes(ancestorNodeShapes));
|
|
309
|
-
objectType.addChildObjectTypes(...relatedObjectTypes(childNodeShapes));
|
|
310
|
-
objectType.addDescendantObjectTypes(...relatedObjectTypes(descendantNodeShapes));
|
|
311
|
-
objectType.addParentObjectTypes(...relatedObjectTypes(parentNodeShapes));
|
|
312
|
-
// Populate properties
|
|
313
|
-
for (const propertyShape of propertyShapes) {
|
|
314
|
-
const propertyEither = this.transformPropertyShapeToAstObjectTypeProperty({
|
|
315
|
-
objectType,
|
|
316
|
-
propertyShape,
|
|
317
|
-
});
|
|
318
|
-
if (propertyEither.isLeft()) {
|
|
319
|
-
return propertyEither;
|
|
320
|
-
}
|
|
321
|
-
propertyEither.ifRight((property) => {
|
|
322
|
-
objectType.addProperties(property);
|
|
323
|
-
});
|
|
324
|
-
}
|
|
325
|
-
if (!objectType.abstract &&
|
|
326
|
-
!objectType.extern &&
|
|
327
|
-
objectType.fromRdfType.isNothing() &&
|
|
328
|
-
!objectType.properties.some(isObjectTypePropertyRequired)) {
|
|
329
|
-
return Left(new Error(`${nodeShape} has no required properties and no implicitly required rdf:type`));
|
|
330
|
-
}
|
|
331
|
-
objectType.sortProperties();
|
|
332
|
-
return Either.of(objectType);
|
|
333
|
-
})().ifLeft(() => {
|
|
334
|
-
this.nodeShapeAstTypesByIdentifier.delete(nodeShape.identifier);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
}
|
|
338
|
-
//# sourceMappingURL=transformNodeShapeToAstType.js.map
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Either, Maybe } from "purify-ts";
|
|
2
|
-
import type * as input from "../input/index.js";
|
|
3
|
-
type AstAbstractTypeProperties = {
|
|
4
|
-
readonly comment: Maybe<string>;
|
|
5
|
-
readonly label: Maybe<string>;
|
|
6
|
-
};
|
|
7
|
-
declare namespace AstAbstractTypeProperties {
|
|
8
|
-
const empty: AstAbstractTypeProperties;
|
|
9
|
-
}
|
|
10
|
-
export declare function transformShapeToAstAbstractTypeProperties(shape: input.Shape): Either<Error, AstAbstractTypeProperties>;
|
|
11
|
-
export {};
|
|
12
|
-
//# sourceMappingURL=transformShapeToAstAbstractTypeProperties.d.ts.map
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { Either, Maybe } from "purify-ts";
|
|
2
|
-
var AstAbstractTypeProperties;
|
|
3
|
-
(function (AstAbstractTypeProperties) {
|
|
4
|
-
AstAbstractTypeProperties.empty = {
|
|
5
|
-
comment: Maybe.empty(),
|
|
6
|
-
label: Maybe.empty(),
|
|
7
|
-
};
|
|
8
|
-
})(AstAbstractTypeProperties || (AstAbstractTypeProperties = {}));
|
|
9
|
-
export function transformShapeToAstAbstractTypeProperties(shape) {
|
|
10
|
-
if (shape.kind === "PropertyShape") {
|
|
11
|
-
// comment, label, et al. belong to the ObjectType.Property, not to the type
|
|
12
|
-
return Either.of(AstAbstractTypeProperties.empty);
|
|
13
|
-
}
|
|
14
|
-
return shape.constraints.properties.chain((properties) => {
|
|
15
|
-
if (properties.length > 0) {
|
|
16
|
-
// comment, label, et al. belong to the ObjectType, not to the type
|
|
17
|
-
return Either.of(AstAbstractTypeProperties.empty);
|
|
18
|
-
}
|
|
19
|
-
return shape.constraints.xone.map((xone) => {
|
|
20
|
-
if (xone.length > 0) {
|
|
21
|
-
// comment, label, et al. belong to the ObjectType, not to the type
|
|
22
|
-
return AstAbstractTypeProperties.empty;
|
|
23
|
-
}
|
|
24
|
-
return {
|
|
25
|
-
comment: shape.comment,
|
|
26
|
-
label: shape.label,
|
|
27
|
-
};
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=transformShapeToAstAbstractTypeProperties.js.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
2
|
-
import { Either, Maybe } from "purify-ts";
|
|
3
|
-
import type { TsFeature } from "../enums/TsFeature.js";
|
|
4
|
-
import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
5
|
-
import { BlankNodeType } from "./BlankNodeType.js";
|
|
6
|
-
import { IdentifierType } from "./IdentifierType.js";
|
|
7
|
-
import { IriType } from "./IriType.js";
|
|
8
|
-
import type { ObjectIntersectionType } from "./ObjectIntersectionType.js";
|
|
9
|
-
import type { ObjectType } from "./ObjectType.js";
|
|
10
|
-
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
11
|
-
import type { Type } from "./Type.js";
|
|
12
|
-
/**
|
|
13
|
-
* Abstract base class for a compound of object types, such as an intersection or union.
|
|
14
|
-
*/
|
|
15
|
-
export declare abstract class AbstractObjectCompoundType<ObjectCompoundTypeT extends ObjectIntersectionType | ObjectUnionType> extends AbstractCompoundType<ObjectCompoundTypeT | ObjectType> {
|
|
16
|
-
#private;
|
|
17
|
-
/**
|
|
18
|
-
* Should generated code derived from this type be visible outside its module?
|
|
19
|
-
*
|
|
20
|
-
* Defaults to true.
|
|
21
|
-
*/
|
|
22
|
-
readonly export: boolean;
|
|
23
|
-
abstract readonly kind: "ObjectIntersectionType" | "ObjectUnionType";
|
|
24
|
-
/**
|
|
25
|
-
* Name of this type, from shaclmate:name.
|
|
26
|
-
*/
|
|
27
|
-
readonly name: Maybe<string>;
|
|
28
|
-
/**
|
|
29
|
-
* Identifier of the shape this ObjectType was derived from.
|
|
30
|
-
*/
|
|
31
|
-
readonly shapeIdentifier: BlankNode | NamedNode;
|
|
32
|
-
constructor({ export_, name, shapeIdentifier, tsFeatures, ...superParameters }: {
|
|
33
|
-
export_: boolean;
|
|
34
|
-
name: Maybe<string>;
|
|
35
|
-
shapeIdentifier: BlankNode | NamedNode;
|
|
36
|
-
tsFeatures: ReadonlySet<TsFeature>;
|
|
37
|
-
} & ConstructorParameters<typeof AbstractCompoundType<ObjectCompoundTypeT | ObjectType>>[0]);
|
|
38
|
-
equals(other: AbstractObjectCompoundType<ObjectCompoundTypeT>): boolean;
|
|
39
|
-
get identifierType(): BlankNodeType | IdentifierType | IriType;
|
|
40
|
-
get memberObjectTypes(): readonly ObjectType[];
|
|
41
|
-
get tsFeatures(): ReadonlySet<TsFeature>;
|
|
42
|
-
addMemberType(memberType: Type): Either<Error, void>;
|
|
43
|
-
toString(): string;
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=AbstractObjectCompoundType.d.ts.map
|