{ "version": 3, "sources": ["src/app/store/knowledge-base/kb-items.actions.ts", "src/app/modules/knowledge-base/knowledge-base.service.ts", "src/app/store/knowledge-base/kb-items.state.ts"], "sourcesContent": ["export class GetAllAnswers {\n public static readonly type = '[KbItems] Get All Answers';\n}\n", "import {HttpClient} from '@angular/common/http';\nimport {inject, Injectable} from '@angular/core';\nimport {Observable} from 'rxjs';\nimport {map} from 'rxjs/operators';\nimport {KnowledgeBaseItem} from 'src/app/interfaces/general/knowledge-base/knowledge-base-item.interface';\n\n@Injectable({providedIn: 'root'})\nexport class KnowledgeBaseService {\n private http = inject(HttpClient);\n\n public getAll(): Observable {\n return this.http\n .get<{knowledgeBase: KnowledgeBaseItem[]}>('/assets/knowledge-base/knowledge-base.json')\n .pipe(map(({knowledgeBase}) => knowledgeBase));\n }\n}\n", "import {Injectable} from '@angular/core';\nimport {Action, Selector, State, StateContext} from '@ngxs/store';\nimport {KnowledgeBaseService} from 'src/app/modules/knowledge-base/knowledge-base.service';\nimport {AppInsightsService} from 'src/app/core/app-insights/app-insights.service';\nimport {GetAllAnswers} from 'src/app/store/knowledge-base/kb-items.actions';\nimport {firstValueFrom} from 'rxjs';\nimport {errorHandler} from 'src/app/shared/helpers/error-handler';\nimport {KnowledgeBaseItem} from 'src/app/interfaces/general/knowledge-base/knowledge-base-item.interface';\n\nexport interface IKbItemsState {\n data: KnowledgeBaseItem[];\n hasValue: boolean;\n loading: boolean;\n error: any;\n}\n\n@State({\n name: 'kbItems',\n defaults: {\n data: [],\n hasValue: false,\n loading: false,\n error: null,\n },\n})\n@Injectable()\nexport class KnowledgeBaseItemsState {\n constructor(\n private kbService: KnowledgeBaseService,\n private insights: AppInsightsService,\n ) {}\n\n @Selector()\n public static answers(state: IKbItemsState): KnowledgeBaseItem[] {\n return state.data;\n }\n\n @Selector()\n public static loading(state: IKbItemsState): boolean {\n return state.loading;\n }\n\n @Selector()\n public static error(state: IKbItemsState): any {\n return state.error;\n }\n\n @Action(GetAllAnswers)\n public async getAllAnswers(ctx: StateContext): Promise {\n ctx.patchState({loading: true, error: null});\n try {\n const kbItems: KnowledgeBaseItem[] = await firstValueFrom(this.kbService.getAll());\n ctx.patchState({\n data: kbItems,\n hasValue: !!kbItems?.length,\n loading: false,\n error: null,\n });\n } catch (error) {\n errorHandler({\n error,\n appInsightsSrv: this.insights,\n scope: 'KnowledgeBaseItemsState',\n });\n ctx.patchState({\n data: [],\n hasValue: false,\n loading: false,\n error: error.message ?? error,\n });\n }\n }\n}\n"], "mappings": "gOAAA,IAAaA,GAAa,IAAA,CAApB,MAAOA,CAAa,QACC,KAAAC,KAAO,2BAA4B,SADjDD,CAAa,GAAA,ECO1B,IAAaE,GAAoB,IAAA,CAA3B,MAAOA,CAAoB,CADjCC,aAAA,CAEY,KAAAC,KAAOC,EAAOC,CAAU,EAEzBC,QAAM,CACT,OAAO,KAAKH,KACPI,IAA0C,4CAA4C,EACtFC,KAAKC,EAAI,CAAC,CAACC,cAAAA,CAAa,IAAMA,CAAa,CAAC,CACrD,iDAPST,EAAoB,CAAA,iCAApBA,EAAoBU,QAApBV,EAAoBW,UAAAC,WADR,MAAM,CAAA,CAAA,SAClBZ,CAAoB,GAAA,ECmB1B,IAAMa,EAAN,MAAMA,CAAuB,CAChCC,YACYC,EACAC,EAA4B,CAD5B,KAAAD,UAAAA,EACA,KAAAC,SAAAA,CACT,CAGW,OAAAC,QAAQC,EAAoB,CACtC,OAAOA,EAAMC,IACjB,CAGc,OAAAC,QAAQF,EAAoB,CACtC,OAAOA,EAAME,OACjB,CAGc,OAAAC,MAAMH,EAAoB,CACpC,OAAOA,EAAMG,KACjB,CAGaC,cAAcC,EAAgC,QAAAC,EAAA,sBACvDD,EAAIE,WAAW,CAACL,QAAS,GAAMC,MAAO,IAAI,CAAC,EAC3C,GAAI,CACA,IAAMK,EAA+B,MAAMC,EAAe,KAAKZ,UAAUa,OAAM,CAAE,EACjFL,EAAIE,WAAW,CACXN,KAAMO,EACNG,SAAU,CAAC,CAACH,GAASI,OACrBV,QAAS,GACTC,MAAO,KACV,CACL,OAASA,EAAO,CACZU,EAAa,CACTV,MAAAA,EACAW,eAAgB,KAAKhB,SACrBiB,MAAO,0BACV,EACDV,EAAIE,WAAW,CACXN,KAAM,CAAA,EACNU,SAAU,GACVT,QAAS,GACTC,MAAOA,EAAMa,SAAWb,EAC3B,CACL,CACJ,mDA7CSR,GAAuBsB,EAAAC,CAAA,EAAAD,EAAAE,CAAA,CAAA,CAAA,CAAA,iCAAvBxB,EAAuByB,QAAvBzB,EAAuB0B,SAAA,CAAA,CAAA,GAsBnBC,EAAA,CADZC,EAAOC,CAAa,CAAC,EAAA7B,EAAA,UAAA,gBAAA,IAAA,EAdR2B,EAAA,CADbG,EAAQ,CAAE,EAAA9B,EAAA,UAAA,IAAA,EAMG2B,EAAA,CADbG,EAAQ,CAAE,EAAA9B,EAAA,UAAA,IAAA,EAMG2B,EAAA,CADbG,EAAQ,CAAE,EAAA9B,EAAA,QAAA,IAAA,EAhBFA,EAAuB2B,EAAA,CAVnCI,EAAqB,CAClBC,KAAM,UACNC,SAAU,CACN3B,KAAM,CAAA,EACNU,SAAU,GACVT,QAAS,GACTC,MAAO,MAEd,CAAC,EAEWR,CAAuB", "names": ["GetAllAnswers", "type", "KnowledgeBaseService", "constructor", "http", "inject", "HttpClient", "getAll", "get", "pipe", "map", "knowledgeBase", "factory", "\u0275fac", "providedIn", "KnowledgeBaseItemsState", "constructor", "kbService", "insights", "answers", "state", "data", "loading", "error", "getAllAnswers", "ctx", "__async", "patchState", "kbItems", "firstValueFrom", "getAll", "hasValue", "length", "errorHandler", "appInsightsSrv", "scope", "message", "\u0275\u0275inject", "KnowledgeBaseService", "AppInsightsService", "factory", "\u0275fac", "__decorate", "Action", "GetAllAnswers", "Selector", "State", "name", "defaults"] }