Skip to content

Commit

Permalink
Remove deprecated fields (#901)
Browse files Browse the repository at this point in the history
* rm deprecated fields

* upgrade dependencies

---------

Co-authored-by: Aleks G <[email protected]>
  • Loading branch information
AlGvrl and Aleks-TT authored Jan 13, 2025
1 parent 4dc3667 commit 9db3e76
Show file tree
Hide file tree
Showing 15 changed files with 443 additions and 392 deletions.
26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,25 +34,25 @@
"prepare": "yarn run compile"
},
"dependencies": {
"axios": "^1.7.4",
"typescript": "^5.4.3"
"axios": "^1.7.9",
"typescript": "^5.7.3"
},
"devDependencies": {
"@eslint/compat": "^1.0.3",
"@types/jest": "^29.5.12",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"axios-mock-adapter": "^1.22.0",
"@eslint/compat": "^1.2.5",
"@types/jest": "^29.5.14",
"@typescript-eslint/eslint-plugin": "^8.19.1",
"@typescript-eslint/parser": "^8.19.1",
"axios-mock-adapter": "^2.1.0",
"cross-env": "^7.0.3",
"eslint": "^9.4.0",
"eslint": "^9.18.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-import": "^2.31.0",
"husky-v4": "^4.3.8",
"jest": "^29.7.0",
"lint-staged": "^15.2.0",
"prettier": "^3.2.5",
"ts-jest": "^29.1.1",
"typescript-eslint": "^7.12.0"
"lint-staged": "^15.3.0",
"prettier": "^3.4.2",
"ts-jest": "^29.2.5",
"typescript-eslint": "^8.19.1"
},
"husky": {
"hooks": {
Expand Down
2 changes: 1 addition & 1 deletion src/absenceTypes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AbsenceTypeCreate, AbsenceTypeUpdate } from './types';
const resourceName = 'absenceTypes';
type ResourceName = typeof resourceName;
export class AbsenceTypesEndpoint extends BaseApi<typeof resourceName> {
public readonly resourceName = 'absenceTypes';
public readonly resourceName = resourceName;

public create(
data: AbsenceTypeCreate,
Expand Down
8 changes: 7 additions & 1 deletion src/authentication/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,20 @@ export class AuthenticationEndpoint extends BaseApi<any> {
return axios.post<TokenResponse>(url, new URLSearchParams(credentials), config);
}

throw objectCheck(
const objectCheckResult = objectCheck(
{
client_id: this.config.settings.clientId,
client_secret: this.config.settings.clientSecret,
refresh_token: refreshToken,
},
'Missing data for:',
);

if (objectCheckResult) {
throw objectCheckResult;
} else {
throw new Error('Unknown refresh token error');
}
}

async login(credentials: Credentials): Promise<{ accessToken: string; refreshToken: string }> {
Expand Down
2 changes: 1 addition & 1 deletion src/baseApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export type ApiConfig = {
apiPrefix?: string;
onServerTimeDeviationChange?: (deviation: number) => void;
canonicalTimeUpdater?: (serverTimeZone: string, serverRequestEndTime: string) => void;
getChangedOnlyConfig?: (loggedInUser: User, since?: string | undefined) => DeltaSyncParams;
getChangedOnlyConfig?: (loggedInUser: User, since?: string) => DeltaSyncParams;
customRequestHeaders?: { [key: string]: string };
};

Expand Down
2 changes: 1 addition & 1 deletion src/generalSettings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const resourceName = 'generalSettings';
type ResourceName = typeof resourceName;

export class GeneralSettingsEndpoint extends BaseApi<ResourceName> {
public readonly resourceName = 'generalSettings';
public readonly resourceName = resourceName;

public readBySettingType(settingType: string): Required<ResourceName, Entity<ResourceName>[]> {
const params = new RequestParamsBuilder<GeneralSetting>().eq('setting_type', settingType).build();
Expand Down
6 changes: 0 additions & 6 deletions src/integrationCategories/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
// Fields externalId, iconUrl, createdAt, updatedAt will be deprecated.
// Use unique_id, icon_url, created_at, updated_at instead.
export type IntegrationCategory = {
id: number;
title: string;
externalId?: string;
unique_id: string;
iconUrl?: string;
icon_url?: string;
createdAt?: string;
created_at?: string;
updatedAt?: string;
updated_at?: string;
};
9 changes: 0 additions & 9 deletions src/integrations/types.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
// Fields shortDescription, websiteUrl, navigationUrl, imageUrl, accessCredentialsId, createdAt, updatedAt will be deprecated.
// Use short_description, website_url, navigation_url, image_url, access_credentials_id, created_at, updated_at instead.
export type Integration = {
id: number;
title: string;
shortDescription?: string;
short_description?: string;
websiteUrl?: string;
website_url?: string;
navigationUrl?: string;
navigation_url?: string;
imageUrl?: string;
image_url?: string;
featured?: boolean;
provider?: string;
application?: string;
accessCredentialsId?: number | null;
access_credentials_id?: number | null;
createdAt?: string;
created_at?: string;
updatedAt?: string;
updated_at?: string;
};
6 changes: 0 additions & 6 deletions src/integrationsToCategories/types.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
// Fields integrationId, categoryId, createdAt, updatedAt will be deprecated.
// Use integration_id, category_id, created_at, updated_at instead.
export type IntegrationToCategory = {
id: number;
integrationId?: number;
integration_id?: number;
categoryId?: number;
category_id?: number;
createdAt?: string;
updatedAt?: string;
created_at?: string;
updated_at?: string;
};
2 changes: 1 addition & 1 deletion src/tasks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const resourceName = 'tasks';
type ResourceName = typeof resourceName;

export class TasksEndpoint extends BaseApi<ResourceName> {
public readonly resourceName = 'tasks';
public readonly resourceName = resourceName;

public create(data: TaskCreate, params?: RequestParams<Entity<ResourceName>>): Required<ResourceName> {
const response = this._post<ResourceName>('create', data, params);
Expand Down
2 changes: 1 addition & 1 deletion src/timesheetAccountingSummaries/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const resourceName = 'timesheetAccountingSummaries';
type ResourceName = typeof resourceName;

export class TimesheetAccountingSummariesEndpoint extends BaseApi<'timesheetAccountingSummaries'> {
public readonly resourceName = 'timesheetAccountingSummaries';
public readonly resourceName = resourceName;

public readTimesheetAccountingSummaries(
params?: RequestParams<TimesheetAccountingSummariesRead> | string,
Expand Down
10 changes: 5 additions & 5 deletions src/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@ import {
} from './types';

const resourceName = 'users';
const usersReadMe = 'usersReadMe';
type UsersReadMe = 'usersReadMe';
type ResourceName = typeof resourceName;

export class UsersEndpoint extends BaseApi<ResourceName> {
public readonly resourceName = 'users';
public readonly resourceName = resourceName;

public readMe(params?: RequestParams<UserReadMe>): Required<typeof usersReadMe> {
const response = this._get<typeof usersReadMe>('me', { params });
public readMe(params?: RequestParams<UserReadMe>): Required<UsersReadMe> {
const response = this._get<UsersReadMe>('me', { params });
return requiredSingle(response);
}

public async readMeRaw(params: RequestParams<UserReadMe>): Promise<ReadRawResponse<UserReadMe>> {
const response = this._get<typeof usersReadMe>('me', { params });
const response = this._get<UsersReadMe>('me', { params });
return createReadRawResponse<UserReadMe>(createResourceResponse(await createRawApiResponse(response)), params);
}

Expand Down
6 changes: 3 additions & 3 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ type Data = {
* @param {string} prefix = undefined prefix of message
* @param {string} postfix = undefined postfix of message
*
* @return {string} message
* @return {Error | null} message
*/
export const objectCheck = (data: Data, prefix?: string, postfix?: string): string => {
export const objectCheck = (data: Data, prefix?: string, postfix?: string): Error | null => {
let message = ''; //: string = `${prefix || ''}`;

for (const key in data) {
Expand All @@ -32,7 +32,7 @@ export const objectCheck = (data: Data, prefix?: string, postfix?: string): stri
}
}

return message;
return message ? new Error(message) : null;
};

export class ConfigProvider {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/response/rawApiResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export async function createRawApiResponse(promise: Promise<AxiosResponse>): Pro
if (error.response?.data != null && typeof error.response.data === 'object' && hasSuccessProperty(error.response.data)) {
axiosResponse = error.response;
} else {
//eslint-disable-next-line @typescript-eslint/only-throw-error
throw {
_plainError: error,
message: error.message,
Expand All @@ -68,6 +69,7 @@ export async function createRawApiResponse(promise: Promise<AxiosResponse>): Pro
} else {
const optionalResponse = axiosResponse.data as ApiResponseOnFailure | undefined;

//eslint-disable-next-line @typescript-eslint/only-throw-error
throw {
response: optionalResponse,
_plainError: axiosResponse,
Expand Down
3 changes: 3 additions & 0 deletions src/utils/response/responseHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ async function resolveResponse<ResourceName extends ResourceNames>(
if (error.response?.data != null && typeof error.response.data !== 'string' && hasSuccessProperty(error.response.data)) {
resolved = error.response as AxiosResponse<ApiResponse<ResourceName>> | AxiosResponse<ApiBatchResponse<ResourceName>>;
} else {
//eslint-disable-next-line @typescript-eslint/only-throw-error
throw {
_plainError: error,
message: error.message,
Expand All @@ -117,6 +118,7 @@ export async function toApiBatchResponse<ResourceName extends ResourceNames>(
return apiResponse;
}

//eslint-disable-next-line @typescript-eslint/only-throw-error
throw getParsedErrorMessageObject(apiResponse, resolved);
}

Expand All @@ -140,6 +142,7 @@ export async function toApiResponse<ResourceName extends ResourceNames>(
return apiResponse;
}

//eslint-disable-next-line @typescript-eslint/only-throw-error
throw getParsedErrorMessageObject(apiResponse, resolved);
}

Expand Down
Loading

0 comments on commit 9db3e76

Please sign in to comment.