@shaclmate/compiler 4.0.8 → 4.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Compiler.d.ts +1 -4
- package/dist/Compiler.js +1 -5
- package/dist/ShapesGraphToAstTransformer.d.ts +2 -11
- package/dist/ShapesGraphToAstTransformer.js +25 -27
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.d.ts +3 -0
- package/dist/_ShapesGraphToAstTransformer/defaultNodeShapeNodeKinds.js +5 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.d.ts +4 -0
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +27 -0
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +74 -19
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +45 -91
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.d.ts +11 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +146 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +7 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +182 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +9 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +3 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +33 -10
- package/dist/ast/AbstractCompoundType.d.ts +26 -8
- package/dist/ast/AbstractCompoundType.js +84 -16
- package/dist/ast/AbstractContainerType.d.ts +2 -4
- package/dist/ast/AbstractContainerType.js +3 -4
- package/dist/ast/AbstractLazyObjectType.d.ts +1 -0
- package/dist/ast/AbstractLazyObjectType.js +3 -0
- package/dist/ast/AbstractTermType.d.ts +1 -0
- package/dist/ast/AbstractTermType.js +1 -0
- package/dist/ast/AbstractType.d.ts +16 -1
- package/dist/ast/AbstractType.js +11 -1
- package/dist/ast/Ast.d.ts +5 -5
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/DefaultValueType.d.ts +1 -2
- package/dist/ast/DefaultValueType.js +2 -0
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/IntersectionType.d.ts +7 -2
- package/dist/ast/IntersectionType.js +8 -0
- package/dist/ast/ListType.d.ts +2 -9
- package/dist/ast/ListType.js +1 -9
- package/dist/ast/LiteralType.d.ts +1 -0
- package/dist/ast/LiteralType.js +26 -0
- package/dist/ast/ObjectCompoundType.d.ts +12 -0
- package/dist/ast/ObjectCompoundType.js +88 -0
- package/dist/ast/ObjectIntersectionType.d.ts +3 -7
- package/dist/ast/ObjectIntersectionType.js +1 -7
- package/dist/ast/ObjectType.d.ts +14 -31
- package/dist/ast/ObjectType.js +41 -73
- package/dist/ast/ObjectUnionType.d.ts +3 -7
- package/dist/ast/ObjectUnionType.js +1 -7
- package/dist/ast/OptionType.d.ts +1 -2
- package/dist/ast/OptionType.js +2 -0
- package/dist/ast/SetType.d.ts +1 -2
- package/dist/ast/SetType.js +2 -0
- package/dist/ast/Type.d.ts +1 -4
- package/dist/ast/Type.js +0 -6
- package/dist/ast/UnionType.d.ts +11 -6
- package/dist/ast/UnionType.js +6 -4
- package/dist/ast/index.d.ts +1 -2
- package/dist/ast/index.js +1 -2
- package/dist/generators/json/AstJsonGenerator.js +17 -15
- package/dist/generators/ts/AbstractCollectionType.d.ts +1 -1
- package/dist/generators/ts/AbstractCollectionType.js +10 -12
- package/dist/generators/ts/AbstractContainerType.d.ts +9 -4
- package/dist/generators/ts/AbstractContainerType.js +10 -3
- package/dist/generators/ts/AbstractDateType.d.ts +2 -2
- package/dist/generators/ts/AbstractDateType.js +2 -2
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractIdentifierType.js +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +13 -10
- package/dist/generators/ts/AbstractLazyObjectType.js +21 -16
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +33 -0
- package/dist/generators/ts/AbstractNamedUnionType.js +195 -0
- package/dist/generators/ts/AbstractNumericType.d.ts +3 -3
- package/dist/generators/ts/AbstractNumericType.js +4 -4
- package/dist/generators/ts/AbstractTermType.d.ts +7 -4
- package/dist/generators/ts/AbstractTermType.js +7 -4
- package/dist/generators/ts/AbstractType.d.ts +34 -19
- package/dist/generators/ts/AbstractUnionType.d.ts +80 -0
- package/dist/generators/ts/AbstractUnionType.js +514 -0
- package/dist/generators/ts/AnonymousUnionType.d.ts +26 -0
- package/dist/generators/ts/AnonymousUnionType.js +56 -0
- package/dist/generators/ts/BigDecimalType.d.ts +4 -4
- package/dist/generators/ts/BigDecimalType.js +5 -5
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +2 -2
- package/dist/generators/ts/BlankNodeType.js +2 -2
- package/dist/generators/ts/BooleanType.d.ts +3 -3
- package/dist/generators/ts/BooleanType.js +3 -3
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +5 -5
- package/dist/generators/ts/DefaultValueType.js +17 -16
- package/dist/generators/ts/IdentifierType.d.ts +2 -2
- package/dist/generators/ts/IdentifierType.js +2 -2
- package/dist/generators/ts/IriType.d.ts +2 -2
- package/dist/generators/ts/IriType.js +2 -2
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +10 -10
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +8 -8
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +9 -10
- package/dist/generators/ts/ListType.d.ts +9 -8
- package/dist/generators/ts/ListType.js +15 -14
- package/dist/generators/ts/LiteralType.d.ts +2 -2
- package/dist/generators/ts/LiteralType.js +3 -3
- package/dist/generators/ts/NamedObjectType.d.ts +126 -0
- package/dist/generators/ts/NamedObjectType.js +420 -0
- package/dist/generators/ts/NamedObjectUnionType.d.ts +35 -0
- package/dist/generators/ts/NamedObjectUnionType.js +217 -0
- package/dist/generators/ts/NamedUnionType.d.ts +11 -0
- package/dist/generators/ts/NamedUnionType.js +13 -0
- package/dist/generators/ts/OptionType.d.ts +5 -5
- package/dist/generators/ts/OptionType.js +12 -12
- package/dist/generators/ts/SetType.d.ts +4 -4
- package/dist/generators/ts/SetType.js +13 -11
- package/dist/generators/ts/StringType.d.ts +3 -3
- package/dist/generators/ts/StringType.js +3 -3
- package/dist/generators/ts/TermType.d.ts +2 -2
- package/dist/generators/ts/TermType.js +3 -3
- package/dist/generators/ts/TsGenerator.js +28 -20
- package/dist/generators/ts/Type.d.ts +5 -4
- package/dist/generators/ts/TypeFactory.d.ts +9 -7
- package/dist/generators/ts/TypeFactory.js +139 -112
- package/dist/generators/ts/ZodGenerator.js +18 -16
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.d.ts +9 -9
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/AbstractProperty.js +3 -3
- package/dist/generators/ts/{_ObjectType/TypeDiscriminantProperty.d.ts → _NamedObjectType/DiscriminantProperty.d.ts} +14 -14
- package/dist/generators/ts/{_ObjectType/TypeDiscriminantProperty.js → _NamedObjectType/DiscriminantProperty.js} +22 -20
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.d.ts +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierPrefixProperty.js +6 -6
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.d.ts +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/IdentifierProperty.js +31 -28
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_classDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_classDeclaration.js → _NamedObjectType/NamedObjectType_classDeclaration.js} +15 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_createFunctionDeclaration.js → _NamedObjectType/NamedObjectType_createFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterFunctionDeclaration.js → _NamedObjectType/NamedObjectType_filterFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_filterTypeDeclaration.js → _NamedObjectType/NamedObjectType_filterTypeDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.js → _NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +6 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.js → _NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfFunctionDeclaration.js → _NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js} +6 -7
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_fromRdfTypeVariableStatement.js → _NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_graphqlTypeVariableStatement.js → _NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.js → _NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_interfaceDeclaration.js → _NamedObjectType/NamedObjectType_interfaceDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_isTypeFunctionDeclaration.js → _NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonTypeAliasDeclaration.js → _NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js → _NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_objectSetMethodNames.js → _NamedObjectType/NamedObjectType_objectSetMethodNames.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +38 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.js → _NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js} +16 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +4 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_schemaVariableStatement.js → _NamedObjectType/NamedObjectType_schemaVariableStatement.js} +3 -4
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +2 -2
- package/dist/generators/ts/{_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js → _NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js} +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.js → _NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js} +10 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +13 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +15 -0
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.d.ts +2 -2
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.d.ts +3 -3
- package/dist/generators/ts/{_ObjectType → _NamedObjectType}/ShaclProperty.js +14 -14
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.js +12 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.js +14 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +17 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +15 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.d.ts +5 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +35 -0
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.js +7 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.js +13 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.js +16 -0
- package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_booleanEquals.js +1 -1
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +1 -1
- package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +2 -3
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +4 -3
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +4 -3
- package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +3 -2
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +4 -4
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +25 -25
- package/dist/generators/ts/imports.d.ts +1 -1
- package/dist/generators/ts/imports.js +1 -1
- package/dist/generators/ts/objectSetDeclarations.d.ts +5 -5
- package/dist/generators/ts/objectSetDeclarations.js +34 -31
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +5 -5
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +6 -4
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +4 -4
- package/dist/generators/ts/objectSetMethodSignatures.js +9 -9
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +5 -5
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +54 -53
- package/dist/generators/ts/singleEntryRecord.d.ts +2 -0
- package/dist/generators/ts/singleEntryRecord.js +6 -0
- package/dist/generators/ts/snippets.d.ts +10 -6
- package/dist/generators/ts/snippets.js +20 -12
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +5 -5
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +19 -20
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +4 -4
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +14 -9
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +5 -5
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +2 -2
- package/dist/input/NodeShape.d.ts +0 -1
- package/dist/input/NodeShape.js +0 -3
- package/dist/input/ShapesGraph.d.ts +3 -2
- package/dist/input/ShapesGraph.js +12 -7
- package/dist/input/generated.d.ts +1899 -88
- package/dist/input/generated.js +676 -564
- package/package.json +5 -7
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/CurieFactory.js +0 -45
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +0 -3
- package/dist/_ShapesGraphToAstTransformer/NodeShapeAstType.js +0 -2
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/index.js +0 -6
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.d.ts +0 -5
- package/dist/_ShapesGraphToAstTransformer/shapeIdentifier.js +0 -9
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +0 -11
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +0 -338
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstAbstractTypeProperties.js +0 -31
- package/dist/ast/AbstractObjectCompoundType.d.ts +0 -45
- package/dist/ast/AbstractObjectCompoundType.js +0 -180
- package/dist/ast/Curie.d.ts +0 -21
- package/dist/ast/Curie.js +0 -29
- package/dist/ast/PlaceholderType.d.ts +0 -15
- package/dist/ast/PlaceholderType.js +0 -19
- package/dist/generators/codeName.d.ts +0 -6
- package/dist/generators/codeName.js +0 -66
- package/dist/generators/ts/AbstractDeclaredType.d.ts +0 -23
- package/dist/generators/ts/AbstractDeclaredType.js +0 -17
- package/dist/generators/ts/ObjectType.d.ts +0 -117
- package/dist/generators/ts/ObjectType.js +0 -402
- package/dist/generators/ts/ObjectUnionType.d.ts +0 -65
- package/dist/generators/ts/ObjectUnionType.js +0 -257
- package/dist/generators/ts/UnionType.d.ts +0 -40
- package/dist/generators/ts/UnionType.js +0 -527
- package/dist/generators/ts/_ObjectType/ObjectType_classDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.js +0 -66
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionOrMethodDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_objectSetMethodNames.d.ts +0 -9
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfFunctionOrMethodDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/MemberType.d.ts +0 -34
- package/dist/generators/ts/_ObjectUnionType/MemberType.js +0 -105
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_equalsFunctionDeclaration.js +0 -29
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_filterTypeDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js +0 -20
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_graphqlTypeVariableStatement.js +0 -18
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_hashFunctionDeclaration.js +0 -28
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_identifierTypeDeclarations.js +0 -9
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_isTypeFunctionDeclaration.js +0 -13
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonTypeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js +0 -14
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_schemaVariableStatement.js +0 -37
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js +0 -35
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js +0 -26
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.d.ts +0 -5
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.js +0 -43
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_typeAliasDeclaration.js +0 -10
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_FromRdfOptions.js +0 -5
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfParameters.js +0 -5
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.js +0 -12
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunction.js +0 -6
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.js +0 -15
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/Property.js +0 -0
- /package/dist/generators/ts/{_ObjectType → _NamedObjectType}/identifierTypeDeclarations.js +0 -0
|
@@ -0,0 +1,420 @@
|
|
|
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 { camelCase } from "change-case";
|
|
8
|
+
import { Maybe, NonEmptyList } from "purify-ts";
|
|
9
|
+
import { Memoize } from "typescript-memoize";
|
|
10
|
+
import { DiscriminantProperty as _DiscriminantProperty } from "./_NamedObjectType/DiscriminantProperty.js";
|
|
11
|
+
import { IdentifierPrefixProperty as _IdentifierPrefixProperty } from "./_NamedObjectType/IdentifierPrefixProperty.js";
|
|
12
|
+
import { IdentifierProperty as _IdentifierProperty } from "./_NamedObjectType/IdentifierProperty.js";
|
|
13
|
+
import { identifierTypeDeclarations } from "./_NamedObjectType/identifierTypeDeclarations.js";
|
|
14
|
+
import { NamedObjectType_classDeclaration } from "./_NamedObjectType/NamedObjectType_classDeclaration.js";
|
|
15
|
+
import { NamedObjectType_createFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_createFunctionDeclaration.js";
|
|
16
|
+
import { NamedObjectType_equalsFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_equalsFunctionOrMethodDeclaration.js";
|
|
17
|
+
import { NamedObjectType_filterFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js";
|
|
18
|
+
import { NamedObjectType_filterTypeDeclaration } from "./_NamedObjectType/NamedObjectType_filterTypeDeclaration.js";
|
|
19
|
+
import { NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js";
|
|
20
|
+
import { NamedObjectType_focusSparqlWherePatternsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js";
|
|
21
|
+
import { NamedObjectType_fromJsonFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js";
|
|
22
|
+
import { NamedObjectType_fromRdfResourceFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js";
|
|
23
|
+
import { NamedObjectType_fromRdfResourceValuesFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js";
|
|
24
|
+
import { NamedObjectType_fromRdfTypeVariableStatement } from "./_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js";
|
|
25
|
+
import { NamedObjectType_graphqlTypeVariableStatement } from "./_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js";
|
|
26
|
+
import { NamedObjectType_hashFunctionOrMethodDeclarations } from "./_NamedObjectType/NamedObjectType_hashFunctionOrMethodDeclarations.js";
|
|
27
|
+
import { NamedObjectType_interfaceDeclaration } from "./_NamedObjectType/NamedObjectType_interfaceDeclaration.js";
|
|
28
|
+
import { NamedObjectType_isTypeFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js";
|
|
29
|
+
import { NamedObjectType_jsonParseFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js";
|
|
30
|
+
import { NamedObjectType_jsonSchemaFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js";
|
|
31
|
+
import { NamedObjectType_jsonTypeAliasDeclaration } from "./_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js";
|
|
32
|
+
import { NamedObjectType_jsonUiSchemaFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js";
|
|
33
|
+
import { NamedObjectType_objectSetMethodNames } from "./_NamedObjectType/NamedObjectType_objectSetMethodNames.js";
|
|
34
|
+
import { NamedObjectType_propertiesFromJsonFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js";
|
|
35
|
+
import { NamedObjectType_propertiesFromRdfResourceFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js";
|
|
36
|
+
import { NamedObjectType_schemaVariableStatement } from "./_NamedObjectType/NamedObjectType_schemaVariableStatement.js";
|
|
37
|
+
import { NamedObjectType_sparqlConstructQueryFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
38
|
+
import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
39
|
+
import { NamedObjectType_toJsonFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_toJsonFunctionOrMethodDeclaration.js";
|
|
40
|
+
import { NamedObjectType_toRdfResourceFunctionOrMethodDeclaration } from "./_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js";
|
|
41
|
+
import { NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js";
|
|
42
|
+
import { NamedObjectType_valueSparqlWherePatternsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js";
|
|
43
|
+
import { ShaclProperty as _ShaclProperty } from "./_NamedObjectType/ShaclProperty.js";
|
|
44
|
+
import { AbstractType } from "./AbstractType.js";
|
|
45
|
+
import { imports } from "./imports.js";
|
|
46
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
47
|
+
import { code, def, joinCode } from "./ts-poet-wrapper.js";
|
|
48
|
+
export class NamedObjectType extends AbstractType {
|
|
49
|
+
imports;
|
|
50
|
+
toRdfTypes;
|
|
51
|
+
abstract;
|
|
52
|
+
declarationType;
|
|
53
|
+
extern;
|
|
54
|
+
features;
|
|
55
|
+
fromRdfType;
|
|
56
|
+
graphqlArgs = Maybe.empty();
|
|
57
|
+
identifierType;
|
|
58
|
+
kind = "NamedObjectType";
|
|
59
|
+
name;
|
|
60
|
+
recursive;
|
|
61
|
+
staticModuleName;
|
|
62
|
+
synthetic;
|
|
63
|
+
typeofs = NonEmptyList(["object"]);
|
|
64
|
+
constructor({ abstract, declarationType, extern, features, fromRdfType, identifierType, imports, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyIdentifierProperty, lazyParentObjectTypes, lazyProperties, name, recursive, staticModuleName, synthetic, toRdfTypes, ...superParameters }) {
|
|
65
|
+
super(superParameters);
|
|
66
|
+
this.abstract = abstract;
|
|
67
|
+
this.declarationType = declarationType;
|
|
68
|
+
this.extern = extern;
|
|
69
|
+
this.features = features;
|
|
70
|
+
this.fromRdfType = fromRdfType;
|
|
71
|
+
this.identifierType = identifierType;
|
|
72
|
+
this.imports = imports;
|
|
73
|
+
// Lazily initialize some members in getters to avoid recursive construction
|
|
74
|
+
this.lazyAncestorObjectTypes = lazyAncestorObjectTypes;
|
|
75
|
+
this.lazyChildObjectTypes = lazyChildObjectTypes;
|
|
76
|
+
this.lazyDescendantObjectTypes = lazyDescendantObjectTypes;
|
|
77
|
+
this.lazyDiscriminantProperty = lazyDiscriminantProperty;
|
|
78
|
+
this.lazyIdentifierProperty = lazyIdentifierProperty;
|
|
79
|
+
this.lazyParentObjectTypes = lazyParentObjectTypes;
|
|
80
|
+
this.lazyProperties = lazyProperties;
|
|
81
|
+
this.name = name;
|
|
82
|
+
this.recursive = recursive;
|
|
83
|
+
this.staticModuleName = staticModuleName;
|
|
84
|
+
this.synthetic = synthetic;
|
|
85
|
+
this.toRdfTypes = toRdfTypes;
|
|
86
|
+
}
|
|
87
|
+
get _discriminantProperty() {
|
|
88
|
+
return this.lazyDiscriminantProperty(this);
|
|
89
|
+
}
|
|
90
|
+
get ancestorObjectTypes() {
|
|
91
|
+
return this.lazyAncestorObjectTypes();
|
|
92
|
+
}
|
|
93
|
+
get childObjectTypes() {
|
|
94
|
+
return this.lazyChildObjectTypes();
|
|
95
|
+
}
|
|
96
|
+
get conversions() {
|
|
97
|
+
return [
|
|
98
|
+
{
|
|
99
|
+
conversionExpression: (value) => value,
|
|
100
|
+
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof ${this.name}`,
|
|
101
|
+
sourceTypeName: this.name,
|
|
102
|
+
sourceTypeof: "object",
|
|
103
|
+
},
|
|
104
|
+
];
|
|
105
|
+
}
|
|
106
|
+
get declaration() {
|
|
107
|
+
const declarations = [];
|
|
108
|
+
for (const import_ of this.imports) {
|
|
109
|
+
declarations.push(code `${import_}`);
|
|
110
|
+
}
|
|
111
|
+
if (!this.extern) {
|
|
112
|
+
const staticModuleDeclarations = [];
|
|
113
|
+
switch (this.declarationType) {
|
|
114
|
+
case "class": {
|
|
115
|
+
declarations.push(NamedObjectType_classDeclaration.call(this));
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "interface": {
|
|
119
|
+
declarations.push(NamedObjectType_interfaceDeclaration.call(this));
|
|
120
|
+
staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionOrMethodDeclaration.bind(this)().toList(), ...NamedObjectType_hashFunctionOrMethodDeclarations.call(this));
|
|
121
|
+
break;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
const jsonModuleDeclarations = [
|
|
125
|
+
...NamedObjectType_jsonParseFunctionDeclaration.call(this).toList(),
|
|
126
|
+
...NamedObjectType_jsonSchemaFunctionDeclaration.call(this).toList(),
|
|
127
|
+
...NamedObjectType_jsonUiSchemaFunctionDeclaration.call(this).toList(),
|
|
128
|
+
];
|
|
129
|
+
staticModuleDeclarations.push(...NamedObjectType_graphqlTypeVariableStatement.call(this).toList(), ...identifierTypeDeclarations.call(this), ...NamedObjectType_jsonTypeAliasDeclaration.call(this).toList(), ...(jsonModuleDeclarations.length > 0
|
|
130
|
+
? [
|
|
131
|
+
code `export namespace ${syntheticNamePrefix}Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`,
|
|
132
|
+
]
|
|
133
|
+
: []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfTypeVariableStatement.call(this).toList(), NamedObjectType_isTypeFunctionDeclaration.call(this), ...NamedObjectType_propertiesFromJsonFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.bind(this)().toList(), NamedObjectType_schemaVariableStatement.call(this), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)().toList(), ...(this.declarationType === "interface"
|
|
134
|
+
? NamedObjectType_toJsonFunctionOrMethodDeclaration.call(this).toList()
|
|
135
|
+
: []), ...(this.declarationType === "interface"
|
|
136
|
+
? NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.call(this).toList()
|
|
137
|
+
: []), ...NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.bind(this)().toList());
|
|
138
|
+
if (staticModuleDeclarations.length > 0) {
|
|
139
|
+
declarations.push(code `\
|
|
140
|
+
export namespace ${def(this.staticModuleName)} {
|
|
141
|
+
${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
142
|
+
}`);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return Maybe.of(joinCode(declarations, { on: "\n\n" }));
|
|
146
|
+
}
|
|
147
|
+
get descendantFromRdfTypeVariables() {
|
|
148
|
+
return this.descendantObjectTypes.flatMap((descendantObjectType) => descendantObjectType.fromRdfTypeVariable.toList());
|
|
149
|
+
}
|
|
150
|
+
get descendantFromRdfTypes() {
|
|
151
|
+
return this.descendantObjectTypes.flatMap((descendantObjectType) => descendantObjectType.fromRdfType.toList());
|
|
152
|
+
}
|
|
153
|
+
get descendantObjectTypes() {
|
|
154
|
+
return this.lazyDescendantObjectTypes();
|
|
155
|
+
}
|
|
156
|
+
get discriminantProperty() {
|
|
157
|
+
return Maybe.of({
|
|
158
|
+
name: this._discriminantProperty.name,
|
|
159
|
+
ownValues: this._discriminantProperty.type.ownValues,
|
|
160
|
+
descendantValues: this._discriminantProperty.type.descendantValues,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
get discriminantValue() {
|
|
164
|
+
return this.name;
|
|
165
|
+
}
|
|
166
|
+
get equalsFunction() {
|
|
167
|
+
switch (this.declarationType) {
|
|
168
|
+
case "class":
|
|
169
|
+
return code `((left, right) => left.${syntheticNamePrefix}equals(right))`;
|
|
170
|
+
case "interface":
|
|
171
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}equals`;
|
|
172
|
+
default:
|
|
173
|
+
throw new RangeError(this.declarationType);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
get filterFunction() {
|
|
177
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}filter`;
|
|
178
|
+
}
|
|
179
|
+
get filterType() {
|
|
180
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}Filter`;
|
|
181
|
+
}
|
|
182
|
+
get fromRdfTypeVariable() {
|
|
183
|
+
return this.fromRdfType.map(() => code `${this.staticModuleName}.${syntheticNamePrefix}fromRdfType`);
|
|
184
|
+
}
|
|
185
|
+
get graphqlType() {
|
|
186
|
+
return new AbstractType.GraphqlType(code `${this.staticModuleName}.${syntheticNamePrefix}GraphQL`);
|
|
187
|
+
}
|
|
188
|
+
get identifierProperty() {
|
|
189
|
+
return this.lazyIdentifierProperty(this);
|
|
190
|
+
}
|
|
191
|
+
get identifierTypeAlias() {
|
|
192
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}Identifier`;
|
|
193
|
+
}
|
|
194
|
+
get mutable() {
|
|
195
|
+
return this.properties.some((property) => property.mutable);
|
|
196
|
+
}
|
|
197
|
+
get objectSetMethodNames() {
|
|
198
|
+
return NamedObjectType_objectSetMethodNames.call(this);
|
|
199
|
+
}
|
|
200
|
+
get ownProperties() {
|
|
201
|
+
if (this.parentObjectTypes.length === 0) {
|
|
202
|
+
// Consider that a root of the object type hierarchy "owns" the identifier and type discriminant properties
|
|
203
|
+
// for all of its subtypes in the hierarchy.
|
|
204
|
+
// invariant(this.properties.length >= 2, this.name);
|
|
205
|
+
return this.properties;
|
|
206
|
+
}
|
|
207
|
+
return this.ownShaclProperties;
|
|
208
|
+
}
|
|
209
|
+
get ownShaclProperties() {
|
|
210
|
+
return this.properties.filter((property) => property.kind === "ShaclProperty");
|
|
211
|
+
}
|
|
212
|
+
get parentObjectTypes() {
|
|
213
|
+
return this.lazyParentObjectTypes();
|
|
214
|
+
}
|
|
215
|
+
get properties() {
|
|
216
|
+
const properties = this.lazyProperties(this);
|
|
217
|
+
const propertyNames = new Set();
|
|
218
|
+
for (const property of properties) {
|
|
219
|
+
if (propertyNames.has(property.name)) {
|
|
220
|
+
throw new Error(`duplicate property '${property.name}'`);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
return properties;
|
|
224
|
+
}
|
|
225
|
+
get schema() {
|
|
226
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}schema`;
|
|
227
|
+
}
|
|
228
|
+
get schemaType() {
|
|
229
|
+
return code `typeof ${this.schema}`;
|
|
230
|
+
}
|
|
231
|
+
get toRdfjsResourceType() {
|
|
232
|
+
if (this.parentObjectTypes.length > 0) {
|
|
233
|
+
return this.parentObjectTypes[0].toRdfjsResourceType;
|
|
234
|
+
}
|
|
235
|
+
return code `${imports.Resource}${this.identifierType.kind === "IriType" ? code `<${imports.NamedNode}>` : ""}`;
|
|
236
|
+
}
|
|
237
|
+
get valueSparqlConstructTriplesFunction() {
|
|
238
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlConstructTriples`;
|
|
239
|
+
}
|
|
240
|
+
get valueSparqlWherePatternsFunction() {
|
|
241
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}valueSparqlWherePatterns`;
|
|
242
|
+
}
|
|
243
|
+
get thisVariable() {
|
|
244
|
+
switch (this.declarationType) {
|
|
245
|
+
case "class":
|
|
246
|
+
return code `this`;
|
|
247
|
+
case "interface":
|
|
248
|
+
return code `_${camelCase(this.name)}`;
|
|
249
|
+
default:
|
|
250
|
+
throw new RangeError(this.declarationType);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
fromJsonExpression({ variables, }) {
|
|
254
|
+
// Assumes the JSON object has been recursively validated already.
|
|
255
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}fromJson(${variables.value})`;
|
|
256
|
+
}
|
|
257
|
+
fromRdfResourceValuesExpression({ variables, }) {
|
|
258
|
+
const { resourceValues, ...options } = variables;
|
|
259
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}fromRdfResourceValues(${resourceValues}, ${options})`;
|
|
260
|
+
}
|
|
261
|
+
graphqlResolveExpression({ variables, }) {
|
|
262
|
+
return variables.value;
|
|
263
|
+
}
|
|
264
|
+
hashStatements({ variables, }) {
|
|
265
|
+
switch (this.declarationType) {
|
|
266
|
+
case "class":
|
|
267
|
+
return [
|
|
268
|
+
code `${variables.value}.${syntheticNamePrefix}hash(${variables.hasher});`,
|
|
269
|
+
];
|
|
270
|
+
case "interface":
|
|
271
|
+
return [
|
|
272
|
+
code `${this.staticModuleName}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
|
|
273
|
+
];
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
jsonSchema({ context, }) {
|
|
277
|
+
let expression = code `${this.staticModuleName}.${syntheticNamePrefix}Json.schema()`;
|
|
278
|
+
if (context === "property" &&
|
|
279
|
+
this.properties.some((property) => property.recursive)) {
|
|
280
|
+
expression = code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.staticModuleName}.${syntheticNamePrefix}Json> => ${expression})`;
|
|
281
|
+
}
|
|
282
|
+
return expression;
|
|
283
|
+
}
|
|
284
|
+
jsonType() {
|
|
285
|
+
return new AbstractType.JsonType(code `${this.staticModuleName}.${syntheticNamePrefix}Json`);
|
|
286
|
+
}
|
|
287
|
+
jsonUiSchemaElement({ variables, }) {
|
|
288
|
+
return Maybe.of(code `${this.staticModuleName}.${syntheticNamePrefix}Json.uiSchema({ scopePrefix: ${variables.scopePrefix} })`);
|
|
289
|
+
}
|
|
290
|
+
newExpression({ parameters }) {
|
|
291
|
+
switch (this.declarationType) {
|
|
292
|
+
case "class":
|
|
293
|
+
return code `new ${this.name}(${parameters})`;
|
|
294
|
+
case "interface":
|
|
295
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}create(${parameters})`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
toJsonExpression({ variables, }) {
|
|
299
|
+
switch (this.declarationType) {
|
|
300
|
+
case "class":
|
|
301
|
+
return code `${variables.value}.${syntheticNamePrefix}toJson()`;
|
|
302
|
+
case "interface":
|
|
303
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}toJson(${variables.value})`;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
307
|
+
switch (this.declarationType) {
|
|
308
|
+
case "class":
|
|
309
|
+
return code `[${variables.value}.${syntheticNamePrefix}toRdfResource({ graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
|
|
310
|
+
case "interface":
|
|
311
|
+
return code `[${this.staticModuleName}.${syntheticNamePrefix}toRdfResource(${variables.value}, { graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
ensureAtMostOneSuperObjectType() {
|
|
315
|
+
if (this.parentObjectTypes.length > 1) {
|
|
316
|
+
throw new RangeError(`object type '${this.name}' has multiple super object types`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
lazyAncestorObjectTypes;
|
|
320
|
+
lazyChildObjectTypes;
|
|
321
|
+
lazyDescendantObjectTypes;
|
|
322
|
+
lazyDiscriminantProperty;
|
|
323
|
+
lazyIdentifierProperty;
|
|
324
|
+
lazyParentObjectTypes;
|
|
325
|
+
lazyProperties;
|
|
326
|
+
}
|
|
327
|
+
__decorate([
|
|
328
|
+
Memoize()
|
|
329
|
+
], NamedObjectType.prototype, "_discriminantProperty", null);
|
|
330
|
+
__decorate([
|
|
331
|
+
Memoize()
|
|
332
|
+
], NamedObjectType.prototype, "ancestorObjectTypes", null);
|
|
333
|
+
__decorate([
|
|
334
|
+
Memoize()
|
|
335
|
+
], NamedObjectType.prototype, "childObjectTypes", null);
|
|
336
|
+
__decorate([
|
|
337
|
+
Memoize()
|
|
338
|
+
], NamedObjectType.prototype, "conversions", null);
|
|
339
|
+
__decorate([
|
|
340
|
+
Memoize()
|
|
341
|
+
], NamedObjectType.prototype, "descendantFromRdfTypeVariables", null);
|
|
342
|
+
__decorate([
|
|
343
|
+
Memoize()
|
|
344
|
+
], NamedObjectType.prototype, "descendantFromRdfTypes", null);
|
|
345
|
+
__decorate([
|
|
346
|
+
Memoize()
|
|
347
|
+
], NamedObjectType.prototype, "descendantObjectTypes", null);
|
|
348
|
+
__decorate([
|
|
349
|
+
Memoize()
|
|
350
|
+
], NamedObjectType.prototype, "discriminantProperty", null);
|
|
351
|
+
__decorate([
|
|
352
|
+
Memoize()
|
|
353
|
+
], NamedObjectType.prototype, "discriminantValue", null);
|
|
354
|
+
__decorate([
|
|
355
|
+
Memoize()
|
|
356
|
+
], NamedObjectType.prototype, "equalsFunction", null);
|
|
357
|
+
__decorate([
|
|
358
|
+
Memoize()
|
|
359
|
+
], NamedObjectType.prototype, "filterFunction", null);
|
|
360
|
+
__decorate([
|
|
361
|
+
Memoize()
|
|
362
|
+
], NamedObjectType.prototype, "filterType", null);
|
|
363
|
+
__decorate([
|
|
364
|
+
Memoize()
|
|
365
|
+
], NamedObjectType.prototype, "fromRdfTypeVariable", null);
|
|
366
|
+
__decorate([
|
|
367
|
+
Memoize()
|
|
368
|
+
], NamedObjectType.prototype, "graphqlType", null);
|
|
369
|
+
__decorate([
|
|
370
|
+
Memoize()
|
|
371
|
+
], NamedObjectType.prototype, "identifierProperty", null);
|
|
372
|
+
__decorate([
|
|
373
|
+
Memoize()
|
|
374
|
+
], NamedObjectType.prototype, "identifierTypeAlias", null);
|
|
375
|
+
__decorate([
|
|
376
|
+
Memoize()
|
|
377
|
+
], NamedObjectType.prototype, "mutable", null);
|
|
378
|
+
__decorate([
|
|
379
|
+
Memoize()
|
|
380
|
+
], NamedObjectType.prototype, "objectSetMethodNames", null);
|
|
381
|
+
__decorate([
|
|
382
|
+
Memoize()
|
|
383
|
+
], NamedObjectType.prototype, "ownProperties", null);
|
|
384
|
+
__decorate([
|
|
385
|
+
Memoize()
|
|
386
|
+
], NamedObjectType.prototype, "ownShaclProperties", null);
|
|
387
|
+
__decorate([
|
|
388
|
+
Memoize()
|
|
389
|
+
], NamedObjectType.prototype, "parentObjectTypes", null);
|
|
390
|
+
__decorate([
|
|
391
|
+
Memoize()
|
|
392
|
+
], NamedObjectType.prototype, "properties", null);
|
|
393
|
+
__decorate([
|
|
394
|
+
Memoize()
|
|
395
|
+
], NamedObjectType.prototype, "schema", null);
|
|
396
|
+
__decorate([
|
|
397
|
+
Memoize()
|
|
398
|
+
], NamedObjectType.prototype, "schemaType", null);
|
|
399
|
+
__decorate([
|
|
400
|
+
Memoize()
|
|
401
|
+
], NamedObjectType.prototype, "toRdfjsResourceType", null);
|
|
402
|
+
__decorate([
|
|
403
|
+
Memoize()
|
|
404
|
+
], NamedObjectType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
405
|
+
__decorate([
|
|
406
|
+
Memoize()
|
|
407
|
+
], NamedObjectType.prototype, "valueSparqlWherePatternsFunction", null);
|
|
408
|
+
__decorate([
|
|
409
|
+
Memoize()
|
|
410
|
+
], NamedObjectType.prototype, "thisVariable", null);
|
|
411
|
+
__decorate([
|
|
412
|
+
Memoize()
|
|
413
|
+
], NamedObjectType.prototype, "jsonType", null);
|
|
414
|
+
(function (NamedObjectType) {
|
|
415
|
+
NamedObjectType.IdentifierPrefixProperty = _IdentifierPrefixProperty;
|
|
416
|
+
NamedObjectType.IdentifierProperty = _IdentifierProperty;
|
|
417
|
+
NamedObjectType.ShaclProperty = _ShaclProperty;
|
|
418
|
+
NamedObjectType.DiscriminantProperty = _DiscriminantProperty;
|
|
419
|
+
})(NamedObjectType || (NamedObjectType = {}));
|
|
420
|
+
//# sourceMappingURL=NamedObjectType.js.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
|
|
2
|
+
import { AbstractType } from "./AbstractType.js";
|
|
3
|
+
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
4
|
+
import type { IdentifierType } from "./IdentifierType.js";
|
|
5
|
+
import type { IriType } from "./IriType.js";
|
|
6
|
+
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
7
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
8
|
+
export declare class NamedObjectUnionType extends AbstractNamedUnionType<NamedObjectType> {
|
|
9
|
+
#private;
|
|
10
|
+
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
11
|
+
readonly kind = "NamedObjectUnionType";
|
|
12
|
+
constructor({ identifierType, ...superParameters }: {
|
|
13
|
+
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
14
|
+
} & Omit<ConstructorParameters<typeof AbstractNamedUnionType<NamedObjectType>>[0], "identifierType">);
|
|
15
|
+
get graphqlType(): AbstractType.GraphqlType;
|
|
16
|
+
get identifierTypeAlias(): Code;
|
|
17
|
+
get objectSetMethodNames(): NamedObjectType.ObjectSetMethodNames;
|
|
18
|
+
get schema(): Code;
|
|
19
|
+
get schemaType(): Code;
|
|
20
|
+
protected get staticModuleDeclarations(): Record<string, Code>;
|
|
21
|
+
private get focusSparqlConstructTriplesFunctionDeclaration();
|
|
22
|
+
private get focusSparqlWherePatternsFunctionDeclaration();
|
|
23
|
+
private get fromRdfResourceFunctionDeclaration();
|
|
24
|
+
private get graphqlTypeVariableStatement();
|
|
25
|
+
private get identifierTypeDeclarations();
|
|
26
|
+
private get isTypeFunctionDeclaration();
|
|
27
|
+
private get schemaVariableStatement();
|
|
28
|
+
private get toRdfResourceFunctionDeclaration();
|
|
29
|
+
graphqlResolveExpression({ variables, }: {
|
|
30
|
+
variables: {
|
|
31
|
+
value: Code;
|
|
32
|
+
};
|
|
33
|
+
}): Code;
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=NamedObjectUnionType.d.ts.map
|
|
@@ -0,0 +1,217 @@
|
|
|
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 { pascalCase } from "change-case";
|
|
8
|
+
import { Maybe } from "purify-ts";
|
|
9
|
+
import { PropertyPath } from "rdfjs-resource";
|
|
10
|
+
import { Memoize } from "typescript-memoize";
|
|
11
|
+
import { NamedObjectType_objectSetMethodNames } from "./_NamedObjectType/NamedObjectType_objectSetMethodNames.js";
|
|
12
|
+
import { NamedObjectType_sparqlConstructQueryFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
13
|
+
import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
14
|
+
import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
|
|
15
|
+
import { AbstractType } from "./AbstractType.js";
|
|
16
|
+
import { imports } from "./imports.js";
|
|
17
|
+
import { singleEntryRecord } from "./singleEntryRecord.js";
|
|
18
|
+
import { snippets } from "./snippets.js";
|
|
19
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
20
|
+
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
21
|
+
export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
22
|
+
#identifierType;
|
|
23
|
+
graphqlArgs = Maybe.empty();
|
|
24
|
+
kind = "NamedObjectUnionType";
|
|
25
|
+
constructor({ identifierType, ...superParameters }) {
|
|
26
|
+
super({ ...superParameters, identifierType: Maybe.of(identifierType) });
|
|
27
|
+
this.#identifierType = identifierType;
|
|
28
|
+
}
|
|
29
|
+
get graphqlType() {
|
|
30
|
+
return new AbstractType.GraphqlType(code `${this._name}.${syntheticNamePrefix}GraphQL`);
|
|
31
|
+
}
|
|
32
|
+
get identifierTypeAlias() {
|
|
33
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}Identifier`;
|
|
34
|
+
}
|
|
35
|
+
get objectSetMethodNames() {
|
|
36
|
+
return NamedObjectType_objectSetMethodNames.call(this);
|
|
37
|
+
}
|
|
38
|
+
get schema() {
|
|
39
|
+
return code `${this.staticModuleName}.${syntheticNamePrefix}schema`;
|
|
40
|
+
}
|
|
41
|
+
get schemaType() {
|
|
42
|
+
return code `typeof ${this.schema}`;
|
|
43
|
+
}
|
|
44
|
+
get staticModuleDeclarations() {
|
|
45
|
+
return {
|
|
46
|
+
...super.staticModuleDeclarations,
|
|
47
|
+
...this.identifierTypeDeclarations,
|
|
48
|
+
...this.focusSparqlConstructTriplesFunctionDeclaration,
|
|
49
|
+
...this.focusSparqlWherePatternsFunctionDeclaration,
|
|
50
|
+
...this.fromRdfResourceFunctionDeclaration,
|
|
51
|
+
...this.graphqlTypeVariableStatement,
|
|
52
|
+
...this.isTypeFunctionDeclaration,
|
|
53
|
+
...this.schemaVariableStatement,
|
|
54
|
+
...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call(this)
|
|
55
|
+
.map((code_) => singleEntryRecord(`${syntheticNamePrefix}sparqlConstructQuery`, code_))
|
|
56
|
+
.orDefault({}),
|
|
57
|
+
...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call(this)
|
|
58
|
+
.map((code_) => singleEntryRecord(`${syntheticNamePrefix}sparqlConstructQueryString`, code_))
|
|
59
|
+
.orDefault({}),
|
|
60
|
+
...this.toRdfResourceFunctionDeclaration,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
get focusSparqlConstructTriplesFunctionDeclaration() {
|
|
64
|
+
if (!this.features.has("sparql")) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
return singleEntryRecord(`${syntheticNamePrefix}focusSparqlConstructTriples`, code `\
|
|
68
|
+
export function ${syntheticNamePrefix}focusSparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
69
|
+
return [${joinCode(this.concreteMembers.map((member) => code `...${member.type.staticModuleName}.${syntheticNamePrefix}focusSparqlConstructTriples({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`), { on: ", " })}];
|
|
70
|
+
}`);
|
|
71
|
+
}
|
|
72
|
+
get focusSparqlWherePatternsFunctionDeclaration() {
|
|
73
|
+
if (!this.features.has("sparql")) {
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
return singleEntryRecord(`${syntheticNamePrefix}focusSparqlWherePatterns`, code `\
|
|
77
|
+
export function ${syntheticNamePrefix}focusSparqlWherePatterns({ filter, focusIdentifier, preferredLanguages, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; preferredLanguages: readonly string[] | undefined; variablePrefix: string }): readonly ${snippets.SparqlPattern}[] {
|
|
78
|
+
${joinCode([
|
|
79
|
+
code `let patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
80
|
+
code `\
|
|
81
|
+
if (focusIdentifier.termType === "Variable") {
|
|
82
|
+
patterns = patterns.concat(${this.#identifierType.valueSparqlWherePatternsFunction}({
|
|
83
|
+
filter: filter?.${syntheticNamePrefix}identifier,
|
|
84
|
+
ignoreRdfType: false,
|
|
85
|
+
preferredLanguages,
|
|
86
|
+
propertyPatterns: [],
|
|
87
|
+
schema: ${this.#identifierType.schema},
|
|
88
|
+
valueVariable: focusIdentifier,
|
|
89
|
+
variablePrefix,
|
|
90
|
+
}));
|
|
91
|
+
}`,
|
|
92
|
+
code `patterns.push({ patterns: [${joinCode(this.concreteMembers.map((member) => code `${{
|
|
93
|
+
patterns: code `${member.type.staticModuleName}.${syntheticNamePrefix}focusSparqlWherePatterns({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`,
|
|
94
|
+
type: literalOf("group"),
|
|
95
|
+
}}`), { on: ", " })}], type: "union" });`,
|
|
96
|
+
code `return patterns;`,
|
|
97
|
+
])}
|
|
98
|
+
}`);
|
|
99
|
+
}
|
|
100
|
+
get fromRdfResourceFunctionDeclaration() {
|
|
101
|
+
if (!this.features.has("rdf")) {
|
|
102
|
+
return {};
|
|
103
|
+
}
|
|
104
|
+
return singleEntryRecord(`${syntheticNamePrefix}fromRdfResource`, code `\
|
|
105
|
+
export const ${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFunction}<${this.name}> = (resource, options) =>
|
|
106
|
+
${this.concreteMembers.reduce((expression, member) => {
|
|
107
|
+
const memberTypeExpression = code `(${member.type.staticModuleName}.${syntheticNamePrefix}fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${imports.Either}<Error, ${this.name}>)`;
|
|
108
|
+
return expression !== null
|
|
109
|
+
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
110
|
+
: memberTypeExpression;
|
|
111
|
+
}, null)};`);
|
|
112
|
+
}
|
|
113
|
+
get graphqlTypeVariableStatement() {
|
|
114
|
+
if (!this.features.has("graphql")) {
|
|
115
|
+
return {};
|
|
116
|
+
}
|
|
117
|
+
return singleEntryRecord(`${syntheticNamePrefix}GraphQL`, code `\
|
|
118
|
+
export const ${syntheticNamePrefix}GraphQL = new ${imports.GraphQLUnionType}(${{
|
|
119
|
+
description: this.comment.map(JSON.stringify).extract(),
|
|
120
|
+
name: this.name,
|
|
121
|
+
resolveType: code `(value: ${this.name}) => value.${syntheticNamePrefix}type`,
|
|
122
|
+
types: code `[${joinCode(this.concreteMembers.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
|
|
123
|
+
}});`);
|
|
124
|
+
}
|
|
125
|
+
get identifierTypeDeclarations() {
|
|
126
|
+
return singleEntryRecord(`${syntheticNamePrefix}Identifier`, code `\
|
|
127
|
+
export type ${syntheticNamePrefix}Identifier = ${this.#identifierType.name};
|
|
128
|
+
export namespace ${syntheticNamePrefix}Identifier { ${joinCode([this.#identifierType.fromStringFunction, this.#identifierType.toStringFunction])} }`);
|
|
129
|
+
}
|
|
130
|
+
get isTypeFunctionDeclaration() {
|
|
131
|
+
if (this._name === `${syntheticNamePrefix}Object`) {
|
|
132
|
+
return {};
|
|
133
|
+
}
|
|
134
|
+
return singleEntryRecord(`is${this._name}`, code `\
|
|
135
|
+
export function is${this._name}(object: ${syntheticNamePrefix}Object): object is ${this.name} {
|
|
136
|
+
return ${joinCode(this.concreteMembers.map((member) => code `${member.type.staticModuleName}.is${member.type.name}(object)`), { on: " || " })};
|
|
137
|
+
}`);
|
|
138
|
+
}
|
|
139
|
+
get schemaVariableStatement() {
|
|
140
|
+
const commonPropertiesByName = {};
|
|
141
|
+
this.concreteMembers.forEach((member, memberI) => {
|
|
142
|
+
for (const memberTypeProperty of member.type.ownProperties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.ownProperties))) {
|
|
143
|
+
if (memberTypeProperty.kind !== "ShaclProperty") {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
let commonProperty = commonPropertiesByName[memberTypeProperty.name];
|
|
147
|
+
if (commonProperty) {
|
|
148
|
+
if (PropertyPath.equals(commonProperty.property.path, memberTypeProperty.path)) {
|
|
149
|
+
commonProperty.memberTypesWithProperty[memberI] = true;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
commonPropertiesByName[memberTypeProperty.name] = commonProperty = {
|
|
154
|
+
memberTypesWithProperty: new Array(this.concreteMembers.length).fill(false),
|
|
155
|
+
property: memberTypeProperty,
|
|
156
|
+
};
|
|
157
|
+
commonProperty.memberTypesWithProperty[memberI] = true;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
const propertiesObject = [];
|
|
162
|
+
for (const name of Object.keys(commonPropertiesByName).toSorted()) {
|
|
163
|
+
const { memberTypesWithProperty, property } = commonPropertiesByName[name];
|
|
164
|
+
if (!memberTypesWithProperty.every((value) => value)) {
|
|
165
|
+
continue;
|
|
166
|
+
}
|
|
167
|
+
propertiesObject.push(code `${property.name}: ${property.schema}`);
|
|
168
|
+
}
|
|
169
|
+
return singleEntryRecord(`${syntheticNamePrefix}schema`, code `\
|
|
170
|
+
export const ${syntheticNamePrefix}schema =
|
|
171
|
+
${{
|
|
172
|
+
...super.schemaObject,
|
|
173
|
+
properties: code `{ ${joinCode(propertiesObject, { on: ", " })} }`,
|
|
174
|
+
}} as const;`);
|
|
175
|
+
}
|
|
176
|
+
get toRdfResourceFunctionDeclaration() {
|
|
177
|
+
if (!this.features.has("rdf")) {
|
|
178
|
+
return {};
|
|
179
|
+
}
|
|
180
|
+
return singleEntryRecord(`${syntheticNamePrefix}toRdfResource`, code `\
|
|
181
|
+
export const ${syntheticNamePrefix}toRdfResource: ${snippets.ToRdfResourceFunction}<${this.name}> = (value, options) => {
|
|
182
|
+
${joinCode(this.concreteMembers
|
|
183
|
+
.map((member) => {
|
|
184
|
+
let returnExpression;
|
|
185
|
+
switch (member.type.declarationType) {
|
|
186
|
+
case "class":
|
|
187
|
+
returnExpression = code `value.${syntheticNamePrefix}toRdfResource(options)`;
|
|
188
|
+
break;
|
|
189
|
+
case "interface":
|
|
190
|
+
returnExpression = code `${member.type.staticModuleName}.${syntheticNamePrefix}toRdfResource(value, options)`;
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
return code `if (${member.type.staticModuleName}.is${member.type.name}(value)) { return ${returnExpression}; }`;
|
|
194
|
+
})
|
|
195
|
+
.concat(code `throw new Error("unrecognized type");`))}
|
|
196
|
+
};`);
|
|
197
|
+
}
|
|
198
|
+
graphqlResolveExpression({ variables, }) {
|
|
199
|
+
return variables.value;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
__decorate([
|
|
203
|
+
Memoize()
|
|
204
|
+
], NamedObjectUnionType.prototype, "graphqlType", null);
|
|
205
|
+
__decorate([
|
|
206
|
+
Memoize()
|
|
207
|
+
], NamedObjectUnionType.prototype, "identifierTypeAlias", null);
|
|
208
|
+
__decorate([
|
|
209
|
+
Memoize()
|
|
210
|
+
], NamedObjectUnionType.prototype, "objectSetMethodNames", null);
|
|
211
|
+
__decorate([
|
|
212
|
+
Memoize()
|
|
213
|
+
], NamedObjectUnionType.prototype, "schema", null);
|
|
214
|
+
__decorate([
|
|
215
|
+
Memoize()
|
|
216
|
+
], NamedObjectUnionType.prototype, "schemaType", null);
|
|
217
|
+
//# sourceMappingURL=NamedObjectUnionType.js.map
|