[ci:force] - Fixed lint

This commit is contained in:
VitoAlbano
2024-10-14 00:08:11 +01:00
committed by Vito Albano
parent c1a42596dd
commit 7bdec42329
279 changed files with 3312 additions and 3998 deletions

View File

@@ -21,7 +21,6 @@ import { HttpParameterCodec } from '@angular/common/http';
// does not encode some special characters like + with is causing issues with the alfresco js API and returns 500 error
export class AlfrescoApiParamEncoder implements HttpParameterCodec {
encodeKey(key: string): string {
return encodeURIComponent(key);
}

View File

@@ -16,10 +16,9 @@
*/
export class AlfrescoApiResponseError extends Error {
public name = 'AlfrescoApiResponseError';
constructor(msg: string, public status: number, public response: Record<string, any> ) {
constructor(msg: string, public status: number, public response: Record<string, any>) {
super(msg);
}
}

View File

@@ -18,7 +18,6 @@
import { isConstructor, getQueryParamsWithCustomEncoder, removeNilValues } from './alfresco-api.utils';
describe('AlfrescoApiUtils', () => {
describe('isConstructor', () => {
class MockClass {}
/**
@@ -50,9 +49,7 @@ describe('AlfrescoApiUtils', () => {
});
});
describe('getQueryParamsWithCustomEncoder', () => {
it('should return queryParams with removed undefined values', () => {
const actual = getQueryParamsWithCustomEncoder({
key1: 'value1',
@@ -73,9 +70,7 @@ describe('AlfrescoApiUtils', () => {
});
});
describe('removeUndefinedValues', () => {
it('should return queryParams with removed undefined values', () => {
const actual = removeNilValues({
key1: 'value1',
@@ -98,5 +93,4 @@ describe('AlfrescoApiUtils', () => {
expect(actual?.getAll('key2')).toEqual(['value2', 'value3']);
});
});
});

View File

@@ -15,18 +15,31 @@
* limitations under the License.
*/
import { HttpEvent, HttpUploadProgressEvent, HttpEventType, HttpResponse, HttpParams, HttpParameterCodec, HttpUrlEncodingCodec } from '@angular/common/http';
import {
HttpEvent,
HttpUploadProgressEvent,
HttpEventType,
HttpResponse,
HttpParams,
HttpParameterCodec,
HttpUrlEncodingCodec
} from '@angular/common/http';
import { Constructor } from '../types';
export const isHttpUploadProgressEvent = <T>(val: HttpEvent<T>): val is HttpUploadProgressEvent => val.type === HttpEventType.UploadProgress;
export const isHttpResponseEvent = <T>(val: HttpEvent<T>): val is HttpResponse<T> => val.type === HttpEventType.Response;
export const isDate = (value: unknown): value is Date => value instanceof Date;
export const isXML = (value: unknown): boolean => typeof value === 'string' && value.startsWith('<?xml');
export const isBlobResponse = (response: HttpResponse<any>, returnType: Constructor<unknown> | 'blob'): response is HttpResponse<Blob> => returnType === 'blob' || response.body instanceof Blob;
export const isConstructor = <T = unknown>(value: any): value is Constructor<T> => typeof value === 'function' && !!value?.prototype?.constructor.name;
export const isBlobResponse = (response: HttpResponse<any>, returnType: Constructor<unknown> | 'blob'): response is HttpResponse<Blob> =>
returnType === 'blob' || response.body instanceof Blob;
export const isConstructor = <T = unknown>(value: any): value is Constructor<T> =>
typeof value === 'function' && !!value?.prototype?.constructor.name;
const convertParamsToString = (value: any): any => isDate(value) ? value.toISOString() : value;
export const getQueryParamsWithCustomEncoder = (obj: Record<string | number, unknown>, encoder: HttpParameterCodec = new HttpUrlEncodingCodec()): HttpParams | undefined => {
const convertParamsToString = (value: any): any => (isDate(value) ? value.toISOString() : value);
export const getQueryParamsWithCustomEncoder = (
obj: Record<string | number, unknown>,
encoder: HttpParameterCodec = new HttpUrlEncodingCodec()
): HttpParams | undefined => {
if (!obj) {
return undefined;
}
@@ -38,7 +51,6 @@ export const getQueryParamsWithCustomEncoder = (obj: Record<string | number, unk
const params = removeNilValues(obj);
for (const key in params) {
if (Object.prototype.hasOwnProperty.call(params, key)) {
const value = params[key];
if (value instanceof Array) {
@@ -57,12 +69,10 @@ export const getQueryParamsWithCustomEncoder = (obj: Record<string | number, unk
/**
* Removes null and undefined values from an object.
*
* @param obj object to process
* @returns object with updated values
*/
export const removeNilValues = (obj: Record<string | number, unknown>) => {
if (!obj) {
return {};
}
@@ -74,9 +84,7 @@ export const removeNilValues = (obj: Record<string | number, unknown>) => {
}, {});
};
export const convertObjectToFormData = (formParams: Record<string | number, string | Blob>): FormData => {
const formData = new FormData();
for (const key in formParams) {

View File

@@ -17,6 +17,6 @@
export interface Dictionary<T> {
[key: string]: T;
};
}
export type Constructor<T> = new (...args: any[]) => T;