@open-mercato/search 0.10.1-develop.8046.1.ec4dd00394 → 0.10.1-develop.8052.1.b8f5a8e876

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.
@@ -1,5 +1,4 @@
1
1
  import { loadEntityRecordScope } from "@open-mercato/shared/lib/db/recordScope";
2
- import { resolveAutoIndexingEnabled } from "../lib/auto-indexing.js";
3
2
  import { searchDebugWarn, searchError } from "../../../lib/debug.js";
4
3
  const metadata = { event: "search.index_record", persistent: false };
5
4
  async function handle(payload, ctx) {
@@ -28,10 +27,6 @@ async function handle(payload, ctx) {
28
27
  if (!tenantId) {
29
28
  return;
30
29
  }
31
- const autoIndexingEnabled = await resolveAutoIndexingEnabled(ctx, { defaultValue: true });
32
- if (!autoIndexingEnabled) {
33
- return;
34
- }
35
30
  let queue;
36
31
  try {
37
32
  queue = ctx.resolve("fulltextIndexQueue");
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../src/modules/search/subscribers/fulltext_upsert.ts"],
4
- "sourcesContent": ["import { loadEntityRecordScope } from '@open-mercato/shared/lib/db/recordScope'\nimport type { Queue } from '@open-mercato/queue'\nimport type { FulltextIndexJobPayload } from '../../../queue/fulltext-indexing'\nimport { resolveAutoIndexingEnabled } from '../lib/auto-indexing'\nimport { searchDebugWarn, searchError } from '../../../lib/debug'\n\nexport const metadata = { event: 'search.index_record', persistent: false }\n\ntype Payload = {\n entityId?: string\n recordId?: string\n organizationId?: string | null\n tenantId?: string | null\n}\n\ntype HandlerContext = { resolve: <T = unknown>(name: string) => T }\n\nexport default async function handle(payload: Payload, ctx: HandlerContext) {\n const entityType = String(payload?.entityId ?? '')\n const recordId = String(payload?.recordId ?? '')\n\n if (!entityType || !recordId) {\n return\n }\n\n let organizationId = payload?.organizationId ?? null\n let tenantId = payload?.tenantId ?? null\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let em: any | null = null\n try {\n em = ctx.resolve('em')\n } catch {\n em = null\n }\n\n // Resolve missing scope from DB if needed (same pattern as vector_upsert.ts)\n if ((organizationId == null || tenantId == null) && em) {\n try {\n const lookupEm = typeof em.fork === 'function' ? em.fork() : em\n const scope = await loadEntityRecordScope(lookupEm, entityType, recordId)\n if (organizationId == null) organizationId = scope?.organizationId ?? organizationId\n if (tenantId == null) tenantId = scope?.tenantId ?? tenantId\n } catch {\n // Ignore lookup errors\n }\n }\n\n if (!tenantId) {\n return\n }\n\n const autoIndexingEnabled = await resolveAutoIndexingEnabled(ctx, { defaultValue: true })\n if (!autoIndexingEnabled) {\n return\n }\n\n let queue: Queue<FulltextIndexJobPayload>\n try {\n queue = ctx.resolve<Queue<FulltextIndexJobPayload>>('fulltextIndexQueue')\n } catch {\n searchDebugWarn('search.fulltext', 'fulltextIndexQueue not available, skipping fulltext indexing')\n return\n }\n\n try {\n await queue.enqueue({\n jobType: 'index',\n entityType,\n recordId,\n tenantId: String(tenantId),\n organizationId: organizationId ? String(organizationId) : null,\n })\n } catch (error) {\n searchError('search.fulltext', 'Failed to enqueue fulltext index job', {\n entityType,\n recordId,\n error: error instanceof Error ? error.message : error,\n })\n throw error\n }\n}\n"],
5
- "mappings": "AAAA,SAAS,6BAA6B;AAGtC,SAAS,kCAAkC;AAC3C,SAAS,iBAAiB,mBAAmB;AAEtC,MAAM,WAAW,EAAE,OAAO,uBAAuB,YAAY,MAAM;AAW1E,eAAO,OAA8B,SAAkB,KAAqB;AAC1E,QAAM,aAAa,OAAO,SAAS,YAAY,EAAE;AACjD,QAAM,WAAW,OAAO,SAAS,YAAY,EAAE;AAE/C,MAAI,CAAC,cAAc,CAAC,UAAU;AAC5B;AAAA,EACF;AAEA,MAAI,iBAAiB,SAAS,kBAAkB;AAChD,MAAI,WAAW,SAAS,YAAY;AAGpC,MAAI,KAAiB;AACrB,MAAI;AACF,SAAK,IAAI,QAAQ,IAAI;AAAA,EACvB,QAAQ;AACN,SAAK;AAAA,EACP;AAGA,OAAK,kBAAkB,QAAQ,YAAY,SAAS,IAAI;AACtD,QAAI;AACF,YAAM,WAAW,OAAO,GAAG,SAAS,aAAa,GAAG,KAAK,IAAI;AAC7D,YAAM,QAAQ,MAAM,sBAAsB,UAAU,YAAY,QAAQ;AACxE,UAAI,kBAAkB,KAAM,kBAAiB,OAAO,kBAAkB;AACtE,UAAI,YAAY,KAAM,YAAW,OAAO,YAAY;AAAA,IACtD,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAEA,QAAM,sBAAsB,MAAM,2BAA2B,KAAK,EAAE,cAAc,KAAK,CAAC;AACxF,MAAI,CAAC,qBAAqB;AACxB;AAAA,EACF;AAEA,MAAI;AACJ,MAAI;AACF,YAAQ,IAAI,QAAwC,oBAAoB;AAAA,EAC1E,QAAQ;AACN,oBAAgB,mBAAmB,8DAA8D;AACjG;AAAA,EACF;AAEA,MAAI;AACF,UAAM,MAAM,QAAQ;AAAA,MAClB,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,UAAU,OAAO,QAAQ;AAAA,MACzB,gBAAgB,iBAAiB,OAAO,cAAc,IAAI;AAAA,IAC5D,CAAC;AAAA,EACH,SAAS,OAAO;AACd,gBAAY,mBAAmB,wCAAwC;AAAA,MACrE;AAAA,MACA;AAAA,MACA,OAAO,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IAClD,CAAC;AACD,UAAM;AAAA,EACR;AACF;",
4
+ "sourcesContent": ["import { loadEntityRecordScope } from '@open-mercato/shared/lib/db/recordScope'\nimport type { Queue } from '@open-mercato/queue'\nimport type { FulltextIndexJobPayload } from '../../../queue/fulltext-indexing'\nimport { searchDebugWarn, searchError } from '../../../lib/debug'\n\nexport const metadata = { event: 'search.index_record', persistent: false }\n\ntype Payload = {\n entityId?: string\n recordId?: string\n organizationId?: string | null\n tenantId?: string | null\n}\n\ntype HandlerContext = { resolve: <T = unknown>(name: string) => T }\n\nexport default async function handle(payload: Payload, ctx: HandlerContext) {\n const entityType = String(payload?.entityId ?? '')\n const recordId = String(payload?.recordId ?? '')\n\n if (!entityType || !recordId) {\n return\n }\n\n let organizationId = payload?.organizationId ?? null\n let tenantId = payload?.tenantId ?? null\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n let em: any | null = null\n try {\n em = ctx.resolve('em')\n } catch {\n em = null\n }\n\n // Resolve missing scope from DB if needed (same pattern as vector_upsert.ts)\n if ((organizationId == null || tenantId == null) && em) {\n try {\n const lookupEm = typeof em.fork === 'function' ? em.fork() : em\n const scope = await loadEntityRecordScope(lookupEm, entityType, recordId)\n if (organizationId == null) organizationId = scope?.organizationId ?? organizationId\n if (tenantId == null) tenantId = scope?.tenantId ?? tenantId\n } catch {\n // Ignore lookup errors\n }\n }\n\n if (!tenantId) {\n return\n }\n\n // The auto-indexing switch (OM_DISABLE_VECTOR_SEARCH_AUTOINDEXING and its tenant setting)\n // is vector-only, so it must not stop full-text records from being queued.\n let queue: Queue<FulltextIndexJobPayload>\n try {\n queue = ctx.resolve<Queue<FulltextIndexJobPayload>>('fulltextIndexQueue')\n } catch {\n searchDebugWarn('search.fulltext', 'fulltextIndexQueue not available, skipping fulltext indexing')\n return\n }\n\n try {\n await queue.enqueue({\n jobType: 'index',\n entityType,\n recordId,\n tenantId: String(tenantId),\n organizationId: organizationId ? String(organizationId) : null,\n })\n } catch (error) {\n searchError('search.fulltext', 'Failed to enqueue fulltext index job', {\n entityType,\n recordId,\n error: error instanceof Error ? error.message : error,\n })\n throw error\n }\n}\n"],
5
+ "mappings": "AAAA,SAAS,6BAA6B;AAGtC,SAAS,iBAAiB,mBAAmB;AAEtC,MAAM,WAAW,EAAE,OAAO,uBAAuB,YAAY,MAAM;AAW1E,eAAO,OAA8B,SAAkB,KAAqB;AAC1E,QAAM,aAAa,OAAO,SAAS,YAAY,EAAE;AACjD,QAAM,WAAW,OAAO,SAAS,YAAY,EAAE;AAE/C,MAAI,CAAC,cAAc,CAAC,UAAU;AAC5B;AAAA,EACF;AAEA,MAAI,iBAAiB,SAAS,kBAAkB;AAChD,MAAI,WAAW,SAAS,YAAY;AAGpC,MAAI,KAAiB;AACrB,MAAI;AACF,SAAK,IAAI,QAAQ,IAAI;AAAA,EACvB,QAAQ;AACN,SAAK;AAAA,EACP;AAGA,OAAK,kBAAkB,QAAQ,YAAY,SAAS,IAAI;AACtD,QAAI;AACF,YAAM,WAAW,OAAO,GAAG,SAAS,aAAa,GAAG,KAAK,IAAI;AAC7D,YAAM,QAAQ,MAAM,sBAAsB,UAAU,YAAY,QAAQ;AACxE,UAAI,kBAAkB,KAAM,kBAAiB,OAAO,kBAAkB;AACtE,UAAI,YAAY,KAAM,YAAW,OAAO,YAAY;AAAA,IACtD,QAAQ;AAAA,IAER;AAAA,EACF;AAEA,MAAI,CAAC,UAAU;AACb;AAAA,EACF;AAIA,MAAI;AACJ,MAAI;AACF,YAAQ,IAAI,QAAwC,oBAAoB;AAAA,EAC1E,QAAQ;AACN,oBAAgB,mBAAmB,8DAA8D;AACjG;AAAA,EACF;AAEA,MAAI;AACF,UAAM,MAAM,QAAQ;AAAA,MAClB,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA,UAAU,OAAO,QAAQ;AAAA,MACzB,gBAAgB,iBAAiB,OAAO,cAAc,IAAI;AAAA,IAC5D,CAAC;AAAA,EACH,SAAS,OAAO;AACd,gBAAY,mBAAmB,wCAAwC;AAAA,MACrE;AAAA,MACA;AAAA,MACA,OAAO,iBAAiB,QAAQ,MAAM,UAAU;AAAA,IAClD,CAAC;AACD,UAAM;AAAA,EACR;AACF;",
6
6
  "names": []
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@open-mercato/search",
3
- "version": "0.10.1-develop.8046.1.ec4dd00394",
3
+ "version": "0.10.1-develop.8052.1.b8f5a8e876",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -127,9 +127,9 @@
127
127
  "zod": "^4.6.6"
128
128
  },
129
129
  "peerDependencies": {
130
- "@open-mercato/core": "0.10.1-develop.8046.1.ec4dd00394",
131
- "@open-mercato/queue": "0.10.1-develop.8046.1.ec4dd00394",
132
- "@open-mercato/shared": "0.10.1-develop.8046.1.ec4dd00394"
130
+ "@open-mercato/core": "0.10.1-develop.8052.1.b8f5a8e876",
131
+ "@open-mercato/queue": "0.10.1-develop.8052.1.b8f5a8e876",
132
+ "@open-mercato/shared": "0.10.1-develop.8052.1.b8f5a8e876"
133
133
  },
134
134
  "devDependencies": {
135
135
  "@types/jest": "^30.0.0",
@@ -0,0 +1,34 @@
1
+ jest.mock('../../lib/auto-indexing', () => ({
2
+ resolveAutoIndexingEnabled: jest.fn().mockResolvedValue(false),
3
+ }))
4
+
5
+ import fulltextUpsert from '../fulltext_upsert'
6
+
7
+ /**
8
+ * The auto-indexing switch (OM_DISABLE_VECTOR_SEARCH_AUTOINDEXING) only controls the vector
9
+ * strategy. With it on, new and restored records must still reach the full-text queue.
10
+ */
11
+ describe('fulltext_upsert with vector auto-indexing disabled', () => {
12
+ it('still enqueues the full-text index job', async () => {
13
+ const enqueue = jest.fn().mockResolvedValue(undefined)
14
+ const ctx = {
15
+ resolve: jest.fn((name: string) => {
16
+ if (name === 'fulltextIndexQueue') return { enqueue }
17
+ throw new Error(`[internal] not registered: ${name}`)
18
+ }),
19
+ }
20
+
21
+ await fulltextUpsert(
22
+ { entityId: 'customers:customer_person', recordId: 'r1', tenantId: 'tenant-1', organizationId: 'org-1' },
23
+ ctx,
24
+ )
25
+
26
+ expect(enqueue).toHaveBeenCalledWith({
27
+ jobType: 'index',
28
+ entityType: 'customers:customer_person',
29
+ recordId: 'r1',
30
+ tenantId: 'tenant-1',
31
+ organizationId: 'org-1',
32
+ })
33
+ })
34
+ })
@@ -1,7 +1,6 @@
1
1
  import { loadEntityRecordScope } from '@open-mercato/shared/lib/db/recordScope'
2
2
  import type { Queue } from '@open-mercato/queue'
3
3
  import type { FulltextIndexJobPayload } from '../../../queue/fulltext-indexing'
4
- import { resolveAutoIndexingEnabled } from '../lib/auto-indexing'
5
4
  import { searchDebugWarn, searchError } from '../../../lib/debug'
6
5
 
7
6
  export const metadata = { event: 'search.index_record', persistent: false }
@@ -50,11 +49,8 @@ export default async function handle(payload: Payload, ctx: HandlerContext) {
50
49
  return
51
50
  }
52
51
 
53
- const autoIndexingEnabled = await resolveAutoIndexingEnabled(ctx, { defaultValue: true })
54
- if (!autoIndexingEnabled) {
55
- return
56
- }
57
-
52
+ // The auto-indexing switch (OM_DISABLE_VECTOR_SEARCH_AUTOINDEXING and its tenant setting)
53
+ // is vector-only, so it must not stop full-text records from being queued.
58
54
  let queue: Queue<FulltextIndexJobPayload>
59
55
  try {
60
56
  queue = ctx.resolve<Queue<FulltextIndexJobPayload>>('fulltextIndexQueue')