@shaclmate/compiler 4.0.29 → 4.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +0 -4
- package/dist/generators/ts/AbstractCollectionType.js +13 -15
- package/dist/generators/ts/AbstractDateType.js +6 -8
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractIdentifierType.js +9 -5
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +2 -3
- package/dist/generators/ts/AbstractLazyObjectType.js +2 -5
- package/dist/generators/ts/AbstractLiteralType.js +2 -3
- package/dist/generators/ts/AbstractNamedUnionType.js +39 -41
- package/dist/generators/ts/AbstractNumericType.js +8 -11
- package/dist/generators/ts/AbstractPrimitiveType.js +1 -2
- package/dist/generators/ts/AbstractTermType.js +12 -14
- package/dist/generators/ts/AbstractType.d.ts +9 -2
- package/dist/generators/ts/AbstractType.js +15 -5
- package/dist/generators/ts/AbstractUnionType.d.ts +3 -0
- package/dist/generators/ts/AbstractUnionType.js +37 -28
- package/dist/generators/ts/BigDecimalType.d.ts +3 -3
- package/dist/generators/ts/BigDecimalType.js +24 -21
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.js +9 -5
- package/dist/generators/ts/BlankNodeType.js +9 -11
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.js +13 -11
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +14 -3
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +14 -3
- package/dist/generators/ts/DefaultValueType.js +5 -8
- package/dist/generators/ts/FloatType.d.ts +1 -1
- package/dist/generators/ts/FloatType.js +13 -2
- package/dist/generators/ts/IdentifierType.js +9 -11
- package/dist/generators/ts/{imports.d.ts → Imports.d.ts} +3 -3
- package/dist/generators/ts/Imports.js +41 -0
- package/dist/generators/ts/IntType.d.ts +1 -1
- package/dist/generators/ts/IntType.js +13 -2
- package/dist/generators/ts/IriType.js +15 -20
- package/dist/generators/ts/LazyObjectOptionType.d.ts +8 -8
- package/dist/generators/ts/LazyObjectOptionType.js +21 -26
- package/dist/generators/ts/LazyObjectSetType.d.ts +5 -1
- package/dist/generators/ts/LazyObjectSetType.js +12 -20
- package/dist/generators/ts/LazyObjectType.d.ts +5 -1
- package/dist/generators/ts/LazyObjectType.js +20 -18
- package/dist/generators/ts/ListType.js +12 -15
- package/dist/generators/ts/LiteralType.js +8 -10
- package/dist/generators/ts/NamedObjectType.d.ts +1 -3
- package/dist/generators/ts/NamedObjectType.js +33 -32
- package/dist/generators/ts/NamedObjectUnionType.js +37 -29
- package/dist/generators/ts/OptionType.js +13 -15
- package/dist/generators/ts/Reusables.d.ts +11 -0
- package/dist/generators/ts/Reusables.js +14 -0
- package/dist/generators/ts/SetType.js +4 -6
- package/dist/generators/ts/Snippet.d.ts +3 -0
- package/dist/generators/ts/Snippet.js +2 -0
- package/dist/generators/ts/SnippetFactory.d.ts +14 -0
- package/dist/generators/ts/SnippetFactory.js +2 -0
- package/dist/generators/ts/Snippets.d.ts +126 -0
- package/dist/generators/ts/Snippets.js +825 -0
- package/dist/generators/ts/StringType.d.ts +2 -2
- package/dist/generators/ts/StringType.js +14 -12
- package/dist/generators/ts/TermType.js +14 -17
- package/dist/generators/ts/TsGenerator.d.ts +7 -1
- package/dist/generators/ts/TsGenerator.js +90 -14
- package/dist/generators/ts/TypeFactory.d.ts +4 -1
- package/dist/generators/ts/TypeFactory.js +29 -3
- package/dist/generators/ts/ZodGenerator.d.ts +1 -0
- package/dist/generators/ts/ZodGenerator.js +10 -8
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +9 -4
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +10 -1
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +17 -24
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +1 -1
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +10 -14
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +3 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +2 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +7 -11
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +11 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +21 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +83 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +2 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +4 -6
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +3 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +4 -7
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +2 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +14 -23
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +4 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +2 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +3 -5
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +12 -15
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +4 -5
- package/dist/generators/ts/_snippets/snippets_BlankNodeFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_BlankNodeFilter.js +1 -2
- package/dist/generators/ts/_snippets/snippets_BlankNodeSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_BlankNodeSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_BooleanFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_BooleanFilter.js +1 -2
- package/dist/generators/ts/_snippets/snippets_BooleanSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_CollectionFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_CollectionFilter.js +1 -2
- package/dist/generators/ts/_snippets/snippets_CollectionSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_DateFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_DateFilter.js +1 -2
- package/dist/generators/ts/_snippets/snippets_DateSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_DateSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +1 -3
- package/dist/generators/ts/_snippets/snippets_EqualsResult.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_EqualsResult.js +1 -3
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_FocusSparqlConstructTriplesFunction.js +1 -3
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_FocusSparqlWherePatternsFunction.js +2 -5
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +1 -3
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +1 -3
- package/dist/generators/ts/_snippets/snippets_Hasher.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_Hasher.js +1 -2
- package/dist/generators/ts/_snippets/snippets_IdentifierFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_IdentifierFilter.js +1 -3
- package/dist/generators/ts/_snippets/snippets_IdentifierSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_IdentifierSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_IdentifierSet.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_IdentifierSet.js +1 -3
- package/dist/generators/ts/_snippets/snippets_IriFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_IriFilter.js +1 -3
- package/dist/generators/ts/_snippets/snippets_IriSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_IriSchema.js +1 -3
- package/dist/generators/ts/_snippets/snippets_LazyObject.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_LazyObject.js +1 -3
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +1 -3
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +1 -3
- package/dist/generators/ts/_snippets/snippets_LiteralFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_LiteralFilter.js +2 -5
- package/dist/generators/ts/_snippets/snippets_LiteralSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_LiteralSchema.js +1 -3
- package/dist/generators/ts/_snippets/snippets_MaybeFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_MaybeFilter.js +1 -2
- package/dist/generators/ts/_snippets/snippets_MaybeSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_NumericFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_NumericFilter.js +1 -2
- package/dist/generators/ts/_snippets/snippets_NumericSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_NumericSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_PropertyPath.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +8 -13
- package/dist/generators/ts/_snippets/snippets_RdfVocabularies.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_RdfVocabularies.js +1 -3
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +2 -4
- package/dist/generators/ts/_snippets/snippets_SparqlFilterPattern.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_SparqlFilterPattern.js +1 -3
- package/dist/generators/ts/_snippets/snippets_SparqlPattern.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_SparqlPattern.js +1 -4
- package/dist/generators/ts/_snippets/snippets_SparqlPattern_isSolutionGenerating.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_SparqlPattern_isSolutionGenerating.js +2 -4
- package/dist/generators/ts/_snippets/snippets_StringFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_StringFilter.js +1 -2
- package/dist/generators/ts/_snippets/snippets_StringSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_StringSchema.js +1 -2
- package/dist/generators/ts/_snippets/snippets_TermFilter.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_TermFilter.js +1 -3
- package/dist/generators/ts/_snippets/snippets_TermSchema.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_TermSchema.js +1 -3
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceFunction.js +9 -5
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_ToRdfResourceValuesFunction.js +5 -6
- package/dist/generators/ts/_snippets/snippets_UnwrapR.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_UnwrapR.js +1 -3
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_ValueSparqlConstructTriplesFunction.js +1 -3
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_ValueSparqlWherePatternsFunction.js +3 -6
- package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.js +13 -0
- package/dist/generators/ts/_snippets/snippets__ToRdfResourceFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets__ToRdfResourceFunction.js +12 -0
- package/dist/generators/ts/_snippets/snippets_arrayEquals.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_arrayEquals.js +7 -10
- package/dist/generators/ts/_snippets/snippets_arrayIntersection.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_arrayIntersection.js +1 -2
- package/dist/generators/ts/_snippets/snippets_bigDecimalLiteral.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalLiteral.js +2 -5
- package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_bigDecimalSparqlWherePatterns.js +11 -19
- package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_blankNodeSparqlWherePatterns.js +2 -6
- package/dist/generators/ts/_snippets/snippets_booleanEquals.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_booleanEquals.js +4 -6
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +5 -12
- package/dist/generators/ts/_snippets/snippets_compactRecord.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_compactRecord.js +1 -2
- package/dist/generators/ts/_snippets/snippets_dateEquals.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_dateEquals.js +4 -6
- package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +9 -17
- package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_decodeBigDecimalLiteral.js +1 -3
- package/dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_deduplicateSparqlPatterns.js +3 -5
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +3 -7
- package/dist/generators/ts/_snippets/snippets_filterArray.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterArray.js +2 -4
- package/dist/generators/ts/_snippets/snippets_filterBigDecimal.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterBigDecimal.js +2 -5
- package/dist/generators/ts/_snippets/snippets_filterBlankNode.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterBlankNode.js +2 -5
- package/dist/generators/ts/_snippets/snippets_filterBoolean.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterBoolean.js +2 -4
- package/dist/generators/ts/_snippets/snippets_filterDate.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterDate.js +2 -4
- package/dist/generators/ts/_snippets/snippets_filterIdentifier.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterIdentifier.js +2 -5
- package/dist/generators/ts/_snippets/snippets_filterIri.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterIri.js +2 -5
- package/dist/generators/ts/_snippets/snippets_filterLiteral.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterLiteral.js +3 -7
- package/dist/generators/ts/_snippets/snippets_filterMaybe.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterMaybe.js +2 -5
- package/dist/generators/ts/_snippets/snippets_filterNumeric.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterNumeric.js +2 -4
- package/dist/generators/ts/_snippets/snippets_filterString.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterString.js +2 -4
- package/dist/generators/ts/_snippets/snippets_filterTerm.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_filterTerm.js +2 -5
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_fromRdfLanguageIn.js +1 -3
- package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_fromRdfPreferredLanguages.js +1 -3
- package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_identifierSparqlWherePatterns.js +4 -10
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +5 -12
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +1 -2
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +1 -2
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +1 -2
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +1 -2
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +1 -2
- package/dist/generators/ts/_snippets/snippets_liftSparqlPatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_liftSparqlPatterns.js +4 -7
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +6 -12
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +9 -18
- package/dist/generators/ts/_snippets/snippets_literalFactory.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_literalFactory.js +1 -3
- package/dist/generators/ts/_snippets/snippets_literalSchemaSparqlPatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_literalSchemaSparqlPatterns.js +7 -13
- package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_literalSparqlWherePatterns.js +3 -8
- package/dist/generators/ts/_snippets/snippets_maybeEquals.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_maybeEquals.js +5 -8
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +2 -6
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +4 -9
- package/dist/generators/ts/_snippets/snippets_normalizeSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_normalizeSparqlWherePatterns.js +9 -14
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +9 -17
- package/dist/generators/ts/_snippets/snippets_parseBlankNode.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_parseBlankNode.js +2 -5
- package/dist/generators/ts/_snippets/snippets_parseIdentifier.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_parseIdentifier.js +1 -3
- package/dist/generators/ts/_snippets/snippets_parseIri.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_parseIri.js +2 -5
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +2 -6
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +3 -8
- package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertyFromRdf.js +2 -5
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +4 -9
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +8 -15
- package/dist/generators/ts/_snippets/snippets_sortSparqlPatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_sortSparqlPatterns.js +5 -7
- package/dist/generators/ts/_snippets/snippets_sparqlInstancesOfPattern.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_sparqlInstancesOfPattern.js +3 -6
- package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_sparqlPropertyPath.js +3 -6
- package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_sparqlValueInPattern.js +3 -7
- package/dist/generators/ts/_snippets/snippets_strictEquals.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_strictEquals.js +4 -6
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +7 -15
- package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_termFilterSparqlPatterns.js +4 -9
- package/dist/generators/ts/_snippets/snippets_termSchemaSparqlPatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_termSchemaSparqlPatterns.js +6 -11
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_termSparqlWherePatterns.js +3 -9
- package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.js +10 -0
- package/dist/generators/ts/_snippets/snippets_wrap_ToRdfResourceFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_wrap_ToRdfResourceFunction.js +14 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +2 -1
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +13 -14
- package/dist/generators/ts/objectSetDeclarations.d.ts +2 -1
- package/dist/generators/ts/objectSetDeclarations.js +3 -3
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +2 -1
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +4 -5
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +2 -1
- package/dist/generators/ts/objectSetMethodSignatures.js +4 -5
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +2 -1
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +49 -51
- package/dist/generators/ts/rdfjsTermExpression.d.ts +6 -2
- package/dist/generators/ts/rdfjsTermExpression.js +13 -15
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +2 -1
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +43 -45
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +2 -1
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +6 -7
- package/dist/input/ShapesGraph.d.ts +4 -4
- package/dist/input/ShapesGraph.js +4 -4
- package/dist/input/generated.d.ts +184 -267
- package/dist/input/generated.js +721 -779
- package/package.json +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js +0 -38
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +0 -101
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +0 -15
- package/dist/generators/ts/imports.js +0 -41
- package/dist/generators/ts/snippets.d.ts +0 -110
- package/dist/generators/ts/snippets.js +0 -217
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +0 -11
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +0 -68
|
@@ -3,8 +3,12 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
3
3
|
export declare class LazyObjectType extends AbstractLazyObjectType<AbstractLazyObjectType.ObjectTypeConstraint, AbstractLazyObjectType.ObjectTypeConstraint> {
|
|
4
4
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
5
5
|
readonly kind = "LazyObjectType";
|
|
6
|
-
constructor({ partialType, resolveType, ...superParameters }: Omit<ConstructorParameters<typeof AbstractLazyObjectType<AbstractLazyObjectType.ObjectTypeConstraint, AbstractLazyObjectType.ObjectTypeConstraint>>[0], "runtimeClass">);
|
|
7
6
|
get conversions(): readonly AbstractLazyObjectType.Conversion[];
|
|
7
|
+
protected get runtimeClass(): {
|
|
8
|
+
name: Code;
|
|
9
|
+
partialPropertyName: string;
|
|
10
|
+
rawName: Code;
|
|
11
|
+
};
|
|
8
12
|
fromJsonExpression(parameters: Parameters<Super["fromJsonExpression"]>[0]): Code;
|
|
9
13
|
fromRdfResourceValuesExpression(parameters: Parameters<Super["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
10
14
|
graphqlResolveExpression({ variables, }: Parameters<Super["graphqlResolveExpression"]>[0]): Code;
|
|
@@ -1,29 +1,21 @@
|
|
|
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
|
+
};
|
|
1
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { Memoize } from "typescript-memoize";
|
|
2
9
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
3
|
-
import { imports } from "./imports.js";
|
|
4
|
-
import { snippets } from "./snippets.js";
|
|
5
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
6
10
|
import { code } from "./ts-poet-wrapper.js";
|
|
7
11
|
export class LazyObjectType extends AbstractLazyObjectType {
|
|
8
12
|
graphqlArgs = Maybe.empty();
|
|
9
13
|
kind = "LazyObjectType";
|
|
10
|
-
constructor({ partialType, resolveType, ...superParameters }) {
|
|
11
|
-
super({
|
|
12
|
-
...superParameters,
|
|
13
|
-
partialType,
|
|
14
|
-
resolveType,
|
|
15
|
-
runtimeClass: {
|
|
16
|
-
name: code `${snippets.LazyObject}<${resolveType.identifierTypeAlias}, ${partialType.name}, ${resolveType.name}>`,
|
|
17
|
-
partialPropertyName: "partial",
|
|
18
|
-
rawName: code `${snippets.LazyObject}`,
|
|
19
|
-
},
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
14
|
get conversions() {
|
|
23
15
|
const conversions = super.conversions.concat();
|
|
24
16
|
if (this.partialType.kind === "NamedObjectType") {
|
|
25
17
|
conversions.push({
|
|
26
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.partialType.name}
|
|
18
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.partialType.name}.create(${value}), resolver: async () => ${this.reusables.imports.Right}(${value} as ${this.resolveType.name}) })`,
|
|
27
19
|
// Don't check instanceof value since the NamedObjectType may be an interface
|
|
28
20
|
// Rely on the fact that this will be the last type check on an object
|
|
29
21
|
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
@@ -35,7 +27,7 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
35
27
|
this.partialType.kind === "NamedObjectUnionType" &&
|
|
36
28
|
this.resolveType.members.length === this.partialType.members.length) {
|
|
37
29
|
conversions.push({
|
|
38
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ((object: ${this.resolveType.name}) => { ${this.resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType: this.resolveType, partialNamedObjectUnionType: this.partialType, variables: { resolvedObjectUnion: code `object` } })} })(${value}), resolver: async () => ${imports.Right}(${value} as ${this.resolveType.name}) })`,
|
|
30
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ((object: ${this.resolveType.name}) => { ${this.resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType: this.resolveType, partialNamedObjectUnionType: this.partialType, variables: { resolvedObjectUnion: code `object` } })} })(${value}), resolver: async () => ${this.reusables.imports.Right}(${value} as ${this.resolveType.name}) })`,
|
|
39
31
|
// Don't check instanceof value since the NamedObjectUnionType may be an interface
|
|
40
32
|
// Rely on the fact that this will be the last type check on an object
|
|
41
33
|
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
@@ -45,8 +37,15 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
45
37
|
}
|
|
46
38
|
return conversions;
|
|
47
39
|
}
|
|
40
|
+
get runtimeClass() {
|
|
41
|
+
return {
|
|
42
|
+
name: code `${this.reusables.snippets.LazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.name}, ${this.resolveType.name}>`,
|
|
43
|
+
partialPropertyName: "partial",
|
|
44
|
+
rawName: code `${this.reusables.snippets.LazyObject}`,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
48
47
|
fromJsonExpression(parameters) {
|
|
49
|
-
return code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.partialType.fromJsonExpression(parameters)}, resolver: (identifier) => Promise.resolve(${imports.Left}(new Error(\`unable to resolve identifier \${identifier} deserialized from JSON\`))) })`;
|
|
48
|
+
return code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.partialType.fromJsonExpression(parameters)}, resolver: (identifier) => Promise.resolve(${this.reusables.imports.Left}(new Error(\`unable to resolve identifier \${identifier} deserialized from JSON\`))) })`;
|
|
50
49
|
}
|
|
51
50
|
fromRdfResourceValuesExpression(parameters) {
|
|
52
51
|
const { variables } = parameters;
|
|
@@ -56,4 +55,7 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
56
55
|
return code `${variables.value}.resolve().then(either => either.unsafeCoerce())`;
|
|
57
56
|
}
|
|
58
57
|
}
|
|
58
|
+
__decorate([
|
|
59
|
+
Memoize()
|
|
60
|
+
], LazyObjectType.prototype, "runtimeClass", null);
|
|
59
61
|
//# sourceMappingURL=LazyObjectType.js.map
|
|
@@ -7,9 +7,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
9
|
import { AbstractCollectionType } from "./AbstractCollectionType.js";
|
|
10
|
-
import { imports } from "./imports.js";
|
|
11
|
-
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
12
|
-
import { snippets } from "./snippets.js";
|
|
13
10
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
14
11
|
export class ListType extends AbstractCollectionType {
|
|
15
12
|
identifierNodeKind;
|
|
@@ -21,10 +18,10 @@ export class ListType extends AbstractCollectionType {
|
|
|
21
18
|
this.toRdfTypes = toRdfTypes;
|
|
22
19
|
}
|
|
23
20
|
get valueSparqlConstructTriplesFunction() {
|
|
24
|
-
return code `${snippets.listSparqlConstructTriples}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlConstructTriplesFunction})`;
|
|
21
|
+
return code `${this.reusables.snippets.listSparqlConstructTriples}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlConstructTriplesFunction})`;
|
|
25
22
|
}
|
|
26
23
|
get valueSparqlWherePatternsFunction() {
|
|
27
|
-
return code `${snippets.listSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
|
|
24
|
+
return code `${this.reusables.snippets.listSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
|
|
28
25
|
}
|
|
29
26
|
fromRdfResourceValuesExpression({ variables, }) {
|
|
30
27
|
return joinCode([
|
|
@@ -35,7 +32,7 @@ export class ListType extends AbstractCollectionType {
|
|
|
35
32
|
valueList => ${this.itemType.fromRdfResourceValuesExpression({
|
|
36
33
|
variables: {
|
|
37
34
|
...variables,
|
|
38
|
-
resourceValues: code `${imports.Right}(${imports.Resource}.Values.fromArray({ focusResource: ${variables.resource}, propertyPath: ${variables.propertyPath}, values: valueList.toArray() }))`,
|
|
35
|
+
resourceValues: code `${this.reusables.imports.Right}(${this.reusables.imports.Resource}.Values.fromArray({ focusResource: ${variables.resource}, propertyPath: ${variables.propertyPath}, values: valueList.toArray() }))`,
|
|
39
36
|
},
|
|
40
37
|
})}
|
|
41
38
|
))`, // Resource.Values<Resource.Values> to Resource.Values<item type arrays>
|
|
@@ -52,12 +49,12 @@ export class ListType extends AbstractCollectionType {
|
|
|
52
49
|
switch (this.identifierNodeKind) {
|
|
53
50
|
case "BlankNode": {
|
|
54
51
|
mintListIdentifierFunction =
|
|
55
|
-
mintSubListIdentifierFunction = code `(() => ${imports.dataFactory}.blankNode())`;
|
|
56
|
-
resourceTypeName = code `${imports.Resource}<${imports.BlankNode}>`;
|
|
52
|
+
mintSubListIdentifierFunction = code `(() => ${this.reusables.imports.dataFactory}.blankNode())`;
|
|
53
|
+
resourceTypeName = code `${this.reusables.imports.Resource}<${this.reusables.imports.BlankNode}>`;
|
|
57
54
|
break;
|
|
58
55
|
}
|
|
59
56
|
case "IRI": {
|
|
60
|
-
resourceTypeName = code `${imports.Resource}<${imports.NamedNode}>`;
|
|
57
|
+
resourceTypeName = code `${this.reusables.imports.Resource}<${this.reusables.imports.NamedNode}>`;
|
|
61
58
|
throw new RangeError("list IRI minting is unsupported");
|
|
62
59
|
}
|
|
63
60
|
}
|
|
@@ -66,28 +63,28 @@ export class ListType extends AbstractCollectionType {
|
|
|
66
63
|
currentSubListResource = listResource;
|
|
67
64
|
} else {
|
|
68
65
|
const newSubListResource = ${variables.resourceSet}.resource(${mintSubListIdentifierFunction}());
|
|
69
|
-
currentSubListResource!.add(${rdfjsTermExpression(rdf.rest
|
|
66
|
+
currentSubListResource!.add(${this.rdfjsTermExpression(rdf.rest)}, newSubListResource.identifier, ${variables.graph});
|
|
70
67
|
currentSubListResource = newSubListResource;
|
|
71
68
|
}
|
|
72
69
|
|
|
73
|
-
${joinCode(this.toRdfTypes.map((rdfType) => code `currentSubListResource.add(${rdfjsTermExpression(rdf.type
|
|
70
|
+
${joinCode(this.toRdfTypes.map((rdfType) => code `currentSubListResource.add(${this.rdfjsTermExpression(rdf.type)}, ${this.reusables.imports.dataFactory}.namedNode("${rdfType.value}"), ${variables.graph})`))}
|
|
74
71
|
|
|
75
|
-
currentSubListResource.add(${rdfjsTermExpression(rdf.first
|
|
72
|
+
currentSubListResource.add(${this.rdfjsTermExpression(rdf.first)}, ${this.itemType.toRdfResourceValuesExpression({ variables: { graph: variables.graph, propertyPath: this.rdfjsTermExpression(rdf.first), resource: code `currentSubListResource`, resourceSet: variables.resourceSet, value: code `item` } })}, ${variables.graph});
|
|
76
73
|
|
|
77
74
|
if (itemIndex + 1 === list.length) {
|
|
78
|
-
currentSubListResource.add(${rdfjsTermExpression(rdf.rest
|
|
75
|
+
currentSubListResource.add(${this.rdfjsTermExpression(rdf.rest)}, ${this.rdfjsTermExpression(rdf.nil)}, ${variables.graph});
|
|
79
76
|
}
|
|
80
77
|
|
|
81
78
|
return { currentSubListResource, listResource };
|
|
82
79
|
},
|
|
83
80
|
{
|
|
84
81
|
currentSubListResource: null,
|
|
85
|
-
listResource: resourceSet.resource(${mintListIdentifierFunction}()),
|
|
82
|
+
listResource: ${variables.resourceSet}.resource(${mintListIdentifierFunction}()),
|
|
86
83
|
} as {
|
|
87
84
|
currentSubListResource: ${resourceTypeName} | null;
|
|
88
85
|
listResource: ${resourceTypeName};
|
|
89
86
|
},
|
|
90
|
-
).listResource.identifier : ${rdfjsTermExpression(rdf.nil
|
|
87
|
+
).listResource.identifier : ${this.rdfjsTermExpression(rdf.nil)}]`;
|
|
91
88
|
}
|
|
92
89
|
toStringExpression({ variables, }) {
|
|
93
90
|
return code `\`[\${${variables.value}.map(item => (${this.itemType.toStringExpression({ variables: { value: code `item` } })}))}]\``;
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { xsd } from "@tpluscode/rdf-ns-builders";
|
|
2
2
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
3
|
-
import { imports } from "./imports.js";
|
|
4
|
-
import { snippets } from "./snippets.js";
|
|
5
3
|
import { code } from "./ts-poet-wrapper.js";
|
|
6
4
|
export class LiteralType extends AbstractLiteralType {
|
|
7
|
-
filterFunction = code `${snippets.filterLiteral}`;
|
|
8
|
-
filterType = code `${snippets.LiteralFilter}`;
|
|
5
|
+
filterFunction = code `${this.reusables.snippets.filterLiteral}`;
|
|
6
|
+
filterType = code `${this.reusables.snippets.LiteralFilter}`;
|
|
9
7
|
kind = "LiteralType";
|
|
10
|
-
name = code `${imports.Literal}`;
|
|
11
|
-
schemaType = code `${snippets.LiteralSchema}`;
|
|
12
|
-
valueSparqlWherePatternsFunction = code `${snippets.literalSparqlWherePatterns}`;
|
|
8
|
+
name = code `${this.reusables.imports.Literal}`;
|
|
9
|
+
schemaType = code `${this.reusables.snippets.LiteralSchema}`;
|
|
10
|
+
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.literalSparqlWherePatterns}`;
|
|
13
11
|
get graphqlType() {
|
|
14
12
|
throw new Error("not implemented");
|
|
15
13
|
}
|
|
16
14
|
fromJsonExpression({ variables, }) {
|
|
17
|
-
return code `${imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined))`;
|
|
15
|
+
return code `${this.reusables.imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined))`;
|
|
18
16
|
}
|
|
19
17
|
graphqlResolveExpression(_parameters) {
|
|
20
18
|
throw new Error("not implemented");
|
|
@@ -34,9 +32,9 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
34
32
|
}
|
|
35
33
|
jsonSchema({ includeDiscriminantProperty, }) {
|
|
36
34
|
const discriminantProperty = includeDiscriminantProperty
|
|
37
|
-
? code `, termType: ${imports.z}.literal("Literal")`
|
|
35
|
+
? code `, termType: ${this.reusables.imports.z}.literal("Literal")`
|
|
38
36
|
: "";
|
|
39
|
-
return code `${imports.z}.object({ "@language": ${imports.z}.string().optional()${discriminantProperty}, "@type": ${imports.z}.string().optional(), "@value": ${imports.z}.string() })`;
|
|
37
|
+
return code `${this.reusables.imports.z}.object({ "@language": ${this.reusables.imports.z}.string().optional()${discriminantProperty}, "@type": ${this.reusables.imports.z}.string().optional(), "@value": ${this.reusables.imports.z}.string() })`;
|
|
40
38
|
}
|
|
41
39
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
42
40
|
return code `{ "@language": ${variables.value}.language.length > 0 ? ${variables.value}.language : undefined${includeDiscriminantProperty ? `, "termType": "Literal" as const` : ""}, "@type": ${variables.value}.datatype.value !== "${xsd.string.value}" ? ${variables.value}.datatype.value : undefined, "@value": ${variables.value}.value }`;
|
|
@@ -12,7 +12,6 @@ import type { TsFeature } from "./TsFeature.js";
|
|
|
12
12
|
import type { Type } from "./Type.js";
|
|
13
13
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
14
14
|
export declare class NamedObjectType extends AbstractType {
|
|
15
|
-
private readonly imports;
|
|
16
15
|
protected readonly toRdfTypes: readonly NamedNode[];
|
|
17
16
|
readonly extern: boolean;
|
|
18
17
|
readonly features: ReadonlySet<TsFeature>;
|
|
@@ -24,13 +23,12 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
24
23
|
readonly recursive: boolean;
|
|
25
24
|
readonly synthetic: boolean;
|
|
26
25
|
readonly typeofs: NonEmptyList<"object">;
|
|
27
|
-
constructor({ extern, features, fromRdfType, identifierType,
|
|
26
|
+
constructor({ extern, features, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, name, recursive, synthetic, toRdfTypes, ...superParameters }: {
|
|
28
27
|
comment: Maybe<string>;
|
|
29
28
|
extern: boolean;
|
|
30
29
|
features: ReadonlySet<TsFeature>;
|
|
31
30
|
fromRdfType: Maybe<NamedNode>;
|
|
32
31
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
33
|
-
imports: readonly string[];
|
|
34
32
|
label: Maybe<string>;
|
|
35
33
|
lazyAncestorObjectTypes: () => readonly NamedObjectType[];
|
|
36
34
|
lazyChildObjectTypes: () => readonly NamedObjectType[];
|
|
@@ -30,8 +30,6 @@ import { NamedObjectType_jsonSchemaFunctionDeclaration } from "./_NamedObjectTyp
|
|
|
30
30
|
import { NamedObjectType_jsonTypeAliasDeclaration } from "./_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js";
|
|
31
31
|
import { NamedObjectType_jsonUiSchemaFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js";
|
|
32
32
|
import { NamedObjectType_objectSetMethodNames } from "./_NamedObjectType/NamedObjectType_objectSetMethodNames.js";
|
|
33
|
-
import { NamedObjectType_propertiesFromJsonFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_propertiesFromJsonFunctionDeclaration.js";
|
|
34
|
-
import { NamedObjectType_propertiesFromRdfResourceFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js";
|
|
35
33
|
import { NamedObjectType_schemaVariableStatement } from "./_NamedObjectType/NamedObjectType_schemaVariableStatement.js";
|
|
36
34
|
import { NamedObjectType_sparqlConstructQueryFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
37
35
|
import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
@@ -42,11 +40,9 @@ import { NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration } from "
|
|
|
42
40
|
import { NamedObjectType_valueSparqlWherePatternsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js";
|
|
43
41
|
import { ShaclProperty as _ShaclProperty } from "./_NamedObjectType/ShaclProperty.js";
|
|
44
42
|
import { AbstractType } from "./AbstractType.js";
|
|
45
|
-
import { imports } from "./imports.js";
|
|
46
43
|
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
47
44
|
import { code, def, joinCode } from "./ts-poet-wrapper.js";
|
|
48
45
|
export class NamedObjectType extends AbstractType {
|
|
49
|
-
imports;
|
|
50
46
|
toRdfTypes;
|
|
51
47
|
extern;
|
|
52
48
|
features;
|
|
@@ -58,13 +54,12 @@ export class NamedObjectType extends AbstractType {
|
|
|
58
54
|
recursive;
|
|
59
55
|
synthetic;
|
|
60
56
|
typeofs = NonEmptyList(["object"]);
|
|
61
|
-
constructor({ extern, features, fromRdfType, identifierType,
|
|
57
|
+
constructor({ extern, features, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, name, recursive, synthetic, toRdfTypes, ...superParameters }) {
|
|
62
58
|
super(superParameters);
|
|
63
59
|
this.extern = extern;
|
|
64
60
|
this.features = features;
|
|
65
61
|
this.fromRdfType = fromRdfType;
|
|
66
62
|
this.identifierType = identifierType;
|
|
67
|
-
this.imports = imports;
|
|
68
63
|
// Lazily initialize some members in getters to avoid recursive construction
|
|
69
64
|
this.lazyAncestorObjectTypes = lazyAncestorObjectTypes;
|
|
70
65
|
this.lazyChildObjectTypes = lazyChildObjectTypes;
|
|
@@ -98,9 +93,6 @@ export class NamedObjectType extends AbstractType {
|
|
|
98
93
|
}
|
|
99
94
|
get declaration() {
|
|
100
95
|
const declarations = [];
|
|
101
|
-
for (const import_ of this.imports) {
|
|
102
|
-
declarations.push(code `${import_}`);
|
|
103
|
-
}
|
|
104
96
|
if (!this.extern) {
|
|
105
97
|
const staticModuleDeclarations = [];
|
|
106
98
|
declarations.push(NamedObjectType_interfaceDeclaration.call(this));
|
|
@@ -112,9 +104,19 @@ export class NamedObjectType extends AbstractType {
|
|
|
112
104
|
];
|
|
113
105
|
staticModuleDeclarations.push(...NamedObjectType_graphqlTypeVariableStatement.call(this).toList(), ...identifierTypeDeclarations.call(this), ...NamedObjectType_jsonTypeAliasDeclaration.call(this).toList(), ...(jsonModuleDeclarations.length > 0
|
|
114
106
|
? [
|
|
115
|
-
code `export namespace
|
|
107
|
+
code `export namespace Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`,
|
|
116
108
|
]
|
|
117
|
-
: []), 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),
|
|
109
|
+
: []), 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_schemaVariableStatement.call(this), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.bind({
|
|
110
|
+
features: this.features,
|
|
111
|
+
filterType: this.filterType,
|
|
112
|
+
name: this.name,
|
|
113
|
+
reusables: this.reusables,
|
|
114
|
+
})().toList(), ...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.bind({
|
|
115
|
+
features: this.features,
|
|
116
|
+
filterType: this.filterType,
|
|
117
|
+
name: this.name,
|
|
118
|
+
reusables: this.reusables,
|
|
119
|
+
})().toList(), ...NamedObjectType_toJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_toRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_toStringFunctionDeclarations.call(this), ...NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.bind(this)().toList(), ...NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.bind(this)().toList());
|
|
118
120
|
if (staticModuleDeclarations.length > 0) {
|
|
119
121
|
declarations.push(code `\
|
|
120
122
|
export namespace ${def(this.name)} {
|
|
@@ -135,6 +137,7 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
135
137
|
}
|
|
136
138
|
get discriminantProperty() {
|
|
137
139
|
return Maybe.of({
|
|
140
|
+
jsonName: this._discriminantProperty.jsonName,
|
|
138
141
|
name: this._discriminantProperty.name,
|
|
139
142
|
ownValues: this._discriminantProperty.type.ownValues,
|
|
140
143
|
descendantValues: this._discriminantProperty.type.descendantValues,
|
|
@@ -144,22 +147,22 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
144
147
|
return this.name;
|
|
145
148
|
}
|
|
146
149
|
get equalsFunction() {
|
|
147
|
-
return code `${this.name}
|
|
150
|
+
return code `${this.name}.equals`;
|
|
148
151
|
}
|
|
149
152
|
get filterFunction() {
|
|
150
|
-
return code `${this.name}
|
|
153
|
+
return code `${this.name}.filter`;
|
|
151
154
|
}
|
|
152
155
|
get filterType() {
|
|
153
|
-
return code `${this.name}
|
|
156
|
+
return code `${this.name}.Filter`;
|
|
154
157
|
}
|
|
155
158
|
get fromRdfTypeVariable() {
|
|
156
|
-
return this.fromRdfType.map(() => code `${this.name}
|
|
159
|
+
return this.fromRdfType.map(() => code `${this.name}.fromRdfType`);
|
|
157
160
|
}
|
|
158
161
|
get graphqlType() {
|
|
159
|
-
return new AbstractType.GraphqlType(code `${this.name}
|
|
162
|
+
return new AbstractType.GraphqlType(code `${this.name}.GraphQL`, this.reusables);
|
|
160
163
|
}
|
|
161
164
|
get identifierTypeAlias() {
|
|
162
|
-
return code `${this.name}
|
|
165
|
+
return code `${this.name}.Identifier`;
|
|
163
166
|
}
|
|
164
167
|
get mutable() {
|
|
165
168
|
return this.properties.some((property) => property.mutable);
|
|
@@ -181,7 +184,7 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
181
184
|
return properties;
|
|
182
185
|
}
|
|
183
186
|
get schema() {
|
|
184
|
-
return code `${this.name}
|
|
187
|
+
return code `${this.name}.schema`;
|
|
185
188
|
}
|
|
186
189
|
get schemaType() {
|
|
187
190
|
return code `typeof ${this.schema}`;
|
|
@@ -193,55 +196,53 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
193
196
|
if (this.parentObjectTypes.length > 0) {
|
|
194
197
|
return this.parentObjectTypes[0].toRdfjsResourceType;
|
|
195
198
|
}
|
|
196
|
-
return code `${imports.Resource}${this.identifierType.kind === "IriType" ? code `<${imports.NamedNode}>` : ""}`;
|
|
199
|
+
return code `${this.reusables.imports.Resource}${this.identifierType.kind === "IriType" ? code `<${this.reusables.imports.NamedNode}>` : ""}`;
|
|
197
200
|
}
|
|
198
201
|
get valueSparqlConstructTriplesFunction() {
|
|
199
|
-
return code `${this.name}
|
|
202
|
+
return code `${this.name}.valueSparqlConstructTriples`;
|
|
200
203
|
}
|
|
201
204
|
get valueSparqlWherePatternsFunction() {
|
|
202
|
-
return code `${this.name}
|
|
205
|
+
return code `${this.name}.valueSparqlWherePatterns`;
|
|
203
206
|
}
|
|
204
207
|
get thisVariable() {
|
|
205
208
|
return code `_${camelCase(this.name)}`;
|
|
206
209
|
}
|
|
207
210
|
fromJsonExpression({ variables, }) {
|
|
208
211
|
// Assumes the JSON object has been recursively validated already.
|
|
209
|
-
return code `${this.name}
|
|
212
|
+
return code `${this.name}.fromJson(${variables.value})`;
|
|
210
213
|
}
|
|
211
214
|
fromRdfResourceValuesExpression({ variables, }) {
|
|
212
215
|
const { resourceValues, ...options } = variables;
|
|
213
|
-
return code `${this.name}
|
|
216
|
+
return code `${this.name}.fromRdfResourceValues(${resourceValues}, ${options})`;
|
|
214
217
|
}
|
|
215
218
|
graphqlResolveExpression({ variables, }) {
|
|
216
219
|
return variables.value;
|
|
217
220
|
}
|
|
218
221
|
hashStatements({ variables, }) {
|
|
219
|
-
return [
|
|
220
|
-
code `${this.name}.${syntheticNamePrefix}hash(${variables.value}, ${variables.hasher});`,
|
|
221
|
-
];
|
|
222
|
+
return [code `${this.name}.hash(${variables.value}, ${variables.hasher});`];
|
|
222
223
|
}
|
|
223
224
|
jsonSchema({ context, }) {
|
|
224
|
-
let expression = code `${this.name}
|
|
225
|
+
let expression = code `${this.name}.Json.schema()`;
|
|
225
226
|
if (context === "property" &&
|
|
226
227
|
this.properties.some((property) => property.recursive)) {
|
|
227
|
-
expression = code `${imports.z}.lazy((): ${imports.z}.ZodType<${this.name}
|
|
228
|
+
expression = code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.name}.Json> => ${expression})`;
|
|
228
229
|
}
|
|
229
230
|
return expression;
|
|
230
231
|
}
|
|
231
232
|
jsonType() {
|
|
232
|
-
return new AbstractType.JsonType(code `${this.name}
|
|
233
|
+
return new AbstractType.JsonType(code `${this.name}.Json`);
|
|
233
234
|
}
|
|
234
235
|
jsonUiSchemaElement({ variables, }) {
|
|
235
|
-
return Maybe.of(code `${this.name}
|
|
236
|
+
return Maybe.of(code `${this.name}.Json.uiSchema({ scopePrefix: ${variables.scopePrefix} })`);
|
|
236
237
|
}
|
|
237
238
|
toJsonExpression({ variables, }) {
|
|
238
|
-
return code `${this.name}
|
|
239
|
+
return code `${this.name}.toJson(${variables.value})`;
|
|
239
240
|
}
|
|
240
241
|
toStringExpression({ variables, }) {
|
|
241
242
|
return code `${this.name}.${syntheticNamePrefix}toString(${variables.value})`;
|
|
242
243
|
}
|
|
243
244
|
toRdfResourceValuesExpression({ variables, }) {
|
|
244
|
-
return code `[${this.name}
|
|
245
|
+
return code `[${this.name}.toRdfResource(${variables.value}, { graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
|
|
245
246
|
}
|
|
246
247
|
lazyAncestorObjectTypes;
|
|
247
248
|
lazyChildObjectTypes;
|
|
@@ -13,9 +13,7 @@ import { NamedObjectType_sparqlConstructQueryFunctionDeclaration } from "./_Name
|
|
|
13
13
|
import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
14
14
|
import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
|
|
15
15
|
import { AbstractType } from "./AbstractType.js";
|
|
16
|
-
import { imports } from "./imports.js";
|
|
17
16
|
import { singleEntryRecord } from "./singleEntryRecord.js";
|
|
18
|
-
import { snippets } from "./snippets.js";
|
|
19
17
|
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
20
18
|
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
21
19
|
export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
@@ -27,16 +25,16 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
27
25
|
this.#identifierType = identifierType;
|
|
28
26
|
}
|
|
29
27
|
get graphqlType() {
|
|
30
|
-
return new AbstractType.GraphqlType(code `${this._name}
|
|
28
|
+
return new AbstractType.GraphqlType(code `${this._name}.GraphQL`, this.reusables);
|
|
31
29
|
}
|
|
32
30
|
get identifierTypeAlias() {
|
|
33
|
-
return code `${this.name}
|
|
31
|
+
return code `${this.name}.Identifier`;
|
|
34
32
|
}
|
|
35
33
|
get objectSetMethodNames() {
|
|
36
34
|
return NamedObjectType_objectSetMethodNames.call(this);
|
|
37
35
|
}
|
|
38
36
|
get schema() {
|
|
39
|
-
return code `${this.name}
|
|
37
|
+
return code `${this.name}.schema`;
|
|
40
38
|
}
|
|
41
39
|
get schemaType() {
|
|
42
40
|
return code `typeof ${this.schema}`;
|
|
@@ -51,11 +49,21 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
51
49
|
...this.graphqlTypeVariableStatement,
|
|
52
50
|
...this.isTypeFunctionDeclaration,
|
|
53
51
|
...this.schemaVariableStatement,
|
|
54
|
-
...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call(
|
|
55
|
-
.
|
|
52
|
+
...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
|
|
53
|
+
features: this.features,
|
|
54
|
+
filterType: this.filterType,
|
|
55
|
+
name: this.name,
|
|
56
|
+
reusables: this.reusables,
|
|
57
|
+
})
|
|
58
|
+
.map((code_) => singleEntryRecord(`sparqlConstructQuery`, code_))
|
|
56
59
|
.orDefault({}),
|
|
57
|
-
...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call(
|
|
58
|
-
.
|
|
60
|
+
...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
|
|
61
|
+
features: this.features,
|
|
62
|
+
filterType: this.filterType,
|
|
63
|
+
name: this.name,
|
|
64
|
+
reusables: this.reusables,
|
|
65
|
+
})
|
|
66
|
+
.map((code_) => singleEntryRecord(`sparqlConstructQueryString`, code_))
|
|
59
67
|
.orDefault({}),
|
|
60
68
|
...this.toRdfResourceFunctionDeclaration,
|
|
61
69
|
};
|
|
@@ -64,19 +72,19 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
64
72
|
if (!this.features.has("sparql")) {
|
|
65
73
|
return {};
|
|
66
74
|
}
|
|
67
|
-
return singleEntryRecord(
|
|
68
|
-
export function
|
|
69
|
-
return [${joinCode(this.members.map((member) => code `...${member.type.name}
|
|
75
|
+
return singleEntryRecord(`focusSparqlConstructTriples`, code `\
|
|
76
|
+
export function focusSparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${this.reusables.imports.NamedNode} | ${this.reusables.imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${this.reusables.imports.sparqljs}.Triple[] {
|
|
77
|
+
return [${joinCode(this.members.map((member) => code `...${member.type.name}.focusSparqlConstructTriples({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`), { on: ", " })}];
|
|
70
78
|
}`);
|
|
71
79
|
}
|
|
72
80
|
get focusSparqlWherePatternsFunctionDeclaration() {
|
|
73
81
|
if (!this.features.has("sparql")) {
|
|
74
82
|
return {};
|
|
75
83
|
}
|
|
76
|
-
return singleEntryRecord(
|
|
77
|
-
export function
|
|
84
|
+
return singleEntryRecord(`focusSparqlWherePatterns`, code `\
|
|
85
|
+
export function focusSparqlWherePatterns({ filter, focusIdentifier, preferredLanguages, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${this.reusables.imports.NamedNode} | ${this.reusables.imports.Variable}; ignoreRdfType: boolean; preferredLanguages: readonly string[] | undefined; variablePrefix: string }): readonly ${this.reusables.snippets.SparqlPattern}[] {
|
|
78
86
|
${joinCode([
|
|
79
|
-
code `let patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
87
|
+
code `let patterns: ${this.reusables.snippets.SparqlPattern}[] = [];`,
|
|
80
88
|
code `\
|
|
81
89
|
if (focusIdentifier.termType === "Variable") {
|
|
82
90
|
patterns = patterns.concat(${this.#identifierType.valueSparqlWherePatternsFunction}({
|
|
@@ -90,7 +98,7 @@ if (focusIdentifier.termType === "Variable") {
|
|
|
90
98
|
}));
|
|
91
99
|
}`,
|
|
92
100
|
code `patterns.push({ patterns: [${joinCode(this.members.map((member) => code `${{
|
|
93
|
-
patterns: code `${member.type.name}
|
|
101
|
+
patterns: code `${member.type.name}.focusSparqlWherePatterns({ filter: filter?.on?.${member.type.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(member.type.name)}\` }).concat()`,
|
|
94
102
|
type: literalOf("group"),
|
|
95
103
|
}}`), { on: ", " })}], type: "union" });`,
|
|
96
104
|
code `return patterns;`,
|
|
@@ -101,10 +109,10 @@ if (focusIdentifier.termType === "Variable") {
|
|
|
101
109
|
if (!this.features.has("rdf")) {
|
|
102
110
|
return {};
|
|
103
111
|
}
|
|
104
|
-
return singleEntryRecord(
|
|
105
|
-
export const
|
|
112
|
+
return singleEntryRecord(`fromRdfResource`, code `\
|
|
113
|
+
export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<${this.name}> = (resource, options) =>
|
|
106
114
|
${this.members.reduce((expression, member) => {
|
|
107
|
-
const memberTypeExpression = code `(${member.type.name}
|
|
115
|
+
const memberTypeExpression = code `(${member.type.name}.fromRdfResource(resource, { ...options, ignoreRdfType: false }) as ${this.reusables.imports.Either}<Error, ${this.name}>)`;
|
|
108
116
|
return expression !== null
|
|
109
117
|
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
110
118
|
: memberTypeExpression;
|
|
@@ -114,8 +122,8 @@ export const ${syntheticNamePrefix}fromRdfResource: ${snippets.FromRdfResourceFu
|
|
|
114
122
|
if (!this.features.has("graphql")) {
|
|
115
123
|
return {};
|
|
116
124
|
}
|
|
117
|
-
return singleEntryRecord(
|
|
118
|
-
export const
|
|
125
|
+
return singleEntryRecord(`GraphQL`, code `\
|
|
126
|
+
export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
|
|
119
127
|
description: this.comment.map(JSON.stringify).extract(),
|
|
120
128
|
name: this.name,
|
|
121
129
|
resolveType: code `(value: ${this.name}) => value.${syntheticNamePrefix}type`,
|
|
@@ -123,9 +131,9 @@ export const ${syntheticNamePrefix}GraphQL = new ${imports.GraphQLUnionType}(${{
|
|
|
123
131
|
}});`);
|
|
124
132
|
}
|
|
125
133
|
get identifierTypeDeclarations() {
|
|
126
|
-
return singleEntryRecord(
|
|
127
|
-
export type
|
|
128
|
-
export namespace
|
|
134
|
+
return singleEntryRecord(`Identifier`, code `\
|
|
135
|
+
export type Identifier = ${this.#identifierType.name};
|
|
136
|
+
export namespace Identifier {
|
|
129
137
|
export const parse = ${this.#identifierType.parseFunction};
|
|
130
138
|
export const stringify = ${this.#identifierType.stringifyFunction};
|
|
131
139
|
}`);
|
|
@@ -169,8 +177,8 @@ export namespace ${syntheticNamePrefix}Identifier {
|
|
|
169
177
|
}
|
|
170
178
|
propertiesObject.push(code `${property.name}: ${property.schema}`);
|
|
171
179
|
}
|
|
172
|
-
return singleEntryRecord(
|
|
173
|
-
export const
|
|
180
|
+
return singleEntryRecord(`schema`, code `\
|
|
181
|
+
export const schema =
|
|
174
182
|
${{
|
|
175
183
|
...super.schemaObject,
|
|
176
184
|
properties: code `{ ${joinCode(propertiesObject, { on: ", " })} }`,
|
|
@@ -180,10 +188,10 @@ ${{
|
|
|
180
188
|
if (!this.features.has("rdf")) {
|
|
181
189
|
return {};
|
|
182
190
|
}
|
|
183
|
-
return singleEntryRecord(
|
|
184
|
-
export const
|
|
191
|
+
return singleEntryRecord(`toRdfResource`, code `\
|
|
192
|
+
export const toRdfResource: ${this.reusables.snippets.ToRdfResourceFunction}<${this.name}> = (object, options) => {
|
|
185
193
|
${joinCode(this.members
|
|
186
|
-
.map((member) => code `if (${member.type.name}.is${member.type.name}(
|
|
194
|
+
.map((member) => code `if (${member.type.name}.is${member.type.name}(object)) { return ${member.type.name}.toRdfResource(object, options); }`)
|
|
187
195
|
.concat(code `throw new Error("unrecognized type");`))}
|
|
188
196
|
};`);
|
|
189
197
|
}
|