@shaclmate/compiler 4.0.8 → 4.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Compiler.d.ts +1 -4
- package/dist/Compiler.js +1 -5
- package/dist/ShapesGraphToAstTransformer.d.ts +2 -11
- package/dist/ShapesGraphToAstTransformer.js +25 -27
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.d.ts +3 -0
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.js +5 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.d.ts +4 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +27 -0
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +74 -19
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +45 -91
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +11 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +146 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +7 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +182 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +9 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +3 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +33 -10
- package/dist/ast/AbstractCompoundType.d.ts +26 -8
- package/dist/ast/AbstractCompoundType.js +84 -16
- package/dist/ast/AbstractContainerType.d.ts +2 -4
- package/dist/ast/AbstractContainerType.js +3 -4
- package/dist/ast/AbstractLazyObjectType.d.ts +1 -0
- package/dist/ast/AbstractLazyObjectType.js +3 -0
- package/dist/ast/AbstractTermType.d.ts +1 -0
- package/dist/ast/AbstractTermType.js +1 -0
- package/dist/ast/AbstractType.d.ts +16 -1
- package/dist/ast/AbstractType.js +11 -1
- package/dist/ast/Ast.d.ts +5 -5
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/DefaultValueType.d.ts +1 -2
- package/dist/ast/DefaultValueType.js +2 -0
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/IntersectionType.d.ts +7 -2
- package/dist/ast/IntersectionType.js +8 -0
- package/dist/ast/ListType.d.ts +2 -9
- package/dist/ast/ListType.js +1 -9
- package/dist/ast/LiteralType.d.ts +1 -0
- package/dist/ast/LiteralType.js +26 -0
- package/dist/ast/ObjectCompoundType.d.ts +12 -0
- package/dist/ast/ObjectCompoundType.js +88 -0
- package/dist/ast/ObjectIntersectionType.d.ts +3 -7
- package/dist/ast/ObjectIntersectionType.js +1 -7
- package/dist/ast/ObjectType.d.ts +14 -31
- package/dist/ast/ObjectType.js +41 -73
- package/dist/ast/ObjectUnionType.d.ts +3 -7
- package/dist/ast/ObjectUnionType.js +1 -7
- package/dist/ast/OptionType.d.ts +1 -2
- package/dist/ast/OptionType.js +2 -0
- package/dist/ast/SetType.d.ts +1 -2
- package/dist/ast/SetType.js +2 -0
- package/dist/ast/Type.d.ts +1 -4
- package/dist/ast/Type.js +0 -6
- package/dist/ast/UnionType.d.ts +11 -6
- package/dist/ast/UnionType.js +6 -4
- package/dist/ast/index.d.ts +1 -2
- package/dist/ast/index.js +1 -2
- package/dist/generators/json/AstJsonGenerator.js +17 -15
- package/dist/generators/ts/AbstractCollectionType.d.ts +1 -1
- package/dist/generators/ts/AbstractCollectionType.js +10 -12
- package/dist/generators/ts/AbstractContainerType.d.ts +9 -4
- package/dist/generators/ts/AbstractContainerType.js +10 -3
- package/dist/generators/ts/AbstractDateType.d.ts +2 -2
- package/dist/generators/ts/AbstractDateType.js +2 -2
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractIdentifierType.js +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +13 -10
- package/dist/generators/ts/AbstractLazyObjectType.js +21 -16
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +33 -0
- package/dist/generators/ts/AbstractNamedUnionType.js +195 -0
- package/dist/generators/ts/AbstractNumericType.d.ts +3 -3
- package/dist/generators/ts/AbstractNumericType.js +4 -4
- package/dist/generators/ts/AbstractTermType.d.ts +7 -4
- package/dist/generators/ts/AbstractTermType.js +7 -4
- package/dist/generators/ts/AbstractType.d.ts +34 -19
- package/dist/generators/ts/AbstractUnionType.d.ts +80 -0
- package/dist/generators/ts/AbstractUnionType.js +514 -0
- package/dist/generators/ts/AnonymousUnionType.d.ts +26 -0
- package/dist/generators/ts/AnonymousUnionType.js +56 -0
- package/dist/generators/ts/BigDecimalType.d.ts +4 -4
- package/dist/generators/ts/BigDecimalType.js +5 -5
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +2 -2
- package/dist/generators/ts/BlankNodeType.js +2 -2
- package/dist/generators/ts/BooleanType.d.ts +3 -3
- package/dist/generators/ts/BooleanType.js +3 -3
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +5 -5
- package/dist/generators/ts/DefaultValueType.js +17 -16
- package/dist/generators/ts/IdentifierType.d.ts +2 -2
- package/dist/generators/ts/IdentifierType.js +2 -2
- package/dist/generators/ts/IriType.d.ts +2 -2
- package/dist/generators/ts/IriType.js +2 -2
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +10 -10
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +8 -8
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +9 -10
- package/dist/generators/ts/ListType.d.ts +9 -8
- package/dist/generators/ts/ListType.js +15 -14
- package/dist/generators/ts/LiteralType.d.ts +2 -2
- package/dist/generators/ts/LiteralType.js +3 -3
- package/dist/generators/ts/NamedObjectType.d.ts +126 -0
- package/dist/generators/ts/NamedObjectType.js +420 -0
- package/dist/generators/ts/NamedObjectUnionType.d.ts +35 -0
- package/dist/generators/ts/NamedObjectUnionType.js +217 -0
- package/dist/generators/ts/NamedUnionType.d.ts +11 -0
- package/dist/generators/ts/NamedUnionType.js +13 -0
- package/dist/generators/ts/OptionType.d.ts +5 -5
- package/dist/generators/ts/OptionType.js +12 -12
- package/dist/generators/ts/SetType.d.ts +4 -4
- package/dist/generators/ts/SetType.js +13 -11
- package/dist/generators/ts/StringType.d.ts +3 -3
- package/dist/generators/ts/StringType.js +3 -3
- package/dist/generators/ts/TermType.d.ts +2 -2
- package/dist/generators/ts/TermType.js +3 -3
- package/dist/generators/ts/TsGenerator.js +28 -20
- package/dist/generators/ts/Type.d.ts +5 -4
- package/dist/generators/ts/TypeFactory.d.ts +9 -7
- package/dist/generators/ts/TypeFactory.js +139 -112
- package/dist/generators/ts/ZodGenerator.js +18 -16
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.d.ts +9 -9
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.js +3 -3
- package/dist/generators/ts/{_ObjectType/TypeDiscriminantProperty.d.ts → _NamedObjectType/DiscriminantProperty.d.ts} +14 -14
- package/dist/generators/ts/{_ObjectType/TypeDiscriminantProperty.js → _NamedObjectType/DiscriminantProperty.js} +22 -20
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.d.ts +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.js +6 -6
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.d.ts +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.js +31 -28
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_classDeclaration.js → _NamedObjectType/NamedObjectType_classDeclaration.js} +15 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_createFunctionDeclaration.js → _NamedObjectType/NamedObjectType_createFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterFunctionDeclaration.js → _NamedObjectType/NamedObjectType_filterFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterTypeDeclaration.js → _NamedObjectType/NamedObjectType_filterTypeDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +6 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.js → _NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js} +6 -7
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfTypeVariableStatement.js → _NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_graphqlTypeVariableStatement.js → _NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.js → _NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_interfaceDeclaration.js → _NamedObjectType/NamedObjectType_interfaceDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_isTypeFunctionDeclaration.js → _NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonTypeAliasDeclaration.js → _NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_objectSetMethodNames.js → _NamedObjectType/NamedObjectType_objectSetMethodNames.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +38 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.js → _NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js} +16 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_schemaVariableStatement.js → _NamedObjectType/NamedObjectType_schemaVariableStatement.js} +3 -4
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js} +10 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +13 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +15 -0
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.d.ts +2 -2
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.d.ts +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.js +14 -14
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.js +12 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.js +14 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +17 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.d.ts +5 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +35 -0
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.js +7 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.js +13 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_booleanEquals.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +2 -3
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +4 -3
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +4 -3
- package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +3 -2
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +4 -4
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +25 -25
- package/dist/generators/ts/imports.d.ts +1 -1
- package/dist/generators/ts/imports.js +1 -1
- package/dist/generators/ts/objectSetDeclarations.d.ts +5 -5
- package/dist/generators/ts/objectSetDeclarations.js +34 -31
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +5 -5
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +6 -4
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +4 -4
- package/dist/generators/ts/objectSetMethodSignatures.js +9 -9
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +5 -5
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +54 -53
- package/dist/generators/ts/singleEntryRecord.d.ts +2 -0
- package/dist/generators/ts/singleEntryRecord.js +6 -0
- package/dist/generators/ts/snippets.d.ts +10 -6
- package/dist/generators/ts/snippets.js +20 -12
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +5 -5
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +19 -20
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +4 -4
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +14 -9
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +5 -5
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +2 -2
- package/dist/input/NodeShape.d.ts +0 -1
- package/dist/input/NodeShape.js +0 -3
- package/dist/input/ShapesGraph.d.ts +3 -2
- package/dist/input/ShapesGraph.js +12 -7
- package/dist/input/generated.d.ts +1899 -88
- package/dist/input/generated.js +676 -564
- package/package.json +5 -7
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.js +0 -45
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +0 -3
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.js +0 -2
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/index.js +0 -6
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.d.ts +0 -5
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.js +0 -9
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +0 -11
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +0 -338
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.js +0 -31
- package/dist/ast/AbstractObjectCompoundType.d.ts +0 -45
- package/dist/ast/AbstractObjectCompoundType.js +0 -180
- package/dist/ast/Curie.d.ts +0 -21
- package/dist/ast/Curie.js +0 -29
- package/dist/ast/PlaceholderType.d.ts +0 -15
- package/dist/ast/PlaceholderType.js +0 -19
- package/dist/generators/codeName.d.ts +0 -6
- package/dist/generators/codeName.js +0 -66
- package/dist/generators/ts/AbstractDeclaredType.d.ts +0 -23
- package/dist/generators/ts/AbstractDeclaredType.js +0 -17
- package/dist/generators/ts/ObjectType.d.ts +0 -117
- package/dist/generators/ts/ObjectType.js +0 -402
- package/dist/generators/ts/ObjectUnionType.d.ts +0 -65
- package/dist/generators/ts/ObjectUnionType.js +0 -257
- package/dist/generators/ts/UnionType.d.ts +0 -40
- package/dist/generators/ts/UnionType.js +0 -527
- package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.js +0 -66
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +0 -9
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/MemberType.d.ts +0 -34
- package/dist/generators/ts/_ObjectUnionType/MemberType.js +0 -105
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.js +0 -29
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js +0 -20
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.js +0 -18
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.js +0 -28
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.js +0 -9
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.js +0 -13
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.js +0 -37
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js +0 -35
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js +0 -26
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.js +0 -43
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.js +0 -5
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.js +0 -5
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.js +0 -12
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.js +0 -15
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.js +0 -0
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/identifierTypeDeclarations.js +0 -0
package/dist/Compiler.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import PrefixMap from "@rdfjs/prefix-map/PrefixMap.js";
|
|
2
1
|
import type { Either } from "purify-ts";
|
|
3
2
|
import type { Generator } from "./generators/Generator.js";
|
|
4
3
|
import type { ShapesGraph } from "./input/ShapesGraph.js";
|
|
5
4
|
export declare class Compiler {
|
|
6
5
|
private readonly generator;
|
|
7
|
-
|
|
8
|
-
constructor({ generator, iriPrefixMap, }: {
|
|
6
|
+
constructor({ generator }: {
|
|
9
7
|
generator: Generator;
|
|
10
|
-
iriPrefixMap?: PrefixMap;
|
|
11
8
|
});
|
|
12
9
|
compile(shapesGraph: ShapesGraph): Either<Error, string>;
|
|
13
10
|
}
|
package/dist/Compiler.js
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import PrefixMap from "@rdfjs/prefix-map/PrefixMap.js";
|
|
2
1
|
import { ShapesGraphToAstTransformer } from "./ShapesGraphToAstTransformer.js";
|
|
3
2
|
export class Compiler {
|
|
4
3
|
generator;
|
|
5
|
-
|
|
6
|
-
constructor({ generator, iriPrefixMap, }) {
|
|
4
|
+
constructor({ generator }) {
|
|
7
5
|
this.generator = generator;
|
|
8
|
-
this.iriPrefixMap = iriPrefixMap ?? new PrefixMap();
|
|
9
6
|
}
|
|
10
7
|
compile(shapesGraph) {
|
|
11
8
|
return new ShapesGraphToAstTransformer({
|
|
12
|
-
iriPrefixMap: this.iriPrefixMap,
|
|
13
9
|
shapesGraph,
|
|
14
10
|
})
|
|
15
11
|
.transform()
|
|
@@ -1,23 +1,14 @@
|
|
|
1
|
-
import type PrefixMap from "@rdfjs/prefix-map/PrefixMap.js";
|
|
2
1
|
import TermMap from "@rdfjs/term-map";
|
|
3
2
|
import type * as rdfjs from "@rdfjs/types";
|
|
4
3
|
import { Either } from "purify-ts";
|
|
5
|
-
import { CurieFactory } from "./_ShapesGraphToAstTransformer/CurieFactory.js";
|
|
6
|
-
import * as _ShapesGraphToAstTransformer from "./_ShapesGraphToAstTransformer/index.js";
|
|
7
4
|
import type * as ast from "./ast/index.js";
|
|
8
5
|
import type { TsFeature } from "./enums/TsFeature.js";
|
|
9
6
|
import type * as input from "./input/index.js";
|
|
10
7
|
export declare class ShapesGraphToAstTransformer {
|
|
11
|
-
protected readonly
|
|
12
|
-
protected readonly nodeShapeAstTypesByIdentifier: TermMap<rdfjs.BlankNode | rdfjs.NamedNode, _ShapesGraphToAstTransformer.NodeShapeAstType>;
|
|
8
|
+
protected readonly cachedAstTypesByShapeIdentifier: TermMap<rdfjs.BlankNode | rdfjs.NamedNode, ast.Type>;
|
|
13
9
|
protected readonly shapesGraph: input.ShapesGraph;
|
|
14
|
-
protected shapeIdentifier: typeof _ShapesGraphToAstTransformer.shapeIdentifier;
|
|
15
|
-
protected transformNodeShapeToAstType: typeof _ShapesGraphToAstTransformer.transformNodeShapeToAstType;
|
|
16
|
-
protected transformPropertyShapeToAstObjectTypeProperty: typeof _ShapesGraphToAstTransformer.transformPropertyShapeToAstObjectTypeProperty;
|
|
17
|
-
protected transformShapeToAstType: typeof _ShapesGraphToAstTransformer.transformShapeToAstType;
|
|
18
10
|
protected tsFeaturesDefault: ReadonlySet<TsFeature>;
|
|
19
|
-
constructor({
|
|
20
|
-
iriPrefixMap: PrefixMap;
|
|
11
|
+
constructor({ shapesGraph, tsFeaturesDefault, }: {
|
|
21
12
|
shapesGraph: input.ShapesGraph;
|
|
22
13
|
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
23
14
|
});
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import TermMap from "@rdfjs/term-map";
|
|
2
2
|
import { dash } from "@tpluscode/rdf-ns-builders";
|
|
3
3
|
import { Either } from "purify-ts";
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { invariant } from "ts-invariant";
|
|
5
|
+
import { ShapeStack } from "./_ShapesGraphToAstTransformer/ShapeStack.js";
|
|
6
|
+
import { transformShapeToAstType } from "./_ShapesGraphToAstTransformer/transformShapeToAstType.js";
|
|
6
7
|
export class ShapesGraphToAstTransformer {
|
|
7
|
-
// Members are protected so they're accessible to
|
|
8
|
-
|
|
9
|
-
nodeShapeAstTypesByIdentifier = new TermMap();
|
|
8
|
+
// Members are protected so they're accessible to functions in other files
|
|
9
|
+
cachedAstTypesByShapeIdentifier = new TermMap();
|
|
10
10
|
shapesGraph;
|
|
11
|
-
shapeIdentifier = _ShapesGraphToAstTransformer.shapeIdentifier;
|
|
12
|
-
transformNodeShapeToAstType = _ShapesGraphToAstTransformer.transformNodeShapeToAstType;
|
|
13
|
-
transformPropertyShapeToAstObjectTypeProperty = _ShapesGraphToAstTransformer.transformPropertyShapeToAstObjectTypeProperty;
|
|
14
|
-
transformShapeToAstType = _ShapesGraphToAstTransformer.transformShapeToAstType;
|
|
15
11
|
tsFeaturesDefault;
|
|
16
|
-
constructor({
|
|
17
|
-
this.curieFactory = new CurieFactory({ prefixMap: iriPrefixMap });
|
|
12
|
+
constructor({ shapesGraph, tsFeaturesDefault, }) {
|
|
18
13
|
this.shapesGraph = shapesGraph;
|
|
19
14
|
this.tsFeaturesDefault =
|
|
20
15
|
tsFeaturesDefault ??
|
|
21
16
|
new Set(["create", "equals", "hash", "json", "rdf"]);
|
|
22
17
|
}
|
|
23
18
|
transform() {
|
|
24
|
-
const
|
|
25
|
-
const
|
|
19
|
+
const astNamedIntersectionTypes = [];
|
|
20
|
+
const astObjectTypes = [];
|
|
26
21
|
const syntheticAstObjectTypesByName = {};
|
|
27
|
-
const
|
|
22
|
+
const astNamedUnionTypes = [];
|
|
28
23
|
for (const nodeShape of this.shapesGraph.nodeShapes) {
|
|
29
24
|
if (nodeShape.identifier.termType !== "NamedNode") {
|
|
30
25
|
continue;
|
|
@@ -32,26 +27,27 @@ export class ShapesGraphToAstTransformer {
|
|
|
32
27
|
if (nodeShape.identifier.value.startsWith(dash[""].value)) {
|
|
33
28
|
continue;
|
|
34
29
|
}
|
|
35
|
-
const nodeShapeAstTypeEither =
|
|
30
|
+
const nodeShapeAstTypeEither = transformShapeToAstType.call(this, nodeShape, new ShapeStack());
|
|
36
31
|
if (nodeShapeAstTypeEither.isLeft()) {
|
|
37
32
|
return nodeShapeAstTypeEither;
|
|
38
33
|
}
|
|
39
34
|
const nodeShapeAstType = nodeShapeAstTypeEither.unsafeCoerce();
|
|
40
35
|
switch (nodeShapeAstType.kind) {
|
|
41
|
-
case "
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
36
|
+
case "IntersectionType":
|
|
37
|
+
if (nodeShapeAstType.name.isJust()) {
|
|
38
|
+
astNamedIntersectionTypes.push(nodeShapeAstType);
|
|
39
|
+
}
|
|
45
40
|
break;
|
|
46
41
|
case "ObjectType": {
|
|
47
|
-
|
|
42
|
+
invariant(nodeShapeAstType.name.isJust());
|
|
43
|
+
astObjectTypes.push(nodeShapeAstType);
|
|
48
44
|
for (const property of nodeShapeAstType.properties) {
|
|
49
45
|
switch (property.type.kind) {
|
|
50
46
|
case "LazyObjectOptionType":
|
|
51
47
|
case "LazyObjectSetType":
|
|
52
48
|
case "LazyObjectType": {
|
|
53
49
|
const partialItemType = property.type.partialType.kind === "ObjectType" ||
|
|
54
|
-
property.type.partialType.kind === "
|
|
50
|
+
property.type.partialType.kind === "UnionType"
|
|
55
51
|
? property.type.partialType
|
|
56
52
|
: property.type.partialType.itemType;
|
|
57
53
|
if (partialItemType.kind === "ObjectType" &&
|
|
@@ -67,17 +63,19 @@ export class ShapesGraphToAstTransformer {
|
|
|
67
63
|
}
|
|
68
64
|
break;
|
|
69
65
|
}
|
|
70
|
-
case "
|
|
71
|
-
|
|
66
|
+
case "UnionType":
|
|
67
|
+
if (nodeShapeAstType.name.isJust()) {
|
|
68
|
+
astNamedUnionTypes.push(nodeShapeAstType);
|
|
69
|
+
}
|
|
72
70
|
break;
|
|
73
71
|
default:
|
|
74
|
-
|
|
72
|
+
break;
|
|
75
73
|
}
|
|
76
74
|
}
|
|
77
75
|
return Either.of({
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
namedIntersectionTypes: astNamedIntersectionTypes,
|
|
77
|
+
namedObjectTypes: astObjectTypes.concat(Object.values(syntheticAstObjectTypesByName)),
|
|
78
|
+
namedUnionTypes: astNamedUnionTypes,
|
|
81
79
|
});
|
|
82
80
|
}
|
|
83
81
|
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Curie } from "@shaclmate/shacl-ast";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
export function shapeAstTypeName(shape) {
|
|
4
|
+
if (shape.kind !== "NodeShape") {
|
|
5
|
+
return Maybe.empty();
|
|
6
|
+
}
|
|
7
|
+
if (shape.identifier.termType !== "NamedNode") {
|
|
8
|
+
return Maybe.empty();
|
|
9
|
+
}
|
|
10
|
+
// Explicit shaclmate:name
|
|
11
|
+
if (shape.shaclmateName.isJust()) {
|
|
12
|
+
return shape.shaclmateName;
|
|
13
|
+
}
|
|
14
|
+
// Explicit rdfs:label
|
|
15
|
+
if (shape.label.isJust()) {
|
|
16
|
+
return shape.label;
|
|
17
|
+
}
|
|
18
|
+
// CURIE shape identifier
|
|
19
|
+
if (shape.identifier instanceof Curie) {
|
|
20
|
+
if (shape.identifier.hasUniqueReference) {
|
|
21
|
+
return Maybe.of(shape.identifier.reference);
|
|
22
|
+
}
|
|
23
|
+
return Maybe.of(`${shape.identifier.prefix}_${shape.identifier.reference}`);
|
|
24
|
+
}
|
|
25
|
+
return Maybe.empty();
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=shapeAstTypeName.js.map
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import dataFactory from "@rdfjs/data-model";
|
|
2
|
+
import { Curie } from "@shaclmate/shacl-ast";
|
|
2
3
|
import { Either, Left, Maybe } from "purify-ts";
|
|
3
4
|
import { invariant } from "ts-invariant";
|
|
4
5
|
import * as ast from "../ast/index.js";
|
|
5
6
|
import { Eithers } from "../Eithers.js";
|
|
6
7
|
import { ShapeStack } from "./ShapeStack.js";
|
|
7
|
-
import {
|
|
8
|
+
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
8
9
|
function synthesizePartialAstObjectType({ identifierType, tsFeatures, }) {
|
|
9
10
|
let syntheticName;
|
|
10
11
|
switch (identifierType.kind) {
|
|
@@ -20,7 +21,6 @@ function synthesizePartialAstObjectType({ identifierType, tsFeatures, }) {
|
|
|
20
21
|
return new ast.ObjectType({
|
|
21
22
|
abstract: false,
|
|
22
23
|
comment: Maybe.empty(),
|
|
23
|
-
export_: true,
|
|
24
24
|
extern: false,
|
|
25
25
|
fromRdfType: Maybe.empty(),
|
|
26
26
|
identifierType,
|
|
@@ -35,13 +35,55 @@ function synthesizePartialAstObjectType({ identifierType, tsFeatures, }) {
|
|
|
35
35
|
tsObjectDeclarationType: "class",
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
|
-
function
|
|
38
|
+
function propertyName(objectType, propertyShape) {
|
|
39
|
+
// Explicit shaclmate:name or sh:name
|
|
40
|
+
const name = propertyShape.shaclmateName.alt(propertyShape.name).extract();
|
|
41
|
+
if (name) {
|
|
42
|
+
return name;
|
|
43
|
+
}
|
|
44
|
+
// Explicit rdfs:label
|
|
45
|
+
const label = propertyShape.label.extract();
|
|
46
|
+
if (label) {
|
|
47
|
+
return label;
|
|
48
|
+
}
|
|
49
|
+
// Pick up the common pattern of a property shape identifier being the node shape's identifier -localName,
|
|
50
|
+
// like ex:NodeShape-property
|
|
51
|
+
if (propertyShape.identifier.termType === "NamedNode" &&
|
|
52
|
+
objectType.shapeIdentifier.termType === "NamedNode") {
|
|
53
|
+
const propertyShapeIdentifierPrefix = `${objectType.shapeIdentifier.value}-`;
|
|
54
|
+
if (propertyShape.identifier.value.startsWith(propertyShapeIdentifierPrefix) &&
|
|
55
|
+
propertyShape.identifier.value.length >
|
|
56
|
+
propertyShapeIdentifierPrefix.length) {
|
|
57
|
+
return propertyShape.identifier.value.substring(propertyShapeIdentifierPrefix.length);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
// sh:path CURIE reference
|
|
61
|
+
if (propertyShape.path instanceof Curie) {
|
|
62
|
+
return propertyShape.path.reference;
|
|
63
|
+
}
|
|
64
|
+
// Shape identifier CURIE reference
|
|
65
|
+
if (propertyShape.identifier instanceof Curie) {
|
|
66
|
+
return propertyShape.identifier.reference;
|
|
67
|
+
}
|
|
68
|
+
// Shape identifier IRI
|
|
69
|
+
if (propertyShape.identifier.termType === "NamedNode") {
|
|
70
|
+
return propertyShape.identifier.value;
|
|
71
|
+
}
|
|
72
|
+
// sh:path IRI
|
|
73
|
+
if (propertyShape.path.termType === "NamedNode") {
|
|
74
|
+
return propertyShape.path.value;
|
|
75
|
+
}
|
|
76
|
+
throw new Error(`${propertyShape}: unable to infer name`);
|
|
77
|
+
}
|
|
78
|
+
function transformPropertyShapeToAstType(propertyShape, shapeStack) {
|
|
39
79
|
// if (
|
|
40
80
|
// propertyShape.path.kind === "PredicatePath" &&
|
|
41
81
|
// propertyShape.path.iri.value.endsWith("termProperty")
|
|
42
82
|
// ) {
|
|
43
83
|
// }
|
|
44
|
-
return
|
|
84
|
+
return transformShapeToAstType
|
|
85
|
+
.call(this, propertyShape, shapeStack)
|
|
86
|
+
.chain((propertyShapeAstType) => {
|
|
45
87
|
let maxCount = propertyShape.constraints.maxCount.orDefault(Number.MAX_SAFE_INTEGER);
|
|
46
88
|
let minCount = propertyShape.constraints.minCount.orDefault(0);
|
|
47
89
|
if (minCount < 0) {
|
|
@@ -84,17 +126,23 @@ function transformPropertyShapeToAstType(propertyShape) {
|
|
|
84
126
|
});
|
|
85
127
|
}
|
|
86
128
|
export function transformPropertyShapeToAstObjectTypeProperty({ objectType, propertyShape, }) {
|
|
87
|
-
|
|
129
|
+
const shapeStack = new ShapeStack(); // Start a new ShapeStack per property shape
|
|
130
|
+
return Eithers.chain2(propertyShape.resolve, transformPropertyShapeToAstType.call(this, propertyShape, shapeStack)).chain(([propertyShapeResolve, astType]) => {
|
|
88
131
|
let astResolveItemType;
|
|
89
132
|
if (propertyShapeResolve.isJust()) {
|
|
90
|
-
const astResolveTypeEither =
|
|
133
|
+
const astResolveTypeEither = transformShapeToAstType
|
|
134
|
+
.call(this, propertyShapeResolve.unsafeCoerce(), shapeStack)
|
|
135
|
+
.chain((astResolveType) => {
|
|
91
136
|
switch (astResolveType.kind) {
|
|
92
|
-
case "ListType":
|
|
93
|
-
case "ObjectIntersectionType":
|
|
94
|
-
return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind}`));
|
|
95
137
|
case "ObjectType":
|
|
96
|
-
case "ObjectUnionType":
|
|
97
138
|
return Either.of(astResolveType);
|
|
139
|
+
case "UnionType":
|
|
140
|
+
if (!astResolveType.isObjectUnionType()) {
|
|
141
|
+
return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind} with non-ObjectType members`));
|
|
142
|
+
}
|
|
143
|
+
return Either.of(astResolveType);
|
|
144
|
+
default:
|
|
145
|
+
return Left(new Error(`${propertyShape} resolve cannot refer to a ${astResolveType.kind}`));
|
|
98
146
|
}
|
|
99
147
|
});
|
|
100
148
|
if (astResolveTypeEither.isLeft()) {
|
|
@@ -130,18 +178,29 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
130
178
|
});
|
|
131
179
|
break;
|
|
132
180
|
case "ObjectType":
|
|
133
|
-
|
|
181
|
+
astPartialItemType = astItemType;
|
|
182
|
+
break;
|
|
183
|
+
case "UnionType":
|
|
184
|
+
if (!astItemType.isObjectUnionType()) {
|
|
185
|
+
return Left(new Error(`${propertyShape} partial type cannot be a ${astItemType.kind} with non-ObjectType members`));
|
|
186
|
+
}
|
|
134
187
|
astPartialItemType = astItemType;
|
|
135
188
|
break;
|
|
136
189
|
default:
|
|
137
190
|
return Left(new Error(`${propertyShape} has a resolve with an incompatible partial type ${astItemType.kind}`));
|
|
138
191
|
}
|
|
192
|
+
const astAbstractTypeProperties = {
|
|
193
|
+
comment: Maybe.empty(),
|
|
194
|
+
label: Maybe.empty(),
|
|
195
|
+
name: Maybe.empty(),
|
|
196
|
+
shapeIdentifier: propertyShape.identifier,
|
|
197
|
+
};
|
|
139
198
|
switch (astType.kind) {
|
|
140
199
|
case "BlankNodeType":
|
|
141
200
|
case "IdentifierType":
|
|
142
201
|
case "IriType":
|
|
143
202
|
case "ObjectType":
|
|
144
|
-
case "
|
|
203
|
+
case "UnionType":
|
|
145
204
|
astType = new ast.LazyObjectType({
|
|
146
205
|
...astAbstractTypeProperties,
|
|
147
206
|
partialType: astPartialItemType,
|
|
@@ -183,15 +242,11 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
183
242
|
description: propertyShape.description,
|
|
184
243
|
label: propertyShape.label,
|
|
185
244
|
mutable: propertyShape.mutable.orDefault(false),
|
|
186
|
-
name:
|
|
245
|
+
name: propertyName.call(this, objectType, propertyShape),
|
|
187
246
|
objectType,
|
|
188
247
|
order: propertyShape.order.orDefault(0),
|
|
189
|
-
path:
|
|
190
|
-
|
|
191
|
-
: undefined) ?? propertyShape.path,
|
|
192
|
-
shapeIdentifier: (propertyShape.identifier.termType === "NamedNode"
|
|
193
|
-
? this.curieFactory.create(propertyShape.identifier).extract()
|
|
194
|
-
: undefined) ?? propertyShape.identifier,
|
|
248
|
+
path: propertyShape.path,
|
|
249
|
+
shapeIdentifier: propertyShape.identifier,
|
|
195
250
|
type: astType,
|
|
196
251
|
visibility: propertyShape.visibility,
|
|
197
252
|
}));
|
|
@@ -6,5 +6,5 @@ import type { ShapeStack } from "./ShapeStack.js";
|
|
|
6
6
|
/**
|
|
7
7
|
* Try to convert a shape to a compound type (intersection or union) using some heuristics.
|
|
8
8
|
*/
|
|
9
|
-
export declare function transformShapeToAstCompoundType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<
|
|
9
|
+
export declare function transformShapeToAstCompoundType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.Type>>;
|
|
10
10
|
//# sourceMappingURL=transformShapeToAstCompoundType.d.ts.map
|
|
@@ -2,25 +2,28 @@ import { Either, Left, Maybe } from "purify-ts";
|
|
|
2
2
|
import { invariant } from "ts-invariant";
|
|
3
3
|
import * as ast from "../ast/index.js";
|
|
4
4
|
import { Eithers } from "../Eithers.js";
|
|
5
|
-
import {
|
|
5
|
+
import { nodeShapeTsFeatures } from "./nodeShapeTsFeatures.js";
|
|
6
|
+
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
7
|
+
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
6
8
|
/**
|
|
7
9
|
* Try to convert a shape to a compound type (intersection or union) using some heuristics.
|
|
8
10
|
*/
|
|
9
11
|
export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
10
12
|
shapeStack.push(shape);
|
|
11
13
|
try {
|
|
12
|
-
return Eithers.
|
|
14
|
+
return Eithers.chain4(shape.constraints.and, shape.constraints.nodes, shape.kind === "NodeShape"
|
|
15
|
+
? nodeShapeTsFeatures.call(this, shape)
|
|
16
|
+
: Either.of(new Set()), shape.constraints.xone).chain(([andConstraintShapes, nodeConstraintShapes, tsFeatures, xoneConstraintShapes,]) => {
|
|
13
17
|
let compoundTypeKind;
|
|
14
18
|
// Distinguish constraints that take arbitrary shapes from those that only take node shapes
|
|
15
19
|
// With the latter we'll do special transformations.
|
|
16
20
|
let memberShapes;
|
|
17
|
-
let memberNodeShapes;
|
|
18
21
|
if (andConstraintShapes.length > 0) {
|
|
19
22
|
memberShapes = andConstraintShapes;
|
|
20
23
|
compoundTypeKind = "IntersectionType";
|
|
21
24
|
}
|
|
22
25
|
else if (nodeConstraintShapes.length > 0) {
|
|
23
|
-
|
|
26
|
+
memberShapes = nodeConstraintShapes;
|
|
24
27
|
compoundTypeKind = "IntersectionType";
|
|
25
28
|
}
|
|
26
29
|
else if (xoneConstraintShapes.length > 0) {
|
|
@@ -30,107 +33,58 @@ export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
|
30
33
|
else {
|
|
31
34
|
return Either.of(Maybe.empty());
|
|
32
35
|
}
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
else if (memberDiscriminantValues.length > 0) {
|
|
50
|
-
return Left(new Error(`${shape} does not have a discriminant value while the other members of the compound type do`));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
}
|
|
36
|
+
invariant(memberShapes.length > 0);
|
|
37
|
+
const memberDiscriminantValues = new Set();
|
|
38
|
+
const compoundType = new (compoundTypeKind === "IntersectionType"
|
|
39
|
+
? ast.IntersectionType
|
|
40
|
+
: ast.UnionType)({
|
|
41
|
+
comment: shape.comment,
|
|
42
|
+
label: shape.label,
|
|
43
|
+
name: shapeAstTypeName(shape),
|
|
44
|
+
shapeIdentifier: shape.identifier,
|
|
45
|
+
tsFeatures,
|
|
46
|
+
});
|
|
47
|
+
if (memberShapes.length === 1) {
|
|
48
|
+
return transformShapeToAstType
|
|
49
|
+
.call(this, memberShapes[0], shapeStack)
|
|
50
|
+
.map(Maybe.of);
|
|
54
51
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
52
|
+
// Put a placeholder in the cache to deal with cyclic references
|
|
53
|
+
this.cachedAstTypesByShapeIdentifier.set(shape.identifier, compoundType);
|
|
54
|
+
return Either.sequence(memberShapes.map((memberShape) => transformShapeToAstType.call(this, memberShape, shapeStack)))
|
|
55
|
+
.chain((memberShapeTypes) => {
|
|
56
|
+
for (let memberI = 0; memberI < memberShapes.length; memberI++) {
|
|
57
|
+
const memberShape = memberShapes[memberI];
|
|
58
|
+
const memberType = memberShapeTypes[memberI];
|
|
59
|
+
if (!ast.IntersectionType.isMemberType(memberType)) {
|
|
60
|
+
return Left(new Error(`${shape} has an invalid member type kind "${memberType.kind}"`));
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
if (memberI > 0 &&
|
|
63
|
+
compoundType.members.some((existingMember) => ast.Type.equals(memberType, existingMember.type))) {
|
|
64
|
+
return Left(new Error(`${shape} has duplicate ${compoundTypeKind} member type: ${memberType}`));
|
|
65
|
+
}
|
|
66
|
+
let memberDiscriminantValue;
|
|
63
67
|
if (compoundTypeKind === "UnionType") {
|
|
64
|
-
let memberDiscriminantValue;
|
|
65
68
|
if (memberShape.kind === "NodeShape") {
|
|
66
69
|
memberDiscriminantValue =
|
|
67
70
|
memberShape.discriminantValue.extract();
|
|
68
71
|
}
|
|
69
72
|
if (memberDiscriminantValue) {
|
|
70
|
-
if (memberDiscriminantValues.
|
|
73
|
+
if (memberDiscriminantValues.has(memberDiscriminantValue)) {
|
|
71
74
|
return Left(new Error(`${shape} member ${memberShape} has a duplicate discriminant value: ${memberDiscriminantValue}`));
|
|
72
75
|
}
|
|
73
|
-
memberDiscriminantValues.
|
|
74
|
-
}
|
|
75
|
-
else if (memberDiscriminantValues.length > 0) {
|
|
76
|
-
return Left(new Error(`${shape} member ${memberShape} does not have a discriminant value while the other members of the compound type do`));
|
|
76
|
+
memberDiscriminantValues.add(memberDiscriminantValue);
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
invariant(false);
|
|
83
|
-
}
|
|
84
|
-
if (memberTypes.length === 1) {
|
|
85
|
-
return Either.of(Maybe.of(memberTypes[0]));
|
|
86
|
-
}
|
|
87
|
-
return transformShapeToAstAbstractTypeProperties(shape).chain((astAbstractTypeProperties) => {
|
|
88
|
-
// If every member type is an ObjectType, ObjectIntersectionType, or ObjectUnionType (the latter of which can be flattened to ObjectTypes),
|
|
89
|
-
// produce a different AST type (ObjectIntersectionType or ObjectUnionType).
|
|
90
|
-
if (memberTypes.every((memberType) => {
|
|
91
|
-
switch (memberType.kind) {
|
|
92
|
-
case "ObjectType":
|
|
93
|
-
case "ObjectIntersectionType":
|
|
94
|
-
case "ObjectUnionType":
|
|
95
|
-
return true;
|
|
96
|
-
default:
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
})) {
|
|
100
|
-
const compoundType = new (compoundTypeKind === "IntersectionType"
|
|
101
|
-
? ast.ObjectIntersectionType
|
|
102
|
-
: ast.ObjectUnionType)({
|
|
103
|
-
...astAbstractTypeProperties,
|
|
104
|
-
export_: true,
|
|
105
|
-
name: shape.shaclmateName,
|
|
106
|
-
shapeIdentifier: this.shapeIdentifier(shape),
|
|
107
|
-
tsFeatures: this.tsFeaturesDefault,
|
|
79
|
+
compoundType.addMember({
|
|
80
|
+
discriminantValue: Maybe.fromNullable(memberDiscriminantValue),
|
|
81
|
+
type: memberType,
|
|
108
82
|
});
|
|
109
|
-
for (const memberType of memberTypes) {
|
|
110
|
-
const addMemberTypeResult = compoundType.addMemberType(memberType);
|
|
111
|
-
if (addMemberTypeResult.isLeft()) {
|
|
112
|
-
return addMemberTypeResult;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
// Compound type doesn't solely consist of ObjectTypes
|
|
117
|
-
switch (compoundTypeKind) {
|
|
118
|
-
case "IntersectionType":
|
|
119
|
-
return Either.of(Maybe.of(new ast.IntersectionType({
|
|
120
|
-
...astAbstractTypeProperties,
|
|
121
|
-
memberTypes,
|
|
122
|
-
})));
|
|
123
|
-
case "UnionType":
|
|
124
|
-
if (memberDiscriminantValues.length > 0 &&
|
|
125
|
-
memberDiscriminantValues.length !== memberTypes.length) {
|
|
126
|
-
return Left(new Error(`${shape} has members without discriminant values`));
|
|
127
|
-
}
|
|
128
|
-
return Either.of(Maybe.of(new ast.UnionType({
|
|
129
|
-
...astAbstractTypeProperties,
|
|
130
|
-
memberDiscriminantValues,
|
|
131
|
-
memberTypes,
|
|
132
|
-
})));
|
|
133
83
|
}
|
|
84
|
+
return Either.of(Maybe.of(compoundType));
|
|
85
|
+
})
|
|
86
|
+
.ifLeft(() => {
|
|
87
|
+
this.cachedAstTypesByShapeIdentifier.delete(shape.identifier);
|
|
134
88
|
});
|
|
135
89
|
});
|
|
136
90
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
import type { ShapeStack } from "./ShapeStack.js";
|
|
6
|
+
/**
|
|
7
|
+
* Is an ast.ObjectType actually the shape of an RDF list?
|
|
8
|
+
* If so, return the type of its rdf:first.
|
|
9
|
+
*/
|
|
10
|
+
export declare function transformShapeToAstListType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.ListType>>;
|
|
11
|
+
//# sourceMappingURL=transformShapeToAstListType.d.ts.map
|