@equinor/fusion-framework-module-http
Advanced tools
Comparing version 0.6.2 to 1.0.0-0
import { HttpClient } from './client'; | ||
export class HttpClientMsal extends HttpClient { | ||
defaultScopes = []; | ||
fetch(path, init) { | ||
fetch$(path, init) { | ||
const args = Object.assign(init || {}, { | ||
scopes: this.defaultScopes.concat(init?.scopes || []), | ||
}); | ||
return super._fetch(path, args); | ||
return super._fetch$(path, args); | ||
} | ||
@@ -10,0 +10,0 @@ } |
@@ -38,9 +38,12 @@ import { firstValueFrom, of, Subject } from 'rxjs'; | ||
} | ||
fetch$(path, args) { | ||
return this._fetch$(path, args); | ||
} | ||
fetch(path, args) { | ||
return this._fetch(path, args); | ||
return firstValueFrom(this.fetch$(path, args)); | ||
} | ||
fetchAsync(path, args) { | ||
return firstValueFrom(this.fetch(path, args)); | ||
return this.fetch(path, args); | ||
} | ||
json(path, args) { | ||
json$(path, args) { | ||
const body = typeof args?.body === 'object' ? JSON.stringify(args?.body) : args?.body; | ||
@@ -50,3 +53,3 @@ const selector = args?.selector ?? jsonSelector; | ||
header.append('Content-Type', 'application/json'); | ||
return this.fetch(path, { | ||
return this.fetch$(path, { | ||
...args, | ||
@@ -57,4 +60,7 @@ body, | ||
} | ||
json(path, args) { | ||
return firstValueFrom(this.json$(path, args)); | ||
} | ||
jsonAsync(path, args) { | ||
return firstValueFrom(this.json(path, args)); | ||
return this.json(path, args); | ||
} | ||
@@ -64,3 +70,3 @@ abort() { | ||
} | ||
_fetch(path, args) { | ||
_fetch$(path, args) { | ||
const { selector, ...options } = args || {}; | ||
@@ -67,0 +73,0 @@ const response$ = of({ |
@@ -9,4 +9,4 @@ import type { Observable } from 'rxjs'; | ||
defaultScopes: string[]; | ||
fetch<T = TResponse>(path: string, init?: MsalFetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
fetch$<T = TResponse>(path: string, init?: MsalFetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
} | ||
export default HttpClientMsal; |
@@ -26,6 +26,6 @@ import { Subject } from 'rxjs'; | ||
response$: Observable<TResponse>; | ||
fetch<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
fetchAsync<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
json<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
jsonAsync<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
fetch$<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
fetch<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
json$<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
json<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
abort(): void; | ||
@@ -44,8 +44,10 @@ } | ||
protected _init(): void; | ||
fetch<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
fetch$<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
fetch<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
fetchAsync<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
json<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
json$<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
json<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
jsonAsync<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
abort(): void; | ||
protected _fetch<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
protected _fetch$<T = TResponse>(path: string, args?: FetchRequestInit<T, TRequest, TResponse>): Observable<T>; | ||
protected _prepareRequest(init: TRequest): ObservableInput<TRequest>; | ||
@@ -52,0 +54,0 @@ protected _prepareResponse(response: TResponse): ObservableInput<TResponse>; |
{ | ||
"name": "@equinor/fusion-framework-module-http", | ||
"version": "0.6.2", | ||
"version": "1.0.0-0", | ||
"description": "", | ||
@@ -31,4 +31,3 @@ "main": "dist/esm/index.js", | ||
"typescript": "^4.7.4" | ||
}, | ||
"gitHead": "ac0ad3f30905bed1e292c609684db498de0d2435" | ||
} | ||
} |
@@ -21,3 +21,3 @@ import type { Observable } from 'rxjs'; | ||
/** @inheritdoc */ | ||
fetch<T = TResponse>( | ||
fetch$<T = TResponse>( | ||
path: string, | ||
@@ -29,3 +29,3 @@ init?: MsalFetchRequestInit<T, TRequest, TResponse> | ||
}) as FetchRequestInit<T, TRequest, TResponse>; | ||
return super._fetch(path, args); | ||
return super._fetch$(path, args); | ||
} | ||
@@ -32,0 +32,0 @@ } |
@@ -104,3 +104,3 @@ import { firstValueFrom, of, Subject } from 'rxjs'; | ||
*/ | ||
fetch<T = TResponse>( | ||
fetch$<T = TResponse>( | ||
path: string, | ||
@@ -139,8 +139,5 @@ init?: FetchRequestInit<T, TRequest, TResponse> | ||
*/ | ||
fetchAsync<T = TResponse>( | ||
path: string, | ||
init?: FetchRequestInit<T, TRequest, TResponse> | ||
): Promise<T>; | ||
fetch<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
json<T = TResponse>( | ||
json$<T = TResponse>( | ||
path: string, | ||
@@ -150,6 +147,3 @@ init?: FetchRequestInit<T, TRequest, TResponse> | ||
jsonAsync<T = TResponse>( | ||
path: string, | ||
init?: FetchRequestInit<T, TRequest, TResponse> | ||
): Promise<T>; | ||
json<T = TResponse>(path: string, init?: FetchRequestInit<T, TRequest, TResponse>): Promise<T>; | ||
@@ -200,9 +194,17 @@ /** | ||
public fetch<T = TResponse>( | ||
public fetch$<T = TResponse>( | ||
path: string, | ||
args?: FetchRequestInit<T, TRequest, TResponse> | ||
): Observable<T> { | ||
return this._fetch(path, args); | ||
return this._fetch$(path, args); | ||
} | ||
public fetch<T = TResponse>( | ||
path: string, | ||
args?: FetchRequestInit<T, TRequest, TResponse> | ||
): Promise<T> { | ||
return firstValueFrom(this.fetch$<T>(path, args)); | ||
} | ||
/** @deprecated */ | ||
public fetchAsync<T = TResponse>( | ||
@@ -212,6 +214,6 @@ path: string, | ||
): Promise<T> { | ||
return firstValueFrom(this.fetch<T>(path, args)); | ||
return this.fetch(path, args); | ||
} | ||
public json<T = TResponse>( | ||
public json$<T = TResponse>( | ||
path: string, | ||
@@ -224,3 +226,3 @@ args?: FetchRequestInit<T, TRequest, TResponse> | ||
header.append('Content-Type', 'application/json'); | ||
return this.fetch(path, { | ||
return this.fetch$(path, { | ||
...args, | ||
@@ -232,2 +234,10 @@ body, | ||
public json<T = TResponse>( | ||
path: string, | ||
args?: FetchRequestInit<T, TRequest, TResponse> | ||
): Promise<T> { | ||
return firstValueFrom(this.json$<T>(path, args)); | ||
} | ||
/** @deprecated */ | ||
public jsonAsync<T = TResponse>( | ||
@@ -237,3 +247,3 @@ path: string, | ||
): Promise<T> { | ||
return firstValueFrom(this.json<T>(path, args)); | ||
return this.json(path, args); | ||
} | ||
@@ -245,3 +255,3 @@ | ||
protected _fetch<T = TResponse>( | ||
protected _fetch$<T = TResponse>( | ||
path: string, | ||
@@ -248,0 +258,0 @@ args?: FetchRequestInit<T, TRequest, TResponse> |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
120218
980