update dependencies. fix eslint errors

This commit is contained in:
Alexander T 2019-07-19 14:11:48 +03:00
Родитель 80f9ef2a16
Коммит 0369ea3f56
9 изменённых файлов: 624 добавлений и 481 удалений

Просмотреть файл

@ -1,11 +1,13 @@
{
"parserOptions": {
"project": "./tsconfig.json"
},
"extends": ["skype"],
"env": {
"jasmine": true
},
"rules": {
"@typescript-eslint/interface-name-prefix": "off",
"no-console": ["error", { "allow": ["error", "warn"] }]
}
}

960
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -20,28 +20,28 @@
},
"devDependencies": {
"@types/faker": "4.1.5",
"@types/jasmine": "3.3.12",
"@types/jasmine-ajax": "3.1.39",
"@typescript-eslint/eslint-plugin": "1.9.0",
"@typescript-eslint/parser": "1.9.0",
"eslint": "5.16.0",
"eslint-config-skype": "0.0.3",
"@types/jasmine": "3.3.14",
"@types/jasmine-ajax": "3.1.40",
"@typescript-eslint/eslint-plugin": "1.12.0",
"@typescript-eslint/parser": "1.12.0",
"eslint": "6.0.1",
"eslint-config-skype": "0.2.0",
"faker": "4.1.0",
"fork-ts-checker-webpack-plugin": "1.3.3",
"fork-ts-checker-webpack-plugin": "1.4.3",
"jasmine": "3.4.0",
"jasmine-core": "3.4.0",
"karma": "4.1.0",
"karma-chrome-launcher": "2.2.0",
"karma": "4.2.0",
"karma-chrome-launcher": "3.0.0",
"karma-jasmine": "2.0.1",
"karma-jasmine-ajax": "0.1.13",
"karma-jasmine-html-reporter": "1.4.2",
"karma-sourcemap-loader": "0.3.7",
"karma-spec-reporter": "0.0.32",
"karma-webpack": "4.0.0-beta.0",
"karma-webpack": "4.0.2",
"rimraf": "2.6.3",
"ts-loader": "6.0.1",
"typescript": "3.4.5",
"webpack": "4.31.0"
"ts-loader": "6.0.4",
"typescript": "3.5.3",
"webpack": "4.36.1"
},
"repository": {
"type": "git",

Просмотреть файл

@ -22,9 +22,9 @@ export class ExponentialTime {
* @param jitterFactor
*/
constructor(private _initialTime: number,
private _maxTime: number,
private _growFactor = DEFAULT_TIME_GROW_FACTOR,
private _jitterFactor = DEFAULT_TIME_JITTER) {
private _maxTime: number,
private _growFactor = DEFAULT_TIME_GROW_FACTOR,
private _jitterFactor = DEFAULT_TIME_JITTER) {
assert(this._initialTime > 0, 'Initial delay must be positive');
assert(this._maxTime > 0, 'Delay upper bound must be positive');

Просмотреть файл

@ -36,7 +36,7 @@ export class GenericRestClient {
protected _defaultOptions: ApiCallOptions = {
excludeEndpointUrl: false,
withCredentials: false,
retries: 0
retries: 0,
};
constructor(endpointUrl: string) {
@ -44,9 +44,9 @@ export class GenericRestClient {
}
protected _performApiCall<T>(apiPath: string,
action: HttpAction,
objToPost: any,
givenOptions?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
action: HttpAction,
objToPost: any,
givenOptions?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
let options = defaults<ApiCallOptions, ApiCallOptions, ApiCallOptions>({}, givenOptions || {}, this._defaultOptions);
if (objToPost) {
@ -71,7 +71,7 @@ export class GenericRestClient {
finalUrl,
options,
() => this._getHeaders(options),
() => this._blockRequestUntil(options)
() => this._blockRequestUntil(options),
)
.start()
.then(response => {
@ -114,8 +114,8 @@ export class GenericRestClient {
}
performApiPostDetailed<T>(apiPath: string,
objToPost: any,
options?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
objToPost: any,
options?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
return this._performApiCall<T>(apiPath, 'POST', objToPost, options);
}
@ -126,8 +126,8 @@ export class GenericRestClient {
}
performApiPatchDetailed<T>(apiPath: string,
objToPatch: any,
options?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
objToPatch: any,
options?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
return this._performApiCall<T>(apiPath, 'PATCH', objToPatch, options);
}
@ -148,8 +148,8 @@ export class GenericRestClient {
}
performApiDeleteDetailed<T>(apiPath: string,
objToDelete: any,
options?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
objToDelete: any,
options?: ApiCallOptions): SyncTasks.Promise<WebResponse<T, ApiCallOptions>> {
return this._performApiCall<T>(apiPath, 'DELETE', objToDelete, options);
}
}

Просмотреть файл

@ -136,9 +136,10 @@ function isFormDataContentType(ct: string): boolean {
}
export const DefaultOptions: WebRequestOptions = {
priority: WebRequestPriority.Normal
priority: WebRequestPriority.Normal,
};
// eslint-disable-next-line @typescript-eslint/interface-name-prefix
export interface ISimpleWebRequestOptions {
// Maximum executing requests allowed. Other requests will be queued until free spots become available.
MaxSimultaneousRequests: number;
@ -157,7 +158,7 @@ export let SimpleWebRequestOptions: ISimpleWebRequestOptions = {
HungRequestCleanupIntervalMs: 10000,
setTimeout: (callback: () => void, timeoutMs?: number) => window.setTimeout(callback, timeoutMs),
clearTimeout: (id: number) => window.clearTimeout(id)
clearTimeout: (id: number) => window.clearTimeout(id),
};
export function DefaultErrorHandler(webRequest: SimpleWebRequestBase, errResp: WebTransportErrorResponse): ErrorHandlingType {
@ -214,9 +215,9 @@ export abstract class SimpleWebRequestBase<TOptions extends WebRequestOptions =
protected _retryExponentialTime = new ExponentialTime(1000, 300000);
constructor(protected _action: string,
protected _url: string, options: TOptions,
protected _getHeaders?: () => Headers,
protected _blockRequestUntil?: () => SyncTasks.Promise<void> | undefined) {
protected _url: string, options: TOptions,
protected _getHeaders?: () => Headers,
protected _blockRequestUntil?: () => SyncTasks.Promise<void> | undefined) {
this._options = _.defaults(options, DefaultOptions);
}
@ -663,10 +664,10 @@ export class SimpleWebRequest<TBody, TOptions extends WebRequestOptions = WebReq
private _deferred: SyncTasks.Deferred<WebResponse<TBody, TOptions>>;
constructor(action: string,
url: string,
options: TOptions,
getHeaders?: () => Headers,
blockRequestUntil?: () => SyncTasks.Promise<void> | undefined) {
url: string,
options: TOptions,
getHeaders?: () => Headers,
blockRequestUntil?: () => SyncTasks.Promise<void> | undefined) {
super(action, url, options, getHeaders, blockRequestUntil);
}
@ -815,7 +816,7 @@ export class SimpleWebRequest<TBody, TOptions extends WebRequestOptions = WebReq
statusCode: statusCode,
statusText: statusText,
headers: headers,
body: body as TBody
body: body as TBody,
};
this._deferred.resolve(resp);
@ -830,7 +831,7 @@ export class SimpleWebRequest<TBody, TOptions extends WebRequestOptions = WebReq
headers: headers,
body: body,
canceled: this._aborted,
timedOut: this._timedOut
timedOut: this._timedOut,
};
if (this._options.augmentErrorResponse) {

Просмотреть файл

@ -36,7 +36,7 @@ describe('GenericRestClient', () => {
const body = {
title: faker.name.title(),
text: faker.lorem.text(),
id
id,
};
const path = `/get/${id}`;
const url = BASE_URL + path;
@ -47,7 +47,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -64,7 +64,7 @@ describe('GenericRestClient', () => {
const body = {
title: faker.name.title(),
text: faker.lorem.text(),
id
id,
};
const path = `/get/${id}`;
const url = BASE_URL + path;
@ -74,7 +74,7 @@ describe('GenericRestClient', () => {
statusCode,
method,
body,
url
url,
};
http.performApiGetDetailed(path, { contentType: 'json' })
@ -83,7 +83,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -97,7 +97,7 @@ describe('GenericRestClient', () => {
const method = 'POST';
const sendData = {
title: faker.name.title(),
text: faker.lorem.text()
text: faker.lorem.text(),
};
const body = { ...sendData, id: faker.random.uuid() };
const path = '/post';
@ -109,7 +109,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -124,7 +124,7 @@ describe('GenericRestClient', () => {
const onSuccess = jasmine.createSpy('onSuccess');
const sendData = {
title: faker.name.title(),
text: faker.lorem.text()
text: faker.lorem.text(),
};
const method = 'POST';
const body = { ...sendData, id: faker.random.uuid() };
@ -136,7 +136,7 @@ describe('GenericRestClient', () => {
statusCode,
method,
body,
url
url,
};
http.performApiPostDetailed(path, sendData, { contentType: 'json' })
@ -145,7 +145,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -170,7 +170,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -195,7 +195,7 @@ describe('GenericRestClient', () => {
statusCode,
method,
body,
url
url,
};
http.performApiPutDetailed(path, sendData, { contentType: 'json' })
@ -204,7 +204,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -221,7 +221,7 @@ describe('GenericRestClient', () => {
const method = 'PATCH';
const sendData = {
title: faker.name.title(),
text: faker.lorem.text()
text: faker.lorem.text(),
};
const body = { ...sendData, text: faker.lorem.text(), id };
const path = '/patch' + id;
@ -233,7 +233,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -249,7 +249,7 @@ describe('GenericRestClient', () => {
const onSuccess = jasmine.createSpy('onSuccess');
const sendData = {
title: faker.name.title(),
text: faker.lorem.text()
text: faker.lorem.text(),
};
const method = 'PATCH';
const body = { ...sendData, id: faker.random.uuid() };
@ -261,7 +261,7 @@ describe('GenericRestClient', () => {
statusCode,
method,
body,
url
url,
};
http.performApiPatchDetailed(path, sendData, { contentType: 'json' })
@ -270,7 +270,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -294,7 +294,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -317,7 +317,7 @@ describe('GenericRestClient', () => {
statusCode,
method,
body,
url
url,
};
http.performApiDeleteDetailed(path, sendData, { contentType: 'json' })
@ -326,7 +326,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);
@ -337,7 +337,7 @@ describe('GenericRestClient', () => {
it('performs request with custom headers', () => {
const headers = {
'Authorization': `Barrier ${faker.random.uuid()}`
'Authorization': `Barrier ${faker.random.uuid()}`,
};
class Http extends GenericRestClient {
@ -380,7 +380,7 @@ describe('GenericRestClient', () => {
const request = jasmine.Ajax.requests.mostRecent();
request.respondWith({
responseText: JSON.stringify(body),
status: statusCode
status: statusCode,
});
expect(request.url).toEqual(url);

Просмотреть файл

@ -5,7 +5,7 @@ import {
SimpleWebRequest,
SimpleWebRequestOptions,
WebErrorResponse,
WebRequestPriority
WebRequestPriority,
} from '../src/SimpleWebRequest';
import { DETAILED_RESPONSE } from './helpers';
@ -48,7 +48,7 @@ describe('SimpleWebRequest', () => {
it('sends json POST request', () => {
const sendData = {
title: faker.name.title(),
text: faker.lorem.text()
text: faker.lorem.text(),
};
const requestOptions = { sendData };
const statusCode = 201;
@ -74,7 +74,7 @@ describe('SimpleWebRequest', () => {
it('allows to set request headers', () => {
const headers = {
'X-Requested-With': 'XMLHttpRequest',
'Max-Forwards': '10'
'Max-Forwards': '10',
};
const method = 'POST';
const url = faker.internet.url();
@ -93,7 +93,7 @@ describe('SimpleWebRequest', () => {
spyOn(console, 'error');
const headers = {
'Accept': 'application/xml'
'Accept': 'application/xml',
};
const method = 'GET';
const url = faker.internet.url();
@ -108,7 +108,7 @@ describe('SimpleWebRequest', () => {
spyOn(console, 'error');
const headers = {
'Content-Type': 'application/xml'
'Content-Type': 'application/xml',
};
const method = 'GET';
const url = faker.internet.url();
@ -325,7 +325,7 @@ describe('SimpleWebRequest', () => {
const requestPromise = new SimpleWebRequest<string>(url, method, {
timeout: 10,
retries: 1,
customErrorHandler: () => ErrorHandlingType.RetryCountedWithBackoff
customErrorHandler: () => ErrorHandlingType.RetryCountedWithBackoff,
}).start();
requestPromise

Просмотреть файл

@ -3,12 +3,12 @@ export const REQUEST_OPTIONS = {
withCredentials: false,
contentType: 'json',
priority: 2,
retries: 0
retries: 0,
};
export const REQUEST_HEADERS = {
'Content-Type': 'application/json',
'Accept': 'application/json'
'Accept': 'application/json',
};
export const DETAILED_RESPONSE = {
@ -18,5 +18,5 @@ export const DETAILED_RESPONSE = {
statusText: undefined,
headers: { 'content-type': 'application/json' },
body: '',
url: ''
url: '',
};