From 252320753fd7a12ac5f318be04b6c20dfc428753 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 21 Nov 2025 12:29:32 +0000 Subject: [PATCH 1/5] Make insertDocuments public --- src/Typesense/Index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Typesense/Index.php b/src/Typesense/Index.php index 6c15991..cb301e3 100644 --- a/src/Typesense/Index.php +++ b/src/Typesense/Index.php @@ -73,7 +73,7 @@ public function exists() } } - protected function insertDocuments(Documents $documents) + public function insertDocuments(Documents $documents) { $this->getOrCreateIndex()->documents->import($documents->all(), ['action' => 'upsert']); } From c110c73c1f84673ad06b29d99102a73d5c4d2960 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 21 Nov 2025 12:30:59 +0000 Subject: [PATCH 2/5] Drop custom implementation of `insertMultiple` Chunking is now handled in Statamic's native implementation. --- config/statamic-typesense.php | 9 --------- src/ServiceProvider.php | 10 ---------- src/Typesense/Index.php | 17 ----------------- 3 files changed, 36 deletions(-) delete mode 100644 config/statamic-typesense.php 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 cb301e3..e03c6f2 100644 --- a/src/Typesense/Index.php +++ b/src/Typesense/Index.php @@ -33,24 +33,7 @@ public function insert($document) return $this->insertMultiple(collect([$document])); } - public function insertMultiple($documents) { - $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; } public function delete($document) From 0c6645989d80fd8c3aecc85cd1ad2b6998f9d13a Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 21 Nov 2025 12:31:29 +0000 Subject: [PATCH 3/5] Add `fields` method to manipulate data before sending to Typesense --- src/Typesense/Index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Typesense/Index.php b/src/Typesense/Index.php index e03c6f2..cae0920 100644 --- a/src/Typesense/Index.php +++ b/src/Typesense/Index.php @@ -33,7 +33,12 @@ public function insert($document) return $this->insertMultiple(collect([$document])); } + public function fields(Searchable $searchable) { + return array_merge( + $this->searchables()->fields($searchable), + $this->getDefaultFields($searchable) + ); } public function delete($document) From 3be8482033760cd1ebbb0d29b76d841e81b66ebf Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 21 Nov 2025 12:35:05 +0000 Subject: [PATCH 4/5] Drop support for Statamic 5 --- .github/workflows/run-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 }} From 931bfb7ddeef19925b00ca3f2b50730824ad3ed0 Mon Sep 17 00:00:00 2001 From: Duncan McClean Date: Fri, 21 Nov 2025 12:36:55 +0000 Subject: [PATCH 5/5] Drop v5 dependencies in composer.json too --- composer.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 88242b2..c5235f5 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", "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": {