Skip to content

Commit

Permalink
Fix imports
Browse files Browse the repository at this point in the history
  • Loading branch information
acelaya committed Aug 6, 2023
1 parent 007d79d commit eae7eed
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion shlink-web-component/src/tags/data/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { ShlinkTagsStats } from '../../../api/types';
import type { ShlinkTagsStats } from '@shlinkio/shlink-web-component/api-contract';

export type TagStats = Omit<ShlinkTagsStats, 'tag'>;

Expand Down
2 changes: 1 addition & 1 deletion shlink-web-component/src/visits/types/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { ShlinkVisitsParams } from '@shlinkio/shlink-web-component/api-contract';
import { countBy, groupBy, pipe, prop } from 'ramda';
import type { ShlinkVisitsParams } from '../../../api/types';
import { formatIsoDate } from '../../utils/dates/helpers/date';
import type { CreateVisit, NormalizedOrphanVisit, NormalizedVisit, OrphanVisit, Stats, Visit, VisitsParams } from './index';

Expand Down
16 changes: 13 additions & 3 deletions src/api/services/ShlinkApiClient.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { orderToString, stringifyQuery } from '@shlinkio/shlink-frontend-kit';
import type {
RegularNotFound,
ShlinkApiClient as BaseShlinkApiClient,
ShlinkDomainRedirects,
ShlinkDomainsResponse,
Expand All @@ -15,9 +16,11 @@ import type {
ShlinkTagsStatsResponse,
ShlinkVisits,
ShlinkVisitsOverview,
ShlinkVisitsParams,
ShlinkVisitsParams } from '@shlinkio/shlink-web-component/api-contract';
import {
ErrorTypeV2,
ErrorTypeV3,
} from '@shlinkio/shlink-web-component/api-contract';
import { isRegularNotFound, parseApiError } from '@shlinkio/shlink-web-component/api-contract/utils';
import { isEmpty, isNil, reject } from 'ramda';
import type { ShortUrl, ShortUrlData } from '../../../shlink-web-component/src/short-urls/data';
import type { HttpClient } from '../../common/services/HttpClient';
Expand All @@ -44,6 +47,13 @@ const normalizeListParams = (
excludePastValidUntil: excludePastValidUntil === true ? 'true' : undefined,
orderBy: orderToString(orderBy),
});
export const isRegularNotFound = (error: unknown): error is RegularNotFound => {
if (error === null || !(typeof error === 'object' && 'type' in error && 'status' in error)) {
return false;
}

return (error.type === ErrorTypeV2.NOT_FOUND || error.type === ErrorTypeV3.NOT_FOUND) && error.status === 404;
};

export class ShlinkApiClient implements BaseShlinkApiClient {
private apiVersion: ApiVersion;
Expand Down Expand Up @@ -162,7 +172,7 @@ export class ShlinkApiClient implements BaseShlinkApiClient {
};

private readonly handleFetchError = (retryFetch: Function) => (e: unknown) => {
if (!isRegularNotFound(parseApiError(e))) {
if (!isRegularNotFound(e)) {
throw e;
}

Expand Down

0 comments on commit eae7eed

Please sign in to comment.