@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
|
@@ -4,11 +4,11 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
4
4
|
export declare class StringType extends AbstractPrimitiveType<string> {
|
|
5
5
|
readonly filterFunction: Code;
|
|
6
6
|
readonly filterType: Code;
|
|
7
|
-
readonly graphqlType: import("./AbstractType.js").AbstractType.GraphqlType;
|
|
8
7
|
readonly kind = "StringType";
|
|
9
8
|
readonly schemaType: Code;
|
|
10
|
-
readonly valueSparqlWherePatternsFunction: Code;
|
|
11
9
|
readonly typeofs: NonEmptyList<"string">;
|
|
10
|
+
readonly valueSparqlWherePatternsFunction: Code;
|
|
11
|
+
get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
|
|
12
12
|
get name(): string;
|
|
13
13
|
protected get schemaObject(): {
|
|
14
14
|
in: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
@@ -8,18 +8,17 @@ import { xsd } from "@tpluscode/rdf-ns-builders";
|
|
|
8
8
|
import { NonEmptyList } from "purify-ts";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
11
|
-
import { imports } from "./imports.js";
|
|
12
|
-
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
13
|
-
import { snippets } from "./snippets.js";
|
|
14
11
|
import { arrayOf, code, literalOf } from "./ts-poet-wrapper.js";
|
|
15
12
|
export class StringType extends AbstractPrimitiveType {
|
|
16
|
-
filterFunction = code `${snippets.filterString}`;
|
|
17
|
-
filterType = code `${snippets.StringFilter}`;
|
|
18
|
-
graphqlType = new AbstractPrimitiveType.GraphqlType(code `${imports.GraphQLString}`);
|
|
13
|
+
filterFunction = code `${this.reusables.snippets.filterString}`;
|
|
14
|
+
filterType = code `${this.reusables.snippets.StringFilter}`;
|
|
19
15
|
kind = "StringType";
|
|
20
|
-
schemaType = code `${snippets.StringSchema}`;
|
|
21
|
-
valueSparqlWherePatternsFunction = code `${snippets.stringSparqlWherePatterns}`;
|
|
16
|
+
schemaType = code `${this.reusables.snippets.StringSchema}`;
|
|
22
17
|
typeofs = NonEmptyList(["string"]);
|
|
18
|
+
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.stringSparqlWherePatterns}`;
|
|
19
|
+
get graphqlType() {
|
|
20
|
+
return new AbstractPrimitiveType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
|
|
21
|
+
}
|
|
23
22
|
get name() {
|
|
24
23
|
if (this.primitiveIn.length > 0) {
|
|
25
24
|
return `${this.primitiveIn.map((value) => `"${value}"`).join(" | ")}`;
|
|
@@ -40,15 +39,15 @@ export class StringType extends AbstractPrimitiveType {
|
|
|
40
39
|
jsonSchema(_parameters) {
|
|
41
40
|
switch (this.primitiveIn.length) {
|
|
42
41
|
case 0:
|
|
43
|
-
return code `${imports.z}.string()`;
|
|
42
|
+
return code `${this.reusables.imports.z}.string()`;
|
|
44
43
|
case 1:
|
|
45
|
-
return code `${imports.z}.literal(${this.primitiveIn[0]})`;
|
|
44
|
+
return code `${this.reusables.imports.z}.literal(${this.primitiveIn[0]})`;
|
|
46
45
|
default:
|
|
47
|
-
return code `${imports.z}.enum(${arrayOf(...this.primitiveIn)})`;
|
|
46
|
+
return code `${this.reusables.imports.z}.enum(${arrayOf(...this.primitiveIn)})`;
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
toRdfResourceValuesExpression({ variables, }) {
|
|
51
|
-
return code `[${snippets.literalFactory}.string(${variables.value}${!this.datatype.equals(xsd.string) ? `, ${rdfjsTermExpression(this.datatype
|
|
50
|
+
return code `[${this.reusables.snippets.literalFactory}.string(${variables.value}${!this.datatype.equals(xsd.string) ? `, ${this.rdfjsTermExpression(this.datatype)}` : ""})]`;
|
|
52
51
|
}
|
|
53
52
|
fromRdfExpressionChain({ variables, }) {
|
|
54
53
|
return {
|
|
@@ -57,6 +56,9 @@ export class StringType extends AbstractPrimitiveType {
|
|
|
57
56
|
};
|
|
58
57
|
}
|
|
59
58
|
}
|
|
59
|
+
__decorate([
|
|
60
|
+
Memoize()
|
|
61
|
+
], StringType.prototype, "graphqlType", null);
|
|
60
62
|
__decorate([
|
|
61
63
|
Memoize()
|
|
62
64
|
], StringType.prototype, "name", null);
|
|
@@ -9,17 +9,14 @@ import { xsd } from "@tpluscode/rdf-ns-builders";
|
|
|
9
9
|
import { invariant } from "ts-invariant";
|
|
10
10
|
import { Memoize } from "typescript-memoize";
|
|
11
11
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
12
|
-
import { imports } from "./imports.js";
|
|
13
|
-
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
14
|
-
import { snippets } from "./snippets.js";
|
|
15
12
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
16
13
|
export class TermType extends AbstractTermType {
|
|
17
|
-
filterFunction = code `${snippets.filterTerm}`;
|
|
18
|
-
filterType = code `${snippets.TermFilter}`;
|
|
14
|
+
filterFunction = code `${this.reusables.snippets.filterTerm}`;
|
|
15
|
+
filterType = code `${this.reusables.snippets.TermFilter}`;
|
|
19
16
|
kind = "TermType";
|
|
20
17
|
nodeKinds;
|
|
21
|
-
schemaType = code `${snippets.TermSchema}`;
|
|
22
|
-
valueSparqlWherePatternsFunction = code `${snippets.termSparqlWherePatterns}`;
|
|
18
|
+
schemaType = code `${this.reusables.snippets.TermSchema}`;
|
|
19
|
+
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.termSparqlWherePatterns}`;
|
|
23
20
|
constructor({ nodeKinds, ...superParameters }) {
|
|
24
21
|
super(superParameters);
|
|
25
22
|
this.nodeKinds = nodeKinds;
|
|
@@ -34,11 +31,11 @@ export class TermType extends AbstractTermType {
|
|
|
34
31
|
.map((nodeKind) => {
|
|
35
32
|
switch (nodeKind) {
|
|
36
33
|
case "BlankNode":
|
|
37
|
-
return imports.BlankNode;
|
|
34
|
+
return this.reusables.imports.BlankNode;
|
|
38
35
|
case "IRI":
|
|
39
|
-
return imports.NamedNode;
|
|
36
|
+
return this.reusables.imports.NamedNode;
|
|
40
37
|
case "Literal":
|
|
41
|
-
return imports.Literal;
|
|
38
|
+
return this.reusables.imports.Literal;
|
|
42
39
|
default:
|
|
43
40
|
nodeKind;
|
|
44
41
|
throw new RangeError(nodeKind);
|
|
@@ -50,7 +47,7 @@ export class TermType extends AbstractTermType {
|
|
|
50
47
|
return {
|
|
51
48
|
...super.schemaObject,
|
|
52
49
|
in: this.in_.length > 0
|
|
53
|
-
? this.in_.map((in_) => rdfjsTermExpression(in_
|
|
50
|
+
? this.in_.map((in_) => this.rdfjsTermExpression(in_))
|
|
54
51
|
: undefined,
|
|
55
52
|
};
|
|
56
53
|
}
|
|
@@ -59,13 +56,13 @@ export class TermType extends AbstractTermType {
|
|
|
59
56
|
let valueToNodeKind;
|
|
60
57
|
switch (nodeKind) {
|
|
61
58
|
case "BlankNode":
|
|
62
|
-
valueToNodeKind = code `${imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2))`;
|
|
59
|
+
valueToNodeKind = code `${this.reusables.imports.dataFactory}.blankNode(${variables.value}["@id"].substring(2))`;
|
|
63
60
|
break;
|
|
64
61
|
case "IRI":
|
|
65
|
-
valueToNodeKind = code `${imports.dataFactory}.namedNode(${variables.value}["@id"])`;
|
|
62
|
+
valueToNodeKind = code `${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"])`;
|
|
66
63
|
break;
|
|
67
64
|
case "Literal":
|
|
68
|
-
valueToNodeKind = code `${imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined))`;
|
|
65
|
+
valueToNodeKind = code `${this.reusables.imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined))`;
|
|
69
66
|
break;
|
|
70
67
|
default:
|
|
71
68
|
throw new RangeError(nodeKind);
|
|
@@ -85,13 +82,13 @@ export class TermType extends AbstractTermType {
|
|
|
85
82
|
.join(" | ")} } | { readonly "@language"?: string, readonly "@type"?: string, readonly "@value": string, readonly termType: "Literal" }`);
|
|
86
83
|
}
|
|
87
84
|
jsonSchema(_parameters) {
|
|
88
|
-
return code `${imports.z}.discriminatedUnion("termType", [${joinCode([...this.nodeKinds].map((nodeKind) => {
|
|
85
|
+
return code `${this.reusables.imports.z}.discriminatedUnion("termType", [${joinCode([...this.nodeKinds].map((nodeKind) => {
|
|
89
86
|
switch (nodeKind) {
|
|
90
87
|
case "BlankNode":
|
|
91
88
|
case "IRI":
|
|
92
|
-
return code `${imports.z}.object({ "@id": ${imports.z}.string().min(1), termType: ${imports.z}.literal("${NodeKind.toTermType(nodeKind)}") })`;
|
|
89
|
+
return code `${this.reusables.imports.z}.object({ "@id": ${this.reusables.imports.z}.string().min(1), termType: ${this.reusables.imports.z}.literal("${NodeKind.toTermType(nodeKind)}") })`;
|
|
93
90
|
case "Literal":
|
|
94
|
-
return code `${imports.z}.object({ "@language": ${imports.z}.string().optional(), "@type": ${imports.z}.string().optional(), "@value": ${imports.z}.string(), termType: ${imports.z}.literal("Literal") })`;
|
|
91
|
+
return code `${this.reusables.imports.z}.object({ "@language": ${this.reusables.imports.z}.string().optional(), "@type": ${this.reusables.imports.z}.string().optional(), "@value": ${this.reusables.imports.z}.string(), termType: ${this.reusables.imports.z}.literal("Literal") })`;
|
|
95
92
|
default:
|
|
96
93
|
throw new RangeError(nodeKind);
|
|
97
94
|
}
|
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import type { Logger } from "ts-log";
|
|
2
2
|
import * as ast from "../../ast/index.js";
|
|
3
3
|
import type { Generator } from "../Generator.js";
|
|
4
|
+
import { Reusables } from "./Reusables.js";
|
|
4
5
|
export declare class TsGenerator implements Generator {
|
|
5
|
-
private readonly logger;
|
|
6
6
|
private readonly typeFactory;
|
|
7
|
+
protected readonly logger: Logger;
|
|
8
|
+
protected readonly reusables: Reusables;
|
|
7
9
|
constructor({ logger }: {
|
|
8
10
|
logger: Logger;
|
|
9
11
|
});
|
|
10
12
|
generate(ast_: ast.Ast): string;
|
|
13
|
+
/**
|
|
14
|
+
* Synthesize the $Object union.
|
|
15
|
+
*/
|
|
16
|
+
private synthesizeUberObjectUnionType;
|
|
11
17
|
}
|
|
12
18
|
//# sourceMappingURL=TsGenerator.d.ts.map
|
|
@@ -1,20 +1,35 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { invariant } from "ts-invariant";
|
|
1
3
|
import * as ast from "../../ast/index.js";
|
|
4
|
+
import { BlankNodeType } from "./BlankNodeType.js";
|
|
2
5
|
import { graphqlSchemaVariableStatement } from "./graphqlSchemaVariableStatement.js";
|
|
6
|
+
import { IdentifierType } from "./IdentifierType.js";
|
|
7
|
+
import { IriType } from "./IriType.js";
|
|
8
|
+
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
3
9
|
import { objectSetDeclarations } from "./objectSetDeclarations.js";
|
|
4
|
-
import {
|
|
5
|
-
import { synthesizeUberObjectUnionType } from "./synthesizeUberObjectUnionType.js";
|
|
10
|
+
import { Reusables } from "./Reusables.js";
|
|
6
11
|
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
7
12
|
import { TypeFactory } from "./TypeFactory.js";
|
|
8
13
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
9
14
|
export class TsGenerator {
|
|
10
|
-
logger;
|
|
11
15
|
typeFactory;
|
|
16
|
+
logger;
|
|
17
|
+
reusables;
|
|
12
18
|
constructor({ logger }) {
|
|
13
19
|
this.logger = logger;
|
|
14
|
-
this.
|
|
20
|
+
this.reusables = new Reusables({ logger });
|
|
21
|
+
this.typeFactory = new TypeFactory({
|
|
22
|
+
logger,
|
|
23
|
+
reusables: this.reusables,
|
|
24
|
+
});
|
|
15
25
|
}
|
|
16
26
|
generate(ast_) {
|
|
17
27
|
let declarations = [];
|
|
28
|
+
for (const namedObjectType of ast_.namedObjectTypes) {
|
|
29
|
+
for (const tsImport of namedObjectType.tsImports) {
|
|
30
|
+
declarations.push(code `${tsImport}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
18
33
|
for (const astNamedUnionType of ast_.namedUnionTypes) {
|
|
19
34
|
if (astNamedUnionType.isObjectUnionType()) {
|
|
20
35
|
continue;
|
|
@@ -40,26 +55,87 @@ export class TsGenerator {
|
|
|
40
55
|
declarations.push(code `type ${syntheticNamePrefix}Object = ${namedObjectTypesNameSorted[0].name};`);
|
|
41
56
|
break;
|
|
42
57
|
default: {
|
|
43
|
-
const uberObjectUnionType = synthesizeUberObjectUnionType(
|
|
44
|
-
logger: this.logger,
|
|
45
|
-
namedObjectTypes: namedObjectTypesToposorted.toReversed(), // Reverse topological order so children ane before parents
|
|
46
|
-
});
|
|
58
|
+
const uberObjectUnionType = this.synthesizeUberObjectUnionType(namedObjectTypesToposorted.toReversed());
|
|
47
59
|
declarations = declarations.concat(uberObjectUnionType.declaration.toList());
|
|
48
60
|
namedObjectUnionTypesNameSorted.push(uberObjectUnionType);
|
|
49
61
|
}
|
|
50
62
|
}
|
|
51
|
-
declarations.push(...objectSetDeclarations({
|
|
63
|
+
declarations.push(...objectSetDeclarations.call(this, {
|
|
52
64
|
namedObjectTypes: namedObjectTypesNameSorted,
|
|
53
65
|
namedObjectUnionTypes: namedObjectUnionTypesNameSorted,
|
|
54
66
|
}));
|
|
55
|
-
declarations.push(...graphqlSchemaVariableStatement
|
|
67
|
+
declarations.push(...graphqlSchemaVariableStatement
|
|
68
|
+
.call(this, {
|
|
56
69
|
namedObjectTypes: namedObjectTypesNameSorted,
|
|
57
70
|
namedObjectUnionTypes: namedObjectUnionTypesNameSorted,
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
.map((snippet) => code `${snippet.ifUsed}`), { on: "\n\n" }));
|
|
71
|
+
})
|
|
72
|
+
.toList());
|
|
73
|
+
declarations.splice(0, 0, joinCode(this.reusables.snippets.ifUsed, { on: "\n\n" }));
|
|
62
74
|
return joinCode(declarations).toString({});
|
|
63
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Synthesize the $Object union.
|
|
78
|
+
*/
|
|
79
|
+
synthesizeUberObjectUnionType(namedObjectTypes) {
|
|
80
|
+
const filteredNamedObjectTypes = namedObjectTypes.filter((namedObjectType) => !namedObjectType.extern);
|
|
81
|
+
invariant(filteredNamedObjectTypes.length > 0);
|
|
82
|
+
const nodeKinds = filteredNamedObjectTypes.reduce((nodeKinds, namedObjectType) => {
|
|
83
|
+
for (const nodeKind of namedObjectType.identifierType.nodeKinds) {
|
|
84
|
+
nodeKinds.add(nodeKind);
|
|
85
|
+
}
|
|
86
|
+
return nodeKinds;
|
|
87
|
+
}, new Set());
|
|
88
|
+
let identifierType;
|
|
89
|
+
if (nodeKinds.size === 2) {
|
|
90
|
+
identifierType = new IdentifierType({
|
|
91
|
+
comment: Maybe.empty(),
|
|
92
|
+
label: Maybe.empty(),
|
|
93
|
+
logger: this.logger,
|
|
94
|
+
reusables: this.reusables,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
switch ([...nodeKinds][0]) {
|
|
99
|
+
case "BlankNode":
|
|
100
|
+
identifierType = new BlankNodeType({
|
|
101
|
+
comment: Maybe.empty(),
|
|
102
|
+
label: Maybe.empty(),
|
|
103
|
+
logger: this.logger,
|
|
104
|
+
reusables: this.reusables,
|
|
105
|
+
});
|
|
106
|
+
break;
|
|
107
|
+
case "IRI":
|
|
108
|
+
identifierType = new IriType({
|
|
109
|
+
comment: Maybe.empty(),
|
|
110
|
+
hasValues: [],
|
|
111
|
+
in_: [],
|
|
112
|
+
label: Maybe.empty(),
|
|
113
|
+
logger: this.logger,
|
|
114
|
+
reusables: this.reusables,
|
|
115
|
+
});
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return new NamedObjectUnionType({
|
|
120
|
+
comment: Maybe.empty(),
|
|
121
|
+
features: filteredNamedObjectTypes.reduce((features, namedObjectType) => {
|
|
122
|
+
for (const feature of namedObjectType.features) {
|
|
123
|
+
features.add(feature);
|
|
124
|
+
}
|
|
125
|
+
features.delete("graphql");
|
|
126
|
+
return features;
|
|
127
|
+
}, new Set()),
|
|
128
|
+
identifierType,
|
|
129
|
+
label: Maybe.empty(),
|
|
130
|
+
logger: this.logger,
|
|
131
|
+
members: filteredNamedObjectTypes.map((namedObjectType) => ({
|
|
132
|
+
discriminantValue: Maybe.empty(),
|
|
133
|
+
type: namedObjectType,
|
|
134
|
+
})),
|
|
135
|
+
name: `${syntheticNamePrefix}Object`,
|
|
136
|
+
recursive: false,
|
|
137
|
+
reusables: this.reusables,
|
|
138
|
+
});
|
|
139
|
+
}
|
|
64
140
|
}
|
|
65
141
|
//# sourceMappingURL=TsGenerator.js.map
|
|
@@ -5,14 +5,17 @@ import { AnonymousUnionType } from "./AnonymousUnionType.js";
|
|
|
5
5
|
import { NamedObjectType } from "./NamedObjectType.js";
|
|
6
6
|
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
7
7
|
import { NamedUnionType } from "./NamedUnionType.js";
|
|
8
|
+
import type { Reusables } from "./Reusables.js";
|
|
8
9
|
import type { Type } from "./Type.js";
|
|
9
10
|
export declare class TypeFactory {
|
|
10
11
|
private cachedNamedObjectUnionTypesByShapeIdentifier;
|
|
11
12
|
private cachedObjectTypePropertiesByShapeIdentifier;
|
|
12
13
|
private cachedObjectTypesByShapeIdentifier;
|
|
13
14
|
private readonly logger;
|
|
14
|
-
|
|
15
|
+
private readonly reusables;
|
|
16
|
+
constructor({ logger, reusables }: {
|
|
15
17
|
logger: Logger;
|
|
18
|
+
reusables: Reusables;
|
|
16
19
|
});
|
|
17
20
|
createNamedObjectUnionType(astType: ast.ObjectUnionType): NamedObjectUnionType;
|
|
18
21
|
createNamedObjectType(astType: ast.ObjectType): NamedObjectType;
|
|
@@ -38,8 +38,10 @@ export class TypeFactory {
|
|
|
38
38
|
cachedObjectTypePropertiesByShapeIdentifier = new TermMap();
|
|
39
39
|
cachedObjectTypesByShapeIdentifier = new TermMap();
|
|
40
40
|
logger;
|
|
41
|
-
|
|
41
|
+
reusables;
|
|
42
|
+
constructor({ logger, reusables }) {
|
|
42
43
|
this.logger = logger;
|
|
44
|
+
this.reusables = reusables;
|
|
43
45
|
}
|
|
44
46
|
createNamedObjectUnionType(astType) {
|
|
45
47
|
{
|
|
@@ -60,6 +62,7 @@ export class TypeFactory {
|
|
|
60
62
|
})),
|
|
61
63
|
name: tsName(astType.name.unsafeCoerce()),
|
|
62
64
|
recursive: astType.recursive,
|
|
65
|
+
reusables: this.reusables,
|
|
63
66
|
});
|
|
64
67
|
this.cachedNamedObjectUnionTypesByShapeIdentifier.set(astType.shapeIdentifier, namedObjectUnionType);
|
|
65
68
|
return namedObjectUnionType;
|
|
@@ -81,7 +84,6 @@ export class TypeFactory {
|
|
|
81
84
|
features: astType.tsFeatures,
|
|
82
85
|
fromRdfType: astType.fromRdfType,
|
|
83
86
|
identifierType,
|
|
84
|
-
imports: astType.tsImports,
|
|
85
87
|
label: astType.label,
|
|
86
88
|
lazyAncestorObjectTypes: () => astType.ancestorObjectTypes.map((astType) => this.createNamedObjectType(astType)),
|
|
87
89
|
lazyChildObjectTypes: () => astType.childObjectTypes.map((astType) => this.createNamedObjectType(astType)),
|
|
@@ -96,6 +98,7 @@ export class TypeFactory {
|
|
|
96
98
|
logger: this.logger,
|
|
97
99
|
name: `${syntheticNamePrefix}type`,
|
|
98
100
|
namedObjectType,
|
|
101
|
+
reusables: this.reusables,
|
|
99
102
|
type: new NamedObjectType.DiscriminantProperty.Type({
|
|
100
103
|
descendantValues: [...discriminantDescendantValues].sort(),
|
|
101
104
|
mutable: false,
|
|
@@ -124,14 +127,16 @@ export class TypeFactory {
|
|
|
124
127
|
logger: this.logger,
|
|
125
128
|
name: `${syntheticNamePrefix}identifier`,
|
|
126
129
|
namedObjectType,
|
|
130
|
+
reusables: this.reusables,
|
|
127
131
|
type: identifierType,
|
|
128
|
-
typeAlias: code `${name}
|
|
132
|
+
typeAlias: code `${name}.Identifier`,
|
|
129
133
|
}));
|
|
130
134
|
return properties;
|
|
131
135
|
},
|
|
132
136
|
logger: this.logger,
|
|
133
137
|
name,
|
|
134
138
|
recursive: astType.recursive,
|
|
139
|
+
reusables: this.reusables,
|
|
135
140
|
synthetic: astType.synthetic,
|
|
136
141
|
toRdfTypes: astType.toRdfTypes,
|
|
137
142
|
});
|
|
@@ -189,6 +194,7 @@ export class TypeFactory {
|
|
|
189
194
|
})),
|
|
190
195
|
name,
|
|
191
196
|
recursive: astType.recursive,
|
|
197
|
+
reusables: this.reusables,
|
|
192
198
|
}))
|
|
193
199
|
.orDefaultLazy(() => new AnonymousUnionType({
|
|
194
200
|
comment: astType.comment,
|
|
@@ -200,6 +206,7 @@ export class TypeFactory {
|
|
|
200
206
|
type: this.createType(member.type),
|
|
201
207
|
})),
|
|
202
208
|
recursive: astType.recursive,
|
|
209
|
+
reusables: this.reusables,
|
|
203
210
|
}));
|
|
204
211
|
}
|
|
205
212
|
createBlankNodeType(astType) {
|
|
@@ -207,6 +214,7 @@ export class TypeFactory {
|
|
|
207
214
|
comment: astType.comment,
|
|
208
215
|
label: astType.label,
|
|
209
216
|
logger: this.logger,
|
|
217
|
+
reusables: this.reusables,
|
|
210
218
|
});
|
|
211
219
|
}
|
|
212
220
|
createDefaultValueType(astType) {
|
|
@@ -220,6 +228,7 @@ export class TypeFactory {
|
|
|
220
228
|
itemType,
|
|
221
229
|
label: astType.label,
|
|
222
230
|
logger: this.logger,
|
|
231
|
+
reusables: this.reusables,
|
|
223
232
|
});
|
|
224
233
|
}
|
|
225
234
|
createIdentifierType(astType) {
|
|
@@ -231,6 +240,7 @@ export class TypeFactory {
|
|
|
231
240
|
comment: astType.comment,
|
|
232
241
|
label: astType.label,
|
|
233
242
|
logger: this.logger,
|
|
243
|
+
reusables: this.reusables,
|
|
234
244
|
});
|
|
235
245
|
case "IriType":
|
|
236
246
|
return this.createIriType(astType);
|
|
@@ -243,6 +253,7 @@ export class TypeFactory {
|
|
|
243
253
|
in_: astType.in_,
|
|
244
254
|
label: astType.label,
|
|
245
255
|
logger: this.logger,
|
|
256
|
+
reusables: this.reusables,
|
|
246
257
|
});
|
|
247
258
|
}
|
|
248
259
|
createLazyObjectOptionType(astType) {
|
|
@@ -252,6 +263,7 @@ export class TypeFactory {
|
|
|
252
263
|
logger: this.logger,
|
|
253
264
|
partialType: this.createOptionType(astType.partialType),
|
|
254
265
|
resolveType: this.createOptionType(astType.resolveType),
|
|
266
|
+
reusables: this.reusables,
|
|
255
267
|
});
|
|
256
268
|
}
|
|
257
269
|
createLazyObjectSetType(astType) {
|
|
@@ -261,6 +273,7 @@ export class TypeFactory {
|
|
|
261
273
|
logger: this.logger,
|
|
262
274
|
partialType: this.createSetType(astType.partialType),
|
|
263
275
|
resolveType: this.createSetType(astType.resolveType),
|
|
276
|
+
reusables: this.reusables,
|
|
264
277
|
});
|
|
265
278
|
}
|
|
266
279
|
createLazyObjectType(astType) {
|
|
@@ -270,6 +283,7 @@ export class TypeFactory {
|
|
|
270
283
|
logger: this.logger,
|
|
271
284
|
partialType: this.createType(astType.partialType),
|
|
272
285
|
resolveType: this.createType(astType.resolveType),
|
|
286
|
+
reusables: this.reusables,
|
|
273
287
|
});
|
|
274
288
|
}
|
|
275
289
|
createListType(astType) {
|
|
@@ -283,6 +297,7 @@ export class TypeFactory {
|
|
|
283
297
|
logger: this.logger,
|
|
284
298
|
minCount: 0n,
|
|
285
299
|
mutable: astType.mutable,
|
|
300
|
+
reusables: this.reusables,
|
|
286
301
|
toRdfTypes: astType.toRdfTypes,
|
|
287
302
|
});
|
|
288
303
|
}
|
|
@@ -317,6 +332,7 @@ export class TypeFactory {
|
|
|
317
332
|
label: astType.label,
|
|
318
333
|
languageIn: [],
|
|
319
334
|
logger: this.logger,
|
|
335
|
+
reusables: this.reusables,
|
|
320
336
|
});
|
|
321
337
|
case "bigint":
|
|
322
338
|
return new BigIntType({
|
|
@@ -328,6 +344,7 @@ export class TypeFactory {
|
|
|
328
344
|
languageIn: [],
|
|
329
345
|
logger: this.logger,
|
|
330
346
|
primitiveIn: astType.in_.map((value) => LiteralDecoder.decodeBigIntLiteral(value).unsafeCoerce()),
|
|
347
|
+
reusables: this.reusables,
|
|
331
348
|
});
|
|
332
349
|
case "boolean":
|
|
333
350
|
return new BooleanType({
|
|
@@ -339,6 +356,7 @@ export class TypeFactory {
|
|
|
339
356
|
in_: astType.in_,
|
|
340
357
|
logger: this.logger,
|
|
341
358
|
primitiveIn: astType.in_.map((value) => LiteralDecoder.decodeBooleanLiteral(value).unsafeCoerce()),
|
|
359
|
+
reusables: this.reusables,
|
|
342
360
|
});
|
|
343
361
|
case "date":
|
|
344
362
|
case "datetime":
|
|
@@ -353,6 +371,7 @@ export class TypeFactory {
|
|
|
353
371
|
primitiveIn: astType.in_.map((value) => (datatypeDefinition.kind === "date"
|
|
354
372
|
? LiteralDecoder.decodeDateLiteral
|
|
355
373
|
: LiteralDecoder.decodeDateTimeLiteral)(value).unsafeCoerce()),
|
|
374
|
+
reusables: this.reusables,
|
|
356
375
|
});
|
|
357
376
|
case "float":
|
|
358
377
|
case "int":
|
|
@@ -367,6 +386,7 @@ export class TypeFactory {
|
|
|
367
386
|
primitiveIn: astType.in_.map((value) => (datatypeDefinition.kind === "float"
|
|
368
387
|
? LiteralDecoder.decodeFloatLiteral
|
|
369
388
|
: LiteralDecoder.decodeIntLiteral)(value).unsafeCoerce()),
|
|
389
|
+
reusables: this.reusables,
|
|
370
390
|
});
|
|
371
391
|
case "string":
|
|
372
392
|
if (!datatype.equals(rdf.langString)) {
|
|
@@ -379,6 +399,7 @@ export class TypeFactory {
|
|
|
379
399
|
languageIn: astType.languageIn,
|
|
380
400
|
logger: this.logger,
|
|
381
401
|
primitiveIn: astType.in_.map((value) => value.value),
|
|
402
|
+
reusables: this.reusables,
|
|
382
403
|
});
|
|
383
404
|
}
|
|
384
405
|
break;
|
|
@@ -404,6 +425,7 @@ export class TypeFactory {
|
|
|
404
425
|
label: astType.label,
|
|
405
426
|
languageIn: astType.languageIn,
|
|
406
427
|
logger: this.logger,
|
|
428
|
+
reusables: this.reusables,
|
|
407
429
|
});
|
|
408
430
|
}
|
|
409
431
|
createObjectTypeProperty({ astObjectTypeProperty, namedObjectType, }) {
|
|
@@ -424,6 +446,7 @@ export class TypeFactory {
|
|
|
424
446
|
name: tsName(astObjectTypeProperty.name),
|
|
425
447
|
path: astObjectTypeProperty.path,
|
|
426
448
|
recursive: !!astObjectTypeProperty.recursive,
|
|
449
|
+
reusables: this.reusables,
|
|
427
450
|
type: this.createType(astObjectTypeProperty.type),
|
|
428
451
|
});
|
|
429
452
|
this.cachedObjectTypePropertiesByShapeIdentifier.set(astObjectTypeProperty.shapeIdentifier, property);
|
|
@@ -437,6 +460,7 @@ export class TypeFactory {
|
|
|
437
460
|
itemType,
|
|
438
461
|
label: astType.label,
|
|
439
462
|
logger: this.logger,
|
|
463
|
+
reusables: this.reusables,
|
|
440
464
|
});
|
|
441
465
|
}
|
|
442
466
|
createSetType(astType) {
|
|
@@ -449,6 +473,7 @@ export class TypeFactory {
|
|
|
449
473
|
logger: this.logger,
|
|
450
474
|
mutable: astType.mutable,
|
|
451
475
|
minCount: astType.minCount,
|
|
476
|
+
reusables: this.reusables,
|
|
452
477
|
});
|
|
453
478
|
}
|
|
454
479
|
createTermType(astType) {
|
|
@@ -459,6 +484,7 @@ export class TypeFactory {
|
|
|
459
484
|
label: astType.label,
|
|
460
485
|
logger: this.logger,
|
|
461
486
|
nodeKinds: astType.nodeKinds,
|
|
487
|
+
reusables: this.reusables,
|
|
462
488
|
});
|
|
463
489
|
}
|
|
464
490
|
}
|
|
@@ -2,6 +2,7 @@ import type { Logger } from "ts-log";
|
|
|
2
2
|
import * as ast from "../../ast/index.js";
|
|
3
3
|
import type { Generator } from "../Generator.js";
|
|
4
4
|
export declare class ZodGenerator implements Generator {
|
|
5
|
+
private readonly reusables;
|
|
5
6
|
private readonly typeFactory;
|
|
6
7
|
constructor({ logger }: {
|
|
7
8
|
logger: Logger;
|
|
@@ -2,14 +2,18 @@ import { invariant } from "ts-invariant";
|
|
|
2
2
|
import * as ast from "../../ast/index.js";
|
|
3
3
|
import { NamedObjectType_jsonSchemaFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js";
|
|
4
4
|
import { NamedObjectType_jsonTypeAliasDeclaration } from "./_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js";
|
|
5
|
-
import {
|
|
6
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
5
|
+
import { Reusables } from "./Reusables.js";
|
|
7
6
|
import { TypeFactory } from "./TypeFactory.js";
|
|
8
7
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
9
8
|
export class ZodGenerator {
|
|
9
|
+
reusables;
|
|
10
10
|
typeFactory;
|
|
11
11
|
constructor({ logger }) {
|
|
12
|
-
this.
|
|
12
|
+
this.reusables = new Reusables({ logger });
|
|
13
|
+
this.typeFactory = new TypeFactory({
|
|
14
|
+
logger,
|
|
15
|
+
reusables: this.reusables,
|
|
16
|
+
});
|
|
13
17
|
}
|
|
14
18
|
generate(ast_) {
|
|
15
19
|
const declarations = [];
|
|
@@ -18,7 +22,7 @@ export class ZodGenerator {
|
|
|
18
22
|
export namespace ${namedObjectType.name} {
|
|
19
23
|
${joinCode(NamedObjectType_jsonTypeAliasDeclaration.bind(namedObjectType)().toList())}
|
|
20
24
|
|
|
21
|
-
export namespace
|
|
25
|
+
export namespace Json {
|
|
22
26
|
${joinCode(NamedObjectType_jsonSchemaFunctionDeclaration.bind(namedObjectType)().toList())}
|
|
23
27
|
}
|
|
24
28
|
}`);
|
|
@@ -28,14 +32,12 @@ export namespace ${namedObjectType.name} {
|
|
|
28
32
|
declarations.push(code `\
|
|
29
33
|
export namespace ${astNamedUnionType.name} {
|
|
30
34
|
${astNamedUnionType.jsonTypeAliasDeclaration}
|
|
31
|
-
export namespace
|
|
35
|
+
export namespace Json {
|
|
32
36
|
${astNamedUnionType.jsonSchemaFunctionDeclaration}
|
|
33
37
|
}
|
|
34
38
|
}`);
|
|
35
39
|
}
|
|
36
|
-
declarations.splice(0, 0, joinCode(
|
|
37
|
-
.sort((left, right) => left.usageSiteName.localeCompare(right.usageSiteName))
|
|
38
|
-
.map((snippet) => code `${snippet.ifUsed}`), { on: "\n\n" }));
|
|
40
|
+
declarations.splice(0, 0, joinCode(this.reusables.snippets.ifUsed, { on: "\n\n" }));
|
|
39
41
|
return joinCode(declarations, { on: "\n\n" }).toString({});
|
|
40
42
|
}
|
|
41
43
|
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import type { Maybe } from "purify-ts";
|
|
2
2
|
import type { Logger } from "ts-log";
|
|
3
3
|
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
4
|
+
import type { Reusables } from "../Reusables.js";
|
|
5
|
+
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
4
6
|
import type { Type } from "../Type.js";
|
|
5
7
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
6
8
|
export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterFunction" | "mutable" | "name" | "schema">> {
|
|
7
9
|
protected readonly logger: Logger;
|
|
8
10
|
protected readonly namedObjectType: NamedObjectType;
|
|
11
|
+
protected readonly reusables: Reusables;
|
|
12
|
+
protected readonly rdfjsTermExpression: (parameters: Parameters<typeof rdfjsTermExpression>[0]) => Code;
|
|
9
13
|
/**
|
|
10
14
|
* Optional property to include in the parameters object of a class constructor.
|
|
11
15
|
*/
|
|
@@ -64,10 +68,11 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
64
68
|
* Property type
|
|
65
69
|
. */
|
|
66
70
|
readonly type: TypeT;
|
|
67
|
-
constructor({ logger, name, namedObjectType, type, }: {
|
|
71
|
+
constructor({ logger, name, namedObjectType, reusables, type, }: {
|
|
68
72
|
logger: Logger;
|
|
69
73
|
name: string;
|
|
70
74
|
namedObjectType: NamedObjectType;
|
|
75
|
+
reusables: Reusables;
|
|
71
76
|
type: TypeT;
|
|
72
77
|
});
|
|
73
78
|
/**
|
|
@@ -96,13 +101,13 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
96
101
|
};
|
|
97
102
|
}): readonly Code[];
|
|
98
103
|
/**
|
|
99
|
-
*
|
|
104
|
+
* Expression to deserialize JSON for this property (as described by toJsonObjectMember) to a typed value of the property.
|
|
100
105
|
*/
|
|
101
|
-
abstract
|
|
106
|
+
abstract fromJsonExpression(parameters: {
|
|
102
107
|
variables: {
|
|
103
108
|
jsonObject: Code;
|
|
104
109
|
};
|
|
105
|
-
}):
|
|
110
|
+
}): Maybe<Code>;
|
|
106
111
|
/**
|
|
107
112
|
* Expression to deserialize this property on the given rdfjsResource.Resource to a Either<Error, this property type>.
|
|
108
113
|
*/
|