mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 16:42:56 +00:00
style: apply stricter ts lint rules
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018 StApps
|
||||
* Copyright (C) 2018, 2019 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
@@ -14,6 +14,7 @@
|
||||
*/
|
||||
import {
|
||||
SCAbstractRoute,
|
||||
SCErrorResponse,
|
||||
SCFeedbackRequest,
|
||||
SCFeedbackResponse,
|
||||
SCFeedbackRoute,
|
||||
@@ -32,7 +33,7 @@ import {
|
||||
SCThings,
|
||||
} from '@openstapps/core';
|
||||
import {ApiError, CoreVersionIncompatibleError, OutOfRangeError} from './errors';
|
||||
import {HttpClientHeaders, HttpClientInterface} from './httpClientInterface';
|
||||
import {HttpClientHeaders, HttpClientInterface} from './http-client-interface';
|
||||
|
||||
/**
|
||||
* StApps-API client
|
||||
@@ -115,7 +116,7 @@ export class Client {
|
||||
* @param feedback Feedback to send
|
||||
*/
|
||||
async feedback(feedback: SCFeedbackRequest): Promise<SCFeedbackResponse> {
|
||||
return await this.invokeRoute<SCFeedbackResponse>(this.feedbackRoute, undefined, feedback);
|
||||
return this.invokeRoute<SCFeedbackResponse>(this.feedbackRoute, undefined, feedback);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -167,7 +168,7 @@ export class Client {
|
||||
* @param body Body for the request
|
||||
*/
|
||||
async invokeRoute<T>(route: SCAbstractRoute,
|
||||
parameters?: { [k: string]: string },
|
||||
parameters?: { [k: string]: string; },
|
||||
body?: SCRequests): Promise<T> {
|
||||
// make the request
|
||||
const response = await this.httpClient.request({
|
||||
@@ -182,7 +183,7 @@ export class Client {
|
||||
return response.body as T;
|
||||
}
|
||||
|
||||
throw new ApiError(response.body);
|
||||
throw new ApiError(response.body as SCErrorResponse);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -197,21 +198,24 @@ export class Client {
|
||||
let preFlightNecessary = false;
|
||||
|
||||
// gather search requests where size is not set
|
||||
Object.keys(multiSearchRequest).forEach((key) => {
|
||||
const searchRequest = multiSearchRequest[key];
|
||||
Object.keys(multiSearchRequest)
|
||||
.forEach((key) => {
|
||||
const searchRequest = multiSearchRequest[key];
|
||||
|
||||
if (typeof searchRequest.size === 'undefined') {
|
||||
preFlightRequest[key] = {
|
||||
...searchRequest,
|
||||
};
|
||||
preFlightRequest[key].size = 0;
|
||||
preFlightNecessary = true;
|
||||
}
|
||||
});
|
||||
if (typeof searchRequest.size === 'undefined') {
|
||||
preFlightRequest[key] = {
|
||||
...searchRequest,
|
||||
};
|
||||
preFlightRequest[key].size = 0;
|
||||
preFlightNecessary = true;
|
||||
}
|
||||
});
|
||||
|
||||
let returnMultiSearchRequest = multiSearchRequest;
|
||||
|
||||
if (preFlightNecessary) {
|
||||
// copy multi search request
|
||||
multiSearchRequest = {
|
||||
returnMultiSearchRequest = {
|
||||
...multiSearchRequest,
|
||||
};
|
||||
|
||||
@@ -223,13 +227,14 @@ export class Client {
|
||||
);
|
||||
|
||||
// set size for multi search requests that were in pre flight request
|
||||
Object.keys(preFlightRequest).forEach((key) => {
|
||||
multiSearchRequest[key].size = preFlightResponse[key].pagination.total;
|
||||
});
|
||||
Object.keys(preFlightRequest)
|
||||
.forEach((key) => {
|
||||
returnMultiSearchRequest[key].size = preFlightResponse[key].pagination.total;
|
||||
});
|
||||
}
|
||||
|
||||
// actually invoke the route
|
||||
return await this.invokeRoute<SCMultiSearchResponse>(this.multiSearchRoute, undefined, multiSearchRequest);
|
||||
return this.invokeRoute<SCMultiSearchResponse>(this.multiSearchRoute, undefined, returnMultiSearchRequest);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -251,7 +256,7 @@ export class Client {
|
||||
size = preFlightResponse.pagination.total;
|
||||
}
|
||||
|
||||
return await this.invokeRoute<SCSearchResponse>(this.searchRoute, undefined, {
|
||||
return this.invokeRoute<SCSearchResponse>(this.searchRoute, undefined, {
|
||||
...searchRequest,
|
||||
size,
|
||||
});
|
||||
@@ -264,8 +269,10 @@ export class Client {
|
||||
* @param searchResponse Search response for supplied search request
|
||||
*/
|
||||
async searchNext(searchRequest: SCSearchRequest, searchResponse: SCSearchResponse): Promise<{
|
||||
/* tslint:disable:completed-docs */
|
||||
searchRequest: SCSearchRequest;
|
||||
searchResponse: SCSearchResponse;
|
||||
/* tslint:enable:completed-docs */
|
||||
}> {
|
||||
const nextSearchRequest = Client.nextWindow(searchRequest, searchResponse);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user