-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
692: Changes related to the next Meilisearch release (v1.12.0) r=curquiza a=meili-bot Related to this issue: meilisearch/integration-guides#307 This PR: - gathers the changes related to the next Meilisearch release (v1.12.0) so that this package is ready when the official release is out. - should pass the tests against the [latest pre-release of Meilisearch](https://github.com/meilisearch/meilisearch/releases). - might eventually contain test failures until the Meilisearch v1.12.0 is out.⚠️ This PR should NOT be merged until the next release of Meilisearch (v1.12.0) is out. _This PR is auto-generated for the [pre-release week](https://github.com/meilisearch/integration-guides/blob/main/resources/pre-release-week.md) purpose._ Co-authored-by: meili-bot <[email protected]> Co-authored-by: Clémentine <[email protected]> Co-authored-by: Strift <[email protected]> Co-authored-by: Laurent Cazanove <[email protected]>
- Loading branch information
Showing
14 changed files
with
540 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Meilisearch\Contracts; | ||
|
||
use Meilisearch\Endpoints\Delegates\TasksQueryTrait; | ||
|
||
class BatchesQuery | ||
{ | ||
use TasksQueryTrait; | ||
|
||
private ?int $from = null; | ||
|
||
/** | ||
* @var non-negative-int|null | ||
*/ | ||
private ?int $limit = null; | ||
|
||
private ?bool $reverse = null; | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function setFrom(int $from): self | ||
{ | ||
$this->from = $from; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function setLimit(int $limit): self | ||
{ | ||
$this->limit = $limit; | ||
|
||
return $this; | ||
} | ||
|
||
/** | ||
* @return $this | ||
*/ | ||
public function setReverse(bool $reverse): self | ||
{ | ||
$this->reverse = $reverse; | ||
|
||
return $this; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return array_filter( | ||
array_merge( | ||
$this->baseArray(), | ||
[ | ||
'from' => $this->from, | ||
'limit' => $this->limit, | ||
'reverse' => (null !== $this->reverse ? ($this->reverse ? 'true' : 'false') : null), | ||
] | ||
), | ||
static function ($item) { | ||
return null !== $item; | ||
} | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Meilisearch\Contracts; | ||
|
||
class BatchesResults extends Data | ||
{ | ||
/** | ||
* @var non-negative-int | ||
*/ | ||
private int $next; | ||
|
||
/** | ||
* @var non-negative-int | ||
*/ | ||
private int $limit; | ||
|
||
/** | ||
* @var non-negative-int | ||
*/ | ||
private int $from; | ||
|
||
/** | ||
* @var non-negative-int | ||
*/ | ||
private int $total; | ||
|
||
public function __construct(array $params) | ||
{ | ||
parent::__construct($params['results']); | ||
|
||
$this->from = $params['from'] ?? 0; | ||
$this->limit = $params['limit'] ?? 0; | ||
$this->next = $params['next'] ?? 0; | ||
$this->total = $params['total'] ?? 0; | ||
} | ||
|
||
/** | ||
* @return array<int, array> | ||
*/ | ||
public function getResults(): array | ||
{ | ||
return $this->data; | ||
} | ||
|
||
/** | ||
* @return non-negative-int | ||
*/ | ||
public function getNext(): int | ||
{ | ||
return $this->next; | ||
} | ||
|
||
/** | ||
* @return non-negative-int | ||
*/ | ||
public function getLimit(): int | ||
{ | ||
return $this->limit; | ||
} | ||
|
||
/** | ||
* @return non-negative-int | ||
*/ | ||
public function getFrom(): int | ||
{ | ||
return $this->from; | ||
} | ||
|
||
/** | ||
* @return non-negative-int | ||
*/ | ||
public function getTotal(): int | ||
{ | ||
return $this->total; | ||
} | ||
|
||
public function toArray(): array | ||
{ | ||
return [ | ||
'results' => $this->data, | ||
'next' => $this->next, | ||
'limit' => $this->limit, | ||
'from' => $this->from, | ||
'total' => $this->total, | ||
]; | ||
} | ||
|
||
public function count(): int | ||
{ | ||
return \count($this->data); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Meilisearch\Endpoints; | ||
|
||
use Meilisearch\Contracts\Endpoint; | ||
|
||
class Batches extends Endpoint | ||
{ | ||
protected const PATH = '/batches'; | ||
|
||
public function get($batchUid): array | ||
{ | ||
return $this->http->get(self::PATH.'/'.$batchUid); | ||
} | ||
|
||
public function all(array $query = []): array | ||
{ | ||
return $this->http->get(self::PATH.'/', $query); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Meilisearch\Endpoints\Delegates; | ||
|
||
use Meilisearch\Contracts\BatchesQuery; | ||
use Meilisearch\Contracts\BatchesResults; | ||
use Meilisearch\Endpoints\Batches; | ||
|
||
trait HandlesBatches | ||
{ | ||
protected Batches $batches; | ||
|
||
public function getBatch($uid): array | ||
{ | ||
return $this->batches->get($uid); | ||
} | ||
|
||
public function getBatches(?BatchesQuery $options = null): BatchesResults | ||
{ | ||
$query = null !== $options ? $options->toArray() : []; | ||
|
||
$response = $this->batches->all($query); | ||
|
||
return new BatchesResults($response); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.