@posiwise/common-services 0.2.24 → 0.2.25
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.
|
@@ -2,24 +2,24 @@ import * as i0 from '@angular/core';
|
|
|
2
2
|
import { DOCUMENT, Inject, Injectable, isDevMode, inject, NgModule, ViewEncapsulation } from '@angular/core';
|
|
3
3
|
import * as i3 from '@angular/router';
|
|
4
4
|
import { NavigationEnd } from '@angular/router';
|
|
5
|
-
import * as
|
|
5
|
+
import * as i2 from '@posiwise/app-config-service';
|
|
6
6
|
import { AppConfigService } from '@posiwise/app-config-service';
|
|
7
|
-
import * as i1$
|
|
7
|
+
import * as i1$1 from '@angular/common/http';
|
|
8
8
|
import { HttpErrorResponse, HttpHeaders } from '@angular/common/http';
|
|
9
9
|
import { throwError, of, BehaviorSubject, tap, timer } from 'rxjs';
|
|
10
10
|
import { catchError, take, tap as tap$1, switchMap, map, mergeMap, distinctUntilChanged } from 'rxjs/operators';
|
|
11
11
|
import { HelperService } from '@posiwise/helper-service';
|
|
12
|
-
import * as i1
|
|
12
|
+
import * as i1 from 'ngx-toastr';
|
|
13
13
|
import { CommonModule } from '@angular/common';
|
|
14
14
|
import { getUser, SetUser, UserActionTypes, appReducers } from '@posiwise/app-store';
|
|
15
|
-
import * as i1$
|
|
15
|
+
import * as i1$2 from '@ngrx/effects';
|
|
16
16
|
import { Actions, createEffect, ofType, EffectsModule } from '@ngrx/effects';
|
|
17
|
-
import * as
|
|
17
|
+
import * as i3$1 from '@ngrx/store';
|
|
18
18
|
import { StoreModule } from '@ngrx/store';
|
|
19
|
-
import { INTEGRATIONS_API_PREFIX, MAIN_API_PREFIX, PROJECT_PATH, USER_PATH, TOKEN_HEADER_KEY, NEWSLETTER_CONFIRMATION_PATH, NEWSLETTER_UNSUBSCRIBE_PATH, CAPTCHA_VALIDATION_PATH, SOCIAL_LOGIN_PATH, TOKEN_KEY, PERMISSION_NAMES, ADMIN_SUB_MENU_WHITELIST, AB_TEST_ACTIONS, GEO_PATH, PRODUCT_PATH, CONTACT_US_PATH, INCIDENTS_PATH, INCIDENTS_PATH_ADMIN, NEWSLETTERS_PATH, NEWSLETTER_SUBSCRIPTION_PATH, ADMIN_FAQS_PATH, FAQS_PATH, ORGANIZATIONS_PATH, GLOBAL_SUBSCRIPTION_CONFIGS_PATH, GLOBAL_CONFIGS_PATH, USER_LOGIN_NOTIFICATION, FEEDBACK_QUESTIONS_PATH, USER_FEEDBACKS_PATH, CUSTOMER_SUPPORT_PATH, ADMIN_TAG_PATH, ADMIN_TAG_CATEGORIES_PATH, ADMIN_PATH, QUALIFICATIONS_PATH,
|
|
19
|
+
import { INTEGRATIONS_API_PREFIX, MAIN_API_PREFIX, PROJECT_PATH, USER_PATH, TOKEN_HEADER_KEY, NEWSLETTER_CONFIRMATION_PATH, NEWSLETTER_UNSUBSCRIBE_PATH, CAPTCHA_VALIDATION_PATH, SOCIAL_LOGIN_PATH, TOKEN_KEY, PERMISSION_NAMES, ADMIN_SUB_MENU_WHITELIST, AB_TEST_ACTIONS, GEO_PATH, PRODUCT_PATH, CONTACT_US_PATH, INCIDENTS_PATH, INCIDENTS_PATH_ADMIN, NEWSLETTERS_PATH, NEWSLETTER_SUBSCRIPTION_PATH, ADMIN_FAQS_PATH, FAQS_PATH, ORGANIZATIONS_PATH, GLOBAL_SUBSCRIPTION_CONFIGS_PATH, GLOBAL_CONFIGS_PATH, USER_LOGIN_NOTIFICATION, FEEDBACK_QUESTIONS_PATH, USER_FEEDBACKS_PATH, CUSTOMER_SUPPORT_PATH, ADMIN_TAG_PATH, ADMIN_TAG_CATEGORIES_PATH, ADMIN_PATH, QUALIFICATIONS_PATH, BRAIN_API_PREFIX, SOCKET_TYPE } from '@posiwise/common-utilities';
|
|
20
20
|
import swal from 'sweetalert2';
|
|
21
21
|
import moment from 'moment';
|
|
22
|
-
import * as i1$
|
|
22
|
+
import * as i1$3 from '@angular/platform-browser';
|
|
23
23
|
import cloneDeep from 'lodash/cloneDeep';
|
|
24
24
|
import pickBy from 'lodash/pickBy';
|
|
25
25
|
import * as i2$1 from 'ngx-cookie';
|
|
@@ -227,12 +227,12 @@ class GoogleAnalyticsService {
|
|
|
227
227
|
this.subscription.unsubscribe();
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: GoogleAnalyticsService, deps: [{ token: i3.Router }, { token: ScriptLoaderService }, { token:
|
|
230
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: GoogleAnalyticsService, deps: [{ token: i3.Router }, { token: ScriptLoaderService }, { token: i2.AppConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
231
231
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: GoogleAnalyticsService }); }
|
|
232
232
|
}
|
|
233
233
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: GoogleAnalyticsService, decorators: [{
|
|
234
234
|
type: Injectable
|
|
235
|
-
}], ctorParameters: () => [{ type: i3.Router }, { type: ScriptLoaderService }, { type:
|
|
235
|
+
}], ctorParameters: () => [{ type: i3.Router }, { type: ScriptLoaderService }, { type: i2.AppConfigService }] });
|
|
236
236
|
|
|
237
237
|
class CustomToastService {
|
|
238
238
|
constructor(toastr) {
|
|
@@ -304,7 +304,7 @@ class CustomToastService {
|
|
|
304
304
|
this.error(message);
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: CustomToastService, deps: [{ token: i1
|
|
307
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: CustomToastService, deps: [{ token: i1.ToastrService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
308
308
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: CustomToastService, providedIn: 'root' }); }
|
|
309
309
|
}
|
|
310
310
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: CustomToastService, decorators: [{
|
|
@@ -312,7 +312,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
312
312
|
args: [{
|
|
313
313
|
providedIn: 'root'
|
|
314
314
|
}]
|
|
315
|
-
}], ctorParameters: () => [{ type: i1
|
|
315
|
+
}], ctorParameters: () => [{ type: i1.ToastrService }] });
|
|
316
316
|
|
|
317
317
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
318
318
|
class BaseHttpService {
|
|
@@ -398,12 +398,12 @@ class BaseHttpService {
|
|
|
398
398
|
this.toast.showToast(error);
|
|
399
399
|
}
|
|
400
400
|
}
|
|
401
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BaseHttpService, deps: [{ token: i1$
|
|
401
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BaseHttpService, deps: [{ token: i1$1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
402
402
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BaseHttpService }); }
|
|
403
403
|
}
|
|
404
404
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BaseHttpService, decorators: [{
|
|
405
405
|
type: Injectable
|
|
406
|
-
}], ctorParameters: () => [{ type: i1$
|
|
406
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i0.Injector }] });
|
|
407
407
|
|
|
408
408
|
class IntegrationsApiHttpService extends BaseHttpService {
|
|
409
409
|
constructor(http, injector) {
|
|
@@ -416,7 +416,7 @@ class IntegrationsApiHttpService extends BaseHttpService {
|
|
|
416
416
|
: config?.['links']?.integrations_api;
|
|
417
417
|
});
|
|
418
418
|
}
|
|
419
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: IntegrationsApiHttpService, deps: [{ token: i1$
|
|
419
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: IntegrationsApiHttpService, deps: [{ token: i1$1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
420
420
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: IntegrationsApiHttpService, providedIn: 'root' }); }
|
|
421
421
|
}
|
|
422
422
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: IntegrationsApiHttpService, decorators: [{
|
|
@@ -424,7 +424,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
424
424
|
args: [{
|
|
425
425
|
providedIn: 'root'
|
|
426
426
|
}]
|
|
427
|
-
}], ctorParameters: () => [{ type: i1$
|
|
427
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i0.Injector }] });
|
|
428
428
|
|
|
429
429
|
class LocalStorage {
|
|
430
430
|
getItem$(key) {
|
|
@@ -464,7 +464,7 @@ class MainApiHttpService extends BaseHttpService {
|
|
|
464
464
|
this.baseUrl = isDevMode() ? MAIN_API_PREFIX : config?.['links']?.main_api;
|
|
465
465
|
});
|
|
466
466
|
}
|
|
467
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: MainApiHttpService, deps: [{ token: i1$
|
|
467
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: MainApiHttpService, deps: [{ token: i1$1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
468
468
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: MainApiHttpService, providedIn: 'root' }); }
|
|
469
469
|
}
|
|
470
470
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: MainApiHttpService, decorators: [{
|
|
@@ -472,7 +472,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
472
472
|
args: [{
|
|
473
473
|
providedIn: 'root'
|
|
474
474
|
}]
|
|
475
|
-
}], ctorParameters: () => [{ type: i1$
|
|
475
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i0.Injector }] });
|
|
476
476
|
|
|
477
477
|
/**
|
|
478
478
|
* Secure Token Storage Service
|
|
@@ -1007,7 +1007,7 @@ class UserService {
|
|
|
1007
1007
|
refreshUserApiTokens() {
|
|
1008
1008
|
return this.api.get(`${this.endpoint}/refresh_user_api_tokens`);
|
|
1009
1009
|
}
|
|
1010
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: UserService, deps: [{ token: MainApiHttpService }, { token:
|
|
1010
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: UserService, deps: [{ token: MainApiHttpService }, { token: i3$1.Store }, { token: i3.Router }, { token: i2.AppConfigService }, { token: ProfileService }, { token: CustomToastService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1011
1011
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: UserService, providedIn: 'root' }); }
|
|
1012
1012
|
}
|
|
1013
1013
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: UserService, decorators: [{
|
|
@@ -1015,7 +1015,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
1015
1015
|
args: [{
|
|
1016
1016
|
providedIn: 'root'
|
|
1017
1017
|
}]
|
|
1018
|
-
}], ctorParameters: () => [{ type: MainApiHttpService }, { type:
|
|
1018
|
+
}], ctorParameters: () => [{ type: MainApiHttpService }, { type: i3$1.Store }, { type: i3.Router }, { type: i2.AppConfigService }, { type: ProfileService }, { type: CustomToastService }] });
|
|
1019
1019
|
|
|
1020
1020
|
class AuthService {
|
|
1021
1021
|
constructor(localStorage, secureTokenStorage, router, http, userService, toastr, appConfigService, integrationsApi, document) {
|
|
@@ -1157,6 +1157,7 @@ class AuthService {
|
|
|
1157
1157
|
}
|
|
1158
1158
|
return this.http.delete('session', options).pipe(tap$1(() => {
|
|
1159
1159
|
this.secureTokenStorage.clearTokens().subscribe();
|
|
1160
|
+
this.clearBrainChatStorage();
|
|
1160
1161
|
// Reset Crisp session on logout so next visitor is anonymous again
|
|
1161
1162
|
if (typeof window?.$crisp?.push === 'function') {
|
|
1162
1163
|
window.$crisp.push(['do', 'session:reset']);
|
|
@@ -1167,6 +1168,25 @@ class AuthService {
|
|
|
1167
1168
|
}
|
|
1168
1169
|
}));
|
|
1169
1170
|
}
|
|
1171
|
+
/**
|
|
1172
|
+
* Wipe every `pw-brain.*` localStorage key on logout so the next user
|
|
1173
|
+
* on a shared browser doesn't inherit the previous user's chat thread
|
|
1174
|
+
* (ticket #4167). Best-effort: private-browsing / quota throws are
|
|
1175
|
+
* swallowed so logout never breaks.
|
|
1176
|
+
*/
|
|
1177
|
+
clearBrainChatStorage() {
|
|
1178
|
+
try {
|
|
1179
|
+
for (let i = localStorage.length - 1; i >= 0; i--) {
|
|
1180
|
+
const key = localStorage.key(i);
|
|
1181
|
+
if (key?.startsWith('pw-brain.')) {
|
|
1182
|
+
localStorage.removeItem(key);
|
|
1183
|
+
}
|
|
1184
|
+
}
|
|
1185
|
+
}
|
|
1186
|
+
catch {
|
|
1187
|
+
// ignored — best-effort cleanup
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1170
1190
|
/**
|
|
1171
1191
|
* Clear all authentication tokens
|
|
1172
1192
|
*/
|
|
@@ -1374,12 +1394,12 @@ class AuthService {
|
|
|
1374
1394
|
}
|
|
1375
1395
|
});
|
|
1376
1396
|
}
|
|
1377
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AuthService, deps: [{ token: LocalStorage }, { token: SecureTokenStorageService }, { token: i3.Router }, { token: MainApiHttpService }, { token: UserService }, { token: CustomToastService }, { token:
|
|
1397
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AuthService, deps: [{ token: LocalStorage }, { token: SecureTokenStorageService }, { token: i3.Router }, { token: MainApiHttpService }, { token: UserService }, { token: CustomToastService }, { token: i2.AppConfigService }, { token: IntegrationsApiHttpService }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1378
1398
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AuthService }); }
|
|
1379
1399
|
}
|
|
1380
1400
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AuthService, decorators: [{
|
|
1381
1401
|
type: Injectable
|
|
1382
|
-
}], ctorParameters: () => [{ type: LocalStorage }, { type: SecureTokenStorageService }, { type: i3.Router }, { type: MainApiHttpService }, { type: UserService }, { type: CustomToastService }, { type:
|
|
1402
|
+
}], ctorParameters: () => [{ type: LocalStorage }, { type: SecureTokenStorageService }, { type: i3.Router }, { type: MainApiHttpService }, { type: UserService }, { type: CustomToastService }, { type: i2.AppConfigService }, { type: IntegrationsApiHttpService }, { type: Document, decorators: [{
|
|
1383
1403
|
type: Inject,
|
|
1384
1404
|
args: [DOCUMENT]
|
|
1385
1405
|
}] }] });
|
|
@@ -1406,7 +1426,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
1406
1426
|
|
|
1407
1427
|
class CommonServicesModule {
|
|
1408
1428
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: CommonServicesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
|
|
1409
|
-
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.6", ngImport: i0, type: CommonServicesModule, imports: [CommonModule, i1$
|
|
1429
|
+
static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.6", ngImport: i0, type: CommonServicesModule, imports: [CommonModule, i1$2.EffectsRootModule, i3$1.StoreRootModule] }); }
|
|
1410
1430
|
static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: CommonServicesModule, providers: [AuthService], imports: [CommonModule, EffectsModule.forRoot([UserEffects]), StoreModule.forRoot(appReducers)] }); }
|
|
1411
1431
|
}
|
|
1412
1432
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: CommonServicesModule, decorators: [{
|
|
@@ -1446,7 +1466,7 @@ class SeoService {
|
|
|
1446
1466
|
this.meta.updateTag({ name: 'twitter:description', content: description });
|
|
1447
1467
|
this.meta.updateTag({ name: 'twitter:card', content: 'summary' });
|
|
1448
1468
|
}
|
|
1449
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SeoService, deps: [{ token: i1$
|
|
1469
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SeoService, deps: [{ token: i1$3.Meta }, { token: i1$3.Title }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1450
1470
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SeoService, providedIn: 'root' }); }
|
|
1451
1471
|
}
|
|
1452
1472
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SeoService, decorators: [{
|
|
@@ -1454,7 +1474,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
1454
1474
|
args: [{
|
|
1455
1475
|
providedIn: 'root'
|
|
1456
1476
|
}]
|
|
1457
|
-
}], ctorParameters: () => [{ type: i1$
|
|
1477
|
+
}], ctorParameters: () => [{ type: i1$3.Meta }, { type: i1$3.Title }] });
|
|
1458
1478
|
|
|
1459
1479
|
/**
|
|
1460
1480
|
* Centralized feature flag evaluation service.
|
|
@@ -1912,7 +1932,7 @@ class AbTestService {
|
|
|
1912
1932
|
? this.injector.get(service)
|
|
1913
1933
|
: this.injector.get(MainApiHttpService);
|
|
1914
1934
|
}
|
|
1915
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AbTestService, deps: [{ token: i0.Injector }, { token: i1$
|
|
1935
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AbTestService, deps: [{ token: i0.Injector }, { token: i1$1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
1916
1936
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AbTestService, providedIn: 'root' }); }
|
|
1917
1937
|
}
|
|
1918
1938
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AbTestService, decorators: [{
|
|
@@ -1920,7 +1940,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
1920
1940
|
args: [{
|
|
1921
1941
|
providedIn: 'root'
|
|
1922
1942
|
}]
|
|
1923
|
-
}], ctorParameters: () => [{ type: i0.Injector }, { type: i1$
|
|
1943
|
+
}], ctorParameters: () => [{ type: i0.Injector }, { type: i1$1.HttpClient }] });
|
|
1924
1944
|
|
|
1925
1945
|
class GeoService {
|
|
1926
1946
|
constructor(api, cookieService) {
|
|
@@ -2024,8 +2044,8 @@ class SubscriptionService {
|
|
|
2024
2044
|
toggleAdmin(id, data) {
|
|
2025
2045
|
return this.api.put(`/subscriptions/${id}/toggle_admin`, data);
|
|
2026
2046
|
}
|
|
2027
|
-
updateSubscriptionAPIKey(id) {
|
|
2028
|
-
return this.api.put(`/subscriptions/${id}/update_api_key
|
|
2047
|
+
updateSubscriptionAPIKey(id, productId) {
|
|
2048
|
+
return this.api.put(`/subscriptions/${id}/update_api_key`, { product_id: productId });
|
|
2029
2049
|
}
|
|
2030
2050
|
refreshApiTokens(id) {
|
|
2031
2051
|
return this.api.get(`/subscriptions/${id}/refresh_api_tokens`);
|
|
@@ -2297,7 +2317,7 @@ class AhoyService {
|
|
|
2297
2317
|
this.toast.showToast(error);
|
|
2298
2318
|
}
|
|
2299
2319
|
}
|
|
2300
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AhoyService, deps: [{ token: i1$
|
|
2320
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AhoyService, deps: [{ token: i1$1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2301
2321
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AhoyService, providedIn: 'root' }); }
|
|
2302
2322
|
}
|
|
2303
2323
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: AhoyService, decorators: [{
|
|
@@ -2305,7 +2325,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
2305
2325
|
args: [{
|
|
2306
2326
|
providedIn: 'root'
|
|
2307
2327
|
}]
|
|
2308
|
-
}], ctorParameters: () => [{ type: i1$
|
|
2328
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i0.Injector }] });
|
|
2309
2329
|
|
|
2310
2330
|
class CommonService {
|
|
2311
2331
|
constructor(api) {
|
|
@@ -2958,7 +2978,7 @@ class McpJsonRpcService {
|
|
|
2958
2978
|
return res.result;
|
|
2959
2979
|
}));
|
|
2960
2980
|
}
|
|
2961
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: McpJsonRpcService, deps: [{ token: i1$
|
|
2981
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: McpJsonRpcService, deps: [{ token: i1$1.HttpClient }, { token: i2.AppConfigService }, { token: i3$1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2962
2982
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: McpJsonRpcService, providedIn: 'root' }); }
|
|
2963
2983
|
}
|
|
2964
2984
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: McpJsonRpcService, decorators: [{
|
|
@@ -2966,7 +2986,99 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
2966
2986
|
args: [{
|
|
2967
2987
|
providedIn: 'root'
|
|
2968
2988
|
}]
|
|
2969
|
-
}], ctorParameters: () => [{ type: i1$
|
|
2989
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i2.AppConfigService }, { type: i3$1.Store }] });
|
|
2990
|
+
|
|
2991
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2992
|
+
class MCPOrchestratorService {
|
|
2993
|
+
/**
|
|
2994
|
+
* Dev base — `BRAIN_API_PREFIX` = '/brain-api/v1/'. In prod the
|
|
2995
|
+
* orchestrator is reached via the API-gateway public hostname; we read
|
|
2996
|
+
* it from `links.brain_api` in app config (same convention as
|
|
2997
|
+
* `BrainApiHttpService`).
|
|
2998
|
+
*/
|
|
2999
|
+
constructor(http, appConfigService, store) {
|
|
3000
|
+
this.http = http;
|
|
3001
|
+
this.appConfigService = appConfigService;
|
|
3002
|
+
this.store = store;
|
|
3003
|
+
}
|
|
3004
|
+
execute(body) {
|
|
3005
|
+
return this.post('mcp/execute', body);
|
|
3006
|
+
}
|
|
3007
|
+
interpret(body) {
|
|
3008
|
+
return this.post('mcp/interpret', body);
|
|
3009
|
+
}
|
|
3010
|
+
confirm(body) {
|
|
3011
|
+
return this.post('mcp/confirm', body);
|
|
3012
|
+
}
|
|
3013
|
+
post(path, body) {
|
|
3014
|
+
const base$ = isDevMode()
|
|
3015
|
+
? of(BRAIN_API_PREFIX.replace(/\/$/, ''))
|
|
3016
|
+
: this.appConfigService.appConfig$.pipe(take(1), switchMap(c => {
|
|
3017
|
+
const url = c?.links?.['brain_api'];
|
|
3018
|
+
if (typeof url === 'string' && url.trim()) {
|
|
3019
|
+
return of(url.trim().replace(/\/$/, ''));
|
|
3020
|
+
}
|
|
3021
|
+
return throwError(() => new Error('Brain API is not configured: set links.brain_api in app configuration.'));
|
|
3022
|
+
}));
|
|
3023
|
+
return base$.pipe(switchMap(base => this.store.pipe(take(1), map((app) => this.pickApiCredentials(app.user?.currentUser ?? null)), switchMap(creds => {
|
|
3024
|
+
if (!creds) {
|
|
3025
|
+
return throwError(() => new Error('PosiWise Brain needs API credentials. Go to /account/details to set or rotate your API keys, then open the active subscription from /account/subscriptions to refresh its credentials.'));
|
|
3026
|
+
}
|
|
3027
|
+
return this.http.post(`${base}/${path}`, body, {
|
|
3028
|
+
headers: this.buildHeaders(creds)
|
|
3029
|
+
});
|
|
3030
|
+
}))));
|
|
3031
|
+
}
|
|
3032
|
+
/**
|
|
3033
|
+
* Pull `(token, userId, clientId?)` for the active session.
|
|
3034
|
+
*
|
|
3035
|
+
* `clientId` comes from `PermissionService.selectedSubscription` — the
|
|
3036
|
+
* canonical "currently-active subscription" on this frontend, set when
|
|
3037
|
+
* the user picks/lands on a subscription. Every other place in the
|
|
3038
|
+
* codebase that needs subscription context (mailbox, chatbox, search,
|
|
3039
|
+
* dashboard, admin lists) reads from the same static. Without it,
|
|
3040
|
+
* downstream MCP tools that require subscription scope (e.g.
|
|
3041
|
+
* `cloudolive-api.count_reconciled_account_inputs`) reject the call
|
|
3042
|
+
* with `McpError: This tool requires subscription context. Please
|
|
3043
|
+
* provide api_client_id parameter`.
|
|
3044
|
+
*
|
|
3045
|
+
* `api_client_id` does NOT live on the `User` interface — it's a
|
|
3046
|
+
* property of `Subscription` (`subscription.interface.ts`). Reading
|
|
3047
|
+
* from the user object would always return `undefined` and silently
|
|
3048
|
+
* drop the header.
|
|
3049
|
+
*/
|
|
3050
|
+
pickApiCredentials(user) {
|
|
3051
|
+
if (!user) {
|
|
3052
|
+
return null;
|
|
3053
|
+
}
|
|
3054
|
+
const token = user.api_user_token ?? user.api_keys?.api_user_token;
|
|
3055
|
+
const userId = user.api_user_id ?? user.api_keys?.api_user_id;
|
|
3056
|
+
if (!token || !userId) {
|
|
3057
|
+
return null;
|
|
3058
|
+
}
|
|
3059
|
+
const clientId = PermissionService.selectedSubscription?.api_client_id;
|
|
3060
|
+
return { token, userId, clientId };
|
|
3061
|
+
}
|
|
3062
|
+
buildHeaders(creds) {
|
|
3063
|
+
let h = new HttpHeaders({
|
|
3064
|
+
'Content-Type': 'application/json',
|
|
3065
|
+
'X-API-USER-TOKEN': creds.token,
|
|
3066
|
+
'X-API-USER-ID': creds.userId
|
|
3067
|
+
});
|
|
3068
|
+
if (creds.clientId) {
|
|
3069
|
+
h = h.set('X-API-CLIENT-ID', creds.clientId);
|
|
3070
|
+
}
|
|
3071
|
+
return h;
|
|
3072
|
+
}
|
|
3073
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: MCPOrchestratorService, deps: [{ token: i1$1.HttpClient }, { token: i2.AppConfigService }, { token: i3$1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3074
|
+
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: MCPOrchestratorService, providedIn: 'root' }); }
|
|
3075
|
+
}
|
|
3076
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: MCPOrchestratorService, decorators: [{
|
|
3077
|
+
type: Injectable,
|
|
3078
|
+
args: [{
|
|
3079
|
+
providedIn: 'root'
|
|
3080
|
+
}]
|
|
3081
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i2.AppConfigService }, { type: i3$1.Store }] });
|
|
2970
3082
|
|
|
2971
3083
|
class WebsocketService {
|
|
2972
3084
|
constructor(appConfigService, authService) {
|
|
@@ -2979,7 +3091,7 @@ class WebsocketService {
|
|
|
2979
3091
|
this.webSocket$ = this.webSocketSubject.asObservable().pipe(distinctUntilChanged());
|
|
2980
3092
|
});
|
|
2981
3093
|
}
|
|
2982
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: WebsocketService, deps: [{ token:
|
|
3094
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: WebsocketService, deps: [{ token: i2.AppConfigService }, { token: AuthService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
2983
3095
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: WebsocketService, providedIn: 'root' }); }
|
|
2984
3096
|
}
|
|
2985
3097
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: WebsocketService, decorators: [{
|
|
@@ -2987,7 +3099,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
2987
3099
|
args: [{
|
|
2988
3100
|
providedIn: 'root'
|
|
2989
3101
|
}]
|
|
2990
|
-
}], ctorParameters: () => [{ type:
|
|
3102
|
+
}], ctorParameters: () => [{ type: i2.AppConfigService }, { type: AuthService }] });
|
|
2991
3103
|
|
|
2992
3104
|
class NotificationService {
|
|
2993
3105
|
constructor(api, toastrService, socketService) {
|
|
@@ -3535,7 +3647,7 @@ class SentryErrorHandler {
|
|
|
3535
3647
|
console.error(error, e);
|
|
3536
3648
|
}
|
|
3537
3649
|
}
|
|
3538
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SentryErrorHandler, deps: [{ token:
|
|
3650
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SentryErrorHandler, deps: [{ token: i2.AppConfigService }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3539
3651
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SentryErrorHandler, providedIn: 'root' }); }
|
|
3540
3652
|
}
|
|
3541
3653
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: SentryErrorHandler, decorators: [{
|
|
@@ -3543,7 +3655,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
3543
3655
|
args: [{
|
|
3544
3656
|
providedIn: 'root'
|
|
3545
3657
|
}]
|
|
3546
|
-
}], ctorParameters: () => [{ type:
|
|
3658
|
+
}], ctorParameters: () => [{ type: i2.AppConfigService }] });
|
|
3547
3659
|
|
|
3548
3660
|
class LogoCacheService {
|
|
3549
3661
|
constructor() {
|
|
@@ -3659,7 +3771,7 @@ class BrainApiHttpService extends BaseHttpService {
|
|
|
3659
3771
|
this.baseUrl = isDevMode() ? BRAIN_API_PREFIX : config?.['links']['brain_api'] ?? '';
|
|
3660
3772
|
});
|
|
3661
3773
|
}
|
|
3662
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BrainApiHttpService, deps: [{ token: i1$
|
|
3774
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BrainApiHttpService, deps: [{ token: i1$1.HttpClient }, { token: i0.Injector }], target: i0.ɵɵFactoryTarget.Injectable }); }
|
|
3663
3775
|
static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BrainApiHttpService, providedIn: 'root' }); }
|
|
3664
3776
|
}
|
|
3665
3777
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImport: i0, type: BrainApiHttpService, decorators: [{
|
|
@@ -3667,7 +3779,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
3667
3779
|
args: [{
|
|
3668
3780
|
providedIn: 'root'
|
|
3669
3781
|
}]
|
|
3670
|
-
}], ctorParameters: () => [{ type: i1$
|
|
3782
|
+
}], ctorParameters: () => [{ type: i1$1.HttpClient }, { type: i0.Injector }] });
|
|
3671
3783
|
|
|
3672
3784
|
class BrainApiService {
|
|
3673
3785
|
constructor(api) {
|
|
@@ -3694,5 +3806,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.6", ngImpor
|
|
|
3694
3806
|
* Generated bundle index. Do not edit.
|
|
3695
3807
|
*/
|
|
3696
3808
|
|
|
3697
|
-
export { AbTestService, AhoyService, AuthService, BaseHttpService, BrainApiHttpService, BrainApiService, CommonService, CommonServicesModule, CustomPreloadingStrategy, CustomToastService, DashboardService, DataService, FeatureFlagService, FormHelperService, GeoService, GoogleAnalyticsService, GroupService, HopscotchService, IntegrationsApiHttpService, LinkService, LocalStorage, LogoCacheService, MailBoxService, MainApiHttpService, McpJsonRpcService, NgbDateCustomParserFormatter, NotificationService, NumberPickerService, PermissionService, PrimeNgHelper, ProductService, ProfileService, QualificationService, ScriptLoaderService, SecureTokenStorageService, SentryErrorHandler, SeoService, SubscriptionService, TagService, TipsService, UserEffects, UserService, ValidationService, WebsocketService, WindowService };
|
|
3809
|
+
export { AbTestService, AhoyService, AuthService, BaseHttpService, BrainApiHttpService, BrainApiService, CommonService, CommonServicesModule, CustomPreloadingStrategy, CustomToastService, DashboardService, DataService, FeatureFlagService, FormHelperService, GeoService, GoogleAnalyticsService, GroupService, HopscotchService, IntegrationsApiHttpService, LinkService, LocalStorage, LogoCacheService, MCPOrchestratorService, MailBoxService, MainApiHttpService, McpJsonRpcService, NgbDateCustomParserFormatter, NotificationService, NumberPickerService, PermissionService, PrimeNgHelper, ProductService, ProfileService, QualificationService, ScriptLoaderService, SecureTokenStorageService, SentryErrorHandler, SeoService, SubscriptionService, TagService, TipsService, UserEffects, UserService, ValidationService, WebsocketService, WindowService };
|
|
3698
3810
|
//# sourceMappingURL=posiwise-common-services.mjs.map
|