@shaclmate/compiler 4.0.29 → 4.0.30
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 +10 -13
- package/dist/generators/ts/AbstractType.d.ts +8 -2
- package/dist/generators/ts/AbstractType.js +15 -5
- package/dist/generators/ts/AbstractUnionType.js +17 -19
- 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 +11 -14
- package/dist/generators/ts/LiteralType.js +8 -10
- package/dist/generators/ts/NamedObjectType.d.ts +1 -3
- package/dist/generators/ts/NamedObjectType.js +32 -30
- 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 +123 -0
- package/dist/generators/ts/Snippets.js +804 -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 +6 -1
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +10 -1
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +3 -4
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -10
- 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 +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +2 -3
- 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_propertiesFromJsonFunctionDeclaration.js +3 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +9 -12
- 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 +4 -7
- 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.js +8 -11
- 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_PropertiesFromRdfResourceFunction.d.ts +2 -1
- package/dist/generators/ts/_snippets/snippets_PropertiesFromRdfResourceFunction.js +1 -3
- 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 +1 -3
- 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_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/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 +162 -163
- package/dist/input/generated.js +410 -416
- package/package.json +2 -2
- 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
|
@@ -1,11 +1,19 @@
|
|
|
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 { NonEmptyList } from "purify-ts";
|
|
8
|
+
import { Memoize } from "typescript-memoize";
|
|
2
9
|
import { AbstractNumericType } from "./AbstractNumericType.js";
|
|
3
|
-
import { imports } from "./imports.js";
|
|
4
10
|
import { code } from "./ts-poet-wrapper.js";
|
|
5
11
|
export class FloatType extends AbstractNumericType {
|
|
6
12
|
kind = "FloatType";
|
|
7
|
-
graphqlType = new AbstractNumericType.GraphqlType(code `${imports.GraphQLFloat}`);
|
|
8
13
|
typeofs = NonEmptyList(["number"]);
|
|
14
|
+
get graphqlType() {
|
|
15
|
+
return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLFloat}`, this.reusables);
|
|
16
|
+
}
|
|
9
17
|
fromRdfResourceValueExpression({ variables, }) {
|
|
10
18
|
return code `${variables.value}.toFloat(${this.primitiveIn.length > 0 ? `${JSON.stringify(this.primitiveIn)} as const` : ""})`;
|
|
11
19
|
}
|
|
@@ -13,4 +21,7 @@ export class FloatType extends AbstractNumericType {
|
|
|
13
21
|
return value.toString();
|
|
14
22
|
}
|
|
15
23
|
}
|
|
24
|
+
__decorate([
|
|
25
|
+
Memoize()
|
|
26
|
+
], FloatType.prototype, "graphqlType", null);
|
|
16
27
|
//# sourceMappingURL=FloatType.js.map
|
|
@@ -8,18 +8,16 @@ import { NodeKind } from "@shaclmate/shacl-ast";
|
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
9
|
import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
|
|
10
10
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
11
|
-
import { imports } from "./imports.js";
|
|
12
|
-
import { snippets } from "./snippets.js";
|
|
13
11
|
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
14
12
|
export class IdentifierType extends AbstractIdentifierType {
|
|
15
|
-
filterFunction = code `${snippets.filterIdentifier}`;
|
|
16
|
-
filterType = code `${snippets.IdentifierFilter}`;
|
|
17
|
-
parseFunction = code `${snippets.parseIdentifier};`;
|
|
13
|
+
filterFunction = code `${this.reusables.snippets.filterIdentifier}`;
|
|
14
|
+
filterType = code `${this.reusables.snippets.IdentifierFilter}`;
|
|
15
|
+
parseFunction = code `${this.reusables.snippets.parseIdentifier};`;
|
|
18
16
|
kind = "IdentifierType";
|
|
19
|
-
name = code `(${imports.BlankNode} | ${imports.NamedNode})`;
|
|
17
|
+
name = code `(${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode})`;
|
|
20
18
|
nodeKinds = nodeKinds;
|
|
21
|
-
schemaType = code `${snippets.IdentifierSchema}`;
|
|
22
|
-
valueSparqlWherePatternsFunction = code `${snippets.identifierSparqlWherePatterns}`;
|
|
19
|
+
schemaType = code `${this.reusables.snippets.IdentifierSchema}`;
|
|
20
|
+
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.identifierSparqlWherePatterns}`;
|
|
23
21
|
constructor(parameters) {
|
|
24
22
|
super({
|
|
25
23
|
...parameters,
|
|
@@ -28,7 +26,7 @@ export class IdentifierType extends AbstractIdentifierType {
|
|
|
28
26
|
});
|
|
29
27
|
}
|
|
30
28
|
fromJsonExpression({ variables, }) {
|
|
31
|
-
return code `(${variables.value}["@id"].startsWith("_:") ? ${imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2)) : ${imports.dataFactory}.namedNode(${variables.value}["@id"]))`;
|
|
29
|
+
return code `(${variables.value}["@id"].startsWith("_:") ? ${this.reusables.imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2)) : ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"]))`;
|
|
32
30
|
}
|
|
33
31
|
jsonType(parameters) {
|
|
34
32
|
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
@@ -38,9 +36,9 @@ export class IdentifierType extends AbstractIdentifierType {
|
|
|
38
36
|
}
|
|
39
37
|
jsonSchema({ includeDiscriminantProperty, }) {
|
|
40
38
|
const discriminantProperty = includeDiscriminantProperty
|
|
41
|
-
? code `, termType: ${imports.z}.enum(${arrayOf(...this.nodeKinds)})`
|
|
39
|
+
? code `, termType: ${this.reusables.imports.z}.enum(${arrayOf(...this.nodeKinds)})`
|
|
42
40
|
: "";
|
|
43
|
-
return code `${imports.z}.object({ "@id": ${imports.z}.string().min(1)${discriminantProperty} })`;
|
|
41
|
+
return code `${this.reusables.imports.z}.object({ "@id": ${this.reusables.imports.z}.string().min(1)${discriminantProperty} })`;
|
|
44
42
|
}
|
|
45
43
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
46
44
|
const discriminantProperty = includeDiscriminantProperty
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare
|
|
1
|
+
export declare class Imports {
|
|
2
2
|
readonly BigDecimal: import("ts-poet/build/Import.js").Import;
|
|
3
3
|
readonly BlankNode: import("ts-poet/build/Import.js").Import;
|
|
4
4
|
readonly dataFactory: import("ts-poet/build/Import.js").Import;
|
|
@@ -36,5 +36,5 @@ export declare const imports: {
|
|
|
36
36
|
readonly sparqljs: import("ts-poet/build/Import.js").Import;
|
|
37
37
|
readonly Variable: import("ts-poet/build/Import.js").Import;
|
|
38
38
|
readonly z: import("ts-poet/build/Import.js").Import;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=Imports.d.ts.map
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { imp } from "./ts-poet-wrapper.js";
|
|
2
|
+
export class Imports {
|
|
3
|
+
BigDecimal = imp("Decimal:BigDecimal@decimal.js");
|
|
4
|
+
BlankNode = imp("BlankNode@@rdfjs/types");
|
|
5
|
+
dataFactory = imp("dataFactory=@rdfx/data-factory");
|
|
6
|
+
DatasetCore = imp("DatasetCore@@rdfjs/types");
|
|
7
|
+
datasetFactory = imp("datasetFactory=@rdfjs/dataset");
|
|
8
|
+
Either = imp("Either@purify-ts");
|
|
9
|
+
EitherAsync = imp("EitherAsync@purify-ts");
|
|
10
|
+
GraphQLBigInt = imp("BigInt:GraphQLBigInt@graphql-scalars");
|
|
11
|
+
GraphQLBoolean = imp("GraphQLBoolean@graphql");
|
|
12
|
+
GraphQLDate = imp("Date:GraphQLDate@graphql-scalars");
|
|
13
|
+
GraphQLDateTime = imp("DateTime:GraphQLDateTime@graphql-scalars");
|
|
14
|
+
GraphQLFloat = imp("GraphQLFloat@graphql");
|
|
15
|
+
GraphQLID = imp("GraphQLID@graphql");
|
|
16
|
+
GraphQLInt = imp("GraphQLInt@graphql");
|
|
17
|
+
GraphQLList = imp("GraphQLList@graphql");
|
|
18
|
+
GraphQLNonNull = imp("GraphQLNonNull@graphql");
|
|
19
|
+
GraphQLObjectType = imp("GraphQLObjectType@graphql");
|
|
20
|
+
GraphQLSchema = imp("GraphQLSchema@graphql");
|
|
21
|
+
GraphQLString = imp("GraphQLString@graphql");
|
|
22
|
+
GraphQLUnionType = imp("GraphQLUnionType@graphql");
|
|
23
|
+
Left = imp("Left@purify-ts");
|
|
24
|
+
Literal = imp("Literal@@rdfjs/types");
|
|
25
|
+
LiteralFactory = imp("LiteralFactory@@rdfx/literal");
|
|
26
|
+
Maybe = imp("Maybe@purify-ts");
|
|
27
|
+
NamedNode = imp("NamedNode@@rdfjs/types");
|
|
28
|
+
NonEmptyList = imp("NonEmptyList@purify-ts");
|
|
29
|
+
NTriplesIdentifier = imp("NTriplesIdentifier@@rdfx/string");
|
|
30
|
+
NTriplesTerm = imp("NTriplesTerm@@rdfx/string");
|
|
31
|
+
Quad = imp("Quad@@rdfjs/types");
|
|
32
|
+
Quad_Graph = imp("Quad_Graph@@rdfjs/types");
|
|
33
|
+
RdfxResourcePropertyPath = imp("PropertyPath:RdfxResourcePropertyPath@@rdfx/resource");
|
|
34
|
+
Resource = imp("Resource@@rdfx/resource");
|
|
35
|
+
ResourceSet = imp("ResourceSet@@rdfx/resource");
|
|
36
|
+
Right = imp("Right@purify-ts");
|
|
37
|
+
sparqljs = imp("sparqljs*sparqljs");
|
|
38
|
+
Variable = imp("Variable@@rdfjs/types");
|
|
39
|
+
z = imp("z@zod");
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=Imports.js.map
|
|
@@ -2,9 +2,9 @@ import { NonEmptyList } from "purify-ts";
|
|
|
2
2
|
import { AbstractNumericType } from "./AbstractNumericType.js";
|
|
3
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
4
|
export declare class IntType extends AbstractNumericType<number> {
|
|
5
|
-
readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
|
|
6
5
|
readonly kind = "IntType";
|
|
7
6
|
readonly typeofs: NonEmptyList<"number">;
|
|
7
|
+
get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
|
|
8
8
|
protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractNumericType<number>["fromRdfResourceValueExpression"]>[0]): Code;
|
|
9
9
|
protected literalOf(value: number): string;
|
|
10
10
|
}
|
|
@@ -1,11 +1,19 @@
|
|
|
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 { NonEmptyList } from "purify-ts";
|
|
8
|
+
import { Memoize } from "typescript-memoize";
|
|
2
9
|
import { AbstractNumericType } from "./AbstractNumericType.js";
|
|
3
|
-
import { imports } from "./imports.js";
|
|
4
10
|
import { code } from "./ts-poet-wrapper.js";
|
|
5
11
|
export class IntType extends AbstractNumericType {
|
|
6
|
-
graphqlType = new AbstractNumericType.GraphqlType(code `${imports.GraphQLInt}`);
|
|
7
12
|
kind = "IntType";
|
|
8
13
|
typeofs = NonEmptyList(["number"]);
|
|
14
|
+
get graphqlType() {
|
|
15
|
+
return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLInt}`, this.reusables);
|
|
16
|
+
}
|
|
9
17
|
fromRdfResourceValueExpression({ variables, }) {
|
|
10
18
|
return code `${variables.value}.toInt(${this.primitiveIn.length > 0 ? `${JSON.stringify(this.primitiveIn)} as const` : ""})`;
|
|
11
19
|
}
|
|
@@ -13,4 +21,7 @@ export class IntType extends AbstractNumericType {
|
|
|
13
21
|
return value.toString();
|
|
14
22
|
}
|
|
15
23
|
}
|
|
24
|
+
__decorate([
|
|
25
|
+
Memoize()
|
|
26
|
+
], IntType.prototype, "graphqlType", null);
|
|
16
27
|
//# sourceMappingURL=IntType.js.map
|
|
@@ -7,45 +7,40 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Memoize } from "typescript-memoize";
|
|
8
8
|
import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
|
|
9
9
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
10
|
-
import { imports } from "./imports.js";
|
|
11
|
-
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
12
|
-
import { snippets } from "./snippets.js";
|
|
13
10
|
import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
|
|
14
11
|
export class IriType extends AbstractIdentifierType {
|
|
15
|
-
filterFunction = code `${snippets.filterIri}`;
|
|
16
|
-
filterType = code `${snippets.IriFilter}`;
|
|
12
|
+
filterFunction = code `${this.reusables.snippets.filterIri}`;
|
|
13
|
+
filterType = code `${this.reusables.snippets.IriFilter}`;
|
|
17
14
|
kind = "IriType";
|
|
18
15
|
nodeKinds = nodeKinds;
|
|
19
|
-
schemaType = code `${snippets.IriSchema}`;
|
|
20
|
-
valueSparqlWherePatternsFunction = code `${snippets.iriSparqlWherePatterns}`;
|
|
16
|
+
schemaType = code `${this.reusables.snippets.IriSchema}`;
|
|
17
|
+
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.iriSparqlWherePatterns}`;
|
|
21
18
|
get parseFunction() {
|
|
22
19
|
if (this.in_.length > 0) {
|
|
23
|
-
return code `(identifier: string) => ${snippets.parseIri}(identifier).chain((identifier) => { switch (identifier.value) { ${joinCode(this.in_.map((iri) => code `case "${iri.value}": return ${imports.Right}(identifier as ${this.name});`))} default: return ${imports.Left}(new Error("expected NamedNode identifier to be one of ${this.in_.map((iri) => iri.value).join(" ")}")); } })`;
|
|
20
|
+
return code `(identifier: string) => ${this.reusables.snippets.parseIri}(identifier).chain((identifier) => { switch (identifier.value) { ${joinCode(this.in_.map((iri) => code `case "${iri.value}": return ${this.reusables.imports.Right}(identifier as ${this.name});`))} default: return ${this.reusables.imports.Left}(new Error("expected NamedNode identifier to be one of ${this.in_.map((iri) => iri.value).join(" ")}")); } })`;
|
|
24
21
|
}
|
|
25
|
-
return code `${snippets.parseIri}`;
|
|
22
|
+
return code `${this.reusables.snippets.parseIri}`;
|
|
26
23
|
}
|
|
27
24
|
get name() {
|
|
28
25
|
if (this.in_.length > 0) {
|
|
29
26
|
// Treat sh:in as a union of the IRIs
|
|
30
27
|
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
31
|
-
return code `${imports.NamedNode}<${this.in_
|
|
28
|
+
return code `${this.reusables.imports.NamedNode}<${this.in_
|
|
32
29
|
.map((iri) => `"${iri.value}"`)
|
|
33
30
|
.join(" | ")}>`;
|
|
34
31
|
}
|
|
35
|
-
return code `${imports.NamedNode}`;
|
|
32
|
+
return code `${this.reusables.imports.NamedNode}`;
|
|
36
33
|
}
|
|
37
34
|
get schemaObject() {
|
|
38
35
|
return {
|
|
39
36
|
...super.schemaObject,
|
|
40
37
|
in: this.in_.length > 0
|
|
41
|
-
? this.in_
|
|
42
|
-
.map((in_) => rdfjsTermExpression(in_, { logger: this.logger }))
|
|
43
|
-
.concat()
|
|
38
|
+
? this.in_.map((in_) => this.rdfjsTermExpression(in_)).concat()
|
|
44
39
|
: undefined,
|
|
45
40
|
};
|
|
46
41
|
}
|
|
47
42
|
fromJsonExpression({ variables, }) {
|
|
48
|
-
return code `${imports.dataFactory}.namedNode(${variables.value}["@id"])`;
|
|
43
|
+
return code `${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"])`;
|
|
49
44
|
}
|
|
50
45
|
jsonType(parameters) {
|
|
51
46
|
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
@@ -63,15 +58,15 @@ export class IriType extends AbstractIdentifierType {
|
|
|
63
58
|
if (this.in_.length > 0) {
|
|
64
59
|
// Treat sh:in as a union of the IRIs
|
|
65
60
|
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
66
|
-
idSchema = code `${imports.z}.enum(${arrayOf(...this.in_.map((iri) => iri.value))})`;
|
|
61
|
+
idSchema = code `${this.reusables.imports.z}.enum(${arrayOf(...this.in_.map((iri) => iri.value))})`;
|
|
67
62
|
}
|
|
68
63
|
else {
|
|
69
|
-
idSchema = code `${imports.z}.string().min(1)`;
|
|
64
|
+
idSchema = code `${this.reusables.imports.z}.string().min(1)`;
|
|
70
65
|
}
|
|
71
66
|
const discriminantProperty = includeDiscriminantProperty
|
|
72
|
-
? code `, termType: ${imports.z}.literal("NamedNode")`
|
|
67
|
+
? code `, termType: ${this.reusables.imports.z}.literal("NamedNode")`
|
|
73
68
|
: "";
|
|
74
|
-
return code `${imports.z}.object({ "@id": ${idSchema}${discriminantProperty} })`;
|
|
69
|
+
return code `${this.reusables.imports.z}.object({ "@id": ${idSchema}${discriminantProperty} })`;
|
|
75
70
|
}
|
|
76
71
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
77
72
|
const discriminantProperty = includeDiscriminantProperty
|
|
@@ -83,7 +78,7 @@ export class IriType extends AbstractIdentifierType {
|
|
|
83
78
|
return {
|
|
84
79
|
...super.fromRdfExpressionChain({ variables }),
|
|
85
80
|
valueTo: code `chain(values => values.chainMap(value => value.toIri(${this.in_.length > 0
|
|
86
|
-
? code `[${joinCode(this.in_.map((in_) => rdfjsTermExpression(in_
|
|
81
|
+
? code `[${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}]`
|
|
87
82
|
: ""})))`,
|
|
88
83
|
};
|
|
89
84
|
}
|
|
@@ -3,27 +3,27 @@ import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
|
3
3
|
import type { OptionType } from "./OptionType.js";
|
|
4
4
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
5
5
|
type Super = AbstractLazyObjectType<OptionType<AbstractLazyObjectType.ObjectTypeConstraint>, OptionType<AbstractLazyObjectType.ObjectTypeConstraint>>;
|
|
6
|
-
declare const Super: (abstract new ({ partialType, resolveType,
|
|
6
|
+
declare const Super: (abstract new ({ partialType, resolveType, ...superParameters }: {
|
|
7
7
|
partialType: OptionType<AbstractLazyObjectType.ObjectTypeConstraint>;
|
|
8
8
|
resolveType: OptionType<AbstractLazyObjectType.ObjectTypeConstraint>;
|
|
9
|
-
runtimeClass: {
|
|
10
|
-
readonly name: Code;
|
|
11
|
-
readonly partialPropertyName: string;
|
|
12
|
-
readonly rawName: Code;
|
|
13
|
-
};
|
|
14
9
|
} & {
|
|
15
10
|
comment: Maybe<string>;
|
|
16
11
|
label: Maybe<string>;
|
|
17
12
|
logger: import("ts-log").Logger;
|
|
13
|
+
reusables: import("./Reusables.js").Reusables;
|
|
18
14
|
}) => AbstractLazyObjectType<OptionType<AbstractLazyObjectType.ObjectTypeConstraint>, OptionType<AbstractLazyObjectType.ObjectTypeConstraint>>) & {
|
|
19
15
|
readonly GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
|
|
20
16
|
readonly JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
|
|
21
17
|
};
|
|
22
18
|
export declare class LazyObjectOptionType extends Super {
|
|
23
|
-
readonly kind = "LazyObjectOptionType";
|
|
24
19
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
25
|
-
|
|
20
|
+
readonly kind = "LazyObjectOptionType";
|
|
26
21
|
get conversions(): readonly AbstractLazyObjectType.Conversion[];
|
|
22
|
+
protected get runtimeClass(): {
|
|
23
|
+
name: Code;
|
|
24
|
+
partialPropertyName: string;
|
|
25
|
+
rawName: Code;
|
|
26
|
+
};
|
|
27
27
|
fromJsonExpression(parameters: Parameters<Super["fromJsonExpression"]>[0]): Code;
|
|
28
28
|
fromRdfResourceValuesExpression(parameters: Parameters<Super["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
29
29
|
graphqlResolveExpression({ variables, }: Parameters<Super["graphqlResolveExpression"]>[0]): Code;
|
|
@@ -7,36 +7,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
9
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
10
|
-
import { imports } from "./imports.js";
|
|
11
|
-
import { snippets } from "./snippets.js";
|
|
12
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
13
10
|
import { code } from "./ts-poet-wrapper.js";
|
|
14
11
|
const Super = (AbstractLazyObjectType);
|
|
15
12
|
export class LazyObjectOptionType extends Super {
|
|
16
|
-
kind = "LazyObjectOptionType";
|
|
17
13
|
graphqlArgs = Maybe.empty();
|
|
18
|
-
|
|
19
|
-
super({
|
|
20
|
-
...superParameters,
|
|
21
|
-
partialType,
|
|
22
|
-
resolveType,
|
|
23
|
-
runtimeClass: {
|
|
24
|
-
name: code `${snippets.LazyObjectOption}<${resolveType.itemType.identifierTypeAlias}, ${partialType.itemType.name}, ${resolveType.itemType.name}>`,
|
|
25
|
-
partialPropertyName: "partial",
|
|
26
|
-
rawName: code `${snippets.LazyObjectOption}`,
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
}
|
|
14
|
+
kind = "LazyObjectOptionType";
|
|
30
15
|
get conversions() {
|
|
31
16
|
const conversions = super.conversions.concat();
|
|
32
17
|
if (this.partialType.itemType.kind === "NamedObjectType") {
|
|
33
18
|
conversions.push({
|
|
34
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}.map(${this.partialType.itemType.name}
|
|
35
|
-
sourceTypeCheckExpression: (value) => code `${imports.Maybe}.isMaybe(${value})`,
|
|
36
|
-
sourceTypeName: code `${imports.Maybe}<${this.resolveType.itemType.name}>`,
|
|
19
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}.map(${this.partialType.itemType.name}.create), resolver: async () => ${this.reusables.imports.Right}((${value} as ${this.reusables.imports.Maybe}<${this.resolveType.itemType.name}>).unsafeCoerce()) })`,
|
|
20
|
+
sourceTypeCheckExpression: (value) => code `${this.reusables.imports.Maybe}.isMaybe(${value})`,
|
|
21
|
+
sourceTypeName: code `${this.reusables.imports.Maybe}<${this.resolveType.itemType.name}>`,
|
|
37
22
|
sourceTypeof: "object",
|
|
38
23
|
}, {
|
|
39
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${imports.Maybe}.of(${this.partialType.itemType.name}
|
|
24
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.reusables.imports.Maybe}.of(${this.partialType.itemType.name}.create(${value})), resolver: async () => ${this.reusables.imports.Right}(${value} as ${this.resolveType.itemType.name}) })`,
|
|
40
25
|
// Don't check instanceof value since the NamedObjectUnionType may be an interface
|
|
41
26
|
// Rely on the fact that this will be the last type check on an object
|
|
42
27
|
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
@@ -50,12 +35,12 @@ export class LazyObjectOptionType extends Super {
|
|
|
50
35
|
this.partialType.itemType.members.length) {
|
|
51
36
|
const maybeMap = code `.map(object => { ${this.resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType: this.resolveType.itemType, partialNamedObjectUnionType: this.partialType.itemType, variables: { resolvedObjectUnion: code `object` } })} })`;
|
|
52
37
|
conversions.push({
|
|
53
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}${maybeMap}, resolver: async () => ${imports.Right}((${value} as ${imports.Maybe}<${this.resolveType.itemType.name}>).unsafeCoerce()) })`,
|
|
54
|
-
sourceTypeCheckExpression: (value) => code `${imports.Maybe}.isMaybe(${value})`,
|
|
55
|
-
sourceTypeName: code `${imports.Maybe}<${this.resolveType.itemType.name}>`,
|
|
38
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}${maybeMap}, resolver: async () => ${this.reusables.imports.Right}((${value} as ${this.reusables.imports.Maybe}<${this.resolveType.itemType.name}>).unsafeCoerce()) })`,
|
|
39
|
+
sourceTypeCheckExpression: (value) => code `${this.reusables.imports.Maybe}.isMaybe(${value})`,
|
|
40
|
+
sourceTypeName: code `${this.reusables.imports.Maybe}<${this.resolveType.itemType.name}>`,
|
|
56
41
|
sourceTypeof: "object",
|
|
57
42
|
}, {
|
|
58
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${imports.Maybe}.of(${value})${maybeMap}, resolver: async () => ${imports.Right}(${value} as ${this.resolveType.itemType.name}) })`,
|
|
43
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.reusables.imports.Maybe}.of(${value})${maybeMap}, resolver: async () => ${this.reusables.imports.Right}(${value} as ${this.resolveType.itemType.name}) })`,
|
|
59
44
|
// Don't check instanceof value since the NamedObjectUnionType may be an interface
|
|
60
45
|
// Rely on the fact that this will be the last type check on an object
|
|
61
46
|
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
@@ -64,15 +49,22 @@ export class LazyObjectOptionType extends Super {
|
|
|
64
49
|
});
|
|
65
50
|
}
|
|
66
51
|
conversions.push({
|
|
67
|
-
conversionExpression: () => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${imports.Maybe}.empty(), resolver: async () => { throw new Error("should never be called"); } })`,
|
|
52
|
+
conversionExpression: () => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.reusables.imports.Maybe}.empty(), resolver: async () => { throw new Error("should never be called"); } })`,
|
|
68
53
|
sourceTypeCheckExpression: (value) => code `${value} === undefined`,
|
|
69
54
|
sourceTypeName: code `undefined`,
|
|
70
55
|
sourceTypeof: "undefined",
|
|
71
56
|
});
|
|
72
57
|
return conversions;
|
|
73
58
|
}
|
|
59
|
+
get runtimeClass() {
|
|
60
|
+
return {
|
|
61
|
+
name: code `${this.reusables.snippets.LazyObjectOption}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.name}, ${this.resolveType.itemType.name}>`,
|
|
62
|
+
partialPropertyName: "partial",
|
|
63
|
+
rawName: code `${this.reusables.snippets.LazyObjectOption}`,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
74
66
|
fromJsonExpression(parameters) {
|
|
75
|
-
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\`))) })`;
|
|
67
|
+
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\`))) })`;
|
|
76
68
|
}
|
|
77
69
|
fromRdfResourceValuesExpression(parameters) {
|
|
78
70
|
const { variables } = parameters;
|
|
@@ -85,4 +77,7 @@ export class LazyObjectOptionType extends Super {
|
|
|
85
77
|
__decorate([
|
|
86
78
|
Memoize()
|
|
87
79
|
], LazyObjectOptionType.prototype, "conversions", null);
|
|
80
|
+
__decorate([
|
|
81
|
+
Memoize()
|
|
82
|
+
], LazyObjectOptionType.prototype, "runtimeClass", null);
|
|
88
83
|
//# sourceMappingURL=LazyObjectOptionType.js.map
|
|
@@ -4,8 +4,12 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
4
4
|
export declare class LazyObjectSetType extends AbstractLazyObjectType<SetType<AbstractLazyObjectType.ObjectTypeConstraint>, SetType<AbstractLazyObjectType.ObjectTypeConstraint>> {
|
|
5
5
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
6
6
|
readonly kind = "LazyObjectSetType";
|
|
7
|
-
constructor({ partialType, resolveType, ...superParameters }: Omit<ConstructorParameters<typeof AbstractLazyObjectType<SetType<AbstractLazyObjectType.ObjectTypeConstraint>, SetType<AbstractLazyObjectType.ObjectTypeConstraint>>>[0], "runtimeClass">);
|
|
8
7
|
get conversions(): readonly AbstractLazyObjectType.Conversion[];
|
|
8
|
+
protected get runtimeClass(): {
|
|
9
|
+
name: Code;
|
|
10
|
+
partialPropertyName: string;
|
|
11
|
+
rawName: Code;
|
|
12
|
+
};
|
|
9
13
|
fromJsonExpression(parameters: Parameters<Super["fromJsonExpression"]>[0]): Code;
|
|
10
14
|
fromRdfResourceValuesExpression(parameters: Parameters<Super["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
11
15
|
graphqlResolveExpression({ variables, }: Parameters<Super["graphqlResolveExpression"]>[0]): Code;
|
|
@@ -7,37 +7,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
9
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
10
|
-
import { imports } from "./imports.js";
|
|
11
|
-
import { snippets } from "./snippets.js";
|
|
12
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
13
10
|
import { code } from "./ts-poet-wrapper.js";
|
|
14
11
|
export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
15
12
|
graphqlArgs = Maybe.of({
|
|
16
13
|
limit: {
|
|
17
|
-
type: code `${imports.GraphQLInt}`,
|
|
14
|
+
type: code `${this.reusables.imports.GraphQLInt}`,
|
|
18
15
|
},
|
|
19
16
|
offset: {
|
|
20
|
-
type: code `${imports.GraphQLInt}`,
|
|
17
|
+
type: code `${this.reusables.imports.GraphQLInt}`,
|
|
21
18
|
},
|
|
22
19
|
});
|
|
23
20
|
kind = "LazyObjectSetType";
|
|
24
|
-
constructor({ partialType, resolveType, ...superParameters }) {
|
|
25
|
-
super({
|
|
26
|
-
...superParameters,
|
|
27
|
-
partialType,
|
|
28
|
-
resolveType,
|
|
29
|
-
runtimeClass: {
|
|
30
|
-
name: code `${snippets.LazyObjectSet}<${resolveType.itemType.identifierTypeAlias}, ${partialType.itemType.name}, ${resolveType.itemType.name}>`,
|
|
31
|
-
partialPropertyName: "partials",
|
|
32
|
-
rawName: code `${snippets.LazyObjectSet}`,
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
21
|
get conversions() {
|
|
37
22
|
const conversions = super.conversions.concat();
|
|
38
23
|
if (this.partialType.itemType.kind === "NamedObjectType") {
|
|
39
24
|
conversions.push({
|
|
40
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}.map(${this.partialType.itemType.name}
|
|
25
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}.map(${this.partialType.itemType.name}.create), resolver: async () => ${this.reusables.imports.Right}(${value} as readonly ${this.resolveType.itemType.name}[]) })`,
|
|
41
26
|
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
42
27
|
sourceTypeName: code `readonly ${this.resolveType.itemType.name}[]`,
|
|
43
28
|
sourceTypeof: "object",
|
|
@@ -48,7 +33,7 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
48
33
|
this.resolveType.itemType.members.length ===
|
|
49
34
|
this.partialType.itemType.members.length) {
|
|
50
35
|
conversions.push({
|
|
51
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}.map(object => { ${this.resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType: this.resolveType.itemType, partialNamedObjectUnionType: this.partialType.itemType, variables: { resolvedObjectUnion: code `object` } })} }), resolver: async () => ${imports.Right}(${value} as readonly ${this.resolveType.itemType.name}[]) })`,
|
|
36
|
+
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}.map(object => { ${this.resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType: this.resolveType.itemType, partialNamedObjectUnionType: this.partialType.itemType, variables: { resolvedObjectUnion: code `object` } })} }), resolver: async () => ${this.reusables.imports.Right}(${value} as readonly ${this.resolveType.itemType.name}[]) })`,
|
|
52
37
|
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
53
38
|
sourceTypeName: code `readonly ${this.resolveType.itemType.name}[]`,
|
|
54
39
|
sourceTypeof: "object",
|
|
@@ -62,8 +47,15 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
62
47
|
});
|
|
63
48
|
return conversions;
|
|
64
49
|
}
|
|
50
|
+
get runtimeClass() {
|
|
51
|
+
return {
|
|
52
|
+
name: code `${this.reusables.snippets.LazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.name}, ${this.resolveType.itemType.name}>`,
|
|
53
|
+
partialPropertyName: "partials",
|
|
54
|
+
rawName: code `${this.reusables.snippets.LazyObjectSet}`,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
65
57
|
fromJsonExpression(parameters) {
|
|
66
|
-
return code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.partialType.fromJsonExpression(parameters)}, resolver: () => Promise.resolve(${imports.Left}(new Error("unable to resolve identifiers deserialized from JSON"))) })`;
|
|
58
|
+
return code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.partialType.fromJsonExpression(parameters)}, resolver: () => Promise.resolve(${this.reusables.imports.Left}(new Error("unable to resolve identifiers deserialized from JSON"))) })`;
|
|
67
59
|
}
|
|
68
60
|
fromRdfResourceValuesExpression(parameters) {
|
|
69
61
|
const { variables } = parameters;
|
|
@@ -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
|