From 25aa9b9bd7868726b619e00612f8ca7889d3735d Mon Sep 17 00:00:00 2001 From: Alejandro Celaya Date: Sat, 18 Mar 2023 10:29:49 +0100 Subject: [PATCH] Enhance types including potential bots on visits summary endpoint --- src/api/types/index.ts | 11 +++++++++++ src/short-urls/data/index.ts | 9 ++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/api/types/index.ts b/src/api/types/index.ts index ddd3cd97..a06515f4 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -40,13 +40,24 @@ export interface ShlinkPaginator { totalItems: number; } +export interface ShlinkVisitsSummary { + total: number; + nonBots: number; + bots: number; +} + export interface ShlinkVisits { data: Visit[]; pagination: ShlinkPaginator; } export interface ShlinkVisitsOverview { + nonOrphanVisits?: ShlinkVisitsSummary; // Optional only before Shlink 3.5.0 + orphanVisits?: ShlinkVisitsSummary; // Optional only before Shlink 3.5.0 + + /** @deprecated */ visitsCount: number; + /** @deprecated */ orphanVisitsCount: number; } diff --git a/src/short-urls/data/index.ts b/src/short-urls/data/index.ts index f1a5f9f8..7d37e935 100644 --- a/src/short-urls/data/index.ts +++ b/src/short-urls/data/index.ts @@ -1,3 +1,4 @@ +import type { ShlinkVisitsSummary } from '../../api/types'; import type { Order } from '../../utils/helpers/ordering'; import type { Nullable, OptionalString } from '../../utils/utils'; @@ -41,7 +42,7 @@ export interface ShortUrl { dateCreated: string; /** @deprecated */ visitsCount: number; // Deprecated since Shlink 3.4.0 - visitsSummary?: ShortUrlVisitsSummary; // Optional only before Shlink 3.4.0 + visitsSummary?: ShlinkVisitsSummary; // Optional only before Shlink 3.4.0 meta: Required>; tags: string[]; domain: string | null; @@ -56,12 +57,6 @@ export interface ShortUrlMeta { maxVisits?: number; } -export interface ShortUrlVisitsSummary { - total: number; - nonBots: number; - bots: number; -} - export interface ShortUrlModalProps { shortUrl: ShortUrl; isOpen: boolean;