@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
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import dataFactory from "@rdfjs/data-model";
|
|
2
|
+
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
3
|
+
import { Either, Left, Maybe } from "purify-ts";
|
|
4
|
+
import * as ast from "../ast/index.js";
|
|
5
|
+
import { Eithers } from "../Eithers.js";
|
|
6
|
+
import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
|
|
7
|
+
import { nodeShapeIdentifierMintingStrategy } from "./nodeShapeIdentifierMintingStrategy.js";
|
|
8
|
+
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
9
|
+
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
10
|
+
import { transformPropertyShapeToAstObjectTypeProperty } from "./transformPropertyShapeToAstObjectTypeProperty.js";
|
|
11
|
+
const listPropertiesObjectType = new ast.ObjectType({
|
|
12
|
+
abstract: false,
|
|
13
|
+
extern: false,
|
|
14
|
+
comment: Maybe.empty(),
|
|
15
|
+
label: Maybe.empty(),
|
|
16
|
+
identifierMintingStrategy: Maybe.empty(),
|
|
17
|
+
identifierType: new ast.IdentifierType({
|
|
18
|
+
comment: Maybe.empty(),
|
|
19
|
+
label: Maybe.empty(),
|
|
20
|
+
name: Maybe.empty(),
|
|
21
|
+
shapeIdentifier: dataFactory.blankNode(),
|
|
22
|
+
}),
|
|
23
|
+
fromRdfType: Maybe.empty(),
|
|
24
|
+
name: Maybe.empty(),
|
|
25
|
+
toRdfTypes: [],
|
|
26
|
+
tsFeatures: new Set([]),
|
|
27
|
+
tsObjectDeclarationType: "class",
|
|
28
|
+
shapeIdentifier: dataFactory.blankNode(),
|
|
29
|
+
synthetic: true,
|
|
30
|
+
tsImports: [],
|
|
31
|
+
});
|
|
32
|
+
const astListTypePlaceholderItemType = new ast.BlankNodeType({
|
|
33
|
+
comment: Maybe.empty(),
|
|
34
|
+
label: Maybe.empty(),
|
|
35
|
+
name: Maybe.empty(),
|
|
36
|
+
shapeIdentifier: dataFactory.blankNode(),
|
|
37
|
+
});
|
|
38
|
+
/**
|
|
39
|
+
* Is an ast.ObjectType actually the shape of an RDF list?
|
|
40
|
+
* If so, return the type of its rdf:first.
|
|
41
|
+
*/
|
|
42
|
+
export function transformShapeToAstListType(shape, shapeStack) {
|
|
43
|
+
shapeStack.push(shape);
|
|
44
|
+
try {
|
|
45
|
+
if (shape.kind !== "NodeShape") {
|
|
46
|
+
return Either.of(Maybe.empty());
|
|
47
|
+
}
|
|
48
|
+
const nodeShape = shape;
|
|
49
|
+
if (!nodeShape.isList) {
|
|
50
|
+
return Either.of(Maybe.empty());
|
|
51
|
+
}
|
|
52
|
+
return Eithers.chain3(nodeShapeIdentifierMintingStrategy(nodeShape), shapeNodeKinds(nodeShape, { defaultNodeShapeNodeKinds }), nodeShape.constraints.xone).chain(([identifierMintingStrategy, nodeKinds, xone]) => {
|
|
53
|
+
// Put a placeholder in the cache to deal with cyclic references
|
|
54
|
+
// Remove the placeholder if the transformation fails.
|
|
55
|
+
const listType = new ast.ListType({
|
|
56
|
+
comment: nodeShape.comment,
|
|
57
|
+
identifierNodeKind: nodeKinds.has("BlankNode") ? "BlankNode" : "IRI",
|
|
58
|
+
itemType: astListTypePlaceholderItemType,
|
|
59
|
+
label: nodeShape.label,
|
|
60
|
+
mutable: nodeShape.mutable.orDefault(false),
|
|
61
|
+
name: shapeAstTypeName(nodeShape),
|
|
62
|
+
identifierMintingStrategy,
|
|
63
|
+
shapeIdentifier: nodeShape.identifier,
|
|
64
|
+
toRdfTypes: nodeShape.toRdfTypes,
|
|
65
|
+
});
|
|
66
|
+
this.cachedAstTypesByShapeIdentifier.set(nodeShape.identifier, listType);
|
|
67
|
+
return (() => {
|
|
68
|
+
let emptyListShape;
|
|
69
|
+
let nonEmptyListShape;
|
|
70
|
+
for (const shape of xone) {
|
|
71
|
+
if (shape.constraints.hasValues.length === 1 &&
|
|
72
|
+
shape.constraints.hasValues[0].equals(rdf.nil)) {
|
|
73
|
+
emptyListShape = shape;
|
|
74
|
+
}
|
|
75
|
+
else if (shape.kind === "NodeShape" &&
|
|
76
|
+
shape.constraints.properties.orDefault([]).length >= 2) {
|
|
77
|
+
nonEmptyListShape = shape;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
if (!emptyListShape || !nonEmptyListShape) {
|
|
81
|
+
return Left(new Error(`${nodeShape} does not have an sh:xone with exactly two shapes, one for the empty list and one for the non-empty list`));
|
|
82
|
+
}
|
|
83
|
+
return nonEmptyListShape.constraints.properties.chain((nonEmptyListShapeProperties) => {
|
|
84
|
+
let firstPropertyShape;
|
|
85
|
+
let restPropertyShape;
|
|
86
|
+
for (const propertyShape of nonEmptyListShapeProperties) {
|
|
87
|
+
if (propertyShape.path.termType !== "NamedNode") {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
if (propertyShape.path.equals(rdf.first)) {
|
|
91
|
+
firstPropertyShape = propertyShape;
|
|
92
|
+
}
|
|
93
|
+
else if (propertyShape.path.equals(rdf.rest)) {
|
|
94
|
+
restPropertyShape = propertyShape;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
if (!firstPropertyShape) {
|
|
98
|
+
return Left(new Error(`${nodeShape} has a non-empty list shape without an sh:property shape whose sh:path is rdf:first`));
|
|
99
|
+
}
|
|
100
|
+
if (firstPropertyShape.constraints.maxCount.extract() !== 1 ||
|
|
101
|
+
firstPropertyShape.constraints.minCount.extract() !== 1) {
|
|
102
|
+
return Left(new Error(`${nodeShape} non-empty list shape rdf:first property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
|
|
103
|
+
}
|
|
104
|
+
if (!restPropertyShape) {
|
|
105
|
+
return Left(new Error(`${nodeShape} has a non-empty list shape without an sh:property shape whose sh:path is rdf:rest`));
|
|
106
|
+
}
|
|
107
|
+
if (restPropertyShape.constraints.maxCount.extract() !== 1 ||
|
|
108
|
+
restPropertyShape.constraints.minCount.extract() !== 1) {
|
|
109
|
+
return Left(new Error(`${nodeShape} non-empty list shape rdf:rest property shape does not have sh:maxCount=1 and/or sh:minCount=1`));
|
|
110
|
+
}
|
|
111
|
+
return transformPropertyShapeToAstObjectTypeProperty
|
|
112
|
+
.call(this, {
|
|
113
|
+
// Just need a dummy ast.ObjectType here to get the properties transformed.
|
|
114
|
+
objectType: listPropertiesObjectType,
|
|
115
|
+
propertyShape: firstPropertyShape,
|
|
116
|
+
})
|
|
117
|
+
.chain((firstProperty) => {
|
|
118
|
+
if (!ast.ListType.isItemType(firstProperty.type)) {
|
|
119
|
+
return Left(new Error(`${nodeShape}: ${firstProperty.type.kind} is not a valid list item type`));
|
|
120
|
+
}
|
|
121
|
+
listType.itemType = firstProperty.type;
|
|
122
|
+
return transformPropertyShapeToAstObjectTypeProperty
|
|
123
|
+
.call(this, {
|
|
124
|
+
// Just need a dummy ast.ObjectType here to get the properties transformed.
|
|
125
|
+
objectType: listPropertiesObjectType,
|
|
126
|
+
propertyShape: restPropertyShape,
|
|
127
|
+
})
|
|
128
|
+
.chain((restProperty) => {
|
|
129
|
+
if (restProperty.type.kind !== "ListType" ||
|
|
130
|
+
!restProperty.type.shapeIdentifier.equals(nodeShape.identifier)) {
|
|
131
|
+
return Left(new Error(`${nodeShape} rdf:rest property is not recursive into the node shape`));
|
|
132
|
+
}
|
|
133
|
+
return Either.of(Maybe.of(listType));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
});
|
|
137
|
+
})().ifLeft(() => {
|
|
138
|
+
this.cachedAstTypesByShapeIdentifier.delete(nodeShape.identifier);
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
finally {
|
|
143
|
+
shapeStack.pop(shape);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
//# sourceMappingURL=transformShapeToAstListType.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
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 { ShapeStack } from "./ShapeStack.js";
|
|
6
|
+
export declare function transformShapeToAstObjectType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, Maybe<ast.ObjectType>>;
|
|
7
|
+
//# sourceMappingURL=transformShapeToAstObjectType.d.ts.map
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { Either, Left, Maybe } from "purify-ts";
|
|
2
|
+
import { invariant } from "ts-invariant";
|
|
3
|
+
import * as ast from "../ast/index.js";
|
|
4
|
+
import { Eithers } from "../Eithers.js";
|
|
5
|
+
import { defaultNodeShapeNodeKinds } from "./defaultNodeShapeNodeKinds.js";
|
|
6
|
+
import { nodeShapeIdentifierMintingStrategy } from "./nodeShapeIdentifierMintingStrategy.js";
|
|
7
|
+
import { nodeShapeTsFeatures } from "./nodeShapeTsFeatures.js";
|
|
8
|
+
import { ShapeStack } from "./ShapeStack.js";
|
|
9
|
+
import { shapeAstTypeName } from "./shapeAstTypeName.js";
|
|
10
|
+
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
11
|
+
import { transformPropertyShapeToAstObjectTypeProperty } from "./transformPropertyShapeToAstObjectTypeProperty.js";
|
|
12
|
+
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
13
|
+
function isObjectTypePropertyRequired(property) {
|
|
14
|
+
switch (property.type.kind) {
|
|
15
|
+
case "DefaultValueType":
|
|
16
|
+
return false;
|
|
17
|
+
case "LazyObjectOptionType":
|
|
18
|
+
return false;
|
|
19
|
+
case "LazyObjectSetType":
|
|
20
|
+
return property.type.partialType.minCount > 0;
|
|
21
|
+
case "OptionType":
|
|
22
|
+
return false;
|
|
23
|
+
case "SetType":
|
|
24
|
+
return property.type.minCount > 0;
|
|
25
|
+
case "UnionType":
|
|
26
|
+
return property.type.members.every((member) => isObjectTypePropertyRequired({ type: member.type }));
|
|
27
|
+
case "BlankNodeType":
|
|
28
|
+
case "IdentifierType":
|
|
29
|
+
case "IriType":
|
|
30
|
+
case "LazyObjectType":
|
|
31
|
+
case "ListType":
|
|
32
|
+
case "LiteralType":
|
|
33
|
+
case "ObjectType":
|
|
34
|
+
case "TermType":
|
|
35
|
+
return true;
|
|
36
|
+
case "IntersectionType":
|
|
37
|
+
throw new Error("unsupported");
|
|
38
|
+
default:
|
|
39
|
+
property.type;
|
|
40
|
+
throw new Error("should never reach this point");
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
44
|
+
shapeStack.push(shape);
|
|
45
|
+
try {
|
|
46
|
+
if (shape.kind !== "NodeShape") {
|
|
47
|
+
return Either.of(Maybe.empty());
|
|
48
|
+
}
|
|
49
|
+
const nodeShape = shape;
|
|
50
|
+
if (nodeShape.identifier.termType !== "NamedNode") {
|
|
51
|
+
return Either.of(Maybe.empty());
|
|
52
|
+
}
|
|
53
|
+
return Eithers.chain2(nodeShape.constraints.and, nodeShape.constraints.xone).chain(([andShapes, xoneShapes]) => {
|
|
54
|
+
if (andShapes.length > 0 || xoneShapes.length > 0) {
|
|
55
|
+
return Either.of(Maybe.empty());
|
|
56
|
+
}
|
|
57
|
+
return Eithers.chain9(nodeShape.ancestorNodeShapes, nodeShape.childNodeShapes, nodeShape.descendantNodeShapes, nodeShape.parentNodeShapes, nodeShapeIdentifierMintingStrategy(nodeShape), shapeNodeKinds(nodeShape, { defaultNodeShapeNodeKinds }), nodeShape.constraints.properties, nodeShapeTsFeatures.call(this, nodeShape), nodeShape.tsObjectDeclarationType.isJust()
|
|
58
|
+
? Either.of(nodeShape.tsObjectDeclarationType)
|
|
59
|
+
: nodeShape.isDefinedBy.map((ontology) => ontology.chain((ontology) => ontology.tsObjectDeclarationType))).chain(([ancestorNodeShapes, childNodeShapes, descendantNodeShapes, parentNodeShapes, identifierMintingStrategy, nodeKinds, propertyShapes, tsFeatures, tsObjectDeclarationType,]) => {
|
|
60
|
+
const abstract = nodeShape.abstract.orDefault(false);
|
|
61
|
+
let fromRdfType;
|
|
62
|
+
let toRdfTypes;
|
|
63
|
+
if (!abstract) {
|
|
64
|
+
fromRdfType = nodeShape.fromRdfType.alt(nodeShape.rdfType);
|
|
65
|
+
if (nodeShape.isClass &&
|
|
66
|
+
nodeShape.identifier.termType === "NamedNode") {
|
|
67
|
+
fromRdfType = fromRdfType.alt(Maybe.of(nodeShape.identifier));
|
|
68
|
+
}
|
|
69
|
+
toRdfTypes = nodeShape.toRdfTypes.concat();
|
|
70
|
+
if (toRdfTypes.length === 0) {
|
|
71
|
+
toRdfTypes.push(...nodeShape.rdfType.toList());
|
|
72
|
+
}
|
|
73
|
+
// Ensure toRdfTypes has fromRdfType
|
|
74
|
+
fromRdfType.ifJust((fromRdfType) => {
|
|
75
|
+
if (!toRdfTypes.some((toRdfType) => toRdfType.equals(fromRdfType))) {
|
|
76
|
+
toRdfTypes.push(fromRdfType);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
fromRdfType = Maybe.empty();
|
|
82
|
+
toRdfTypes = [];
|
|
83
|
+
}
|
|
84
|
+
if (nodeKinds.has("Literal")) {
|
|
85
|
+
return Left(new Error(`${nodeShape} should not have a nodeKind "Literal"`));
|
|
86
|
+
}
|
|
87
|
+
let identifierType;
|
|
88
|
+
const identifierTypeProperties = {
|
|
89
|
+
comment: Maybe.empty(),
|
|
90
|
+
label: Maybe.empty(),
|
|
91
|
+
name: Maybe.empty(),
|
|
92
|
+
shapeIdentifier: nodeShape.identifier,
|
|
93
|
+
};
|
|
94
|
+
if (nodeKinds.size === 2) {
|
|
95
|
+
invariant(nodeShape.identifierIn.length === 0);
|
|
96
|
+
identifierType = new ast.IdentifierType(identifierTypeProperties);
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
switch ([...nodeKinds][0]) {
|
|
100
|
+
case "BlankNode":
|
|
101
|
+
invariant(nodeShape.identifierIn.length === 0);
|
|
102
|
+
identifierType = new ast.BlankNodeType(identifierTypeProperties);
|
|
103
|
+
break;
|
|
104
|
+
case "IRI":
|
|
105
|
+
identifierType = new ast.IriType({
|
|
106
|
+
...identifierTypeProperties,
|
|
107
|
+
hasValues: [],
|
|
108
|
+
in_: nodeShape.identifierIn,
|
|
109
|
+
});
|
|
110
|
+
break;
|
|
111
|
+
case "Literal":
|
|
112
|
+
throw new Error("should never happen");
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
invariant(identifierType);
|
|
116
|
+
// Put a placeholder in the cache to deal with cyclic references
|
|
117
|
+
// Remove the placeholder if the transformation fails.
|
|
118
|
+
// If this node shape's properties (directly or indirectly) refer to the node shape itself,
|
|
119
|
+
// we'll return this placeholder.
|
|
120
|
+
const objectType = new ast.ObjectType({
|
|
121
|
+
abstract,
|
|
122
|
+
comment: nodeShape.comment,
|
|
123
|
+
extern: nodeShape.extern.orDefault(false),
|
|
124
|
+
fromRdfType,
|
|
125
|
+
label: nodeShape.label,
|
|
126
|
+
identifierType,
|
|
127
|
+
identifierMintingStrategy,
|
|
128
|
+
name: shapeAstTypeName(nodeShape),
|
|
129
|
+
shapeIdentifier: nodeShape.identifier,
|
|
130
|
+
synthetic: false,
|
|
131
|
+
toRdfTypes,
|
|
132
|
+
tsFeatures,
|
|
133
|
+
tsImports: nodeShape.tsImports,
|
|
134
|
+
tsObjectDeclarationType: tsObjectDeclarationType.orDefault("class"),
|
|
135
|
+
});
|
|
136
|
+
this.cachedAstTypesByShapeIdentifier.set(nodeShape.identifier, objectType);
|
|
137
|
+
return (() => {
|
|
138
|
+
// Populate ancestor and descendant object types
|
|
139
|
+
const relatedObjectTypes = (relatedNodeShapes) => {
|
|
140
|
+
return relatedNodeShapes
|
|
141
|
+
.flatMap((relatedNodeShape) => transformShapeToAstType
|
|
142
|
+
.call(this, relatedNodeShape, new ShapeStack())
|
|
143
|
+
.toMaybe()
|
|
144
|
+
.toList())
|
|
145
|
+
.filter((astType) => astType.kind === "ObjectType");
|
|
146
|
+
};
|
|
147
|
+
objectType.addAncestorObjectTypes(...relatedObjectTypes(ancestorNodeShapes));
|
|
148
|
+
objectType.addChildObjectTypes(...relatedObjectTypes(childNodeShapes));
|
|
149
|
+
objectType.addDescendantObjectTypes(...relatedObjectTypes(descendantNodeShapes));
|
|
150
|
+
objectType.addParentObjectTypes(...relatedObjectTypes(parentNodeShapes));
|
|
151
|
+
// Populate properties
|
|
152
|
+
for (const propertyShape of propertyShapes) {
|
|
153
|
+
const propertyEither = transformPropertyShapeToAstObjectTypeProperty.call(this, {
|
|
154
|
+
objectType,
|
|
155
|
+
propertyShape,
|
|
156
|
+
});
|
|
157
|
+
if (propertyEither.isLeft()) {
|
|
158
|
+
return propertyEither;
|
|
159
|
+
}
|
|
160
|
+
propertyEither.ifRight((property) => {
|
|
161
|
+
objectType.addProperties(property);
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
if (!objectType.abstract &&
|
|
165
|
+
!objectType.extern &&
|
|
166
|
+
objectType.fromRdfType.isNothing() &&
|
|
167
|
+
!objectType.properties.some(isObjectTypePropertyRequired)) {
|
|
168
|
+
return Left(new Error(`${nodeShape} has no required properties and no implicitly required rdf:type`));
|
|
169
|
+
}
|
|
170
|
+
objectType.sortProperties();
|
|
171
|
+
return Either.of(Maybe.of(objectType));
|
|
172
|
+
})().ifLeft(() => {
|
|
173
|
+
this.cachedAstTypesByShapeIdentifier.delete(nodeShape.identifier);
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
shapeStack.pop(shape);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
//# sourceMappingURL=transformShapeToAstObjectType.js.map
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { Either, Left } from "purify-ts";
|
|
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 { Eithers } from "../Eithers.js";
|
|
5
4
|
import { shapeNodeKinds } from "./shapeNodeKinds.js";
|
|
6
|
-
import { transformShapeToAstAbstractTypeProperties } from "./transformShapeToAstAbstractTypeProperties.js";
|
|
7
5
|
/**
|
|
8
6
|
* Try to convert a shape to an AST TermType using some heuristics.
|
|
9
7
|
*/
|
|
10
8
|
export function transformShapeToAstTermType(shape, shapeStack) {
|
|
11
9
|
shapeStack.push(shape);
|
|
12
10
|
try {
|
|
13
|
-
return
|
|
11
|
+
return shapeNodeKinds(shape).chain((nodeKinds) => {
|
|
14
12
|
const hasValues = shapeStack.constraints.hasValues;
|
|
15
13
|
const in_ = shapeStack.constraints.in_;
|
|
14
|
+
const astAbstractTypeProperties = {
|
|
15
|
+
comment: Maybe.empty(),
|
|
16
|
+
name: Maybe.empty(),
|
|
17
|
+
label: Maybe.empty(),
|
|
18
|
+
shapeIdentifier: shape.identifier,
|
|
19
|
+
};
|
|
16
20
|
let termType;
|
|
17
21
|
if (nodeKinds.size === 1) {
|
|
18
22
|
const nodeKind = [...nodeKinds][0];
|
|
19
23
|
switch (nodeKind) {
|
|
20
24
|
case "BlankNode":
|
|
21
25
|
invariant(in_.length === 0);
|
|
22
|
-
termType = new ast.BlankNodeType(
|
|
23
|
-
...astAbstractTypeProperties,
|
|
24
|
-
});
|
|
26
|
+
termType = new ast.BlankNodeType(astAbstractTypeProperties);
|
|
25
27
|
break;
|
|
26
28
|
case "IRI":
|
|
27
29
|
termType = new ast.IriType({
|
|
@@ -4,10 +4,8 @@ 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 convert a shape to a type using some heuristics.
|
|
8
|
-
*
|
|
9
|
-
* We don't try to handle exotic cases allowed by the SHACL spec, such as combinations of sh:in and sh:node. Instead we assume
|
|
10
|
-
* a shape has one type.
|
|
7
|
+
* Try to convert a shape to a type using some heuristics. All shape -> AST type transformation calls should go through this function,
|
|
8
|
+
* not the other transformShapeToAst*Type functions directly.
|
|
11
9
|
*/
|
|
12
|
-
export declare function transformShapeToAstType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error,
|
|
10
|
+
export declare function transformShapeToAstType(this: ShapesGraphToAstTransformer, shape: input.Shape, shapeStack: ShapeStack): Either<Error, ast.Type>;
|
|
13
11
|
//# sourceMappingURL=transformShapeToAstType.d.ts.map
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
import { Either } from "purify-ts";
|
|
2
2
|
import { transformShapeToAstCompoundType } from "./transformShapeToAstCompoundType.js";
|
|
3
|
+
import { transformShapeToAstListType } from "./transformShapeToAstListType.js";
|
|
4
|
+
import { transformShapeToAstObjectType } from "./transformShapeToAstObjectType.js";
|
|
3
5
|
import { transformShapeToAstTermType } from "./transformShapeToAstTermType.js";
|
|
6
|
+
const tryTransformShapeToAstTypeMethods = [
|
|
7
|
+
transformShapeToAstListType, // List type must be before compound type since a list shape uses sh:xone
|
|
8
|
+
transformShapeToAstCompoundType,
|
|
9
|
+
transformShapeToAstObjectType,
|
|
10
|
+
];
|
|
4
11
|
/**
|
|
5
|
-
* Try to convert a shape to a type using some heuristics.
|
|
6
|
-
*
|
|
7
|
-
* We don't try to handle exotic cases allowed by the SHACL spec, such as combinations of sh:in and sh:node. Instead we assume
|
|
8
|
-
* a shape has one type.
|
|
12
|
+
* Try to convert a shape to a type using some heuristics. All shape -> AST type transformation calls should go through this function,
|
|
13
|
+
* not the other transformShapeToAst*Type functions directly.
|
|
9
14
|
*/
|
|
10
15
|
export function transformShapeToAstType(shape, shapeStack) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
const astType = this.cachedAstTypesByShapeIdentifier.get(shape.identifier);
|
|
17
|
+
if (astType) {
|
|
18
|
+
return Either.of(astType);
|
|
19
|
+
}
|
|
20
|
+
// Every transformShapeToAst*Type returns Either<Error, Maybe<ast.Type>>:
|
|
21
|
+
// * Left/Error: the shape was the expected type but the transformation failed
|
|
22
|
+
// * Right+Nothing = the shape wasn't the expected type
|
|
23
|
+
// * Right+Some = the shape was the expected type and the transformation succeeded
|
|
24
|
+
for (const tryTransformAstTypeToShapeMethod of tryTransformShapeToAstTypeMethods) {
|
|
25
|
+
const either = tryTransformAstTypeToShapeMethod.call(this, shape, shapeStack);
|
|
26
|
+
if (either.isLeft()) {
|
|
27
|
+
return either;
|
|
28
|
+
}
|
|
29
|
+
const astType = either.unsafeCoerce().extract();
|
|
30
|
+
if (astType) {
|
|
31
|
+
this.cachedAstTypesByShapeIdentifier.set(shape.identifier, astType);
|
|
32
|
+
return Either.of(astType);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return transformShapeToAstTermType
|
|
36
|
+
.call(this, shape, shapeStack)
|
|
37
|
+
.ifRight((astType) => {
|
|
38
|
+
this.cachedAstTypesByShapeIdentifier.set(shape.identifier, astType);
|
|
39
|
+
});
|
|
17
40
|
}
|
|
18
41
|
//# sourceMappingURL=transformShapeToAstType.js.map
|
|
@@ -1,23 +1,41 @@
|
|
|
1
|
+
import type { TsFeature } from "../enums/TsFeature.js";
|
|
1
2
|
import { AbstractType } from "./AbstractType.js";
|
|
2
|
-
import {
|
|
3
|
+
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
4
|
+
import type { IdentifierType } from "./IdentifierType.js";
|
|
5
|
+
import type { IntersectionType } from "./IntersectionType.js";
|
|
6
|
+
import type { IriType } from "./IriType.js";
|
|
7
|
+
import type { LiteralType } from "./LiteralType.js";
|
|
8
|
+
import type { ObjectType } from "./ObjectType.js";
|
|
9
|
+
import type { TermType } from "./TermType.js";
|
|
10
|
+
import type { Type } from "./Type.js";
|
|
11
|
+
import type { UnionType } from "./UnionType.js";
|
|
3
12
|
/**
|
|
4
13
|
* A compound of types, such as an intersection or union.
|
|
5
14
|
*
|
|
6
15
|
* Compound = combining types at the type level e.g., functions, intersections, unions
|
|
7
16
|
* Composite = combining values at runtime (e.g., arrays, structs whose members have the same type)
|
|
8
17
|
*/
|
|
9
|
-
export declare abstract class AbstractCompoundType<MemberTypeT extends
|
|
18
|
+
export declare abstract class AbstractCompoundType<MemberT extends AbstractCompoundType.Member<MemberTypeT>, MemberTypeT extends AbstractCompoundType.MemberType> extends AbstractType {
|
|
10
19
|
#private;
|
|
11
20
|
/**
|
|
12
21
|
* Type discriminant
|
|
13
22
|
*/
|
|
14
|
-
abstract readonly kind: "IntersectionType" | "
|
|
15
|
-
constructor({
|
|
16
|
-
|
|
23
|
+
abstract readonly kind: "IntersectionType" | "UnionType";
|
|
24
|
+
constructor({ tsFeatures, ...superParameters }: {
|
|
25
|
+
tsFeatures: ReadonlySet<TsFeature>;
|
|
17
26
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
get
|
|
27
|
+
get members(): readonly MemberT[];
|
|
28
|
+
get recursive(): boolean;
|
|
29
|
+
get tsFeatures(): ReadonlySet<TsFeature>;
|
|
30
|
+
addMember(member: MemberT): void;
|
|
31
|
+
equals(other: AbstractCompoundType<MemberT, MemberTypeT>): boolean;
|
|
21
32
|
toString(): string;
|
|
22
33
|
}
|
|
34
|
+
export declare namespace AbstractCompoundType {
|
|
35
|
+
interface Member<TypeT extends MemberType> {
|
|
36
|
+
readonly type: TypeT;
|
|
37
|
+
}
|
|
38
|
+
type MemberType = BlankNodeType | IdentifierType | IntersectionType | IriType | LiteralType | ObjectType | TermType | UnionType;
|
|
39
|
+
function isMemberType(type: Type): type is MemberType;
|
|
40
|
+
}
|
|
23
41
|
//# sourceMappingURL=AbstractCompoundType.d.ts.map
|
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
1
7
|
import { invariant } from "ts-invariant";
|
|
8
|
+
import { Memoize } from "typescript-memoize";
|
|
2
9
|
import { AbstractType } from "./AbstractType.js";
|
|
3
|
-
import { arrayEquals } from "./equals.js";
|
|
4
|
-
import { Type } from "./Type.js";
|
|
5
10
|
/**
|
|
6
11
|
* A compound of types, such as an intersection or union.
|
|
7
12
|
*
|
|
@@ -10,30 +15,93 @@ import { Type } from "./Type.js";
|
|
|
10
15
|
*/
|
|
11
16
|
export class AbstractCompoundType extends AbstractType {
|
|
12
17
|
/**
|
|
13
|
-
*
|
|
18
|
+
* Members.
|
|
14
19
|
*
|
|
15
20
|
* Mutable to support cycle-handling logic in the compiler.
|
|
16
21
|
*/
|
|
17
|
-
#
|
|
18
|
-
|
|
22
|
+
#members = [];
|
|
23
|
+
/**
|
|
24
|
+
* TypeScript features to generate.
|
|
25
|
+
*/
|
|
26
|
+
#tsFeatures;
|
|
27
|
+
constructor({ tsFeatures, ...superParameters }) {
|
|
19
28
|
super(superParameters);
|
|
20
|
-
this.#
|
|
29
|
+
this.#tsFeatures = tsFeatures;
|
|
21
30
|
}
|
|
22
|
-
|
|
23
|
-
this.#
|
|
31
|
+
get members() {
|
|
32
|
+
invariant(this.#members.length > 0);
|
|
33
|
+
return this.#members;
|
|
24
34
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
35
|
+
get recursive() {
|
|
36
|
+
return this.members.some((member) => member.type.recursive);
|
|
37
|
+
}
|
|
38
|
+
get tsFeatures() {
|
|
39
|
+
// Members of the compound type must have the same tsFeatures.
|
|
40
|
+
// They must also have distinct RDF types or no RDF types at all.
|
|
41
|
+
const mergedMemberTsFeatures = new Set();
|
|
42
|
+
for (let memberI = 0; memberI < this.members.length; memberI++) {
|
|
43
|
+
const member = this.members[memberI];
|
|
44
|
+
switch (member.type.kind) {
|
|
45
|
+
case "IntersectionType":
|
|
46
|
+
case "ObjectType":
|
|
47
|
+
case "UnionType":
|
|
48
|
+
break;
|
|
49
|
+
default:
|
|
50
|
+
continue;
|
|
51
|
+
}
|
|
52
|
+
if (memberI === 0) {
|
|
53
|
+
for (const tsFeature of member.type.tsFeatures) {
|
|
54
|
+
mergedMemberTsFeatures.add(tsFeature);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (member.type.tsFeatures.size !== mergedMemberTsFeatures.size) {
|
|
58
|
+
throw new Error(`${this} has a member (${member}) with different tsFeatures than the other members`);
|
|
59
|
+
}
|
|
60
|
+
for (const tsFeature of member.type.tsFeatures) {
|
|
61
|
+
if (!mergedMemberTsFeatures.has(tsFeature)) {
|
|
62
|
+
throw new Error(`${this} has a member (${member}) with different tsFeatures than the other members`);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
28
65
|
}
|
|
29
|
-
return
|
|
66
|
+
return this.#tsFeatures;
|
|
30
67
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
68
|
+
addMember(member) {
|
|
69
|
+
this.#members.push(member);
|
|
70
|
+
}
|
|
71
|
+
equals(other) {
|
|
72
|
+
// return arrayEquals(Type.equals)(this.memberTypes, other.memberTypes);
|
|
73
|
+
// Don't recurse
|
|
74
|
+
return this.shapeIdentifier.equals(other.shapeIdentifier);
|
|
34
75
|
}
|
|
35
76
|
toString() {
|
|
36
|
-
return `${this.kind}(memberTypes=[${this.
|
|
77
|
+
return `${this.kind}(memberTypes=[${this.members.map((memberType) => memberType.toString()).join(", ")}])`;
|
|
37
78
|
}
|
|
38
79
|
}
|
|
80
|
+
__decorate([
|
|
81
|
+
Memoize()
|
|
82
|
+
], AbstractCompoundType.prototype, "tsFeatures", null);
|
|
83
|
+
(function (AbstractCompoundType) {
|
|
84
|
+
function isMemberType(type) {
|
|
85
|
+
switch (type.kind) {
|
|
86
|
+
case "BlankNodeType":
|
|
87
|
+
case "IdentifierType":
|
|
88
|
+
case "IntersectionType":
|
|
89
|
+
case "IriType":
|
|
90
|
+
case "LiteralType":
|
|
91
|
+
case "ObjectType":
|
|
92
|
+
case "TermType":
|
|
93
|
+
case "UnionType":
|
|
94
|
+
return true;
|
|
95
|
+
case "DefaultValueType":
|
|
96
|
+
case "LazyObjectOptionType":
|
|
97
|
+
case "LazyObjectSetType":
|
|
98
|
+
case "LazyObjectType":
|
|
99
|
+
case "ListType":
|
|
100
|
+
case "OptionType":
|
|
101
|
+
case "SetType":
|
|
102
|
+
return false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
AbstractCompoundType.isMemberType = isMemberType;
|
|
106
|
+
})(AbstractCompoundType || (AbstractCompoundType = {}));
|
|
39
107
|
//# sourceMappingURL=AbstractCompoundType.js.map
|
|
@@ -5,10 +5,7 @@ import type { IntersectionType } from "./IntersectionType.js";
|
|
|
5
5
|
import type { IriType } from "./IriType.js";
|
|
6
6
|
import type { ListType } from "./ListType.js";
|
|
7
7
|
import type { LiteralType } from "./LiteralType.js";
|
|
8
|
-
import type { ObjectIntersectionType } from "./ObjectIntersectionType.js";
|
|
9
8
|
import type { ObjectType } from "./ObjectType.js";
|
|
10
|
-
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
11
|
-
import type { PlaceholderType } from "./PlaceholderType.js";
|
|
12
9
|
import type { TermType } from "./TermType.js";
|
|
13
10
|
import { Type } from "./Type.js";
|
|
14
11
|
import type { UnionType } from "./UnionType.js";
|
|
@@ -26,11 +23,12 @@ export declare abstract class AbstractContainerType<ItemTypeT extends AbstractCo
|
|
|
26
23
|
constructor({ itemType, ...superParameters }: {
|
|
27
24
|
itemType: ItemTypeT;
|
|
28
25
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
26
|
+
get recursive(): boolean;
|
|
29
27
|
equals(other: AbstractContainerType<ItemTypeT>): boolean;
|
|
30
28
|
toString(): string;
|
|
31
29
|
}
|
|
32
30
|
export declare namespace AbstractContainerType {
|
|
33
|
-
type ItemType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType |
|
|
31
|
+
type ItemType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | ObjectType | TermType | UnionType;
|
|
34
32
|
function isItemType(type: Type): type is ItemType;
|
|
35
33
|
}
|
|
36
34
|
//# sourceMappingURL=AbstractContainerType.d.ts.map
|