taxtank-core 1.0.6 → 1.0.8

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # Core
2
-
3
- TaxTank Core library with shared business logic. This logic should be shared between all TaxTank apps (Web/Native/future apps maybe).
4
-
5
- Contains all models, services, validators, etc.
1
+ # Core
2
+
3
+ TaxTank Core library with shared business logic. This logic should be shared between all TaxTank apps (Web/Native/future apps maybe).
4
+
5
+ Contains all models, services, validators, etc.
@@ -1 +1 @@
1
- {"version":3,"file":"taxtank-core-common.mjs","sources":["../../../projects/tt-core/common/src/services/mixpanel.service.ts","../../../projects/tt-core/common/src/db/enums/user/user-roles.enum.ts","../../../projects/tt-core/common/src/services/auth/jwt.service.ts","../../../projects/tt-core/common/src/services/auth/auth.service.ts","../../../projects/tt-core/common/src/services/auth/auth-messages.enum.ts","../../../projects/tt-core/common/src/interceptors/jwt-interceptor.ts","../../../projects/tt-core/common/src/interceptors/interceptors.module.ts","../../../projects/tt-core/common/src/common.module.ts","../../../projects/tt-core/common/taxtank-core-common.ts"],"sourcesContent":["import { Inject, Injectable } from '@angular/core';\r\nimport mixpanel from 'mixpanel-browser';\r\n\r\n/**\r\n * Service to work with mixpanel https://docs.mixpanel.com/docs/tracking/reference/javascript\r\n */\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class MixpanelService {\r\n constructor(@Inject('environment') private environment: any) {}\r\n\r\n init(): void {\r\n if (!this.environment.enableMixpanel) {\r\n return;\r\n }\r\n\r\n mixpanel.init(this.environment.mixpanelToken);\r\n }\r\n\r\n identify(id: string): void {\r\n if (!this.environment.enableMixpanel) {\r\n return;\r\n }\r\n\r\n mixpanel.identify(id);\r\n mixpanel.people.set({ 'last seen': new Date(Date.now()).toLocaleString() })\r\n }\r\n\r\n reset(): void {\r\n if (!this.environment.enableMixpanel) {\r\n return;\r\n }\r\n\r\n mixpanel.reset();\r\n }\r\n\r\n track(event: string, properties: { [key: string]: any } = {}): void {\r\n if (!this.environment.enableMixpanel) {\r\n return;\r\n }\r\n\r\n mixpanel.track(event, properties);\r\n }\r\n\r\n trackLink(id: string, event: string): void {\r\n if (!this.environment.enableMixpanel) {\r\n return;\r\n }\r\n\r\n mixpanel['track_links'](`#${id}`, event);\r\n }\r\n\r\n trackPageView(): void {\r\n if (!this.environment.enableMixpanel) {\r\n return;\r\n }\r\n\r\n mixpanel['track_pageview']();\r\n }\r\n}\r\n","export enum UserRolesEnum {\r\n FIRM_OWNER = 'ROLE_FIRM_OWNER',\r\n FIRM_MANAGER = 'ROLE_FIRM_MANAGER',\r\n FIRM_TOP_MANAGER = 'ROLE_FIRM_TOP_MANAGER',\r\n CLIENT = 'ROLE_CLIENT',\r\n EMPLOYEE = 'ROLE_EMPLOYEE',\r\n ACCOUNTANT = 'ROLE_ACCOUNTANT',\r\n ADVISOR = 'ROLE_ADVISOR',\r\n USER = 'ROLE_USER',\r\n SUBSCRIPTION = 'ROLE_USER_SUBSCRIPTION',\r\n WORK_TANK = 'ROLE_USER_WORK',\r\n PROPERTY_TANK = 'ROLE_USER_PROPERTY',\r\n SOLE_TANK = 'ROLE_USER_SOLE',\r\n HOLDING_TANK = 'ROLE_USER_HOLDING',\r\n SWITCH_USER = 'IS_IMPERSONATOR',\r\n}\r\n","import { Injectable, inject } from '@angular/core';\r\nimport { JwtHelperService } from '@auth0/angular-jwt';\r\nimport { MixpanelService } from '../mixpanel.service';\r\nimport { JwtDecodedInterface } from './jwt-decoded.interface';\r\nimport { BehaviorSubject } from 'rxjs';\r\nimport { AuthTokenInterface } from './auth-tokens.interface';\r\nimport { UserRolesEnum } from '../../db';\r\n\r\nconst NAME_TOKEN = 'token';\r\nconst NAME_REFRESH_TOKEN = 'refreshToken';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class JwtService extends JwtHelperService {\r\n private mpService: MixpanelService = inject(MixpanelService);\r\n isLoggedInSubject = new BehaviorSubject(!this.isTokenExpired());\r\n\r\n getToken(): string {\r\n return localStorage[NAME_TOKEN];\r\n }\r\n\r\n getRefreshToken(): string {\r\n return localStorage[NAME_REFRESH_TOKEN];\r\n }\r\n\r\n saveTokens(tokens: AuthTokenInterface): void {\r\n localStorage[NAME_TOKEN] = tokens.token;\r\n localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;\r\n\r\n this.mpService.identify(this.decode(tokens.token).id.toString());\r\n this.isLoggedInSubject.next(true);\r\n }\r\n\r\n destroyTokens(): void {\r\n localStorage.removeItem(NAME_TOKEN);\r\n localStorage.removeItem(NAME_REFRESH_TOKEN);\r\n\r\n this.mpService.track('logout');\r\n this.mpService.reset();\r\n this.isLoggedInSubject.next(false);\r\n\r\n }\r\n\r\n decode(token?: string): JwtDecodedInterface {\r\n return super.decodeToken(token) as JwtDecodedInterface;\r\n }\r\n\r\n isClient(): boolean {\r\n return this.decode().roles.includes(UserRolesEnum.CLIENT);\r\n }\r\n\r\n isMe(userId: number): boolean {\r\n return this.decode().id === userId;\r\n }\r\n}\r\n","import { Inject, Injectable } from '@angular/core';\r\nimport { HttpClient, HttpErrorResponse } from '@angular/common/http';\r\nimport { JwtService } from './jwt.service';\r\nimport { map } from 'rxjs/operators';\r\nimport { AuthTokenInterface } from './auth-tokens.interface';\r\nimport { MixpanelService } from '../mixpanel.service';\r\nimport { UserRolesEnum } from '../../db';\r\n\r\n@Injectable({\r\n providedIn: 'root'\r\n})\r\nexport class AuthService {\r\n constructor(\r\n private http: HttpClient,\r\n private jwtService: JwtService,\r\n private mpService: MixpanelService,\r\n @Inject('environment') private environment: any\r\n ) {\r\n\r\n }\r\n\r\n setAuth(response: AuthTokenInterface) {\r\n this.jwtService.saveTokens(response);\r\n }\r\n\r\n login(username: string, password: string, role: UserRolesEnum = null) {\r\n return this.http.post(`${this.environment.apiV2}/login`, { username, password }).pipe(\r\n map((response: any) => {\r\n if (!role || this.jwtService.decodeToken(response.token).roles.includes(role)) {\r\n this.setAuth(response);\r\n } else {\r\n throw new HttpErrorResponse({\r\n error: { code: 401, message: 'Your TaxTank subscription is expired. Please reactivate your account to link the widget.' },\r\n status: 401,\r\n statusText: 'Unauthorized',\r\n })\r\n }\r\n\r\n return response;\r\n })\r\n );\r\n }\r\n\r\n refresh(refreshToken: string) {\r\n return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(\r\n map((response: any) => {\r\n this.setAuth(response);\r\n\r\n return response;\r\n })\r\n );\r\n }\r\n\r\n logoutFront(url = '/login'): void {\r\n this.jwtService.destroyTokens();\r\n localStorage.clear();\r\n location.replace(url);\r\n }\r\n}\r\n","export enum AuthMessagesEnum {\r\n ERROR_401 = 'Email or password is incorrect'\r\n}\r\n","import { BehaviorSubject, Observable, throwError as observableThrowError } from 'rxjs';\r\nimport { catchError, filter, finalize, switchMap, take } from 'rxjs/operators';\r\nimport { Inject, Injectable } from '@angular/core';\r\nimport { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\r\nimport { AuthService, JwtService } from '../services';\r\n\r\nconst MESSAGE_DEFAULT_500_ERROR = 'Unexpected error! Please try again later. You can send us via chat your questions.';\r\n\r\n/**\r\n * JWT Interceptor add jwt token to each request related with TaxTank API\r\n */\r\n@Injectable()\r\nexport class JwtInterceptor implements HttpInterceptor {\r\n isRefreshingToken = false;\r\n tokenSubject: BehaviorSubject<string> = new BehaviorSubject<string>(null);\r\n\r\n constructor(\r\n public jwtService: JwtService,\r\n private authService: AuthService,\r\n @Inject('environment') private environment: any\r\n ) {}\r\n\r\n addToken(req: HttpRequest<any>): HttpRequest<any> {\r\n return req.clone({\r\n setHeaders: { Authorization: 'Bearer ' + this.jwtService.getToken() },\r\n withCredentials: true\r\n });\r\n }\r\n\r\n intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\r\n // skip third party requests\r\n if (!request.url.includes(this.environment.apiV2)) {\r\n return next.handle(request);\r\n }\r\n\r\n // add token to every api request\r\n return next.handle(this.addToken(request)).pipe(\r\n // handle errors\r\n catchError((err: HttpErrorResponse) => {\r\n if (err instanceof HttpErrorResponse) {\r\n switch ((err as HttpErrorResponse).status) {\r\n // unexpected errors\r\n case 405:\r\n case 500:\r\n this.handle500Error();\r\n break;\r\n // expected errors\r\n case 401:\r\n return this.handle401Error(request, next, err);\r\n case 400:\r\n case 403:\r\n // @TODO in most cases 404 is not an error, handle in components\r\n // case 404:\r\n this.showErrorMessages(err);\r\n break;\r\n }\r\n }\r\n\r\n return observableThrowError(err);\r\n })\r\n );\r\n }\r\n\r\n /**\r\n * @TODO log\r\n * @TODO waiting for backend to handle errors in a better way\r\n */\r\n handle400Error(err: HttpErrorResponse): void {\r\n // this.snackBar.open(err.error['hydra:description'], '', {\r\n // panelClass: 'error'\r\n // });\r\n }\r\n\r\n /**\r\n * @TODO log\r\n * @TODO waiting for backend to handle errors in a better way\r\n */\r\n handle403Error(err: HttpErrorResponse): void {\r\n // this.snackBar.open(err.error['hydra:description'], '', {\r\n // panelClass: 'error'\r\n // });\r\n }\r\n\r\n /**\r\n * @TODO log\r\n */\r\n handle500Error(): void {\r\n // this.snackBar.open(MESSAGE_DEFAULT_500_ERROR, '', {\r\n // panelClass: 'error'\r\n // });\r\n }\r\n\r\n handle401Error(req: HttpRequest<any>, next: HttpHandler, err: HttpErrorResponse) {\r\n // skip 401 errors not from JWT (basiq login case or other)\r\n if (!err.error.message?.includes('JWT Token')) {\r\n return observableThrowError(err);\r\n }\r\n\r\n if (req.url.includes('token/refresh') || req.url.includes('login')) {\r\n if (req.url.includes('token/refresh')) {\r\n this.authService.logoutFront();\r\n }\r\n\r\n return observableThrowError(err);\r\n }\r\n\r\n // refreshing token, wait until it's done and retry the request\r\n if (this.isRefreshingToken) {\r\n return this.tokenSubject.pipe(\r\n filter(token => token != null),\r\n take(1),\r\n switchMap(token => next.handle(this.addToken(req)))\r\n );\r\n // refresh token\r\n }\r\n // subsequent requests should wait until refresh token is ready\r\n this.isRefreshingToken = true;\r\n this.tokenSubject.next(null);\r\n\r\n return this.authService.refresh(this.jwtService.getRefreshToken()).pipe(\r\n switchMap((tokens: { token: string, refreshToken: string }) => {\r\n this.tokenSubject.next(tokens.token);\r\n return next.handle(this.addToken(req));\r\n }),\r\n catchError(() => {\r\n this.authService.logoutFront();\r\n return observableThrowError(err);\r\n }),\r\n finalize(() => {\r\n this.isRefreshingToken = false;\r\n })\r\n );\r\n\r\n }\r\n\r\n /**\r\n * Handle error messages\r\n * @param errorResponse from which messages should be taken\r\n *\r\n * @TODO move to separated interceptor\r\n */\r\n private showErrorMessages(errorResponse: HttpErrorResponse): void {\r\n if (!errorResponse.error.violations) {\r\n // this.snackBar.open('Something went wrong', '', {\r\n // panelClass: 'error'\r\n // });\r\n\r\n return;\r\n }\r\n errorResponse.error.violations.forEach((violation: object): void => {\r\n // this.snackBar.open(violation['message'], '', {\r\n // panelClass: 'error'\r\n // });\r\n });\r\n }\r\n}\r\n","import { NgModule } from '@angular/core';\r\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\r\nimport { JwtInterceptor } from './jwt-interceptor';\r\n\r\n@NgModule({\r\n providers: [\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n useClass: JwtInterceptor,\r\n multi: true\r\n }\r\n ]\r\n})\r\nexport class InterceptorsModule {\r\n}\r\n","import { ModuleWithProviders, NgModule } from '@angular/core';\r\nimport { CommonModule as AngularCommonModule } from '@angular/common';\r\nimport { InterceptorsModule } from './interceptors/interceptors.module';\r\n\r\n/**\r\n * https://angular.io/guide/creating-libraries\r\n */\r\n@NgModule({\r\n declarations: [],\r\n imports: [\r\n AngularCommonModule,\r\n InterceptorsModule\r\n ]\r\n})\r\nexport class CommonModule {\r\n public static forRoot(environment: object): ModuleWithProviders<CommonModule> {\r\n // @TODO remove when bank model refactored (the only use case)\r\n localStorage.setItem('api_uri', environment['api_uri']);\r\n\r\n return {\r\n ngModule: CommonModule,\r\n providers: [\r\n {\r\n provide: 'environment',\r\n useValue: environment\r\n }\r\n ]\r\n };\r\n }\r\n}\r\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["observableThrowError","AngularCommonModule"],"mappings":";;;;;;;;;;AAGA;;AAEG;MAIU,eAAe,CAAA;AAC1B,IAAA,WAAA,CAA2C,WAAgB,EAAA;QAAhB,IAAW,CAAA,WAAA,GAAX,WAAW;;IAEtD,IAAI,GAAA;AACF,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;YACpC;;QAGF,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC;;AAG/C,IAAA,QAAQ,CAAC,EAAU,EAAA;AACjB,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;YACpC;;AAGF,QAAA,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QACrB,QAAQ,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC;;IAG7E,KAAK,GAAA;AACH,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;YACpC;;QAGF,QAAQ,CAAC,KAAK,EAAE;;AAGlB,IAAA,KAAK,CAAC,KAAa,EAAE,UAAA,GAAqC,EAAE,EAAA;AAC1D,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;YACpC;;AAGF,QAAA,QAAQ,CAAC,KAAK,CAAC,KAAK,EAAE,UAAU,CAAC;;IAGnC,SAAS,CAAC,EAAU,EAAE,KAAa,EAAA;AACjC,QAAA,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,cAAc,EAAE;YACpC;;QAGF,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAA,CAAA,EAAI,EAAE,CAAE,CAAA,EAAE,KAAK,CAAC;;IAG1C,aAAa,GAAA;AACX,QA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AACF;AACF,iBAAA;;;ACRD;;AAEG;MAQU,YAAY,CAAA;IAChB,OAAO,OAAO,CAAC,WAAmB,EAAA;;QAEvC,YAAY,CAAC,OAAO,CAAC,SAAS,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC;QAEvD,OAAO;AACL,YAAA,QAAQ,EAAE,YAAY;AACtB,YAAA,SAAS,EAAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,aAAa;AACtB,oBAAA,QAAQ,EAAE;AACX;AACF;SACF;;8GAbQ,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAZ,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrBC,cAAmB;YACnB,kBAAkB,CAAA,EAAA,CAAA,CAAA;AAGT,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrBA,cAAmB;YACnB,kBAAkB,CAAA,EAAA,CAAA,CAAA;;2FAGT,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACPA,cAAmB;wBACnB;AACD;AACF,iBAAA;;;ACbD;;AAEG;;;;"}
1
+ {"version":3,"file":"taxtank-core-common.mjs","sources":["../../../projects/tt-core/common/src/services/mixpanel.service.ts","../../../projects/tt-core/common/src/db/enums/user/user-roles.enum.ts","../../../projects/tt-core/common/src/services/auth/jwt.service.ts","../../../projects/tt-core/common/src/services/auth/auth.service.ts","../../../projects/tt-core/common/src/services/auth/auth-messages.enum.ts","../../../projects/tt-core/common/src/interceptors/jwt-interceptor.ts","../../../projects/tt-core/common/src/interceptors/interceptors.module.ts","../../../projects/tt-core/common/src/common.module.ts","../../../projects/tt-core/common/taxtank-core-common.ts"],"sourcesContent":["import { Inject, Injectable } from '@angular/core';\nimport mixpanel from 'mixpanel-browser';\n\n/**\n * Service to work with mixpanel https://docs.mixpanel.com/docs/tracking/reference/javascript\n */\n@Injectable({\n providedIn: 'root'\n})\nexport class MixpanelService {\n constructor(@Inject('environment') private environment: any) {}\n\n init(): void {\n if (!this.environment.enableMixpanel) {\n return;\n }\n\n mixpanel.init(this.environment.mixpanelToken);\n }\n\n identify(id: string): void {\n if (!this.environment.enableMixpanel) {\n return;\n }\n\n mixpanel.identify(id);\n mixpanel.people.set({ 'last seen': new Date(Date.now()).toLocaleString() })\n }\n\n reset(): void {\n if (!this.environment.enableMixpanel) {\n return;\n }\n\n mixpanel.reset();\n }\n\n track(event: string, properties: { [key: string]: any } = {}): void {\n if (!this.environment.enableMixpanel) {\n return;\n }\n\n mixpanel.track(event, properties);\n }\n\n trackLink(id: string, event: string): void {\n if (!this.environment.enableMixpanel) {\n return;\n }\n\n mixpanel['track_links'](`#${id}`, event);\n }\n\n trackPageView(): void {\n if (!this.environment.enableMixpanel) {\n return;\n }\n\n mixpanel['track_pageview']();\n }\n}\n","export enum UserRolesEnum {\n FIRM_OWNER = 'ROLE_FIRM_OWNER',\n FIRM_MANAGER = 'ROLE_FIRM_MANAGER',\n FIRM_TOP_MANAGER = 'ROLE_FIRM_TOP_MANAGER',\n CLIENT = 'ROLE_CLIENT',\n EMPLOYEE = 'ROLE_EMPLOYEE',\n ACCOUNTANT = 'ROLE_ACCOUNTANT',\n ADVISOR = 'ROLE_ADVISOR',\n USER = 'ROLE_USER',\n SUBSCRIPTION = 'ROLE_USER_SUBSCRIPTION',\n WORK_TANK = 'ROLE_USER_WORK',\n PROPERTY_TANK = 'ROLE_USER_PROPERTY',\n SOLE_TANK = 'ROLE_USER_SOLE',\n HOLDING_TANK = 'ROLE_USER_HOLDING',\n SWITCH_USER = 'IS_IMPERSONATOR',\n}\n","import { Injectable, inject } from '@angular/core';\nimport { JwtHelperService } from '@auth0/angular-jwt';\nimport { MixpanelService } from '../mixpanel.service';\nimport { JwtDecodedInterface } from './jwt-decoded.interface';\nimport { BehaviorSubject } from 'rxjs';\nimport { AuthTokenInterface } from './auth-tokens.interface';\nimport { UserRolesEnum } from '../../db';\n\nconst NAME_TOKEN = 'token';\nconst NAME_REFRESH_TOKEN = 'refreshToken';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class JwtService extends JwtHelperService {\n private mpService: MixpanelService = inject(MixpanelService);\n isLoggedInSubject = new BehaviorSubject(!this.isTokenExpired());\n\n getToken(): string {\n return localStorage[NAME_TOKEN];\n }\n\n getRefreshToken(): string {\n return localStorage[NAME_REFRESH_TOKEN];\n }\n\n saveTokens(tokens: AuthTokenInterface): void {\n localStorage[NAME_TOKEN] = tokens.token;\n localStorage[NAME_REFRESH_TOKEN] = tokens.refreshToken;\n\n this.mpService.identify(this.decode(tokens.token).id.toString());\n this.isLoggedInSubject.next(true);\n }\n\n destroyTokens(): void {\n localStorage.removeItem(NAME_TOKEN);\n localStorage.removeItem(NAME_REFRESH_TOKEN);\n\n this.mpService.track('logout');\n this.mpService.reset();\n this.isLoggedInSubject.next(false);\n\n }\n\n decode(token?: string): JwtDecodedInterface {\n return super.decodeToken(token) as JwtDecodedInterface;\n }\n\n isClient(): boolean {\n return this.decode().roles.includes(UserRolesEnum.CLIENT);\n }\n\n isMe(userId: number): boolean {\n return this.decode().id === userId;\n }\n}\n","import { Inject, Injectable } from '@angular/core';\nimport { HttpClient, HttpErrorResponse } from '@angular/common/http';\nimport { JwtService } from './jwt.service';\nimport { map } from 'rxjs/operators';\nimport { AuthTokenInterface } from './auth-tokens.interface';\nimport { MixpanelService } from '../mixpanel.service';\nimport { UserRolesEnum } from '../../db';\n\n@Injectable({\n providedIn: 'root'\n})\nexport class AuthService {\n constructor(\n private http: HttpClient,\n private jwtService: JwtService,\n private mpService: MixpanelService,\n @Inject('environment') private environment: any\n ) {\n\n }\n\n setAuth(response: AuthTokenInterface) {\n this.jwtService.saveTokens(response);\n }\n\n login(username: string, password: string, role: UserRolesEnum = null) {\n return this.http.post(`${this.environment.apiV2}/login`, { username, password }).pipe(\n map((response: any) => {\n if (!role || this.jwtService.decodeToken(response.token).roles.includes(role)) {\n this.setAuth(response);\n } else {\n throw new HttpErrorResponse({\n error: { code: 401, message: 'Your TaxTank subscription is expired. Please reactivate your account to link the widget.' },\n status: 401,\n statusText: 'Unauthorized',\n })\n }\n\n return response;\n })\n );\n }\n\n refresh(refreshToken: string) {\n return this.http.post(`${this.environment.apiV2}/token/refresh`, { refreshToken }).pipe(\n map((response: any) => {\n this.setAuth(response);\n\n return response;\n })\n );\n }\n\n logoutFront(url = '/login'): void {\n this.jwtService.destroyTokens();\n localStorage.clear();\n location.replace(url);\n }\n}\n","export enum AuthMessagesEnum {\n ERROR_401 = 'Email or password is incorrect'\n}\n","import { BehaviorSubject, Observable, throwError as observableThrowError } from 'rxjs';\nimport { catchError, filter, finalize, switchMap, take } from 'rxjs/operators';\nimport { Inject, Injectable } from '@angular/core';\nimport { HttpErrorResponse, HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';\nimport { AuthService, JwtService } from '../services';\n\nconst MESSAGE_DEFAULT_500_ERROR = 'Unexpected error! Please try again later. You can send us via chat your questions.';\n\n/**\n * JWT Interceptor add jwt token to each request related with TaxTank API\n */\n@Injectable()\nexport class JwtInterceptor implements HttpInterceptor {\n isRefreshingToken = false;\n tokenSubject: BehaviorSubject<string> = new BehaviorSubject<string>(null);\n\n constructor(\n public jwtService: JwtService,\n private authService: AuthService,\n @Inject('environment') private environment: any\n ) {}\n\n addToken(req: HttpRequest<any>): HttpRequest<any> {\n return req.clone({\n setHeaders: { Authorization: 'Bearer ' + this.jwtService.getToken() },\n withCredentials: true\n });\n }\n\n intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n // skip third party requests\n if (!request.url.includes(this.environment.apiV2)) {\n return next.handle(request);\n }\n\n // add token to every api request\n return next.handle(this.addToken(request)).pipe(\n // handle errors\n catchError((err: HttpErrorResponse) => {\n if (err instanceof HttpErrorResponse) {\n switch ((err as HttpErrorResponse).status) {\n // unexpected errors\n case 405:\n case 500:\n this.handle500Error();\n break;\n // expected errors\n case 401:\n return this.handle401Error(request, next, err);\n case 400:\n case 403:\n // @TODO in most cases 404 is not an error, handle in components\n // case 404:\n this.showErrorMessages(err);\n break;\n }\n }\n\n return observableThrowError(err);\n })\n );\n }\n\n /**\n * @TODO log\n * @TODO waiting for backend to handle errors in a better way\n */\n handle400Error(err: HttpErrorResponse): void {\n // this.snackBar.open(err.error['hydra:description'], '', {\n // panelClass: 'error'\n // });\n }\n\n /**\n * @TODO log\n * @TODO waiting for backend to handle errors in a better way\n */\n handle403Error(err: HttpErrorResponse): void {\n // this.snackBar.open(err.error['hydra:description'], '', {\n // panelClass: 'error'\n // });\n }\n\n /**\n * @TODO log\n */\n handle500Error(): void {\n // this.snackBar.open(MESSAGE_DEFAULT_500_ERROR, '', {\n // panelClass: 'error'\n // });\n }\n\n handle401Error(req: HttpRequest<any>, next: HttpHandler, err: HttpErrorResponse) {\n // skip 401 errors not from JWT (basiq login case or other)\n if (!err.error.message?.includes('JWT Token')) {\n return observableThrowError(err);\n }\n\n if (req.url.includes('token/refresh') || req.url.includes('login')) {\n if (req.url.includes('token/refresh')) {\n this.authService.logoutFront();\n }\n\n return observableThrowError(err);\n }\n\n // refreshing token, wait until it's done and retry the request\n if (this.isRefreshingToken) {\n return this.tokenSubject.pipe(\n filter(token => token != null),\n take(1),\n switchMap(token => next.handle(this.addToken(req)))\n );\n // refresh token\n }\n // subsequent requests should wait until refresh token is ready\n this.isRefreshingToken = true;\n this.tokenSubject.next(null);\n\n return this.authService.refresh(this.jwtService.getRefreshToken()).pipe(\n switchMap((tokens: { token: string, refreshToken: string }) => {\n this.tokenSubject.next(tokens.token);\n return next.handle(this.addToken(req));\n }),\n catchError(() => {\n this.authService.logoutFront();\n return observableThrowError(err);\n }),\n finalize(() => {\n this.isRefreshingToken = false;\n })\n );\n\n }\n\n /**\n * Handle error messages\n * @param errorResponse from which messages should be taken\n *\n * @TODO move to separated interceptor\n */\n private showErrorMessages(errorResponse: HttpErrorResponse): void {\n if (!errorResponse.error.violations) {\n // this.snackBar.open('Something went wrong', '', {\n // panelClass: 'error'\n // });\n\n return;\n }\n errorResponse.error.violations.forEach((violation: object): void => {\n // this.snackBar.open(violation['message'], '', {\n // panelClass: 'error'\n // });\n });\n }\n}\n","import { NgModule } from '@angular/core';\r\nimport { HTTP_INTERCEPTORS } from '@angular/common/http';\r\nimport { JwtInterceptor } from './jwt-interceptor';\r\n\r\n@NgModule({\r\n providers: [\r\n {\r\n provide: HTTP_INTERCEPTORS,\r\n useClass: JwtInterceptor,\r\n multi: true\r\n }\r\n ]\r\n})\r\nexport class InterceptorsModule {\r\n}\r\n","import { ModuleWithProviders, NgModule } from '@angular/core';\nimport { CommonModule as AngularCommonModule } from '@angular/common';\nimport { InterceptorsModule } from './interceptors/interceptors.module';\n\n/**\n * https://angular.io/guide/creating-libraries\n */\n@NgModule({\n declarations: [],\n imports: [\n AngularCommonModule,\n InterceptorsModule\n ]\n})\nexport class CommonModule {\n public static forRoot(environment: object): ModuleWithProviders<CommonModule> {\n // @TODO remove when bank model refactored (the only use case)\n localStorage.setItem('api_uri', environment['api_uri']);\n\n return {\n ngModule: CommonModule,\n providers: [\n {\n provide: 'environment',\n useValue: environment\n }\n ]\n };\n }\n}\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":["observableThrowError","AngularCommonModule"],"mappings":";;;;;;;;;;AAGA;;AAEG;MAIU,eAAe,CAAA;AAC1B,IAAA,WAAA,CAA2C,WAAgB,EAAA;QAAhB,IAAW,C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A,SAAS,EAAE;AACT,gBAAA;AACE,oBAAA,OAAO,EAAE,aAAa;AACtB,oBAAA,QAAQ,EAAE;AACX;AACF;SACF;;8GAbQ,YAAY,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,QAAA,EAAA,CAAA,CAAA;AAAZ,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrBC,cAAmB;YACnB,kBAAkB,CAAA,EAAA,CAAA,CAAA;AAGT,IAAA,SAAA,IAAA,CAAA,IAAA,GAAA,EAAA,CAAA,mBAAA,CAAA,EAAA,UAAA,EAAA,QAAA,EAAA,OAAA,EAAA,QAAA,EAAA,QAAA,EAAA,EAAA,EAAA,IAAA,EAAA,YAAY,YAJrBA,cAAmB;YACnB,kBAAkB,CAAA,EAAA,CAAA,CAAA;;2FAGT,YAAY,EAAA,UAAA,EAAA,CAAA;kBAPxB,QAAQ;AAAC,YAAA,IAAA,EAAA,CAAA;AACR,oBAAA,YAAY,EAAE,EAAE;AAChB,oBAAA,OAAO,EAAE;wBACPA,cAAmB;wBACnB;AACD;AACF,iBAAA;;;ACbD;;AAEG;;;;"}
@@ -5,7 +5,7 @@ import { formatDate, CommonModule, CurrencyPipe, DatePipe } from '@angular/commo
5
5
  import * as i1 from '@angular/common/http';
6
6
  import { HttpParams, HttpClient, HttpErrorResponse, HTTP_INTERCEPTORS } from '@angular/common/http';
7
7
  import { map, catchError, mergeMap, filter, first as first$1, finalize, startWith, debounceTime, distinctUntilChanged } from 'rxjs/operators';
8
- import { ReplaySubject, throwError, Subject, Observable, of, combineLatest, BehaviorSubject, forkJoin, from, merge as merge$1 } from 'rxjs';
8
+ import { ReplaySubject, throwError, Subject, Observable, of, forkJoin, combineLatest, BehaviorSubject, from, merge as merge$1 } from 'rxjs';
9
9
  import { plainToClass, Type, Transform, Exclude, Expose, classToPlain } from 'class-transformer';
10
10
  import 'reflect-metadata';
11
11
  import { __decorate } from 'tslib';
@@ -5610,9 +5610,6 @@ class PropertyCategory extends PropertyCategory$1 {
5610
5610
  isVacantLand() {
5611
5611
  return this.id === PropertyCategoryListEnum.VACANT_LAND;
5612
5612
  }
5613
- isShared() {
5614
- return this.id === PropertyCategoryListEnum.SHARED;
5615
- }
5616
5613
  }
5617
5614
 
5618
5615
  class PropertyDocument extends PropertyDocument$1 {
@@ -11599,6 +11596,12 @@ let RestService$1 = class RestService extends DataService {
11599
11596
  return result;
11600
11597
  }), catchError((error) => this.handleError(error)));
11601
11598
  }
11599
+ /**
11600
+ * Create multiple new Model instances in database for resources which support only single entity post
11601
+ */
11602
+ postParallel(models) {
11603
+ return forkJoin(models.map(model => this.post(model)));
11604
+ }
11602
11605
  /**
11603
11606
  * Change an existing Model instance in database
11604
11607
  */
@@ -11627,6 +11630,12 @@ let RestService$1 = class RestService extends DataService {
11627
11630
  return result;
11628
11631
  }));
11629
11632
  }
11633
+ /**
11634
+ * Change multiple existing Model instances in database for resources which support only single entity put
11635
+ */
11636
+ putParallel(models) {
11637
+ return forkJoin(models.map(model => this.post(model)));
11638
+ }
11630
11639
  /**
11631
11640
  * Remove a Model instance from database
11632
11641
  */
@@ -11663,6 +11672,12 @@ let RestService$1 = class RestService extends DataService {
11663
11672
  }
11664
11673
  }), catchError((error) => this.handleError(error)));
11665
11674
  }
11675
+ /**
11676
+ * Remove multiple Model instances from database for resources which support only single entity delete
11677
+ */
11678
+ deleteParallel(models) {
11679
+ return forkJoin(models.map(model => this.delete(model))).pipe(map(() => undefined));
11680
+ }
11666
11681
  /**
11667
11682
  * method with messages that can be redefined in other classes to customize httpErrorMessages
11668
11683
  */
@@ -14232,6 +14247,9 @@ class PropertyDocumentService extends RestService$1 {
14232
14247
  this.endpointUri = 'property-documents';
14233
14248
  this.disabledMethods = ['postBatch', 'putBatch'];
14234
14249
  }
14250
+ postFiles(property, files) {
14251
+ return this.postParallel(files.map(file => plainToClass(PropertyDocument, { file, property })));
14252
+ }
14235
14253
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.1.2", ngImport: i0, type: PropertyDocumentService, deps: null, target: i0.ɵɵFactoryTarget.Injectable }); }
14236
14254
  static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "19.1.2", ngImport: i0, type: PropertyDocumentService, providedIn: 'root' }); }
14237
14255
  }
@@ -23234,8 +23252,14 @@ class PropertyEditForm extends AbstractForm {
23234
23252
  super({
23235
23253
  address: new UntypedFormControl(property.address, Validators.required),
23236
23254
  purchasePrice: new UntypedFormControl(property.purchasePrice, Validators.required),
23237
- contractDate: new UntypedFormControl(property.contractDate, Validators.required),
23238
- settlementDate: new UntypedFormControl(property.settlementDate, Validators.required),
23255
+ contractDate: new UntypedFormControl(property.contractDate, [
23256
+ Validators.required,
23257
+ maxDateValidator(new Date(), 'You cannot add a property with a contract date in future.')
23258
+ ]),
23259
+ settlementDate: new UntypedFormControl(property.settlementDate, [
23260
+ Validators.required,
23261
+ maxDateValidator(new Date(), 'You cannot add a property with a settlement date in future.')
23262
+ ]),
23239
23263
  stampDuty: new UntypedFormControl(property.stampDuty),
23240
23264
  legalFees: new UntypedFormControl(property.legalFees),
23241
23265
  otherCapitalCosts: new UntypedFormControl(property.otherCapitalCosts),
@@ -23352,9 +23376,12 @@ class PropertyAddForm extends AbstractForm {
23352
23376
  purchasePrice: new FormControl(null, Validators.required),
23353
23377
  contractDate: new FormControl(null, [
23354
23378
  Validators.required,
23355
- maxDateValidator(new FinancialYear().endDate, 'You cannot add a property with a contract date in future financial years.')
23379
+ maxDateValidator(new Date(), 'You cannot add a property with a contract date in future.')
23380
+ ]),
23381
+ settlementDate: new FormControl(null, [
23382
+ Validators.required,
23383
+ maxDateValidator(new Date(), 'You cannot add a property with a settlement date in future.')
23356
23384
  ]),
23357
- settlementDate: new FormControl(null, Validators.required),
23358
23385
  share: new PropertyShareForm(),
23359
23386
  forecast: new PropertyForecastForm(),
23360
23387
  category: new FormControl(null, Validators.required)
@@ -23375,7 +23402,7 @@ class PropertyAddForm extends AbstractForm {
23375
23402
  }
23376
23403
  listenCategoryChanges() {
23377
23404
  this.get('category').valueChanges.subscribe((category) => {
23378
- if (category.isShared()) {
23405
+ if (category.isPropertyShare) {
23379
23406
  this.forecastForm.get('claimPercent').enable();
23380
23407
  }
23381
23408
  else {