@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
|
@@ -6,11 +6,14 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { invariant } from "ts-invariant";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
|
+
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
9
10
|
import { removeUndefined } from "../removeUndefined.js";
|
|
10
11
|
import { code, literalOf } from "../ts-poet-wrapper.js";
|
|
11
12
|
export class AbstractProperty {
|
|
12
13
|
logger;
|
|
13
14
|
namedObjectType;
|
|
15
|
+
reusables;
|
|
16
|
+
rdfjsTermExpression;
|
|
14
17
|
/**
|
|
15
18
|
* TypeScript identifier-safe name of the property.
|
|
16
19
|
*/
|
|
@@ -19,11 +22,17 @@ export class AbstractProperty {
|
|
|
19
22
|
* Property type
|
|
20
23
|
. */
|
|
21
24
|
type;
|
|
22
|
-
constructor({ logger, name, namedObjectType, type, }) {
|
|
25
|
+
constructor({ logger, name, namedObjectType, reusables, type, }) {
|
|
23
26
|
this.logger = logger;
|
|
24
27
|
this.name = name;
|
|
25
28
|
this.namedObjectType = namedObjectType;
|
|
29
|
+
this.reusables = reusables;
|
|
26
30
|
this.type = type;
|
|
31
|
+
this.rdfjsTermExpression = rdfjsTermExpression.bind({
|
|
32
|
+
imports: this.reusables.imports,
|
|
33
|
+
logger: this.logger,
|
|
34
|
+
snippets: this.reusables.snippets,
|
|
35
|
+
});
|
|
27
36
|
}
|
|
28
37
|
/**
|
|
29
38
|
* TypeScript object describing this type, for runtime use.
|
|
@@ -12,12 +12,12 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
|
|
|
12
12
|
type: DiscriminantProperty.Type;
|
|
13
13
|
} & ConstructorParameters<typeof AbstractProperty>[0]);
|
|
14
14
|
get declaration(): Code;
|
|
15
|
+
get jsonName(): string;
|
|
15
16
|
get jsonSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonSchema"];
|
|
16
17
|
get jsonSignature(): Maybe<Code>;
|
|
17
18
|
private get initializer();
|
|
18
|
-
private get override();
|
|
19
19
|
constructorStatements(): readonly Code[];
|
|
20
|
-
|
|
20
|
+
fromJsonExpression(): Maybe<Code>;
|
|
21
21
|
fromRdfResourceValuesExpression(): Maybe<Code>;
|
|
22
22
|
hashStatements({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["hashStatements"]>[0]): readonly Code[];
|
|
23
23
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
@@ -6,7 +6,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
|
-
import { imports } from "../imports.js";
|
|
10
9
|
import { removeUndefined } from "../removeUndefined.js";
|
|
11
10
|
import { arrayOf, code, literalOf } from "../ts-poet-wrapper.js";
|
|
12
11
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
@@ -23,49 +22,43 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
23
22
|
get declaration() {
|
|
24
23
|
return code `readonly ${this.name}: ${this.type.name};`;
|
|
25
24
|
}
|
|
25
|
+
get jsonName() {
|
|
26
|
+
return "@type";
|
|
27
|
+
}
|
|
26
28
|
get jsonSchema() {
|
|
27
|
-
if (this.override) {
|
|
28
|
-
return Maybe.empty();
|
|
29
|
-
}
|
|
30
29
|
return Maybe.of({
|
|
31
|
-
key: this.
|
|
30
|
+
key: this.jsonName,
|
|
32
31
|
schema: this.type.values.length > 1
|
|
33
|
-
? code `${imports.z}.enum(${arrayOf(...this.type.values)})`
|
|
34
|
-
: code `${imports.z}.literal(${literalOf(this.type.values[0])})`,
|
|
32
|
+
? code `${this.reusables.imports.z}.enum(${arrayOf(...this.type.values)})`
|
|
33
|
+
: code `${this.reusables.imports.z}.literal(${literalOf(this.type.values[0])})`,
|
|
35
34
|
});
|
|
36
35
|
}
|
|
37
36
|
get jsonSignature() {
|
|
38
|
-
|
|
39
|
-
return Maybe.empty();
|
|
40
|
-
}
|
|
41
|
-
return Maybe.of(code `readonly ${this.name}: ${this.type.name}`);
|
|
37
|
+
return Maybe.of(code `readonly "${this.jsonName}": ${this.type.name}`);
|
|
42
38
|
}
|
|
43
39
|
get initializer() {
|
|
44
40
|
return code `${literalOf(this.namedObjectType.discriminantValue)} as const`;
|
|
45
41
|
}
|
|
46
|
-
get override() {
|
|
47
|
-
return this.namedObjectType.parentObjectTypes.length > 0;
|
|
48
|
-
}
|
|
49
42
|
constructorStatements() {
|
|
50
43
|
return [code `const ${this.name} = ${this.initializer};`];
|
|
51
44
|
}
|
|
52
|
-
|
|
53
|
-
return
|
|
45
|
+
fromJsonExpression() {
|
|
46
|
+
return Maybe.empty();
|
|
54
47
|
}
|
|
55
48
|
fromRdfResourceValuesExpression() {
|
|
56
|
-
return Maybe.
|
|
49
|
+
return Maybe.empty();
|
|
57
50
|
}
|
|
58
51
|
hashStatements({ variables, }) {
|
|
59
|
-
if (this.
|
|
52
|
+
if (this.namedObjectType.parentObjectTypes.length > 0) {
|
|
60
53
|
return [];
|
|
61
54
|
}
|
|
62
55
|
return [code `${variables.hasher}.update(${variables.value});`];
|
|
63
56
|
}
|
|
64
57
|
jsonUiSchemaElement({ variables, }) {
|
|
65
|
-
if (this.
|
|
58
|
+
if (this.namedObjectType.parentObjectTypes.length > 0) {
|
|
66
59
|
return Maybe.empty();
|
|
67
60
|
}
|
|
68
|
-
const scope = code `\`\${${variables.scopePrefix}}/properties/${this.
|
|
61
|
+
const scope = code `\`\${${variables.scopePrefix}}/properties/${this.jsonName}\``;
|
|
69
62
|
return Maybe.of(code `{ rule: { condition: { schema: { const: ${this.initializer} }, scope: ${scope} }, effect: "HIDE" }, scope: ${scope}, type: "Control" }`);
|
|
70
63
|
}
|
|
71
64
|
sparqlConstructTriplesExpression() {
|
|
@@ -75,10 +68,7 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
75
68
|
return Maybe.empty();
|
|
76
69
|
}
|
|
77
70
|
toJsonObjectMemberExpression({ variables, }) {
|
|
78
|
-
|
|
79
|
-
return Maybe.empty();
|
|
80
|
-
}
|
|
81
|
-
return Maybe.of(code `${this.name}: ${variables.value}`);
|
|
71
|
+
return Maybe.of(code `"${this.jsonName}": ${variables.value}`);
|
|
82
72
|
}
|
|
83
73
|
toRdfRdfResourceValuesStatements() {
|
|
84
74
|
return [];
|
|
@@ -87,6 +77,9 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
87
77
|
return Maybe.empty();
|
|
88
78
|
}
|
|
89
79
|
}
|
|
80
|
+
__decorate([
|
|
81
|
+
Memoize()
|
|
82
|
+
], DiscriminantProperty.prototype, "jsonName", null);
|
|
90
83
|
__decorate([
|
|
91
84
|
Memoize()
|
|
92
85
|
], DiscriminantProperty.prototype, "jsonSchema", null);
|
|
@@ -24,7 +24,7 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
|
|
|
24
24
|
get jsonSignature(): Maybe<Code>;
|
|
25
25
|
accessExpression({ variables, }: Parameters<AbstractProperty<BlankNodeType | IdentifierType | IriType>["accessExpression"]>[0]): Code;
|
|
26
26
|
constructorStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorStatements"]>[0]): readonly Code[];
|
|
27
|
-
|
|
27
|
+
fromJsonExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonExpression"]>[0]): Maybe<Code>;
|
|
28
28
|
fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromRdfResourceValuesExpression"]>[0]): Maybe<Code>;
|
|
29
29
|
hashStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["hashStatements"]>[0]): readonly Code[];
|
|
30
30
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
@@ -10,8 +10,6 @@ import { Maybe } from "purify-ts";
|
|
|
10
10
|
import { invariant } from "ts-invariant";
|
|
11
11
|
import { Memoize } from "typescript-memoize";
|
|
12
12
|
import { codeEquals } from "../codeEquals.js";
|
|
13
|
-
import { imports } from "../imports.js";
|
|
14
|
-
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
15
13
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
16
14
|
import { arrayOf, code, joinCode } from "../ts-poet-wrapper.js";
|
|
17
15
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
@@ -59,10 +57,10 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
59
57
|
if (this.type.in_.length > 0 && this.type.kind === "IriType") {
|
|
60
58
|
// Treat sh:in as a union of the IRIs
|
|
61
59
|
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
62
|
-
schema = code `${imports.z}.enum(${arrayOf(...this.type.in_.map((iri) => iri.value))})`;
|
|
60
|
+
schema = code `${this.reusables.imports.z}.enum(${arrayOf(...this.type.in_.map((iri) => iri.value))})`;
|
|
63
61
|
}
|
|
64
62
|
else {
|
|
65
|
-
schema = code `${imports.z}.string().min(1)`;
|
|
63
|
+
schema = code `${this.reusables.imports.z}.string().min(1)`;
|
|
66
64
|
}
|
|
67
65
|
return Maybe.of({
|
|
68
66
|
key: "@id",
|
|
@@ -95,26 +93,24 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
95
93
|
conversionBranches.push(code `if (${conversion.sourceTypeCheckExpression(parameterVariable)}) { ${this.name} = () => ${conversion.conversionExpression(parameterVariable)}; }`);
|
|
96
94
|
}
|
|
97
95
|
if (this.type.nodeKinds.has("BlankNode")) {
|
|
98
|
-
conversionBranches.push(code `if (${parameterVariable} === undefined) { const ${syntheticNamePrefix}eagerIdentifier = ${imports.dataFactory}.blankNode(); ${this.name} = () => ${syntheticNamePrefix}eagerIdentifier; }`);
|
|
96
|
+
conversionBranches.push(code `if (${parameterVariable} === undefined) { const ${syntheticNamePrefix}eagerIdentifier = ${this.reusables.imports.dataFactory}.blankNode(); ${this.name} = () => ${syntheticNamePrefix}eagerIdentifier; }`);
|
|
99
97
|
}
|
|
100
98
|
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
101
99
|
conversionBranches.push(code `{ ${this.name} = (${parameterVariable}) satisfies never;\n }`);
|
|
102
100
|
statements.push(joinCode(conversionBranches, { on: " else " }));
|
|
103
101
|
return statements;
|
|
104
102
|
}
|
|
105
|
-
|
|
106
|
-
return
|
|
107
|
-
|
|
108
|
-
|
|
103
|
+
fromJsonExpression({ variables, }) {
|
|
104
|
+
return Maybe.of(this.type.fromJsonExpression({
|
|
105
|
+
variables: { value: variables.jsonObject },
|
|
106
|
+
}));
|
|
109
107
|
}
|
|
110
108
|
fromRdfResourceValuesExpression({ variables, }) {
|
|
111
109
|
return Maybe.of(code `${this.type.fromRdfResourceValuesExpression({
|
|
112
110
|
variables: {
|
|
113
111
|
...variables,
|
|
114
|
-
propertyPath: rdfjsTermExpression(rdf.subject,
|
|
115
|
-
|
|
116
|
-
}),
|
|
117
|
-
resourceValues: code `${imports.Right}(new ${imports.Resource}.Value(${{ dataFactory: imports.dataFactory, focusResource: variables.resource, propertyPath: rdfjsTermExpression(rdf.subject, { logger: this.logger }), term: code `${variables.resource}.identifier` }}).toValues())`,
|
|
112
|
+
propertyPath: this.rdfjsTermExpression(rdf.subject),
|
|
113
|
+
resourceValues: code `${this.reusables.imports.Right}(new ${this.reusables.imports.Resource}.Value(${{ dataFactory: this.reusables.imports.dataFactory, focusResource: variables.resource, propertyPath: this.rdfjsTermExpression(rdf.subject), term: code `${variables.resource}.identifier` }}).toValues())`,
|
|
118
114
|
},
|
|
119
115
|
})}.chain(values => values.head())`);
|
|
120
116
|
}
|
|
@@ -135,7 +131,7 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
135
131
|
ignoreRdfType: true, // Unused
|
|
136
132
|
preferredLanguages: variables.preferredLanguages,
|
|
137
133
|
propertyPatterns: code `[]`,
|
|
138
|
-
schema: code `${this.namedObjectType.name}
|
|
134
|
+
schema: code `${this.namedObjectType.name}.schema.properties.${this.name}.type()`,
|
|
139
135
|
valueVariable: variables.focusIdentifier,
|
|
140
136
|
variablePrefix: variables.variablePrefix, // Unused
|
|
141
137
|
}})`,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { invariant } from "ts-invariant";
|
|
3
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
3
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
5
4
|
export function NamedObjectType_createFunctionDeclaration() {
|
|
6
5
|
if (!this.features.has("create")) {
|
|
@@ -12,7 +11,7 @@ export function NamedObjectType_createFunctionDeclaration() {
|
|
|
12
11
|
parametersType.push(code `{ ${joinCode(parametersPropertySignatures)} }`);
|
|
13
12
|
}
|
|
14
13
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
15
|
-
parametersType.push(code `Parameters<typeof ${parentObjectType.name}
|
|
14
|
+
parametersType.push(code `Parameters<typeof ${parentObjectType.name}.create>[0]`);
|
|
16
15
|
}
|
|
17
16
|
if (parametersType.length === 0) {
|
|
18
17
|
parametersType.push(code `object`);
|
|
@@ -21,7 +20,7 @@ export function NamedObjectType_createFunctionDeclaration() {
|
|
|
21
20
|
const omitPropertyNames = [];
|
|
22
21
|
const propertyStatements = [];
|
|
23
22
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
24
|
-
propertyInitializers.push(`...${parentObjectType.name}
|
|
23
|
+
propertyInitializers.push(`...${parentObjectType.name}.create(parameters)`);
|
|
25
24
|
}
|
|
26
25
|
const parametersHasQuestionToken = this.parentObjectTypes.length === 0 &&
|
|
27
26
|
parametersPropertySignatures.every((propertySignature) => propertySignature.toCodeString([]).indexOf("?:") !== -1);
|
|
@@ -44,7 +43,7 @@ export function NamedObjectType_createFunctionDeclaration() {
|
|
|
44
43
|
invariant(propertyInitializers.length > 0);
|
|
45
44
|
invariant(propertyStatements.length > 0);
|
|
46
45
|
return Maybe.of(code `\
|
|
47
|
-
export function
|
|
46
|
+
export function create(parameters${parametersHasQuestionToken ? "?" : ""}: ${joinCode(parametersType, { on: " & " })}): ${omitPropertyNames.length === 0 ? this.name : `Omit<${this.name}, ${omitPropertyNames.map((omitPropertyName) => `"${omitPropertyName}"`).join(" | ")}>`} {
|
|
48
47
|
${joinCode(propertyStatements)}
|
|
49
48
|
return { ${propertyInitializers.join(", ")} };
|
|
50
49
|
}`);
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { snippets } from "../snippets.js";
|
|
3
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
5
3
|
export function NamedObjectType_equalsFunctionDeclaration() {
|
|
6
4
|
if (!this.features.has("equals")) {
|
|
@@ -9,7 +7,7 @@ export function NamedObjectType_equalsFunctionDeclaration() {
|
|
|
9
7
|
const chain = [];
|
|
10
8
|
// For every parent, find the nearest equals implementation
|
|
11
9
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
12
|
-
chain.push(code `${parentObjectType.name}
|
|
10
|
+
chain.push(code `${parentObjectType.name}.equals(left, right)`);
|
|
13
11
|
}
|
|
14
12
|
for (const property of this.properties) {
|
|
15
13
|
if (property.kind === "DiscriminantProperty") {
|
|
@@ -18,7 +16,7 @@ export function NamedObjectType_equalsFunctionDeclaration() {
|
|
|
18
16
|
chain.push(code `(${property.type.equalsFunction})(${property.accessExpression({ variables: { object: code `left` } })}, ${property.accessExpression({ variables: { object: code `right` } })}).mapLeft(propertyValuesUnequal => ({ left, right, propertyName: "${property.name}", propertyValuesUnequal, type: "property" as const }))`);
|
|
19
17
|
}
|
|
20
18
|
return Maybe.of(code `\
|
|
21
|
-
export function
|
|
19
|
+
export function equals(left: ${this.name}, right: ${this.name}): ${this.reusables.snippets.EqualsResult} {
|
|
22
20
|
return ${joinCode(chain.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : code `chain(() => ${chainPart})`), { on: "." })}
|
|
23
21
|
}`);
|
|
24
22
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
2
1
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
2
|
export function NamedObjectType_filterFunctionDeclaration() {
|
|
4
3
|
const statements = [];
|
|
@@ -14,7 +13,7 @@ export function NamedObjectType_filterFunctionDeclaration() {
|
|
|
14
13
|
}
|
|
15
14
|
statements.push(code `return true;`);
|
|
16
15
|
return code `\
|
|
17
|
-
export function
|
|
16
|
+
export function filter(filter: ${this.filterType}, value: ${this.name}): boolean {
|
|
18
17
|
${joinCode(statements)}
|
|
19
18
|
}`;
|
|
20
19
|
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
2
1
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
2
|
export function NamedObjectType_filterTypeDeclaration() {
|
|
4
3
|
const members = [];
|
|
@@ -14,9 +13,9 @@ export function NamedObjectType_filterTypeDeclaration() {
|
|
|
14
13
|
}
|
|
15
14
|
}
|
|
16
15
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
17
|
-
members.push(code `${parentObjectType.name}
|
|
16
|
+
members.push(code `${parentObjectType.name}.Filter`);
|
|
18
17
|
}
|
|
19
18
|
return code `\
|
|
20
|
-
export type
|
|
19
|
+
export type Filter = ${members.length > 0 ? joinCode(members, { on: " & " }) : "object"};`;
|
|
21
20
|
}
|
|
22
21
|
//# sourceMappingURL=NamedObjectType_filterTypeDeclaration.js.map
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
|
-
import { imports } from "../imports.js";
|
|
4
|
-
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
5
|
-
import { snippets } from "../snippets.js";
|
|
6
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
7
3
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
8
4
|
const variables = {
|
|
9
5
|
filter: code `parameters.filter`,
|
|
@@ -14,20 +10,20 @@ export function NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration()
|
|
|
14
10
|
if (!this.features.has("sparql")) {
|
|
15
11
|
return Maybe.empty();
|
|
16
12
|
}
|
|
17
|
-
const rdfClassVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
18
|
-
const rdfTypeVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
13
|
+
const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
14
|
+
const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
19
15
|
let triplesVariableDeclarationKeyword = "const";
|
|
20
16
|
const statements = [];
|
|
21
17
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
22
|
-
statements.push(code `triples = triples.concat(${parentObjectType.name}
|
|
18
|
+
statements.push(code `triples = triples.concat(${parentObjectType.name}.focusSparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
23
19
|
triplesVariableDeclarationKeyword = "let";
|
|
24
20
|
}
|
|
25
21
|
if (this.fromRdfType.isJust()) {
|
|
26
22
|
statements.push(code `\
|
|
27
23
|
if (!parameters?.ignoreRdfType) {
|
|
28
24
|
triples.push(
|
|
29
|
-
{ subject: ${variables.focusIdentifier}, predicate: ${rdfjsTermExpression(rdf.type
|
|
30
|
-
{ subject: ${rdfTypeVariable}, predicate: ${rdfjsTermExpression(rdfs.subClassOf
|
|
25
|
+
{ subject: ${variables.focusIdentifier}, predicate: ${this.rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} },
|
|
26
|
+
{ subject: ${rdfTypeVariable}, predicate: ${this.rdfjsTermExpression(rdfs.subClassOf)}, object: ${rdfClassVariable} }
|
|
31
27
|
);
|
|
32
28
|
}`);
|
|
33
29
|
}
|
|
@@ -45,10 +41,10 @@ if (!parameters?.ignoreRdfType) {
|
|
|
45
41
|
});
|
|
46
42
|
}
|
|
47
43
|
return Maybe.of(code `\
|
|
48
|
-
export const
|
|
44
|
+
export const focusSparqlConstructTriples: ${this.reusables.snippets.FocusSparqlConstructTriplesFunction}<${this.filterType}> = (${statements.length === 0 ? "_" : ""}parameters) => {
|
|
49
45
|
${statements.length > 0
|
|
50
46
|
? joinCode([
|
|
51
|
-
code `${triplesVariableDeclarationKeyword} triples: ${imports.sparqljs}.Triple[] = [];`,
|
|
47
|
+
code `${triplesVariableDeclarationKeyword} triples: ${this.reusables.imports.sparqljs}.Triple[] = [];`,
|
|
52
48
|
...statements,
|
|
53
49
|
code `return triples;`,
|
|
54
50
|
])
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
|
-
import { imports } from "../imports.js";
|
|
4
|
-
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
5
|
-
import { snippets } from "../snippets.js";
|
|
6
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
7
3
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
8
4
|
const variables = {
|
|
9
5
|
filter: code `parameters.filter`,
|
|
@@ -15,13 +11,13 @@ export function NamedObjectType_focusSparqlWherePatternsFunctionDeclaration() {
|
|
|
15
11
|
if (!this.features.has("sparql")) {
|
|
16
12
|
return Maybe.empty();
|
|
17
13
|
}
|
|
18
|
-
const rdfClassVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
19
|
-
const rdfTypeVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
14
|
+
const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
15
|
+
const rdfTypeVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
20
16
|
let patternsVariableDeclarationKeyword = "const";
|
|
21
17
|
const statements = [];
|
|
22
18
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
23
19
|
statements.push(code `\
|
|
24
|
-
patterns = patterns.concat(${parentObjectType.name}
|
|
20
|
+
patterns = patterns.concat(${parentObjectType.name}.focusSparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, preferredLanguages: variables.preferredLanguages, variablePrefix: variables.variablePrefix }}));`);
|
|
25
21
|
patternsVariableDeclarationKeyword = "let";
|
|
26
22
|
}
|
|
27
23
|
if (this.fromRdfType.isJust()) {
|
|
@@ -36,18 +32,18 @@ if (!parameters?.ignoreRdfType) {
|
|
|
36
32
|
{
|
|
37
33
|
type: "values" as const,
|
|
38
34
|
values: [${joinCode(fromRdfTypeVariables, { on: "," })}].map((identifier) => {
|
|
39
|
-
const valuePatternRow: ${imports.sparqljs}.ValuePatternRow = {};
|
|
40
|
-
valuePatternRow[\`?\${${variables.variablePrefix}}FromRdfType\`] = identifier as ${imports.NamedNode};
|
|
35
|
+
const valuePatternRow: ${this.reusables.imports.sparqljs}.ValuePatternRow = {};
|
|
36
|
+
valuePatternRow[\`?\${${variables.variablePrefix}}FromRdfType\`] = identifier as ${this.reusables.imports.NamedNode};
|
|
41
37
|
return valuePatternRow;
|
|
42
38
|
}),
|
|
43
39
|
},
|
|
44
|
-
${snippets.sparqlInstancesOfPattern}({ rdfType: ${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}FromRdfType\`), subject: ${variables.focusIdentifier} }),`
|
|
45
|
-
: code `${snippets.sparqlInstancesOfPattern}({ rdfType: ${fromRdfTypeVariables[0]}, subject: ${variables.focusIdentifier} }),`}
|
|
40
|
+
${this.reusables.snippets.sparqlInstancesOfPattern}({ rdfType: ${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}FromRdfType\`), subject: ${variables.focusIdentifier} }),`
|
|
41
|
+
: code `${this.reusables.snippets.sparqlInstancesOfPattern}({ rdfType: ${fromRdfTypeVariables[0]}, subject: ${variables.focusIdentifier} }),`}
|
|
46
42
|
{
|
|
47
43
|
triples: [
|
|
48
44
|
{
|
|
49
45
|
subject: ${variables.focusIdentifier},
|
|
50
|
-
predicate: ${rdfjsTermExpression(rdf.type
|
|
46
|
+
predicate: ${this.rdfjsTermExpression(rdf.type)},
|
|
51
47
|
object: rdfTypeVariable
|
|
52
48
|
}
|
|
53
49
|
],
|
|
@@ -60,7 +56,7 @@ if (!parameters?.ignoreRdfType) {
|
|
|
60
56
|
{
|
|
61
57
|
subject: rdfTypeVariable,
|
|
62
58
|
predicate: {
|
|
63
|
-
items: [${rdfjsTermExpression(rdfs.subClassOf
|
|
59
|
+
items: [${this.rdfjsTermExpression(rdfs.subClassOf)}],
|
|
64
60
|
pathType: "+" as const,
|
|
65
61
|
type: "path" as const
|
|
66
62
|
},
|
|
@@ -93,10 +89,10 @@ if (!parameters?.ignoreRdfType) {
|
|
|
93
89
|
});
|
|
94
90
|
}
|
|
95
91
|
return Maybe.of(code `\
|
|
96
|
-
export const
|
|
92
|
+
export const focusSparqlWherePatterns: ${this.reusables.snippets.FocusSparqlWherePatternsFunction}<${this.filterType}> = (${statements.length === 0 ? "_" : ""}parameters) => {
|
|
97
93
|
${statements.length > 0
|
|
98
94
|
? joinCode([
|
|
99
|
-
code `${patternsVariableDeclarationKeyword} patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
95
|
+
code `${patternsVariableDeclarationKeyword} patterns: ${this.reusables.snippets.SparqlPattern}[] = [];`,
|
|
100
96
|
...statements,
|
|
101
97
|
code `return patterns;`,
|
|
102
98
|
])
|
|
@@ -1,13 +1,31 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
|
-
import { code } from "../ts-poet-wrapper.js";
|
|
3
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
4
|
+
const variables = {
|
|
5
|
+
jsonObject: code `${syntheticNamePrefix}json`,
|
|
6
|
+
};
|
|
4
7
|
export function NamedObjectType_fromJsonFunctionDeclaration() {
|
|
5
8
|
if (!this.features.has("json")) {
|
|
6
9
|
return Maybe.empty();
|
|
7
10
|
}
|
|
11
|
+
const initializers = [];
|
|
12
|
+
const statements = [];
|
|
13
|
+
this.parentObjectTypes.forEach((parentObjectType) => {
|
|
14
|
+
initializers.push(code `...${parentObjectType.name}.fromJson(${variables.jsonObject})`);
|
|
15
|
+
});
|
|
16
|
+
for (const property of this.properties) {
|
|
17
|
+
property
|
|
18
|
+
.fromJsonExpression({
|
|
19
|
+
variables,
|
|
20
|
+
})
|
|
21
|
+
.ifJust((propertyFromJsonExpression) => {
|
|
22
|
+
initializers.push(code `${property.name}: ${propertyFromJsonExpression}`);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
statements.push(code `return create({ ${joinCode(initializers, { on: ", " })} });`);
|
|
8
26
|
return Maybe.of(code `\
|
|
9
|
-
export function ${
|
|
10
|
-
|
|
27
|
+
export function fromJson(${variables.jsonObject}: ${this.jsonType().name}): ${this.name} {
|
|
28
|
+
${joinCode(statements, { on: "\n" })}
|
|
11
29
|
}`);
|
|
12
30
|
}
|
|
13
31
|
//# sourceMappingURL=NamedObjectType_fromJsonFunctionDeclaration.js.map
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js
CHANGED
|
@@ -1,18 +1,93 @@
|
|
|
1
|
+
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
1
2
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { snippets } from "../snippets.js";
|
|
3
3
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
4
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
5
|
+
const optionsVariable = `_${syntheticNamePrefix}options`;
|
|
6
|
+
const variables = {
|
|
7
|
+
context: code `${optionsVariable}.context`,
|
|
8
|
+
graph: code `${optionsVariable}.graph`,
|
|
9
|
+
ignoreRdfType: code `${optionsVariable}.ignoreRdfType`,
|
|
10
|
+
objectSet: code `${optionsVariable}.objectSet`,
|
|
11
|
+
preferredLanguages: code `${optionsVariable}.preferredLanguages`,
|
|
12
|
+
resource: code `${syntheticNamePrefix}resource`,
|
|
13
|
+
};
|
|
14
|
+
const propertyFromRdfResourceValuesExpressionVariable = {
|
|
15
|
+
context: variables.context,
|
|
16
|
+
graph: variables.graph,
|
|
17
|
+
preferredLanguages: variables.preferredLanguages,
|
|
18
|
+
objectSet: variables.objectSet,
|
|
19
|
+
resource: variables.resource,
|
|
20
|
+
};
|
|
5
21
|
export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
|
|
6
22
|
if (!this.features.has("rdf")) {
|
|
7
23
|
return Maybe.empty();
|
|
8
24
|
}
|
|
25
|
+
const chains = [];
|
|
26
|
+
const initializers = [];
|
|
27
|
+
this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
|
|
28
|
+
chains.push({
|
|
29
|
+
expression: code `${parentObjectType.name}._fromRdfResource(${variables.resource}, { ...${optionsVariable}, ignoreRdfType: true })`,
|
|
30
|
+
variable: `${syntheticNamePrefix}super${parentObjectTypeI}`,
|
|
31
|
+
});
|
|
32
|
+
initializers.push(code `...${syntheticNamePrefix}super${parentObjectTypeI}`);
|
|
33
|
+
});
|
|
34
|
+
this.fromRdfType.ifJust((fromRdfType) => {
|
|
35
|
+
const fromRdfTypeVariable = this.fromRdfTypeVariable.unsafeCoerce();
|
|
36
|
+
const predicate = this.rdfjsTermExpression(rdf.type);
|
|
37
|
+
// Check the expected type and its known subtypes
|
|
38
|
+
const cases = new Set();
|
|
39
|
+
cases.add(fromRdfType.value);
|
|
40
|
+
for (const descendantFromRdfType of this.descendantFromRdfTypes) {
|
|
41
|
+
cases.add(descendantFromRdfType.value);
|
|
42
|
+
}
|
|
43
|
+
chains.push({
|
|
44
|
+
expression: code `!${variables.ignoreRdfType} ? ${variables.resource}.value(${predicate}, ${{ graph: variables.graph }})
|
|
45
|
+
.chain(actualRdfType => actualRdfType.toIri())
|
|
46
|
+
.chain((actualRdfType) => {
|
|
47
|
+
// Check the expected type and its known subtypes
|
|
48
|
+
switch (actualRdfType.value) {
|
|
49
|
+
${[...cases].map((fromRdfType) => `case "${fromRdfType}":`).join("\n")}
|
|
50
|
+
return ${this.reusables.imports.Right}(true as const);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Check arbitrary rdfs:subClassOf's of the expected type
|
|
54
|
+
if (${variables.resource}.isInstanceOf(${fromRdfTypeVariable}, ${{ graph: variables.graph }})) {
|
|
55
|
+
return ${this.reusables.imports.Right}(true as const);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return ${this.reusables.imports.Left}(new Error(\`\${${variables.resource}.identifier} has unexpected RDF type (actual: \${actualRdfType.value}, expected: ${fromRdfType.value})\`));
|
|
59
|
+
}) : ${this.reusables.imports.Right}(true as const)`,
|
|
60
|
+
variable: "_rdfTypeCheck",
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
for (const property of this.properties) {
|
|
64
|
+
property
|
|
65
|
+
.fromRdfResourceValuesExpression({
|
|
66
|
+
variables: propertyFromRdfResourceValuesExpressionVariable,
|
|
67
|
+
})
|
|
68
|
+
.ifJust((propertyFromRdfExpression) => {
|
|
69
|
+
chains.push({
|
|
70
|
+
expression: propertyFromRdfExpression,
|
|
71
|
+
variable: property.name,
|
|
72
|
+
});
|
|
73
|
+
initializers.push(code `${property.name}`);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
const statements = [];
|
|
77
|
+
const resultExpression = code `${this.name}.create({ ${joinCode(initializers, { on: "," })} })`;
|
|
78
|
+
if (chains.length === 0) {
|
|
79
|
+
statements.push(code `return ${this.reusables.imports.Right}(${resultExpression});`);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
statements.push(code `return ${chains
|
|
83
|
+
.reverse()
|
|
84
|
+
.reduce((acc, { expression, variable }, chainI) => code `(${expression}).${chainI === 0 ? "map" : "chain"}(${variable} => ${acc})`, code `(${resultExpression})`)}`);
|
|
85
|
+
}
|
|
9
86
|
return Maybe.of(code `\
|
|
10
|
-
export const
|
|
11
|
-
${joinCode(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
])}
|
|
16
|
-
};`);
|
|
87
|
+
export const _fromRdfResource: ${this.reusables.snippets._FromRdfResourceFunction}<${this.name}> = (${variables.resource}, ${optionsVariable}) => {
|
|
88
|
+
${joinCode(statements)}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export const fromRdfResource = ${this.reusables.snippets.wrap_FromRdfResourceFunction}(_fromRdfResource);`);
|
|
17
92
|
}
|
|
18
93
|
//# sourceMappingURL=NamedObjectType_fromRdfResourceFunctionDeclaration.js.map
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { snippets } from "../snippets.js";
|
|
3
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
5
3
|
export function NamedObjectType_fromRdfResourceValuesFunctionDeclaration() {
|
|
6
4
|
if (!this.features.has("rdf")) {
|
|
7
5
|
return Maybe.empty();
|
|
8
6
|
}
|
|
9
7
|
return Maybe.of(code `\
|
|
10
|
-
export const
|
|
8
|
+
export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.name}> = (values, options) =>
|
|
11
9
|
values.chain(
|
|
12
10
|
values => values.chainMap(
|
|
13
|
-
value => value.toResource().chain(resource => ${this.name}
|
|
11
|
+
value => value.toResource().chain(resource => ${this.name}.fromRdfResource(resource, options))
|
|
14
12
|
)
|
|
15
13
|
);`);
|
|
16
14
|
}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { imports } from "../imports.js";
|
|
3
|
-
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
4
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
6
3
|
export function NamedObjectType_fromRdfTypeVariableStatement() {
|
|
7
4
|
if (!this.features.has("rdf")) {
|
|
8
5
|
return Maybe.empty();
|
|
9
6
|
}
|
|
10
7
|
return this.fromRdfType.map((fromRdfType) => code `\
|
|
11
|
-
export const
|
|
8
|
+
export const fromRdfType: ${this.reusables.imports.NamedNode}<string> = ${this.rdfjsTermExpression(fromRdfType)};`);
|
|
12
9
|
}
|
|
13
10
|
//# sourceMappingURL=NamedObjectType_fromRdfTypeVariableStatement.js.map
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { imports } from "../imports.js";
|
|
3
2
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
3
|
import { code } from "../ts-poet-wrapper.js";
|
|
5
4
|
export function NamedObjectType_graphqlTypeVariableStatement() {
|
|
@@ -10,7 +9,7 @@ export function NamedObjectType_graphqlTypeVariableStatement() {
|
|
|
10
9
|
return Maybe.empty();
|
|
11
10
|
}
|
|
12
11
|
return Maybe.of(code `\
|
|
13
|
-
export const
|
|
12
|
+
export const GraphQL = new ${this.reusables.imports.GraphQLObjectType}<${this.name}, { objectSet: ${syntheticNamePrefix}ObjectSet }>(${{
|
|
14
13
|
description: this.comment.extract(),
|
|
15
14
|
fields: code `() => (${this.properties.reduce((fields, property) => {
|
|
16
15
|
property.graphqlField.ifJust((field) => {
|