@shaclmate/compiler 4.0.7 → 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 +5 -6
- package/dist/input/NodeShape.js +19 -22
- package/dist/input/Ontology.d.ts +4 -4
- package/dist/input/Ontology.js +10 -10
- package/dist/input/PropertyShape.d.ts +4 -4
- package/dist/input/PropertyShape.js +10 -10
- package/dist/input/ShapesGraph.d.ts +3 -2
- package/dist/input/ShapesGraph.js +13 -8
- package/dist/input/generated.d.ts +2551 -2040
- package/dist/input/generated.js +2806 -2346
- 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
|
@@ -2,11 +2,13 @@ import TermMap from "@rdfjs/term-map";
|
|
|
2
2
|
import TermSet from "@rdfjs/term-set";
|
|
3
3
|
import base62 from "@sindresorhus/base62";
|
|
4
4
|
import { rdf, xsd } from "@tpluscode/rdf-ns-builders";
|
|
5
|
+
import { Maybe } from "purify-ts";
|
|
5
6
|
import { LiteralDecoder, literalDatatypeDefinitions } from "rdfjs-resource";
|
|
6
7
|
import reservedTsIdentifiers_ from "reserved-identifiers";
|
|
7
8
|
import { invariant } from "ts-invariant";
|
|
9
|
+
import * as ast from "../../ast/index.js";
|
|
8
10
|
import { logger } from "../../logger.js";
|
|
9
|
-
import {
|
|
11
|
+
import { AnonymousUnionType } from "./AnonymousUnionType.js";
|
|
10
12
|
import { BigDecimalType } from "./BigDecimalType.js";
|
|
11
13
|
import { BigIntType } from "./BigIntType.js";
|
|
12
14
|
import { BlankNodeType } from "./BlankNodeType.js";
|
|
@@ -23,30 +25,41 @@ import { LazyObjectSetType } from "./LazyObjectSetType.js";
|
|
|
23
25
|
import { LazyObjectType } from "./LazyObjectType.js";
|
|
24
26
|
import { ListType } from "./ListType.js";
|
|
25
27
|
import { LiteralType } from "./LiteralType.js";
|
|
28
|
+
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
29
|
+
import { NamedUnionType } from "./NamedUnionType.js";
|
|
26
30
|
import { ObjectType } from "./ObjectType.js";
|
|
27
|
-
import { ObjectUnionType } from "./ObjectUnionType.js";
|
|
28
31
|
import { OptionType } from "./OptionType.js";
|
|
29
32
|
import { SetType } from "./SetType.js";
|
|
30
33
|
import { StringType } from "./StringType.js";
|
|
31
34
|
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
32
35
|
import { TermType } from "./TermType.js";
|
|
33
36
|
import { code } from "./ts-poet-wrapper.js";
|
|
34
|
-
import { UnionType } from "./UnionType.js";
|
|
35
|
-
const reservedTsIdentifiers = reservedTsIdentifiers_({
|
|
36
|
-
includeGlobalProperties: true,
|
|
37
|
-
});
|
|
38
|
-
const tsName = codeName((value) => {
|
|
39
|
-
// Adapted from https://github.com/sindresorhus/to-valid-identifier , MIT license
|
|
40
|
-
if (reservedTsIdentifiers.has(value)) {
|
|
41
|
-
// We prefix with underscore to avoid any potential conflicts with the Base62 encoded string.
|
|
42
|
-
return `$_${value}$`;
|
|
43
|
-
}
|
|
44
|
-
return value.replaceAll(/\P{ID_Continue}/gu, (x) => `$${base62.encodeInteger(x.codePointAt(0))}$`);
|
|
45
|
-
}, syntheticNamePrefix);
|
|
46
37
|
export class TypeFactory {
|
|
38
|
+
cachedNamedObjectUnionTypesByShapeIdentifier = new TermMap();
|
|
47
39
|
cachedObjectTypePropertiesByShapeIdentifier = new TermMap();
|
|
48
40
|
cachedObjectTypesByShapeIdentifier = new TermMap();
|
|
49
|
-
|
|
41
|
+
createNamedObjectUnionType(astType) {
|
|
42
|
+
{
|
|
43
|
+
const cachedNamedObjectUnionType = this.cachedNamedObjectUnionTypesByShapeIdentifier.get(astType.shapeIdentifier);
|
|
44
|
+
if (cachedNamedObjectUnionType) {
|
|
45
|
+
return cachedNamedObjectUnionType;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const namedObjectUnionType = new NamedObjectUnionType({
|
|
49
|
+
comment: astType.comment,
|
|
50
|
+
features: astType.tsFeatures,
|
|
51
|
+
identifierType: this.createIdentifierType(ast.ObjectCompoundType.identifierType(astType)),
|
|
52
|
+
label: astType.label,
|
|
53
|
+
members: ast.ObjectCompoundType.memberObjectTypes(astType).map((objectType) => ({
|
|
54
|
+
discriminantValue: Maybe.empty(),
|
|
55
|
+
type: this.createObjectType(objectType),
|
|
56
|
+
})),
|
|
57
|
+
name: tsName(astType.name.unsafeCoerce()),
|
|
58
|
+
recursive: astType.recursive,
|
|
59
|
+
});
|
|
60
|
+
this.cachedNamedObjectUnionTypesByShapeIdentifier.set(astType.shapeIdentifier, namedObjectUnionType);
|
|
61
|
+
return namedObjectUnionType;
|
|
62
|
+
}
|
|
50
63
|
createObjectType(astType) {
|
|
51
64
|
{
|
|
52
65
|
const cachedObjectType = this.cachedObjectTypesByShapeIdentifier.get(astType.shapeIdentifier);
|
|
@@ -55,14 +68,14 @@ export class TypeFactory {
|
|
|
55
68
|
}
|
|
56
69
|
}
|
|
57
70
|
const identifierType = this.createIdentifierType(astType.identifierType);
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
|
|
71
|
+
const name = tsName(astType.name.unsafeCoerce(), {
|
|
72
|
+
synthetic: astType.synthetic,
|
|
73
|
+
});
|
|
74
|
+
const staticModuleName = astType.childObjectTypes.length > 0 ? `${name}Static` : name;
|
|
61
75
|
const objectType = new ObjectType({
|
|
62
76
|
abstract: astType.abstract,
|
|
63
77
|
comment: astType.comment,
|
|
64
78
|
declarationType: astType.tsObjectDeclarationType,
|
|
65
|
-
export_: astType.export,
|
|
66
79
|
extern: astType.extern,
|
|
67
80
|
features: astType.tsFeatures,
|
|
68
81
|
fromRdfType: astType.fromRdfType,
|
|
@@ -72,6 +85,37 @@ export class TypeFactory {
|
|
|
72
85
|
lazyAncestorObjectTypes: () => astType.ancestorObjectTypes.map((astType) => this.createObjectType(astType)),
|
|
73
86
|
lazyChildObjectTypes: () => astType.childObjectTypes.map((astType) => this.createObjectType(astType)),
|
|
74
87
|
lazyDescendantObjectTypes: () => astType.descendantObjectTypes.map((astType) => this.createObjectType(astType)),
|
|
88
|
+
lazyDiscriminantProperty: (objectType) => {
|
|
89
|
+
// Discriminant property
|
|
90
|
+
const discriminantOwnValue = !astType.abstract
|
|
91
|
+
? objectType.discriminantValue
|
|
92
|
+
: undefined;
|
|
93
|
+
const discriminantDescendantValues = new Set();
|
|
94
|
+
for (const descendantObjectType of objectType.descendantObjectTypes) {
|
|
95
|
+
if (!descendantObjectType.abstract) {
|
|
96
|
+
discriminantDescendantValues.add(descendantObjectType.discriminantValue);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return new ObjectType.DiscriminantProperty({
|
|
100
|
+
name: `${syntheticNamePrefix}type`,
|
|
101
|
+
objectType,
|
|
102
|
+
type: new ObjectType.DiscriminantProperty.Type({
|
|
103
|
+
descendantValues: [...discriminantDescendantValues].sort(),
|
|
104
|
+
mutable: false,
|
|
105
|
+
ownValues: discriminantOwnValue ? [discriminantOwnValue] : [],
|
|
106
|
+
}),
|
|
107
|
+
visibility: "public",
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
lazyIdentifierProperty: (objectType) => new ObjectType.IdentifierProperty({
|
|
111
|
+
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
112
|
+
identifierPrefixPropertyName: `${syntheticNamePrefix}identifierPrefix`,
|
|
113
|
+
name: `${syntheticNamePrefix}identifier`,
|
|
114
|
+
objectType,
|
|
115
|
+
type: identifierType,
|
|
116
|
+
typeAlias: code `${staticModuleName}.${syntheticNamePrefix}Identifier`,
|
|
117
|
+
visibility: "public",
|
|
118
|
+
}),
|
|
75
119
|
lazyParentObjectTypes: () => astType.parentObjectTypes.map((astType) => this.createObjectType(astType)),
|
|
76
120
|
lazyProperties: (objectType) => {
|
|
77
121
|
const properties = astType.properties
|
|
@@ -82,36 +126,15 @@ export class TypeFactory {
|
|
|
82
126
|
if (left.order > right.order) {
|
|
83
127
|
return 1;
|
|
84
128
|
}
|
|
85
|
-
return tsName(left).localeCompare(tsName(right));
|
|
129
|
+
return tsName(left.name).localeCompare(tsName(right.name));
|
|
86
130
|
})
|
|
87
131
|
.map((astProperty) => this.createObjectTypeProperty({
|
|
88
132
|
astObjectTypeProperty: astProperty,
|
|
89
133
|
objectType,
|
|
90
134
|
}));
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
: undefined;
|
|
95
|
-
const typeDiscriminantDescendantValues = new Set();
|
|
96
|
-
for (const descendantObjectType of objectType.descendantObjectTypes) {
|
|
97
|
-
if (!descendantObjectType.abstract) {
|
|
98
|
-
typeDiscriminantDescendantValues.add(descendantObjectType.discriminantValue);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (typeDiscriminantOwnValue ||
|
|
102
|
-
typeDiscriminantDescendantValues.size > 0) {
|
|
103
|
-
properties.splice(0, 0, new ObjectType.TypeDiscriminantProperty({
|
|
104
|
-
name: `${syntheticNamePrefix}type`,
|
|
105
|
-
objectType,
|
|
106
|
-
type: new ObjectType.TypeDiscriminantProperty.Type({
|
|
107
|
-
descendantValues: [...typeDiscriminantDescendantValues].sort(),
|
|
108
|
-
mutable: false,
|
|
109
|
-
ownValues: typeDiscriminantOwnValue
|
|
110
|
-
? [typeDiscriminantOwnValue]
|
|
111
|
-
: [],
|
|
112
|
-
}),
|
|
113
|
-
visibility: "public",
|
|
114
|
-
}));
|
|
135
|
+
if (objectType._discriminantProperty.type.ownValues.length > 0 ||
|
|
136
|
+
objectType._discriminantProperty.type.descendantValues.length > 0) {
|
|
137
|
+
properties.splice(0, 0, objectType._discriminantProperty);
|
|
115
138
|
}
|
|
116
139
|
// Some ObjectTypes have an identifierPrefix property, depending on their identifier minting strategy.
|
|
117
140
|
if (objectTypeNeedsIdentifierPrefixProperty(astType)) {
|
|
@@ -132,19 +155,11 @@ export class TypeFactory {
|
|
|
132
155
|
}));
|
|
133
156
|
}
|
|
134
157
|
// Every ObjectType has an identifier property. Some are abstract.
|
|
135
|
-
properties.splice(0, 0,
|
|
136
|
-
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
137
|
-
identifierPrefixPropertyName: `${syntheticNamePrefix}identifierPrefix`,
|
|
138
|
-
name: `${syntheticNamePrefix}identifier`,
|
|
139
|
-
objectType,
|
|
140
|
-
type: identifierType,
|
|
141
|
-
typeAlias: code `${staticModuleName}.${syntheticNamePrefix}Identifier`,
|
|
142
|
-
visibility: "public",
|
|
143
|
-
}));
|
|
158
|
+
properties.splice(0, 0, objectType.identifierProperty);
|
|
144
159
|
return properties;
|
|
145
160
|
},
|
|
146
|
-
|
|
147
|
-
|
|
161
|
+
name,
|
|
162
|
+
recursive: astType.recursive,
|
|
148
163
|
staticModuleName,
|
|
149
164
|
synthetic: astType.synthetic,
|
|
150
165
|
toRdfTypes: astType.toRdfTypes,
|
|
@@ -152,25 +167,6 @@ export class TypeFactory {
|
|
|
152
167
|
this.cachedObjectTypesByShapeIdentifier.set(astType.shapeIdentifier, objectType);
|
|
153
168
|
return objectType;
|
|
154
169
|
}
|
|
155
|
-
createObjectUnionType(astType) {
|
|
156
|
-
{
|
|
157
|
-
const cachedObjectUnionType = this.cachedObjectUnionTypesByShapeIdentifier.get(astType.shapeIdentifier);
|
|
158
|
-
if (cachedObjectUnionType) {
|
|
159
|
-
return cachedObjectUnionType;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const objectUnionType = new ObjectUnionType({
|
|
163
|
-
comment: astType.comment,
|
|
164
|
-
export_: astType.export,
|
|
165
|
-
features: astType.tsFeatures,
|
|
166
|
-
identifierType: this.createIdentifierType(astType.identifierType),
|
|
167
|
-
label: astType.label,
|
|
168
|
-
memberTypes: astType.memberObjectTypes.map((objectType) => this.createObjectType(objectType)),
|
|
169
|
-
name: tsName(astType),
|
|
170
|
-
});
|
|
171
|
-
this.cachedObjectUnionTypesByShapeIdentifier.set(astType.shapeIdentifier, objectUnionType);
|
|
172
|
-
return objectUnionType;
|
|
173
|
-
}
|
|
174
170
|
createType(astType, parameters) {
|
|
175
171
|
switch (astType.kind) {
|
|
176
172
|
case "BlankNodeType":
|
|
@@ -193,16 +189,10 @@ export class TypeFactory {
|
|
|
193
189
|
return this.createListType(astType);
|
|
194
190
|
case "LiteralType":
|
|
195
191
|
return this.createLiteralType(astType, parameters);
|
|
196
|
-
case "ObjectIntersectionType":
|
|
197
|
-
throw new Error("not implemented");
|
|
198
192
|
case "ObjectType":
|
|
199
193
|
return this.createObjectType(astType);
|
|
200
|
-
case "ObjectUnionType":
|
|
201
|
-
return this.createObjectUnionType(astType);
|
|
202
194
|
case "OptionType":
|
|
203
195
|
return this.createOptionType(astType);
|
|
204
|
-
case "PlaceholderType":
|
|
205
|
-
throw new Error(astType.kind);
|
|
206
196
|
case "SetType":
|
|
207
197
|
return this.createSetType(astType);
|
|
208
198
|
case "TermType":
|
|
@@ -211,6 +201,34 @@ export class TypeFactory {
|
|
|
211
201
|
return this.createUnionType(astType);
|
|
212
202
|
}
|
|
213
203
|
}
|
|
204
|
+
createUnionType(astType) {
|
|
205
|
+
if (astType.isObjectUnionType()) {
|
|
206
|
+
return this.createNamedObjectUnionType(astType);
|
|
207
|
+
}
|
|
208
|
+
return astType.name
|
|
209
|
+
.map((name) => new NamedUnionType({
|
|
210
|
+
comment: astType.comment,
|
|
211
|
+
features: astType.tsFeatures,
|
|
212
|
+
identifierType: Maybe.empty(),
|
|
213
|
+
label: astType.label,
|
|
214
|
+
members: astType.members.map((member) => ({
|
|
215
|
+
discriminantValue: member.discriminantValue,
|
|
216
|
+
type: this.createType(member.type),
|
|
217
|
+
})),
|
|
218
|
+
name,
|
|
219
|
+
recursive: astType.recursive,
|
|
220
|
+
}))
|
|
221
|
+
.orDefaultLazy(() => new AnonymousUnionType({
|
|
222
|
+
comment: astType.comment,
|
|
223
|
+
label: astType.label,
|
|
224
|
+
identifierType: Maybe.empty(),
|
|
225
|
+
members: astType.members.map((member) => ({
|
|
226
|
+
discriminantValue: member.discriminantValue,
|
|
227
|
+
type: this.createType(member.type),
|
|
228
|
+
})),
|
|
229
|
+
recursive: astType.recursive,
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
214
232
|
createBlankNodeType(astType) {
|
|
215
233
|
return new BlankNodeType({
|
|
216
234
|
comment: astType.comment,
|
|
@@ -408,14 +426,13 @@ export class TypeFactory {
|
|
|
408
426
|
return cachedProperty;
|
|
409
427
|
}
|
|
410
428
|
}
|
|
411
|
-
const name = tsName(astObjectTypeProperty);
|
|
412
429
|
const property = new ObjectType.ShaclProperty({
|
|
413
430
|
comment: astObjectTypeProperty.comment,
|
|
414
431
|
description: astObjectTypeProperty.description,
|
|
415
432
|
label: astObjectTypeProperty.label,
|
|
416
433
|
mutable: astObjectTypeProperty.mutable,
|
|
417
434
|
objectType,
|
|
418
|
-
name,
|
|
435
|
+
name: tsName(astObjectTypeProperty.name),
|
|
419
436
|
path: astObjectTypeProperty.path,
|
|
420
437
|
recursive: !!astObjectTypeProperty.recursive,
|
|
421
438
|
type: this.createType(astObjectTypeProperty.type),
|
|
@@ -453,14 +470,6 @@ export class TypeFactory {
|
|
|
453
470
|
nodeKinds: astType.nodeKinds,
|
|
454
471
|
});
|
|
455
472
|
}
|
|
456
|
-
createUnionType(astType) {
|
|
457
|
-
return new UnionType({
|
|
458
|
-
comment: astType.comment,
|
|
459
|
-
label: astType.label,
|
|
460
|
-
memberDiscriminantValues: astType.memberDiscriminantValues,
|
|
461
|
-
memberTypes: astType.memberTypes.map((astType) => this.createType(astType)),
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
473
|
}
|
|
465
474
|
function objectTypeNeedsIdentifierPrefixProperty(objectType) {
|
|
466
475
|
return objectType.identifierMintingStrategy
|
|
@@ -478,4 +487,22 @@ function objectTypeNeedsIdentifierPrefixProperty(objectType) {
|
|
|
478
487
|
})
|
|
479
488
|
.orDefault(false);
|
|
480
489
|
}
|
|
490
|
+
function tsName(name, options) {
|
|
491
|
+
if (name[0] === "$") {
|
|
492
|
+
return name;
|
|
493
|
+
}
|
|
494
|
+
// Adapted from https://github.com/sindresorhus/to-valid-identifier , MIT license
|
|
495
|
+
if (reservedTsIdentifiers.has(name)) {
|
|
496
|
+
// We prefix with underscore to avoid any potential conflicts with the Base62 encoded string.
|
|
497
|
+
return `$_${name}$`;
|
|
498
|
+
}
|
|
499
|
+
let tsName = name.replaceAll(/\P{ID_Continue}/gu, (x) => `$${base62.encodeInteger(x.codePointAt(0))}$`);
|
|
500
|
+
if (options?.synthetic) {
|
|
501
|
+
tsName = `${syntheticNamePrefix}${tsName}`;
|
|
502
|
+
}
|
|
503
|
+
return tsName;
|
|
504
|
+
}
|
|
505
|
+
const reservedTsIdentifiers = reservedTsIdentifiers_({
|
|
506
|
+
includeGlobalProperties: true,
|
|
507
|
+
});
|
|
481
508
|
//# sourceMappingURL=TypeFactory.js.map
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { invariant } from "ts-invariant";
|
|
1
2
|
import * as ast from "../../ast/index.js";
|
|
2
3
|
import { ObjectType_jsonTypeAliasDeclaration } from "./_ObjectType/ObjectType_jsonTypeAliasDeclaration.js";
|
|
3
4
|
import { ObjectType_jsonZodSchemaFunctionDeclaration } from "./_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js";
|
|
4
|
-
import { ObjectUnionType_jsonTypeAliasDeclaration } from "./_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js";
|
|
5
|
-
import { ObjectUnionType_jsonZodSchemaFunctionDeclaration } from "./_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js";
|
|
6
5
|
import { snippets } from "./snippets.js";
|
|
7
6
|
import { TypeFactory } from "./TypeFactory.js";
|
|
8
7
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
@@ -19,12 +18,13 @@ ${joinCode([
|
|
|
19
18
|
], { on: "\n\n" })}
|
|
20
19
|
}`);
|
|
21
20
|
}
|
|
22
|
-
for (const
|
|
21
|
+
for (const astNamedUnionType of ast_.namedUnionTypes.map((astNamedUnionType) => this.typeFactory.createUnionType(astNamedUnionType))) {
|
|
22
|
+
invariant(astNamedUnionType.kind !== "AnonymousUnionType");
|
|
23
23
|
declarations.push(code `\
|
|
24
|
-
export namespace ${
|
|
24
|
+
export namespace ${astNamedUnionType.staticModuleName} {
|
|
25
25
|
${joinCode([
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
astNamedUnionType.jsonTypeAliasDeclaration,
|
|
27
|
+
astNamedUnionType.jsonZodSchemaFunctionDeclaration,
|
|
28
28
|
], { on: "\n\n" })}
|
|
29
29
|
}`);
|
|
30
30
|
}
|
|
@@ -109,7 +109,7 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
109
109
|
/**
|
|
110
110
|
* Expression to deserialize this property on the given rdfjsResource.Resource to a Either<Error, this property type>.
|
|
111
111
|
*/
|
|
112
|
-
abstract
|
|
112
|
+
abstract fromRdfResourceValuesExpression(parameters: {
|
|
113
113
|
variables: {
|
|
114
114
|
context: Code;
|
|
115
115
|
graph: Code;
|
|
@@ -184,8 +184,8 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
184
184
|
/**
|
|
185
185
|
* Statements to serialize this property to an RDF resource.
|
|
186
186
|
*/
|
|
187
|
-
abstract
|
|
188
|
-
variables: Omit<Parameters<Type["
|
|
187
|
+
abstract toRdfRdfResourceValuesStatements(parameters: {
|
|
188
|
+
variables: Omit<Parameters<Type["toRdfResourceValuesExpression"]>[0]["variables"], "propertyPath">;
|
|
189
189
|
}): readonly Code[];
|
|
190
190
|
}
|
|
191
191
|
//# sourceMappingURL=AbstractProperty.d.ts.map
|
package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.d.ts → DiscriminantProperty.d.ts}
RENAMED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
3
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
4
|
-
export declare class
|
|
4
|
+
export declare class DiscriminantProperty extends AbstractProperty<DiscriminantProperty.Type> {
|
|
5
5
|
readonly constructorParametersSignature: Maybe<Code>;
|
|
6
6
|
readonly equalsFunction: Maybe<Code>;
|
|
7
|
-
readonly filterProperty: AbstractProperty<
|
|
7
|
+
readonly filterProperty: AbstractProperty<DiscriminantProperty.Type>["filterProperty"];
|
|
8
8
|
readonly getAccessorDeclaration: Maybe<Code>;
|
|
9
|
-
readonly graphqlField: AbstractProperty<
|
|
10
|
-
readonly kind = "
|
|
9
|
+
readonly graphqlField: AbstractProperty<DiscriminantProperty.Type>["graphqlField"];
|
|
10
|
+
readonly kind = "DiscriminantProperty";
|
|
11
11
|
readonly mutable = false;
|
|
12
12
|
readonly recursive = false;
|
|
13
13
|
constructor({ type, ...superParameters }: {
|
|
14
|
-
type:
|
|
14
|
+
type: DiscriminantProperty.Type;
|
|
15
15
|
} & ConstructorParameters<typeof AbstractProperty>[0]);
|
|
16
16
|
get declaration(): Maybe<Code>;
|
|
17
17
|
get jsonSignature(): Maybe<Code>;
|
|
18
|
-
get jsonZodSchema(): AbstractProperty<
|
|
18
|
+
get jsonZodSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonZodSchema"];
|
|
19
19
|
private get abstract();
|
|
20
20
|
private get initializer();
|
|
21
21
|
private get override();
|
|
22
22
|
constructorStatements(): readonly Code[];
|
|
23
23
|
fromJsonStatements(): readonly Code[];
|
|
24
|
-
|
|
25
|
-
hashStatements({ variables, }: Parameters<AbstractProperty<
|
|
26
|
-
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<
|
|
24
|
+
fromRdfResourceValuesExpression(): Maybe<Code>;
|
|
25
|
+
hashStatements({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["hashStatements"]>[0]): readonly Code[];
|
|
26
|
+
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
27
27
|
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
28
|
-
sparqlWherePatternsExpression(): ReturnType<AbstractProperty<
|
|
29
|
-
toJsonObjectMemberExpression({ variables, }: Parameters<AbstractProperty<
|
|
30
|
-
|
|
28
|
+
sparqlWherePatternsExpression(): ReturnType<AbstractProperty<DiscriminantProperty.Type>["sparqlWherePatternsExpression"]>;
|
|
29
|
+
toJsonObjectMemberExpression({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
|
|
30
|
+
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
31
31
|
}
|
|
32
|
-
export declare namespace
|
|
32
|
+
export declare namespace DiscriminantProperty {
|
|
33
33
|
class Type {
|
|
34
34
|
readonly filterFunction: Code;
|
|
35
35
|
readonly mutable: boolean;
|
|
@@ -45,4 +45,4 @@ export declare namespace TypeDiscriminantProperty {
|
|
|
45
45
|
get values(): string[];
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
//# sourceMappingURL=
|
|
48
|
+
//# sourceMappingURL=DiscriminantProperty.d.ts.map
|
package/dist/generators/ts/_ObjectType/{TypeDiscriminantProperty.js → DiscriminantProperty.js}
RENAMED
|
@@ -12,13 +12,13 @@ import { removeUndefined } from "../removeUndefined.js";
|
|
|
12
12
|
import { snippets } from "../snippets.js";
|
|
13
13
|
import { arrayOf, code, literalOf } from "../ts-poet-wrapper.js";
|
|
14
14
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
15
|
-
export class
|
|
15
|
+
export class DiscriminantProperty extends AbstractProperty {
|
|
16
16
|
constructorParametersSignature = Maybe.empty();
|
|
17
17
|
equalsFunction = Maybe.of(code `${snippets.strictEquals}`);
|
|
18
18
|
filterProperty = Maybe.empty();
|
|
19
19
|
getAccessorDeclaration = Maybe.empty();
|
|
20
20
|
graphqlField = Maybe.empty();
|
|
21
|
-
kind = "
|
|
21
|
+
kind = "DiscriminantProperty";
|
|
22
22
|
mutable = false;
|
|
23
23
|
recursive = false;
|
|
24
24
|
constructor({ type, ...superParameters }) {
|
|
@@ -72,7 +72,7 @@ export class TypeDiscriminantProperty extends AbstractProperty {
|
|
|
72
72
|
? [code `const ${this.name} = ${this.initializer};`]
|
|
73
73
|
: [];
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
fromRdfResourceValuesExpression() {
|
|
76
76
|
return !this.abstract && this.objectType.declarationType === "interface"
|
|
77
77
|
? Maybe.of(code `${imports.Right}<${literalOf(this.objectType.discriminantValue)}>(${this.initializer})`)
|
|
78
78
|
: Maybe.empty();
|
|
@@ -93,17 +93,17 @@ export class TypeDiscriminantProperty extends AbstractProperty {
|
|
|
93
93
|
toJsonObjectMemberExpression({ variables, }) {
|
|
94
94
|
return Maybe.of(code `${this.name}: ${variables.value}`);
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
toRdfRdfResourceValuesStatements() {
|
|
97
97
|
return [];
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
__decorate([
|
|
101
101
|
Memoize()
|
|
102
|
-
],
|
|
102
|
+
], DiscriminantProperty.prototype, "jsonSignature", null);
|
|
103
103
|
__decorate([
|
|
104
104
|
Memoize()
|
|
105
|
-
],
|
|
106
|
-
(function (
|
|
105
|
+
], DiscriminantProperty.prototype, "jsonZodSchema", null);
|
|
106
|
+
(function (DiscriminantProperty) {
|
|
107
107
|
class Type {
|
|
108
108
|
filterFunction = code `nonextant`;
|
|
109
109
|
mutable;
|
|
@@ -137,6 +137,6 @@ __decorate([
|
|
|
137
137
|
__decorate([
|
|
138
138
|
Memoize()
|
|
139
139
|
], Type.prototype, "values", null);
|
|
140
|
-
|
|
141
|
-
})(
|
|
142
|
-
//# sourceMappingURL=
|
|
140
|
+
DiscriminantProperty.Type = Type;
|
|
141
|
+
})(DiscriminantProperty || (DiscriminantProperty = {}));
|
|
142
|
+
//# sourceMappingURL=DiscriminantProperty.js.map
|
|
@@ -21,12 +21,12 @@ export declare class IdentifierPrefixProperty extends AbstractProperty<StringTyp
|
|
|
21
21
|
get getAccessorDeclaration(): Maybe<Code>;
|
|
22
22
|
constructorStatements({ variables, }: Parameters<AbstractProperty<StringType>["constructorStatements"]>[0]): readonly Code[];
|
|
23
23
|
fromJsonStatements(): readonly Code[];
|
|
24
|
-
|
|
24
|
+
fromRdfResourceValuesExpression(): Maybe<Code>;
|
|
25
25
|
hashStatements(): readonly Code[];
|
|
26
26
|
jsonUiSchemaElement(): Maybe<Code>;
|
|
27
27
|
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
28
28
|
sparqlWherePatternsExpression(): ReturnType<AbstractProperty<StringType>["sparqlWherePatternsExpression"]>;
|
|
29
29
|
toJsonObjectMemberExpression(): Maybe<Code>;
|
|
30
|
-
|
|
30
|
+
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
31
31
|
}
|
|
32
32
|
//# sourceMappingURL=IdentifierPrefixProperty.d.ts.map
|
|
@@ -61,7 +61,7 @@ protected ${!this.own ? "override " : ""} get ${this.name}(): ${this.type.name}
|
|
|
61
61
|
fromJsonStatements() {
|
|
62
62
|
return [];
|
|
63
63
|
}
|
|
64
|
-
|
|
64
|
+
fromRdfResourceValuesExpression() {
|
|
65
65
|
return Maybe.empty();
|
|
66
66
|
}
|
|
67
67
|
hashStatements() {
|
|
@@ -79,7 +79,7 @@ protected ${!this.own ? "override " : ""} get ${this.name}(): ${this.type.name}
|
|
|
79
79
|
toJsonObjectMemberExpression() {
|
|
80
80
|
return Maybe.empty();
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
toRdfRdfResourceValuesStatements() {
|
|
83
83
|
return [];
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -35,7 +35,7 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
|
|
|
35
35
|
private get override();
|
|
36
36
|
constructorStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorStatements"]>[0]): readonly Code[];
|
|
37
37
|
fromJsonStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonStatements"]>[0]): readonly Code[];
|
|
38
|
-
|
|
38
|
+
fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromRdfResourceValuesExpression"]>[0]): Maybe<Code>;
|
|
39
39
|
hashStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["hashStatements"]>[0]): readonly Code[];
|
|
40
40
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
41
41
|
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
@@ -44,6 +44,6 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
|
|
|
44
44
|
patterns: Code;
|
|
45
45
|
}>;
|
|
46
46
|
toJsonObjectMemberExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["toJsonObjectMemberExpression"]>[0]): Maybe<Code>;
|
|
47
|
-
|
|
47
|
+
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
48
48
|
}
|
|
49
49
|
//# sourceMappingURL=IdentifierProperty.d.ts.map
|
|
@@ -143,6 +143,9 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
145
|
get jsonSignature() {
|
|
146
|
+
if (this.type.in_.length > 0) {
|
|
147
|
+
return Maybe.of(code `readonly "@id": ${this.type.in_.map((iri) => `"${iri.value}"`).join(" | ")}`);
|
|
148
|
+
}
|
|
146
149
|
return Maybe.of(code `readonly "@id": string`);
|
|
147
150
|
}
|
|
148
151
|
get jsonZodSchema() {
|
|
@@ -277,8 +280,8 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
277
280
|
code `const ${this.name} = ${this.type.fromJsonExpression({ variables: { value: variables.jsonObject } })};`,
|
|
278
281
|
];
|
|
279
282
|
}
|
|
280
|
-
|
|
281
|
-
return Maybe.of(code `${this.type.
|
|
283
|
+
fromRdfResourceValuesExpression({ variables, }) {
|
|
284
|
+
return Maybe.of(code `${this.type.fromRdfResourceValuesExpression({
|
|
282
285
|
variables: {
|
|
283
286
|
...variables,
|
|
284
287
|
propertyPath: rdfjsTermExpression(rdf.subject),
|
|
@@ -298,7 +301,7 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
298
301
|
sparqlWherePatternsExpression({ variables, }) {
|
|
299
302
|
return Maybe.of({
|
|
300
303
|
condition: code `${variables.focusIdentifier}.termType === "Variable"`,
|
|
301
|
-
patterns: code `${this.type.
|
|
304
|
+
patterns: code `${this.type.valueSparqlWherePatternsFunction}(${{
|
|
302
305
|
filter: code `${variables.filter}?.${this.name}`,
|
|
303
306
|
ignoreRdfType: true, // Unused
|
|
304
307
|
preferredLanguages: variables.preferredLanguages,
|
|
@@ -327,7 +330,7 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
327
330
|
invariant(valueToNodeKinds.length === 2);
|
|
328
331
|
return Maybe.of(code `"@id": ${variables.value}.termType === "${NodeKind.toTermType(nodeKinds[0])}" ? ${valueToNodeKinds[0]} : ${valueToNodeKinds[1]}`);
|
|
329
332
|
}
|
|
330
|
-
|
|
333
|
+
toRdfRdfResourceValuesStatements() {
|
|
331
334
|
return [];
|
|
332
335
|
}
|
|
333
336
|
}
|
|
@@ -5,7 +5,7 @@ import { tsComment } from "../tsComment.js";
|
|
|
5
5
|
import { ObjectType_equalsFunctionOrMethodDeclaration } from "./ObjectType_equalsFunctionOrMethodDeclaration.js";
|
|
6
6
|
import { ObjectType_hashFunctionOrMethodDeclarations } from "./ObjectType_hashFunctionOrMethodDeclarations.js";
|
|
7
7
|
import { ObjectType_toJsonFunctionOrMethodDeclaration } from "./ObjectType_toJsonFunctionOrMethodDeclaration.js";
|
|
8
|
-
import {
|
|
8
|
+
import { ObjectType_toRdfResourceFunctionOrMethodDeclaration } from "./ObjectType_toRdfResourceFunctionOrMethodDeclaration.js";
|
|
9
9
|
function ObjectType_constructorDeclaration() {
|
|
10
10
|
const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParametersSignature.toList());
|
|
11
11
|
const parametersType = [];
|
|
@@ -47,16 +47,16 @@ export function ObjectType_classDeclaration() {
|
|
|
47
47
|
${this.comment
|
|
48
48
|
.alt(this.label)
|
|
49
49
|
.map(tsComment)
|
|
50
|
-
.orDefault("")}
|
|
50
|
+
.orDefault("")}export ${this.abstract ? "abstract " : ""}class ${def(this.name)}${this.parentObjectTypes.length > 0 ? ` extends ${this.parentObjectTypes[0].name}` : ""} {
|
|
51
51
|
${joinCode([
|
|
52
52
|
...this.properties.flatMap((property) => property.declaration.toList()),
|
|
53
|
-
ObjectType_constructorDeclaration.
|
|
53
|
+
ObjectType_constructorDeclaration.call(this),
|
|
54
54
|
...this.properties.flatMap((property) => property.getAccessorDeclaration.toList()),
|
|
55
|
-
...ObjectType_equalsFunctionOrMethodDeclaration.
|
|
56
|
-
...ObjectType_hashFunctionOrMethodDeclarations.
|
|
57
|
-
...ObjectType_toJsonFunctionOrMethodDeclaration.
|
|
58
|
-
...
|
|
59
|
-
...ObjectType_toStringMethodDeclaration.
|
|
55
|
+
...ObjectType_equalsFunctionOrMethodDeclaration.call(this).toList(),
|
|
56
|
+
...ObjectType_hashFunctionOrMethodDeclarations.call(this),
|
|
57
|
+
...ObjectType_toJsonFunctionOrMethodDeclaration.call(this).toList(),
|
|
58
|
+
...ObjectType_toRdfResourceFunctionOrMethodDeclaration.call(this).toList(),
|
|
59
|
+
...ObjectType_toStringMethodDeclaration.call(this).toList(),
|
|
60
60
|
], { on: "\n\n" })}
|
|
61
61
|
}`;
|
|
62
62
|
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_focusSparqlConstructTriplesFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts.map
|