@open-mercato/search 0.6.5-develop.5337.1.534b781eac → 0.6.5
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/fulltext/drivers/meilisearch/index.js +4 -2
- package/dist/fulltext/drivers/meilisearch/index.js.map +2 -2
- package/dist/indexer/search-indexer.js +3 -3
- package/dist/indexer/search-indexer.js.map +2 -2
- package/dist/modules/search/api/index/route.js +25 -10
- package/dist/modules/search/api/index/route.js.map +3 -3
- package/dist/modules/search/cli.js +1 -1
- package/dist/modules/search/cli.js.map +2 -2
- package/dist/modules/search/subscribers/vector_purge.js +2 -1
- package/dist/modules/search/subscribers/vector_purge.js.map +2 -2
- package/dist/service.js +2 -2
- package/dist/service.js.map +2 -2
- package/dist/strategies/fulltext.strategy.js +2 -2
- package/dist/strategies/fulltext.strategy.js.map +2 -2
- package/dist/strategies/token.strategy.js +7 -2
- package/dist/strategies/token.strategy.js.map +2 -2
- package/dist/strategies/vector.strategy.js +2 -2
- package/dist/strategies/vector.strategy.js.map +2 -2
- package/dist/vector/drivers/pgvector/index.js +10 -3
- package/dist/vector/drivers/pgvector/index.js.map +2 -2
- package/dist/vector/services/vector-index.service.js +2 -2
- package/dist/vector/services/vector-index.service.js.map +2 -2
- package/dist/vector/types.js.map +1 -1
- package/package.json +12 -13
- package/src/__tests__/purge-org-scoping.test.ts +136 -0
- package/src/__tests__/service.test.ts +2 -1
- package/src/fulltext/drivers/meilisearch/index.ts +8 -2
- package/src/fulltext/types.ts +1 -1
- package/src/indexer/search-indexer.ts +4 -3
- package/src/modules/search/api/__tests__/org-scoping.routes.test.ts +111 -1
- package/src/modules/search/api/index/route.ts +36 -8
- package/src/modules/search/cli.ts +1 -1
- package/src/modules/search/subscribers/__tests__/vector_purge.test.ts +55 -0
- package/src/modules/search/subscribers/vector_purge.ts +1 -0
- package/src/service.ts +2 -2
- package/src/strategies/fulltext.strategy.ts +2 -2
- package/src/strategies/token.strategy.ts +8 -3
- package/src/strategies/vector.strategy.ts +2 -2
- package/src/vector/drivers/pgvector/index.ts +11 -3
- package/src/vector/services/vector-index.service.ts +2 -2
- package/src/vector/types.ts +1 -1
|
@@ -302,11 +302,19 @@ export function createPgVectorDriver(opts: PgVectorDriverOptions = {}): VectorDr
|
|
|
302
302
|
return res.rowCount ? res.rows[0].checksum : null
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
const purge = async (entityId: string, tenantId: string) => {
|
|
305
|
+
const purge = async (entityId: string, tenantId: string, organizationId?: string | null) => {
|
|
306
306
|
await ensureReady()
|
|
307
|
+
const normalizedOrganizationId =
|
|
308
|
+
typeof organizationId === 'string' && organizationId.trim().length > 0 ? organizationId.trim() : null
|
|
309
|
+
const conditions = ['driver_id = $1', 'entity_id = $2', 'tenant_id = $3::uuid']
|
|
310
|
+
const values: any[] = [DRIVER_ID, entityId, tenantId]
|
|
311
|
+
if (normalizedOrganizationId !== null) {
|
|
312
|
+
conditions.push('organization_id = $4::uuid')
|
|
313
|
+
values.push(normalizedOrganizationId)
|
|
314
|
+
}
|
|
307
315
|
await pool.query(
|
|
308
|
-
`DELETE FROM ${tableIdent} WHERE
|
|
309
|
-
|
|
316
|
+
`DELETE FROM ${tableIdent} WHERE ${conditions.join(' AND ')}`,
|
|
317
|
+
values,
|
|
310
318
|
)
|
|
311
319
|
}
|
|
312
320
|
|
|
@@ -900,7 +900,7 @@ export class VectorIndexService {
|
|
|
900
900
|
|
|
901
901
|
if (this.opts.eventBus) {
|
|
902
902
|
if (shouldPurge && driver.purge && args.tenantId) {
|
|
903
|
-
await driver.purge(args.entityId, args.tenantId)
|
|
903
|
+
await driver.purge(args.entityId, args.tenantId, args.organizationId)
|
|
904
904
|
} else if (shouldPurge && !args.tenantId) {
|
|
905
905
|
searchDebugWarn('vector', 'Skipping purge for multi-tenant reindex (tenant not provided)')
|
|
906
906
|
}
|
|
@@ -923,7 +923,7 @@ export class VectorIndexService {
|
|
|
923
923
|
}
|
|
924
924
|
|
|
925
925
|
if (shouldPurge && driver.purge) {
|
|
926
|
-
await driver.purge(args.entityId, args.tenantId)
|
|
926
|
+
await driver.purge(args.entityId, args.tenantId, args.organizationId)
|
|
927
927
|
}
|
|
928
928
|
|
|
929
929
|
const pageSize = 50
|
package/src/vector/types.ts
CHANGED
|
@@ -103,7 +103,7 @@ export interface VectorDriver {
|
|
|
103
103
|
delete(entityId: EntityId, recordId: string, tenantId: string): Promise<void>
|
|
104
104
|
query(input: VectorDriverQuery): Promise<VectorDriverQueryResult[]>
|
|
105
105
|
getChecksum(entityId: EntityId, recordId: string, tenantId: string): Promise<string | null>
|
|
106
|
-
purge?(entityId: EntityId, tenantId: string): Promise<void>
|
|
106
|
+
purge?(entityId: EntityId, tenantId: string, organizationId?: string | null): Promise<void>
|
|
107
107
|
list?(params: VectorDriverListParams): Promise<VectorIndexEntry[]>
|
|
108
108
|
count?(params: VectorDriverCountParams): Promise<number>
|
|
109
109
|
removeOrphans?(params: VectorDriverRemoveOrphansParams): Promise<number | void>
|