diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index f9275bc..7154711 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -27,8 +27,8 @@ jobs: matrix: os: [ubuntu-latest] php: [8.3, 8.4] - laravel: [11.*, 12.*] - statamic: [5.*, 6.*] + laravel: [12.*] + statamic: [6.*] dependency-version: [prefer-stable] name: P${{ matrix.php }} - L${{ matrix.laravel }} - S${{ matrix.statamic }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} diff --git a/composer.json b/composer.json index 88242b2..1cc1c1d 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,14 @@ "php": "^8.2", "guzzlehttp/guzzle": "^7.3", "http-interop/http-factory-guzzle": "^1.0", - "illuminate/support": "^11.0 || ^12.0", - "statamic/cms": "^5.38 || ^6.0", + "illuminate/support": "^12.0", + "statamic/cms": "^6.0.0-beta.4", "typesense/typesense-php": "^4.9" }, "require-dev": { "laravel/pint": "^1.17", - "orchestra/testbench": "^8.14 || ^9.0 || ^10.0", - "phpunit/phpunit": "^10.0 || ^11.0" + "orchestra/testbench": "^10.0", + "phpunit/phpunit": "^11.0" }, "autoload": { "psr-4": { @@ -58,5 +58,7 @@ "name": "Typesense", "description": "Typesense search driver for Statamic" } - } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/config/statamic-typesense.php b/config/statamic-typesense.php deleted file mode 100644 index 9ac9414..0000000 --- a/config/statamic-typesense.php +++ /dev/null @@ -1,9 +0,0 @@ - 100, - -]; diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 012c925..c25b24d 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -11,16 +11,6 @@ class ServiceProvider extends AddonServiceProvider { public function bootAddon() { - $this->mergeConfigFrom(__DIR__.'/../config/statamic-typesense.php', 'statamic-typesense'); - - if ($this->app->runningInConsole()) { - - $this->publishes([ - __DIR__.'/../config/statamic-typesense.php' => config_path('statamic-typesense.php'), - ], 'statamic-typesense-config'); - - } - Search::extend('typesense', function (Application $app, array $config, $name, $locale = null) { $client = new Client($config['client'] ?? []); diff --git a/src/Typesense/Index.php b/src/Typesense/Index.php index 6c15991..cae0920 100644 --- a/src/Typesense/Index.php +++ b/src/Typesense/Index.php @@ -33,24 +33,12 @@ public function insert($document) return $this->insertMultiple(collect([$document])); } - public function insertMultiple($documents) + public function fields(Searchable $searchable) { - $documents - ->chunk(config('statamic-typesense.insert_chunk_size', 100)) - ->each(function ($documents, $index) { - $documents = $documents - ->filter() - ->map(fn ($document) => array_merge( - $this->searchables()->fields($document), - $this->getDefaultFields($document), - )) - ->values() - ->toArray(); - - $this->insertDocuments(new Documents($documents)); - }); - - return $this; + return array_merge( + $this->searchables()->fields($searchable), + $this->getDefaultFields($searchable) + ); } public function delete($document) @@ -73,7 +61,7 @@ public function exists() } } - protected function insertDocuments(Documents $documents) + public function insertDocuments(Documents $documents) { $this->getOrCreateIndex()->documents->import($documents->all(), ['action' => 'upsert']); } diff --git a/tests/TestCase.php b/tests/TestCase.php index 008e0d0..688f0c6 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -15,7 +15,6 @@ protected function resolveApplicationConfiguration($app) { parent::resolveApplicationConfiguration($app); - // add typesense driver $app['config']->set('statamic.search.drivers.typesense', [ 'client' => [ 'api_key' => env('TYPESENSE_API_KEY', 'xyz'), @@ -40,7 +39,10 @@ protected function resolveApplicationConfiguration($app) ], ]); - // add typesense index + $app['config']->set('statamic.search.indexes.cp', [ + 'driver' => 'null', + ]); + $app['config']->set('statamic.search.indexes.typesense_index', [ 'driver' => 'typesense', 'searchables' => ['collection:pages'],