@open-mercato/search 0.10.1-develop.8212.1.08dada9624 → 0.10.1-develop.8214.1.2a8d49710f
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/modules/search/__integration__/TC-SEARCH-002.spec.js +8 -4
- package/dist/modules/search/__integration__/TC-SEARCH-002.spec.js.map +2 -2
- package/dist/modules/search/__integration__/TC-SEARCH-015.spec.js +33 -0
- package/dist/modules/search/__integration__/TC-SEARCH-015.spec.js.map +2 -2
- package/dist/modules/search/frontend/components/SearchSettingsPageClient.js +1 -1
- package/dist/modules/search/frontend/components/SearchSettingsPageClient.js.map +2 -2
- package/dist/modules/search/frontend/components/sections/FulltextSearchSection.js +15 -9
- package/dist/modules/search/frontend/components/sections/FulltextSearchSection.js.map +2 -2
- package/dist/modules/search/frontend/components/sections/VectorSearchSection.js +32 -18
- package/dist/modules/search/frontend/components/sections/VectorSearchSection.js.map +2 -2
- package/dist/modules/search/i18n/de.json +4 -0
- package/dist/modules/search/i18n/en.json +4 -0
- package/dist/modules/search/i18n/es.json +4 -0
- package/dist/modules/search/i18n/ko.json +4 -0
- package/dist/modules/search/i18n/pl.json +4 -0
- package/package.json +4 -4
- package/src/modules/search/__integration__/TC-SEARCH-002.spec.ts +8 -4
- package/src/modules/search/__integration__/TC-SEARCH-015.spec.ts +33 -0
- package/src/modules/search/frontend/components/SearchSettingsPageClient.tsx +1 -1
- package/src/modules/search/frontend/components/sections/FulltextSearchSection.tsx +16 -9
- package/src/modules/search/frontend/components/sections/VectorSearchSection.tsx +33 -34
- package/src/modules/search/frontend/components/sections/__tests__/FulltextSearchSection.test.tsx +45 -0
- package/src/modules/search/frontend/components/sections/__tests__/VectorSearchSection.test.tsx +100 -0
- package/src/modules/search/i18n/de.json +4 -0
- package/src/modules/search/i18n/en.json +4 -0
- package/src/modules/search/i18n/es.json +4 -0
- package/src/modules/search/i18n/ko.json +4 -0
- package/src/modules/search/i18n/pl.json +4 -0
- package/src/modules/search/subscribers/__tests__/scope-lookup-isolation.test.ts +3 -2
- package/src/modules/search/subscribers/__tests__/scope-lookup.pg.test.ts +135 -113
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { expect, test } from "@playwright/test";
|
|
2
2
|
import { apiRequest, getAuthToken } from "@open-mercato/core/helpers/integration/api";
|
|
3
|
+
import { getTokenContext } from "@open-mercato/core/helpers/integration/generalFixtures";
|
|
3
4
|
import {
|
|
4
5
|
createCompanyFixture,
|
|
5
6
|
deleteEntityIfExists,
|
|
@@ -51,8 +52,11 @@ test.describe("TC-SEARCH-002: search endpoint merges duplicate strategy hits", (
|
|
|
51
52
|
const uniqueCompanyName = `QATCSEARCH002${Date.now()}`;
|
|
52
53
|
let mergedResult = null;
|
|
53
54
|
try {
|
|
54
|
-
const authToken = await getAuthToken(request, "
|
|
55
|
+
const authToken = await getAuthToken(request, "admin");
|
|
55
56
|
token = authToken;
|
|
57
|
+
const { organizationId, tenantId } = getTokenContext(authToken);
|
|
58
|
+
expect(organizationId).not.toBe("");
|
|
59
|
+
expect(tenantId).not.toBe("");
|
|
56
60
|
const settingsResponse = await apiRequest(request, "GET", "/api/search/settings", { token: authToken });
|
|
57
61
|
expect(settingsResponse.ok()).toBeTruthy();
|
|
58
62
|
const settings = await readJson(settingsResponse);
|
|
@@ -101,11 +105,11 @@ test.describe("TC-SEARCH-002: search endpoint merges duplicate strategy hits", (
|
|
|
101
105
|
const metadata = isRecord(ensuredMergedResult.metadata) ? ensuredMergedResult.metadata : {};
|
|
102
106
|
expect(typeof metadata._rrfScore).toBe("number");
|
|
103
107
|
expect(ensuredMergedResult.entityId).toBe("customers:customer_company_profile");
|
|
104
|
-
|
|
105
|
-
expect(ensuredMergedResult.url).
|
|
108
|
+
const expectedCompanyUrl = `/backend/customers/companies-v2/${encodeURIComponent(requireValue(companyId, "Expected the created company id"))}`;
|
|
109
|
+
expect(ensuredMergedResult.url).toBe(expectedCompanyUrl);
|
|
106
110
|
const links = getLinks(ensuredMergedResult);
|
|
107
111
|
expect(
|
|
108
|
-
links.some((link) =>
|
|
112
|
+
links.some((link) => link.href === `${expectedCompanyUrl}/edit` && link.kind === "secondary")
|
|
109
113
|
).toBeTruthy();
|
|
110
114
|
} finally {
|
|
111
115
|
await deleteEntityIfExists(request, token, "/api/customers/companies", companyId);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/search/__integration__/TC-SEARCH-002.spec.ts"],
|
|
4
|
-
"sourcesContent": ["import { expect, test, type APIResponse } from '@playwright/test'\nimport { apiRequest, getAuthToken } from '@open-mercato/core/helpers/integration/api'\nimport {\n createCompanyFixture,\n deleteEntityIfExists,\n readJsonSafe,\n} from '@open-mercato/core/helpers/integration/crmFixtures'\n\ntype JsonRecord = Record<string, unknown>\n\ntype SearchSettingsResponse = {\n settings?: {\n strategies?: Array<{\n id?: unknown\n available?: unknown\n }>\n tokensEnabled?: unknown\n }\n}\n\ntype SearchResultPayload = {\n entityId?: unknown\n recordId?: unknown\n source?: unknown\n presenter?: unknown\n url?: unknown\n links?: unknown\n metadata?: unknown\n}\n\ntype SearchResponse = {\n results?: SearchResultPayload[]\n}\n\nfunction isRecord(value: unknown): value is JsonRecord {\n return typeof value === 'object' && value !== null\n}\n\nfunction requireValue<T>(value: T | null | undefined, message: string): NonNullable<T> {\n if (value == null) {\n throw new Error(message)\n }\n\n return value as NonNullable<T>\n}\n\nasync function readJson<T extends JsonRecord>(response: APIResponse): Promise<T> {\n return ((await readJsonSafe<T>(response)) ?? {}) as T\n}\n\nfunction getPresenterTitle(result: SearchResultPayload): string | null {\n if (!isRecord(result.presenter)) return null\n const title = result.presenter.title\n return typeof title === 'string' && title.trim().length > 0 ? title : null\n}\n\nfunction getSources(result: SearchResultPayload): string[] {\n if (!isRecord(result.metadata)) return []\n const rawSources = result.metadata._sources\n if (!Array.isArray(rawSources)) return []\n return rawSources.filter((source): source is string => typeof source === 'string').sort()\n}\n\nfunction getLinks(result: SearchResultPayload): Array<{ href?: unknown; label?: unknown; kind?: unknown }> {\n return Array.isArray(result.links)\n ? result.links.filter((link): link is { href?: unknown; label?: unknown; kind?: unknown } => isRecord(link))\n : []\n}\n\nfunction hasStrategy(\n settings: SearchSettingsResponse,\n id: string,\n): boolean {\n const strategies = Array.isArray(settings.settings?.strategies) ? settings.settings.strategies : []\n return strategies.some((strategy) => strategy.id === id && strategy.available === true)\n}\n\nfunction buildSearchPath(query: string): string {\n const params = new URLSearchParams({\n q: query,\n limit: '10',\n strategies: 'fulltext,tokens',\n entityTypes: 'customers:customer_company_profile',\n })\n return `/api/search/search?${params.toString()}`\n}\n\ntest.describe('TC-SEARCH-002: search endpoint merges duplicate strategy hits', () => {\n test('returns a single merged company result with both token and fulltext sources', async ({ request }) => {\n let token: string | null = null\n let companyId: string | null = null\n\n const uniqueCompanyName = `QATCSEARCH002${Date.now()}`\n let mergedResult: SearchResultPayload | null = null\n\n try {\n const authToken = await getAuthToken(request, '
|
|
5
|
-
"mappings": "AAAA,SAAS,QAAQ,YAA8B;AAC/C,SAAS,YAAY,oBAAoB;AACzC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4BP,SAAS,SAAS,OAAqC;AACrD,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;AAEA,SAAS,aAAgB,OAA6B,SAAiC;AACrF,MAAI,SAAS,MAAM;AACjB,UAAM,IAAI,MAAM,OAAO;AAAA,EACzB;AAEA,SAAO;AACT;AAEA,eAAe,SAA+B,UAAmC;AAC/E,SAAS,MAAM,aAAgB,QAAQ,KAAM,CAAC;AAChD;AAEA,SAAS,kBAAkB,QAA4C;AACrE,MAAI,CAAC,SAAS,OAAO,SAAS,EAAG,QAAO;AACxC,QAAM,QAAQ,OAAO,UAAU;AAC/B,SAAO,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS,IAAI,QAAQ;AACxE;AAEA,SAAS,WAAW,QAAuC;AACzD,MAAI,CAAC,SAAS,OAAO,QAAQ,EAAG,QAAO,CAAC;AACxC,QAAM,aAAa,OAAO,SAAS;AACnC,MAAI,CAAC,MAAM,QAAQ,UAAU,EAAG,QAAO,CAAC;AACxC,SAAO,WAAW,OAAO,CAAC,WAA6B,OAAO,WAAW,QAAQ,EAAE,KAAK;AAC1F;AAEA,SAAS,SAAS,QAAyF;AACzG,SAAO,MAAM,QAAQ,OAAO,KAAK,IAC7B,OAAO,MAAM,OAAO,CAAC,SAAsE,SAAS,IAAI,CAAC,IACzG,CAAC;AACP;AAEA,SAAS,YACP,UACA,IACS;AACT,QAAM,aAAa,MAAM,QAAQ,SAAS,UAAU,UAAU,IAAI,SAAS,SAAS,aAAa,CAAC;AAClG,SAAO,WAAW,KAAK,CAAC,aAAa,SAAS,OAAO,MAAM,SAAS,cAAc,IAAI;AACxF;AAEA,SAAS,gBAAgB,OAAuB;AAC9C,QAAM,SAAS,IAAI,gBAAgB;AAAA,IACjC,GAAG;AAAA,IACH,OAAO;AAAA,IACP,YAAY;AAAA,IACZ,aAAa;AAAA,EACf,CAAC;AACD,SAAO,sBAAsB,OAAO,SAAS,CAAC;AAChD;AAEA,KAAK,SAAS,iEAAiE,MAAM;AACnF,OAAK,+EAA+E,OAAO,EAAE,QAAQ,MAAM;AACzG,QAAI,QAAuB;AAC3B,QAAI,YAA2B;AAE/B,UAAM,oBAAoB,gBAAgB,KAAK,IAAI,CAAC;AACpD,QAAI,eAA2C;AAE/C,QAAI;AACF,YAAM,YAAY,MAAM,aAAa,SAAS,
|
|
4
|
+
"sourcesContent": ["import { expect, test, type APIResponse } from '@playwright/test'\nimport { apiRequest, getAuthToken } from '@open-mercato/core/helpers/integration/api'\nimport { getTokenContext } from '@open-mercato/core/helpers/integration/generalFixtures'\nimport {\n createCompanyFixture,\n deleteEntityIfExists,\n readJsonSafe,\n} from '@open-mercato/core/helpers/integration/crmFixtures'\n\ntype JsonRecord = Record<string, unknown>\n\ntype SearchSettingsResponse = {\n settings?: {\n strategies?: Array<{\n id?: unknown\n available?: unknown\n }>\n tokensEnabled?: unknown\n }\n}\n\ntype SearchResultPayload = {\n entityId?: unknown\n recordId?: unknown\n source?: unknown\n presenter?: unknown\n url?: unknown\n links?: unknown\n metadata?: unknown\n}\n\ntype SearchResponse = {\n results?: SearchResultPayload[]\n}\n\nfunction isRecord(value: unknown): value is JsonRecord {\n return typeof value === 'object' && value !== null\n}\n\nfunction requireValue<T>(value: T | null | undefined, message: string): NonNullable<T> {\n if (value == null) {\n throw new Error(message)\n }\n\n return value as NonNullable<T>\n}\n\nasync function readJson<T extends JsonRecord>(response: APIResponse): Promise<T> {\n return ((await readJsonSafe<T>(response)) ?? {}) as T\n}\n\nfunction getPresenterTitle(result: SearchResultPayload): string | null {\n if (!isRecord(result.presenter)) return null\n const title = result.presenter.title\n return typeof title === 'string' && title.trim().length > 0 ? title : null\n}\n\nfunction getSources(result: SearchResultPayload): string[] {\n if (!isRecord(result.metadata)) return []\n const rawSources = result.metadata._sources\n if (!Array.isArray(rawSources)) return []\n return rawSources.filter((source): source is string => typeof source === 'string').sort()\n}\n\nfunction getLinks(result: SearchResultPayload): Array<{ href?: unknown; label?: unknown; kind?: unknown }> {\n return Array.isArray(result.links)\n ? result.links.filter((link): link is { href?: unknown; label?: unknown; kind?: unknown } => isRecord(link))\n : []\n}\n\nfunction hasStrategy(\n settings: SearchSettingsResponse,\n id: string,\n): boolean {\n const strategies = Array.isArray(settings.settings?.strategies) ? settings.settings.strategies : []\n return strategies.some((strategy) => strategy.id === id && strategy.available === true)\n}\n\nfunction buildSearchPath(query: string): string {\n const params = new URLSearchParams({\n q: query,\n limit: '10',\n strategies: 'fulltext,tokens',\n entityTypes: 'customers:customer_company_profile',\n })\n return `/api/search/search?${params.toString()}`\n}\n\ntest.describe('TC-SEARCH-002: search endpoint merges duplicate strategy hits', () => {\n test('returns a single merged company result with both token and fulltext sources', async ({ request }) => {\n let token: string | null = null\n let companyId: string | null = null\n\n const uniqueCompanyName = `QATCSEARCH002${Date.now()}`\n let mergedResult: SearchResultPayload | null = null\n\n try {\n const authToken = await getAuthToken(request, 'admin')\n token = authToken\n const { organizationId, tenantId } = getTokenContext(authToken)\n expect(organizationId).not.toBe('')\n expect(tenantId).not.toBe('')\n\n const settingsResponse = await apiRequest(request, 'GET', '/api/search/settings', { token: authToken })\n expect(settingsResponse.ok()).toBeTruthy()\n const settings = await readJson<SearchSettingsResponse>(settingsResponse)\n\n if (!hasStrategy(settings, 'fulltext')) {\n test.skip(true, 'Fulltext strategy is not available in this environment')\n return\n }\n\n if (settings.settings?.tokensEnabled !== true) {\n test.skip(true, 'Token search is disabled in this environment')\n return\n }\n\n companyId = await createCompanyFixture(request, authToken, uniqueCompanyName)\n\n await expect\n .poll(\n async () => {\n const searchResponse = await apiRequest(request, 'GET', buildSearchPath(uniqueCompanyName), {\n token: authToken,\n })\n if (!searchResponse.ok()) {\n mergedResult = null\n return 'response-not-ok'\n }\n\n const searchBody = await readJson<SearchResponse>(searchResponse)\n const results = Array.isArray(searchBody.results) ? searchBody.results : []\n const matchingResults = results.filter((result) => getPresenterTitle(result) === uniqueCompanyName)\n\n if (matchingResults.length !== 1) {\n mergedResult = null\n return `matches:${matchingResults.length}`\n }\n\n const candidate = matchingResults[0]\n const sources = getSources(candidate)\n if (sources.join(',') !== 'fulltext,tokens') {\n mergedResult = null\n return sources.join(',') || 'missing-sources'\n }\n\n mergedResult = candidate\n return sources.join(',')\n },\n { timeout: 15_000 },\n )\n .toBe('fulltext,tokens')\n\n const ensuredMergedResult = requireValue<SearchResultPayload>(\n mergedResult,\n 'Expected merged result from search response',\n )\n\n expect(ensuredMergedResult.source).toBe('fulltext')\n expect(getPresenterTitle(ensuredMergedResult)).toBe(uniqueCompanyName)\n\n const metadata = isRecord(ensuredMergedResult.metadata) ? ensuredMergedResult.metadata : {}\n expect(typeof metadata._rrfScore).toBe('number')\n\n expect(ensuredMergedResult.entityId).toBe('customers:customer_company_profile')\n\n const expectedCompanyUrl = `/backend/customers/companies-v2/${encodeURIComponent(requireValue(companyId, 'Expected the created company id'))}`\n expect(ensuredMergedResult.url).toBe(expectedCompanyUrl)\n\n const links = getLinks(ensuredMergedResult)\n expect(\n links.some((link) => link.href === `${expectedCompanyUrl}/edit` && link.kind === 'secondary'),\n ).toBeTruthy()\n } finally {\n await deleteEntityIfExists(request, token, '/api/customers/companies', companyId)\n }\n })\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,QAAQ,YAA8B;AAC/C,SAAS,YAAY,oBAAoB;AACzC,SAAS,uBAAuB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4BP,SAAS,SAAS,OAAqC;AACrD,SAAO,OAAO,UAAU,YAAY,UAAU;AAChD;AAEA,SAAS,aAAgB,OAA6B,SAAiC;AACrF,MAAI,SAAS,MAAM;AACjB,UAAM,IAAI,MAAM,OAAO;AAAA,EACzB;AAEA,SAAO;AACT;AAEA,eAAe,SAA+B,UAAmC;AAC/E,SAAS,MAAM,aAAgB,QAAQ,KAAM,CAAC;AAChD;AAEA,SAAS,kBAAkB,QAA4C;AACrE,MAAI,CAAC,SAAS,OAAO,SAAS,EAAG,QAAO;AACxC,QAAM,QAAQ,OAAO,UAAU;AAC/B,SAAO,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,SAAS,IAAI,QAAQ;AACxE;AAEA,SAAS,WAAW,QAAuC;AACzD,MAAI,CAAC,SAAS,OAAO,QAAQ,EAAG,QAAO,CAAC;AACxC,QAAM,aAAa,OAAO,SAAS;AACnC,MAAI,CAAC,MAAM,QAAQ,UAAU,EAAG,QAAO,CAAC;AACxC,SAAO,WAAW,OAAO,CAAC,WAA6B,OAAO,WAAW,QAAQ,EAAE,KAAK;AAC1F;AAEA,SAAS,SAAS,QAAyF;AACzG,SAAO,MAAM,QAAQ,OAAO,KAAK,IAC7B,OAAO,MAAM,OAAO,CAAC,SAAsE,SAAS,IAAI,CAAC,IACzG,CAAC;AACP;AAEA,SAAS,Y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B,WAAW,KAAK,SAAS,WAAW;AAAA,MAC9F,EAAE,WAAW;AAAA,IACf,UAAE;AACA,YAAM,qBAAqB,SAAS,OAAO,4BAA4B,SAAS;AAAA,IAClF;AAAA,EACF,CAAC;AACH,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -18,6 +18,7 @@ test("TC-SEARCH-015: Polish settings show environment hints and isolated unavail
|
|
|
18
18
|
test.setTimeout(12e4);
|
|
19
19
|
const token = await getAuthToken(request, "admin");
|
|
20
20
|
const { organizationId } = getTokenContext(token);
|
|
21
|
+
const longIndexPrefix = "search_namespace_".repeat(40);
|
|
21
22
|
const stamp = randomUUID();
|
|
22
23
|
const email = `search-diagnostics-${stamp}@example.com`;
|
|
23
24
|
const password = `Search-015-${stamp}!`;
|
|
@@ -53,17 +54,49 @@ test("TC-SEARCH-015: Polish settings show environment hints and isolated unavail
|
|
|
53
54
|
settings: { ...body.settings, embeddingConfig: null, configuredProviders: [], providerAvailability: [missingKey, unreachable] }
|
|
54
55
|
} });
|
|
55
56
|
});
|
|
57
|
+
await page.route("**/api/search/settings/fulltext", async (route) => {
|
|
58
|
+
const response = await route.fetch();
|
|
59
|
+
expect(response.status()).toBe(200);
|
|
60
|
+
const body = await response.json();
|
|
61
|
+
await route.fulfill({ response, json: {
|
|
62
|
+
...body,
|
|
63
|
+
optionalEnvVars: {
|
|
64
|
+
...body.optionalEnvVars,
|
|
65
|
+
MEILISEARCH_INDEX_PREFIX: {
|
|
66
|
+
...body.optionalEnvVars.MEILISEARCH_INDEX_PREFIX,
|
|
67
|
+
set: true,
|
|
68
|
+
value: longIndexPrefix
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} });
|
|
72
|
+
});
|
|
73
|
+
await page.setViewportSize({ width: 390, height: 844 });
|
|
56
74
|
await page.goto("/backend/config/search");
|
|
57
75
|
for (const key of ["host", "apiKey", "indexPrefix", "excludeEncrypted"]) {
|
|
58
76
|
await expect(page.getByText(translate(`search.settings.fulltext.hints.${key}`), { exact: true })).toBeVisible();
|
|
59
77
|
}
|
|
60
78
|
await expect(page.getByText(missingKey.reason, { exact: true })).toBeVisible();
|
|
61
79
|
await expect(page.getByText(unreachable.reason, { exact: true })).toBeVisible();
|
|
80
|
+
const prefixValue = page.getByText(longIndexPrefix, { exact: false });
|
|
81
|
+
await expect(prefixValue).toBeVisible();
|
|
82
|
+
for (const width of [390, 1440]) {
|
|
83
|
+
await page.setViewportSize({ width, height: 900 });
|
|
84
|
+
await expect.poll(() => page.evaluate(() => ({
|
|
85
|
+
documentWidth: document.documentElement.scrollWidth,
|
|
86
|
+
bodyWidth: document.body.scrollWidth,
|
|
87
|
+
viewportWidth: window.innerWidth
|
|
88
|
+
}))).toEqual({ documentWidth: width, bodyWidth: width, viewportWidth: width });
|
|
89
|
+
const bounds = await prefixValue.boundingBox();
|
|
90
|
+
expect(bounds).not.toBeNull();
|
|
91
|
+
expect(bounds.x).toBeGreaterThanOrEqual(0);
|
|
92
|
+
expect(bounds.x + bounds.width).toBeLessThanOrEqual(width);
|
|
93
|
+
}
|
|
62
94
|
await expect(page.getByRole("button", { name: /OpenAI/ })).toBeDisabled();
|
|
63
95
|
await expect(page.getByRole("button", { name: /Ollama/ })).toBeDisabled();
|
|
64
96
|
await expect(page.locator("body")).not.toContainText(/The URL of your|API key for authentication|Set OPENAI_API_KEY|Ollama not reachable|search\.settings\.(fulltext\.hints|providers\.diagnostics)/);
|
|
65
97
|
} finally {
|
|
66
98
|
await page.unroute("**/api/search/embeddings");
|
|
99
|
+
await page.unroute("**/api/search/settings/fulltext");
|
|
67
100
|
await page.context().clearCookies();
|
|
68
101
|
await deleteUserIfExists(request, token, userId);
|
|
69
102
|
await deleteRoleIfExists(request, token, roleId);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/modules/search/__integration__/TC-SEARCH-015.spec.ts"],
|
|
4
|
-
"sourcesContent": ["import { randomUUID } from 'node:crypto'\nimport { expect, test } from '@playwright/test'\nimport { getAuthToken } from '@open-mercato/core/helpers/integration/api'\nimport {\n createRoleFixture, createUserFixture, deleteRoleIfExists, deleteUserIfExists, setRoleAclFeatures,\n} from '@open-mercato/core/helpers/integration/authFixtures'\nimport { getTokenContext } from '@open-mercato/core/helpers/integration/generalFixtures'\nimport { acknowledgeGlobalNotices } from '@open-mercato/core/helpers/integration/auth'\nimport { createTranslator } from '@open-mercato/shared/lib/i18n/translate'\nimport { localizeProviderAvailability } from '../lib/provider-diagnostics'\nimport pl from '../i18n/pl.json' with { type: 'json' }\n\nexport const integrationMeta = { dependsOnModules: ['search', 'auth'] }\n\ntest('TC-SEARCH-015: Polish settings show environment hints and isolated unavailable-provider diagnostics', async ({ page, request, baseURL }) => {\n test.setTimeout(120_000)\n const token = await getAuthToken(request, 'admin')\n const { organizationId } = getTokenContext(token)\n const stamp = randomUUID()\n const email = `search-diagnostics-${stamp}@example.com`\n const password = `Search-015-${stamp}!`\n let roleId: string | null = null\n let userId: string | null = null\n const translate = createTranslator(pl)\n const missingKey = localizeProviderAvailability({\n providerId: 'openai', available: false, reason: 'Set OPENAI_API_KEY to enable OpenAI',\n diagnostic: { key: 'missingKey', params: { envKey: 'OPENAI_API_KEY', provider: 'OpenAI' } },\n }, translate)\n const unreachable = localizeProviderAvailability({\n providerId: 'ollama', available: false, reason: 'Ollama not reachable',\n diagnostic: { key: 'ollamaTimeout', params: { baseUrl: 'http://ollama.test:11434' } },\n }, translate)\n try {\n roleId = await createRoleFixture(request, token, { name: `search-diagnostics-${stamp}` })\n await setRoleAclFeatures(request, token, { roleId, features: ['search.view', 'search.embeddings.view'] })\n userId = await createUserFixture(request, token, { email, password, organizationId, roles: [roleId] })\n const login = await page.request.post('/api/auth/login', { form: { email, password } })\n expect(login.ok()).toBeTruthy()\n await acknowledgeGlobalNotices(page)\n await page.context().addCookies([{ name: 'locale', value: 'pl', url: baseURL ?? 'http://localhost:3000' }])\n await page.route('**/api/search/embeddings', async (route) => {\n const response = await route.fetch()\n expect(response.status()).toBe(200)\n const body = await response.json()\n await route.fulfill({ response, json: {\n ...body,\n settings: { ...body.settings, embeddingConfig: null, configuredProviders: [], providerAvailability: [missingKey, unreachable] },\n } })\n })\n await page.goto('/backend/config/search')\n for (const key of ['host', 'apiKey', 'indexPrefix', 'excludeEncrypted']) {\n await expect(page.getByText(translate(`search.settings.fulltext.hints.${key}`), { exact: true })).toBeVisible()\n }\n await expect(page.getByText(missingKey.reason!, { exact: true })).toBeVisible()\n await expect(page.getByText(unreachable.reason!, { exact: true })).toBeVisible()\n await expect(page.getByRole('button', { name: /OpenAI/ })).toBeDisabled()\n await expect(page.getByRole('button', { name: /Ollama/ })).toBeDisabled()\n await expect(page.locator('body')).not.toContainText(/The URL of your|API key for authentication|Set OPENAI_API_KEY|Ollama not reachable|search\\.settings\\.(fulltext\\.hints|providers\\.diagnostics)/)\n } finally {\n await page.unroute('**/api/search/embeddings')\n await page.context().clearCookies()\n await deleteUserIfExists(request, token, userId)\n await deleteRoleIfExists(request, token, roleId)\n }\n})\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7B;AAAA,EACE;AAAA,EAAmB;AAAA,EAAmB;AAAA,EAAoB;AAAA,EAAoB;AAAA,OACzE;AACP,SAAS,uBAAuB;AAChC,SAAS,gCAAgC;AACzC,SAAS,wBAAwB;AACjC,SAAS,oCAAoC;AAC7C,OAAO,QAAQ;AAER,MAAM,kBAAkB,EAAE,kBAAkB,CAAC,UAAU,MAAM,EAAE;AAEtE,KAAK,uGAAuG,OAAO,EAAE,MAAM,SAAS,QAAQ,MAAM;AAChJ,OAAK,WAAW,IAAO;AACvB,QAAM,QAAQ,MAAM,aAAa,SAAS,OAAO;AACjD,QAAM,EAAE,eAAe,IAAI,gBAAgB,KAAK;AAChD,QAAM,QAAQ,WAAW;AACzB,QAAM,QAAQ,sBAAsB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AA,QACpC,GAAG;AAAA,QACH,UAAU,EAAE,GAAG,KAAK,UAAU,iBAAiB,MAAM,qBAAqB,CAAC,GAAG,sBAAsB,CAAC,YAAY,WAAW,EAAE;AAAA,MAChI,EAAE,CAAC;AAAA,IACL,CAAC;AACD,UAAM,KAAK,KAAK,wBAAwB;AACxC,eAAW,OAAO,CAAC,QAAQ,UAAU,eAAe,kBAAkB,GAAG;AACvE,YAAM,OAAO,KAAK,UAAU,UAAU,kCAAkC,GAAG,EAAE,GAAG,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,YAAY;AAAA,IAChH;AACA,UAAM,OAAO,KAAK,UAAU,WAAW,QAAS,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,YAAY;AAC9E,UAAM,OAAO,KAAK,UAAU,YAAY,QAAS,EAAE,OAAO,KAAK,CAAC,CAAC,EAAE,YAAY;AAC/E,UAAM,OAAO,KAAK,UAAU,UAAU,EAAE,MAAM,SAAS,CAAC,CAAC,EAAE,aAAa;AACxE,UAAM,OAAO,KAAK,UAAU,UAAU,EAAE,MAAM,SAAS,CAAC,CAAC,EAAE,aAAa;AACxE,UAAM,OAAO,KAAK,QAAQ,MAAM,CAAC,EAAE,IAAI,cAAc,+IAA+I;AAAA,EACtM,UAAE;AACA,UAAM,KAAK,QAAQ,0BAA0B;AAC7C,UAAM,KAAK,QAAQ,EAAE,aAAa;AAClC,UAAM,mBAAmB,SAAS,OAAO,MAAM;AAC/C,UAAM,mBAAmB,SAAS,OAAO,MAAM;AAAA,EACjD;AACF,CAAC;",
|
|
4
|
+
"sourcesContent": ["import { randomUUID } from 'node:crypto'\nimport { expect, test } from '@playwright/test'\nimport { getAuthToken } from '@open-mercato/core/helpers/integration/api'\nimport {\n createRoleFixture, createUserFixture, deleteRoleIfExists, deleteUserIfExists, setRoleAclFeatures,\n} from '@open-mercato/core/helpers/integration/authFixtures'\nimport { getTokenContext } from '@open-mercato/core/helpers/integration/generalFixtures'\nimport { acknowledgeGlobalNotices } from '@open-mercato/core/helpers/integration/auth'\nimport { createTranslator } from '@open-mercato/shared/lib/i18n/translate'\nimport { localizeProviderAvailability } from '../lib/provider-diagnostics'\nimport pl from '../i18n/pl.json' with { type: 'json' }\n\nexport const integrationMeta = { dependsOnModules: ['search', 'auth'] }\n\ntest('TC-SEARCH-015: Polish settings show environment hints and isolated unavailable-provider diagnostics', async ({ page, request, baseURL }) => {\n test.setTimeout(120_000)\n const token = await getAuthToken(request, 'admin')\n const { organizationId } = getTokenContext(token)\n const longIndexPrefix = 'search_namespace_'.repeat(40)\n const stamp = randomUUID()\n const email = `search-diagnostics-${stamp}@example.com`\n const password = `Search-015-${stamp}!`\n let roleId: string | null = null\n let userId: string | null = null\n const translate = createTranslator(pl)\n const missingKey = localizeProviderAvailability({\n providerId: 'openai', available: false, reason: 'Set OPENAI_API_KEY to enable OpenAI',\n diagnostic: { key: 'missingKey', params: { envKey: 'OPENAI_API_KEY', provider: 'OpenAI' } },\n }, translate)\n const unreachable = localizeProviderAvailability({\n providerId: 'ollama', available: false, reason: 'Ollama not reachable',\n diagnostic: { key: 'ollamaTimeout', params: { baseUrl: 'http://ollama.test:11434' } },\n }, translate)\n try {\n roleId = await createRoleFixture(request, token, { name: `search-diagnostics-${stamp}` })\n await setRoleAclFeatures(request, token, { roleId, features: ['search.view', 'search.embeddings.view'] })\n userId = await createUserFixture(request, token, { email, password, organizationId, roles: [roleId] })\n const login = await page.request.post('/api/auth/login', { form: { email, password } })\n expect(login.ok()).toBeTruthy()\n await acknowledgeGlobalNotices(page)\n await page.context().addCookies([{ name: 'locale', value: 'pl', url: baseURL ?? 'http://localhost:3000' }])\n await page.route('**/api/search/embeddings', async (route) => {\n const response = await route.fetch()\n expect(response.status()).toBe(200)\n const body = await response.json()\n await route.fulfill({ response, json: {\n ...body,\n settings: { ...body.settings, embeddingConfig: null, configuredProviders: [], providerAvailability: [missingKey, unreachable] },\n } })\n })\n await page.route('**/api/search/settings/fulltext', async (route) => {\n const response = await route.fetch()\n expect(response.status()).toBe(200)\n const body = await response.json()\n await route.fulfill({ response, json: {\n ...body,\n optionalEnvVars: {\n ...body.optionalEnvVars,\n MEILISEARCH_INDEX_PREFIX: {\n ...body.optionalEnvVars.MEILISEARCH_INDEX_PREFIX,\n set: true,\n value: longIndexPrefix,\n },\n },\n } })\n })\n await page.setViewportSize({ width: 390, height: 844 })\n await page.goto('/backend/config/search')\n for (const key of ['host', 'apiKey', 'indexPrefix', 'excludeEncrypted']) {\n await expect(page.getByText(translate(`search.settings.fulltext.hints.${key}`), { exact: true })).toBeVisible()\n }\n await expect(page.getByText(missingKey.reason!, { exact: true })).toBeVisible()\n await expect(page.getByText(unreachable.reason!, { exact: true })).toBeVisible()\n const prefixValue = page.getByText(longIndexPrefix, { exact: false })\n await expect(prefixValue).toBeVisible()\n for (const width of [390, 1440]) {\n await page.setViewportSize({ width, height: 900 })\n await expect.poll(() => page.evaluate(() => ({\n documentWidth: document.documentElement.scrollWidth,\n bodyWidth: document.body.scrollWidth,\n viewportWidth: window.innerWidth,\n }))).toEqual({ documentWidth: width, bodyWidth: width, viewportWidth: width })\n const bounds = await prefixValue.boundingBox()\n expect(bounds).not.toBeNull()\n expect(bounds!.x).toBeGreaterThanOrEqual(0)\n expect(bounds!.x + bounds!.width).toBeLessThanOrEqual(width)\n }\n await expect(page.getByRole('button', { name: /OpenAI/ })).toBeDisabled()\n await expect(page.getByRole('button', { name: /Ollama/ })).toBeDisabled()\n await expect(page.locator('body')).not.toContainText(/The URL of your|API key for authentication|Set OPENAI_API_KEY|Ollama not reachable|search\\.settings\\.(fulltext\\.hints|providers\\.diagnostics)/)\n } finally {\n await page.unroute('**/api/search/embeddings')\n await page.unroute('**/api/search/settings/fulltext')\n await page.context().clearCookies()\n await deleteUserIfExists(request, token, userId)\n await deleteRoleIfExists(request, token, roleId)\n }\n})\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,kBAAkB;AAC3B,SAAS,QAAQ,YAAY;AAC7B,SAAS,oBAAoB;AAC7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,QAAQ,EAAE,aAAa;AAClC,UAAM,mBAAmB,SAAS,OAAO,MAAM;AAC/C,UAAM,mBAAmB,SAAS,OAAO,MAAM;AAAA,EACjD;AACF,CAAC;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -231,7 +231,7 @@ function SearchSettingsPageClient() {
|
|
|
231
231
|
const handleEmbeddingSettingsUpdate = React.useCallback((newSettings) => {
|
|
232
232
|
setEmbeddingSettings(newSettings);
|
|
233
233
|
}, []);
|
|
234
|
-
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
234
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col gap-6", children: [
|
|
235
235
|
/* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
236
236
|
/* @__PURE__ */ jsx("h1", { className: "text-2xl font-bold", children: t("search.settings.pageTitle", "Search Settings") }),
|
|
237
237
|
/* @__PURE__ */ jsx("p", { className: "text-muted-foreground", children: t("search.settings.pageDescription", "Configure search strategies and view their availability.") })
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/modules/search/frontend/components/SearchSettingsPageClient.tsx"],
|
|
4
|
-
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { useAppEvent } from '@open-mercato/ui/backend/injection/useAppEvent'\nimport { GlobalSearchSection } from './sections/GlobalSearchSection'\nimport { FulltextSearchSection } from './sections/FulltextSearchSection'\nimport { VectorSearchSection } from './sections/VectorSearchSection'\n\n// Types\ntype StrategyStatus = {\n id: string\n name: string\n priority: number\n available: boolean\n}\n\ntype FulltextStats = {\n numberOfDocuments: number\n isIndexing: boolean\n fieldDistribution: Record<string, number>\n}\n\ntype ReindexLock = {\n type: 'fulltext' | 'vector'\n action: string\n startedAt: string\n elapsedMinutes: number\n}\n\ntype SearchSettings = {\n strategies: StrategyStatus[]\n fulltextConfigured: boolean\n fulltextStats: FulltextStats | null\n vectorConfigured: boolean\n tokensEnabled: boolean\n defaultStrategies: string[]\n reindexLock: ReindexLock | null\n fulltextReindexLock: ReindexLock | null\n vectorReindexLock: ReindexLock | null\n}\n\ntype SettingsResponse = {\n settings?: SearchSettings\n error?: string\n}\n\n// Embedding types\ntype EmbeddingProviderId = 'openai' | 'google' | 'mistral' | 'cohere' | 'bedrock' | 'ollama'\n\ntype EmbeddingProviderConfig = {\n providerId: EmbeddingProviderId\n model: string\n dimension: number\n outputDimensionality?: number\n baseUrl?: string\n updatedAt: string\n}\n\ntype EmbeddingSettings = {\n openaiConfigured: boolean\n autoIndexingEnabled: boolean\n autoIndexingLocked: boolean\n lockReason: string | null\n embeddingConfig: EmbeddingProviderConfig | null\n configuredProviders: EmbeddingProviderId[]\n indexedDimension: number | null\n reindexRequired: boolean\n documentCount: number | null\n}\n\ntype EmbeddingSettingsResponse = {\n settings?: EmbeddingSettings\n error?: string\n}\n\n// Full-text search config types\ntype FulltextEnvVarStatus = {\n set: boolean\n hint: string\n}\n\ntype FulltextOptionalEnvVarStatus = {\n set: boolean\n value?: string | boolean\n default?: string | boolean\n hint: string\n}\n\ntype FulltextConfigResponse = {\n driver: 'meilisearch' | null\n configured: boolean\n envVars: {\n MEILISEARCH_HOST: FulltextEnvVarStatus\n MEILISEARCH_API_KEY: FulltextEnvVarStatus\n }\n optionalEnvVars: {\n MEILISEARCH_INDEX_PREFIX: FulltextOptionalEnvVarStatus\n SEARCH_EXCLUDE_ENCRYPTED_FIELDS: FulltextOptionalEnvVarStatus\n }\n}\n\n// Vector store driver types\ntype VectorDriverId = 'pgvector' | 'qdrant' | 'chromadb'\n\ntype VectorDriverEnvVar = {\n name: string\n set: boolean\n hint: string\n}\n\ntype VectorDriverStatus = {\n id: VectorDriverId\n name: string\n configured: boolean\n implemented: boolean\n available?: boolean | null\n unavailableReason?: string | null\n envVars: VectorDriverEnvVar[]\n}\n\ntype VectorStoreConfigResponse = {\n currentDriver: VectorDriverId\n configured: boolean\n drivers: VectorDriverStatus[]\n}\n\nconst normalizeErrorMessage = (error: unknown, fallback: string): string => {\n if (typeof error === 'string' && error.trim().length) return error.trim()\n if (error instanceof Error && error.message.trim().length) return error.message.trim()\n return fallback\n}\n\nexport function SearchSettingsPageClient() {\n const t = useT()\n\n // Main settings state\n const [settings, setSettings] = React.useState<SearchSettings | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n\n // Embedding settings state\n const [embeddingSettings, setEmbeddingSettings] = React.useState<EmbeddingSettings | null>(null)\n const [embeddingLoading, setEmbeddingLoading] = React.useState(true)\n\n // Global search settings state\n const [globalSearchStrategies, setGlobalSearchStrategies] = React.useState<Set<string>>(() => new Set(['fulltext', 'vector', 'tokens']))\n const [globalSearchInitial, setGlobalSearchInitial] = React.useState<Set<string>>(() => new Set(['fulltext', 'vector', 'tokens']))\n const [globalSearchLoading, setGlobalSearchLoading] = React.useState(true)\n const [globalSearchSaving, setGlobalSearchSaving] = React.useState(false)\n\n // Full-text search config state\n const [fulltextConfig, setFulltextConfig] = React.useState<FulltextConfigResponse | null>(null)\n const [fulltextConfigLoading, setFulltextConfigLoading] = React.useState(true)\n\n // Vector store config state\n const [vectorStoreConfig, setVectorStoreConfig] = React.useState<VectorStoreConfigResponse | null>(null)\n const [vectorStoreConfigLoading, setVectorStoreConfigLoading] = React.useState(true)\n\n // Fetch main settings\n const fetchSettings = React.useCallback(async () => {\n setLoading(true)\n setError(null)\n try {\n const body = await readApiResultOrThrow<SettingsResponse>(\n '/api/search/settings',\n undefined,\n { errorMessage: t('search.settings.errorLabel', 'Failed to load settings'), allowNullResult: true },\n )\n if (body?.settings) {\n setSettings(body.settings)\n } else {\n setSettings({\n strategies: [],\n fulltextConfigured: false,\n fulltextStats: null,\n vectorConfigured: false,\n tokensEnabled: true,\n defaultStrategies: [],\n reindexLock: null,\n fulltextReindexLock: null,\n vectorReindexLock: null,\n })\n }\n } catch (err) {\n const message = normalizeErrorMessage(err, t('search.settings.errorLabel', 'Failed to load settings'))\n setError(message)\n flash(message, 'error')\n } finally {\n setLoading(false)\n }\n }, [t])\n\n React.useEffect(() => {\n fetchSettings()\n }, [fetchSettings])\n\n // Lightweight stats refresh for polling during reindex\n const refreshStatsOnly = React.useCallback(async () => {\n try {\n const body = await readApiResultOrThrow<SettingsResponse>(\n '/api/search/settings',\n { cache: 'no-store' },\n { errorMessage: '', allowNullResult: true },\n )\n if (body?.settings) {\n setSettings(body.settings)\n }\n } catch {\n // Silently ignore errors during polling\n }\n }, [])\n\n const hasActiveReindexLock = Boolean(settings?.fulltextReindexLock || settings?.vectorReindexLock)\n React.useEffect(() => {\n if (!hasActiveReindexLock) return\n\n const interval = setInterval(() => {\n void refreshStatsOnly()\n }, 5000)\n\n return () => clearInterval(interval)\n }, [hasActiveReindexLock, refreshStatsOnly])\n\n // Lightweight embedding stats refresh\n const refreshEmbeddingStatsOnly = React.useCallback(async () => {\n try {\n const body = await readApiResultOrThrow<EmbeddingSettingsResponse>(\n '/api/search/embeddings',\n { cache: 'no-store' },\n { errorMessage: '', allowNullResult: true },\n )\n if (body?.settings) {\n setEmbeddingSettings(body.settings)\n }\n } catch {\n // Silently ignore errors during polling\n }\n }, [])\n\n useAppEvent('progress.job.updated', () => {\n void refreshStatsOnly()\n void refreshEmbeddingStatsOnly()\n }, [refreshStatsOnly, refreshEmbeddingStatsOnly])\n\n useAppEvent('progress.job.completed', () => {\n void refreshStatsOnly()\n void refreshEmbeddingStatsOnly()\n }, [refreshStatsOnly, refreshEmbeddingStatsOnly])\n\n useAppEvent('om:bridge:reconnected', () => {\n void refreshStatsOnly()\n void refreshEmbeddingStatsOnly()\n }, [refreshStatsOnly, refreshEmbeddingStatsOnly])\n\n // Fetch embedding settings\n const fetchEmbeddingSettings = React.useCallback(async () => {\n setEmbeddingLoading(true)\n try {\n const body = await readApiResultOrThrow<EmbeddingSettingsResponse>(\n '/api/search/embeddings',\n undefined,\n { errorMessage: t('search.settings.errors.loadFailed', 'Failed to load settings'), allowNullResult: true },\n )\n if (body?.settings) {\n setEmbeddingSettings(body.settings)\n } else {\n setEmbeddingSettings({\n openaiConfigured: false,\n autoIndexingEnabled: true,\n autoIndexingLocked: false,\n lockReason: null,\n embeddingConfig: null,\n configuredProviders: [],\n indexedDimension: null,\n reindexRequired: false,\n documentCount: null,\n })\n }\n } catch {\n // Error already handled\n } finally {\n setEmbeddingLoading(false)\n }\n }, [t])\n\n React.useEffect(() => {\n fetchEmbeddingSettings()\n }, [fetchEmbeddingSettings])\n\n // Fetch global search settings\n const fetchGlobalSearchSettings = React.useCallback(async () => {\n setGlobalSearchLoading(true)\n try {\n const response = await fetch('/api/search/settings/global-search')\n if (response.ok) {\n const body = await response.json() as { enabledStrategies?: string[] }\n if (body.enabledStrategies && Array.isArray(body.enabledStrategies) && body.enabledStrategies.length > 0) {\n const strategies = new Set(body.enabledStrategies)\n setGlobalSearchStrategies(strategies)\n setGlobalSearchInitial(new Set(strategies))\n }\n }\n } catch {\n // Silently use defaults\n } finally {\n setGlobalSearchLoading(false)\n }\n }, [])\n\n React.useEffect(() => {\n fetchGlobalSearchSettings()\n }, [fetchGlobalSearchSettings])\n\n // Fetch fulltext config\n const fetchFulltextConfig = React.useCallback(async () => {\n setFulltextConfigLoading(true)\n try {\n const response = await fetch('/api/search/settings/fulltext')\n if (response.ok) {\n const body = await response.json() as FulltextConfigResponse\n setFulltextConfig(body)\n }\n } catch {\n // Silently use null\n } finally {\n setFulltextConfigLoading(false)\n }\n }, [])\n\n React.useEffect(() => {\n fetchFulltextConfig()\n }, [fetchFulltextConfig])\n\n // Fetch vector store config\n const fetchVectorStoreConfig = React.useCallback(async () => {\n setVectorStoreConfigLoading(true)\n try {\n const response = await fetch('/api/search/settings/vector-store')\n if (response.ok) {\n const body = await response.json() as VectorStoreConfigResponse\n setVectorStoreConfig(body)\n }\n } catch {\n // Silently use null\n } finally {\n setVectorStoreConfigLoading(false)\n }\n }, [])\n\n React.useEffect(() => {\n fetchVectorStoreConfig()\n }, [fetchVectorStoreConfig])\n\n // Global search settings handlers - auto-save on toggle\n const toggleGlobalSearchStrategy = React.useCallback(async (strategyId: string) => {\n const newStrategies = new Set(globalSearchStrategies)\n if (newStrategies.has(strategyId)) {\n if (newStrategies.size > 1) {\n newStrategies.delete(strategyId)\n } else {\n return\n }\n } else {\n newStrategies.add(strategyId)\n }\n\n setGlobalSearchStrategies(newStrategies)\n setGlobalSearchSaving(true)\n\n try {\n const response = await fetch('/api/search/settings/global-search', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ enabledStrategies: Array.from(newStrategies) }),\n })\n\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error || t('search.settings.globalSearch.saveError', 'Failed to save settings'))\n }\n\n setGlobalSearchInitial(new Set(newStrategies))\n } catch (err) {\n setGlobalSearchStrategies(globalSearchInitial)\n flash(normalizeErrorMessage(err, t('search.settings.globalSearch.saveError', 'Failed to save settings')), 'error')\n } finally {\n setGlobalSearchSaving(false)\n }\n }, [globalSearchStrategies, globalSearchInitial, t])\n\n // Callbacks for section components\n const handleFulltextStatsUpdate = React.useCallback((stats: FulltextStats | null) => {\n setSettings(prev => prev ? { ...prev, fulltextStats: stats } : prev)\n }, [])\n\n const handleEmbeddingSettingsUpdate = React.useCallback((newSettings: EmbeddingSettings) => {\n setEmbeddingSettings(newSettings)\n }, [])\n\n return (\n <div className=\"flex flex-col gap-6\">\n {/* Header */}\n <div className=\"space-y-1\">\n <h1 className=\"text-2xl font-bold\">{t('search.settings.pageTitle', 'Search Settings')}</h1>\n <p className=\"text-muted-foreground\">{t('search.settings.pageDescription', 'Configure search strategies and view their availability.')}</p>\n </div>\n\n {/* Section 1: Global Search Settings */}\n <GlobalSearchSection\n loading={globalSearchLoading}\n saving={globalSearchSaving}\n strategies={globalSearchStrategies}\n fulltextConfigured={settings?.fulltextConfigured ?? false}\n vectorConfigured={settings?.vectorConfigured ?? false}\n onToggleStrategy={toggleGlobalSearchStrategy}\n />\n\n {/* Section 2: Full-Text Search (with tabs) */}\n <FulltextSearchSection\n fulltextConfig={fulltextConfig}\n fulltextConfigLoading={fulltextConfigLoading}\n fulltextStats={settings?.fulltextStats ?? null}\n fulltextReindexLock={settings?.fulltextReindexLock ?? null}\n loading={loading}\n onStatsUpdate={handleFulltextStatsUpdate}\n onRefresh={fetchSettings}\n />\n\n {/* Section 3: Vector Search (with tabs) */}\n <VectorSearchSection\n embeddingSettings={embeddingSettings}\n embeddingLoading={embeddingLoading}\n vectorStoreConfig={vectorStoreConfig}\n vectorStoreConfigLoading={vectorStoreConfigLoading}\n vectorReindexLock={settings?.vectorReindexLock ?? null}\n onEmbeddingSettingsUpdate={handleEmbeddingSettingsUpdate}\n onRefreshEmbeddings={fetchEmbeddingSettings}\n />\n\n {/* Refresh Button */}\n <div className=\"flex items-center gap-3\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => fetchSettings()}\n disabled={loading}\n >\n {loading ? (\n <>\n <Spinner size=\"sm\" className=\"mr-2\" />\n {t('search.settings.loadingLabel', 'Loading settings...')}\n </>\n ) : (\n t('search.settings.refreshLabel', 'Refresh')\n )}\n </Button>\n {error && <span className=\"text-sm text-destructive\">{error}</span>}\n </div>\n </div>\n )\n}\n\nexport default SearchSettingsPageClient\n"],
|
|
5
|
-
"mappings": ";AAuZM,SA+CM,UA9CJ,KADF;AArZN,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,4BAA4B;AACrC,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AAC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,IAAI,IAAI;AAAA,EACrE,GAAG,CAAC,CAAC;AAEL,QAAM,gCAAgC,MAAM,YAAY,CAAC,gBAAmC;AAC1F,yBAAqB,WAAW;AAAA,EAClC,GAAG,CAAC,CAAC;AAEL,SACE,qBAAC,SAAI,WAAU
|
|
4
|
+
"sourcesContent": ["'use client'\n\nimport * as React from 'react'\nimport { useT } from '@open-mercato/shared/lib/i18n/context'\nimport { readApiResultOrThrow } from '@open-mercato/ui/backend/utils/apiCall'\nimport { flash } from '@open-mercato/ui/backend/FlashMessages'\nimport { Button } from '@open-mercato/ui/primitives/button'\nimport { Spinner } from '@open-mercato/ui/primitives/spinner'\nimport { useAppEvent } from '@open-mercato/ui/backend/injection/useAppEvent'\nimport { GlobalSearchSection } from './sections/GlobalSearchSection'\nimport { FulltextSearchSection } from './sections/FulltextSearchSection'\nimport { VectorSearchSection } from './sections/VectorSearchSection'\n\n// Types\ntype StrategyStatus = {\n id: string\n name: string\n priority: number\n available: boolean\n}\n\ntype FulltextStats = {\n numberOfDocuments: number\n isIndexing: boolean\n fieldDistribution: Record<string, number>\n}\n\ntype ReindexLock = {\n type: 'fulltext' | 'vector'\n action: string\n startedAt: string\n elapsedMinutes: number\n}\n\ntype SearchSettings = {\n strategies: StrategyStatus[]\n fulltextConfigured: boolean\n fulltextStats: FulltextStats | null\n vectorConfigured: boolean\n tokensEnabled: boolean\n defaultStrategies: string[]\n reindexLock: ReindexLock | null\n fulltextReindexLock: ReindexLock | null\n vectorReindexLock: ReindexLock | null\n}\n\ntype SettingsResponse = {\n settings?: SearchSettings\n error?: string\n}\n\n// Embedding types\ntype EmbeddingProviderId = 'openai' | 'google' | 'mistral' | 'cohere' | 'bedrock' | 'ollama'\n\ntype EmbeddingProviderConfig = {\n providerId: EmbeddingProviderId\n model: string\n dimension: number\n outputDimensionality?: number\n baseUrl?: string\n updatedAt: string\n}\n\ntype EmbeddingSettings = {\n openaiConfigured: boolean\n autoIndexingEnabled: boolean\n autoIndexingLocked: boolean\n lockReason: string | null\n embeddingConfig: EmbeddingProviderConfig | null\n configuredProviders: EmbeddingProviderId[]\n indexedDimension: number | null\n reindexRequired: boolean\n documentCount: number | null\n}\n\ntype EmbeddingSettingsResponse = {\n settings?: EmbeddingSettings\n error?: string\n}\n\n// Full-text search config types\ntype FulltextEnvVarStatus = {\n set: boolean\n hint: string\n}\n\ntype FulltextOptionalEnvVarStatus = {\n set: boolean\n value?: string | boolean\n default?: string | boolean\n hint: string\n}\n\ntype FulltextConfigResponse = {\n driver: 'meilisearch' | null\n configured: boolean\n envVars: {\n MEILISEARCH_HOST: FulltextEnvVarStatus\n MEILISEARCH_API_KEY: FulltextEnvVarStatus\n }\n optionalEnvVars: {\n MEILISEARCH_INDEX_PREFIX: FulltextOptionalEnvVarStatus\n SEARCH_EXCLUDE_ENCRYPTED_FIELDS: FulltextOptionalEnvVarStatus\n }\n}\n\n// Vector store driver types\ntype VectorDriverId = 'pgvector' | 'qdrant' | 'chromadb'\n\ntype VectorDriverEnvVar = {\n name: string\n set: boolean\n hint: string\n}\n\ntype VectorDriverStatus = {\n id: VectorDriverId\n name: string\n configured: boolean\n implemented: boolean\n available?: boolean | null\n unavailableReason?: string | null\n envVars: VectorDriverEnvVar[]\n}\n\ntype VectorStoreConfigResponse = {\n currentDriver: VectorDriverId\n configured: boolean\n drivers: VectorDriverStatus[]\n}\n\nconst normalizeErrorMessage = (error: unknown, fallback: string): string => {\n if (typeof error === 'string' && error.trim().length) return error.trim()\n if (error instanceof Error && error.message.trim().length) return error.message.trim()\n return fallback\n}\n\nexport function SearchSettingsPageClient() {\n const t = useT()\n\n // Main settings state\n const [settings, setSettings] = React.useState<SearchSettings | null>(null)\n const [loading, setLoading] = React.useState(true)\n const [error, setError] = React.useState<string | null>(null)\n\n // Embedding settings state\n const [embeddingSettings, setEmbeddingSettings] = React.useState<EmbeddingSettings | null>(null)\n const [embeddingLoading, setEmbeddingLoading] = React.useState(true)\n\n // Global search settings state\n const [globalSearchStrategies, setGlobalSearchStrategies] = React.useState<Set<string>>(() => new Set(['fulltext', 'vector', 'tokens']))\n const [globalSearchInitial, setGlobalSearchInitial] = React.useState<Set<string>>(() => new Set(['fulltext', 'vector', 'tokens']))\n const [globalSearchLoading, setGlobalSearchLoading] = React.useState(true)\n const [globalSearchSaving, setGlobalSearchSaving] = React.useState(false)\n\n // Full-text search config state\n const [fulltextConfig, setFulltextConfig] = React.useState<FulltextConfigResponse | null>(null)\n const [fulltextConfigLoading, setFulltextConfigLoading] = React.useState(true)\n\n // Vector store config state\n const [vectorStoreConfig, setVectorStoreConfig] = React.useState<VectorStoreConfigResponse | null>(null)\n const [vectorStoreConfigLoading, setVectorStoreConfigLoading] = React.useState(true)\n\n // Fetch main settings\n const fetchSettings = React.useCallback(async () => {\n setLoading(true)\n setError(null)\n try {\n const body = await readApiResultOrThrow<SettingsResponse>(\n '/api/search/settings',\n undefined,\n { errorMessage: t('search.settings.errorLabel', 'Failed to load settings'), allowNullResult: true },\n )\n if (body?.settings) {\n setSettings(body.settings)\n } else {\n setSettings({\n strategies: [],\n fulltextConfigured: false,\n fulltextStats: null,\n vectorConfigured: false,\n tokensEnabled: true,\n defaultStrategies: [],\n reindexLock: null,\n fulltextReindexLock: null,\n vectorReindexLock: null,\n })\n }\n } catch (err) {\n const message = normalizeErrorMessage(err, t('search.settings.errorLabel', 'Failed to load settings'))\n setError(message)\n flash(message, 'error')\n } finally {\n setLoading(false)\n }\n }, [t])\n\n React.useEffect(() => {\n fetchSettings()\n }, [fetchSettings])\n\n // Lightweight stats refresh for polling during reindex\n const refreshStatsOnly = React.useCallback(async () => {\n try {\n const body = await readApiResultOrThrow<SettingsResponse>(\n '/api/search/settings',\n { cache: 'no-store' },\n { errorMessage: '', allowNullResult: true },\n )\n if (body?.settings) {\n setSettings(body.settings)\n }\n } catch {\n // Silently ignore errors during polling\n }\n }, [])\n\n const hasActiveReindexLock = Boolean(settings?.fulltextReindexLock || settings?.vectorReindexLock)\n React.useEffect(() => {\n if (!hasActiveReindexLock) return\n\n const interval = setInterval(() => {\n void refreshStatsOnly()\n }, 5000)\n\n return () => clearInterval(interval)\n }, [hasActiveReindexLock, refreshStatsOnly])\n\n // Lightweight embedding stats refresh\n const refreshEmbeddingStatsOnly = React.useCallback(async () => {\n try {\n const body = await readApiResultOrThrow<EmbeddingSettingsResponse>(\n '/api/search/embeddings',\n { cache: 'no-store' },\n { errorMessage: '', allowNullResult: true },\n )\n if (body?.settings) {\n setEmbeddingSettings(body.settings)\n }\n } catch {\n // Silently ignore errors during polling\n }\n }, [])\n\n useAppEvent('progress.job.updated', () => {\n void refreshStatsOnly()\n void refreshEmbeddingStatsOnly()\n }, [refreshStatsOnly, refreshEmbeddingStatsOnly])\n\n useAppEvent('progress.job.completed', () => {\n void refreshStatsOnly()\n void refreshEmbeddingStatsOnly()\n }, [refreshStatsOnly, refreshEmbeddingStatsOnly])\n\n useAppEvent('om:bridge:reconnected', () => {\n void refreshStatsOnly()\n void refreshEmbeddingStatsOnly()\n }, [refreshStatsOnly, refreshEmbeddingStatsOnly])\n\n // Fetch embedding settings\n const fetchEmbeddingSettings = React.useCallback(async () => {\n setEmbeddingLoading(true)\n try {\n const body = await readApiResultOrThrow<EmbeddingSettingsResponse>(\n '/api/search/embeddings',\n undefined,\n { errorMessage: t('search.settings.errors.loadFailed', 'Failed to load settings'), allowNullResult: true },\n )\n if (body?.settings) {\n setEmbeddingSettings(body.settings)\n } else {\n setEmbeddingSettings({\n openaiConfigured: false,\n autoIndexingEnabled: true,\n autoIndexingLocked: false,\n lockReason: null,\n embeddingConfig: null,\n configuredProviders: [],\n indexedDimension: null,\n reindexRequired: false,\n documentCount: null,\n })\n }\n } catch {\n // Error already handled\n } finally {\n setEmbeddingLoading(false)\n }\n }, [t])\n\n React.useEffect(() => {\n fetchEmbeddingSettings()\n }, [fetchEmbeddingSettings])\n\n // Fetch global search settings\n const fetchGlobalSearchSettings = React.useCallback(async () => {\n setGlobalSearchLoading(true)\n try {\n const response = await fetch('/api/search/settings/global-search')\n if (response.ok) {\n const body = await response.json() as { enabledStrategies?: string[] }\n if (body.enabledStrategies && Array.isArray(body.enabledStrategies) && body.enabledStrategies.length > 0) {\n const strategies = new Set(body.enabledStrategies)\n setGlobalSearchStrategies(strategies)\n setGlobalSearchInitial(new Set(strategies))\n }\n }\n } catch {\n // Silently use defaults\n } finally {\n setGlobalSearchLoading(false)\n }\n }, [])\n\n React.useEffect(() => {\n fetchGlobalSearchSettings()\n }, [fetchGlobalSearchSettings])\n\n // Fetch fulltext config\n const fetchFulltextConfig = React.useCallback(async () => {\n setFulltextConfigLoading(true)\n try {\n const response = await fetch('/api/search/settings/fulltext')\n if (response.ok) {\n const body = await response.json() as FulltextConfigResponse\n setFulltextConfig(body)\n }\n } catch {\n // Silently use null\n } finally {\n setFulltextConfigLoading(false)\n }\n }, [])\n\n React.useEffect(() => {\n fetchFulltextConfig()\n }, [fetchFulltextConfig])\n\n // Fetch vector store config\n const fetchVectorStoreConfig = React.useCallback(async () => {\n setVectorStoreConfigLoading(true)\n try {\n const response = await fetch('/api/search/settings/vector-store')\n if (response.ok) {\n const body = await response.json() as VectorStoreConfigResponse\n setVectorStoreConfig(body)\n }\n } catch {\n // Silently use null\n } finally {\n setVectorStoreConfigLoading(false)\n }\n }, [])\n\n React.useEffect(() => {\n fetchVectorStoreConfig()\n }, [fetchVectorStoreConfig])\n\n // Global search settings handlers - auto-save on toggle\n const toggleGlobalSearchStrategy = React.useCallback(async (strategyId: string) => {\n const newStrategies = new Set(globalSearchStrategies)\n if (newStrategies.has(strategyId)) {\n if (newStrategies.size > 1) {\n newStrategies.delete(strategyId)\n } else {\n return\n }\n } else {\n newStrategies.add(strategyId)\n }\n\n setGlobalSearchStrategies(newStrategies)\n setGlobalSearchSaving(true)\n\n try {\n const response = await fetch('/api/search/settings/global-search', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify({ enabledStrategies: Array.from(newStrategies) }),\n })\n\n if (!response.ok) {\n const body = await response.json().catch(() => ({})) as { error?: string }\n throw new Error(body.error || t('search.settings.globalSearch.saveError', 'Failed to save settings'))\n }\n\n setGlobalSearchInitial(new Set(newStrategies))\n } catch (err) {\n setGlobalSearchStrategies(globalSearchInitial)\n flash(normalizeErrorMessage(err, t('search.settings.globalSearch.saveError', 'Failed to save settings')), 'error')\n } finally {\n setGlobalSearchSaving(false)\n }\n }, [globalSearchStrategies, globalSearchInitial, t])\n\n // Callbacks for section components\n const handleFulltextStatsUpdate = React.useCallback((stats: FulltextStats | null) => {\n setSettings(prev => prev ? { ...prev, fulltextStats: stats } : prev)\n }, [])\n\n const handleEmbeddingSettingsUpdate = React.useCallback((newSettings: EmbeddingSettings) => {\n setEmbeddingSettings(newSettings)\n }, [])\n\n return (\n <div className=\"flex min-w-0 flex-col gap-6\">\n {/* Header */}\n <div className=\"space-y-1\">\n <h1 className=\"text-2xl font-bold\">{t('search.settings.pageTitle', 'Search Settings')}</h1>\n <p className=\"text-muted-foreground\">{t('search.settings.pageDescription', 'Configure search strategies and view their availability.')}</p>\n </div>\n\n {/* Section 1: Global Search Settings */}\n <GlobalSearchSection\n loading={globalSearchLoading}\n saving={globalSearchSaving}\n strategies={globalSearchStrategies}\n fulltextConfigured={settings?.fulltextConfigured ?? false}\n vectorConfigured={settings?.vectorConfigured ?? false}\n onToggleStrategy={toggleGlobalSearchStrategy}\n />\n\n {/* Section 2: Full-Text Search (with tabs) */}\n <FulltextSearchSection\n fulltextConfig={fulltextConfig}\n fulltextConfigLoading={fulltextConfigLoading}\n fulltextStats={settings?.fulltextStats ?? null}\n fulltextReindexLock={settings?.fulltextReindexLock ?? null}\n loading={loading}\n onStatsUpdate={handleFulltextStatsUpdate}\n onRefresh={fetchSettings}\n />\n\n {/* Section 3: Vector Search (with tabs) */}\n <VectorSearchSection\n embeddingSettings={embeddingSettings}\n embeddingLoading={embeddingLoading}\n vectorStoreConfig={vectorStoreConfig}\n vectorStoreConfigLoading={vectorStoreConfigLoading}\n vectorReindexLock={settings?.vectorReindexLock ?? null}\n onEmbeddingSettingsUpdate={handleEmbeddingSettingsUpdate}\n onRefreshEmbeddings={fetchEmbeddingSettings}\n />\n\n {/* Refresh Button */}\n <div className=\"flex items-center gap-3\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={() => fetchSettings()}\n disabled={loading}\n >\n {loading ? (\n <>\n <Spinner size=\"sm\" className=\"mr-2\" />\n {t('search.settings.loadingLabel', 'Loading settings...')}\n </>\n ) : (\n t('search.settings.refreshLabel', 'Refresh')\n )}\n </Button>\n {error && <span className=\"text-sm text-destructive\">{error}</span>}\n </div>\n </div>\n )\n}\n\nexport default SearchSettingsPageClient\n"],
|
|
5
|
+
"mappings": ";AAuZM,SA+CM,UA9CJ,KADF;AArZN,YAAY,WAAW;AACvB,SAAS,YAAY;AACrB,SAAS,4BAA4B;AACrC,SAAS,aAAa;AACtB,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,mBAAmB;AAC5B,SAAS,2BAA2B;AACpC,SAAS,6BAA6B;AACtC,SAAS,2BAA2B;AAwHpC,MAAM,wBAAwB,CAAC,OAAgB,aAA6B;AAC1E,MAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,OAAQ,QAAO,MAAM,KAAK;AACxE,MAAI,iBAAiB,SAAS,MAAM,QAAQ,KAAK,EAAE,OAAQ,QAAO,MAAM,QAAQ,KAAK;AACrF,SAAO;AACT;AAEO,SAAS,2BAA2B;AACzC,QAAM,IAAI,KAAK;AAGf,QAAM,CAAC,UAAU,WAAW,IAAI,MAAM,SAAgC,IAAI;AAC1E,QAAM,CAAC,SAAS,UAAU,IAAI,MAAM,SAAS,IAAI;AACjD,QAAM,CAAC,OAAO,QAAQ,IAAI,MAAM,SAAwB,IAAI;AAG5D,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,MAAM,SAAmC,IAAI;AAC/F,QAAM,CAAC,kBAAkB,mBAAmB,IAAI,MAAM,SAAS,IAAI;AAGnE,QAAM,CAAC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,QACA;AAAA,QACA,eAAe,UAAU,iBAAiB;AAAA,QAC1C,qBAAqB,UAAU,uBAAuB;AAAA,QACtD;AAAA,QACA,eAAe;AAAA,QACf,WAAW;AAAA;AAAA,IACb;AAAA,IAGA;AAAA,MAAC;AAAA;AAAA,QACC;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA,mBAAmB,UAAU,qBAAqB;AAAA,QAClD,2BAA2B;AAAA,QAC3B,qBAAqB;AAAA;AAAA,IACvB;AAAA,IAGA,qBAAC,SAAI,WAAU,2BACb;AAAA;AAAA,QAAC;AAAA;AAAA,UACC,MAAK;AAAA,UACL,SAAQ;AAAA,UACR,MAAK;AAAA,UACL,SAAS,MAAM,cAAc;AAAA,UAC7B,UAAU;AAAA,UAET,oBACC,iCACE;AAAA,gCAAC,WAAQ,MAAK,MAAK,WAAU,QAAO;AAAA,YACnC,EAAE,gCAAgC,qBAAqB;AAAA,aAC1D,IAEA,EAAE,gCAAgC,SAAS;AAAA;AAAA,MAE/C;AAAA,MACC,SAAS,oBAAC,UAAK,WAAU,4BAA4B,iBAAM;AAAA,OAC9D;AAAA,KACF;AAEJ;AAEA,IAAO,mCAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -12,6 +12,12 @@ const normalizeErrorMessage = (error, fallback) => {
|
|
|
12
12
|
if (error instanceof Error && error.message.trim().length) return error.message.trim();
|
|
13
13
|
return fallback;
|
|
14
14
|
};
|
|
15
|
+
const environmentHints = {
|
|
16
|
+
MEILISEARCH_HOST: { key: "search.settings.fulltext.hints.host", fallback: "The URL of your Meilisearch server (e.g., http://localhost:7700)" },
|
|
17
|
+
MEILISEARCH_API_KEY: { key: "search.settings.fulltext.hints.apiKey", fallback: "API key for authentication with Meilisearch" },
|
|
18
|
+
MEILISEARCH_INDEX_PREFIX: { key: "search.settings.fulltext.hints.indexPrefix", fallback: "Prefix for index names to namespace indexes per tenant" },
|
|
19
|
+
SEARCH_EXCLUDE_ENCRYPTED_FIELDS: { key: "search.settings.fulltext.hints.excludeEncrypted", fallback: "Exclude encrypted fields from full-text indexing for security" }
|
|
20
|
+
};
|
|
15
21
|
function FulltextSearchSection({
|
|
16
22
|
fulltextConfig,
|
|
17
23
|
fulltextConfigLoading,
|
|
@@ -128,11 +134,11 @@ function FulltextSearchSection({
|
|
|
128
134
|
}
|
|
129
135
|
};
|
|
130
136
|
const getStrategyIcon = () => /* @__PURE__ */ jsx("svg", { className: "h-5 w-5", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z" }) });
|
|
131
|
-
return /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border bg-card p-5 shadow-sm", children: [
|
|
137
|
+
return /* @__PURE__ */ jsxs("div", { className: "min-w-0 rounded-lg border border-border bg-card p-5 shadow-sm", children: [
|
|
132
138
|
/* @__PURE__ */ jsx("h2", { className: "text-lg font-semibold mb-2", children: t("search.settings.fulltext.sectionTitle", "Full-Text Search") }),
|
|
133
139
|
/* @__PURE__ */ jsx("p", { className: "text-sm text-muted-foreground mb-4", children: t("search.settings.fulltext.sectionDescription", "Fast, typo-tolerant search using Meilisearch.") }),
|
|
134
140
|
/* @__PURE__ */ jsxs(Tabs, { defaultValue: "configuration", children: [
|
|
135
|
-
/* @__PURE__ */ jsxs(TabsList, { className: "mb-4", children: [
|
|
141
|
+
/* @__PURE__ */ jsxs(TabsList, { className: "mb-4 h-auto max-w-full flex-wrap", children: [
|
|
136
142
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "configuration", children: t("search.settings.tabs.configuration", "Configuration") }),
|
|
137
143
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "index", children: t("search.settings.tabs.indexManagement", "Index Management") }),
|
|
138
144
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "activity", children: t("search.settings.tabs.activity", "Activity") })
|
|
@@ -156,21 +162,21 @@ function FulltextSearchSection({
|
|
|
156
162
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold mb-2", children: t("search.settings.fulltext.envVars", "Required Environment Variables") }),
|
|
157
163
|
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: fulltextConfig?.envVars && Object.entries(fulltextConfig.envVars).map(([key, status]) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 p-3 rounded-md border border-border", children: [
|
|
158
164
|
/* @__PURE__ */ jsx("div", { className: `flex h-5 w-5 items-center justify-center rounded-full flex-shrink-0 mt-0.5 ${status.set ? "bg-status-success-bg text-status-success-icon" : "bg-status-error-bg text-status-error-icon"}`, children: status.set ? /* @__PURE__ */ jsx("svg", { className: "h-3 w-3", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" }) }) : /* @__PURE__ */ jsx("svg", { className: "h-3 w-3", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", strokeWidth: 3, children: /* @__PURE__ */ jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) }) }),
|
|
159
|
-
/* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
|
|
160
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
165
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
166
|
+
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
161
167
|
/* @__PURE__ */ jsx("code", { className: "text-sm font-mono bg-muted px-1.5 py-0.5 rounded", children: key }),
|
|
162
168
|
/* @__PURE__ */ jsx("span", { className: `text-xs ${status.set ? "text-status-success-text" : "text-status-error-text"}`, children: status.set ? t("search.settings.fulltext.envSet", "Set") : t("search.settings.fulltext.envMissing", "Missing") })
|
|
163
169
|
] }),
|
|
164
|
-
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: status.hint })
|
|
170
|
+
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground mt-1", children: environmentHints[key] ? t(environmentHints[key].key, environmentHints[key].fallback) : status.hint })
|
|
165
171
|
] })
|
|
166
172
|
] }, key)) })
|
|
167
173
|
] }),
|
|
168
174
|
/* @__PURE__ */ jsxs("div", { children: [
|
|
169
175
|
/* @__PURE__ */ jsx("h3", { className: "text-sm font-semibold mb-2", children: t("search.settings.fulltext.optional", "Optional Settings") }),
|
|
170
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: fulltextConfig?.optionalEnvVars && Object.entries(fulltextConfig.optionalEnvVars).map(([key, status]) => /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-3 p-2 rounded-md bg-muted/30", children: [
|
|
171
|
-
/* @__PURE__ */ jsx("code", { className: "text-xs font-mono bg-muted px-1.5 py-0.5 rounded", children: key }),
|
|
172
|
-
/* @__PURE__ */ jsxs("div", { className: "
|
|
173
|
-
/* @__PURE__ */ jsx("span", { children: status.hint }),
|
|
176
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: fulltextConfig?.optionalEnvVars && Object.entries(fulltextConfig.optionalEnvVars).map(([key, status]) => /* @__PURE__ */ jsxs("div", { className: "flex min-w-0 flex-col items-start gap-3 p-2 rounded-md bg-muted/30 sm:flex-row", children: [
|
|
177
|
+
/* @__PURE__ */ jsx("code", { className: "max-w-full break-all text-xs font-mono bg-muted px-1.5 py-0.5 rounded", children: key }),
|
|
178
|
+
/* @__PURE__ */ jsxs("div", { className: "min-w-0 max-w-full break-words text-xs text-muted-foreground sm:flex-1", children: [
|
|
179
|
+
/* @__PURE__ */ jsx("span", { children: environmentHints[key] ? t(environmentHints[key].key, environmentHints[key].fallback) : status.hint }),
|
|
174
180
|
status.set ? /* @__PURE__ */ jsxs("span", { className: "ml-2 text-status-success-text", children: [
|
|
175
181
|
"(",
|
|
176
182
|
t("search.settings.fulltext.currentValue", "Current"),
|