keystone-design-bootstrap 1.0.105-dev.0 → 1.0.105
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.d.ts +5 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/design_system/components/ChatWidget.tsx +1 -1
- package/src/lib/chat-backend-constants.ts +8 -0
- package/src/lib/chat-backend.ts +5 -4
- package/src/next/layouts/root-layout.tsx +11 -2
package/package.json
CHANGED
|
@@ -7,7 +7,7 @@ import { cx } from '../../utils/cx';
|
|
|
7
7
|
import { captureEvent } from '../../tracking/captureEvent';
|
|
8
8
|
import { useRealtimeReplyOrchestrator, type RealtimeSubscriptionData } from '../chat/useRealtimeReplyOrchestrator';
|
|
9
9
|
import { error as logError } from '../../tracking/logging';
|
|
10
|
-
import { RAILS_BACKEND, SOR_BACKEND, type ChatBackend } from '../../lib/chat-backend';
|
|
10
|
+
import { RAILS_BACKEND, SOR_BACKEND, type ChatBackend } from '../../lib/chat-backend-constants';
|
|
11
11
|
|
|
12
12
|
interface Message {
|
|
13
13
|
id: string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chat backend identifiers — isomorphic (safe to import from client
|
|
3
|
+
* components; no server-only dependencies). Backend *resolution* lives in
|
|
4
|
+
* ./chat-backend (server-only: reads env, logs via server-log).
|
|
5
|
+
*/
|
|
6
|
+
export const RAILS_BACKEND = 'rails' as const;
|
|
7
|
+
export const SOR_BACKEND = 'sor' as const;
|
|
8
|
+
export type ChatBackend = typeof RAILS_BACKEND | typeof SOR_BACKEND;
|
package/src/lib/chat-backend.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Which chat backend the site's /api/chat proxy targets.
|
|
2
|
+
* Which chat backend the site's /api/chat proxy targets. SERVER-ONLY module
|
|
3
|
+
* (reads env, logs via server-log) — client components import the constants
|
|
4
|
+
* from ./chat-backend-constants instead.
|
|
3
5
|
*
|
|
4
6
|
* The two backends have architecturally different webchat contracts:
|
|
5
7
|
* - 'rails' (keystone-mono-proto): /public/messages + ActionCable realtime.
|
|
@@ -16,10 +18,9 @@
|
|
|
16
18
|
* backend; flip the default to 'sor' once the Rails backend is scrapped.
|
|
17
19
|
*/
|
|
18
20
|
import { serverError } from './server-log';
|
|
21
|
+
import { RAILS_BACKEND, SOR_BACKEND, type ChatBackend } from './chat-backend-constants';
|
|
19
22
|
|
|
20
|
-
export
|
|
21
|
-
export const SOR_BACKEND = 'sor' as const;
|
|
22
|
-
export type ChatBackend = typeof RAILS_BACKEND | typeof SOR_BACKEND;
|
|
23
|
+
export { RAILS_BACKEND, SOR_BACKEND, type ChatBackend };
|
|
23
24
|
|
|
24
25
|
export function resolveChatBackend(): ChatBackend {
|
|
25
26
|
const explicit = process.env.CHAT_BACKEND;
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
KeystoneAnalyticsTracker,
|
|
12
12
|
} from '../../tracking';
|
|
13
13
|
import { ChatWidget } from '../../design_system/components/ChatWidget';
|
|
14
|
-
import { resolveChatBackend } from '../../lib/chat-backend';
|
|
14
|
+
import { resolveChatBackend, type ChatBackend } from '../../lib/chat-backend';
|
|
15
15
|
import { FormDefinitionsProvider } from '../contexts/form-definitions';
|
|
16
16
|
import { KeystoneSSRProvider } from '../providers/ssr-provider';
|
|
17
17
|
import {
|
|
@@ -56,6 +56,15 @@ export type KeystoneRootLayoutOptions = {
|
|
|
56
56
|
headerOverrides?: KeystoneRootLayoutHeaderOverrides;
|
|
57
57
|
/** Chat widget position */
|
|
58
58
|
chatPosition?: 'bottom-right' | 'bottom-left';
|
|
59
|
+
/**
|
|
60
|
+
* Which backend the site's /api/chat proxy targets. MUST match the route's
|
|
61
|
+
* `createChatRouteHandlers({ backend })` selection — if you pass an explicit
|
|
62
|
+
* backend to the route factory, pass the same value here, or the widget's
|
|
63
|
+
* reply delivery (realtime vs polling) diverges from the route's wire shape
|
|
64
|
+
* and the typing indicator can hang. When omitted, both sides derive the
|
|
65
|
+
* same value from CHAT_BACKEND / API_URL (see lib/chat-backend).
|
|
66
|
+
*/
|
|
67
|
+
chatBackend?: ChatBackend;
|
|
59
68
|
/**
|
|
60
69
|
* PostHog ingest host. Defaults to `https://us.i.posthog.com`.
|
|
61
70
|
* Override when self-hosting or using the EU cloud (`https://eu.i.posthog.com`).
|
|
@@ -185,7 +194,7 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
|
185
194
|
const chatEnabled = Boolean(ci?.chat_enabled);
|
|
186
195
|
// Which backend the site's /api/chat proxy targets — same resolution as the
|
|
187
196
|
// route handlers (CHAT_BACKEND override, else derived from API_URL).
|
|
188
|
-
const chatBackend = resolveChatBackend();
|
|
197
|
+
const chatBackend = options?.chatBackend ?? resolveChatBackend();
|
|
189
198
|
|
|
190
199
|
const headerOverrides = options?.headerOverrides;
|
|
191
200
|
const posthogHost = options?.posthogHost?.trim() || undefined;
|