@sabstravtech/obtservices 0.2.2605051730 → 0.2.2605141232

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.
@@ -0,0 +1,33 @@
1
+ import { HttpClient } from '@angular/common/http';
2
+ import { Subject } from 'rxjs';
3
+ import { WebTokenService } from '../services/webtoken.service';
4
+ import { Environment } from '../classes/environment';
5
+ import { BaseChatbotService, ChatMessage, ChatRequest, ChatResponse, ChatSearchParameters } from '@sabstravtech/obtservices/base';
6
+ import { ResultAwareService } from './result-aware.service';
7
+ import * as i0 from "@angular/core";
8
+ export declare class ChatbotService extends BaseChatbotService {
9
+ private http;
10
+ private webTokenService;
11
+ private resultAwareService;
12
+ private environment;
13
+ private messagesSubject;
14
+ messages$: import("rxjs").Observable<ChatMessage[]>;
15
+ private loadingSubject;
16
+ loading$: import("rxjs").Observable<boolean>;
17
+ fillSearchForm$: Subject<{
18
+ parameters: ChatSearchParameters;
19
+ autoSearch: boolean;
20
+ }>;
21
+ constructor(http: HttpClient, webTokenService: WebTokenService, resultAwareService: ResultAwareService, environment: Environment);
22
+ protected getApiUrl(): string;
23
+ protected getAuthToken(): string | null;
24
+ protected httpPost(url: string, body: ChatRequest, token: string): Promise<ChatResponse>;
25
+ protected notifyMessages(msgs: ChatMessage[]): void;
26
+ protected notifyLoading(value: boolean): void;
27
+ protected notifyFillForm(params: ChatSearchParameters, autoSearch: boolean): void;
28
+ protected executeSelection(selectedIndex: number, returnSelectedIndex?: number): Promise<void>;
29
+ protected hasResults(): boolean;
30
+ clearSession(): void;
31
+ static ɵfac: i0.ɵɵFactoryDeclaration<ChatbotService, never>;
32
+ static ɵprov: i0.ɵɵInjectableDeclaration<ChatbotService>;
33
+ }
@@ -0,0 +1,37 @@
1
+ import { Router } from '@angular/router';
2
+ import { EnterpriseSearchService } from './search.service';
3
+ import { EnterpriseBasketService } from './enterprise-basket.service';
4
+ import { CondensedResult } from '@sabstravtech/obtservices/base';
5
+ import * as i0 from "@angular/core";
6
+ export declare class ResultAwareService {
7
+ private searchService;
8
+ private basketService;
9
+ private router;
10
+ private condensedResults;
11
+ private rawResults;
12
+ private currentServiceType;
13
+ private railSourceId;
14
+ private railReturnJourneys;
15
+ private resultsAvailableSubject;
16
+ resultsAvailable$: import("rxjs").Observable<boolean>;
17
+ constructor(searchService: EnterpriseSearchService, basketService: EnterpriseBasketService, router: Router);
18
+ captureFlightResults(results: any[]): void;
19
+ captureRailResults(quoteResult: any): void;
20
+ getCondensedResults(): CondensedResult[];
21
+ hasResults(): boolean;
22
+ clearResults(): void;
23
+ executeSelection(selectedIndex: number, returnIndex?: number): Promise<void>;
24
+ private executeFlightSelection;
25
+ private condenseFlightResults;
26
+ private formatTime;
27
+ private formatDuration;
28
+ private executeRailSelection;
29
+ private findCheapestRailJourney;
30
+ private getCheapestRailFare;
31
+ private condenseRailResults;
32
+ private derivePolicyStatus;
33
+ private derivePolicyMessages;
34
+ private getFirstCabinClassName;
35
+ static ɵfac: i0.ɵɵFactoryDeclaration<ResultAwareService, never>;
36
+ static ɵprov: i0.ɵɵInjectableDeclaration<ResultAwareService>;
37
+ }
@@ -17,3 +17,5 @@ export * from './lib/vendor/services/rail-fare-processing.service';
17
17
  export * from './lib/vendor/services/rail-results-state.service';
18
18
  export * from './lib/vendor/services/search-document-validation.service';
19
19
  export * from './lib/vendor/services/search-payment-validation.service';
20
+ export * from './lib/vendor/services/chatbot.service';
21
+ export * from './lib/vendor/services/result-aware.service';
@@ -38,3 +38,4 @@ export * from './lib/vendor/interfaces/Iseason-tickets-enterprise-search';
38
38
  export * from './lib/vendor/interfaces/hotel-stars-to-hide.interface';
39
39
  export * from './lib/vendor/interfaces/cheapest-price';
40
40
  export * from './lib/vendor/interfaces/cheapest-price-object';
41
+ export * from './lib/vendor/interfaces/chatbot.types';
@@ -0,0 +1,107 @@
1
+ export type ChatConversationState = 'GREETING' | 'COLLECTING_PARAMS' | 'PARAMS_COMPLETE' | 'SEARCHING' | 'HANDED_OFF' | 'SELECTING_RESULT';
2
+ export interface CondensedResult {
3
+ index: number;
4
+ airline?: string;
5
+ operator?: string;
6
+ depart: string;
7
+ arrive: string;
8
+ stops: number;
9
+ duration: string;
10
+ price: number;
11
+ cabin?: string;
12
+ class?: string;
13
+ co2?: number;
14
+ policyStatus?: 'IN_POLICY' | 'ALLOW_WITH_REASON' | 'UNAVAILABLE';
15
+ policyMessages?: string[];
16
+ from?: string;
17
+ to?: string;
18
+ flightNumbers?: string;
19
+ fares?: {
20
+ cabin: string;
21
+ price: number;
22
+ bags: number;
23
+ }[];
24
+ inbound?: {
25
+ depart: string;
26
+ arrive: string;
27
+ stops: number;
28
+ duration: string;
29
+ flightNumbers?: string;
30
+ };
31
+ returnOptions?: {
32
+ index: number;
33
+ depart: string;
34
+ arrive: string;
35
+ stops: number;
36
+ duration: string;
37
+ price: number;
38
+ operator?: string;
39
+ policyStatus?: 'IN_POLICY' | 'ALLOW_WITH_REASON' | 'UNAVAILABLE';
40
+ }[];
41
+ }
42
+ export interface ChatSearchParameters {
43
+ travelType: 'flight' | 'rail' | 'hotel';
44
+ departure: string;
45
+ arrival: string;
46
+ departureCode?: string;
47
+ arrivalCode?: string;
48
+ departureDate: string;
49
+ departureTime?: string;
50
+ returnDate?: string;
51
+ returnTime?: string;
52
+ journeyType?: 'single' | 'return';
53
+ passengers: number;
54
+ }
55
+ export interface ChatSuggestion {
56
+ type: 'search_action' | 'select_action';
57
+ label: string;
58
+ action: 'FILL_FORM' | 'FILL_AND_SEARCH' | 'SELECT_RESULT';
59
+ }
60
+ export interface ChatRequest {
61
+ message: string;
62
+ sessionId?: string;
63
+ searchResults?: CondensedResult[];
64
+ }
65
+ export interface ChatResponse {
66
+ sessionId: string;
67
+ text: string;
68
+ intent: string | null;
69
+ parameters: ChatSearchParameters | null;
70
+ policyHints: string[];
71
+ suggestions: ChatSuggestion[];
72
+ state: ChatConversationState;
73
+ selectedIndex?: number;
74
+ returnSelectedIndex?: number;
75
+ alternativeIndex?: number;
76
+ action?: 'search' | 'select' | 'navigate' | 'fill';
77
+ }
78
+ export type ChatMessageRole = 'user' | 'assistant';
79
+ export interface ChatMessage {
80
+ id: string;
81
+ role: ChatMessageRole;
82
+ text: string;
83
+ timestamp: Date;
84
+ parameters?: ChatSearchParameters | null;
85
+ policyHints?: string[];
86
+ suggestions?: ChatSuggestion[];
87
+ state?: ChatConversationState;
88
+ selectedIndex?: number;
89
+ returnSelectedIndex?: number;
90
+ alternativeIndex?: number;
91
+ action?: 'search' | 'select' | 'navigate' | 'fill';
92
+ }
93
+ export interface ChatbotRailFillEvent {
94
+ params: ChatSearchParameters;
95
+ autoSearch: boolean;
96
+ resolvedFrom?: any;
97
+ resolvedTo?: any;
98
+ }
99
+ export interface ChatbotFlightFillEvent {
100
+ params: ChatSearchParameters;
101
+ resolvedDepart?: any;
102
+ resolvedArrive?: any;
103
+ }
104
+ export interface ChatbotHotelFillEvent {
105
+ params: ChatSearchParameters;
106
+ resolvedLocation?: any;
107
+ }
@@ -0,0 +1,26 @@
1
+ import { ChatMessage, ChatRequest, ChatResponse, ChatSearchParameters, CondensedResult } from '../interfaces/chatbot.types';
2
+ export declare abstract class BaseChatbotService {
3
+ protected sessionId: string | null;
4
+ protected messages: ChatMessage[];
5
+ protected loading: boolean;
6
+ protected condensedResults: CondensedResult[];
7
+ protected abstract getApiUrl(): string;
8
+ protected abstract getAuthToken(): string | null;
9
+ protected abstract httpPost(url: string, body: ChatRequest, token: string): Promise<ChatResponse>;
10
+ protected abstract notifyMessages(messages: ChatMessage[]): void;
11
+ protected abstract notifyLoading(loading: boolean): void;
12
+ protected abstract notifyFillForm(params: ChatSearchParameters, autoSearch: boolean): void;
13
+ protected abstract executeSelection(selectedIndex: number, returnSelectedIndex?: number): Promise<void>;
14
+ protected abstract hasResults(): boolean;
15
+ sendMessage(text: string): Promise<void>;
16
+ fillForm(parameters: ChatSearchParameters): void;
17
+ fillAndSearch(parameters: ChatSearchParameters): void;
18
+ setCondensedResults(results: CondensedResult[]): void;
19
+ clearSession(): void;
20
+ getMessages(): ChatMessage[];
21
+ isLoading(): boolean;
22
+ protected addMessage(message: ChatMessage): void;
23
+ protected setLoadingState(value: boolean): void;
24
+ protected isSelectionRequest(text: string): boolean;
25
+ protected generateId(): string;
26
+ }
@@ -13,3 +13,4 @@ export * from './lib/vendor/services/routehappy.service';
13
13
  export * from './lib/vendor/services/requires-reason.service';
14
14
  export * from './lib/vendor/services/http-cancel.service';
15
15
  export * from './lib/vendor/services/messages.service';
16
+ export * from './lib/vendor/services/chatbot.service';