@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
|
@@ -1,37 +1,13 @@
|
|
|
1
1
|
import dataFactory from "@rdfx/data-factory";
|
|
2
2
|
import { Curie } from "@shaclmate/shacl-ast";
|
|
3
|
+
import { sh } from "@tpluscode/rdf-ns-builders";
|
|
3
4
|
import { Either, Left, Maybe } from "purify-ts";
|
|
4
5
|
import { invariant } from "ts-invariant";
|
|
5
6
|
import * as ast from "../ast/index.js";
|
|
6
7
|
import { Eithers } from "../Eithers.js";
|
|
7
8
|
import { ShapeStack } from "./ShapeStack.js";
|
|
8
9
|
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
9
|
-
function
|
|
10
|
-
let syntheticName;
|
|
11
|
-
switch (identifierType.kind) {
|
|
12
|
-
case "BlankNode":
|
|
13
|
-
throw new Error("should never happen");
|
|
14
|
-
case "Identifier":
|
|
15
|
-
syntheticName = "DefaultPartial";
|
|
16
|
-
break;
|
|
17
|
-
case "Iri":
|
|
18
|
-
syntheticName = "NamedDefaultPartial";
|
|
19
|
-
break;
|
|
20
|
-
}
|
|
21
|
-
return new ast.ObjectType({
|
|
22
|
-
comment: Maybe.empty(),
|
|
23
|
-
extern: false,
|
|
24
|
-
fromRdfType: Maybe.empty(),
|
|
25
|
-
identifierType,
|
|
26
|
-
label: Maybe.empty(),
|
|
27
|
-
name: Maybe.of(syntheticName),
|
|
28
|
-
shapeIdentifier: dataFactory.namedNode(`urn:shaclmate:synthetic:${syntheticName}`),
|
|
29
|
-
synthetic: true,
|
|
30
|
-
toRdfTypes: [],
|
|
31
|
-
tsImports: [],
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function propertyName(objectType, propertyShape) {
|
|
10
|
+
function fieldName(propertyShape, structType) {
|
|
35
11
|
// Explicit shaclmate:name or sh:name
|
|
36
12
|
const name = propertyShape.shaclmateName.alt(propertyShape.name).extract();
|
|
37
13
|
if (name) {
|
|
@@ -46,8 +22,8 @@ function propertyName(objectType, propertyShape) {
|
|
|
46
22
|
// like ex:NodeShape-property
|
|
47
23
|
const propertyShapeIdentifier = propertyShape.$identifier();
|
|
48
24
|
if (propertyShapeIdentifier.termType === "NamedNode" &&
|
|
49
|
-
|
|
50
|
-
const propertyShapeIdentifierPrefix = `${
|
|
25
|
+
structType.shapeIdentifier.termType === "NamedNode") {
|
|
26
|
+
const propertyShapeIdentifierPrefix = `${structType.shapeIdentifier.value}-`;
|
|
51
27
|
if (propertyShapeIdentifier.value.startsWith(propertyShapeIdentifierPrefix) &&
|
|
52
28
|
propertyShapeIdentifier.value.length >
|
|
53
29
|
propertyShapeIdentifierPrefix.length) {
|
|
@@ -72,6 +48,37 @@ function propertyName(objectType, propertyShape) {
|
|
|
72
48
|
}
|
|
73
49
|
throw new Error(`${propertyShape}: unable to infer name`);
|
|
74
50
|
}
|
|
51
|
+
function synthesizePartialAstStructType({ identifierType, }) {
|
|
52
|
+
let syntheticName;
|
|
53
|
+
switch (identifierType.kind) {
|
|
54
|
+
case "BlankNode":
|
|
55
|
+
throw new Error("should never happen");
|
|
56
|
+
case "Identifier":
|
|
57
|
+
syntheticName = "DefaultPartial";
|
|
58
|
+
break;
|
|
59
|
+
case "Iri":
|
|
60
|
+
syntheticName = "NamedDefaultPartial";
|
|
61
|
+
break;
|
|
62
|
+
}
|
|
63
|
+
let partialAstStructType = this.syntheticAstStructTypesByName.get(syntheticName);
|
|
64
|
+
if (partialAstStructType) {
|
|
65
|
+
return partialAstStructType;
|
|
66
|
+
}
|
|
67
|
+
partialAstStructType = new ast.StructType({
|
|
68
|
+
comment: Maybe.empty(),
|
|
69
|
+
extern: false,
|
|
70
|
+
fromRdfType: Maybe.empty(),
|
|
71
|
+
identifierType,
|
|
72
|
+
label: Maybe.empty(),
|
|
73
|
+
name: Maybe.of(syntheticName),
|
|
74
|
+
shapeIdentifier: dataFactory.namedNode(`urn:shaclmate:synthetic:${syntheticName}`),
|
|
75
|
+
synthetic: true,
|
|
76
|
+
toRdfTypes: [],
|
|
77
|
+
tsImports: [],
|
|
78
|
+
});
|
|
79
|
+
this.syntheticAstStructTypesByName.set(syntheticName, partialAstStructType);
|
|
80
|
+
return partialAstStructType;
|
|
81
|
+
}
|
|
75
82
|
function transformPropertyShapeToAstType(propertyShape, shapeStack) {
|
|
76
83
|
// if (
|
|
77
84
|
// propertyShape.path.kind === "PredicatePath" &&
|
|
@@ -122,7 +129,23 @@ function transformPropertyShapeToAstType(propertyShape, shapeStack) {
|
|
|
122
129
|
}));
|
|
123
130
|
});
|
|
124
131
|
}
|
|
125
|
-
|
|
132
|
+
/**
|
|
133
|
+
* Try to transform a property shape to an ast.StructType.Field.
|
|
134
|
+
*
|
|
135
|
+
* Returns:
|
|
136
|
+
* - Right<Just<ast.StructType.Field>> if the transformation succeeds
|
|
137
|
+
* - Right<Nothing> if the property shape should be ignored
|
|
138
|
+
* - Left<Error> if the transformation fails
|
|
139
|
+
*/
|
|
140
|
+
export function transformPropertyShapeToAstStructTypeField({ propertyShape, structType, }) {
|
|
141
|
+
if (propertyShape.ignore) {
|
|
142
|
+
return Either.of(Maybe.empty());
|
|
143
|
+
}
|
|
144
|
+
switch (propertyShape.severity.orDefault(sh.Violation).value) {
|
|
145
|
+
case "http://www.w3.org/ns/shacl#Info":
|
|
146
|
+
case "http://www.w3.org/ns/shacl#Warning":
|
|
147
|
+
return Either.of(Maybe.empty());
|
|
148
|
+
}
|
|
126
149
|
const shapeStack = new ShapeStack(); // Start a new ShapeStack per property shape
|
|
127
150
|
return Eithers.chain2(propertyShape.resolve.isJust()
|
|
128
151
|
? this.shapesGraph
|
|
@@ -135,14 +158,14 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
135
158
|
.call(this, propertyShapeResolve.unsafeCoerce(), shapeStack)
|
|
136
159
|
.chain((astResolveType) => {
|
|
137
160
|
switch (astResolveType.kind) {
|
|
138
|
-
case "
|
|
161
|
+
case "Struct":
|
|
139
162
|
return Either.of(astResolveType);
|
|
140
163
|
case "Union":
|
|
141
164
|
if (
|
|
142
165
|
// This check relies on .members being populated, which may not happen in cycles
|
|
143
166
|
astResolveType.members.length > 0 &&
|
|
144
|
-
!astResolveType.
|
|
145
|
-
return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind} with non-
|
|
167
|
+
!astResolveType.isStructUnionType()) {
|
|
168
|
+
return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind} with non-StructType members`));
|
|
146
169
|
}
|
|
147
170
|
return Either.of(astResolveType);
|
|
148
171
|
default:
|
|
@@ -162,10 +185,10 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
162
185
|
case "Set":
|
|
163
186
|
astItemType = astType.itemType;
|
|
164
187
|
break;
|
|
165
|
-
case "
|
|
166
|
-
case "
|
|
188
|
+
case "LazyOption":
|
|
189
|
+
case "LazySet":
|
|
167
190
|
// biome-ignore lint/suspicious/noFallthroughSwitchClause: break is unreachable
|
|
168
|
-
case "
|
|
191
|
+
case "Lazy":
|
|
169
192
|
invariant(false, `lazy types should not appear here: ${astType.kind}`);
|
|
170
193
|
default:
|
|
171
194
|
astItemType = astType;
|
|
@@ -176,16 +199,16 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
176
199
|
case "BlankNode":
|
|
177
200
|
case "Identifier":
|
|
178
201
|
case "Iri":
|
|
179
|
-
astPartialItemType =
|
|
202
|
+
astPartialItemType = synthesizePartialAstStructType.call(this, {
|
|
180
203
|
identifierType: astItemType,
|
|
181
204
|
});
|
|
182
205
|
break;
|
|
183
|
-
case "
|
|
206
|
+
case "Struct":
|
|
184
207
|
astPartialItemType = astItemType;
|
|
185
208
|
break;
|
|
186
209
|
case "Union":
|
|
187
|
-
if (!astItemType.
|
|
188
|
-
return Left(new Error(`${propertyShape} partial type cannot be a ${astItemType.kind} with non-
|
|
210
|
+
if (!astItemType.isStructUnionType()) {
|
|
211
|
+
return Left(new Error(`${propertyShape} partial type cannot be a ${astItemType.kind} with non-StructType members`));
|
|
189
212
|
}
|
|
190
213
|
astPartialItemType = astItemType;
|
|
191
214
|
break;
|
|
@@ -202,16 +225,16 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
202
225
|
case "BlankNode":
|
|
203
226
|
case "Identifier":
|
|
204
227
|
case "Iri":
|
|
205
|
-
case "
|
|
228
|
+
case "Struct":
|
|
206
229
|
case "Union":
|
|
207
|
-
astType = new ast.
|
|
230
|
+
astType = new ast.LazyType({
|
|
208
231
|
...astAbstractTypeProperties,
|
|
209
232
|
partialType: astPartialItemType,
|
|
210
233
|
resolveType: astResolveItemType,
|
|
211
234
|
});
|
|
212
235
|
break;
|
|
213
236
|
case "Option":
|
|
214
|
-
astType = new ast.
|
|
237
|
+
astType = new ast.LazyOptionType({
|
|
215
238
|
...astAbstractTypeProperties,
|
|
216
239
|
partialType: new ast.OptionType({
|
|
217
240
|
itemType: astPartialItemType,
|
|
@@ -222,7 +245,7 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
222
245
|
});
|
|
223
246
|
break;
|
|
224
247
|
case "Set":
|
|
225
|
-
astType = new ast.
|
|
248
|
+
astType = new ast.LazySetType({
|
|
226
249
|
...astAbstractTypeProperties,
|
|
227
250
|
partialType: new ast.SetType({
|
|
228
251
|
itemType: astPartialItemType,
|
|
@@ -244,19 +267,19 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
244
267
|
astType.nodeKinds.has("Literal")) {
|
|
245
268
|
return Left(new Error(`${propertyShape}: property shapes with inverse paths can only have blank node or IRI node kinds`));
|
|
246
269
|
}
|
|
247
|
-
return Either.of(new ast.
|
|
270
|
+
return Either.of(Maybe.of(new ast.StructType.Field({
|
|
248
271
|
comment: propertyShape.comment,
|
|
249
272
|
description: propertyShape.description,
|
|
250
273
|
display: propertyShape.display,
|
|
251
274
|
label: propertyShape.label,
|
|
252
275
|
mutable: propertyShape.mutable.orDefault(false),
|
|
253
|
-
name:
|
|
254
|
-
objectType,
|
|
276
|
+
name: fieldName.call(this, propertyShape, structType),
|
|
255
277
|
order: propertyShape.order.orDefault(0),
|
|
256
278
|
path: propertyShape.path,
|
|
257
279
|
shapeIdentifier: propertyShape.$identifier(),
|
|
280
|
+
structType,
|
|
258
281
|
type: astType,
|
|
259
|
-
}));
|
|
282
|
+
})));
|
|
260
283
|
});
|
|
261
284
|
}
|
|
262
|
-
//# sourceMappingURL=
|
|
285
|
+
//# sourceMappingURL=transformPropertyShapeToAstStructTypeField.js.map
|
|
@@ -4,7 +4,7 @@ import type * as input from "../input/index.js";
|
|
|
4
4
|
import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
|
|
5
5
|
import type { ShapeStack } from "./ShapeStack.js";
|
|
6
6
|
/**
|
|
7
|
-
* Is an ast.
|
|
7
|
+
* Is an ast.StructType actually the shape of an RDF list?
|
|
8
8
|
* If so, return the type of its rdf:first.
|
|
9
9
|
*/
|
|
10
10
|
export declare function transformShapeToAstListType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.ListType>>;
|
|
@@ -4,10 +4,9 @@ import { Either, Left, Maybe } from "purify-ts";
|
|
|
4
4
|
import * as ast from "../ast/index.js";
|
|
5
5
|
import { Eithers } from "../Eithers.js";
|
|
6
6
|
import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
|
|
7
|
-
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
8
7
|
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
9
|
-
import {
|
|
10
|
-
const
|
|
8
|
+
import { transformPropertyShapeToAstStructTypeField } from "./transformPropertyShapeToAstStructTypeField.js";
|
|
9
|
+
const listPropertiesStructType = new ast.StructType({
|
|
11
10
|
extern: false,
|
|
12
11
|
comment: Maybe.empty(),
|
|
13
12
|
label: Maybe.empty(),
|
|
@@ -32,7 +31,7 @@ const astListTypePlaceholderItemType = new ast.BlankNodeType({
|
|
|
32
31
|
});
|
|
33
32
|
const empty = Either.of(Maybe.empty());
|
|
34
33
|
/**
|
|
35
|
-
* Is an ast.
|
|
34
|
+
* Is an ast.StructType actually the shape of an RDF list?
|
|
36
35
|
* If so, return the type of its rdf:first.
|
|
37
36
|
*/
|
|
38
37
|
export function transformShapeToAstListType(shape, shapeStack) {
|
|
@@ -53,7 +52,9 @@ export function transformShapeToAstListType(shape, shapeStack) {
|
|
|
53
52
|
itemType: astListTypePlaceholderItemType,
|
|
54
53
|
label: nodeShape.label,
|
|
55
54
|
mutable: nodeShape.mutable.orDefault(false),
|
|
56
|
-
name: shapeAstTypeName(nodeShape),
|
|
55
|
+
// name: shapeAstTypeName(nodeShape),
|
|
56
|
+
// List types don't need names currently
|
|
57
|
+
name: Maybe.empty(),
|
|
57
58
|
shapeIdentifier: nodeShape.$identifier(),
|
|
58
59
|
toRdfTypes: nodeShape.toRdfTypes,
|
|
59
60
|
});
|
|
@@ -74,10 +75,10 @@ export function transformShapeToAstListType(shape, shapeStack) {
|
|
|
74
75
|
if (!emptyListShape || !nonEmptyListShape) {
|
|
75
76
|
return empty;
|
|
76
77
|
}
|
|
77
|
-
return Either.sequence(nonEmptyListShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier))).chain((
|
|
78
|
+
return Either.sequence(nonEmptyListShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier))).chain((nonEmptyListShapePropertyShapes) => {
|
|
78
79
|
let firstPropertyShape;
|
|
79
80
|
let restPropertyShape;
|
|
80
|
-
for (const propertyShape of
|
|
81
|
+
for (const propertyShape of nonEmptyListShapePropertyShapes) {
|
|
81
82
|
if (propertyShape.path.termType !== "NamedNode") {
|
|
82
83
|
continue;
|
|
83
84
|
}
|
|
@@ -102,26 +103,34 @@ export function transformShapeToAstListType(shape, shapeStack) {
|
|
|
102
103
|
restPropertyShape.minCount.extract() !== 1n) {
|
|
103
104
|
return Left(new Error(`${nodeShape} non-empty list shape rdf:rest property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
|
|
104
105
|
}
|
|
105
|
-
return
|
|
106
|
+
return transformPropertyShapeToAstStructTypeField
|
|
106
107
|
.call(this, {
|
|
107
|
-
// Just need a dummy ast.
|
|
108
|
-
objectType: listPropertiesObjectType,
|
|
108
|
+
// Just need a dummy ast.StructType here to get the properties transformed.
|
|
109
109
|
propertyShape: firstPropertyShape,
|
|
110
|
+
structType: listPropertiesStructType,
|
|
110
111
|
})
|
|
111
|
-
.chain((
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
.chain((firstFieldMaybe) => {
|
|
113
|
+
const firstField = firstFieldMaybe.extract();
|
|
114
|
+
if (!firstField) {
|
|
115
|
+
return Left(new Error(`${nodeShape}: rdf:first field is ignored`));
|
|
114
116
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
if (!ast.ListType.isItemType(firstField.type)) {
|
|
118
|
+
return Left(new Error(`${nodeShape}: ${firstField.type.kind} is not a valid list item type`));
|
|
119
|
+
}
|
|
120
|
+
listType.itemType = firstField.type;
|
|
121
|
+
return transformPropertyShapeToAstStructTypeField
|
|
117
122
|
.call(this, {
|
|
118
|
-
// Just need a dummy ast.
|
|
119
|
-
objectType: listPropertiesObjectType,
|
|
123
|
+
// Just need a dummy ast.StructType here to get the properties transformed.
|
|
120
124
|
propertyShape: restPropertyShape,
|
|
125
|
+
structType: listPropertiesStructType,
|
|
121
126
|
})
|
|
122
|
-
.chain((
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
.chain((restFieldMaybe) => {
|
|
128
|
+
const restField = restFieldMaybe.extract();
|
|
129
|
+
if (!restField) {
|
|
130
|
+
return Left(new Error(`${nodeShape}: rdf:rest field is ignored`));
|
|
131
|
+
}
|
|
132
|
+
if (restField.type.kind !== "List" ||
|
|
133
|
+
!restField.type.shapeIdentifier.equals(nodeShape.$identifier())) {
|
|
125
134
|
return Left(new Error(`${nodeShape} rdf:rest property is not recursive into the node shape`));
|
|
126
135
|
}
|
|
127
136
|
return Either.of(Maybe.of(listType));
|
|
@@ -2,6 +2,6 @@ import { Either, Maybe } from "purify-ts";
|
|
|
2
2
|
import * as ast from "../ast/index.js";
|
|
3
3
|
import type * as input from "../input/index.js";
|
|
4
4
|
import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
|
|
5
|
-
import { ShapeStack } from "./ShapeStack.js";
|
|
6
|
-
export declare function
|
|
7
|
-
//# sourceMappingURL=
|
|
5
|
+
import type { ShapeStack } from "./ShapeStack.js";
|
|
6
|
+
export declare function transformShapeToAstStructType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.Type>>;
|
|
7
|
+
//# sourceMappingURL=transformShapeToAstStructType.d.ts.map
|
|
@@ -4,44 +4,44 @@ import { invariant } from "ts-invariant";
|
|
|
4
4
|
import * as ast from "../ast/index.js";
|
|
5
5
|
import { Eithers } from "../Eithers.js";
|
|
6
6
|
import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
|
|
7
|
-
import { ShapeStack } from "./ShapeStack.js";
|
|
8
7
|
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
9
8
|
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
10
|
-
import {
|
|
9
|
+
import { transformPropertyShapeToAstStructTypeField } from "./transformPropertyShapeToAstStructTypeField.js";
|
|
11
10
|
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
12
|
-
function
|
|
13
|
-
switch (
|
|
11
|
+
function isStructTypeFieldRequired(field) {
|
|
12
|
+
switch (field.type.kind) {
|
|
14
13
|
case "DefaultValue":
|
|
15
14
|
return false;
|
|
16
|
-
case "
|
|
15
|
+
case "LazyOption":
|
|
17
16
|
return false;
|
|
18
|
-
case "
|
|
19
|
-
return
|
|
17
|
+
case "LazySet":
|
|
18
|
+
return field.type.partialType.minCount > 0n;
|
|
20
19
|
case "Option":
|
|
21
20
|
return false;
|
|
22
21
|
case "Set":
|
|
23
|
-
return
|
|
22
|
+
return field.type.minCount > 0;
|
|
24
23
|
case "Union":
|
|
25
|
-
return
|
|
24
|
+
return field.type.members.every((member) => isStructTypeFieldRequired({ type: member.type }));
|
|
26
25
|
case "BlankNode":
|
|
27
26
|
case "Identifier":
|
|
28
27
|
case "Iri":
|
|
29
|
-
case "
|
|
28
|
+
case "Lazy":
|
|
30
29
|
case "List":
|
|
31
30
|
case "Literal":
|
|
32
|
-
case "
|
|
31
|
+
case "Struct":
|
|
33
32
|
case "Term":
|
|
34
33
|
return true;
|
|
35
34
|
case "Intersection":
|
|
36
35
|
throw new Error("unsupported");
|
|
37
36
|
default:
|
|
38
|
-
|
|
37
|
+
field.type;
|
|
39
38
|
throw new Error("should never reach this point");
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
|
-
export function
|
|
41
|
+
export function transformShapeToAstStructType(shape, shapeStack) {
|
|
43
42
|
shapeStack.push(shape);
|
|
44
43
|
try {
|
|
44
|
+
// If the shape has an sh:node itself then transform that instead
|
|
45
45
|
if (shape.node.isJust()) {
|
|
46
46
|
return this.shapesGraph
|
|
47
47
|
.nodeShape(shape.node.unsafeCoerce())
|
|
@@ -56,14 +56,15 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
|
56
56
|
nodeShape.xone.orDefault([]).length > 0) {
|
|
57
57
|
return Either.of(Maybe.empty());
|
|
58
58
|
}
|
|
59
|
-
if (nodeShape
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
if (!nodeShape.extern.orDefault(false)) {
|
|
60
|
+
if (nodeShape.properties.length === 0) {
|
|
61
|
+
// A node shape must have sh:property to be considered a StructType
|
|
62
|
+
return Either.of(Maybe.empty());
|
|
63
|
+
}
|
|
64
|
+
} // else assume all extern node shapes are structs
|
|
62
65
|
return Eithers.chain2(shapeNodeKinds.call(this, nodeShape, { defaultNodeShapeNodeKinds }), Either.sequence(nodeShape.properties.map((propertyShapeIdentifier) => this.shapesGraph.propertyShape(propertyShapeIdentifier)))).chain(([nodeKinds, propertyShapes]) => {
|
|
63
66
|
const nodeShapeIdentifier = nodeShape.$identifier();
|
|
64
|
-
const { ancestors: ancestorNodeShapes, descendants: descendantNodeShapes, children: childNodeShapes, parents: parentNodeShapes, } = this.relatedNodeShapesByIdentifier.get(nodeShapeIdentifier);
|
|
65
67
|
const isClass = nodeShape.subClassOf.length > 0 ||
|
|
66
|
-
descendantNodeShapes.length > 0 || // A node shape that is the object of an rdfs:subClassOf is itself an rdfs:Class
|
|
67
68
|
nodeShape.types.some((type) => type.equals(owl.Class) || type.equals(rdfs.Class));
|
|
68
69
|
let fromRdfType = nodeShape.fromRdfType.alt(nodeShape.rdfType);
|
|
69
70
|
if (isClass && nodeShapeIdentifier.termType === "NamedNode") {
|
|
@@ -117,7 +118,7 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
|
117
118
|
// Remove the placeholder if the transformation fails.
|
|
118
119
|
// If this node shape's properties (directly or indirectly) refer to the node shape itself,
|
|
119
120
|
// we'll return this placeholder.
|
|
120
|
-
const
|
|
121
|
+
const structType = new ast.StructType({
|
|
121
122
|
comment: nodeShape.comment,
|
|
122
123
|
extern: nodeShape.extern.orDefault(false),
|
|
123
124
|
fromRdfType,
|
|
@@ -129,41 +130,30 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
|
129
130
|
toRdfTypes,
|
|
130
131
|
tsImports: nodeShape.tsImports,
|
|
131
132
|
});
|
|
132
|
-
this.cachedAstTypesByShapeIdentifier.set(nodeShape.$identifier(),
|
|
133
|
+
this.cachedAstTypesByShapeIdentifier.set(nodeShape.$identifier(), structType);
|
|
133
134
|
return (() => {
|
|
134
|
-
// Populate ancestor and descendant object types
|
|
135
|
-
const relatedObjectTypes = (relatedNodeShapes) => {
|
|
136
|
-
return relatedNodeShapes
|
|
137
|
-
.flatMap((relatedNodeShape) => transformShapeToAstType
|
|
138
|
-
.call(this, relatedNodeShape, new ShapeStack())
|
|
139
|
-
.toMaybe()
|
|
140
|
-
.toList())
|
|
141
|
-
.filter((astType) => astType.kind === "Object");
|
|
142
|
-
};
|
|
143
|
-
objectType.addAncestorObjectTypes(...relatedObjectTypes(ancestorNodeShapes));
|
|
144
|
-
objectType.addChildObjectTypes(...relatedObjectTypes(childNodeShapes));
|
|
145
|
-
objectType.addDescendantObjectTypes(...relatedObjectTypes(descendantNodeShapes));
|
|
146
|
-
objectType.addParentObjectTypes(...relatedObjectTypes(parentNodeShapes));
|
|
147
135
|
// Populate properties
|
|
148
136
|
for (const propertyShape of propertyShapes) {
|
|
149
|
-
const
|
|
150
|
-
objectType,
|
|
137
|
+
const fieldEither = transformPropertyShapeToAstStructTypeField.call(this, {
|
|
151
138
|
propertyShape,
|
|
139
|
+
structType,
|
|
152
140
|
});
|
|
153
|
-
if (
|
|
154
|
-
return
|
|
141
|
+
if (fieldEither.isLeft()) {
|
|
142
|
+
return fieldEither;
|
|
155
143
|
}
|
|
156
|
-
|
|
157
|
-
|
|
144
|
+
fieldEither.ifRight((property) => {
|
|
145
|
+
property.ifJust((property) => {
|
|
146
|
+
structType.addFields(property);
|
|
147
|
+
});
|
|
158
148
|
});
|
|
159
149
|
}
|
|
160
|
-
if (!
|
|
161
|
-
|
|
162
|
-
!
|
|
150
|
+
if (!structType.extern &&
|
|
151
|
+
structType.fromRdfType.isNothing() &&
|
|
152
|
+
!structType.fields.some(isStructTypeFieldRequired)) {
|
|
163
153
|
return Left(new Error(`${nodeShape} has no required properties and no implicitly required rdf:type`));
|
|
164
154
|
}
|
|
165
|
-
|
|
166
|
-
return Either.of(Maybe.of(
|
|
155
|
+
structType.sortFields();
|
|
156
|
+
return Either.of(Maybe.of(structType));
|
|
167
157
|
})().ifLeft(() => {
|
|
168
158
|
this.cachedAstTypesByShapeIdentifier.delete(nodeShape.$identifier());
|
|
169
159
|
});
|
|
@@ -173,4 +163,4 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
|
173
163
|
shapeStack.pop(shape);
|
|
174
164
|
}
|
|
175
165
|
}
|
|
176
|
-
//# sourceMappingURL=
|
|
166
|
+
//# sourceMappingURL=transformShapeToAstStructType.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Either, Left, Maybe } from "purify-ts";
|
|
2
2
|
import { invariant } from "ts-invariant";
|
|
3
3
|
import * as ast from "../ast/index.js";
|
|
4
|
+
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
4
5
|
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
5
6
|
/**
|
|
6
7
|
* Try to convert a shape to an AST TermType using some heuristics.
|
|
@@ -13,7 +14,7 @@ export function transformShapeToAstTermType(shape, shapeStack) {
|
|
|
13
14
|
const in_ = shapeStack.constraints.in_;
|
|
14
15
|
const astAbstractTypeProperties = {
|
|
15
16
|
comment: Maybe.empty(),
|
|
16
|
-
name:
|
|
17
|
+
name: shapeAstTypeName(shape),
|
|
17
18
|
label: Maybe.empty(),
|
|
18
19
|
shapeIdentifier: shape.$identifier(),
|
|
19
20
|
};
|
|
@@ -4,7 +4,7 @@ import type * as input from "../input/index.js";
|
|
|
4
4
|
import type { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
|
|
5
5
|
import type { ShapeStack } from "./ShapeStack.js";
|
|
6
6
|
/**
|
|
7
|
-
* Try to
|
|
7
|
+
* Try to transform a shape to an AST type using some heuristics. All shape -> AST type transformation calls should go through this function,
|
|
8
8
|
* not the other transformShapeToAst*Type functions directly.
|
|
9
9
|
*/
|
|
10
10
|
export declare function transformShapeToAstType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, ast.Type>;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Either } from "purify-ts";
|
|
2
2
|
import { transformShapeToAstCompoundType } from "./transformShapeToAstCompoundType.js";
|
|
3
3
|
import { transformShapeToAstListType } from "./transformShapeToAstListType.js";
|
|
4
|
-
import {
|
|
4
|
+
import { transformShapeToAstStructType } from "./transformShapeToAstStructType.js";
|
|
5
5
|
import { transformShapeToAstTermType } from "./transformShapeToAstTermType.js";
|
|
6
6
|
const tryTransformShapeToAstTypeMethods = [
|
|
7
7
|
transformShapeToAstListType, // List type must be before compound type since a list shape uses sh:xone
|
|
8
8
|
transformShapeToAstCompoundType,
|
|
9
|
-
|
|
9
|
+
transformShapeToAstStructType,
|
|
10
10
|
];
|
|
11
11
|
/**
|
|
12
|
-
* Try to
|
|
12
|
+
* Try to transform a shape to an AST type using some heuristics. All shape -> AST type transformation calls should go through this function,
|
|
13
13
|
* not the other transformShapeToAst*Type functions directly.
|
|
14
14
|
*/
|
|
15
15
|
export function transformShapeToAstType(shape, shapeStack) {
|
|
@@ -4,8 +4,9 @@ import type { BlankNodeType } from "./BlankNodeType.js";
|
|
|
4
4
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
5
5
|
import type { IntersectionType } from "./IntersectionType.js";
|
|
6
6
|
import type { IriType } from "./IriType.js";
|
|
7
|
+
import type { ListType } from "./ListType.js";
|
|
7
8
|
import type { LiteralType } from "./LiteralType.js";
|
|
8
|
-
import type {
|
|
9
|
+
import type { StructType } from "./StructType.js";
|
|
9
10
|
import type { TermType } from "./TermType.js";
|
|
10
11
|
import type { Type } from "./Type.js";
|
|
11
12
|
import type { UnionType } from "./UnionType.js";
|
|
@@ -38,7 +39,7 @@ export declare namespace AbstractCompoundType {
|
|
|
38
39
|
interface Member<TypeT extends MemberType> {
|
|
39
40
|
readonly type: TypeT;
|
|
40
41
|
}
|
|
41
|
-
type MemberType = BlankNodeType | IdentifierType | IntersectionType | IriType | LiteralType |
|
|
42
|
+
type MemberType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType | UnionType;
|
|
42
43
|
function isMemberType(type: Type): type is MemberType;
|
|
43
44
|
}
|
|
44
45
|
//# sourceMappingURL=AbstractCompoundType.d.ts.map
|
|
@@ -61,16 +61,16 @@ __decorate([
|
|
|
61
61
|
case "Identifier":
|
|
62
62
|
case "Intersection":
|
|
63
63
|
case "Iri":
|
|
64
|
+
case "List":
|
|
64
65
|
case "Literal":
|
|
65
|
-
case "
|
|
66
|
+
case "Struct":
|
|
66
67
|
case "Term":
|
|
67
68
|
case "Union":
|
|
68
69
|
return true;
|
|
69
70
|
case "DefaultValue":
|
|
70
|
-
case "
|
|
71
|
-
case "
|
|
72
|
-
case "
|
|
73
|
-
case "List":
|
|
71
|
+
case "LazyOption":
|
|
72
|
+
case "LazySet":
|
|
73
|
+
case "Lazy":
|
|
74
74
|
case "Option":
|
|
75
75
|
case "Set":
|
|
76
76
|
return false;
|
|
@@ -6,7 +6,7 @@ import type { IntersectionType } from "./IntersectionType.js";
|
|
|
6
6
|
import type { IriType } from "./IriType.js";
|
|
7
7
|
import type { ListType } from "./ListType.js";
|
|
8
8
|
import type { LiteralType } from "./LiteralType.js";
|
|
9
|
-
import type {
|
|
9
|
+
import type { StructType } from "./StructType.js";
|
|
10
10
|
import type { TermType } from "./TermType.js";
|
|
11
11
|
import { Type } from "./Type.js";
|
|
12
12
|
import type { UnionType } from "./UnionType.js";
|
|
@@ -38,7 +38,7 @@ export declare abstract class AbstractContainerType<ItemTypeT extends AbstractCo
|
|
|
38
38
|
};
|
|
39
39
|
}
|
|
40
40
|
export declare namespace AbstractContainerType {
|
|
41
|
-
type ItemType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType |
|
|
41
|
+
type ItemType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | StructType | TermType | UnionType;
|
|
42
42
|
function isItemType(type: Type): type is ItemType;
|
|
43
43
|
}
|
|
44
44
|
//# sourceMappingURL=AbstractContainerType.d.ts.map
|
|
@@ -45,14 +45,14 @@ export class AbstractContainerType extends AbstractType {
|
|
|
45
45
|
case "Iri":
|
|
46
46
|
case "List":
|
|
47
47
|
case "Literal":
|
|
48
|
-
case "
|
|
48
|
+
case "Struct":
|
|
49
49
|
case "Term":
|
|
50
50
|
case "Union":
|
|
51
51
|
return true;
|
|
52
52
|
case "DefaultValue":
|
|
53
|
-
case "
|
|
54
|
-
case "
|
|
55
|
-
case "
|
|
53
|
+
case "LazyOption":
|
|
54
|
+
case "LazySet":
|
|
55
|
+
case "Lazy":
|
|
56
56
|
case "Option":
|
|
57
57
|
case "Set":
|
|
58
58
|
return false;
|