mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 09:30:31 +03:00
Fix imports
This commit is contained in:
parent
007d79dd03
commit
9f9f3b6402
3 changed files with 15 additions and 5 deletions
|
@ -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'>;
|
export type TagStats = Omit<ShlinkTagsStats, 'tag'>;
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
import type { ShlinkVisitsParams } from '@shlinkio/shlink-web-component/api-contract';
|
||||||
import { countBy, groupBy, pipe, prop } from 'ramda';
|
import { countBy, groupBy, pipe, prop } from 'ramda';
|
||||||
import type { ShlinkVisitsParams } from '../../../api/types';
|
|
||||||
import { formatIsoDate } from '../../utils/dates/helpers/date';
|
import { formatIsoDate } from '../../utils/dates/helpers/date';
|
||||||
import type { CreateVisit, NormalizedOrphanVisit, NormalizedVisit, OrphanVisit, Stats, Visit, VisitsParams } from './index';
|
import type { CreateVisit, NormalizedOrphanVisit, NormalizedVisit, OrphanVisit, Stats, Visit, VisitsParams } from './index';
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { orderToString, stringifyQuery } from '@shlinkio/shlink-frontend-kit';
|
import { orderToString, stringifyQuery } from '@shlinkio/shlink-frontend-kit';
|
||||||
import type {
|
import type {
|
||||||
|
RegularNotFound,
|
||||||
ShlinkApiClient as BaseShlinkApiClient,
|
ShlinkApiClient as BaseShlinkApiClient,
|
||||||
ShlinkDomainRedirects,
|
ShlinkDomainRedirects,
|
||||||
ShlinkDomainsResponse,
|
ShlinkDomainsResponse,
|
||||||
|
@ -15,9 +16,11 @@ import type {
|
||||||
ShlinkTagsStatsResponse,
|
ShlinkTagsStatsResponse,
|
||||||
ShlinkVisits,
|
ShlinkVisits,
|
||||||
ShlinkVisitsOverview,
|
ShlinkVisitsOverview,
|
||||||
ShlinkVisitsParams,
|
ShlinkVisitsParams } from '@shlinkio/shlink-web-component/api-contract';
|
||||||
|
import {
|
||||||
|
ErrorTypeV2,
|
||||||
|
ErrorTypeV3,
|
||||||
} from '@shlinkio/shlink-web-component/api-contract';
|
} 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 { isEmpty, isNil, reject } from 'ramda';
|
||||||
import type { ShortUrl, ShortUrlData } from '../../../shlink-web-component/src/short-urls/data';
|
import type { ShortUrl, ShortUrlData } from '../../../shlink-web-component/src/short-urls/data';
|
||||||
import type { HttpClient } from '../../common/services/HttpClient';
|
import type { HttpClient } from '../../common/services/HttpClient';
|
||||||
|
@ -44,6 +47,13 @@ const normalizeListParams = (
|
||||||
excludePastValidUntil: excludePastValidUntil === true ? 'true' : undefined,
|
excludePastValidUntil: excludePastValidUntil === true ? 'true' : undefined,
|
||||||
orderBy: orderToString(orderBy),
|
orderBy: orderToString(orderBy),
|
||||||
});
|
});
|
||||||
|
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 {
|
export class ShlinkApiClient implements BaseShlinkApiClient {
|
||||||
private apiVersion: ApiVersion;
|
private apiVersion: ApiVersion;
|
||||||
|
@ -162,7 +172,7 @@ export class ShlinkApiClient implements BaseShlinkApiClient {
|
||||||
};
|
};
|
||||||
|
|
||||||
private readonly handleFetchError = (retryFetch: Function) => (e: unknown) => {
|
private readonly handleFetchError = (retryFetch: Function) => (e: unknown) => {
|
||||||
if (!isRegularNotFound(parseApiError(e))) {
|
if (!isRegularNotFound(e)) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue