@shaclmate/compiler 4.0.40 → 4.0.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -8
- package/dist/ShapesGraphToAstTransformer.js +11 -126
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstStructTypeField.d.ts +17 -0
- package/dist/_ShapesGraphToAstTransformer/{transformPropertyShapeToAstObjectTypeProperty.js → transformPropertyShapeToAstStructTypeField.js} +71 -48
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +29 -20
- package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.d.ts → transformShapeToAstStructType.d.ts} +3 -3
- package/dist/_ShapesGraphToAstTransformer/{transformShapeToAstObjectType.js → transformShapeToAstStructType.js} +35 -45
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +2 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
- package/dist/ast/AbstractCompoundType.d.ts +3 -2
- package/dist/ast/AbstractCompoundType.js +5 -5
- package/dist/ast/AbstractContainerType.d.ts +2 -2
- package/dist/ast/AbstractContainerType.js +4 -4
- package/dist/ast/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +10 -12
- package/dist/ast/{AbstractLazyObjectType.js → AbstractLazyType.js} +3 -3
- package/dist/ast/AbstractType.d.ts +1 -1
- package/dist/ast/AbstractType.js +3 -0
- package/dist/ast/Ast.d.ts +2 -6
- package/dist/ast/DefaultValueType.js +2 -1
- package/dist/ast/IntersectionType.d.ts +2 -2
- package/dist/ast/IntersectionType.js +3 -3
- package/dist/ast/LazyOptionType.d.ts +6 -0
- package/dist/ast/LazyOptionType.js +5 -0
- package/dist/ast/LazySetType.d.ts +6 -0
- package/dist/ast/LazySetType.js +5 -0
- package/dist/ast/LazyType.d.ts +5 -0
- package/dist/ast/LazyType.js +5 -0
- package/dist/ast/ListType.d.ts +2 -2
- package/dist/ast/ListType.js +5 -5
- package/dist/ast/OptionType.js +2 -1
- package/dist/ast/SetType.js +2 -1
- package/dist/ast/StructCompoundType.d.ts +12 -0
- package/dist/ast/{ObjectCompoundType.js → StructCompoundType.js} +18 -18
- package/dist/ast/StructIntersectionType.d.ts +4 -0
- package/dist/ast/StructIntersectionType.js +2 -0
- package/dist/ast/{ObjectType.d.ts → StructType.d.ts} +28 -39
- package/dist/ast/{ObjectType.js → StructType.js} +81 -156
- package/dist/ast/StructUnionType.d.ts +4 -0
- package/dist/ast/StructUnionType.js +2 -0
- package/dist/ast/Type.d.ts +5 -5
- package/dist/ast/Type.js +4 -4
- package/dist/ast/UnionType.d.ts +2 -2
- package/dist/ast/UnionType.js +3 -3
- package/dist/ast/index.d.ts +7 -7
- package/dist/ast/index.js +7 -7
- package/dist/generators/AstJsonGenerator.js +7 -3
- package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
- package/dist/generators/ts/AbstractCollectionType.d.ts +4 -11
- package/dist/generators/ts/AbstractCollectionType.js +3 -62
- package/dist/generators/ts/AbstractContainerType.d.ts +1 -2
- package/dist/generators/ts/AbstractContainerType.js +7 -10
- package/dist/generators/ts/AbstractDateType.d.ts +5 -8
- package/dist/generators/ts/AbstractDateType.js +7 -12
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
- package/dist/generators/ts/AbstractIdentifierType.js +3 -0
- package/dist/generators/ts/{AbstractLazyObjectType.d.ts → AbstractLazyType.d.ts} +8 -8
- package/dist/generators/ts/{AbstractLazyObjectType.js → AbstractLazyType.js} +30 -17
- package/dist/generators/ts/AbstractLiteralType.d.ts +3 -5
- package/dist/generators/ts/AbstractLiteralType.js +0 -21
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -7
- package/dist/generators/ts/AbstractNumericType.js +17 -27
- package/dist/generators/ts/AbstractObjectSetType.d.ts +1 -1
- package/dist/generators/ts/AbstractObjectSetType.js +2 -2
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -1
- package/dist/generators/ts/AbstractPrimitiveType.js +1 -1
- package/dist/generators/ts/AbstractTermType.d.ts +7 -23
- package/dist/generators/ts/AbstractTermType.js +27 -58
- package/dist/generators/ts/AbstractType.d.ts +86 -63
- package/dist/generators/ts/AbstractType.js +48 -22
- package/dist/generators/ts/BigDecimalType.d.ts +7 -3
- package/dist/generators/ts/BigDecimalType.js +7 -9
- package/dist/generators/ts/BigIntType.d.ts +5 -3
- package/dist/generators/ts/BigIntType.js +8 -5
- package/dist/generators/ts/BlankNodeType.d.ts +2 -7
- package/dist/generators/ts/BlankNodeType.js +4 -9
- package/dist/generators/ts/BooleanType.d.ts +6 -4
- package/dist/generators/ts/BooleanType.js +13 -15
- package/dist/generators/ts/DateTimeType.d.ts +2 -2
- package/dist/generators/ts/DateTimeType.js +14 -4
- package/dist/generators/ts/DateType.d.ts +2 -2
- package/dist/generators/ts/DateType.js +14 -4
- package/dist/generators/ts/DefaultValueType.d.ts +40 -2
- package/dist/generators/ts/DefaultValueType.js +15 -14
- package/dist/generators/ts/FloatType.d.ts +5 -3
- package/dist/generators/ts/FloatType.js +8 -5
- package/dist/generators/ts/GraphqlSchema.js +2 -2
- package/dist/generators/ts/IdentifierType.d.ts +2 -2
- package/dist/generators/ts/IdentifierType.js +8 -11
- package/dist/generators/ts/IntType.d.ts +5 -3
- package/dist/generators/ts/IntType.js +8 -5
- package/dist/generators/ts/IriType.d.ts +2 -2
- package/dist/generators/ts/IriType.js +16 -16
- package/dist/generators/ts/{LazyObjectOptionType.d.ts → LazyOptionType.d.ts} +13 -11
- package/dist/generators/ts/LazyOptionType.js +75 -0
- package/dist/generators/ts/LazySetType.d.ts +20 -0
- package/dist/generators/ts/LazySetType.js +76 -0
- package/dist/generators/ts/LazyType.d.ts +19 -0
- package/dist/generators/ts/LazyType.js +65 -0
- package/dist/generators/ts/ListType.d.ts +11 -2
- package/dist/generators/ts/ListType.js +53 -26
- package/dist/generators/ts/LiteralType.d.ts +7 -2
- package/dist/generators/ts/LiteralType.js +12 -5
- package/dist/generators/ts/ObjectType.d.ts +24 -25
- package/dist/generators/ts/ObjectType.js +303 -161
- package/dist/generators/ts/ObjectUnionType.js +42 -42
- package/dist/generators/ts/OptionType.d.ts +6 -2
- package/dist/generators/ts/OptionType.js +16 -9
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -4
- package/dist/generators/ts/SetType.d.ts +17 -2
- package/dist/generators/ts/SetType.js +85 -9
- package/dist/generators/ts/Snippets.d.ts +29 -9
- package/dist/generators/ts/Snippets.js +179 -39
- package/dist/generators/ts/StringType.d.ts +7 -4
- package/dist/generators/ts/StringType.js +23 -12
- package/dist/generators/ts/TermType.d.ts +9 -3
- package/dist/generators/ts/TermType.js +29 -7
- package/dist/generators/ts/TsGenerator.d.ts +1 -1
- package/dist/generators/ts/TsGenerator.js +62 -32
- package/dist/generators/ts/Type.d.ts +4 -4
- package/dist/generators/ts/TypeFactory.d.ts +5 -5
- package/dist/generators/ts/TypeFactory.js +90 -82
- package/dist/generators/ts/UnionType.d.ts +25 -23
- package/dist/generators/ts/UnionType.js +254 -261
- package/dist/generators/ts/ZodGenerator.d.ts +1 -1
- package/dist/generators/ts/ZodGenerator.js +29 -14
- package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +28 -16
- package/dist/generators/ts/_ObjectType/AbstractProperty.js +1 -24
- package/dist/generators/ts/_ObjectType/DiscriminantProperty.d.ts +15 -17
- package/dist/generators/ts/_ObjectType/DiscriminantProperty.js +24 -54
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +8 -2
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +48 -20
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionExpression.js +28 -0
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionExpression.js +15 -0
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionExpression.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_filterTypeDeclaration.js → ObjectType_filterTypeExpression.js} +5 -10
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_focusSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionExpression.js} +5 -13
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_focusSparqlWherePatternsFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/{ObjectType_focusSparqlWherePatternsFunctionDeclaration.js → ObjectType_focusSparqlWherePatternsFunctionExpression.js} +8 -31
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionExpression.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionExpression.js +43 -0
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_graphqlTypeVariableStatement.js → ObjectType_graphqlTypeExpression.js} +6 -13
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionExpression.js +30 -0
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_identifierTypeDeclarations.js +13 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +11 -8
- package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +1 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.js +2 -6
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaExpression.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeExpression.js +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionExpression.js +17 -0
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.js +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaExpression.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaTypeExpression.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +5 -9
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +4 -8
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionExpression.js +14 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_toRdfResourceFunctionDeclaration.js → ObjectType_toRdfResourceFunctionExpression.js} +7 -13
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionExpression.js +7 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toStringRecordFunctionExpression.js +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts → ObjectType_valueSparqlConstructTriplesFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionExpression.js +8 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts → ObjectType_valueSparqlWherePatternsFunctionExpression.d.ts} +2 -3
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionExpression.js +10 -0
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +9 -2
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +70 -38
- package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +4 -3
- package/dist/generators/ts/_snippets/snippets_DateSchema.js +4 -3
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +6 -5
- package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +2 -1
- package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -0
- package/dist/generators/ts/_snippets/snippets_Lazy.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_Lazy.js +22 -0
- package/dist/generators/ts/_snippets/snippets_LazyOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_LazyOption.js +25 -0
- package/dist/generators/ts/_snippets/snippets_LazySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_LazySet.js +40 -0
- package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +1 -3
- package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -0
- package/dist/generators/ts/_snippets/snippets_NumericSchema.js +2 -1
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +6 -8
- package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +32 -32
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_StringSchema.js +5 -3
- package/dist/generators/ts/_snippets/snippets_TermFilter.js +3 -3
- package/dist/generators/ts/_snippets/snippets_TermSchema.js +4 -2
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_bigDecimalFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_bigIntFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_blankNodeFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_booleanFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazy.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazy.js +15 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyOption.js +33 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazySet.js +27 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
- package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_dateFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_dateTimeFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueFromRdfResourceValues.js +10 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_filterNumeric.js +1 -1
- package/dist/generators/ts/_snippets/snippets_filterTerm.js +1 -2
- package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_floatFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identifierFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_intFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_iriFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_listFromRdfResourceValues.js +15 -0
- package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_literalFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_maybeFromRdfResourceValues.js +11 -0
- package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_mutableListFromRdfResourceValues.js +8 -0
- package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_mutableSetFromRdfResourceValues.js +8 -0
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_setFromRdfResourceValues.js +9 -0
- package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +13 -7
- package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_stringFromRdfResourceValues.js +6 -0
- package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_termFromRdfResourceValues.js +17 -0
- package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_termLikeFromRdfResourceValues.js +60 -0
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
- package/dist/input/generated.d.ts +1116 -400
- package/dist/input/generated.js +1879 -1917
- package/package.json +2 -4
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +0 -9
- package/dist/ast/LazyObjectOptionType.d.ts +0 -6
- package/dist/ast/LazyObjectOptionType.js +0 -5
- package/dist/ast/LazyObjectSetType.d.ts +0 -6
- package/dist/ast/LazyObjectSetType.js +0 -5
- package/dist/ast/LazyObjectType.d.ts +0 -5
- package/dist/ast/LazyObjectType.js +0 -5
- package/dist/ast/ObjectCompoundType.d.ts +0 -12
- package/dist/ast/ObjectIntersectionType.d.ts +0 -4
- package/dist/ast/ObjectIntersectionType.js +0 -2
- package/dist/ast/ObjectUnionType.d.ts +0 -4
- package/dist/ast/ObjectUnionType.js +0 -2
- package/dist/generators/ts/LazyObjectOptionType.js +0 -62
- package/dist/generators/ts/LazyObjectSetType.d.ts +0 -20
- package/dist/generators/ts/LazyObjectSetType.js +0 -61
- package/dist/generators/ts/LazyObjectType.d.ts +0 -19
- package/dist/generators/ts/LazyObjectType.js +0 -53
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +0 -65
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.js +0 -23
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.js +0 -24
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +0 -43
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.js +0 -10
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +0 -45
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +0 -16
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -31
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +0 -16
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +0 -17
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +0 -14
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +0 -41
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.js +0 -36
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +0 -11
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +0 -13
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +0 -27
- package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_LazyObject.js +0 -22
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +0 -25
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +0 -40
- package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +0 -15
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +0 -31
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +0 -25
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +0 -15
- package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +0 -23
|
@@ -5,52 +5,27 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { PropertyPath } from "@rdfx/resource";
|
|
8
|
-
import { NTriplesIdentifier } from "@rdfx/string";
|
|
9
|
-
import genericToposort from "toposort";
|
|
10
8
|
import { invariant } from "ts-invariant";
|
|
11
9
|
import { Memoize } from "typescript-memoize";
|
|
12
10
|
import { AbstractType } from "./AbstractType.js";
|
|
13
11
|
import { arrayEquals } from "./equals.js";
|
|
14
12
|
import { Type } from "./Type.js";
|
|
15
|
-
export class
|
|
13
|
+
export class StructType extends AbstractType {
|
|
16
14
|
/**
|
|
17
|
-
*
|
|
15
|
+
* Fields of this StructType.
|
|
18
16
|
*
|
|
19
17
|
* Mutable to support cycle-handling logic in the compiler.
|
|
20
18
|
*/
|
|
21
|
-
#
|
|
19
|
+
#fields = [];
|
|
20
|
+
fieldNames = new Set();
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
* Mutable to support cycle-handling logic in the compiler.
|
|
26
|
-
*/
|
|
27
|
-
#childObjectTypes = [];
|
|
28
|
-
/**
|
|
29
|
-
* Descendant (children, their children, ad nauseum) ObjectTypes of this ObjectType.
|
|
30
|
-
*
|
|
31
|
-
* Mutable to support cycle-handling logic in the compiler.
|
|
32
|
-
*/
|
|
33
|
-
#descendantObjectTypes = [];
|
|
34
|
-
/**
|
|
35
|
-
* Immediate parent ObjectTypes of this Object types.
|
|
36
|
-
*
|
|
37
|
-
* Mutable to support cycle-handling logic in the compiler.
|
|
38
|
-
*/
|
|
39
|
-
#parentObjectTypes = [];
|
|
40
|
-
/**
|
|
41
|
-
* Properties of this ObjectType.
|
|
42
|
-
*
|
|
43
|
-
* Mutable to support cycle-handling logic in the compiler.
|
|
44
|
-
*/
|
|
45
|
-
#properties = [];
|
|
46
|
-
/**
|
|
47
|
-
* If true, the code for this ObjectType is defined externally and should not be generated.
|
|
22
|
+
* If true, the code for this StructType is defined externally and should not be generated.
|
|
48
23
|
*
|
|
49
24
|
* Defaults to false.
|
|
50
25
|
*/
|
|
51
26
|
extern;
|
|
52
27
|
/**
|
|
53
|
-
* The expected rdf:type of instances of this
|
|
28
|
+
* The expected rdf:type of instances of this StructType.
|
|
54
29
|
*
|
|
55
30
|
* This is usually the identifier of an sh:NodeShape that is also an rdfs:Class (i.e., a node shape with implicit
|
|
56
31
|
* class targets).
|
|
@@ -63,7 +38,7 @@ export class ObjectType extends AbstractType {
|
|
|
63
38
|
/**
|
|
64
39
|
* Type discriminant.
|
|
65
40
|
*/
|
|
66
|
-
kind = "
|
|
41
|
+
kind = "Struct";
|
|
67
42
|
nodeKinds = nodeKinds;
|
|
68
43
|
/**
|
|
69
44
|
* Was this type synthesized or did it come from SHACL?
|
|
@@ -79,7 +54,7 @@ export class ObjectType extends AbstractType {
|
|
|
79
54
|
/**
|
|
80
55
|
* TypeScript imports to add to generated code.
|
|
81
56
|
*
|
|
82
|
-
* This is often used in conjunction with extern=true to import the extern'd
|
|
57
|
+
* This is often used in conjunction with extern=true to import the extern'd StructType code in order for generated
|
|
83
58
|
* code to reference it.
|
|
84
59
|
*
|
|
85
60
|
* import { MyType } from "./MyType.js"
|
|
@@ -94,48 +69,26 @@ export class ObjectType extends AbstractType {
|
|
|
94
69
|
this.toRdfTypes = toRdfTypes;
|
|
95
70
|
this.tsImports = tsImports;
|
|
96
71
|
}
|
|
97
|
-
get
|
|
98
|
-
return this.#
|
|
99
|
-
}
|
|
100
|
-
get childObjectTypes() {
|
|
101
|
-
return this.#childObjectTypes;
|
|
102
|
-
}
|
|
103
|
-
get descendantObjectTypes() {
|
|
104
|
-
return this.#descendantObjectTypes;
|
|
105
|
-
}
|
|
106
|
-
get parentObjectTypes() {
|
|
107
|
-
return this.#parentObjectTypes;
|
|
108
|
-
}
|
|
109
|
-
get properties() {
|
|
110
|
-
return this.#properties;
|
|
72
|
+
get fields() {
|
|
73
|
+
return this.#fields;
|
|
111
74
|
}
|
|
112
75
|
get recursive() {
|
|
113
|
-
return this.
|
|
114
|
-
}
|
|
115
|
-
addAncestorObjectTypes(...ancestorObjectTypes) {
|
|
116
|
-
this.#ancestorObjectTypes.push(...ancestorObjectTypes);
|
|
117
|
-
}
|
|
118
|
-
addChildObjectTypes(...childObjectTypes) {
|
|
119
|
-
this.#childObjectTypes.push(...childObjectTypes);
|
|
120
|
-
}
|
|
121
|
-
addDescendantObjectTypes(...descendantObjectTypes) {
|
|
122
|
-
this.#descendantObjectTypes.push(...descendantObjectTypes);
|
|
123
|
-
}
|
|
124
|
-
addParentObjectTypes(...parentObjectTypes) {
|
|
125
|
-
this.#parentObjectTypes.push(...parentObjectTypes);
|
|
76
|
+
return this.fields.some((field) => field.recursive);
|
|
126
77
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
invariant(
|
|
78
|
+
addFields(...fields) {
|
|
79
|
+
for (const field of fields) {
|
|
80
|
+
invariant(Object.is(field.structType, this), "field has unexpected .structType");
|
|
81
|
+
invariant(!this.fieldNames.has(field.name), `${field.structType.shapeIdentifier}: duplicate field name: ${field.name}`);
|
|
82
|
+
this.#fields.push(field);
|
|
83
|
+
this.fieldNames.add(field.name);
|
|
131
84
|
}
|
|
132
85
|
}
|
|
133
86
|
equals(other) {
|
|
134
87
|
// Don't recurse
|
|
135
88
|
return this.shapeIdentifier.equals(other.shapeIdentifier);
|
|
136
89
|
}
|
|
137
|
-
|
|
138
|
-
this.#
|
|
90
|
+
sortFields() {
|
|
91
|
+
this.#fields.sort((left, right) => {
|
|
139
92
|
if (left.order < right.order) {
|
|
140
93
|
return -1;
|
|
141
94
|
}
|
|
@@ -150,18 +103,14 @@ export class ObjectType extends AbstractType {
|
|
|
150
103
|
...super.toJSON(),
|
|
151
104
|
fromRdfType: this.fromRdfType.extract(),
|
|
152
105
|
identifierType: this.identifierType.toJSON(),
|
|
153
|
-
parentObjectTypes: this.parentObjectTypes.length > 0
|
|
154
|
-
? this.parentObjectTypes.map((parentObjectType) => parentObjectType.name.extract() ??
|
|
155
|
-
parentObjectType.shapeIdentifier)
|
|
156
|
-
: undefined,
|
|
157
106
|
synthetic: this.synthetic ? true : undefined,
|
|
158
107
|
toRdfTypes: this.toRdfTypes.length > 0 ? this.toRdfTypes : undefined,
|
|
159
108
|
};
|
|
160
109
|
}
|
|
161
110
|
}
|
|
162
111
|
const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
163
|
-
(function (
|
|
164
|
-
class
|
|
112
|
+
(function (StructType) {
|
|
113
|
+
class Field {
|
|
165
114
|
/**
|
|
166
115
|
* Documentation comment from rdfs:comment.
|
|
167
116
|
*/
|
|
@@ -171,7 +120,7 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
171
120
|
*/
|
|
172
121
|
description;
|
|
173
122
|
/**
|
|
174
|
-
* Should the
|
|
123
|
+
* Should the field and its value be displayed in a toString()-type representation?
|
|
175
124
|
*/
|
|
176
125
|
display;
|
|
177
126
|
/**
|
|
@@ -179,42 +128,42 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
179
128
|
*/
|
|
180
129
|
label;
|
|
181
130
|
/**
|
|
182
|
-
* The
|
|
131
|
+
* The field should be mutable in generated code i.e., it should be re-assignable. The field value may or may
|
|
183
132
|
* not be mutable.
|
|
184
133
|
*/
|
|
185
134
|
mutable;
|
|
186
135
|
/**
|
|
187
|
-
* Name of this
|
|
136
|
+
* Name of this field, derived from sh:name or shaclmate:name.
|
|
188
137
|
*/
|
|
189
138
|
name;
|
|
190
139
|
/**
|
|
191
|
-
*
|
|
192
|
-
*/
|
|
193
|
-
objectType;
|
|
194
|
-
/**
|
|
195
|
-
* Relative order of this property, derived from sh:order.
|
|
140
|
+
* Relative order of this field, derived from sh:order.
|
|
196
141
|
*/
|
|
197
142
|
order;
|
|
198
143
|
/**
|
|
199
|
-
* SHACL property path (https://www.w3.org/TR/shacl/#
|
|
144
|
+
* SHACL property path (https://www.w3.org/TR/shacl/#field-paths)
|
|
200
145
|
*/
|
|
201
146
|
path;
|
|
202
147
|
/**
|
|
203
|
-
* Identifier of the
|
|
148
|
+
* Identifier of the field shape.
|
|
204
149
|
*/
|
|
205
150
|
shapeIdentifier;
|
|
206
151
|
/**
|
|
207
|
-
*
|
|
152
|
+
* StructType this field belongs to.
|
|
153
|
+
*/
|
|
154
|
+
structType;
|
|
155
|
+
/**
|
|
156
|
+
* Type of this field.
|
|
208
157
|
*/
|
|
209
158
|
type;
|
|
210
|
-
constructor({ comment, description, display, label, mutable, name,
|
|
159
|
+
constructor({ comment, description, display, label, mutable, name, order, path, shapeIdentifier, structType, type, }) {
|
|
211
160
|
this.comment = comment;
|
|
212
161
|
this.description = description;
|
|
213
162
|
this.display = display;
|
|
214
163
|
this.label = label;
|
|
215
164
|
this.mutable = mutable;
|
|
216
165
|
this.name = name;
|
|
217
|
-
this.
|
|
166
|
+
this.structType = structType;
|
|
218
167
|
this.order = order;
|
|
219
168
|
this.path = path;
|
|
220
169
|
this.shapeIdentifier = shapeIdentifier;
|
|
@@ -224,35 +173,35 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
224
173
|
return this.shapeIdentifier.equals(other.shapeIdentifier);
|
|
225
174
|
}
|
|
226
175
|
/**
|
|
227
|
-
* Does the
|
|
176
|
+
* Does the field directly or indirectly reference the StructType itself?
|
|
228
177
|
*/
|
|
229
178
|
get recursive() {
|
|
230
179
|
const DEBUG = false;
|
|
231
|
-
const
|
|
232
|
-
const
|
|
180
|
+
const rootField = this;
|
|
181
|
+
const rootStructType = this.structType;
|
|
233
182
|
function helper(stack) {
|
|
234
183
|
const currentStackFrame = stack.at(-1);
|
|
235
|
-
const {
|
|
184
|
+
const { field, fieldType, structType } = currentStackFrame;
|
|
236
185
|
if (DEBUG) {
|
|
237
186
|
process.stderr.write(`${[
|
|
238
187
|
stack.length.toString(),
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
? `[${propertyType.map(Type.toString).join(", ")}]`
|
|
188
|
+
rootField,
|
|
189
|
+
rootStructType,
|
|
190
|
+
field,
|
|
191
|
+
fieldType
|
|
192
|
+
? `[${fieldType.map(Type.toString).join(", ")}]`
|
|
245
193
|
: "undefined",
|
|
194
|
+
structType,
|
|
246
195
|
].join(",")}\n`);
|
|
247
196
|
}
|
|
248
197
|
for (const lowerStackFrame of stack.slice(0, -1)) {
|
|
249
|
-
if (!Type.equals(currentStackFrame.
|
|
198
|
+
if (!Type.equals(currentStackFrame.structType, lowerStackFrame.structType)) {
|
|
250
199
|
continue;
|
|
251
200
|
}
|
|
252
|
-
if (!currentStackFrame.
|
|
201
|
+
if (!currentStackFrame.field.equals(lowerStackFrame.field)) {
|
|
253
202
|
continue;
|
|
254
203
|
}
|
|
255
|
-
if (!arrayEquals(Type.equals)(currentStackFrame.
|
|
204
|
+
if (!arrayEquals(Type.equals)(currentStackFrame.fieldType ?? [], lowerStackFrame.fieldType ?? [])) {
|
|
256
205
|
continue;
|
|
257
206
|
}
|
|
258
207
|
// We've seen this combination before and don't want to recurse further, to avoid infinite recursion
|
|
@@ -261,49 +210,49 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
261
210
|
}
|
|
262
211
|
return true;
|
|
263
212
|
}
|
|
264
|
-
if (!
|
|
213
|
+
if (!fieldType) {
|
|
265
214
|
return helper(stack.concat({
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
215
|
+
field,
|
|
216
|
+
fieldType: [field.type],
|
|
217
|
+
structType,
|
|
269
218
|
}));
|
|
270
219
|
}
|
|
271
|
-
invariant(
|
|
272
|
-
const
|
|
273
|
-
switch (
|
|
220
|
+
invariant(fieldType.length > 0);
|
|
221
|
+
const currentFieldType = fieldType.at(-1);
|
|
222
|
+
switch (currentFieldType.kind) {
|
|
274
223
|
case "BlankNode":
|
|
275
224
|
case "Identifier":
|
|
276
225
|
case "Iri":
|
|
277
226
|
case "Literal":
|
|
278
227
|
case "Term":
|
|
279
228
|
return false;
|
|
280
|
-
case "
|
|
281
|
-
case "
|
|
282
|
-
case "
|
|
229
|
+
case "LazyOption":
|
|
230
|
+
case "LazySet":
|
|
231
|
+
case "Lazy": {
|
|
283
232
|
if (helper(stack.concat({
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
233
|
+
field,
|
|
234
|
+
fieldType: fieldType.concat(currentFieldType.partialType),
|
|
235
|
+
structType,
|
|
287
236
|
}))) {
|
|
288
237
|
return true;
|
|
289
238
|
}
|
|
290
239
|
if (helper(stack.concat({
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
240
|
+
field,
|
|
241
|
+
fieldType: fieldType.concat(currentFieldType.resolveType),
|
|
242
|
+
structType,
|
|
294
243
|
}))) {
|
|
295
244
|
return true;
|
|
296
245
|
}
|
|
297
246
|
return false;
|
|
298
247
|
}
|
|
299
|
-
case "
|
|
248
|
+
case "Struct": {
|
|
300
249
|
if (DEBUG) {
|
|
301
|
-
process.stderr.write(`recurse into ${
|
|
250
|
+
process.stderr.write(`recurse into ${currentFieldType}`);
|
|
302
251
|
}
|
|
303
|
-
for (const
|
|
252
|
+
for (const field of currentFieldType.fields) {
|
|
304
253
|
if (helper(stack.concat({
|
|
305
|
-
|
|
306
|
-
|
|
254
|
+
structType: currentFieldType,
|
|
255
|
+
field,
|
|
307
256
|
}))) {
|
|
308
257
|
return true;
|
|
309
258
|
}
|
|
@@ -313,13 +262,13 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
313
262
|
case "Intersection":
|
|
314
263
|
case "Union": {
|
|
315
264
|
if (DEBUG) {
|
|
316
|
-
process.stderr.write(`recurse into ${
|
|
265
|
+
process.stderr.write(`recurse into ${currentFieldType}`);
|
|
317
266
|
}
|
|
318
|
-
for (const member of
|
|
267
|
+
for (const member of currentFieldType.members) {
|
|
319
268
|
if (helper(stack.concat({
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
269
|
+
field,
|
|
270
|
+
fieldType: fieldType.concat(member.type),
|
|
271
|
+
structType,
|
|
323
272
|
}))) {
|
|
324
273
|
return true;
|
|
325
274
|
}
|
|
@@ -331,13 +280,13 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
331
280
|
case "Option":
|
|
332
281
|
case "Set":
|
|
333
282
|
return helper(stack.concat({
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
283
|
+
field,
|
|
284
|
+
fieldType: fieldType.concat(currentFieldType.itemType),
|
|
285
|
+
structType,
|
|
337
286
|
}));
|
|
338
287
|
}
|
|
339
288
|
}
|
|
340
|
-
return helper([{
|
|
289
|
+
return helper([{ structType: rootStructType, field: rootField }]);
|
|
341
290
|
}
|
|
342
291
|
toJSON() {
|
|
343
292
|
return {
|
|
@@ -359,31 +308,7 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
359
308
|
}
|
|
360
309
|
__decorate([
|
|
361
310
|
Memoize()
|
|
362
|
-
],
|
|
363
|
-
|
|
364
|
-
})(
|
|
365
|
-
|
|
366
|
-
function toposort(objectTypes) {
|
|
367
|
-
const objectTypesByShapeIdentifier = {};
|
|
368
|
-
const objectTypeGraphNodes = [];
|
|
369
|
-
const objectTypeGraphEdges = [];
|
|
370
|
-
for (const objectType of objectTypes) {
|
|
371
|
-
const objectTypeShapeIdentifier = NTriplesIdentifier.stringify(objectType.shapeIdentifier);
|
|
372
|
-
invariant(!objectTypesByShapeIdentifier[objectTypeShapeIdentifier]);
|
|
373
|
-
objectTypesByShapeIdentifier[objectTypeShapeIdentifier] = objectType;
|
|
374
|
-
objectTypeGraphNodes.push(objectTypeShapeIdentifier);
|
|
375
|
-
for (const parentAstObjectType of objectType.parentObjectTypes) {
|
|
376
|
-
objectTypeGraphEdges.push([
|
|
377
|
-
objectTypeShapeIdentifier,
|
|
378
|
-
NTriplesIdentifier.stringify(parentAstObjectType.shapeIdentifier),
|
|
379
|
-
]);
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
return genericToposort
|
|
383
|
-
.array(objectTypeGraphNodes, objectTypeGraphEdges)
|
|
384
|
-
.map((objectTypeIdentifier) => objectTypesByShapeIdentifier[objectTypeIdentifier])
|
|
385
|
-
.reverse();
|
|
386
|
-
}
|
|
387
|
-
ObjectType.toposort = toposort;
|
|
388
|
-
})(ObjectType || (ObjectType = {}));
|
|
389
|
-
//# sourceMappingURL=ObjectType.js.map
|
|
311
|
+
], Field.prototype, "recursive", null);
|
|
312
|
+
StructType.Field = Field;
|
|
313
|
+
})(StructType || (StructType = {}));
|
|
314
|
+
//# sourceMappingURL=StructType.js.map
|
package/dist/ast/Type.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ import type { DefaultValueType } from "./DefaultValueType.js";
|
|
|
3
3
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
4
4
|
import type { IntersectionType } from "./IntersectionType.js";
|
|
5
5
|
import type { IriType } from "./IriType.js";
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
6
|
+
import type { LazyOptionType } from "./LazyOptionType.js";
|
|
7
|
+
import type { LazySetType } from "./LazySetType.js";
|
|
8
|
+
import type { LazyType } from "./LazyType.js";
|
|
9
9
|
import type { ListType } from "./ListType.js";
|
|
10
10
|
import type { LiteralType } from "./LiteralType.js";
|
|
11
|
-
import type { ObjectType } from "./ObjectType.js";
|
|
12
11
|
import type { OptionType } from "./OptionType.js";
|
|
13
12
|
import type { SetType } from "./SetType.js";
|
|
13
|
+
import type { StructType } from "./StructType.js";
|
|
14
14
|
import type { TermType } from "./TermType.js";
|
|
15
15
|
import type { UnionType } from "./UnionType.js";
|
|
16
|
-
export type Type = BlankNodeType | DefaultValueType | IdentifierType | IntersectionType | IriType |
|
|
16
|
+
export type Type = BlankNodeType | DefaultValueType | IdentifierType | IntersectionType | IriType | LazyOptionType | LazySetType | LazyType | ListType | LiteralType | StructType | OptionType | SetType | TermType | UnionType;
|
|
17
17
|
export declare namespace Type {
|
|
18
18
|
function equals(left: Type, right: Type): boolean;
|
|
19
19
|
}
|
package/dist/ast/Type.js
CHANGED
|
@@ -17,15 +17,15 @@ export var Type;
|
|
|
17
17
|
return left.equals(right);
|
|
18
18
|
case "Literal":
|
|
19
19
|
return left.equals(right);
|
|
20
|
-
case "
|
|
20
|
+
case "LazyOption":
|
|
21
21
|
return left.equals(right);
|
|
22
|
-
case "
|
|
22
|
+
case "LazySet":
|
|
23
23
|
return left.equals(right);
|
|
24
|
-
case "
|
|
24
|
+
case "Lazy":
|
|
25
25
|
return left.equals(right);
|
|
26
26
|
case "List":
|
|
27
27
|
return left.equals(right);
|
|
28
|
-
case "
|
|
28
|
+
case "Struct":
|
|
29
29
|
return left.equals(right);
|
|
30
30
|
case "Option":
|
|
31
31
|
return left.equals(right);
|
package/dist/ast/UnionType.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { StructUnionType } from "./StructUnionType.js";
|
|
4
4
|
/**
|
|
5
5
|
* A disjunction/union of types, corresponding to an sh:xone.
|
|
6
6
|
*/
|
|
7
7
|
export declare class UnionType<MemberTypeT extends UnionType.MemberType = UnionType.MemberType> extends AbstractCompoundType<UnionType.Member<MemberTypeT>, MemberTypeT> {
|
|
8
8
|
readonly kind = "Union";
|
|
9
|
-
|
|
9
|
+
isStructUnionType(): this is StructUnionType;
|
|
10
10
|
toJSON(): {
|
|
11
11
|
members: {
|
|
12
12
|
discriminantValue: string | number | undefined;
|
package/dist/ast/UnionType.js
CHANGED
|
@@ -4,10 +4,10 @@ import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
|
4
4
|
*/
|
|
5
5
|
export class UnionType extends AbstractCompoundType {
|
|
6
6
|
kind = "Union";
|
|
7
|
-
|
|
7
|
+
isStructUnionType() {
|
|
8
8
|
return (this.members.length > 0 &&
|
|
9
|
-
this.members.every((member) => member.type.kind === "
|
|
10
|
-
(member.type.kind === "Union" && member.type.
|
|
9
|
+
this.members.every((member) => member.type.kind === "Struct" ||
|
|
10
|
+
(member.type.kind === "Union" && member.type.isStructUnionType())));
|
|
11
11
|
}
|
|
12
12
|
toJSON() {
|
|
13
13
|
return {
|
package/dist/ast/index.d.ts
CHANGED
|
@@ -4,17 +4,17 @@ export * from "./DefaultValueType.js";
|
|
|
4
4
|
export * from "./IdentifierType.js";
|
|
5
5
|
export * from "./IntersectionType.js";
|
|
6
6
|
export * from "./IriType.js";
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
7
|
+
export * from "./LazyOptionType.js";
|
|
8
|
+
export * from "./LazySetType.js";
|
|
9
|
+
export * from "./LazyType.js";
|
|
10
10
|
export * from "./ListType.js";
|
|
11
11
|
export * from "./LiteralType.js";
|
|
12
|
-
export * from "./ObjectCompoundType.js";
|
|
13
|
-
export * from "./ObjectIntersectionType.js";
|
|
14
|
-
export * from "./ObjectType.js";
|
|
15
|
-
export * from "./ObjectUnionType.js";
|
|
16
12
|
export * from "./OptionType.js";
|
|
17
13
|
export * from "./SetType.js";
|
|
14
|
+
export * from "./StructCompoundType.js";
|
|
15
|
+
export * from "./StructIntersectionType.js";
|
|
16
|
+
export * from "./StructType.js";
|
|
17
|
+
export * from "./StructUnionType.js";
|
|
18
18
|
export * from "./TermType.js";
|
|
19
19
|
export * from "./Type.js";
|
|
20
20
|
export * from "./UnionType.js";
|
package/dist/ast/index.js
CHANGED
|
@@ -4,17 +4,17 @@ export * from "./DefaultValueType.js";
|
|
|
4
4
|
export * from "./IdentifierType.js";
|
|
5
5
|
export * from "./IntersectionType.js";
|
|
6
6
|
export * from "./IriType.js";
|
|
7
|
-
export * from "./
|
|
8
|
-
export * from "./
|
|
9
|
-
export * from "./
|
|
7
|
+
export * from "./LazyOptionType.js";
|
|
8
|
+
export * from "./LazySetType.js";
|
|
9
|
+
export * from "./LazyType.js";
|
|
10
10
|
export * from "./ListType.js";
|
|
11
11
|
export * from "./LiteralType.js";
|
|
12
|
-
export * from "./ObjectCompoundType.js";
|
|
13
|
-
export * from "./ObjectIntersectionType.js";
|
|
14
|
-
export * from "./ObjectType.js";
|
|
15
|
-
export * from "./ObjectUnionType.js";
|
|
16
12
|
export * from "./OptionType.js";
|
|
17
13
|
export * from "./SetType.js";
|
|
14
|
+
export * from "./StructCompoundType.js";
|
|
15
|
+
export * from "./StructIntersectionType.js";
|
|
16
|
+
export * from "./StructType.js";
|
|
17
|
+
export * from "./StructUnionType.js";
|
|
18
18
|
export * from "./TermType.js";
|
|
19
19
|
export * from "./Type.js";
|
|
20
20
|
export * from "./UnionType.js";
|
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
export class AstJsonGenerator {
|
|
2
2
|
generate(ast) {
|
|
3
3
|
return JSON.stringify({
|
|
4
|
-
|
|
5
|
-
...
|
|
6
|
-
|
|
4
|
+
namedTypes: ast.namedTypes.map((namedType) => ({
|
|
5
|
+
...namedType.toJSON(),
|
|
6
|
+
...(namedType.kind === "Struct"
|
|
7
|
+
? {
|
|
8
|
+
properties: namedType.fields.map((property) => property.toJSON()),
|
|
9
|
+
}
|
|
10
|
+
: {}),
|
|
7
11
|
})),
|
|
8
12
|
}, undefined, 2);
|
|
9
13
|
}
|