PluginProbe
Yatra – Travel Booking & Tour Operator Software / 3.0.13
Yatra – Travel Booking & Tour Operator Software v3.0.13
3.0.16 3.0.15 3.0.14 3.0.14.1 3.0.14.2 3.0.12 3.0.13 3.0.11 3.0.10 3.0.9 3.0.8 3.0.7 3.0.6 3.0.5 3.0.5.1 3.0.4 3.0.3 3.0.2.9 3.0.2.7 3.0.2.8 3.0.2.6 trunk 1.0.0 2.0.0 2.0.1 All 84 releases
yatra / resources / js / lib / ai-availability.ts

ai-availability.ts in Yatra – Travel Booking & Tour Operator Software 3.0.13, at resources/js/lib/ai-availability.ts

53 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Single-source check for "should the AI sparkle button render here?".
3 *
4 * Three independent gates must all be true:
5 * 1. `isAiEligible` — license tier is Growth or Agency (set by Pro).
6 * 2. `aiAssistantEnabled` — module toggle on (set by Pro).
7 * 3. `aiAssistantConfigured` — at least one provider has an API key
8 * (set by Pro's AiModule::boot → LocalizedData::register).
9 *
10 * Components import this so the rule lives in one place — flipping it
11 * later (e.g. allowing per-user opt-in) is a single edit.
12 */
13
14 export interface AiAdminWindow {
15 isAiEligible?: boolean;
16 aiAssistantEnabled?: boolean;
17 aiAssistantConfigured?: boolean;
18 }
19
20 function readAdmin(): AiAdminWindow {
21 return ((window as any).yatraAdmin ?? {}) as AiAdminWindow;
22 }
23
24 /** Is the AI module fully ready (eligible + enabled + at least one key)? */
25 export function isAiReady(): boolean {
26 const a = readAdmin();
27 return Boolean(
28 a.isAiEligible && a.aiAssistantEnabled && a.aiAssistantConfigured,
29 );
30 }
31
32 /**
33 * Looser check: the operator's license tier qualifies and the module is
34 * enabled, but no key is configured yet. Used by the Settings page to
35 * show the "add your API key to start" state.
36 */
37 export function isAiActiveButUnconfigured(): boolean {
38 const a = readAdmin();
39 return Boolean(
40 a.isAiEligible && a.aiAssistantEnabled && !a.aiAssistantConfigured,
41 );
42 }
43
44 /** Did the operator's license tier even unlock AI Assistant? */
45 export function isAiEligible(): boolean {
46 return Boolean(readAdmin().isAiEligible);
47 }
48
49 /** Is the AI Assistant module toggle on? */
50 export function isAiModuleEnabled(): boolean {
51 return Boolean(readAdmin().aiAssistantEnabled);
52 }
53