Skip to content
Merged
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
440 changes: 263 additions & 177 deletions src/Adapters/ShopifyAdapter.php

Large diffs are not rendered by default.

44 changes: 0 additions & 44 deletions src/V2/ValueObjects/Common/LocaleNormalizer.php

This file was deleted.

3 changes: 1 addition & 2 deletions src/V2/ValueObjects/Common/LocalizedField.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use BradSearch\SyncSdk\V2\Exceptions\InvalidArgumentException;
use BradSearch\SyncSdk\V2\Exceptions\InvalidLocaleException;
use BradSearch\SyncSdk\V2\ValueObjects\Common\LocaleNormalizer;
use Stringable;

/**
Expand Down Expand Up @@ -37,7 +36,7 @@ public function __construct(
throw new InvalidLocaleException($locale);
}

$this->locale = LocaleNormalizer::normalize($locale);
$this->locale = $locale;
}

/**
Expand Down
3 changes: 1 addition & 2 deletions src/V2/ValueObjects/Index/IndexCreateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

use BradSearch\SyncSdk\V2\Exceptions\InvalidArgumentException;
use BradSearch\SyncSdk\V2\Exceptions\InvalidLocaleException;
use BradSearch\SyncSdk\V2\ValueObjects\Common\LocaleNormalizer;
use BradSearch\SyncSdk\V2\ValueObjects\ValueObject;

/**
Expand All @@ -33,7 +32,7 @@ public function __construct(
) {
$this->validateLocales($locales);
$this->validateFields($fields);
$this->locales = LocaleNormalizer::normalizeAll($locales);
$this->locales = $locales;
}

/**
Expand Down
21 changes: 11 additions & 10 deletions src/V2/ValueObjects/SearchSettings/SearchSettingsRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace BradSearch\SyncSdk\V2\ValueObjects\SearchSettings;

use BradSearch\SyncSdk\V2\Exceptions\InvalidArgumentException;
use BradSearch\SyncSdk\V2\ValueObjects\Common\LocaleNormalizer;
use BradSearch\SyncSdk\V2\ValueObjects\ValueObject;

/**
Expand All @@ -26,8 +25,7 @@
* @param ResponseConfig|null $responseConfig Optional response configuration (source fields, sortable fields)
* @param array<string>|null $supportedLocales Optional supported locales
* @param array<string, mixed>|null $rawQueryConfig Optional raw query config (Go-native format, bypasses SearchConfig VOs)
* @param array<string, array<string, string>>|null $featuresKeyValueMap Optional feature ID → locale → display name map
* @param array<string, array<string, string>>|null $attributeKeyValueMap Optional attribute ID → locale → display name map
* @param array<string, mixed>|null $filterConfig Optional filter configuration for facets/aggregations
*/
public function __construct(
public string $appId,
Expand All @@ -36,13 +34,12 @@ public function __construct(
public ?ResponseConfig $responseConfig = null,
?array $supportedLocales = null,
public ?array $rawQueryConfig = null,
public ?array $filterConfig = null,
public ?array $featuresKeyValueMap = null,
public ?array $attributeKeyValueMap = null,
) {
$this->validateAppId($appId);
$this->supportedLocales = $supportedLocales !== null
? LocaleNormalizer::normalizeAll($supportedLocales)
: null;
$this->supportedLocales = $supportedLocales;
}

/**
Expand All @@ -60,6 +57,7 @@ public static function fromSearchConfiguration(string $appId, array $config): se
responseConfig: isset($config['response_config'])
? ResponseConfig::fromArray($config['response_config'])
: null,
filterConfig: $config['filter_config'] ?? null,
featuresKeyValueMap: $config['features_key_value_map'] ?? null,
attributeKeyValueMap: $config['attribute_key_value_map'] ?? null,
);
Expand All @@ -70,31 +68,31 @@ public static function fromSearchConfiguration(string $appId, array $config): se
*/
public function withAppId(string $appId): self
{
return new self($appId, $this->searchConfig, $this->scoringConfig, $this->responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
return new self($appId, $this->searchConfig, $this->scoringConfig, $this->responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->filterConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
}

/**
* Returns a new instance with a different search config.
*/
public function withSearchConfig(?SearchConfig $searchConfig): self
{
return new self($this->appId, $searchConfig, $this->scoringConfig, $this->responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
return new self($this->appId, $searchConfig, $this->scoringConfig, $this->responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->filterConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
}

/**
* Returns a new instance with a different scoring config.
*/
public function withScoringConfig(?ScoringConfig $scoringConfig): self
{
return new self($this->appId, $this->searchConfig, $scoringConfig, $this->responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
return new self($this->appId, $this->searchConfig, $scoringConfig, $this->responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->filterConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
}

/**
* Returns a new instance with a different response config.
*/
public function withResponseConfig(?ResponseConfig $responseConfig): self
{
return new self($this->appId, $this->searchConfig, $this->scoringConfig, $responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
return new self($this->appId, $this->searchConfig, $this->scoringConfig, $responseConfig, $this->supportedLocales, $this->rawQueryConfig, $this->filterConfig, $this->featuresKeyValueMap, $this->attributeKeyValueMap);
}

/**
Expand Down Expand Up @@ -134,6 +132,9 @@ public function jsonSerialize(): array
}
}

if ($this->filterConfig !== null && count($this->filterConfig) > 0) {
$result['filter_config'] = $this->filterConfig;
}
if ($this->featuresKeyValueMap !== null && count($this->featuresKeyValueMap) > 0) {
$result['features_key_value_map'] = $this->featuresKeyValueMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ final class SearchSettingsRequestBuilder
/** @var array<string, mixed>|null */
private ?array $rawQueryConfig = null;

/** @var array<string, mixed>|null */
private ?array $filterConfig = null;

/** @var array<string, array<string, string>>|null */
private ?array $featuresKeyValueMap = null;

Expand Down Expand Up @@ -163,6 +166,17 @@ public function rawQueryConfig(array $config): self
return $this;
}

/**
* Sets filter configuration for facets/aggregations.
*
* @param array<string, mixed> $filterConfig
*/
public function filterConfig(array $filterConfig): self
{
$this->filterConfig = $filterConfig;
return $this;
}

/**
* Sets the features key-value map for facet name translation.
*
Expand Down Expand Up @@ -276,6 +290,7 @@ public function build(): SearchSettingsRequest
$responseConfig,
$this->supportedLocales,
$this->rawQueryConfig,
$this->filterConfig,
$this->featuresKeyValueMap,
$this->attributeKeyValueMap,
);
Expand All @@ -296,6 +311,7 @@ public function reset(): self
$this->sortableFields = [];
$this->supportedLocales = null;
$this->rawQueryConfig = null;
$this->filterConfig = null;
$this->featuresKeyValueMap = null;
$this->attributeKeyValueMap = null;
return $this;
Expand Down
Loading
Loading