@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,514 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Maybe, NonEmptyList } from "purify-ts";
|
|
8
|
+
import { invariant } from "ts-invariant";
|
|
9
|
+
import { Memoize } from "typescript-memoize";
|
|
10
|
+
import { AbstractType } from "./AbstractType.js";
|
|
11
|
+
import { imports } from "./imports.js";
|
|
12
|
+
import { removeUndefined } from "./removeUndefined.js";
|
|
13
|
+
import { snippets } from "./snippets.js";
|
|
14
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
15
|
+
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
16
|
+
export class AbstractUnionType extends AbstractType {
|
|
17
|
+
discriminant;
|
|
18
|
+
identifierType;
|
|
19
|
+
abstract = false;
|
|
20
|
+
lazyMembers;
|
|
21
|
+
recursive;
|
|
22
|
+
constructor({ identifierType, members, recursive, ...superParameters }) {
|
|
23
|
+
super(superParameters);
|
|
24
|
+
this.identifierType = identifierType;
|
|
25
|
+
invariant(members.length >= 2);
|
|
26
|
+
this.recursive = recursive;
|
|
27
|
+
if (members.some((member) => member.discriminantValue.isJust())) {
|
|
28
|
+
this.discriminant = {
|
|
29
|
+
descendantValues: [],
|
|
30
|
+
kind: "envelope",
|
|
31
|
+
name: "type",
|
|
32
|
+
ownValues: members.map((member, memberI) => member.discriminantValue.orDefault(memberI)),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
this.discriminant = Discriminant.infer(members.map((member) => member.type));
|
|
37
|
+
}
|
|
38
|
+
this.lazyMembers = () => members.map((member, memberI) => {
|
|
39
|
+
if (member.type.abstract) {
|
|
40
|
+
return { abstract: true, discriminantValues: [], type: member.type };
|
|
41
|
+
}
|
|
42
|
+
let discriminantValues;
|
|
43
|
+
switch (this.discriminant.kind) {
|
|
44
|
+
case "envelope":
|
|
45
|
+
discriminantValues = [this.discriminant.ownValues[memberI]];
|
|
46
|
+
break;
|
|
47
|
+
case "inline": {
|
|
48
|
+
// A member type's combined discriminant property values are its "own" values plus any descendant values that are
|
|
49
|
+
// not the "own" values of some other member type.
|
|
50
|
+
// So if you have type A, type B, and B inherits A, then
|
|
51
|
+
// A has
|
|
52
|
+
// own discriminant property values: ["A"]
|
|
53
|
+
// descendant discriminant property values: ["B"]
|
|
54
|
+
// and B has
|
|
55
|
+
// own discriminant property values: ["B"]
|
|
56
|
+
// descendant discriminant property values ["B"]
|
|
57
|
+
// In this case A shouldn't have "B" as a combined discriminant property value since it's "claimed" by B.
|
|
58
|
+
const memberOwnDiscriminantPropertyValues = new Set();
|
|
59
|
+
for (const member of members) {
|
|
60
|
+
for (const ownDiscriminantPropertyValue of member.type.discriminantProperty.unsafeCoerce()
|
|
61
|
+
.ownValues) {
|
|
62
|
+
memberOwnDiscriminantPropertyValues.add(ownDiscriminantPropertyValue);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
discriminantValues = member.type.discriminantProperty
|
|
66
|
+
.unsafeCoerce()
|
|
67
|
+
.ownValues.concat(member.type.discriminantProperty
|
|
68
|
+
.unsafeCoerce()
|
|
69
|
+
.descendantValues.filter((value) => !memberOwnDiscriminantPropertyValues.has(value)));
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
case "typeof":
|
|
73
|
+
discriminantValues = member.type.typeofs;
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
throw this.discriminant;
|
|
77
|
+
}
|
|
78
|
+
if (discriminantValues.length === 0) {
|
|
79
|
+
return { abstract: true, discriminantValues: [], type: member.type };
|
|
80
|
+
}
|
|
81
|
+
const typeCheck = (json) => (instance) => {
|
|
82
|
+
switch (this.discriminant.kind) {
|
|
83
|
+
case "envelope":
|
|
84
|
+
return code `(${joinCode(discriminantValues.map((discriminantValue) => code `${instance}.${this.discriminant.name} === ${literalOf(discriminantValue)}`), { on: " || " })})`;
|
|
85
|
+
case "inline": {
|
|
86
|
+
if (!json) {
|
|
87
|
+
switch (member.type.kind) {
|
|
88
|
+
case "NamedObjectUnionType":
|
|
89
|
+
case "NamedUnionType":
|
|
90
|
+
case "NamedObjectType":
|
|
91
|
+
return code `${member.type.staticModuleName}.is${member.type.name}(${instance})`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return code `(${joinCode(discriminantValues.map((discriminantValue) => code `${instance}.${this.discriminant.name} === ${literalOf(discriminantValue)}`), { on: " || " })})`;
|
|
95
|
+
}
|
|
96
|
+
case "typeof":
|
|
97
|
+
return code `(${joinCode(discriminantValues.map((discriminantValue) => code `typeof ${instance} === ${literalOf(discriminantValue)}`), { on: " || " })})`;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
return {
|
|
101
|
+
abstract: false,
|
|
102
|
+
discriminantValues,
|
|
103
|
+
jsonTypeCheck: typeCheck(true),
|
|
104
|
+
primaryDiscriminantValue: discriminantValues[0],
|
|
105
|
+
type: member.type,
|
|
106
|
+
typeCheck: typeCheck(false),
|
|
107
|
+
unwrap: (instance) => {
|
|
108
|
+
switch (this.discriminant.kind) {
|
|
109
|
+
case "envelope":
|
|
110
|
+
return code `${instance}.value`;
|
|
111
|
+
case "inline":
|
|
112
|
+
case "typeof":
|
|
113
|
+
return instance;
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
wrap: (instance) => {
|
|
117
|
+
switch (this.discriminant.kind) {
|
|
118
|
+
case "envelope":
|
|
119
|
+
return code `{ ${this.discriminant.name}: "${discriminantValues[0]}" as const, value: ${instance} }`;
|
|
120
|
+
case "inline":
|
|
121
|
+
case "typeof":
|
|
122
|
+
return instance;
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
};
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
get conversions() {
|
|
129
|
+
switch (this.discriminant.kind) {
|
|
130
|
+
case "envelope":
|
|
131
|
+
case "inline":
|
|
132
|
+
return [
|
|
133
|
+
{
|
|
134
|
+
conversionExpression: (value) => value,
|
|
135
|
+
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
136
|
+
sourceTypeName: this.name,
|
|
137
|
+
sourceTypeof: "object",
|
|
138
|
+
},
|
|
139
|
+
];
|
|
140
|
+
case "typeof":
|
|
141
|
+
return this.concreteMembers.map(({ primaryDiscriminantValue, type, typeCheck }) => ({
|
|
142
|
+
conversionExpression: (value) => value,
|
|
143
|
+
sourceTypeCheckExpression: (value) => typeCheck(value),
|
|
144
|
+
sourceTypeName: type.name,
|
|
145
|
+
sourceTypeof: primaryDiscriminantValue,
|
|
146
|
+
}));
|
|
147
|
+
default:
|
|
148
|
+
throw this.discriminant;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
get discriminantProperty() {
|
|
152
|
+
switch (this.discriminant.kind) {
|
|
153
|
+
case "envelope":
|
|
154
|
+
case "inline":
|
|
155
|
+
return Maybe.of(this.discriminant);
|
|
156
|
+
case "typeof":
|
|
157
|
+
return Maybe.empty();
|
|
158
|
+
default:
|
|
159
|
+
throw this.discriminant;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
get members() {
|
|
163
|
+
return this.lazyMembers();
|
|
164
|
+
}
|
|
165
|
+
get mutable() {
|
|
166
|
+
return this.members.some((member) => member.type.mutable);
|
|
167
|
+
}
|
|
168
|
+
get schema() {
|
|
169
|
+
return code `${removeUndefined(this.schemaObject)}`;
|
|
170
|
+
}
|
|
171
|
+
get schemaType() {
|
|
172
|
+
invariant(this.kind.endsWith("Type"));
|
|
173
|
+
return code `${{
|
|
174
|
+
// discriminant: {
|
|
175
|
+
// kind: '"envelope" | "inline" | "typeof"',
|
|
176
|
+
// },
|
|
177
|
+
kind: code `${literalOf(this.kind.substring(0, this.kind.length - "Type".length))}`,
|
|
178
|
+
members: code `{ ${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}: ${{
|
|
179
|
+
discriminantValues: code `readonly (number | string)[]`,
|
|
180
|
+
type: type.schemaType,
|
|
181
|
+
}}`), { on: ";" })} }`,
|
|
182
|
+
}}`;
|
|
183
|
+
}
|
|
184
|
+
get typeofs() {
|
|
185
|
+
return NonEmptyList.fromArray(this.concreteMembers.flatMap((member) => member.type.typeofs)).unsafeCoerce();
|
|
186
|
+
}
|
|
187
|
+
get concreteMembers() {
|
|
188
|
+
return this.members.filter((member) => !member.abstract);
|
|
189
|
+
}
|
|
190
|
+
get inlineEqualsFunction() {
|
|
191
|
+
return code `\
|
|
192
|
+
((left: ${this.name}, right: ${this.name}) => {
|
|
193
|
+
${joinCode(this.concreteMembers.map(({ type, typeCheck, unwrap }) => code `if (${typeCheck(code `left`)} && ${typeCheck(code `right`)}) {
|
|
194
|
+
return ${type.equalsFunction}(${unwrap(code `left`)} as ${type.name}, ${unwrap(code `right`)} as ${type.name});
|
|
195
|
+
}`))}
|
|
196
|
+
|
|
197
|
+
return ${imports.Left}({ left, right, propertyName: "type", propertyValuesUnequal: { left: typeof left, right: typeof right, type: "boolean" as const }, type: "property" as const });
|
|
198
|
+
})`;
|
|
199
|
+
}
|
|
200
|
+
get inlineFilterFunction() {
|
|
201
|
+
return code `\
|
|
202
|
+
((filter: ${this.filterType}, value: ${this.name}) => {
|
|
203
|
+
${joinCode([
|
|
204
|
+
...this.identifierType
|
|
205
|
+
.map((identifierType) => code `\
|
|
206
|
+
if (filter.${syntheticNamePrefix}identifier !== undefined && !${identifierType.filterFunction}(filter.${syntheticNamePrefix}identifier, value.${syntheticNamePrefix}identifier)) {
|
|
207
|
+
return false;
|
|
208
|
+
}`)
|
|
209
|
+
.toList(),
|
|
210
|
+
...this.concreteMembers.map(({ primaryDiscriminantValue, type, typeCheck, unwrap }) => code `\
|
|
211
|
+
if (filter.on?.[${literalOf(primaryDiscriminantValue)}] !== undefined && ${typeCheck(code `value`)}) {
|
|
212
|
+
if (!${type.filterFunction}(filter.on[${literalOf(primaryDiscriminantValue)}], ${unwrap(code `value`)})) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
}`),
|
|
216
|
+
])}
|
|
217
|
+
|
|
218
|
+
return true;
|
|
219
|
+
})`;
|
|
220
|
+
}
|
|
221
|
+
get inlineFilterType() {
|
|
222
|
+
return code `\
|
|
223
|
+
{
|
|
224
|
+
${this.identifierType.map((identifierType) => code `readonly ${syntheticNamePrefix}identifier?: ${identifierType.filterType};`).orDefault(code ``)}
|
|
225
|
+
readonly on?: { ${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `readonly ${literalOf(primaryDiscriminantValue)}?: ${type.filterType}`), { on: ";" })} }
|
|
226
|
+
}`;
|
|
227
|
+
}
|
|
228
|
+
get inlineFromJsonFunction() {
|
|
229
|
+
return code `\
|
|
230
|
+
((value: ${this.jsonType().name}): ${this.name} => {
|
|
231
|
+
${joinCode(this.concreteMembers.map(({ jsonTypeCheck, type, unwrap, wrap }) => code `if (${jsonTypeCheck(code `value`)}) { return ${wrap(type.fromJsonExpression({
|
|
232
|
+
variables: {
|
|
233
|
+
value: code `(${unwrap(code `value`)} as ${type.jsonType().name})`,
|
|
234
|
+
},
|
|
235
|
+
}))}; }`))}
|
|
236
|
+
|
|
237
|
+
throw new Error("unable to deserialize JSON");
|
|
238
|
+
})`;
|
|
239
|
+
}
|
|
240
|
+
get inlineFromRdfResourceValuesFunction() {
|
|
241
|
+
const variables = {
|
|
242
|
+
context: code `_options.context`,
|
|
243
|
+
graph: code `_options.graph`,
|
|
244
|
+
ignoreRdfType: false,
|
|
245
|
+
objectSet: code `_options.objectSet`,
|
|
246
|
+
preferredLanguages: code `_options.preferredLanguages`,
|
|
247
|
+
propertyPath: code `_options.propertyPath`,
|
|
248
|
+
resource: code `_options.resource`,
|
|
249
|
+
};
|
|
250
|
+
return code `\
|
|
251
|
+
(((values, _options) =>
|
|
252
|
+
values.chain(values => values.chainMap(value => {
|
|
253
|
+
const valueAsValues = ${imports.Right}(value.toValues());
|
|
254
|
+
return ${this.concreteMembers.reduce((expression, { type, primaryDiscriminantValue }) => {
|
|
255
|
+
let typeExpression = type.fromRdfResourceValuesExpression({
|
|
256
|
+
variables: {
|
|
257
|
+
context: variables.context,
|
|
258
|
+
graph: variables.graph,
|
|
259
|
+
ignoreRdfType: false,
|
|
260
|
+
objectSet: variables.objectSet,
|
|
261
|
+
preferredLanguages: variables.preferredLanguages,
|
|
262
|
+
propertyPath: variables.propertyPath,
|
|
263
|
+
resource: variables.resource,
|
|
264
|
+
resourceValues: code `valueAsValues`,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
if (this.discriminant.kind === "envelope") {
|
|
268
|
+
typeExpression = code `${typeExpression}.map(values => values.map(value => ({ ${this.discriminant.name}: ${literalOf(primaryDiscriminantValue)} as const, value }) as (${this.name})))`;
|
|
269
|
+
}
|
|
270
|
+
typeExpression = code `(${typeExpression} as ${imports.Either}<Error, ${imports.Resource}.Values<${this.name}>>)`;
|
|
271
|
+
return expression !== null
|
|
272
|
+
? code `${expression}.altLazy(() => ${typeExpression})`
|
|
273
|
+
: typeExpression;
|
|
274
|
+
}, null)}.chain(values => values.head());
|
|
275
|
+
}))
|
|
276
|
+
) satisfies ${snippets.FromRdfResourceValuesFunction}<${this.name}>)`;
|
|
277
|
+
}
|
|
278
|
+
get inlineJsonType() {
|
|
279
|
+
switch (this.discriminant.kind) {
|
|
280
|
+
case "envelope":
|
|
281
|
+
return new AbstractType.JsonType(code `(${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `{ ${this.discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.jsonType().name} }`), { on: "|" })})`);
|
|
282
|
+
case "inline":
|
|
283
|
+
case "typeof":
|
|
284
|
+
return new AbstractType.JsonType(joinCode(this.concreteMembers.map(({ type }) => code `${type.jsonType({
|
|
285
|
+
includeDiscriminantProperty: this.discriminant.kind === "inline",
|
|
286
|
+
}).name}`), { on: "|" }));
|
|
287
|
+
default:
|
|
288
|
+
throw this.discriminant;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
get inlineJsonSchema() {
|
|
292
|
+
switch (this.discriminant.kind) {
|
|
293
|
+
case "envelope":
|
|
294
|
+
return code `${imports.z}.discriminatedUnion("${this.discriminant.name}", [${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `${imports.z}.object({ ${this.discriminant.name}: ${imports.z}.literal(${literalOf(primaryDiscriminantValue)}), value: ${type.jsonSchema({ context: "type" })} })`), { on: "," })}])`;
|
|
295
|
+
case "inline":
|
|
296
|
+
return code `${imports.z}.discriminatedUnion("${this.discriminant.name}", [${joinCode(this.concreteMembers.map(({ type }) => type.jsonSchema({
|
|
297
|
+
includeDiscriminantProperty: true,
|
|
298
|
+
context: "type",
|
|
299
|
+
})), { on: "," })}])`;
|
|
300
|
+
case "typeof":
|
|
301
|
+
return code `${imports.z}.union([${joinCode(this.concreteMembers.map(({ type }) => type.jsonSchema({ context: "type" })), { on: "," })}])`;
|
|
302
|
+
default:
|
|
303
|
+
throw this.discriminant;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
get inlineName() {
|
|
307
|
+
switch (this.discriminant.kind) {
|
|
308
|
+
case "envelope":
|
|
309
|
+
return code `(${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `{ ${this.discriminant.name}: ${literalOf(primaryDiscriminantValue)}, value: ${type.name} }`), { on: "|" })})`;
|
|
310
|
+
case "inline":
|
|
311
|
+
// If every type shares a discriminant (e.g., RDF/JS "termType" or generated NamedObjectType "type"),
|
|
312
|
+
// just join their names with "|"
|
|
313
|
+
return code `(${joinCode(this.members.map(({ type }) => code `${type.name}`), { on: "|" })})`;
|
|
314
|
+
case "typeof":
|
|
315
|
+
// The type.name may include literal values, but they should still be unambiguous with other member types since the typeofs
|
|
316
|
+
// of the different member types are known to be different.
|
|
317
|
+
return code `(${joinCode(this.members.map(({ type }) => code `${type.name}`), { on: "|" })})`;
|
|
318
|
+
default:
|
|
319
|
+
this.discriminant;
|
|
320
|
+
throw new Error("should never reach this point");
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
get inlineValueSparqlConstructTriplesFunction() {
|
|
324
|
+
return code `\
|
|
325
|
+
((({ ignoreRdfType, filter, schema, ...otherParameters }) => {
|
|
326
|
+
let triples: ${imports.sparqljs}.Triple[] = [];
|
|
327
|
+
|
|
328
|
+
${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `\
|
|
329
|
+
triples = triples.concat(${type.valueSparqlConstructTriplesFunction}({ ...otherParameters, filter: filter?.on?.[${literalOf(primaryDiscriminantValue)}], ignoreRdfType: false, schema: schema.members[${literalOf(primaryDiscriminantValue)}].type }));`))}
|
|
330
|
+
|
|
331
|
+
return triples;
|
|
332
|
+
}) satisfies ${snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}>)`;
|
|
333
|
+
}
|
|
334
|
+
get inlineValueSparqlWherePatternsFunction() {
|
|
335
|
+
return code `\
|
|
336
|
+
((({ filter, schema, ...otherParameters }) => {
|
|
337
|
+
const unionPatterns: ${imports.sparqljs}.GroupPattern[] = [];
|
|
338
|
+
|
|
339
|
+
${joinCode(this.concreteMembers.map(({ type, primaryDiscriminantValue }) => code `\
|
|
340
|
+
unionPatterns.push({ patterns: ${type.valueSparqlWherePatternsFunction}({ ...otherParameters, filter: filter?.on?.[${literalOf(primaryDiscriminantValue)}], ignoreRdfType: false, schema: schema.members[${literalOf(primaryDiscriminantValue)}].type }).concat(), type: "group" });`))}
|
|
341
|
+
|
|
342
|
+
return [{ patterns: unionPatterns, type: "union" }];
|
|
343
|
+
}) satisfies ${snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}>)`;
|
|
344
|
+
}
|
|
345
|
+
get inlineToJsonFunction() {
|
|
346
|
+
return code `\
|
|
347
|
+
((value: ${this.name}): ${this.jsonType().name} => {
|
|
348
|
+
${joinCode(this.concreteMembers.map(({ type, typeCheck, unwrap, wrap }) => code `if (${typeCheck(code `value`)}) { return ${wrap(type.toJsonExpression({
|
|
349
|
+
includeDiscriminantProperty: this.discriminant.kind === "inline",
|
|
350
|
+
variables: { value: unwrap(code `value`) },
|
|
351
|
+
}))}; }`))}
|
|
352
|
+
|
|
353
|
+
throw new Error("unable to serialize to JSON");
|
|
354
|
+
})`;
|
|
355
|
+
}
|
|
356
|
+
get inlineToRdfResourceValuesFunction() {
|
|
357
|
+
return code `\
|
|
358
|
+
(((value, _options) => {
|
|
359
|
+
${joinCode(this.concreteMembers.map(({ type, unwrap, typeCheck }) => code `if (${typeCheck(code `value`)}) { return ${type.toRdfResourceValuesExpression({
|
|
360
|
+
variables: {
|
|
361
|
+
graph: code `_options.graph`,
|
|
362
|
+
propertyPath: code `_options.propertyPath`,
|
|
363
|
+
resource: code `_options.resource`,
|
|
364
|
+
resourceSet: code `_options.resourceSet`,
|
|
365
|
+
value: unwrap(code `value`),
|
|
366
|
+
},
|
|
367
|
+
})}; }`))}
|
|
368
|
+
|
|
369
|
+
throw new Error("unable to serialize to RDF");
|
|
370
|
+
}) as ${snippets.ToRdfResourceValuesFunction}<${this.name}>)`;
|
|
371
|
+
}
|
|
372
|
+
get schemaObject() {
|
|
373
|
+
return {
|
|
374
|
+
...super.schemaObject,
|
|
375
|
+
members: code `{ ${joinCode(this.concreteMembers.map(({ discriminantValues, type, primaryDiscriminantValue }) => code `${literalOf(primaryDiscriminantValue)}: ${{
|
|
376
|
+
discriminantValues: discriminantValues,
|
|
377
|
+
type: type.schema,
|
|
378
|
+
}}`), { on: "," })} }`,
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
jsonUiSchemaElement() {
|
|
382
|
+
return Maybe.empty();
|
|
383
|
+
}
|
|
384
|
+
inlineHashStatements({ depth, variables, }) {
|
|
385
|
+
return this.concreteMembers.map(({ type, unwrap, typeCheck }) => code `if (${typeCheck(variables.value)}) { ${joinCode(type
|
|
386
|
+
.hashStatements({
|
|
387
|
+
depth: depth + 1,
|
|
388
|
+
variables: {
|
|
389
|
+
hasher: variables.hasher,
|
|
390
|
+
value: unwrap(variables.value),
|
|
391
|
+
},
|
|
392
|
+
})
|
|
393
|
+
.concat())} }`);
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
__decorate([
|
|
397
|
+
Memoize()
|
|
398
|
+
], AbstractUnionType.prototype, "conversions", null);
|
|
399
|
+
__decorate([
|
|
400
|
+
Memoize()
|
|
401
|
+
], AbstractUnionType.prototype, "discriminantProperty", null);
|
|
402
|
+
__decorate([
|
|
403
|
+
Memoize()
|
|
404
|
+
], AbstractUnionType.prototype, "members", null);
|
|
405
|
+
__decorate([
|
|
406
|
+
Memoize()
|
|
407
|
+
], AbstractUnionType.prototype, "mutable", null);
|
|
408
|
+
__decorate([
|
|
409
|
+
Memoize()
|
|
410
|
+
], AbstractUnionType.prototype, "schema", null);
|
|
411
|
+
__decorate([
|
|
412
|
+
Memoize()
|
|
413
|
+
], AbstractUnionType.prototype, "typeofs", null);
|
|
414
|
+
__decorate([
|
|
415
|
+
Memoize()
|
|
416
|
+
], AbstractUnionType.prototype, "concreteMembers", null);
|
|
417
|
+
__decorate([
|
|
418
|
+
Memoize()
|
|
419
|
+
], AbstractUnionType.prototype, "inlineEqualsFunction", null);
|
|
420
|
+
__decorate([
|
|
421
|
+
Memoize()
|
|
422
|
+
], AbstractUnionType.prototype, "inlineFilterFunction", null);
|
|
423
|
+
__decorate([
|
|
424
|
+
Memoize()
|
|
425
|
+
], AbstractUnionType.prototype, "inlineFilterType", null);
|
|
426
|
+
__decorate([
|
|
427
|
+
Memoize()
|
|
428
|
+
], AbstractUnionType.prototype, "inlineJsonType", null);
|
|
429
|
+
__decorate([
|
|
430
|
+
Memoize()
|
|
431
|
+
], AbstractUnionType.prototype, "inlineName", null);
|
|
432
|
+
__decorate([
|
|
433
|
+
Memoize()
|
|
434
|
+
], AbstractUnionType.prototype, "inlineValueSparqlConstructTriplesFunction", null);
|
|
435
|
+
__decorate([
|
|
436
|
+
Memoize()
|
|
437
|
+
], AbstractUnionType.prototype, "inlineValueSparqlWherePatternsFunction", null);
|
|
438
|
+
export var Discriminant;
|
|
439
|
+
(function (Discriminant) {
|
|
440
|
+
function inlineDiscriminantProperty(memberTypes) {
|
|
441
|
+
let inlineDiscriminantProperty;
|
|
442
|
+
for (const memberType of memberTypes) {
|
|
443
|
+
const memberTypeDiscriminantProperty = memberType.discriminantProperty.extract();
|
|
444
|
+
if (!memberTypeDiscriminantProperty) {
|
|
445
|
+
inlineDiscriminantProperty = undefined;
|
|
446
|
+
break;
|
|
447
|
+
}
|
|
448
|
+
if (!inlineDiscriminantProperty) {
|
|
449
|
+
inlineDiscriminantProperty = {
|
|
450
|
+
name: memberTypeDiscriminantProperty.name,
|
|
451
|
+
ownValues: memberTypeDiscriminantProperty.ownValues.concat(),
|
|
452
|
+
descendantValues: memberTypeDiscriminantProperty.descendantValues.concat(),
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
else if (memberTypeDiscriminantProperty.name === inlineDiscriminantProperty.name) {
|
|
456
|
+
inlineDiscriminantProperty.descendantValues =
|
|
457
|
+
inlineDiscriminantProperty.descendantValues.concat(memberTypeDiscriminantProperty.descendantValues);
|
|
458
|
+
inlineDiscriminantProperty.ownValues =
|
|
459
|
+
inlineDiscriminantProperty.ownValues.concat(memberTypeDiscriminantProperty.ownValues);
|
|
460
|
+
}
|
|
461
|
+
else {
|
|
462
|
+
return undefined;
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
return inlineDiscriminantProperty;
|
|
466
|
+
}
|
|
467
|
+
function infer(memberTypes) {
|
|
468
|
+
// Infer the discriminant kind
|
|
469
|
+
const inlineDiscriminantProperty_ = inlineDiscriminantProperty(memberTypes);
|
|
470
|
+
if (inlineDiscriminantProperty_) {
|
|
471
|
+
return {
|
|
472
|
+
...inlineDiscriminantProperty_,
|
|
473
|
+
kind: "inline",
|
|
474
|
+
};
|
|
475
|
+
}
|
|
476
|
+
const memberTypeofs = new Set();
|
|
477
|
+
for (const memberType of memberTypes) {
|
|
478
|
+
for (const typeof_ of memberType.typeofs) {
|
|
479
|
+
memberTypeofs.add(typeof_);
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
if (memberTypeofs.size === memberTypes.length) {
|
|
483
|
+
return {
|
|
484
|
+
kind: "typeof",
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
let ownValues;
|
|
488
|
+
const memberTypeNames = memberTypes.map((memberType) => memberType.name);
|
|
489
|
+
if (memberTypeNames.every((memberTypeName) => typeof memberTypeName === "string")) {
|
|
490
|
+
const memberTypeNamesSet = new Set(memberTypeNames);
|
|
491
|
+
if (memberTypeNamesSet.size === memberTypeNames.length) {
|
|
492
|
+
// If every member type name is a unique string, use those strings as the discriminant values.
|
|
493
|
+
ownValues = memberTypeNames;
|
|
494
|
+
}
|
|
495
|
+
else {
|
|
496
|
+
// Otherwise prefix the non-unique strings with an index and use those as the discriminant values.
|
|
497
|
+
ownValues = memberTypeNames.map((memberTypeName, memberTypeIndex) => `${memberTypeIndex}-${memberTypeName}`);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
501
|
+
// At least one member type name is Code
|
|
502
|
+
// Use member type indices as the discriminant values.
|
|
503
|
+
ownValues = memberTypes.map((_, memberTypeIndex) => memberTypeIndex);
|
|
504
|
+
}
|
|
505
|
+
return {
|
|
506
|
+
descendantValues: [],
|
|
507
|
+
kind: "envelope",
|
|
508
|
+
name: "type",
|
|
509
|
+
ownValues,
|
|
510
|
+
};
|
|
511
|
+
}
|
|
512
|
+
Discriminant.infer = infer;
|
|
513
|
+
})(Discriminant || (Discriminant = {}));
|
|
514
|
+
//# sourceMappingURL=AbstractUnionType.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { AbstractType } from "./AbstractType.js";
|
|
3
|
+
import { AbstractUnionType } from "./AbstractUnionType.js";
|
|
4
|
+
import type { Type } from "./Type.js";
|
|
5
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
6
|
+
export declare class AnonymousUnionType extends AbstractUnionType<Type> {
|
|
7
|
+
readonly declaration: Maybe<Code>;
|
|
8
|
+
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
9
|
+
readonly kind = "AnonymousUnionType";
|
|
10
|
+
get equalsFunction(): Code;
|
|
11
|
+
get filterFunction(): Code;
|
|
12
|
+
get filterType(): Code;
|
|
13
|
+
get graphqlType(): AbstractType.GraphqlType;
|
|
14
|
+
get name(): Code;
|
|
15
|
+
get valueSparqlConstructTriplesFunction(): Code;
|
|
16
|
+
get valueSparqlWherePatternsFunction(): Code;
|
|
17
|
+
fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
|
|
18
|
+
fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
19
|
+
graphqlResolveExpression(_parameters: Parameters<AbstractType["graphqlResolveExpression"]>[0]): Code;
|
|
20
|
+
hashStatements(parameters: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
21
|
+
jsonType(): AbstractType.JsonType;
|
|
22
|
+
jsonSchema(_parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
23
|
+
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
24
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=AnonymousUnionType.d.ts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { AbstractUnionType } from "./AbstractUnionType.js";
|
|
3
|
+
import { code } from "./ts-poet-wrapper.js";
|
|
4
|
+
export class AnonymousUnionType extends AbstractUnionType {
|
|
5
|
+
declaration = Maybe.empty();
|
|
6
|
+
graphqlArgs = Maybe.empty();
|
|
7
|
+
kind = "AnonymousUnionType";
|
|
8
|
+
get equalsFunction() {
|
|
9
|
+
return this.inlineEqualsFunction;
|
|
10
|
+
}
|
|
11
|
+
get filterFunction() {
|
|
12
|
+
return this.inlineFilterFunction;
|
|
13
|
+
}
|
|
14
|
+
get filterType() {
|
|
15
|
+
return this.inlineFilterType;
|
|
16
|
+
}
|
|
17
|
+
get graphqlType() {
|
|
18
|
+
throw new Error("GraphQL doesn't support scalar unions");
|
|
19
|
+
}
|
|
20
|
+
get name() {
|
|
21
|
+
return this.inlineName;
|
|
22
|
+
}
|
|
23
|
+
get valueSparqlConstructTriplesFunction() {
|
|
24
|
+
return this.inlineValueSparqlConstructTriplesFunction;
|
|
25
|
+
}
|
|
26
|
+
get valueSparqlWherePatternsFunction() {
|
|
27
|
+
return this.inlineValueSparqlWherePatternsFunction;
|
|
28
|
+
}
|
|
29
|
+
fromJsonExpression({ variables, }) {
|
|
30
|
+
return code `${this.inlineFromJsonFunction}(${variables.value})`;
|
|
31
|
+
}
|
|
32
|
+
fromRdfResourceValuesExpression({ variables, }) {
|
|
33
|
+
const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
|
|
34
|
+
return code `${this.inlineFromRdfResourceValuesFunction}(${resourceValuesVariable}, ${otherVariables})`;
|
|
35
|
+
}
|
|
36
|
+
graphqlResolveExpression(_parameters) {
|
|
37
|
+
throw new Error("not implemented");
|
|
38
|
+
}
|
|
39
|
+
hashStatements(parameters) {
|
|
40
|
+
return this.inlineHashStatements(parameters);
|
|
41
|
+
}
|
|
42
|
+
jsonType() {
|
|
43
|
+
return this.inlineJsonType;
|
|
44
|
+
}
|
|
45
|
+
jsonSchema(_parameters) {
|
|
46
|
+
return this.inlineJsonSchema;
|
|
47
|
+
}
|
|
48
|
+
toJsonExpression({ variables, }) {
|
|
49
|
+
return code `${this.inlineToJsonFunction}(${variables.value})`;
|
|
50
|
+
}
|
|
51
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
52
|
+
const { value: valueVariable, ...otherVariables } = variables;
|
|
53
|
+
return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=AnonymousUnionType.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type Code } from "ts-poet";
|
|
2
1
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
2
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
3
|
export declare class BigDecimalType extends AbstractLiteralType {
|
|
4
4
|
readonly filterFunction: Code;
|
|
5
5
|
readonly filterType: Code;
|
|
@@ -7,15 +7,15 @@ export declare class BigDecimalType extends AbstractLiteralType {
|
|
|
7
7
|
readonly kind = "BigDecimalType";
|
|
8
8
|
readonly name: Code;
|
|
9
9
|
readonly schemaType: Code;
|
|
10
|
-
readonly
|
|
10
|
+
readonly valueSparqlWherePatternsFunction: Code;
|
|
11
11
|
get conversions(): readonly AbstractLiteralType.Conversion[];
|
|
12
12
|
fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
|
|
13
13
|
graphqlResolveExpression({ variables, }: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
14
14
|
hashStatements({ variables, }: Parameters<AbstractLiteralType["hashStatements"]>[0]): readonly Code[];
|
|
15
15
|
jsonType(): AbstractLiteralType.JsonType;
|
|
16
|
-
|
|
16
|
+
jsonSchema(): Code;
|
|
17
17
|
toJsonExpression({ variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
18
18
|
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractLiteralType["fromRdfExpressionChain"]>[0]): ReturnType<AbstractLiteralType["fromRdfExpressionChain"]>;
|
|
19
|
-
|
|
19
|
+
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractLiteralType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
20
20
|
}
|
|
21
21
|
//# sourceMappingURL=BigDecimalType.d.ts.map
|
|
@@ -4,11 +4,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { code } from "ts-poet";
|
|
8
7
|
import { Memoize } from "typescript-memoize";
|
|
9
8
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
10
9
|
import { imports } from "./imports.js";
|
|
11
10
|
import { snippets } from "./snippets.js";
|
|
11
|
+
import { code } from "./ts-poet-wrapper.js";
|
|
12
12
|
export class BigDecimalType extends AbstractLiteralType {
|
|
13
13
|
filterFunction = code `${snippets.filterBigDecimal}`;
|
|
14
14
|
filterType = code `${snippets.NumericFilter}<${imports.BigDecimal}>`;
|
|
@@ -16,7 +16,7 @@ export class BigDecimalType extends AbstractLiteralType {
|
|
|
16
16
|
kind = "BigDecimalType";
|
|
17
17
|
name = code `${imports.BigDecimal}`;
|
|
18
18
|
schemaType = code `${snippets.NumericSchema}<${imports.BigDecimal}>`;
|
|
19
|
-
|
|
19
|
+
valueSparqlWherePatternsFunction = code `${snippets.bigDecimalSparqlWherePatterns}`;
|
|
20
20
|
get conversions() {
|
|
21
21
|
return [
|
|
22
22
|
// {
|
|
@@ -63,7 +63,7 @@ export class BigDecimalType extends AbstractLiteralType {
|
|
|
63
63
|
jsonType() {
|
|
64
64
|
return new AbstractLiteralType.JsonType("string");
|
|
65
65
|
}
|
|
66
|
-
|
|
66
|
+
jsonSchema() {
|
|
67
67
|
return code `${imports.z}.string()`;
|
|
68
68
|
}
|
|
69
69
|
toJsonExpression({ variables, }) {
|
|
@@ -75,7 +75,7 @@ export class BigDecimalType extends AbstractLiteralType {
|
|
|
75
75
|
valueTo: code `chain(values => values.chainMap(value => value.toLiteral().chain(${snippets.decodeBigDecimalLiteral})))`,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
toRdfResourceValuesExpression({ variables, }) {
|
|
79
79
|
return code `[${snippets.bigDecimalLiteral}(${variables.value})]`;
|
|
80
80
|
}
|
|
81
81
|
}
|
|
@@ -87,5 +87,5 @@ __decorate([
|
|
|
87
87
|
], BigDecimalType.prototype, "jsonType", null);
|
|
88
88
|
__decorate([
|
|
89
89
|
Memoize()
|
|
90
|
-
], BigDecimalType.prototype, "
|
|
90
|
+
], BigDecimalType.prototype, "jsonSchema", null);
|
|
91
91
|
//# sourceMappingURL=BigDecimalType.js.map
|