{ "version": 3, "sources": ["apps/partner-center-client/src/app/core/access/access.service.ts"], "sourcesContent": ["import { Injectable } from '@angular/core';\nimport { WhitelabelService } from '@galaxy/partner';\nimport { Observable, of } from 'rxjs';\nimport { distinctUntilChanged, map, shareReplay, switchMap } from 'rxjs/operators';\nimport { AppConfigService } from '../../app-config.service';\nimport { AccessService, Feature } from 'marketplace-ui';\nimport { HasViewAccessRequestInterface, ViewAccessApiService } from '@vendasta/platform-users';\n\n@Injectable()\nexport class StubAccessService implements AccessService {\n features: Observable;\n\n constructor(\n private app: AppConfigService,\n private whitelabelService: WhitelabelService,\n private readonly viewAccessService: ViewAccessApiService,\n ) {\n this.features = this.app.config$.pipe(\n map((config) => config.partnerId),\n switchMap((partnerId) => this.whitelabelService.getConfiguration(partnerId)),\n map((config) => config.enabledFeatures),\n shareReplay(1),\n );\n }\n\n // note: this should not to be confused with `vconfig/vconfig.service.ts`\n // this is for value based pricing feature access checks\n hasAccessToFeature(feature: Feature): Observable {\n return this.features.pipe(\n map((features) => {\n return Boolean(features && features.indexOf(feature) >= 0);\n }),\n distinctUntilChanged(),\n );\n }\n\n // note: this should not to be confused with `vconfig/vconfig.service.ts`\n // this is for value based pricing feature access checks\n hasAccessToFeatures(features: Feature[]): Observable {\n if (!features) {\n return of(true);\n }\n return this.features.pipe(\n map((partnerFeatures) => {\n return features.every((feature) => Boolean(partnerFeatures && partnerFeatures.indexOf(feature) >= 0));\n }),\n distinctUntilChanged(),\n );\n }\n\n hasAccessToViews(views: string[]): Observable {\n return this.app.config$.pipe(\n switchMap((config) =>\n this.viewAccessService.hasViewAccess({\n partnerId: config.partnerId,\n viewIds: views,\n } as HasViewAccessRequestInterface),\n ),\n map((response) => {\n return response.access.map((view) => view.hasAccess);\n }),\n );\n }\n}\n"], "mappings": "gNASA,IAAaA,GAAiB,IAAA,CAAxB,IAAOA,EAAP,MAAOA,CAAiB,CAG5BC,YACUC,EACAC,EACSC,EAAuC,CAFhD,KAAAF,IAAAA,EACA,KAAAC,kBAAAA,EACS,KAAAC,kBAAAA,EAEjB,KAAKC,SAAW,KAAKH,IAAII,QAAQC,KAC/BC,EAAKC,GAAWA,EAAOC,SAAS,EAChCC,EAAWD,GAAc,KAAKP,kBAAkBS,iBAAiBF,CAAS,CAAC,EAC3EF,EAAKC,GAAWA,EAAOI,eAAe,EACtCC,EAAY,CAAC,CAAC,CAElB,CAIAC,mBAAmBC,EAAgB,CACjC,OAAO,KAAKX,SAASE,KACnBC,EAAKH,GACIY,GAAQZ,GAAYA,EAASa,QAAQF,CAAO,GAAK,EACzD,EACDG,EAAoB,CAAE,CAE1B,CAIAC,oBAAoBf,EAAmB,CACrC,OAAKA,EAGE,KAAKA,SAASE,KACnBC,EAAKa,GACIhB,EAASiB,MAAON,GAAYC,GAAQI,GAAmBA,EAAgBH,QAAQF,CAAO,GAAK,EAAE,CACrG,EACDG,EAAoB,CAAE,EANfI,EAAG,EAAI,CAQlB,CAEAC,iBAAiBC,EAAe,CAC9B,OAAO,KAAKvB,IAAII,QAAQC,KACtBI,EAAWF,GACT,KAAKL,kBAAkBsB,cAAc,CACnChB,UAAWD,EAAOC,UAClBiB,QAASF,EACuB,CAAC,EAErCjB,EAAKoB,GACIA,EAASC,OAAOrB,IAAKsB,GAASA,EAAKC,SAAS,CACpD,CAAC,CAEN,yCArDW/B,GAAiBgC,EAAAC,CAAA,EAAAD,EAAAE,CAAA,EAAAF,EAAAG,CAAA,CAAA,CAAA,wBAAjBnC,EAAiBoC,QAAjBpC,EAAiBqC,SAAA,CAAA,EAAxB,IAAOrC,EAAPsC,SAAOtC,CAAiB,GAAA", "names": ["StubAccessService", "constructor", "app", "whitelabelService", "viewAccessService", "features", "config$", "pipe", "map", "config", "partnerId", "switchMap", "getConfiguration", "enabledFeatures", "shareReplay", "hasAccessToFeature", "feature", "Boolean", "indexOf", "distinctUntilChanged", "hasAccessToFeatures", "partnerFeatures", "every", "of", "hasAccessToViews", "views", "hasViewAccess", "viewIds", "response", "access", "view", "hasAccess", "\u0275\u0275inject", "AppConfigService", "WhitelabelService", "ViewAccessApiService", "factory", "\u0275fac", "_StubAccessService"] }