@shaclmate/compiler 4.0.8 → 4.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Compiler.d.ts +1 -4
- package/dist/Compiler.js +1 -5
- package/dist/ShapesGraphToAstTransformer.d.ts +2 -11
- package/dist/ShapesGraphToAstTransformer.js +25 -27
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.d.ts +3 -0
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.js +5 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.d.ts +4 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +27 -0
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +74 -19
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +45 -91
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +11 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +146 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +7 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +182 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +9 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +3 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +33 -10
- package/dist/ast/AbstractCompoundType.d.ts +26 -8
- package/dist/ast/AbstractCompoundType.js +84 -16
- package/dist/ast/AbstractContainerType.d.ts +2 -4
- package/dist/ast/AbstractContainerType.js +3 -4
- package/dist/ast/AbstractLazyObjectType.d.ts +1 -0
- package/dist/ast/AbstractLazyObjectType.js +3 -0
- package/dist/ast/AbstractTermType.d.ts +1 -0
- package/dist/ast/AbstractTermType.js +1 -0
- package/dist/ast/AbstractType.d.ts +16 -1
- package/dist/ast/AbstractType.js +11 -1
- package/dist/ast/Ast.d.ts +4 -4
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/DefaultValueType.d.ts +1 -2
- package/dist/ast/DefaultValueType.js +2 -0
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/IntersectionType.d.ts +7 -2
- package/dist/ast/IntersectionType.js +8 -0
- package/dist/ast/ListType.d.ts +2 -9
- package/dist/ast/ListType.js +1 -9
- package/dist/ast/LiteralType.d.ts +1 -0
- package/dist/ast/LiteralType.js +26 -0
- package/dist/ast/ObjectCompoundType.d.ts +12 -0
- package/dist/ast/ObjectCompoundType.js +88 -0
- package/dist/ast/ObjectIntersectionType.d.ts +3 -7
- package/dist/ast/ObjectIntersectionType.js +1 -7
- package/dist/ast/ObjectType.d.ts +14 -31
- package/dist/ast/ObjectType.js +41 -73
- package/dist/ast/ObjectUnionType.d.ts +3 -7
- package/dist/ast/ObjectUnionType.js +1 -7
- package/dist/ast/OptionType.d.ts +1 -2
- package/dist/ast/OptionType.js +2 -0
- package/dist/ast/SetType.d.ts +1 -2
- package/dist/ast/SetType.js +2 -0
- package/dist/ast/Type.d.ts +1 -4
- package/dist/ast/Type.js +0 -6
- package/dist/ast/UnionType.d.ts +11 -6
- package/dist/ast/UnionType.js +6 -4
- package/dist/ast/index.d.ts +1 -2
- package/dist/ast/index.js +1 -2
- package/dist/generators/json/AstJsonGenerator.js +16 -14
- package/dist/generators/ts/AbstractCollectionType.js +8 -10
- package/dist/generators/ts/AbstractContainerType.d.ts +8 -3
- package/dist/generators/ts/AbstractContainerType.js +9 -2
- package/dist/generators/ts/AbstractDateType.d.ts +2 -2
- package/dist/generators/ts/AbstractDateType.js +2 -2
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractIdentifierType.js +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +11 -8
- package/dist/generators/ts/AbstractLazyObjectType.js +19 -14
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +33 -0
- package/dist/generators/ts/AbstractNamedUnionType.js +193 -0
- package/dist/generators/ts/AbstractNumericType.d.ts +2 -2
- package/dist/generators/ts/AbstractNumericType.js +3 -3
- package/dist/generators/ts/AbstractTermType.d.ts +7 -4
- package/dist/generators/ts/AbstractTermType.js +7 -4
- package/dist/generators/ts/AbstractType.d.ts +29 -14
- package/dist/generators/ts/AbstractUnionType.d.ts +80 -0
- package/dist/generators/ts/AbstractUnionType.js +514 -0
- package/dist/generators/ts/AnonymousUnionType.d.ts +26 -0
- package/dist/generators/ts/AnonymousUnionType.js +56 -0
- package/dist/generators/ts/BigDecimalType.d.ts +3 -3
- package/dist/generators/ts/BigDecimalType.js +3 -3
- package/dist/generators/ts/BlankNodeType.d.ts +1 -1
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.d.ts +2 -2
- package/dist/generators/ts/BooleanType.js +2 -2
- package/dist/generators/ts/DefaultValueType.d.ts +4 -4
- package/dist/generators/ts/DefaultValueType.js +14 -13
- package/dist/generators/ts/IdentifierType.d.ts +1 -1
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +1 -1
- package/dist/generators/ts/IriType.js +1 -1
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +9 -9
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +7 -7
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +7 -8
- package/dist/generators/ts/ListType.d.ts +8 -7
- package/dist/generators/ts/ListType.js +14 -13
- package/dist/generators/ts/LiteralType.d.ts +1 -1
- package/dist/generators/ts/LiteralType.js +2 -2
- package/dist/generators/ts/NamedObjectUnionType.d.ts +35 -0
- package/dist/generators/ts/NamedObjectUnionType.js +221 -0
- package/dist/generators/ts/NamedUnionType.d.ts +11 -0
- package/dist/generators/ts/NamedUnionType.js +13 -0
- package/dist/generators/ts/ObjectType.d.ts +34 -25
- package/dist/generators/ts/ObjectType.js +62 -52
- package/dist/generators/ts/OptionType.d.ts +4 -4
- package/dist/generators/ts/OptionType.js +10 -10
- package/dist/generators/ts/SetType.d.ts +4 -4
- package/dist/generators/ts/SetType.js +13 -11
- package/dist/generators/ts/StringType.d.ts +2 -2
- package/dist/generators/ts/StringType.js +2 -2
- package/dist/generators/ts/TermType.d.ts +1 -1
- package/dist/generators/ts/TermType.js +2 -2
- package/dist/generators/ts/TsGenerator.js +23 -15
- package/dist/generators/ts/Type.d.ts +4 -3
- package/dist/generators/ts/TypeFactory.d.ts +7 -5
- package/dist/generators/ts/TypeFactory.js +117 -90
- package/dist/generators/ts/ZodGenerator.js +6 -6
- package/dist/generators/ts/_ObjectType/AbstractProperty.d.ts +3 -3
- package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.d.ts → DiscriminantProperty.d.ts} +14 -14
- package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.js → DiscriminantProperty.js} +10 -10
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +2 -2
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +7 -4
- package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.js +8 -8
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_sparqlConstructTriplesFunctionDeclaration.js → ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +6 -5
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_sparqlWherePatternsFunctionDeclarations.js → ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_fromRdfFunctionDeclaration.js → ObjectType_fromRdfResourceFunctionDeclaration.js} +6 -7
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_parseJsonFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromJsonFunctionDeclaration.js +38 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_propertiesFromRdfFunctionDeclaration.js → ObjectType_propertiesFromRdfResourceFunctionDeclaration.js} +16 -15
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +1 -2
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_toRdfFunctionOrMethodDeclaration.js → ObjectType_toRdfResourceFunctionOrMethodDeclaration.js} +10 -8
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +13 -0
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js +15 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +2 -2
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +6 -6
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.js +12 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.js +14 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +17 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.d.ts +5 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +35 -0
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.js +7 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.js +13 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_booleanEquals.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +2 -3
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +4 -3
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +4 -3
- package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +3 -2
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +4 -4
- package/dist/generators/ts/imports.d.ts +1 -1
- package/dist/generators/ts/imports.js +1 -1
- package/dist/generators/ts/objectSetDeclarations.d.ts +3 -3
- package/dist/generators/ts/objectSetDeclarations.js +15 -15
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +3 -3
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +2 -2
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +16 -17
- package/dist/generators/ts/snippets.d.ts +10 -6
- package/dist/generators/ts/snippets.js +20 -12
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +3 -3
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +7 -8
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +2 -2
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +9 -4
- package/dist/input/NodeShape.d.ts +0 -1
- package/dist/input/NodeShape.js +0 -3
- package/dist/input/ShapesGraph.d.ts +3 -2
- package/dist/input/ShapesGraph.js +12 -7
- package/dist/input/generated.d.ts +1899 -88
- package/dist/input/generated.js +676 -564
- package/package.json +3 -5
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.js +0 -45
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +0 -3
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.js +0 -2
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/index.js +0 -6
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.d.ts +0 -5
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.js +0 -9
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +0 -11
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +0 -338
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.js +0 -31
- package/dist/ast/AbstractObjectCompoundType.d.ts +0 -45
- package/dist/ast/AbstractObjectCompoundType.js +0 -180
- package/dist/ast/Curie.d.ts +0 -21
- package/dist/ast/Curie.js +0 -29
- package/dist/ast/PlaceholderType.d.ts +0 -15
- package/dist/ast/PlaceholderType.js +0 -19
- package/dist/generators/codeName.d.ts +0 -6
- package/dist/generators/codeName.js +0 -66
- package/dist/generators/ts/AbstractDeclaredType.d.ts +0 -23
- package/dist/generators/ts/AbstractDeclaredType.js +0 -17
- package/dist/generators/ts/ObjectUnionType.d.ts +0 -65
- package/dist/generators/ts/ObjectUnionType.js +0 -257
- package/dist/generators/ts/UnionType.d.ts +0 -40
- package/dist/generators/ts/UnionType.js +0 -527
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.js +0 -66
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/MemberType.d.ts +0 -34
- package/dist/generators/ts/_ObjectUnionType/MemberType.js +0 -105
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.js +0 -29
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js +0 -20
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.js +0 -18
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.js +0 -28
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.js +0 -9
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.js +0 -13
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.js +0 -37
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js +0 -35
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js +0 -26
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.js +0 -43
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.js +0 -5
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.js +0 -5
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.js +0 -12
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.js +0 -15
|
@@ -4,10 +4,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { code } from "ts-poet";
|
|
8
7
|
import { Memoize } from "typescript-memoize";
|
|
9
8
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
10
9
|
import { imports } from "./imports.js";
|
|
10
|
+
import { code } from "./ts-poet-wrapper.js";
|
|
11
11
|
export class AbstractIdentifierType extends AbstractTermType {
|
|
12
12
|
graphqlType = new AbstractTermType.GraphqlType(code `${imports.GraphQLString}`);
|
|
13
13
|
toStringFunction = // Re-export rdfjsResource.Resource.Identifier.toString
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe, NonEmptyList } from "purify-ts";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
|
+
import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
3
4
|
import type { ObjectType } from "./ObjectType.js";
|
|
4
|
-
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
5
5
|
import type { OptionType } from "./OptionType.js";
|
|
6
6
|
import type { SetType } from "./SetType.js";
|
|
7
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
@@ -13,6 +13,8 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
13
13
|
readonly partialPropertyName: string;
|
|
14
14
|
readonly rawName: Code;
|
|
15
15
|
};
|
|
16
|
+
readonly abstract = false;
|
|
17
|
+
readonly declaration: Maybe<Code>;
|
|
16
18
|
readonly discriminantProperty: AbstractType["discriminantProperty"];
|
|
17
19
|
readonly mutable = false;
|
|
18
20
|
readonly typeofs: NonEmptyList<"object">;
|
|
@@ -27,10 +29,11 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
27
29
|
get filterType(): Code;
|
|
28
30
|
get graphqlType(): AbstractType.GraphqlType;
|
|
29
31
|
get name(): Code;
|
|
32
|
+
get recursive(): boolean;
|
|
30
33
|
get schema(): Code;
|
|
31
34
|
get schemaType(): Code;
|
|
32
|
-
get
|
|
33
|
-
get
|
|
35
|
+
get valueSparqlConstructTriplesFunction(): Code;
|
|
36
|
+
get valueSparqlWherePatternsFunction(): Code;
|
|
34
37
|
protected get schemaObject(): {
|
|
35
38
|
partial: Code;
|
|
36
39
|
kind: Code;
|
|
@@ -40,17 +43,17 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
40
43
|
jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
41
44
|
jsonZodSchema(parameters: Parameters<AbstractType["jsonZodSchema"]>[0]): Code;
|
|
42
45
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
43
|
-
|
|
44
|
-
protected
|
|
45
|
-
|
|
46
|
-
|
|
46
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
47
|
+
protected resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }: {
|
|
48
|
+
resolvedNamedObjectUnionType: NamedObjectUnionType;
|
|
49
|
+
partialNamedObjectUnionType: NamedObjectUnionType;
|
|
47
50
|
variables: {
|
|
48
51
|
resolvedObjectUnion: Code;
|
|
49
52
|
};
|
|
50
53
|
}): Code;
|
|
51
54
|
}
|
|
52
55
|
export declare namespace AbstractLazyObjectType {
|
|
53
|
-
type ObjectTypeConstraint = ObjectType |
|
|
56
|
+
type ObjectTypeConstraint = ObjectType | NamedObjectUnionType;
|
|
54
57
|
type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
|
|
55
58
|
type ResolveTypeConstraint = PartialTypeConstraint;
|
|
56
59
|
type Conversion = AbstractType.Conversion;
|
|
@@ -14,6 +14,8 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
14
14
|
partialType;
|
|
15
15
|
resolveType;
|
|
16
16
|
runtimeClass;
|
|
17
|
+
abstract = false;
|
|
18
|
+
declaration = Maybe.empty();
|
|
17
19
|
discriminantProperty = Maybe.empty();
|
|
18
20
|
mutable = false;
|
|
19
21
|
typeofs = NonEmptyList(["object"]);
|
|
@@ -48,6 +50,9 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
48
50
|
get name() {
|
|
49
51
|
return this.runtimeClass.name;
|
|
50
52
|
}
|
|
53
|
+
get recursive() {
|
|
54
|
+
return this.partialType.recursive;
|
|
55
|
+
}
|
|
51
56
|
get schema() {
|
|
52
57
|
return code `${removeUndefined(this.schemaObject)}`;
|
|
53
58
|
}
|
|
@@ -58,11 +63,11 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
58
63
|
resolveType: this.resolveType.schemaType,
|
|
59
64
|
}}`;
|
|
60
65
|
}
|
|
61
|
-
get
|
|
62
|
-
return code `(({ schema, ...otherParameters }) => ${this.partialType.
|
|
66
|
+
get valueSparqlConstructTriplesFunction() {
|
|
67
|
+
return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.partial() }))`;
|
|
63
68
|
}
|
|
64
|
-
get
|
|
65
|
-
return code `(({ schema, ...otherParameters }) => ${this.partialType.
|
|
69
|
+
get valueSparqlWherePatternsFunction() {
|
|
70
|
+
return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partial() }))`;
|
|
66
71
|
}
|
|
67
72
|
get schemaObject() {
|
|
68
73
|
return {
|
|
@@ -97,22 +102,22 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
97
102
|
},
|
|
98
103
|
});
|
|
99
104
|
}
|
|
100
|
-
|
|
101
|
-
return this.partialType.
|
|
105
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
106
|
+
return this.partialType.toRdfResourceValuesExpression({
|
|
102
107
|
variables: {
|
|
103
108
|
...variables,
|
|
104
109
|
value: code `${variables.value}.${this.runtimeClass.partialPropertyName}`,
|
|
105
110
|
},
|
|
106
111
|
});
|
|
107
112
|
}
|
|
108
|
-
|
|
109
|
-
invariant(
|
|
110
|
-
|
|
111
|
-
const caseBlocks =
|
|
112
|
-
return code `${
|
|
113
|
+
resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType, partialNamedObjectUnionType, variables, }) {
|
|
114
|
+
invariant(resolvedNamedObjectUnionType.members.length ===
|
|
115
|
+
partialNamedObjectUnionType.members.length);
|
|
116
|
+
const caseBlocks = resolvedNamedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
|
|
117
|
+
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialNamedObjectUnionType.members[memberI].type.newExpression({ parameters: variables.resolvedObjectUnion })};`;
|
|
113
118
|
});
|
|
114
119
|
caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
|
|
115
|
-
return code `switch (${variables.resolvedObjectUnion}.${
|
|
120
|
+
return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
|
|
116
121
|
}
|
|
117
122
|
}
|
|
118
123
|
__decorate([
|
|
@@ -129,10 +134,10 @@ __decorate([
|
|
|
129
134
|
], AbstractLazyObjectType.prototype, "schemaType", null);
|
|
130
135
|
__decorate([
|
|
131
136
|
Memoize()
|
|
132
|
-
], AbstractLazyObjectType.prototype, "
|
|
137
|
+
], AbstractLazyObjectType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
133
138
|
__decorate([
|
|
134
139
|
Memoize()
|
|
135
|
-
], AbstractLazyObjectType.prototype, "
|
|
140
|
+
], AbstractLazyObjectType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
136
141
|
(function (AbstractLazyObjectType) {
|
|
137
142
|
AbstractLazyObjectType.GraphqlType = AbstractType.GraphqlType;
|
|
138
143
|
AbstractLazyObjectType.JsonType = AbstractType.JsonType;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { TsFeature } from "../../enums/TsFeature.js";
|
|
3
|
+
import { AbstractType } from "./AbstractType.js";
|
|
4
|
+
import { AbstractUnionType } from "./AbstractUnionType.js";
|
|
5
|
+
import type { Type } from "./Type.js";
|
|
6
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
7
|
+
export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> extends AbstractUnionType<MemberTypeT> {
|
|
8
|
+
protected readonly _name: string;
|
|
9
|
+
readonly features: ReadonlySet<TsFeature>;
|
|
10
|
+
constructor({ features, name, ...superParameters }: {
|
|
11
|
+
features: ReadonlySet<TsFeature>;
|
|
12
|
+
name: string;
|
|
13
|
+
} & ConstructorParameters<typeof AbstractUnionType<MemberTypeT>>[0]);
|
|
14
|
+
get declaration(): Maybe<Code>;
|
|
15
|
+
get equalsFunction(): Code;
|
|
16
|
+
get filterFunction(): Code;
|
|
17
|
+
get filterType(): Code;
|
|
18
|
+
get jsonTypeAliasDeclaration(): Code;
|
|
19
|
+
get jsonZodSchemaFunctionDeclaration(): Code;
|
|
20
|
+
get name(): string;
|
|
21
|
+
get staticModuleName(): string;
|
|
22
|
+
get valueSparqlConstructTriplesFunction(): Code;
|
|
23
|
+
get valueSparqlWherePatternsFunction(): Code;
|
|
24
|
+
protected get staticModuleDeclarations(): Record<string, Code>;
|
|
25
|
+
fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
|
|
26
|
+
fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
27
|
+
hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
28
|
+
jsonType(): AbstractType.JsonType;
|
|
29
|
+
jsonZodSchema({ context, }: Parameters<AbstractType["jsonZodSchema"]>[0]): Code;
|
|
30
|
+
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
31
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=AbstractNamedUnionType.d.ts.map
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Maybe } from "purify-ts";
|
|
8
|
+
import { Memoize } from "typescript-memoize";
|
|
9
|
+
import { AbstractType } from "./AbstractType.js";
|
|
10
|
+
import { AbstractUnionType } from "./AbstractUnionType.js";
|
|
11
|
+
import { imports } from "./imports.js";
|
|
12
|
+
import { snippets } from "./snippets.js";
|
|
13
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
14
|
+
import { code, def, joinCode } from "./ts-poet-wrapper.js";
|
|
15
|
+
export class AbstractNamedUnionType extends AbstractUnionType {
|
|
16
|
+
_name;
|
|
17
|
+
features;
|
|
18
|
+
constructor({ features, name, ...superParameters }) {
|
|
19
|
+
super(superParameters);
|
|
20
|
+
this.features = features;
|
|
21
|
+
this._name = name;
|
|
22
|
+
}
|
|
23
|
+
get declaration() {
|
|
24
|
+
const declarations = [
|
|
25
|
+
code `export type ${def(this._name)} = ${this.inlineName};`,
|
|
26
|
+
];
|
|
27
|
+
const staticModuleDeclarations = Object.entries(this.staticModuleDeclarations);
|
|
28
|
+
if (staticModuleDeclarations.length > 0) {
|
|
29
|
+
declarations.push(code `\
|
|
30
|
+
export namespace ${def(this.staticModuleName)} {
|
|
31
|
+
${joinCode(staticModuleDeclarations
|
|
32
|
+
.sort((left, right) => left[0].localeCompare(right[0]))
|
|
33
|
+
.map((_) => _[1]), { on: "\n\n" })}
|
|
34
|
+
}`);
|
|
35
|
+
}
|
|
36
|
+
return Maybe.of(joinCode(declarations, { on: "\n\n" }));
|
|
37
|
+
}
|
|
38
|
+
get equalsFunction() {
|
|
39
|
+
if (this.features.has("equals")) {
|
|
40
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}equals`;
|
|
41
|
+
}
|
|
42
|
+
return this.inlineEqualsFunction;
|
|
43
|
+
}
|
|
44
|
+
get filterFunction() {
|
|
45
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}filter`;
|
|
46
|
+
}
|
|
47
|
+
get filterType() {
|
|
48
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}Filter`;
|
|
49
|
+
}
|
|
50
|
+
get jsonTypeAliasDeclaration() {
|
|
51
|
+
return code `export type ${syntheticNamePrefix}Json = ${this.inlineJsonType.name}`;
|
|
52
|
+
}
|
|
53
|
+
get jsonZodSchemaFunctionDeclaration() {
|
|
54
|
+
return code `export const ${syntheticNamePrefix}jsonZodSchema = () => ${this.inlineJsonZodSchema};`;
|
|
55
|
+
}
|
|
56
|
+
get name() {
|
|
57
|
+
return this._name;
|
|
58
|
+
}
|
|
59
|
+
get staticModuleName() {
|
|
60
|
+
return this._name;
|
|
61
|
+
}
|
|
62
|
+
get valueSparqlConstructTriplesFunction() {
|
|
63
|
+
if (this.features.has("sparql")) {
|
|
64
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlConstructTriples`;
|
|
65
|
+
}
|
|
66
|
+
return this.inlineValueSparqlConstructTriplesFunction;
|
|
67
|
+
}
|
|
68
|
+
get valueSparqlWherePatternsFunction() {
|
|
69
|
+
if (this.features.has("sparql")) {
|
|
70
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlWherePatterns`;
|
|
71
|
+
}
|
|
72
|
+
return this.inlineValueSparqlWherePatternsFunction;
|
|
73
|
+
}
|
|
74
|
+
get staticModuleDeclarations() {
|
|
75
|
+
const staticModuleDeclarations = {};
|
|
76
|
+
if (this.features.has("equals")) {
|
|
77
|
+
staticModuleDeclarations[`${syntheticNamePrefix}equals`] =
|
|
78
|
+
code `export const ${syntheticNamePrefix}equals = ${this.inlineEqualsFunction};`;
|
|
79
|
+
}
|
|
80
|
+
staticModuleDeclarations[`${syntheticNamePrefix}Filter`] =
|
|
81
|
+
code `export type ${syntheticNamePrefix}Filter = ${this.inlineFilterType};`;
|
|
82
|
+
staticModuleDeclarations[`${syntheticNamePrefix}filter`] =
|
|
83
|
+
code `export const ${syntheticNamePrefix}filter = ${this.inlineFilterFunction};`;
|
|
84
|
+
if (this.features.has("hash")) {
|
|
85
|
+
staticModuleDeclarations[`${syntheticNamePrefix}hash`] =
|
|
86
|
+
code `export function ${syntheticNamePrefix}hash<HasherT extends ${snippets.Hasher}>(value: ${this._name}, hasher: HasherT): HasherT { ${this.inlineHashStatements({ depth: 0, variables: { hasher: code `hasher`, value: code `value` } })} return hasher; }`;
|
|
87
|
+
}
|
|
88
|
+
if (this.features.has("json")) {
|
|
89
|
+
staticModuleDeclarations[`${syntheticNamePrefix}Json`] =
|
|
90
|
+
this.jsonTypeAliasDeclaration;
|
|
91
|
+
staticModuleDeclarations[`${syntheticNamePrefix}fromJson`] =
|
|
92
|
+
code `export const ${syntheticNamePrefix}fromJson = ${this.inlineFromJsonFunction};`;
|
|
93
|
+
staticModuleDeclarations[`${syntheticNamePrefix}jsonZodSchema`] =
|
|
94
|
+
this.jsonZodSchemaFunctionDeclaration;
|
|
95
|
+
staticModuleDeclarations[`${syntheticNamePrefix}parseJson`] = code `\
|
|
96
|
+
export function ${syntheticNamePrefix}parseJson(json: unknown): ${imports.Either}<Error, ${this.name}> {
|
|
97
|
+
const ${syntheticNamePrefix}jsonSafeParseResult = ${syntheticNamePrefix}jsonZodSchema().safeParse(json);
|
|
98
|
+
if (!${syntheticNamePrefix}jsonSafeParseResult.success) { return ${imports.Left}(${syntheticNamePrefix}jsonSafeParseResult.error); }
|
|
99
|
+
return ${imports.Right}(${syntheticNamePrefix}fromJson(${syntheticNamePrefix}jsonSafeParseResult.data));
|
|
100
|
+
}`;
|
|
101
|
+
staticModuleDeclarations[`${syntheticNamePrefix}toJson`] =
|
|
102
|
+
code `export const ${syntheticNamePrefix}toJson = ${this.inlineToJsonFunction};`;
|
|
103
|
+
}
|
|
104
|
+
if (this.features.has("rdf")) {
|
|
105
|
+
staticModuleDeclarations[`${syntheticNamePrefix}fromRdfResourceValues`] =
|
|
106
|
+
code `export const ${syntheticNamePrefix}fromRdfResourceValues: ${snippets.FromRdfResourceValuesFunction}<${this.name}> = ${this.inlineFromRdfResourceValuesFunction};`;
|
|
107
|
+
staticModuleDeclarations[`${syntheticNamePrefix}toRdfResourceValues`] =
|
|
108
|
+
code `export const ${syntheticNamePrefix}toRdfResourceValues: ${snippets.ToRdfResourceValuesFunction}<${this.name}> = ${this.inlineToRdfResourceValuesFunction};`;
|
|
109
|
+
}
|
|
110
|
+
if (this.features.has("sparql")) {
|
|
111
|
+
staticModuleDeclarations[`${syntheticNamePrefix}valueSparqlConstructTriples`] =
|
|
112
|
+
code `export const ${syntheticNamePrefix}valueSparqlConstructTriples: ${snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
|
|
113
|
+
staticModuleDeclarations[`${syntheticNamePrefix}valueSparqlWherePatterns`] =
|
|
114
|
+
code `export const ${syntheticNamePrefix}valueSparqlWherePatterns: ${snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
|
|
115
|
+
}
|
|
116
|
+
return staticModuleDeclarations;
|
|
117
|
+
}
|
|
118
|
+
fromJsonExpression({ variables, }) {
|
|
119
|
+
if (this.features.has("json")) {
|
|
120
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}fromJson(${variables.value})`;
|
|
121
|
+
}
|
|
122
|
+
return code `${this.inlineFromJsonFunction}(${variables.value})`;
|
|
123
|
+
}
|
|
124
|
+
fromRdfResourceValuesExpression({ variables, }) {
|
|
125
|
+
const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
|
|
126
|
+
if (this.features.has("rdf")) {
|
|
127
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
|
|
128
|
+
}
|
|
129
|
+
return code `${this.inlineFromRdfResourceValuesFunction}(${resourceValuesVariable}, ${otherVariables})`;
|
|
130
|
+
}
|
|
131
|
+
hashStatements({ depth, variables, }) {
|
|
132
|
+
if (this.features.has("hash")) {
|
|
133
|
+
return [
|
|
134
|
+
code `${this.staticModuleName}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
return this.inlineHashStatements({ depth, variables });
|
|
138
|
+
}
|
|
139
|
+
jsonType() {
|
|
140
|
+
if (this.features.has("json")) {
|
|
141
|
+
return new AbstractType.JsonType(`${this.staticModuleName}.${syntheticNamePrefix}Json`);
|
|
142
|
+
}
|
|
143
|
+
return this.inlineJsonType;
|
|
144
|
+
}
|
|
145
|
+
jsonZodSchema({ context, }) {
|
|
146
|
+
if (this.features.has("json")) {
|
|
147
|
+
const expression = code `${this.staticModuleName}.${syntheticNamePrefix}jsonZodSchema()`;
|
|
148
|
+
if (context === "property" && this.recursive) {
|
|
149
|
+
return code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.staticModuleName}.${syntheticNamePrefix}Json> => ${expression})`;
|
|
150
|
+
}
|
|
151
|
+
return expression;
|
|
152
|
+
}
|
|
153
|
+
return this.inlineJsonZodSchema;
|
|
154
|
+
}
|
|
155
|
+
toJsonExpression({ variables, }) {
|
|
156
|
+
if (this.features.has("json")) {
|
|
157
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
|
|
158
|
+
}
|
|
159
|
+
return code `${this.inlineToJsonFunction}(${variables.value})`;
|
|
160
|
+
}
|
|
161
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
162
|
+
const { value: valueVariable, ...otherVariables } = variables;
|
|
163
|
+
if (this.features.has("rdf")) {
|
|
164
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}toRdfResourceValues(${valueVariable}, ${otherVariables})`;
|
|
165
|
+
}
|
|
166
|
+
return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
__decorate([
|
|
170
|
+
Memoize()
|
|
171
|
+
], AbstractNamedUnionType.prototype, "declaration", null);
|
|
172
|
+
__decorate([
|
|
173
|
+
Memoize()
|
|
174
|
+
], AbstractNamedUnionType.prototype, "equalsFunction", null);
|
|
175
|
+
__decorate([
|
|
176
|
+
Memoize()
|
|
177
|
+
], AbstractNamedUnionType.prototype, "filterFunction", null);
|
|
178
|
+
__decorate([
|
|
179
|
+
Memoize()
|
|
180
|
+
], AbstractNamedUnionType.prototype, "filterType", null);
|
|
181
|
+
__decorate([
|
|
182
|
+
Memoize()
|
|
183
|
+
], AbstractNamedUnionType.prototype, "name", null);
|
|
184
|
+
__decorate([
|
|
185
|
+
Memoize()
|
|
186
|
+
], AbstractNamedUnionType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
187
|
+
__decorate([
|
|
188
|
+
Memoize()
|
|
189
|
+
], AbstractNamedUnionType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
190
|
+
__decorate([
|
|
191
|
+
Memoize()
|
|
192
|
+
], AbstractNamedUnionType.prototype, "jsonType", null);
|
|
193
|
+
//# sourceMappingURL=AbstractNamedUnionType.js.map
|
|
@@ -9,14 +9,14 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
|
|
|
9
9
|
get filterType(): Code;
|
|
10
10
|
get name(): string;
|
|
11
11
|
get schemaType(): Code;
|
|
12
|
-
get
|
|
12
|
+
get valueSparqlWherePatternsFunction(): Code;
|
|
13
13
|
protected get schemaObject(): {
|
|
14
14
|
in: Code[] | undefined;
|
|
15
15
|
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
16
16
|
kind: Code;
|
|
17
17
|
};
|
|
18
18
|
jsonZodSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonZodSchema"]>[0]): Code;
|
|
19
|
-
|
|
19
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
20
20
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<ValueT>["fromRdfExpressionChain"]>;
|
|
21
21
|
protected abstract fromRdfResourceValueExpression(variables: {
|
|
22
22
|
variables: {
|
|
@@ -29,7 +29,7 @@ export class AbstractNumericType extends AbstractPrimitiveType {
|
|
|
29
29
|
get schemaType() {
|
|
30
30
|
return code `${snippets.NumericSchema}<${this.typeofs[0]}>`;
|
|
31
31
|
}
|
|
32
|
-
get
|
|
32
|
+
get valueSparqlWherePatternsFunction() {
|
|
33
33
|
return code `${snippets.numericSparqlWherePatterns}<${this.typeofs[0]}>`;
|
|
34
34
|
}
|
|
35
35
|
get schemaObject() {
|
|
@@ -50,7 +50,7 @@ export class AbstractNumericType extends AbstractPrimitiveType {
|
|
|
50
50
|
return code `${imports.z}.union([${joinCode(this.primitiveIn.map((value) => code `${imports.z}.literal(${this.literalOf(value)})`), { on: "," })}])`;
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
|
|
53
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
54
54
|
return code `[${snippets.literalFactory}.${this.typeofs[0]}(${variables.value}, ${rdfjsTermExpression(this.datatype)})]`;
|
|
55
55
|
}
|
|
56
56
|
fromRdfExpressionChain({ variables, }) {
|
|
@@ -78,7 +78,7 @@ __decorate([
|
|
|
78
78
|
], AbstractNumericType.prototype, "schemaType", null);
|
|
79
79
|
__decorate([
|
|
80
80
|
Memoize()
|
|
81
|
-
], AbstractNumericType.prototype, "
|
|
81
|
+
], AbstractNumericType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
82
82
|
(function (AbstractNumericType) {
|
|
83
83
|
AbstractNumericType.JsonType = AbstractPrimitiveType.JsonType;
|
|
84
84
|
})(AbstractNumericType || (AbstractNumericType = {}));
|
|
@@ -13,12 +13,15 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
13
13
|
* The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
|
|
14
14
|
*/
|
|
15
15
|
export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends AbstractType {
|
|
16
|
+
readonly abstract = false;
|
|
17
|
+
readonly declaration: Maybe<Code>;
|
|
16
18
|
readonly equalsFunction: Code;
|
|
17
19
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
18
20
|
readonly hasValues: readonly ConstantTermT[];
|
|
19
21
|
readonly in_: readonly ConstantTermT[];
|
|
20
22
|
readonly mutable: boolean;
|
|
21
23
|
abstract readonly nodeKinds: ReadonlySet<NodeKind>;
|
|
24
|
+
readonly recursive = false;
|
|
22
25
|
readonly typeofs: AbstractType["typeofs"];
|
|
23
26
|
constructor({ hasValues, in_, ...superParameters }: {
|
|
24
27
|
hasValues: readonly ConstantTermT[];
|
|
@@ -28,11 +31,11 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
28
31
|
get conversions(): readonly AbstractType.Conversion[];
|
|
29
32
|
get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
|
|
30
33
|
get schema(): Code;
|
|
31
|
-
get
|
|
32
|
-
|
|
34
|
+
get valueSparqlConstructTriplesFunction(): Code;
|
|
35
|
+
fromRdfResourceValuesExpression(parameters: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
33
36
|
hashStatements({ variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
34
37
|
jsonUiSchemaElement(): Maybe<Code>;
|
|
35
|
-
|
|
38
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
36
39
|
/**
|
|
37
40
|
* The fromRdfExpression for a term type can be decomposed into multiple sub-expressions with different purposes:
|
|
38
41
|
*
|
|
@@ -42,7 +45,7 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
42
45
|
*
|
|
43
46
|
* Considering the sub-expressions as a record instead of an array allows them to be selectively overridden by subclasses.
|
|
44
47
|
*/
|
|
45
|
-
protected fromRdfExpressionChain({ variables, }: Parameters<Type["
|
|
48
|
+
protected fromRdfExpressionChain({ variables, }: Parameters<Type["fromRdfResourceValuesExpression"]>[0]): {
|
|
46
49
|
hasValues?: Code;
|
|
47
50
|
languageIn?: Code;
|
|
48
51
|
preferredLanguages?: Code;
|
|
@@ -22,11 +22,14 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
|
22
22
|
* The two are differentiated because identifiers can have BlankNode or NamedNode values at runtime but only NamedNode values for sh:hasValue and sh:in.
|
|
23
23
|
*/
|
|
24
24
|
export class AbstractTermType extends AbstractType {
|
|
25
|
+
abstract = false;
|
|
26
|
+
declaration = Maybe.empty();
|
|
25
27
|
equalsFunction = code `${snippets.booleanEquals}`;
|
|
26
28
|
graphqlArgs = Maybe.empty();
|
|
27
29
|
hasValues;
|
|
28
30
|
in_;
|
|
29
31
|
mutable = false;
|
|
32
|
+
recursive = false;
|
|
30
33
|
typeofs = NonEmptyList([
|
|
31
34
|
"object",
|
|
32
35
|
]);
|
|
@@ -87,10 +90,10 @@ export class AbstractTermType extends AbstractType {
|
|
|
87
90
|
get schema() {
|
|
88
91
|
return code `${removeUndefined(this.schemaObject)}`;
|
|
89
92
|
}
|
|
90
|
-
get
|
|
93
|
+
get valueSparqlConstructTriplesFunction() {
|
|
91
94
|
return code `((_: object) => [])`;
|
|
92
95
|
}
|
|
93
|
-
|
|
96
|
+
fromRdfResourceValuesExpression(parameters) {
|
|
94
97
|
// invariant(
|
|
95
98
|
// this.nodeKinds.has("Literal") &&
|
|
96
99
|
// (this.nodeKinds.has("BlankNode") || this.nodeKinds.has("NamedNode")),
|
|
@@ -115,7 +118,7 @@ export class AbstractTermType extends AbstractType {
|
|
|
115
118
|
jsonUiSchemaElement() {
|
|
116
119
|
return Maybe.empty();
|
|
117
120
|
}
|
|
118
|
-
|
|
121
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
119
122
|
return code `[${variables.value}]`;
|
|
120
123
|
}
|
|
121
124
|
/**
|
|
@@ -163,7 +166,7 @@ __decorate([
|
|
|
163
166
|
], AbstractTermType.prototype, "schema", null);
|
|
164
167
|
__decorate([
|
|
165
168
|
Memoize()
|
|
166
|
-
], AbstractTermType.prototype, "
|
|
169
|
+
], AbstractTermType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
167
170
|
(function (AbstractTermType) {
|
|
168
171
|
AbstractTermType.GraphqlType = AbstractType.GraphqlType;
|
|
169
172
|
AbstractTermType.JsonType = AbstractType.JsonType;
|
|
@@ -5,6 +5,10 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
5
5
|
* Abstract base class all types.
|
|
6
6
|
*/
|
|
7
7
|
export declare abstract class AbstractType {
|
|
8
|
+
/**
|
|
9
|
+
* Is the type abstract?
|
|
10
|
+
*/
|
|
11
|
+
abstract readonly abstract: boolean;
|
|
8
12
|
/**
|
|
9
13
|
* Comment from rdfs:comment.
|
|
10
14
|
*/
|
|
@@ -13,6 +17,10 @@ export declare abstract class AbstractType {
|
|
|
13
17
|
* Expressions that convert a source type or types to this type. It should include the type itself.
|
|
14
18
|
*/
|
|
15
19
|
abstract readonly conversions: readonly AbstractType.Conversion[];
|
|
20
|
+
/**
|
|
21
|
+
* The declaration of named types.
|
|
22
|
+
*/
|
|
23
|
+
abstract readonly declaration: Maybe<Code>;
|
|
16
24
|
/**
|
|
17
25
|
* A property that discriminates sub-types of this type e.g., termType on RDF/JS terms.
|
|
18
26
|
*/
|
|
@@ -57,6 +65,10 @@ export declare abstract class AbstractType {
|
|
|
57
65
|
* TypeScript name of the type.
|
|
58
66
|
*/
|
|
59
67
|
abstract readonly name: Code | string;
|
|
68
|
+
/**
|
|
69
|
+
* Does this type directly or indirectly reference itself?
|
|
70
|
+
*/
|
|
71
|
+
abstract readonly recursive: boolean;
|
|
60
72
|
/**
|
|
61
73
|
* TypeScript object describing this type, for runtime use.
|
|
62
74
|
*/
|
|
@@ -66,20 +78,24 @@ export declare abstract class AbstractType {
|
|
|
66
78
|
*/
|
|
67
79
|
abstract readonly schemaType: Code;
|
|
68
80
|
/**
|
|
69
|
-
*
|
|
81
|
+
* JavaScript typeof(s) the type.
|
|
82
|
+
*/
|
|
83
|
+
abstract readonly typeofs: NonEmptyList<Typeof>;
|
|
84
|
+
/**
|
|
85
|
+
* A ValueSparqlConstructTriplesFunction (reference or declaration) that returns an array of sparqljs.Triple's for a property value of this type.
|
|
70
86
|
*
|
|
71
|
-
* The function takes a parameters object
|
|
87
|
+
* The function takes a parameters object with the following parameters:
|
|
72
88
|
* - filter: an instance of filterType | undefined
|
|
73
89
|
* - ignoreRdfType: boolean
|
|
74
90
|
* - schema: instance of this.schemaType
|
|
75
91
|
* - valueVariable: rdfjs.Variable of the value of this type
|
|
76
92
|
* - variablePrefix: string prefix to use for new variables
|
|
77
93
|
*/
|
|
78
|
-
abstract readonly
|
|
94
|
+
abstract readonly valueSparqlConstructTriplesFunction: Code;
|
|
79
95
|
/**
|
|
80
|
-
* A
|
|
96
|
+
* A ValueSparqlWherePatternsFunction (reference or declaration) that returns an array of SparqlPattern's for a property value of this type.
|
|
81
97
|
*
|
|
82
|
-
* The function takes a parameters object
|
|
98
|
+
* The function takes a parameters object with the following parameters:
|
|
83
99
|
* - filter: an instance of filterType | undefined
|
|
84
100
|
* - preferredLanguages: array of preferred language code (strings) | undefined
|
|
85
101
|
* - propertyPatterns: array of sparqljs.Pattern's for the property; may be empty
|
|
@@ -87,11 +103,7 @@ export declare abstract class AbstractType {
|
|
|
87
103
|
* - valueVariable: rdfjs.Variable of the value of this type
|
|
88
104
|
* - variablePrefix: string prefix to use for new variables
|
|
89
105
|
*/
|
|
90
|
-
abstract readonly
|
|
91
|
-
/**
|
|
92
|
-
* JavaScript typeof(s) the type.
|
|
93
|
-
*/
|
|
94
|
-
abstract readonly typeofs: NonEmptyList<Typeof>;
|
|
106
|
+
abstract readonly valueSparqlWherePatternsFunction: Code;
|
|
95
107
|
constructor({ comment, label, }: {
|
|
96
108
|
comment: Maybe<string>;
|
|
97
109
|
label: Maybe<string>;
|
|
@@ -134,7 +146,7 @@ export declare abstract class AbstractType {
|
|
|
134
146
|
* resource: the Resource passed to Object.fromRdf
|
|
135
147
|
* resourceValues: the Either<Error, rdfjsResource.Resource.Values> to be converted to values of this type
|
|
136
148
|
*/
|
|
137
|
-
abstract
|
|
149
|
+
abstract fromRdfResourceValuesExpression(parameters: {
|
|
138
150
|
variables: {
|
|
139
151
|
context: Code;
|
|
140
152
|
graph: Code;
|
|
@@ -213,7 +225,7 @@ export declare abstract class AbstractType {
|
|
|
213
225
|
* resourceSet: ResourceSet for any new Resources needed while conversion (of e.g., nested objects)
|
|
214
226
|
* value: value of this type, to be converted to (BlankNode | Literal | NamedNode | bigint | boolean | number | string) or an array of the same
|
|
215
227
|
*/
|
|
216
|
-
abstract
|
|
228
|
+
abstract toRdfResourceValuesExpression(parameters: {
|
|
217
229
|
variables: {
|
|
218
230
|
graph: Code;
|
|
219
231
|
propertyPath: Code;
|
|
@@ -231,9 +243,12 @@ export declare namespace AbstractType {
|
|
|
231
243
|
readonly sourceTypeof: Typeof;
|
|
232
244
|
}
|
|
233
245
|
interface DiscriminantProperty {
|
|
246
|
+
readonly descendantValues: readonly DiscriminantProperty.Value[];
|
|
234
247
|
readonly name: string;
|
|
235
|
-
readonly ownValues: readonly
|
|
236
|
-
|
|
248
|
+
readonly ownValues: readonly DiscriminantProperty.Value[];
|
|
249
|
+
}
|
|
250
|
+
namespace DiscriminantProperty {
|
|
251
|
+
type Value = number | string;
|
|
237
252
|
}
|
|
238
253
|
class GraphqlType {
|
|
239
254
|
/**
|