@shaclmate/compiler 4.0.40 → 4.0.42
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 +1 -8
- package/dist/ShapesGraphToAstTransformer.js +11 -126
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.d.ts +17 -0
- package/dist/_ShapesGraphToAstTransformer/{transformPropertyShapeToAstObjectTypeProperty.js → transformPropertyShapeToAstStructTypeField.js} +71 -48
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +29 -20
- package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.d.ts → transformShapeToAstStructType.d.ts} +3 -3
- package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.js → transformShapeToAstStructType.js} +35 -45
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +2 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
- package/dist/ast/AbstractCompoundType.d.ts +3 -2
- package/dist/ast/AbstractCompoundType.js +5 -5
- package/dist/ast/AbstractContainerType.d.ts +2 -2
- package/dist/ast/AbstractContainerType.js +4 -4
- package/dist/ast/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +10 -12
- package/dist/ast/{AbstractLazyObjectType.js → AbstractLazyType.js} +3 -3
- package/dist/ast/AbstractType.d.ts +1 -1
- package/dist/ast/AbstractType.js +3 -0
- package/dist/ast/Ast.d.ts +2 -6
- package/dist/ast/DefaultValueType.js +2 -1
- package/dist/ast/IntersectionType.d.ts +2 -2
- package/dist/ast/IntersectionType.js +3 -3
- package/dist/ast/LazyOptionType.d.ts +6 -0
- package/dist/ast/LazyOptionType.js +5 -0
- package/dist/ast/LazySetType.d.ts +6 -0
- package/dist/ast/LazySetType.js +5 -0
- package/dist/ast/LazyType.d.ts +5 -0
- package/dist/ast/LazyType.js +5 -0
- package/dist/ast/ListType.d.ts +2 -2
- package/dist/ast/ListType.js +5 -5
- package/dist/ast/OptionType.js +2 -1
- package/dist/ast/SetType.js +2 -1
- package/dist/ast/StructCompoundType.d.ts +12 -0
- package/dist/ast/{ObjectCompoundType.js → StructCompoundType.js} +18 -18
- package/dist/ast/StructIntersectionType.d.ts +4 -0
- package/dist/ast/StructIntersectionType.js +2 -0
- package/dist/ast/{ObjectType.d.ts → StructType.d.ts} +28 -39
- package/dist/ast/{ObjectType.js → StructType.js} +81 -156
- package/dist/ast/StructUnionType.d.ts +4 -0
- package/dist/ast/StructUnionType.js +2 -0
- package/dist/ast/Type.d.ts +5 -5
- package/dist/ast/Type.js +4 -4
- package/dist/ast/UnionType.d.ts +2 -2
- package/dist/ast/UnionType.js +3 -3
- package/dist/ast/index.d.ts +7 -7
- package/dist/ast/index.js +7 -7
- package/dist/generators/AstJsonGenerator.js +7 -3
- package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
- package/dist/generators/ts/AbstractCollectionType.d.ts +4 -11
- package/dist/generators/ts/AbstractCollectionType.js +3 -62
- package/dist/generators/ts/AbstractContainerType.d.ts +1 -2
- package/dist/generators/ts/AbstractContainerType.js +7 -10
- package/dist/generators/ts/AbstractDateType.d.ts +5 -8
- package/dist/generators/ts/AbstractDateType.js +7 -12
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
- package/dist/generators/ts/AbstractIdentifierType.js +3 -0
- package/dist/generators/ts/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +8 -8
- package/dist/generators/ts/{AbstractLazyObjectType.js → AbstractLazyType.js} +30 -17
- package/dist/generators/ts/AbstractLiteralType.d.ts +3 -5
- package/dist/generators/ts/AbstractLiteralType.js +0 -21
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -7
- package/dist/generators/ts/AbstractNumericType.js +17 -27
- package/dist/generators/ts/AbstractObjectSetType.d.ts +1 -1
- package/dist/generators/ts/AbstractObjectSetType.js +2 -2
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -1
- package/dist/generators/ts/AbstractPrimitiveType.js +1 -1
- package/dist/generators/ts/AbstractTermType.d.ts +7 -23
- package/dist/generators/ts/AbstractTermType.js +27 -58
- package/dist/generators/ts/AbstractType.d.ts +86 -63
- package/dist/generators/ts/AbstractType.js +48 -22
- package/dist/generators/ts/BigDecimalType.d.ts +7 -3
- package/dist/generators/ts/BigDecimalType.js +7 -9
- package/dist/generators/ts/BigIntType.d.ts +5 -3
- package/dist/generators/ts/BigIntType.js +8 -5
- package/dist/generators/ts/BlankNodeType.d.ts +2 -7
- package/dist/generators/ts/BlankNodeType.js +4 -9
- package/dist/generators/ts/BooleanType.d.ts +6 -4
- package/dist/generators/ts/BooleanType.js +13 -15
- package/dist/generators/ts/DateTimeType.d.ts +2 -2
- package/dist/generators/ts/DateTimeType.js +14 -4
- package/dist/generators/ts/DateType.d.ts +2 -2
- package/dist/generators/ts/DateType.js +14 -4
- package/dist/generators/ts/DefaultValueType.d.ts +40 -2
- package/dist/generators/ts/DefaultValueType.js +15 -14
- package/dist/generators/ts/FloatType.d.ts +5 -3
- package/dist/generators/ts/FloatType.js +8 -5
- package/dist/generators/ts/GraphqlSchema.js +2 -2
- package/dist/generators/ts/IdentifierType.d.ts +2 -2
- package/dist/generators/ts/IdentifierType.js +8 -11
- package/dist/generators/ts/IntType.d.ts +5 -3
- package/dist/generators/ts/IntType.js +8 -5
- package/dist/generators/ts/IriType.d.ts +2 -2
- package/dist/generators/ts/IriType.js +16 -16
- package/dist/generators/ts/{LazyObjectOptionType.d.ts → LazyOptionType.d.ts} +13 -11
- package/dist/generators/ts/LazyOptionType.js +75 -0
- package/dist/generators/ts/LazySetType.d.ts +20 -0
- package/dist/generators/ts/LazySetType.js +76 -0
- package/dist/generators/ts/LazyType.d.ts +19 -0
- package/dist/generators/ts/LazyType.js +65 -0
- package/dist/generators/ts/ListType.d.ts +11 -2
- package/dist/generators/ts/ListType.js +53 -26
- package/dist/generators/ts/LiteralType.d.ts +7 -2
- package/dist/generators/ts/LiteralType.js +12 -5
- package/dist/generators/ts/ObjectType.d.ts +24 -25
- package/dist/generators/ts/ObjectType.js +303 -161
- package/dist/generators/ts/ObjectUnionType.js +42 -42
- package/dist/generators/ts/OptionType.d.ts +6 -2
- package/dist/generators/ts/OptionType.js +16 -9
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -4
- package/dist/generators/ts/SetType.d.ts +17 -2
- package/dist/generators/ts/SetType.js +85 -9
- package/dist/generators/ts/Snippets.d.ts +29 -9
- package/dist/generators/ts/Snippets.js +179 -39
- package/dist/generators/ts/StringType.d.ts +7 -4
- package/dist/generators/ts/StringType.js +23 -12
- package/dist/generators/ts/TermType.d.ts +9 -3
- package/dist/generators/ts/TermType.js +29 -7
- package/dist/generators/ts/TsGenerator.d.ts +1 -1
- package/dist/generators/ts/TsGenerator.js +62 -32
- package/dist/generators/ts/Type.d.ts +4 -4
- package/dist/generators/ts/TypeFactory.d.ts +5 -5
- package/dist/generators/ts/TypeFactory.js +90 -82
- package/dist/generators/ts/UnionType.d.ts +25 -23
- package/dist/generators/ts/UnionType.js +254 -261
- package/dist/generators/ts/ZodGenerator.d.ts +1 -1
- package/dist/generators/ts/ZodGenerator.js +29 -14
- package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +28 -16
- package/dist/generators/ts/_ObjectType/AbstractProperty.js +1 -24
- package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +15 -17
- package/dist/generators/ts/_ObjectType/DiscriminantProperty.js +24 -54
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +8 -2
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +48 -20
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.js +28 -0
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.js +15 -0
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_filterTypeDeclaration.js → ObjectType_filterTypeExpression.js} +5 -10
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_focusSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionExpression.js} +5 -13
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_focusSparqlWherePatternsFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → ObjectType_focusSparqlWherePatternsFunctionExpression.js} +8 -31
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.js +43 -0
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_graphqlTypeVariableStatement.js → ObjectType_graphqlTypeExpression.js} +6 -13
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +30 -0
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.js +13 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +11 -8
- package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +1 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.js +2 -6
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.js +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js +17 -0
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.js +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +5 -9
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +4 -8
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +14 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_toRdfResourceFunctionDeclaration.js → ObjectType_toRdfResourceFunctionExpression.js} +7 -13
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.js +7 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.js +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_valueSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionExpression.js +8 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_valueSparqlWherePatternsFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionExpression.js +10 -0
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +9 -2
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +70 -38
- package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +4 -3
- package/dist/generators/ts/_snippets/snippets_DateSchema.js +4 -3
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +6 -5
- package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +2 -1
- package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -0
- package/dist/generators/ts/_snippets/snippets_Lazy.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_Lazy.js +22 -0
- package/dist/generators/ts/_snippets/snippets_LazyOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_LazyOption.js +25 -0
- package/dist/generators/ts/_snippets/snippets_LazySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_LazySet.js +40 -0
- package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +1 -3
- package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -0
- package/dist/generators/ts/_snippets/snippets_NumericSchema.js +2 -1
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +6 -8
- package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +32 -32
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_StringSchema.js +5 -3
- package/dist/generators/ts/_snippets/snippets_TermFilter.js +3 -3
- package/dist/generators/ts/_snippets/snippets_TermSchema.js +4 -2
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazy.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazy.js +15 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyOption.js +33 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazySet.js +27 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
- package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.js +10 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_filterNumeric.js +1 -1
- package/dist/generators/ts/_snippets/snippets_filterTerm.js +1 -2
- package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.js +15 -0
- package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.js +11 -0
- package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.js +8 -0
- package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.js +8 -0
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.js +9 -0
- package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +13 -7
- package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +17 -0
- package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +60 -0
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
- package/dist/input/generated.d.ts +1116 -400
- package/dist/input/generated.js +1879 -1917
- package/package.json +2 -4
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +0 -9
- package/dist/ast/LazyObjectOptionType.d.ts +0 -6
- package/dist/ast/LazyObjectOptionType.js +0 -5
- package/dist/ast/LazyObjectSetType.d.ts +0 -6
- package/dist/ast/LazyObjectSetType.js +0 -5
- package/dist/ast/LazyObjectType.d.ts +0 -5
- package/dist/ast/LazyObjectType.js +0 -5
- package/dist/ast/ObjectCompoundType.d.ts +0 -12
- package/dist/ast/ObjectIntersectionType.d.ts +0 -4
- package/dist/ast/ObjectIntersectionType.js +0 -2
- package/dist/ast/ObjectUnionType.d.ts +0 -4
- package/dist/ast/ObjectUnionType.js +0 -2
- package/dist/generators/ts/LazyObjectOptionType.js +0 -62
- package/dist/generators/ts/LazyObjectSetType.d.ts +0 -20
- package/dist/generators/ts/LazyObjectSetType.js +0 -61
- package/dist/generators/ts/LazyObjectType.d.ts +0 -19
- package/dist/generators/ts/LazyObjectType.js +0 -53
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +0 -65
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.js +0 -23
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +0 -24
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +0 -43
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.js +0 -10
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +0 -45
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +0 -16
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -31
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +0 -16
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +0 -17
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +0 -14
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +0 -41
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.js +0 -36
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +0 -11
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +0 -13
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +0 -27
- package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_LazyObject.js +0 -22
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +0 -25
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +0 -40
- package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +0 -15
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +0 -31
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +0 -25
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +0 -15
- package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +0 -23
|
@@ -4,22 +4,15 @@ import { Either } from "purify-ts";
|
|
|
4
4
|
import type { Logger } from "ts-log";
|
|
5
5
|
import type * as ast from "./ast/index.js";
|
|
6
6
|
import type * as input from "./input/index.js";
|
|
7
|
-
interface RelatedNodeShapes {
|
|
8
|
-
readonly ancestors: input.NodeShape[];
|
|
9
|
-
readonly children: input.NodeShape[];
|
|
10
|
-
readonly parents: input.NodeShape[];
|
|
11
|
-
readonly descendants: input.NodeShape[];
|
|
12
|
-
}
|
|
13
7
|
export declare class ShapesGraphToAstTransformer {
|
|
14
8
|
protected readonly cachedAstTypesByShapeIdentifier: TermMap<BlankNode | NamedNode, ast.Type>;
|
|
9
|
+
protected readonly syntheticAstStructTypesByName: Map<string, ast.StructType>;
|
|
15
10
|
protected readonly logger: Logger;
|
|
16
11
|
protected readonly shapesGraph: input.ShapesGraph;
|
|
17
|
-
protected readonly relatedNodeShapesByIdentifier: TermMap<BlankNode | NamedNode, RelatedNodeShapes>;
|
|
18
12
|
constructor({ logger, shapesGraph, }: {
|
|
19
13
|
logger: Logger;
|
|
20
14
|
shapesGraph: input.ShapesGraph;
|
|
21
15
|
});
|
|
22
16
|
transform(): Either<Error, ast.Ast>;
|
|
23
17
|
}
|
|
24
|
-
export {};
|
|
25
18
|
//# sourceMappingURL=ShapesGraphToAstTransformer.d.ts.map
|
|
@@ -1,161 +1,46 @@
|
|
|
1
1
|
import TermMap from "@rdfjs/term-map";
|
|
2
|
-
import { dash } from "@tpluscode/rdf-ns-builders";
|
|
3
2
|
import { Either } from "purify-ts";
|
|
4
|
-
import { invariant } from "ts-invariant";
|
|
5
3
|
import { ShapeStack } from "./_ShapesGraphToAstTransformer/ShapeStack.js";
|
|
6
4
|
import { transformShapeToAstType } from "./_ShapesGraphToAstTransformer/transformShapeToAstType.js";
|
|
7
|
-
function relatedNodeShapes({ logger, shapesGraph, }) {
|
|
8
|
-
const immediateRelatedNodeShapes = new TermMap();
|
|
9
|
-
for (const childNodeShape of shapesGraph.nodeShapes) {
|
|
10
|
-
let childRelatedNodeShapes = immediateRelatedNodeShapes.get(childNodeShape.$identifier());
|
|
11
|
-
if (!childRelatedNodeShapes) {
|
|
12
|
-
childRelatedNodeShapes = {
|
|
13
|
-
children: new TermMap(),
|
|
14
|
-
parents: new TermMap(),
|
|
15
|
-
};
|
|
16
|
-
immediateRelatedNodeShapes.set(childNodeShape.$identifier(), childRelatedNodeShapes);
|
|
17
|
-
}
|
|
18
|
-
for (const parentClassIdentifier of childNodeShape.subClassOf) {
|
|
19
|
-
shapesGraph
|
|
20
|
-
.nodeShape(parentClassIdentifier)
|
|
21
|
-
.ifLeft((error) => {
|
|
22
|
-
logger.error("%s is rdfs:subClassOf %s which is either missing or not a node shape: %s", childNodeShape, parentClassIdentifier, error.message);
|
|
23
|
-
})
|
|
24
|
-
.ifRight((parentNodeShape) => {
|
|
25
|
-
childRelatedNodeShapes.parents.set(parentNodeShape.$identifier(), parentNodeShape);
|
|
26
|
-
let parentRelatedNodeShapes = immediateRelatedNodeShapes.get(parentNodeShape.$identifier());
|
|
27
|
-
if (!parentRelatedNodeShapes) {
|
|
28
|
-
parentRelatedNodeShapes = {
|
|
29
|
-
children: new TermMap(),
|
|
30
|
-
parents: new TermMap(),
|
|
31
|
-
};
|
|
32
|
-
immediateRelatedNodeShapes.set(parentNodeShape.$identifier(), parentRelatedNodeShapes);
|
|
33
|
-
}
|
|
34
|
-
parentRelatedNodeShapes.children.set(childNodeShape.$identifier(), childNodeShape);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const result = new TermMap();
|
|
39
|
-
for (const nodeShape of shapesGraph.nodeShapes) {
|
|
40
|
-
const { children: childNodeShapes, parents: parentNodeShapes } = immediateRelatedNodeShapes.get(nodeShape.$identifier());
|
|
41
|
-
const ancestorNodeShapes = new TermMap();
|
|
42
|
-
function recurseAncestorNodeShapes(nodeShape) {
|
|
43
|
-
for (const parentNodeShape of immediateRelatedNodeShapes
|
|
44
|
-
.get(nodeShape.$identifier())
|
|
45
|
-
.parents.values()) {
|
|
46
|
-
if (!ancestorNodeShapes.has(parentNodeShape.$identifier())) {
|
|
47
|
-
ancestorNodeShapes.set(parentNodeShape.$identifier(), parentNodeShape);
|
|
48
|
-
recurseAncestorNodeShapes(parentNodeShape);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
recurseAncestorNodeShapes(nodeShape);
|
|
53
|
-
const descendantNodeShapes = new TermMap();
|
|
54
|
-
function recurseDescendantNodeShapes(nodeShape) {
|
|
55
|
-
for (const childNodeShape of immediateRelatedNodeShapes
|
|
56
|
-
.get(nodeShape.$identifier())
|
|
57
|
-
.children.values()) {
|
|
58
|
-
if (!descendantNodeShapes.has(childNodeShape.$identifier())) {
|
|
59
|
-
descendantNodeShapes.set(childNodeShape.$identifier(), childNodeShape);
|
|
60
|
-
recurseDescendantNodeShapes(childNodeShape);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
recurseDescendantNodeShapes(nodeShape);
|
|
65
|
-
result.set(nodeShape.$identifier(), {
|
|
66
|
-
ancestors: [...ancestorNodeShapes.values()],
|
|
67
|
-
children: [...childNodeShapes.values()],
|
|
68
|
-
descendants: [...descendantNodeShapes.values()],
|
|
69
|
-
parents: [...parentNodeShapes.values()],
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
5
|
export class ShapesGraphToAstTransformer {
|
|
75
6
|
// Members are protected so they're accessible to functions in other files
|
|
76
7
|
cachedAstTypesByShapeIdentifier = new TermMap();
|
|
8
|
+
syntheticAstStructTypesByName = new Map();
|
|
77
9
|
logger;
|
|
78
10
|
shapesGraph;
|
|
79
|
-
relatedNodeShapesByIdentifier = new TermMap();
|
|
80
11
|
constructor({ logger, shapesGraph, }) {
|
|
81
12
|
this.logger = logger;
|
|
82
|
-
this.relatedNodeShapesByIdentifier = relatedNodeShapes({
|
|
83
|
-
logger: this.logger,
|
|
84
|
-
shapesGraph,
|
|
85
|
-
});
|
|
86
13
|
this.shapesGraph = shapesGraph;
|
|
87
14
|
}
|
|
88
15
|
transform() {
|
|
89
|
-
const
|
|
90
|
-
const astObjectTypes = [];
|
|
91
|
-
const syntheticAstObjectTypesByName = {};
|
|
92
|
-
const astNamedUnionTypes = [];
|
|
16
|
+
const astNamedTypes = [];
|
|
93
17
|
for (const nodeShape of this.shapesGraph.nodeShapes) {
|
|
94
18
|
if (nodeShape.$identifier().termType !== "NamedNode") {
|
|
95
19
|
continue;
|
|
96
20
|
}
|
|
97
|
-
if (nodeShape.$identifier().value.startsWith(dash[""].value)) {
|
|
98
|
-
continue;
|
|
99
|
-
}
|
|
100
21
|
const nodeShapeAstTypeEither = transformShapeToAstType.call(this, nodeShape, new ShapeStack());
|
|
101
22
|
if (nodeShapeAstTypeEither.isLeft()) {
|
|
102
23
|
return nodeShapeAstTypeEither;
|
|
103
24
|
}
|
|
104
25
|
const nodeShapeAstType = nodeShapeAstTypeEither.unsafeCoerce();
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
astNamedIntersectionTypes.push(nodeShapeAstType);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
case "Object": {
|
|
112
|
-
invariant(nodeShapeAstType.name.isJust(), `node shape missing name: ${nodeShapeAstType.shapeIdentifier}`);
|
|
113
|
-
astObjectTypes.push(nodeShapeAstType);
|
|
114
|
-
for (const property of nodeShapeAstType.properties) {
|
|
115
|
-
switch (property.type.kind) {
|
|
116
|
-
case "LazyObjectOption":
|
|
117
|
-
case "LazyObjectSet":
|
|
118
|
-
case "LazyObject": {
|
|
119
|
-
const partialItemType = property.type.partialType.kind === "Object" ||
|
|
120
|
-
property.type.partialType.kind === "Union"
|
|
121
|
-
? property.type.partialType
|
|
122
|
-
: property.type.partialType.itemType;
|
|
123
|
-
if (partialItemType.kind === "Object" &&
|
|
124
|
-
partialItemType.synthetic) {
|
|
125
|
-
const partialItemTypeName = partialItemType.name.unsafeCoerce();
|
|
126
|
-
if (!syntheticAstObjectTypesByName[partialItemTypeName]) {
|
|
127
|
-
syntheticAstObjectTypesByName[partialItemTypeName] =
|
|
128
|
-
partialItemType;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
case "Union":
|
|
137
|
-
if (nodeShapeAstType.name.isJust()) {
|
|
138
|
-
astNamedUnionTypes.push(nodeShapeAstType);
|
|
139
|
-
}
|
|
140
|
-
break;
|
|
141
|
-
default:
|
|
142
|
-
break;
|
|
143
|
-
}
|
|
26
|
+
nodeShapeAstType.name.ifJust(() => {
|
|
27
|
+
astNamedTypes.push(nodeShapeAstType);
|
|
28
|
+
});
|
|
144
29
|
}
|
|
145
30
|
return Either.of({
|
|
146
31
|
lazyTypesCount: [...this.cachedAstTypesByShapeIdentifier.values()].reduce((acc, astType) => {
|
|
147
32
|
switch (astType.kind) {
|
|
148
|
-
case "
|
|
149
|
-
case "
|
|
150
|
-
case "
|
|
33
|
+
case "Lazy":
|
|
34
|
+
case "LazyOption":
|
|
35
|
+
case "LazySet":
|
|
151
36
|
return acc + 1;
|
|
152
37
|
default:
|
|
153
38
|
return acc;
|
|
154
39
|
}
|
|
155
40
|
}, 0),
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
41
|
+
namedTypes: astNamedTypes.concat([
|
|
42
|
+
...this.syntheticAstStructTypesByName.values(),
|
|
43
|
+
]),
|
|
159
44
|
});
|
|
160
45
|
}
|
|
161
46
|
}
|
|
@@ -6,177 +6,145 @@ const defaultPropertyShapeNodeKinds = new Set([
|
|
|
6
6
|
"IRI",
|
|
7
7
|
"Literal",
|
|
8
8
|
]);
|
|
9
|
-
function
|
|
10
|
-
const
|
|
9
|
+
export function shapeNodeKinds(shape, options) {
|
|
10
|
+
const explicitNodeKinds = shape.nodeKind
|
|
11
11
|
.map(NodeKind.fromIri)
|
|
12
12
|
.orDefault(new Set());
|
|
13
|
-
//
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
// Consider constraints that dictate certain node kinds, like sh:datatype dictates a Literal nodeKind.
|
|
14
|
+
const constraintExcludeNodeKinds = new Set();
|
|
15
|
+
const constraintIncludeNodeKinds = new Set();
|
|
16
|
+
for (const [constraint, { excludeNodeKinds, includeNodeKinds }] of [
|
|
17
|
+
[
|
|
18
|
+
"sh:class",
|
|
19
|
+
shape.classes.length > 0
|
|
20
|
+
? { excludeNodeKinds: ["Literal"] }
|
|
21
|
+
: {},
|
|
22
|
+
],
|
|
23
|
+
[
|
|
24
|
+
"sh:datatype",
|
|
25
|
+
{
|
|
26
|
+
includeNodeKinds: shape.datatype
|
|
27
|
+
.map(() => ["Literal"])
|
|
28
|
+
.orDefault([]),
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
[
|
|
32
|
+
"sh:defaultValue",
|
|
33
|
+
{
|
|
34
|
+
includeNodeKinds: shape.$type === "PropertyShape"
|
|
35
|
+
? shape.defaultValue
|
|
36
|
+
.map((value) => NodeKind.fromTermType(value.termType))
|
|
37
|
+
.toList()
|
|
38
|
+
: [],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
[
|
|
42
|
+
"sh:hasValue",
|
|
43
|
+
{
|
|
44
|
+
includeNodeKinds: shape.hasValues.map((value) => NodeKind.fromTermType(value.termType)),
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
[
|
|
48
|
+
"sh:in",
|
|
49
|
+
{
|
|
50
|
+
includeNodeKinds: shape.in_
|
|
51
|
+
.orDefault([])
|
|
52
|
+
.map((in_) => NodeKind.fromTermType(in_.termType)),
|
|
53
|
+
},
|
|
54
|
+
],
|
|
55
|
+
[
|
|
56
|
+
"sh:languageIn",
|
|
57
|
+
shape.languageIn.orDefault([]).length > 0
|
|
58
|
+
? { includeNodeKinds: ["Literal"] }
|
|
59
|
+
: {},
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
"sh:maxExclusive",
|
|
63
|
+
{
|
|
64
|
+
includeNodeKinds: shape.maxExclusive
|
|
65
|
+
.map(() => ["Literal"])
|
|
66
|
+
.orDefault([]),
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
"sh:maxInclusive",
|
|
71
|
+
{
|
|
72
|
+
includeNodeKinds: shape.maxInclusive
|
|
73
|
+
.map(() => ["Literal"])
|
|
74
|
+
.orDefault([]),
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
[
|
|
78
|
+
"sh:minExclusive",
|
|
79
|
+
{
|
|
80
|
+
includeNodeKinds: shape.minExclusive
|
|
81
|
+
.map(() => ["Literal"])
|
|
82
|
+
.orDefault([]),
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
[
|
|
86
|
+
"sh:minInclusive",
|
|
87
|
+
{
|
|
88
|
+
includeNodeKinds: shape.minInclusive
|
|
89
|
+
.map(() => ["Literal"])
|
|
90
|
+
.orDefault([]),
|
|
91
|
+
},
|
|
92
|
+
],
|
|
93
|
+
]) {
|
|
94
|
+
for (const excludeNodeKind of excludeNodeKinds ?? []) {
|
|
95
|
+
if (explicitNodeKinds.size > 0 &&
|
|
96
|
+
explicitNodeKinds.has(excludeNodeKind)) {
|
|
97
|
+
return Left(new Error(`${shape} has ${constraint} that conflicts with sh:nodeKind`));
|
|
21
98
|
}
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
if (parentNodeKinds.size > 0) {
|
|
25
|
-
if (thisNodeKinds.size === 0) {
|
|
26
|
-
return Either.of(parentNodeKinds);
|
|
99
|
+
constraintExcludeNodeKinds.add(excludeNodeKind);
|
|
27
100
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return Left(new Error(`${
|
|
101
|
+
for (const includeNodeKind of includeNodeKinds ?? []) {
|
|
102
|
+
if (explicitNodeKinds.size > 0 &&
|
|
103
|
+
!explicitNodeKinds.has(includeNodeKind)) {
|
|
104
|
+
return Left(new Error(`${shape} has ${constraint} that conflicts with sh:nodeKind`));
|
|
32
105
|
}
|
|
106
|
+
constraintIncludeNodeKinds.add(includeNodeKind);
|
|
33
107
|
}
|
|
34
108
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
// Consider constraints that dictate certain node kinds, like sh:datatype dictates a Literal nodeKind.
|
|
45
|
-
const constraintExcludeNodeKinds = new Set();
|
|
46
|
-
const constraintIncludeNodeKinds = new Set();
|
|
47
|
-
for (const [constraint, { excludeNodeKinds, includeNodeKinds }] of [
|
|
48
|
-
[
|
|
49
|
-
"sh:class",
|
|
50
|
-
shape.classes.length > 0
|
|
51
|
-
? { excludeNodeKinds: ["Literal"] }
|
|
52
|
-
: {},
|
|
53
|
-
],
|
|
54
|
-
[
|
|
55
|
-
"sh:datatype",
|
|
56
|
-
{
|
|
57
|
-
includeNodeKinds: shape.datatype
|
|
58
|
-
.map(() => ["Literal"])
|
|
59
|
-
.orDefault([]),
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
[
|
|
63
|
-
"sh:defaultValue",
|
|
64
|
-
{
|
|
65
|
-
includeNodeKinds: shape.$type === "PropertyShape"
|
|
66
|
-
? shape.defaultValue
|
|
67
|
-
.map((value) => NodeKind.fromTermType(value.termType))
|
|
68
|
-
.toList()
|
|
69
|
-
: [],
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
[
|
|
73
|
-
"sh:hasValue",
|
|
74
|
-
{
|
|
75
|
-
includeNodeKinds: shape.hasValues.map((value) => NodeKind.fromTermType(value.termType)),
|
|
76
|
-
},
|
|
77
|
-
],
|
|
78
|
-
[
|
|
79
|
-
"sh:in",
|
|
80
|
-
{
|
|
81
|
-
includeNodeKinds: shape.in_
|
|
82
|
-
.orDefault([])
|
|
83
|
-
.map((in_) => NodeKind.fromTermType(in_.termType)),
|
|
84
|
-
},
|
|
85
|
-
],
|
|
86
|
-
[
|
|
87
|
-
"sh:languageIn",
|
|
88
|
-
shape.languageIn.orDefault([]).length > 0
|
|
89
|
-
? { includeNodeKinds: ["Literal"] }
|
|
90
|
-
: {},
|
|
91
|
-
],
|
|
92
|
-
[
|
|
93
|
-
"sh:maxExclusive",
|
|
94
|
-
{
|
|
95
|
-
includeNodeKinds: shape.maxExclusive
|
|
96
|
-
.map(() => ["Literal"])
|
|
97
|
-
.orDefault([]),
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
[
|
|
101
|
-
"sh:maxInclusive",
|
|
102
|
-
{
|
|
103
|
-
includeNodeKinds: shape.maxInclusive
|
|
104
|
-
.map(() => ["Literal"])
|
|
105
|
-
.orDefault([]),
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
[
|
|
109
|
-
"sh:minExclusive",
|
|
110
|
-
{
|
|
111
|
-
includeNodeKinds: shape.minExclusive
|
|
112
|
-
.map(() => ["Literal"])
|
|
113
|
-
.orDefault([]),
|
|
114
|
-
},
|
|
115
|
-
],
|
|
116
|
-
[
|
|
117
|
-
"sh:minInclusive",
|
|
118
|
-
{
|
|
119
|
-
includeNodeKinds: shape.minInclusive
|
|
120
|
-
.map(() => ["Literal"])
|
|
121
|
-
.orDefault([]),
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
]) {
|
|
125
|
-
for (const excludeNodeKind of excludeNodeKinds ?? []) {
|
|
126
|
-
if (explicitNodeKinds.size > 0 &&
|
|
127
|
-
explicitNodeKinds.has(excludeNodeKind)) {
|
|
128
|
-
return Left(new Error(`${shape} has ${constraint} that conflicts with sh:nodeKind`));
|
|
129
|
-
}
|
|
130
|
-
constraintExcludeNodeKinds.add(excludeNodeKind);
|
|
131
|
-
}
|
|
132
|
-
for (const includeNodeKind of includeNodeKinds ?? []) {
|
|
133
|
-
if (explicitNodeKinds.size > 0 &&
|
|
134
|
-
!explicitNodeKinds.has(includeNodeKind)) {
|
|
135
|
-
return Left(new Error(`${shape} has ${constraint} that conflicts with sh:nodeKind`));
|
|
136
|
-
}
|
|
137
|
-
constraintIncludeNodeKinds.add(includeNodeKind);
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
if (explicitNodeKinds.size > 0) {
|
|
141
|
-
return Either.of(explicitNodeKinds);
|
|
142
|
-
}
|
|
143
|
-
// There were no explicit sh:nodeKind, try to infer the shape's node kind from the node kinds excluded and included by constraints
|
|
144
|
-
const constraintNodeKinds = new Set();
|
|
145
|
-
if (constraintIncludeNodeKinds.size > 0) {
|
|
146
|
-
// If constraints dictated/included certain node kinds be included. Add those to the set.
|
|
147
|
-
for (const constraintIncludeNodeKind of constraintIncludeNodeKinds) {
|
|
148
|
-
constraintNodeKinds.add(constraintIncludeNodeKind);
|
|
149
|
-
}
|
|
150
|
-
// Check whether other constraints' excluded node kinds conflict.
|
|
151
|
-
if (constraintExcludeNodeKinds.size > 0) {
|
|
152
|
-
for (const constraintExcludeNodeKind of constraintExcludeNodeKinds) {
|
|
153
|
-
if (constraintIncludeNodeKinds.has(constraintExcludeNodeKind)) {
|
|
154
|
-
return Left(new Error(`${shape} has constraints with conflicting exclude/include node kinds`));
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
}
|
|
109
|
+
if (explicitNodeKinds.size > 0) {
|
|
110
|
+
return Either.of(explicitNodeKinds);
|
|
111
|
+
}
|
|
112
|
+
// There were no explicit sh:nodeKind, try to infer the shape's node kind from the node kinds excluded and included by constraints
|
|
113
|
+
const constraintNodeKinds = new Set();
|
|
114
|
+
if (constraintIncludeNodeKinds.size > 0) {
|
|
115
|
+
// If constraints dictated/included certain node kinds be included. Add those to the set.
|
|
116
|
+
for (const constraintIncludeNodeKind of constraintIncludeNodeKinds) {
|
|
117
|
+
constraintNodeKinds.add(constraintIncludeNodeKind);
|
|
158
118
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
// Start with all node kinds and exclude.
|
|
162
|
-
constraintNodeKinds.add("BlankNode");
|
|
163
|
-
constraintNodeKinds.add("IRI");
|
|
164
|
-
constraintNodeKinds.add("Literal");
|
|
119
|
+
// Check whether other constraints' excluded node kinds conflict.
|
|
120
|
+
if (constraintExcludeNodeKinds.size > 0) {
|
|
165
121
|
for (const constraintExcludeNodeKind of constraintExcludeNodeKinds) {
|
|
166
|
-
|
|
122
|
+
if (constraintIncludeNodeKinds.has(constraintExcludeNodeKind)) {
|
|
123
|
+
return Left(new Error(`${shape} has constraints with conflicting exclude/include node kinds`));
|
|
124
|
+
}
|
|
167
125
|
}
|
|
168
126
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
127
|
+
}
|
|
128
|
+
else if (constraintExcludeNodeKinds.size > 0) {
|
|
129
|
+
// No constraint dictated that certain node kinds be included, but some constraint dictated that certain node kinds be excluded.
|
|
130
|
+
// Start with all node kinds and exclude.
|
|
131
|
+
constraintNodeKinds.add("BlankNode");
|
|
132
|
+
constraintNodeKinds.add("IRI");
|
|
133
|
+
constraintNodeKinds.add("Literal");
|
|
134
|
+
for (const constraintExcludeNodeKind of constraintExcludeNodeKinds) {
|
|
135
|
+
constraintNodeKinds.delete(constraintExcludeNodeKind);
|
|
178
136
|
}
|
|
179
|
-
|
|
180
|
-
|
|
137
|
+
}
|
|
138
|
+
if (constraintNodeKinds.size > 0) {
|
|
139
|
+
return Either.of(constraintNodeKinds);
|
|
140
|
+
}
|
|
141
|
+
if (shape.$type === "NodeShape") {
|
|
142
|
+
return Either.of(options?.defaultNodeShapeNodeKinds ?? defaultNodeShapeNodeKinds);
|
|
143
|
+
}
|
|
144
|
+
if (shape.path.termType === "InversePath") {
|
|
145
|
+
// Inverse paths can only have blank nodes and IRIs as values, because the value is the subject of a triple.
|
|
146
|
+
return Either.of(new Set(["BlankNode", "IRI"]));
|
|
147
|
+
}
|
|
148
|
+
return Either.of(defaultPropertyShapeNodeKinds);
|
|
181
149
|
}
|
|
182
150
|
//# sourceMappingURL=shapeNodeKinds.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Either, Maybe } 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
|
+
/**
|
|
6
|
+
* Try to transform a property shape to an ast.StructType.Field.
|
|
7
|
+
*
|
|
8
|
+
* Returns:
|
|
9
|
+
* - Right<Just<ast.StructType.Field>> if the transformation succeeds
|
|
10
|
+
* - Right<Nothing> if the property shape should be ignored
|
|
11
|
+
* - Left<Error> if the transformation fails
|
|
12
|
+
*/
|
|
13
|
+
export declare function transformPropertyShapeToAstStructTypeField(this: ShapesGraphToAstTransformer, { propertyShape, structType, }: {
|
|
14
|
+
propertyShape: input.PropertyShape;
|
|
15
|
+
structType: ast.StructType;
|
|
16
|
+
}): Either<Error, Maybe<ast.StructType.Field>>;
|
|
17
|
+
//# sourceMappingURL=transformPropertyShapeToAstStructTypeField.d.ts.map
|