@aakash58/chatbot 1.1.11 → 1.1.13
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/fesm2022/aakash58-chatbot.mjs +118 -60
- package/fesm2022/aakash58-chatbot.mjs.map +1 -1
- package/index.d.ts +27 -1
- package/package.json +1 -1
|
@@ -338,13 +338,12 @@ class HttpService {
|
|
|
338
338
|
http;
|
|
339
339
|
tokenStorage;
|
|
340
340
|
// @BlockUI() blockUI!: NgBlockUI;
|
|
341
|
-
|
|
342
|
-
return `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
|
|
343
|
-
}
|
|
341
|
+
apiUrl;
|
|
344
342
|
constructor(http, tokenStorage) {
|
|
345
343
|
this.http = http;
|
|
346
344
|
this.tokenStorage = tokenStorage;
|
|
347
|
-
|
|
345
|
+
this.apiUrl = `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
|
|
346
|
+
Logger.log('HttpService: Initialized', this.apiUrl);
|
|
348
347
|
}
|
|
349
348
|
get(url, param, nestedParam = false, showLoader = false, refresh = true, headers) {
|
|
350
349
|
// if (showLoader && !this.blockUI.isActive) {
|
|
@@ -521,20 +520,12 @@ class AuthService {
|
|
|
521
520
|
cryptoHelper;
|
|
522
521
|
tokenStorage;
|
|
523
522
|
router;
|
|
523
|
+
apiUrl;
|
|
524
|
+
storageKey;
|
|
525
|
+
secretKey;
|
|
526
|
+
companyCode;
|
|
524
527
|
jwtHelper = new JwtHelperService();
|
|
525
528
|
config = inject(DOOHBOT_ADVANCED_CONFIG, { optional: true });
|
|
526
|
-
get apiUrl() {
|
|
527
|
-
return `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
|
|
528
|
-
}
|
|
529
|
-
get storageKey() {
|
|
530
|
-
return AppConst?.data?.storageKey;
|
|
531
|
-
}
|
|
532
|
-
get secretKey() {
|
|
533
|
-
return AppConst?.data?.secretKey;
|
|
534
|
-
}
|
|
535
|
-
get companyCode() {
|
|
536
|
-
return AppConst?.data?.companyCode;
|
|
537
|
-
}
|
|
538
529
|
// Reactive Authentication State
|
|
539
530
|
authStatusSubject = new BehaviorSubject('unauthenticated');
|
|
540
531
|
authStatus$ = this.authStatusSubject.asObservable();
|
|
@@ -547,7 +538,11 @@ class AuthService {
|
|
|
547
538
|
this.cryptoHelper = cryptoHelper;
|
|
548
539
|
this.tokenStorage = tokenStorage;
|
|
549
540
|
this.router = router;
|
|
550
|
-
|
|
541
|
+
this.apiUrl = `${AppConst?.data?.apiBaseUrl}${AppConst?.data?.apiSegment}`;
|
|
542
|
+
this.storageKey = AppConst?.data?.storageKey;
|
|
543
|
+
this.secretKey = AppConst?.data?.secretKey;
|
|
544
|
+
this.companyCode = AppConst?.data?.companyCode;
|
|
545
|
+
this.cryptoHelper.setSecretKey(this.secretKey);
|
|
551
546
|
}
|
|
552
547
|
getLoggedInUserName() {
|
|
553
548
|
const username = this.tokenStorage.get('username');
|
|
@@ -4202,7 +4197,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
|
|
|
4202
4197
|
|
|
4203
4198
|
class LicenseService {
|
|
4204
4199
|
http = inject(HttpClient);
|
|
4205
|
-
tokenStorage = inject(StorageService);
|
|
4206
4200
|
registry = signal(null, ...(ngDevMode ? [{ debugName: "registry" }] : []));
|
|
4207
4201
|
/**
|
|
4208
4202
|
* Load the license configuration from a JSON file.
|
|
@@ -4296,60 +4290,34 @@ class LicenseService {
|
|
|
4296
4290
|
}
|
|
4297
4291
|
return null;
|
|
4298
4292
|
}
|
|
4299
|
-
resolveFromAppConst(packageId) {
|
|
4300
|
-
const licenseKeys = AppConst.data?.licenseKeys;
|
|
4301
|
-
if (licenseKeys && licenseKeys[packageId]) {
|
|
4302
|
-
Logger.debug(`[LicenseService] Resolved key for ${packageId} via AppConst.licenseKeys`);
|
|
4303
|
-
return licenseKeys[packageId];
|
|
4304
|
-
}
|
|
4305
|
-
return null;
|
|
4306
|
-
}
|
|
4307
4293
|
/**
|
|
4308
4294
|
* Resolves the license key for the current tenant.
|
|
4309
4295
|
* Auto-discovers tenant from URL or optional appBaseUrl pattern.
|
|
4310
4296
|
* Returns the key for 'doohbot' or null if not found.
|
|
4311
4297
|
*/
|
|
4312
4298
|
resolveTenantLicenseKey(appBaseUrl) {
|
|
4313
|
-
//
|
|
4314
|
-
const hostname = window.location.hostname;
|
|
4315
|
-
const protocol = window.location.protocol;
|
|
4316
|
-
const port = window.location.port ? `:${window.location.port}` : '';
|
|
4317
|
-
const currentUrl = `${protocol}//${hostname}${port}`;
|
|
4318
|
-
// Use provided appBaseUrl or fallback to AppConst
|
|
4319
|
-
const finalAppBaseUrl = appBaseUrl || AppConst.data?.appBaseUrl;
|
|
4320
|
-
// Resolve tenancy name
|
|
4299
|
+
// Attempt to resolve tenancy name using ABP utility
|
|
4321
4300
|
let tenancyName = null;
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
const match = currentUrl.match(regex);
|
|
4327
|
-
tenancyName = match?.[1] ?? null;
|
|
4301
|
+
try {
|
|
4302
|
+
tenancyName =
|
|
4303
|
+
window.AppPreBootstrap?.resolveTenancyName(window.AppConsts?.appBaseUrl || appBaseUrl) ||
|
|
4304
|
+
null;
|
|
4328
4305
|
}
|
|
4329
|
-
|
|
4330
|
-
|
|
4331
|
-
const parts = hostname.split('.');
|
|
4332
|
-
if (parts.length > 2)
|
|
4333
|
-
tenancyName = parts[0];
|
|
4306
|
+
catch (e) {
|
|
4307
|
+
Logger.error('[LicenseService] Error resolving tenancy name:', e);
|
|
4334
4308
|
}
|
|
4335
|
-
|
|
4309
|
+
Logger.info('[LicenseService] Detected tenancy name:', tenancyName);
|
|
4336
4310
|
if (!tenancyName) {
|
|
4337
4311
|
Logger.log('[LicenseService] Could not resolve tenancy name.');
|
|
4338
4312
|
return null;
|
|
4339
4313
|
}
|
|
4340
|
-
Logger.
|
|
4341
|
-
// Lookup license key in registry
|
|
4342
|
-
const
|
|
4343
|
-
|
|
4344
|
-
|
|
4345
|
-
|
|
4346
|
-
|
|
4347
|
-
// Return the 'doohbot' license if it exists
|
|
4348
|
-
if (tenantLicenses?.['doohbot']) {
|
|
4349
|
-
Logger.log(`[LicenseService] Found key for tenant: ${tenancyName}`);
|
|
4350
|
-
return tenantLicenses['doohbot'];
|
|
4351
|
-
}
|
|
4352
|
-
return null;
|
|
4314
|
+
Logger.info(`[LicenseService] Detected tenant: ${tenancyName}`);
|
|
4315
|
+
// Lookup license key in registry
|
|
4316
|
+
const tenantLicenses = this.registry()?.subjectLicenses.get(`tenant:${tenancyName}`);
|
|
4317
|
+
const licenseKey = tenantLicenses?.['doohbot'] || null;
|
|
4318
|
+
if (licenseKey)
|
|
4319
|
+
Logger.log(`[LicenseService] Found Doohbot license for tenant: ${tenancyName}`);
|
|
4320
|
+
return licenseKey;
|
|
4353
4321
|
}
|
|
4354
4322
|
/**
|
|
4355
4323
|
* Check if a registry is currently loaded
|
|
@@ -4367,6 +4335,93 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImpo
|
|
|
4367
4335
|
}]
|
|
4368
4336
|
}] });
|
|
4369
4337
|
|
|
4338
|
+
class EnvironmentDiagnosticService {
|
|
4339
|
+
/**
|
|
4340
|
+
* Collects all diagnostic information from the environment.
|
|
4341
|
+
*/
|
|
4342
|
+
getDiagnosticReport() {
|
|
4343
|
+
const report = {
|
|
4344
|
+
timestamp: new Date().toISOString(),
|
|
4345
|
+
url: window.location.href,
|
|
4346
|
+
storage: {
|
|
4347
|
+
localStorage: this.getLocalStorage(),
|
|
4348
|
+
sessionStorage: this.getSessionStorage(),
|
|
4349
|
+
},
|
|
4350
|
+
cookies: this.getCookies(),
|
|
4351
|
+
abpContext: this.getAbpContext(),
|
|
4352
|
+
};
|
|
4353
|
+
Logger.info('[EnvironmentDiagnostic] Full Diagnostic Report:', report);
|
|
4354
|
+
return report;
|
|
4355
|
+
}
|
|
4356
|
+
/**
|
|
4357
|
+
* Retrieves all items from localStorage.
|
|
4358
|
+
*/
|
|
4359
|
+
getLocalStorage() {
|
|
4360
|
+
const result = {};
|
|
4361
|
+
for (let i = 0; i < localStorage.length; i++) {
|
|
4362
|
+
const key = localStorage.key(i);
|
|
4363
|
+
if (key) {
|
|
4364
|
+
result[key] = localStorage.getItem(key) || '';
|
|
4365
|
+
}
|
|
4366
|
+
}
|
|
4367
|
+
Logger.info('[EnvironmentDiagnostic] LocalStorage:', result);
|
|
4368
|
+
return result;
|
|
4369
|
+
}
|
|
4370
|
+
/**
|
|
4371
|
+
* Retrieves all items from sessionStorage.
|
|
4372
|
+
*/
|
|
4373
|
+
getSessionStorage() {
|
|
4374
|
+
const result = {};
|
|
4375
|
+
for (let i = 0; i < sessionStorage.length; i++) {
|
|
4376
|
+
const key = sessionStorage.key(i);
|
|
4377
|
+
if (key) {
|
|
4378
|
+
result[key] = sessionStorage.getItem(key) || '';
|
|
4379
|
+
}
|
|
4380
|
+
}
|
|
4381
|
+
Logger.info('[EnvironmentDiagnostic] SessionStorage:', result);
|
|
4382
|
+
return result;
|
|
4383
|
+
}
|
|
4384
|
+
/**
|
|
4385
|
+
* Parses and retrieves all cookies.
|
|
4386
|
+
*/
|
|
4387
|
+
getCookies() {
|
|
4388
|
+
const result = {};
|
|
4389
|
+
const cookies = document.cookie.split(';');
|
|
4390
|
+
for (let cookie of cookies) {
|
|
4391
|
+
const [key, value] = cookie.trim().split('=');
|
|
4392
|
+
if (key) {
|
|
4393
|
+
result[key] = decodeURIComponent(value || '');
|
|
4394
|
+
}
|
|
4395
|
+
}
|
|
4396
|
+
Logger.info('[EnvironmentDiagnostic] Cookies:', result);
|
|
4397
|
+
return result;
|
|
4398
|
+
}
|
|
4399
|
+
/**
|
|
4400
|
+
* Checks for ABP-specific global variables.
|
|
4401
|
+
*/
|
|
4402
|
+
getAbpContext() {
|
|
4403
|
+
const win = window;
|
|
4404
|
+
const context = {
|
|
4405
|
+
hasAbp: !!win.abp,
|
|
4406
|
+
hasAppPreBootstrap: !!win.AppPreBootstrap,
|
|
4407
|
+
hasAppConsts: !!win.AppConsts,
|
|
4408
|
+
abpAuthToken: win.abp?.auth?.getToken ? 'FUNCTION_EXISTS' : 'NOT_FOUND',
|
|
4409
|
+
appConstsAppBaseUrl: win.AppConsts?.appBaseUrl || 'NOT_FOUND',
|
|
4410
|
+
tenancyName: win.AppPreBootstrap?.resolveTenancyName ? 'RESOLVER_EXISTS' : 'NOT_FOUND',
|
|
4411
|
+
};
|
|
4412
|
+
Logger.info('[EnvironmentDiagnostic] ABP Context:', context);
|
|
4413
|
+
return context;
|
|
4414
|
+
}
|
|
4415
|
+
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: EnvironmentDiagnosticService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
4416
|
+
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: EnvironmentDiagnosticService, providedIn: 'root' });
|
|
4417
|
+
}
|
|
4418
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.14", ngImport: i0, type: EnvironmentDiagnosticService, decorators: [{
|
|
4419
|
+
type: Injectable,
|
|
4420
|
+
args: [{
|
|
4421
|
+
providedIn: 'root',
|
|
4422
|
+
}]
|
|
4423
|
+
}] });
|
|
4424
|
+
|
|
4370
4425
|
class Doohbot extends DoohbotInput {
|
|
4371
4426
|
elementRef;
|
|
4372
4427
|
renderer;
|
|
@@ -4387,6 +4442,7 @@ class Doohbot extends DoohbotInput {
|
|
|
4387
4442
|
snackbarService = inject(SnackbarService);
|
|
4388
4443
|
personalization = inject(PersonalizationService);
|
|
4389
4444
|
licenseService = inject(LicenseService);
|
|
4445
|
+
diagnosticService = inject(EnvironmentDiagnosticService);
|
|
4390
4446
|
//! ========================= EXPOSED STATE FROM SERVICES ============================
|
|
4391
4447
|
// UI State signals
|
|
4392
4448
|
isChatOpen = this.uiState.isChatOpen;
|
|
@@ -4446,6 +4502,8 @@ class Doohbot extends DoohbotInput {
|
|
|
4446
4502
|
// Corrected structural integrity.
|
|
4447
4503
|
ngOnInit() {
|
|
4448
4504
|
Logger.log('Initializing Doohbot component...');
|
|
4505
|
+
// Run diagnostics
|
|
4506
|
+
this.diagnosticService.getDiagnosticReport();
|
|
4449
4507
|
// Run validation once on startup
|
|
4450
4508
|
this.authService.validateStoredToken().subscribe();
|
|
4451
4509
|
// React to auth status changes
|
|
@@ -4986,5 +5044,5 @@ function provideDoohbot() {
|
|
|
4986
5044
|
* Generated bundle index. Do not edit.
|
|
4987
5045
|
*/
|
|
4988
5046
|
|
|
4989
|
-
export { Chips, DOOHBOT_API_CONFIG, DialogComponent, DialogService, Doohbot, DoohbotConst, DoohbotInput, DropdownMenu, MenuItem, SnackBar, initializeApp, initializeDoohbotApp, provideDoohbot };
|
|
5047
|
+
export { Chips, DOOHBOT_API_CONFIG, DialogComponent, DialogService, Doohbot, DoohbotConst, DoohbotInput, DropdownMenu, EnvironmentDiagnosticService, MenuItem, SnackBar, initializeApp, initializeDoohbotApp, provideDoohbot };
|
|
4990
5048
|
//# sourceMappingURL=aakash58-chatbot.mjs.map
|