Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.53.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.67.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<PackageReference Include="MediatR" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.66.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.78.0" />
<PackageReference Include="Scriban" Version="2.1.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
Expand All @@ -15,7 +15,7 @@
<PackageReference Include="GraphQL.DataLoader" Version="4.6.0" />
<PackageReference Include="MediatR" Version="8.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.66.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.78.0" />
<PackageReference Include="VirtoCommerce.Platform.Security" Version="3.66.0" />
<PackageReference Include="VirtoCommerce.CartModule.Core" Version="3.22.0" />
<PackageReference Include="VirtoCommerce.MarketingModule.Core" Version="3.23.0" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,103 +1,103 @@
using System.Collections.Generic;
using System.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;

namespace VirtoCommerce.ExperienceApiModule.XDigitalCatalog.Index
{
public static class IndexFieldsMapper
{
public class RegexpNameMapper
{
namespace VirtoCommerce.ExperienceApiModule.XDigitalCatalog.Index
{
public static class IndexFieldsMapper
{
public class RegexpNameMapper
{
protected Regex _regex { get; set; }

protected string Replacement { get; set; }
public string[] AdditionalFields { get; set; }

public RegexpNameMapper(string pattern, string replacement, string[] additionalFields = null)
{
_regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
Replacement = replacement;
AdditionalFields = additionalFields;
}

public virtual bool CanMap(string input)

protected string Replacement { get; set; }
public string[] AdditionalFields { get; set; }

public RegexpNameMapper(string pattern, string replacement, string[] additionalFields = null)
{
return _regex.IsMatch(input);
}

public virtual string Map(string input)
{
return _regex.Replace(input, Replacement);
}
}
_regex = new Regex(pattern, RegexOptions.IgnoreCase | RegexOptions.Compiled);
Replacement = replacement;
AdditionalFields = additionalFields;
}

public virtual bool CanMap(string input)
{
return _regex.IsMatch(input);
}

public virtual string Map(string input)
{
return _regex.Replace(input, Replacement);
}
}

private static IList<RegexpNameMapper> _mappers;

public static IList<RegexpNameMapper> Mappers
{
get
{
if (_mappers == null)
{
_mappers = new List<RegexpNameMapper>()
{
new RegexpNameMapper(@".*", "$0", new [] { "__object.id", "__object.categoryId", "__object.catalogId" }),
new RegexpNameMapper(@"(items.)?price[s]?.(?<part>[^\.]+).*$","__prices.$2", new [] { "__prices.currency" }),
new RegexpNameMapper(@"^items.variations", "__variations", new [] { "__variations" }),
new RegexpNameMapper(@"^variations", "__variations", new [] { "__variations" }),
new RegexpNameMapper(@"^items", "__object"),
_mappers = new List<RegexpNameMapper>()
{
new RegexpNameMapper(@".*", "$0", new [] { "__object.id", "__object.categoryId", "__object.catalogId" }),
new RegexpNameMapper(@"(items.)?price[s]?.(?<part>[^\.]+).*$","__prices.$2", new [] { "__prices.currency" }),
new RegexpNameMapper(@"^items.variations", "__variations", new [] { "__variations" }),
new RegexpNameMapper(@"^variations", "__variations", new [] { "__variations" }),
new RegexpNameMapper(@"^items", "__object"),
new RegexpNameMapper(@"^(?!__)", "__object."),

new RegexpNameMapper(@"properties.value$", "properties.values"),
new RegexpNameMapper(@"imgSrc", "images"),

new RegexpNameMapper(@"__object.availabilityData.isActive", "__object.isActive"),
new RegexpNameMapper(@"__object.availabilityData.isBuyable", "__object.isBuyable"),
new RegexpNameMapper(@"__object.availabilityData.trackInventory", "__object.trackInventory"),

new RegexpNameMapper(@"__object.parent.*", "__object.parentId"),
new RegexpNameMapper(@"__object.hasParent.*", "__object.parentId"),
new RegexpNameMapper(@"__object.parent.*", "__object.parentId"),

new RegexpNameMapper(@"__object.category.*", "__object.categoryId"),
new RegexpNameMapper(@"__object.descriptions", "__object.reviews"),
new RegexpNameMapper(@"__object.description.*", "__object.reviews"),
new RegexpNameMapper(@"properties.value$", "properties.values"),
new RegexpNameMapper(@"imgSrc", "images"),
new RegexpNameMapper(@"__object.availabilityData.isActive", "__object.isActive"),
new RegexpNameMapper(@"__object.availabilityData.isBuyable", "__object.isBuyable"),
new RegexpNameMapper(@"__object.availabilityData.trackInventory", "__object.trackInventory"),
new RegexpNameMapper(@"__object.parent.*", "__object.parentId"),
new RegexpNameMapper(@"__object.hasParent.*", "__object.parentId"),
new RegexpNameMapper(@"__object.parent.*", "__object.parentId"),
new RegexpNameMapper(@"__object.category.*", "__object.categoryId"),
new RegexpNameMapper(@"__object.descriptions", "__object.reviews"),
new RegexpNameMapper(@"__object.description.*", "__object.reviews"),
new RegexpNameMapper(@"__object.seoInfo.*", "__object.seoInfos"),

new RegexpNameMapper(@"__object.breadcrumbs.*", "__object.outlines"),

#region Category

new RegexpNameMapper(@"__object.slug$", "__object.outlines", new [] { "__object.seoInfos" }),
new RegexpNameMapper(@"__object.outline$", "__object.outlines"),
new RegexpNameMapper(@"__object.level$", "__object.outlines"),
#endregion
#region Category
new RegexpNameMapper(@"__object.slug$", "__object.outlines", new [] { "__object.seoInfos" }),
new RegexpNameMapper(@"__object.outline$", "__object.outlines"),
new RegexpNameMapper(@"__object.level$", "__object.outlines"),
#endregion
};
}
return _mappers;
}
}

public static IEnumerable<string> MapToIndexIncludes(IEnumerable<string> includeFields)
{
}
public static IEnumerable<string> MapToIndexIncludes(IEnumerable<string> includeFields)
{
IEnumerable<string> result = new string[] { };
foreach (var includeField in includeFields)
{
var indexField = includeField;
foreach (var mapper in Mappers)
{
if (mapper.CanMap(indexField))
{
indexField = mapper.Map(indexField);
if (mapper.AdditionalFields != null)
{
result = result.Union(mapper.AdditionalFields);
}
}
}
result = result.Union(new string[] { indexField });
}
return result;
}
foreach (var includeField in includeFields)
{
var indexField = includeField;
foreach (var mapper in Mappers)
{
if (mapper.CanMap(indexField))
{
indexField = mapper.Map(indexField);
if (mapper.AdditionalFields != null)
{
result = result.Union(mapper.AdditionalFields);
}
}
}
result = result.Union(new string[] { indexField });
}
return result;
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
using GraphQL.DataLoader;
using GraphQL.Types;
using MediatR;
using VirtoCommerce.CoreModule.Core.Seo;
using VirtoCommerce.CatalogModule.Core.Model;
using VirtoCommerce.CoreModule.Core.Seo;
using VirtoCommerce.ExperienceApiModule.Core.Extensions;
using VirtoCommerce.ExperienceApiModule.Core.Schemas;
using VirtoCommerce.Platform.Core.Common;
Expand Down Expand Up @@ -109,6 +110,41 @@ public CategoryType(IMediator mediator, IDataLoaderContextAccessor dataLoader)
result = result.Where(x => names.Contains(x.Name, StringComparer.InvariantCultureIgnoreCase)).ToList();
}
return result;
});

Field<ListGraphType<DescriptionType>>("descriptions",
arguments: new QueryArguments(new QueryArgument<StringGraphType> { Name = "type" }),
resolve: context =>
{
var descriptions = context.Source.Category.Descriptions;
var cultureName = context.GetArgumentOrValue<string>("cultureName");
var type = context.GetArgumentOrValue<string>("type");
if (cultureName != null)
{
descriptions = descriptions.Where(x => string.IsNullOrEmpty(x.LanguageCode) || x.LanguageCode.EqualsInvariant(cultureName)).ToList();
}
if (type != null)
{
descriptions = descriptions.Where(x => x.DescriptionType?.EqualsInvariant(type) ?? true).ToList();
}
return descriptions;
});

Field<DescriptionType>("description",
arguments: new QueryArguments(new QueryArgument<StringGraphType> { Name = "type" }),
resolve: context =>
{
var descriptions = context.Source.Category.Descriptions;
var type = context.GetArgumentOrValue<string>("type");
var cultureName = context.GetArgumentOrValue<string>("cultureName");

if (!descriptions.IsNullOrEmpty())
{
return descriptions.Where(x => x.DescriptionType.EqualsInvariant(type ?? "FullReview")).FirstBestMatchForLanguage(cultureName) as CategoryDescription
?? descriptions.FirstBestMatchForLanguage(cultureName) as CategoryDescription;
}

return null;
});

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
<PackageReference Include="VirtoCommerce.CoreModule.Core" Version="3.22.0" />
<PackageReference Include="VirtoCommerce.InventoryModule.Core" Version="3.3.0" />
<PackageReference Include="VirtoCommerce.TaxModule.Core" Version="3.2.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.53.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.67.0" />
<PackageReference Include="VirtoCommerce.MarketingModule.Core" Version="3.23.0" />
<PackageReference Include="VirtoCommerce.PricingModule.Core" Version="3.2.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.66.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.78.0" />
<PackageReference Include="VirtoCommerce.StoreModule.Core" Version="3.21.0" />
<PackageReference Include="VirtoCommerce.SearchModule.Core" Version="3.13.0" />
<PackageReference Include="VirtoCommerce.SearchModule.Core" Version="3.15.0" />
<PackageReference Include="VirtoCommerce.Tools" Version="3.0.0-rc.5" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.2" />
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.1.2" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.53.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.67.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PackageReference Include="VirtoCommerce.CoreModule.Core" Version="3.22.0" />
<PackageReference Include="VirtoCommerce.OrdersModule.Core" Version="3.33.0-alpha.891" />
<PackageReference Include="VirtoCommerce.OrdersModule.Data" Version="3.33.0-alpha.891" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.66.0" />
<PackageReference Include="VirtoCommerce.Platform.Core" Version="3.78.0" />
<PackageReference Include="VirtoCommerce.CartModule.Core" Version="3.22.0" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@

<ItemGroup>
<PackageReference Include="AutoFixture" Version="4.11.0" />
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.53.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="VirtoCommerce.CatalogModule.Core" Version="3.67.0" />
<PackageReference Include="MediatR" Version="8.0.1" />
<PackageReference Include="GraphQL" Version="4.6.0" />
<PackageReference Include="GraphQL.Relay" Version="0.6.2" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1" />
<PackageReference Include="coverlet.collector" Version="1.2.0" />
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>

<ItemGroup>
Expand Down