@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
|
@@ -8,17 +8,11 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
|
|
|
8
8
|
abstract readonly kind: "BigInt" | "Float" | "Int";
|
|
9
9
|
get filterFunction(): Code;
|
|
10
10
|
get filterType(): Code;
|
|
11
|
-
get expression(): Code;
|
|
12
11
|
get schemaType(): Code;
|
|
13
12
|
get valueSparqlWherePatternsFunction(): Code;
|
|
13
|
+
protected get inlineExpression(): Code;
|
|
14
14
|
jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
|
|
15
15
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
16
|
-
protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<ValueT>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<ValueT>["fromRdfResourceValuesExpressionChain"]>;
|
|
17
|
-
protected abstract fromRdfResourceValueExpression(variables: {
|
|
18
|
-
variables: {
|
|
19
|
-
value: Code;
|
|
20
|
-
};
|
|
21
|
-
}): Code;
|
|
22
16
|
}
|
|
23
17
|
export declare namespace AbstractNumericType {
|
|
24
18
|
const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
|
|
@@ -13,45 +13,35 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
|
13
13
|
export class AbstractNumericType extends AbstractPrimitiveType {
|
|
14
14
|
hashFunction = code `${this.reusables.snippets.hashNumeric}`;
|
|
15
15
|
get filterFunction() {
|
|
16
|
-
return code `${this.reusables.snippets.filterNumeric}<${this.
|
|
16
|
+
return code `${this.reusables.snippets.filterNumeric}<${this.expression}>`;
|
|
17
17
|
}
|
|
18
18
|
get filterType() {
|
|
19
|
-
return code `${this.reusables.snippets.NumericFilter}<${this.
|
|
20
|
-
}
|
|
21
|
-
get expression() {
|
|
22
|
-
if (this.primitiveIn.length > 0) {
|
|
23
|
-
return code `${joinCode(this.primitiveIn.map((value) => this.literalExpression(value)), { on: " | " })}`;
|
|
24
|
-
}
|
|
25
|
-
return code `${this.typeofs[0]}`;
|
|
19
|
+
return code `${this.reusables.snippets.NumericFilter}<${this.expression}>`;
|
|
26
20
|
}
|
|
27
21
|
get schemaType() {
|
|
28
|
-
return code `${this.reusables.snippets.NumericSchema}<${this.
|
|
22
|
+
return code `${this.reusables.snippets.NumericSchema}<${this.expression}>`;
|
|
29
23
|
}
|
|
30
24
|
get valueSparqlWherePatternsFunction() {
|
|
31
|
-
return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.
|
|
25
|
+
return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.expression}>`;
|
|
26
|
+
}
|
|
27
|
+
get inlineExpression() {
|
|
28
|
+
if (this.primitiveIn.length > 0) {
|
|
29
|
+
return code `${joinCode(this.primitiveIn.map((value) => this.literalValueExpression(value)), { on: " | " })}`;
|
|
30
|
+
}
|
|
31
|
+
return code `${this.jsTypes[0].typeof}`;
|
|
32
32
|
}
|
|
33
33
|
jsonSchema(_parameters) {
|
|
34
34
|
switch (this.primitiveIn.length) {
|
|
35
35
|
case 0:
|
|
36
|
-
return code `${this.reusables.imports.z}.${this.
|
|
36
|
+
return code `${this.reusables.imports.z}.${this.jsTypes[0].typeof}()`;
|
|
37
37
|
case 1:
|
|
38
|
-
return code `${this.reusables.imports.z}.literal(${this.
|
|
38
|
+
return code `${this.reusables.imports.z}.literal(${this.literalValueExpression(this.primitiveIn[0])})`;
|
|
39
39
|
default:
|
|
40
|
-
return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.
|
|
40
|
+
return code `${this.reusables.imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${this.reusables.imports.z}.literal(${this.literalValueExpression(value)})`), { on: "," })}])`;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
toRdfResourceValuesExpression({ variables, }) {
|
|
44
|
-
return code `[${this.reusables.snippets.literalFactory}.${this.
|
|
45
|
-
}
|
|
46
|
-
fromRdfResourceValuesExpressionChain({ variables, }) {
|
|
47
|
-
return {
|
|
48
|
-
...super.fromRdfResourceValuesExpressionChain({ variables }),
|
|
49
|
-
languageIn: undefined,
|
|
50
|
-
preferredLanguages: undefined,
|
|
51
|
-
valueTo: code `chain(values => values.chainMap(value => ${this.fromRdfResourceValueExpression({
|
|
52
|
-
variables: { value: code `value` },
|
|
53
|
-
})}))`,
|
|
54
|
-
};
|
|
44
|
+
return code `[${this.reusables.snippets.literalFactory}.${this.jsTypes[0].typeof}(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
|
|
55
45
|
}
|
|
56
46
|
}
|
|
57
47
|
__decorate([
|
|
@@ -60,15 +50,15 @@ __decorate([
|
|
|
60
50
|
__decorate([
|
|
61
51
|
Memoize()
|
|
62
52
|
], AbstractNumericType.prototype, "filterType", null);
|
|
63
|
-
__decorate([
|
|
64
|
-
Memoize()
|
|
65
|
-
], AbstractNumericType.prototype, "expression", null);
|
|
66
53
|
__decorate([
|
|
67
54
|
Memoize()
|
|
68
55
|
], AbstractNumericType.prototype, "schemaType", null);
|
|
69
56
|
__decorate([
|
|
70
57
|
Memoize()
|
|
71
58
|
], AbstractNumericType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
59
|
+
__decorate([
|
|
60
|
+
Memoize()
|
|
61
|
+
], AbstractNumericType.prototype, "inlineExpression", null);
|
|
72
62
|
(function (AbstractNumericType) {
|
|
73
63
|
AbstractNumericType.JsonType = AbstractPrimitiveType.JsonType;
|
|
74
64
|
})(AbstractNumericType || (AbstractNumericType = {}));
|
|
@@ -20,9 +20,9 @@ export declare abstract class AbstractObjectSetType {
|
|
|
20
20
|
});
|
|
21
21
|
abstract readonly declaration: Code;
|
|
22
22
|
protected methodSignatures(namedObjectType: {
|
|
23
|
-
readonly alias: Maybe<string>;
|
|
24
23
|
readonly filterType: Code;
|
|
25
24
|
readonly identifierTypeAlias: Code;
|
|
25
|
+
readonly name: Maybe<string>;
|
|
26
26
|
readonly objectSetMethodNames: ObjectType.ObjectSetMethodNames;
|
|
27
27
|
}, options?: {
|
|
28
28
|
parameterNamePrefix?: string;
|
|
@@ -21,7 +21,7 @@ export class AbstractObjectSetType {
|
|
|
21
21
|
object: {
|
|
22
22
|
name: methodNames.object,
|
|
23
23
|
parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
|
|
24
|
-
returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.
|
|
24
|
+
returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.name.unsafeCoerce()}>>`,
|
|
25
25
|
},
|
|
26
26
|
objectCount: {
|
|
27
27
|
name: methodNames.objectCount,
|
|
@@ -36,7 +36,7 @@ export class AbstractObjectSetType {
|
|
|
36
36
|
objects: {
|
|
37
37
|
name: methodNames.objects,
|
|
38
38
|
parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
|
|
39
|
-
returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.
|
|
39
|
+
returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name.unsafeCoerce()}[]>>`,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -17,12 +17,13 @@ export declare abstract class AbstractPrimitiveType<ValueT extends bigint | bool
|
|
|
17
17
|
fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
|
|
18
18
|
graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
19
19
|
jsonType(): AbstractLiteralType.JsonType;
|
|
20
|
-
abstract
|
|
20
|
+
abstract literalValueExpression(literal: Literal | ValueT): Code;
|
|
21
21
|
toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
22
22
|
}
|
|
23
23
|
export declare namespace AbstractPrimitiveType {
|
|
24
24
|
type ConversionFunction = AbstractLiteralType.ConversionFunction;
|
|
25
25
|
type DiscriminantProperty = AbstractLiteralType.DiscriminantProperty;
|
|
26
|
+
type JsType = AbstractLiteralType.JsType;
|
|
26
27
|
const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
|
|
27
28
|
type GraphqlType = AbstractLiteralType.GraphqlType;
|
|
28
29
|
const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
|
|
@@ -24,7 +24,7 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
|
|
|
24
24
|
get schemaInitializers() {
|
|
25
25
|
let initializers = super.schemaInitializers;
|
|
26
26
|
if (this.primitiveIn.length > 0) {
|
|
27
|
-
initializers = initializers.concat(code `in: ${arrayOf(...this.primitiveIn.map((in_) => this.
|
|
27
|
+
initializers = initializers.concat(code `in: ${arrayOf(...this.primitiveIn.map((in_) => this.literalValueExpression(in_)))} as const`);
|
|
28
28
|
}
|
|
29
29
|
return initializers;
|
|
30
30
|
}
|
|
@@ -2,11 +2,9 @@ import type { BlankNode, Literal, NamedNode } from "@rdfjs/types";
|
|
|
2
2
|
import { NodeKind } from "@shaclmate/shacl-ast";
|
|
3
3
|
import { Maybe } from "purify-ts";
|
|
4
4
|
import { AbstractType } from "./AbstractType.js";
|
|
5
|
-
import type { Type } from "./Type.js";
|
|
6
|
-
import type { Typeof } from "./Typeof.js";
|
|
7
5
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
8
6
|
/**
|
|
9
|
-
* Abstract base class for
|
|
7
|
+
* Abstract base class for all types that are terms in RDF (i.e., identifiers, literals).
|
|
10
8
|
*
|
|
11
9
|
* ConstantTermT is the type of sh:hasValue and sh:in.
|
|
12
10
|
* RuntimeTermT is the type of values at runtime.
|
|
@@ -14,7 +12,7 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
14
12
|
* The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
|
|
15
13
|
*/
|
|
16
14
|
export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends AbstractType {
|
|
17
|
-
readonly
|
|
15
|
+
protected abstract readonly inlineExpression: Code;
|
|
18
16
|
readonly equalsFunction: Code;
|
|
19
17
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
20
18
|
readonly hasValues: readonly ConstantTermT[];
|
|
@@ -23,43 +21,29 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
23
21
|
readonly mutable: boolean;
|
|
24
22
|
abstract readonly nodeKinds: ReadonlySet<NodeKind>;
|
|
25
23
|
readonly recursive = false;
|
|
26
|
-
readonly referencesObjectType = false;
|
|
27
|
-
readonly typeofs: readonly Typeof[];
|
|
28
24
|
readonly validationFunction: Maybe<Code>;
|
|
29
25
|
constructor({ hasValues, in_, ...superParameters }: {
|
|
30
26
|
hasValues: readonly ConstantTermT[];
|
|
31
27
|
in_: readonly ConstantTermT[];
|
|
32
28
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
33
|
-
get
|
|
29
|
+
get declaration(): Maybe<Code>;
|
|
34
30
|
get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
|
|
31
|
+
get expression(): Code;
|
|
32
|
+
get referencesNamedType(): boolean;
|
|
35
33
|
get termTypes(): ReadonlySet<"BlankNode" | "Literal" | "NamedNode">;
|
|
36
34
|
get toRdfResourceValueTypes(): Set<"BlankNode" | "Literal" | "NamedNode">;
|
|
37
35
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
38
|
-
|
|
36
|
+
protected get schemaInitializers(): readonly Code[];
|
|
39
37
|
jsonUiSchemaElement(): Maybe<Code>;
|
|
40
38
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
41
39
|
toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
|
|
42
|
-
/**
|
|
43
|
-
* The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
|
|
44
|
-
*
|
|
45
|
-
* hasValues: test whether the values sequence has sh:hasValue values
|
|
46
|
-
* languageIn: filter the values sequence to literals with the right sh:languageIn (or runtime languageIn)
|
|
47
|
-
* valueTo: convert values in the values sequence to the appropriate term type/sub-type (literal, string, etc.)
|
|
48
|
-
*
|
|
49
|
-
* Considering the sub-expressions as a record instead of an array allows them to be selectively overridden by subclasses.
|
|
50
|
-
*/
|
|
51
|
-
protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<Type["fromRdfResourceValuesExpression"]>[0]): {
|
|
52
|
-
hasValues?: Code;
|
|
53
|
-
languageIn?: Code;
|
|
54
|
-
preferredLanguages?: Code;
|
|
55
|
-
valueTo: Code;
|
|
56
|
-
};
|
|
57
40
|
}
|
|
58
41
|
export declare namespace AbstractTermType {
|
|
59
42
|
type ConversionFunction = AbstractType.ConversionFunction;
|
|
60
43
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
61
44
|
const GraphqlType: typeof AbstractType.GraphqlType;
|
|
62
45
|
type GraphqlType = AbstractType.GraphqlType;
|
|
46
|
+
type JsType = AbstractType.JsType;
|
|
63
47
|
const JsonType: typeof AbstractType.JsonType;
|
|
64
48
|
type JsonType = AbstractType.JsonType;
|
|
65
49
|
}
|
|
@@ -8,9 +8,9 @@ import { NodeKind } from "@shaclmate/shacl-ast";
|
|
|
8
8
|
import { Maybe } from "purify-ts";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { AbstractType } from "./AbstractType.js";
|
|
11
|
-
import {
|
|
11
|
+
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
12
12
|
/**
|
|
13
|
-
* Abstract base class for
|
|
13
|
+
* Abstract base class for all types that are terms in RDF (i.e., identifiers, literals).
|
|
14
14
|
*
|
|
15
15
|
* ConstantTermT is the type of sh:hasValue and sh:in.
|
|
16
16
|
* RuntimeTermT is the type of values at runtime.
|
|
@@ -18,7 +18,6 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
|
18
18
|
* The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
|
|
19
19
|
*/
|
|
20
20
|
export class AbstractTermType extends AbstractType {
|
|
21
|
-
declaration = Maybe.empty();
|
|
22
21
|
equalsFunction = code `${this.reusables.snippets.booleanEquals}`;
|
|
23
22
|
graphqlArgs = Maybe.empty();
|
|
24
23
|
hasValues;
|
|
@@ -26,26 +25,32 @@ export class AbstractTermType extends AbstractType {
|
|
|
26
25
|
in_;
|
|
27
26
|
mutable = false;
|
|
28
27
|
recursive = false;
|
|
29
|
-
referencesObjectType = false;
|
|
30
|
-
typeofs = ["object"];
|
|
31
28
|
validationFunction = Maybe.empty();
|
|
32
29
|
constructor({ hasValues, in_, ...superParameters }) {
|
|
33
30
|
super(superParameters);
|
|
34
31
|
this.hasValues = hasValues;
|
|
35
32
|
this.in_ = in_;
|
|
36
33
|
}
|
|
37
|
-
get
|
|
38
|
-
return this.
|
|
34
|
+
get declaration() {
|
|
35
|
+
return this.name.map((name) => code `export type ${name} = ${this.inlineExpression};`);
|
|
39
36
|
}
|
|
40
37
|
get discriminantProperty() {
|
|
41
38
|
return Maybe.of({
|
|
42
|
-
descendantValues: [],
|
|
43
39
|
jsonName: "termType",
|
|
44
40
|
name: "termType",
|
|
45
|
-
|
|
46
|
-
type: "string",
|
|
41
|
+
values: [...this.nodeKinds].map(NodeKind.toTermType),
|
|
47
42
|
});
|
|
48
43
|
}
|
|
44
|
+
get expression() {
|
|
45
|
+
const name = this.name.extract();
|
|
46
|
+
if (name) {
|
|
47
|
+
return code `${name}`;
|
|
48
|
+
}
|
|
49
|
+
return this.inlineExpression;
|
|
50
|
+
}
|
|
51
|
+
get referencesNamedType() {
|
|
52
|
+
return this.name.isJust();
|
|
53
|
+
}
|
|
49
54
|
get termTypes() {
|
|
50
55
|
return new Set([...this.nodeKinds].map(NodeKind.toTermType));
|
|
51
56
|
}
|
|
@@ -55,21 +60,12 @@ export class AbstractTermType extends AbstractType {
|
|
|
55
60
|
get valueSparqlConstructTriplesFunction() {
|
|
56
61
|
return code `((_: object) => [])`;
|
|
57
62
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const chain = this.fromRdfResourceValuesExpressionChain(parameters);
|
|
65
|
-
const { variables } = parameters;
|
|
66
|
-
return joinCode([
|
|
67
|
-
variables.resourceValues,
|
|
68
|
-
chain.hasValues,
|
|
69
|
-
chain.languageIn,
|
|
70
|
-
chain.preferredLanguages,
|
|
71
|
-
chain.valueTo,
|
|
72
|
-
].filter((_) => _ !== undefined), { on: "." });
|
|
63
|
+
get schemaInitializers() {
|
|
64
|
+
let initializers = super.schemaInitializers;
|
|
65
|
+
if (this.hasValues.length > 0) {
|
|
66
|
+
initializers = initializers.concat(code `hasValues: ${arrayOf(...this.hasValues.map((hasValue) => this.rdfjsTermExpression(hasValue)))}`);
|
|
67
|
+
}
|
|
68
|
+
return initializers;
|
|
73
69
|
}
|
|
74
70
|
jsonUiSchemaElement() {
|
|
75
71
|
return Maybe.empty();
|
|
@@ -80,43 +76,16 @@ export class AbstractTermType extends AbstractType {
|
|
|
80
76
|
toStringExpression({ variables, }) {
|
|
81
77
|
return code `${variables.value}.toString()`;
|
|
82
78
|
}
|
|
83
|
-
/**
|
|
84
|
-
* The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
|
|
85
|
-
*
|
|
86
|
-
* hasValues: test whether the values sequence has sh:hasValue values
|
|
87
|
-
* languageIn: filter the values sequence to literals with the right sh:languageIn (or runtime languageIn)
|
|
88
|
-
* valueTo: convert values in the values sequence to the appropriate term type/sub-type (literal, string, etc.)
|
|
89
|
-
*
|
|
90
|
-
* Considering the sub-expressions as a record instead of an array allows them to be selectively overridden by subclasses.
|
|
91
|
-
*/
|
|
92
|
-
fromRdfResourceValuesExpressionChain({ variables, }) {
|
|
93
|
-
let valueToExpression;
|
|
94
|
-
if (this.in_.length > 0) {
|
|
95
|
-
valueToExpression = code `value.toTerm([${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}])`;
|
|
96
|
-
}
|
|
97
|
-
else if (this.nodeKinds.size < 3) {
|
|
98
|
-
const eitherTypeParameters = code `<Error, ${this.expression}>`;
|
|
99
|
-
valueToExpression = code `value.toTerm().chain(term => {
|
|
100
|
-
switch (term.termType) {
|
|
101
|
-
${[...this.nodeKinds].map((nodeKind) => `case "${NodeKind.toTermType(nodeKind)}":`).join("\n")} return ${this.reusables.imports.Either}.of${eitherTypeParameters}(term);
|
|
102
|
-
default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.expression}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
|
|
103
|
-
}})`;
|
|
104
|
-
}
|
|
105
|
-
else {
|
|
106
|
-
valueToExpression = code `value.toTerm()`;
|
|
107
|
-
}
|
|
108
|
-
return {
|
|
109
|
-
hasValues: this.hasValues.length > 0
|
|
110
|
-
? code `\
|
|
111
|
-
chain(values => ${this.reusables.imports.Either}.sequence([${joinCode(this.hasValues.map((hasValue) => this.rdfjsTermExpression(hasValue)), { on: ", " })}].map(hasValue => values.find(value => value.term.equals(hasValue)))).map(() => values))`
|
|
112
|
-
: undefined,
|
|
113
|
-
valueTo: code `chain(values => values.chainMap(value => ${valueToExpression}))`,
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
79
|
}
|
|
80
|
+
__decorate([
|
|
81
|
+
Memoize()
|
|
82
|
+
], AbstractTermType.prototype, "declaration", null);
|
|
117
83
|
__decorate([
|
|
118
84
|
Memoize()
|
|
119
85
|
], AbstractTermType.prototype, "discriminantProperty", null);
|
|
86
|
+
__decorate([
|
|
87
|
+
Memoize()
|
|
88
|
+
], AbstractTermType.prototype, "expression", null);
|
|
120
89
|
__decorate([
|
|
121
90
|
Memoize()
|
|
122
91
|
], AbstractTermType.prototype, "termTypes", null);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
1
2
|
import type { Maybe } from "purify-ts";
|
|
2
3
|
import type { Logger } from "ts-log";
|
|
3
4
|
import type { Reusables } from "./Reusables.js";
|
|
4
5
|
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
5
6
|
import type { TsGenerator } from "./TsGenerator.js";
|
|
6
|
-
import type { Typeof } from "./Typeof.js";
|
|
7
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
8
8
|
/**
|
|
9
9
|
* Abstract base class all types.
|
|
@@ -12,10 +12,6 @@ export declare abstract class AbstractType {
|
|
|
12
12
|
protected readonly configuration: TsGenerator.Configuration;
|
|
13
13
|
protected readonly logger: Logger;
|
|
14
14
|
protected readonly reusables: Reusables;
|
|
15
|
-
/**
|
|
16
|
-
* Alias for this type.
|
|
17
|
-
*/
|
|
18
|
-
readonly alias: Maybe<string>;
|
|
19
15
|
/**
|
|
20
16
|
* Comment from rdfs:comment.
|
|
21
17
|
*/
|
|
@@ -39,7 +35,7 @@ export declare abstract class AbstractType {
|
|
|
39
35
|
*/
|
|
40
36
|
abstract readonly discriminantProperty: Maybe<AbstractType.DiscriminantProperty>;
|
|
41
37
|
/**
|
|
42
|
-
* A function (reference or
|
|
38
|
+
* A function (reference or literal) that compares two property values of this type, returning a
|
|
43
39
|
* $EqualsResult.
|
|
44
40
|
*/
|
|
45
41
|
abstract readonly equalsFunction: Code;
|
|
@@ -48,7 +44,7 @@ export declare abstract class AbstractType {
|
|
|
48
44
|
*/
|
|
49
45
|
abstract readonly expression: Code;
|
|
50
46
|
/**
|
|
51
|
-
* A function (reference or
|
|
47
|
+
* A function (reference or literal) that takes a filter of filterType (below) and a value of this type
|
|
52
48
|
* and returns true if the value passes the filter.
|
|
53
49
|
*/
|
|
54
50
|
abstract readonly filterFunction: Code;
|
|
@@ -56,6 +52,27 @@ export declare abstract class AbstractType {
|
|
|
56
52
|
* Composite type for filtering instances of this type e.g., SomeObject.Filter with filters for each property.
|
|
57
53
|
*/
|
|
58
54
|
abstract readonly filterType: Code;
|
|
55
|
+
/**
|
|
56
|
+
* A FromRdfResourceValuesFunction (reference or literal) that converts a Either<Error, rdfjsResource.Resource.Values> to a
|
|
57
|
+
* Either<Error, rdfjsResource.Resource.Values<this type>>.
|
|
58
|
+
*
|
|
59
|
+
* These functions are used to deserialize property values in an ObjectType, either directly (a property with this type) or indirectly (a property with a type like OptionType
|
|
60
|
+
* that has a type parameter of this type).
|
|
61
|
+
*
|
|
62
|
+
* Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
|
|
63
|
+
* to be considered valid. Similarly, values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
|
|
64
|
+
* (if it exists) is always of the first preferred language.
|
|
65
|
+
*
|
|
66
|
+
* The function takes two parameters, a rdfjsResource.Resource.Values and a parameters object with the following parameters:
|
|
67
|
+
* context: unanticipated properties (...) passed to Object.fromRdf
|
|
68
|
+
* focusResource: the Resource passed to Object.fromRdf
|
|
69
|
+
* graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
|
|
70
|
+
* ignoreRdfType: whether the RDF type of objects/object unions should be ignored
|
|
71
|
+
* objectSet: the ObjectSet passed to Object.fromRdf
|
|
72
|
+
* preferredLanguages: the preferred languages array (e.g., ["en"]) passed to Object.fromRdf
|
|
73
|
+
* propertyPath: the PropertyPath of the object's property
|
|
74
|
+
*/
|
|
75
|
+
abstract readonly fromRdfResourceValuesFunction: Code;
|
|
59
76
|
/**
|
|
60
77
|
* Declarations for GraphQL arguments to pass to this the graphqlResolveExpression.
|
|
61
78
|
*/
|
|
@@ -67,9 +84,13 @@ export declare abstract class AbstractType {
|
|
|
67
84
|
*/
|
|
68
85
|
abstract readonly graphqlType: AbstractType.GraphqlType;
|
|
69
86
|
/**
|
|
70
|
-
* A function (reference or
|
|
87
|
+
* A function (reference or literal) that takes a Hasher and a value of this type, calls hasher.update on the value, and returns the Hasher.
|
|
71
88
|
*/
|
|
72
89
|
abstract readonly hashFunction: Code;
|
|
90
|
+
/**
|
|
91
|
+
* JavaScript type(s) the type.
|
|
92
|
+
*/
|
|
93
|
+
abstract readonly jsTypes: readonly AbstractType.JsType[];
|
|
73
94
|
/**
|
|
74
95
|
* Type discriminant.
|
|
75
96
|
*/
|
|
@@ -82,6 +103,10 @@ export declare abstract class AbstractType {
|
|
|
82
103
|
* Is a value of this type mutable?
|
|
83
104
|
*/
|
|
84
105
|
abstract readonly mutable: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Name for this type.
|
|
108
|
+
*/
|
|
109
|
+
readonly name: Maybe<string>;
|
|
85
110
|
/**
|
|
86
111
|
* Does this type directly or indirectly reference itself?
|
|
87
112
|
*/
|
|
@@ -89,19 +114,19 @@ export declare abstract class AbstractType {
|
|
|
89
114
|
/**
|
|
90
115
|
* Is this type an ObjectType or does it reference an object type?
|
|
91
116
|
*/
|
|
92
|
-
abstract readonly
|
|
117
|
+
abstract readonly referencesNamedType: boolean;
|
|
93
118
|
/**
|
|
94
119
|
* TypeScript type describing .schema.
|
|
95
120
|
*/
|
|
96
121
|
abstract readonly schemaType: Code;
|
|
97
122
|
/**
|
|
98
|
-
*
|
|
123
|
+
* Identifier of the shape this type was derived from.
|
|
99
124
|
*/
|
|
100
|
-
|
|
125
|
+
readonly shapeIdentifier: BlankNode | NamedNode;
|
|
101
126
|
/**
|
|
102
|
-
*
|
|
127
|
+
* The type(s) of the array elements produced by the toRdfResourceValuesExpression.
|
|
103
128
|
*/
|
|
104
|
-
abstract readonly
|
|
129
|
+
abstract readonly toRdfResourceValueTypes: ReadonlySet<"BlankNode" | "NamedNode" | "Literal">;
|
|
105
130
|
/**
|
|
106
131
|
* Function that takes
|
|
107
132
|
* - a schema of this.schemaType
|
|
@@ -115,7 +140,7 @@ export declare abstract class AbstractType {
|
|
|
115
140
|
*/
|
|
116
141
|
abstract readonly validationFunction: Maybe<Code>;
|
|
117
142
|
/**
|
|
118
|
-
* A ValueSparqlConstructTriplesFunction (reference or
|
|
143
|
+
* A ValueSparqlConstructTriplesFunction (reference or literal) that returns an array of sparqljs.Triple's for a property value of this type.
|
|
119
144
|
*
|
|
120
145
|
* The function takes a parameters object with the following parameters:
|
|
121
146
|
* - filter: an instance of filterType | undefined
|
|
@@ -126,7 +151,7 @@ export declare abstract class AbstractType {
|
|
|
126
151
|
*/
|
|
127
152
|
abstract readonly valueSparqlConstructTriplesFunction: Code;
|
|
128
153
|
/**
|
|
129
|
-
* A ValueSparqlWherePatternsFunction (reference or
|
|
154
|
+
* A ValueSparqlWherePatternsFunction (reference or literal) that returns an array of SparqlPattern's for a property value of this type.
|
|
130
155
|
*
|
|
131
156
|
* The function takes a parameters object with the following parameters:
|
|
132
157
|
* - filter: an instance of filterType | undefined
|
|
@@ -137,18 +162,20 @@ export declare abstract class AbstractType {
|
|
|
137
162
|
* - variablePrefix: string prefix to use for new variables
|
|
138
163
|
*/
|
|
139
164
|
abstract readonly valueSparqlWherePatternsFunction: Code;
|
|
140
|
-
constructor({
|
|
141
|
-
|
|
165
|
+
constructor({ comment, configuration, label, logger, name, reusables, shapeIdentifier, }: {
|
|
166
|
+
name: Maybe<string>;
|
|
142
167
|
comment: Maybe<string>;
|
|
143
168
|
configuration: TsGenerator.Configuration;
|
|
144
169
|
label: Maybe<string>;
|
|
145
170
|
logger: Logger;
|
|
146
171
|
reusables: Reusables;
|
|
172
|
+
shapeIdentifier: BlankNode | NamedNode;
|
|
147
173
|
});
|
|
148
174
|
/**
|
|
149
175
|
* TypeScript object describing this type, for runtime use.
|
|
150
176
|
*/
|
|
151
177
|
get schema(): Code;
|
|
178
|
+
protected get schemaExpression(): Code;
|
|
152
179
|
/**
|
|
153
180
|
* Helper to compose the result of schema along the type hierarchy.
|
|
154
181
|
*/
|
|
@@ -161,41 +188,6 @@ export declare abstract class AbstractType {
|
|
|
161
188
|
value: Code;
|
|
162
189
|
};
|
|
163
190
|
}): Code;
|
|
164
|
-
/**
|
|
165
|
-
* An expression that converts a Either<Error, rdfjsResource.Resource.Values> to a
|
|
166
|
-
* Either<Error, rdfjsResource.Resource.Values<this type>>.
|
|
167
|
-
*
|
|
168
|
-
* These expressions are used to deserialize property values in an ObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
|
|
169
|
-
* that has a type parameter of this Type).
|
|
170
|
-
*
|
|
171
|
-
* Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
|
|
172
|
-
* to be considered valid. Similar
|
|
173
|
-
*
|
|
174
|
-
* Values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
|
|
175
|
-
* (if it exists) is always of the first preferred language.
|
|
176
|
-
*
|
|
177
|
-
* variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
|
|
178
|
-
* context: unanticipated properties (...) passed to Object.fromRdf
|
|
179
|
-
* graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
|
|
180
|
-
* ignoreRdfType: whether the RDF type of objects/object unions should be ignored
|
|
181
|
-
* objectSet: the ObjectSet passed to Object.fromRdf
|
|
182
|
-
* preferredLanguages: the preferred languages array (e.g., ["en"]) passed to Object.fromRdf
|
|
183
|
-
* propertyPath: the PropertyPath of the object's property
|
|
184
|
-
* resource: the Resource passed to Object.fromRdf
|
|
185
|
-
* resourceValues: the Either<Error, rdfjsResource.Resource.Values> to be converted to values of this type
|
|
186
|
-
*/
|
|
187
|
-
abstract fromRdfResourceValuesExpression(parameters: {
|
|
188
|
-
variables: {
|
|
189
|
-
context: Code;
|
|
190
|
-
graph: Code;
|
|
191
|
-
ignoreRdfType?: boolean;
|
|
192
|
-
objectSet: Code;
|
|
193
|
-
preferredLanguages: Code;
|
|
194
|
-
propertyPath: Code;
|
|
195
|
-
resource: Code;
|
|
196
|
-
resourceValues: Code;
|
|
197
|
-
};
|
|
198
|
-
}): Code;
|
|
199
191
|
/**
|
|
200
192
|
* An expression that resolves a value of this type in the GraphQL server.
|
|
201
193
|
*/
|
|
@@ -277,14 +269,13 @@ export declare namespace AbstractType {
|
|
|
277
269
|
readonly code: Code;
|
|
278
270
|
readonly sourceTypes: {
|
|
279
271
|
readonly expression: Code;
|
|
280
|
-
readonly
|
|
272
|
+
readonly jsType: JsType;
|
|
281
273
|
}[];
|
|
282
274
|
}
|
|
283
275
|
interface DiscriminantProperty {
|
|
284
|
-
readonly descendantValues: readonly DiscriminantProperty.Value[];
|
|
285
276
|
readonly jsonName: string;
|
|
286
277
|
readonly name: string;
|
|
287
|
-
readonly
|
|
278
|
+
readonly values: readonly DiscriminantProperty.Value[];
|
|
288
279
|
}
|
|
289
280
|
namespace DiscriminantProperty {
|
|
290
281
|
type Value = number | string;
|
|
@@ -295,14 +286,46 @@ export declare namespace AbstractType {
|
|
|
295
286
|
*/
|
|
296
287
|
readonly nullable: boolean;
|
|
297
288
|
/**
|
|
298
|
-
* The
|
|
289
|
+
* The expression of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
|
|
299
290
|
*/
|
|
300
|
-
readonly
|
|
291
|
+
readonly nullableExpression: Code;
|
|
301
292
|
private readonly reusables;
|
|
302
|
-
constructor(
|
|
293
|
+
constructor(nullableExpression: Code, reusables: Reusables, options?: {
|
|
303
294
|
nullable: boolean;
|
|
304
295
|
});
|
|
305
|
-
get
|
|
296
|
+
get expression(): Code;
|
|
297
|
+
}
|
|
298
|
+
type JsType = {
|
|
299
|
+
typeof: "bigint";
|
|
300
|
+
} | {
|
|
301
|
+
typeof: "boolean";
|
|
302
|
+
} | {
|
|
303
|
+
typeof: "function";
|
|
304
|
+
} | {
|
|
305
|
+
typeof: "number";
|
|
306
|
+
} | {
|
|
307
|
+
instanceof: "Array";
|
|
308
|
+
typeof: "object";
|
|
309
|
+
} | {
|
|
310
|
+
className: Code;
|
|
311
|
+
instanceof: "class";
|
|
312
|
+
typeof: "object";
|
|
313
|
+
} | {
|
|
314
|
+
instanceof: "Date";
|
|
315
|
+
typeof: "object";
|
|
316
|
+
} | {
|
|
317
|
+
instanceof: "Maybe";
|
|
318
|
+
typeof: "object";
|
|
319
|
+
} | {
|
|
320
|
+
instanceof: "Object";
|
|
321
|
+
typeof: "object";
|
|
322
|
+
} | {
|
|
323
|
+
typeof: "string";
|
|
324
|
+
} | {
|
|
325
|
+
typeof: "undefined";
|
|
326
|
+
};
|
|
327
|
+
namespace JsType {
|
|
328
|
+
function equals(left: JsType, right: JsType): boolean;
|
|
306
329
|
}
|
|
307
330
|
class JsonType {
|
|
308
331
|
/**
|
|
@@ -310,13 +333,13 @@ export declare namespace AbstractType {
|
|
|
310
333
|
*/
|
|
311
334
|
readonly optional: boolean;
|
|
312
335
|
/**
|
|
313
|
-
* The
|
|
336
|
+
* The expression of the type when it's required i.e. -- so it should never include "| undefined".
|
|
314
337
|
*/
|
|
315
|
-
readonly
|
|
316
|
-
constructor(
|
|
338
|
+
readonly requiredExpression: Code;
|
|
339
|
+
constructor(requiredExpression: Code, parameters?: {
|
|
317
340
|
optional: boolean;
|
|
318
341
|
});
|
|
319
|
-
get
|
|
342
|
+
get expression(): Code;
|
|
320
343
|
}
|
|
321
344
|
}
|
|
322
345
|
//# sourceMappingURL=AbstractType.d.ts.map
|