All files / app/service/api graph.service.ts

77.77% Statements 14/18
77.77% Branches 7/9
50% Functions 3/6
76.92% Lines 10/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35  4x   4x 4x             4x     2x 2x 2x       1x       1x 1x                  
import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { catchError, map, Observable, of } from 'rxjs';
import { mapRefOrNull, RefNode } from '../../model/ref';
import { params } from '../../util/http';
import { ConfigService } from '../config.service';
import { LoginService } from '../login.service';
 
@Injectable({
  providedIn: 'root'
})
export class GraphService {
 
  constructor(
    private http: HttpClient,
    private config: ConfigService,
    private login: LoginService,
  ) { }
 
  private get base() {
    return this.config.api + '/api/v1/graph';
  }
 
  list(urls: string[]): Observable<(RefNode | null)[]> {
    Iif (!urls?.length) return of([]);
    return this.http.get(`${this.base}/list`, {
      params: params({ urls }),
    }).pipe(
      map(res => res as any[]),
      map(res => res.map(mapRefOrNull)),
      catchError(err => this.login.handleHttpError(err)),
    );
  }
}