@nexo-labs/payload-typesense 1.4.3 → 1.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3287,7 +3287,15 @@ const applySyncHooks = (config, pluginOptions, typesenseClient, embeddingService
3287
3287
  ...collection.hooks,
3288
3288
  afterChange: [...collection.hooks?.afterChange || [], async ({ doc, operation, req: _req }) => {
3289
3289
  if (tableConfigs && Array.isArray(tableConfigs)) {
3290
- for (const tableConfig of tableConfigs) if (tableConfig.enabled) await syncDocumentToTypesense(typesenseClient, collection.slug, doc, operation, tableConfig, embeddingService);
3290
+ for (const tableConfig of tableConfigs) if (tableConfig.enabled) {
3291
+ if (tableConfig.shouldIndex) {
3292
+ if (!await tableConfig.shouldIndex(doc)) {
3293
+ await deleteDocumentFromTypesense(typesenseClient, collection.slug, doc.id, tableConfig);
3294
+ continue;
3295
+ }
3296
+ }
3297
+ await syncDocumentToTypesense(typesenseClient, collection.slug, doc, operation, tableConfig, embeddingService);
3298
+ }
3291
3299
  }
3292
3300
  }],
3293
3301
  afterDelete: [...collection.hooks?.afterDelete || [], async ({ doc, req: _req }) => {