@aakash58/chatbot 1.1.26 → 1.1.28

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,8 +1,8 @@
1
1
  import * as i1$2 from '@angular/common';
2
2
  import { CommonModule } from '@angular/common';
3
3
  import * as i0 from '@angular/core';
4
- import { isDevMode, InjectionToken, signal, Injectable, inject, effect, EventEmitter, Output, Input, Component, Pipe, ViewChild, Inject, HostListener, Directive, computed, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, ViewEncapsulation, APP_INITIALIZER, ContentChildren } from '@angular/core';
5
- import { delay, retry, map, catchError, of, BehaviorSubject, firstValueFrom, throwError, tap, Observable, Subject, lastValueFrom, ReplaySubject, switchMap, filter, take } from 'rxjs';
4
+ import { isDevMode, InjectionToken, Injectable, signal, inject, effect, EventEmitter, Output, Input, Component, Pipe, ViewChild, Inject, HostListener, Directive, computed, ChangeDetectionStrategy, ChangeDetectorRef, ElementRef, ViewEncapsulation, makeEnvironmentProviders, APP_INITIALIZER, ContentChildren } from '@angular/core';
5
+ import { ReplaySubject, delay, retry, map, catchError, of, BehaviorSubject, firstValueFrom, throwError, tap, Observable, Subject, lastValueFrom, switchMap, filter, take } from 'rxjs';
6
6
  import { JwtHelperService } from '@auth0/angular-jwt';
7
7
  import * as i1 from '@angular/common/http';
8
8
  import { HttpHeaders, HttpEventType, HttpClient, HttpErrorResponse, provideHttpClient, HTTP_INTERCEPTORS, withInterceptorsFromDi } from '@angular/common/http';
@@ -16,7 +16,7 @@ import * as i4$1 from '@angular/material/menu';
16
16
  import { MatMenuModule } from '@angular/material/menu';
17
17
  import * as i1$4 from '@angular/material/dialog';
18
18
  import { MAT_DIALOG_DATA, MatDialogModule, MatDialogRef, MatDialog } from '@angular/material/dialog';
19
- import { DomSanitizer, bootstrapApplication } from '@angular/platform-browser';
19
+ import { DomSanitizer } from '@angular/platform-browser';
20
20
  import * as i2 from '@angular/material/button';
21
21
  import { MatButtonModule } from '@angular/material/button';
22
22
  import * as i1$5 from '@angular/forms';
@@ -179,8 +179,79 @@ class DoohbotInput {
179
179
  buttonStyle;
180
180
  primaryColor = '';
181
181
  accentColor = '';
182
+ useStandardApi = true;
182
183
  }
183
184
 
185
+ // export const environment = {
186
+ // staging: false,
187
+ // development: false,
188
+ // production: true,
189
+ // chatApiUrl: 'https://api.production.com',
190
+ // apiKey: '',
191
+ // };
192
+ const environment = {
193
+ config: 'const/app-const.json',
194
+ production: false,
195
+ apiBaseUrl: '',
196
+ loginEndpoint: '',
197
+ apiSegment: 'api/v1/',
198
+ };
199
+
200
+ class AppConst {
201
+ static appBaseUrl = environment.apiBaseUrl;
202
+ static data;
203
+ config$ = new ReplaySubject(1);
204
+ constructor() { }
205
+ async load() {
206
+ const filePath = `./assets/${environment.production ? environment.config : environment.config}?t=${new Date().getTime()}`;
207
+ const response = await fetch(filePath);
208
+ if (!response.ok) {
209
+ Logger.error('============================ ERROR ============================');
210
+ Logger.error(`Could not find file ${filePath}`);
211
+ Logger.error('============================ ERROR ============================');
212
+ }
213
+ Logger.error('============================ AppConst ============================', filePath);
214
+ if (response.ok) {
215
+ try {
216
+ AppConst.data = await response.json();
217
+ this.config$.next(AppConst.data);
218
+ Logger.error('============================ AppConst ============================', AppConst.data);
219
+ // Override apiBaseUrl if present in environment
220
+ // if (environment.apiBaseUrl) {
221
+ // AppConst.data.apiBaseUrl = environment.apiBaseUrl;
222
+ // }
223
+ // // Override loginEndpoint if present in environment
224
+ // if (environment.loginEndpoint) {
225
+ // AppConst.data.loginEndpoint = environment.loginEndpoint;
226
+ // }
227
+ }
228
+ catch (error) {
229
+ Logger.error('============================ ERROR ============================');
230
+ Logger.error(`Could not find file ${filePath}.\nMESSAGE: ${error.message}`);
231
+ Logger.error('============================ ERROR ============================');
232
+ }
233
+ if (AppConst.data && !Object.keys(AppConst.data).length) {
234
+ Logger.error('============================ ERROR ============================');
235
+ Logger.error(`No data found in file ${filePath}`);
236
+ Logger.error('============================ ERROR ============================');
237
+ }
238
+ }
239
+ else {
240
+ Logger.error('============================ ERROR ============================');
241
+ Logger.error(`Failed to load file ${filePath}.\nMESSAGE: Request failed with ${response.status} / ${response.statusText}`);
242
+ Logger.error('============================ ERROR ============================');
243
+ }
244
+ }
245
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
246
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, providedIn: 'root' });
247
+ }
248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, decorators: [{
249
+ type: Injectable,
250
+ args: [{
251
+ providedIn: 'root',
252
+ }]
253
+ }], ctorParameters: () => [] });
254
+
184
255
  class CoreConfigService {
185
256
  configSignal = signal(new DoohbotInput(), ...(ngDevMode ? [{ debugName: "configSignal" }] : []));
186
257
  config$ = this.configSignal.asReadonly();
@@ -195,7 +266,13 @@ class CoreConfigService {
195
266
  */
196
267
  get apiUrl() {
197
268
  const config = this.configSignal();
198
- return `${config.apiBaseUrl}${config.apiSegment}`;
269
+ if (config.apiBaseUrl) {
270
+ return `${config.apiBaseUrl}${config.apiSegment || ''}`;
271
+ }
272
+ // Fallback to AppConst
273
+ const appBase = AppConst.data?.apiBaseUrl || '';
274
+ const appSegment = AppConst.data?.apiSegment || '';
275
+ return `${appBase}${appSegment}`;
199
276
  }
200
277
  get storageKey() {
201
278
  return this.configSignal().storageKey || '';
@@ -218,6 +295,9 @@ class CoreConfigService {
218
295
  get rememberMe() {
219
296
  return this.configSignal().rememberMe !== undefined ? this.configSignal().rememberMe : false;
220
297
  }
298
+ get useStandardApi() {
299
+ return !!this.configSignal().useStandardApi;
300
+ }
221
301
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CoreConfigService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
222
302
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: CoreConfigService, providedIn: 'root' });
223
303
  }
@@ -1097,6 +1177,9 @@ class ThemeService {
1097
1177
  const defaults = this.personalization.developerDefaults();
1098
1178
  color = defaults.primaryColor || 'default';
1099
1179
  }
1180
+ //! If still 'default', do not apply anything. Let CSS fallback handle it.
1181
+ if (color === 'default')
1182
+ return;
1100
1183
  if (color.includes(',')) {
1101
1184
  const parts = color.split(',').map((p) => p.trim());
1102
1185
  const isDark = this._activeTheme() === 'dark-theme';
@@ -2814,6 +2897,7 @@ class ChatService {
2814
2897
  // Dependencies
2815
2898
  apiService = inject(ChatApiService);
2816
2899
  authService = inject(AuthService);
2900
+ customConfig = inject(CoreConfigService);
2817
2901
  audioService = inject(ChatAudioService);
2818
2902
  config = inject(DOOHBOT_ADVANCED_CONFIG, { optional: true });
2819
2903
  chatHistoryService = inject(ChatHistoryService);
@@ -2839,7 +2923,8 @@ class ChatService {
2839
2923
  apiError = signal(null, ...(ngDevMode ? [{ debugName: "apiError" }] : []));
2840
2924
  isBotTyping = signal(false, ...(ngDevMode ? [{ debugName: "isBotTyping" }] : []));
2841
2925
  promptMode = signal('markdown', ...(ngDevMode ? [{ debugName: "promptMode" }] : []));
2842
- isStreaming = signal(true, ...(ngDevMode ? [{ debugName: "isStreaming" }] : [])); //! `isStreaming` is set to true by default
2926
+ //! Controls whether to use Streaming API (default) or Standard API
2927
+ isStreaming = computed(() => !this.customConfig.useStandardApi, ...(ngDevMode ? [{ debugName: "isStreaming" }] : []));
2843
2928
  messagesStream = [];
2844
2929
  currentResponse = '';
2845
2930
  streamSubscription;
@@ -4493,76 +4578,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
4493
4578
  }]
4494
4579
  }] });
4495
4580
 
4496
- // export const environment = {
4497
- // staging: false,
4498
- // development: false,
4499
- // production: true,
4500
- // chatApiUrl: 'https://api.production.com',
4501
- // apiKey: '',
4502
- // };
4503
- const environment = {
4504
- config: 'const/app-const.json',
4505
- production: false,
4506
- apiBaseUrl: '',
4507
- loginEndpoint: '',
4508
- apiSegment: 'api/v1/',
4509
- };
4510
-
4511
- class AppConst {
4512
- static appBaseUrl = environment.apiBaseUrl;
4513
- static data;
4514
- config$ = new ReplaySubject(1);
4515
- constructor() { }
4516
- async load() {
4517
- const filePath = `./assets/${environment.production ? environment.config : environment.config}?t=${new Date().getTime()}`;
4518
- const response = await fetch(filePath);
4519
- if (!response.ok) {
4520
- Logger.error('============================ ERROR ============================');
4521
- Logger.error(`Could not find file ${filePath}`);
4522
- Logger.error('============================ ERROR ============================');
4523
- }
4524
- Logger.error('============================ AppConst ============================', filePath);
4525
- if (response.ok) {
4526
- try {
4527
- AppConst.data = await response.json();
4528
- this.config$.next(AppConst.data);
4529
- Logger.error('============================ AppConst ============================', AppConst.data);
4530
- // Override apiBaseUrl if present in environment
4531
- // if (environment.apiBaseUrl) {
4532
- // AppConst.data.apiBaseUrl = environment.apiBaseUrl;
4533
- // }
4534
- // // Override loginEndpoint if present in environment
4535
- // if (environment.loginEndpoint) {
4536
- // AppConst.data.loginEndpoint = environment.loginEndpoint;
4537
- // }
4538
- }
4539
- catch (error) {
4540
- Logger.error('============================ ERROR ============================');
4541
- Logger.error(`Could not find file ${filePath}.\nMESSAGE: ${error.message}`);
4542
- Logger.error('============================ ERROR ============================');
4543
- }
4544
- if (AppConst.data && !Object.keys(AppConst.data).length) {
4545
- Logger.error('============================ ERROR ============================');
4546
- Logger.error(`No data found in file ${filePath}`);
4547
- Logger.error('============================ ERROR ============================');
4548
- }
4549
- }
4550
- else {
4551
- Logger.error('============================ ERROR ============================');
4552
- Logger.error(`Failed to load file ${filePath}.\nMESSAGE: Request failed with ${response.status} / ${response.statusText}`);
4553
- Logger.error('============================ ERROR ============================');
4554
- }
4555
- }
4556
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
4557
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, providedIn: 'root' });
4558
- }
4559
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: AppConst, decorators: [{
4560
- type: Injectable,
4561
- args: [{
4562
- providedIn: 'root',
4563
- }]
4564
- }], ctorParameters: () => [] });
4565
-
4566
4581
  class AuthInterceptor {
4567
4582
  tokenStorage;
4568
4583
  injector;
@@ -5101,13 +5116,17 @@ function initializeApp() {
5101
5116
  const appConst = inject(AppConst);
5102
5117
  return () => appConst.load();
5103
5118
  }
5104
- bootstrapApplication(Doohbot, {
5105
- providers: [
5119
+ function initializeAppConst(appConst) {
5120
+ return () => appConst.load();
5121
+ }
5122
+ function provideDoohbot() {
5123
+ return makeEnvironmentProviders([
5106
5124
  provideHttpClient(withInterceptorsFromDi()),
5107
5125
  AppConst,
5108
5126
  {
5109
5127
  provide: APP_INITIALIZER,
5110
5128
  useFactory: initializeApp,
5129
+ deps: [AppConst],
5111
5130
  multi: true,
5112
5131
  },
5113
5132
  {
@@ -5120,8 +5139,8 @@ bootstrapApplication(Doohbot, {
5120
5139
  useClass: LicenseInterceptor,
5121
5140
  multi: true,
5122
5141
  },
5123
- ],
5124
- });
5142
+ ]);
5143
+ }
5125
5144
 
5126
5145
  /**
5127
5146
  * Injection token for providing Doohbot API configuration
@@ -5219,5 +5238,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
5219
5238
  * Generated bundle index. Do not edit.
5220
5239
  */
5221
5240
 
5222
- export { Chips, DOOHBOT_API_CONFIG, DialogComponent, DialogService, Doohbot, DoohbotConst, DoohbotInput, DropdownMenu, MenuItem, SnackBar, initializeApp };
5241
+ export { Chips, DOOHBOT_API_CONFIG, DialogComponent, DialogService, Doohbot, DoohbotConst, DoohbotInput, DropdownMenu, MenuItem, SnackBar, initializeApp, initializeAppConst, provideDoohbot };
5223
5242
  //# sourceMappingURL=aakash58-chatbot.mjs.map