diff --git a/shlink-web-component/src/api-contract/ShlinkApiClient.ts b/shlink-web-component/src/api-contract/ShlinkApiClient.ts index 20c9ce5c..dcd1c5d7 100644 --- a/shlink-web-component/src/api-contract/ShlinkApiClient.ts +++ b/shlink-web-component/src/api-contract/ShlinkApiClient.ts @@ -1,4 +1,4 @@ -import type { ShortUrl, ShortUrlData } from '../short-urls/data'; +import type { ShlinkShortUrl, ShortUrlData } from '../short-urls/data'; import type { ShlinkDomainRedirects, ShlinkDomainsResponse, @@ -20,7 +20,7 @@ export type ShlinkApiClient = { listShortUrls(params?: ShlinkShortUrlsListParams): Promise; - createShortUrl(options: ShortUrlData): Promise; + createShortUrl(options: ShortUrlData): Promise; getShortUrlVisits(shortCode: string, query?: ShlinkVisitsParams): Promise; @@ -34,7 +34,7 @@ export type ShlinkApiClient = { getVisitsOverview(): Promise; - getShortUrl(shortCode: string, domain?: string | null): Promise; + getShortUrl(shortCode: string, domain?: string | null): Promise; deleteShortUrl(shortCode: string, domain?: string | null): Promise; @@ -42,7 +42,7 @@ export type ShlinkApiClient = { shortCode: string, domain: string | null | undefined, body: ShlinkShortUrlData, - ): Promise; + ): Promise; listTags(): Promise; diff --git a/shlink-web-component/src/api-contract/types.ts b/shlink-web-component/src/api-contract/types.ts index 5ef4fed5..ddc61d51 100644 --- a/shlink-web-component/src/api-contract/types.ts +++ b/shlink-web-component/src/api-contract/types.ts @@ -1,9 +1,9 @@ import type { Order } from '@shlinkio/shlink-frontend-kit'; -import type { ShortUrl, ShortUrlMeta } from '../short-urls/data'; +import type { ShlinkDeviceLongUrls, ShlinkShortUrl } from '../short-urls/data'; import type { Visit } from '../visits/types'; export interface ShlinkShortUrlsResponse { - data: ShortUrl[]; + data: ShlinkShortUrl[]; pagination: ShlinkPaginator; } @@ -77,11 +77,18 @@ export interface ShlinkVisitsParams { excludeBots?: boolean; } -export interface ShlinkShortUrlData extends ShortUrlMeta { +export interface ShlinkShortUrlData { longUrl?: string; - title?: string; + title?: string | null; + /** @deprecated */ validateUrl?: boolean; tags?: string[]; + deviceLongUrls?: ShlinkDeviceLongUrls; + crawlable?: boolean; + forwardQuery?: boolean; + validSince?: string | null; + validUntil?: string | null; + maxVisits?: number | null; } export interface ShlinkDomainRedirects { diff --git a/shlink-web-component/src/short-urls/ShortUrlForm.tsx b/shlink-web-component/src/short-urls/ShortUrlForm.tsx index dad880c8..801ab447 100644 --- a/shlink-web-component/src/short-urls/ShortUrlForm.tsx +++ b/shlink-web-component/src/short-urls/ShortUrlForm.tsx @@ -17,7 +17,7 @@ import { DateTimeInput } from '../utils/dates/DateTimeInput'; import { formatIsoDate } from '../utils/dates/helpers/date'; import { useFeature } from '../utils/features'; import { handleEventPreventingDefault, hasValue } from '../utils/helpers'; -import type { DeviceLongUrls, ShortUrlData } from './data'; +import type { ShlinkDeviceLongUrls, ShortUrlData } from './data'; import { ShortUrlFormCheckboxGroup } from './helpers/ShortUrlFormCheckboxGroup'; import { UseExistingIfFoundInfoIcon } from './UseExistingIfFoundInfoIcon'; import './ShortUrlForm.scss'; @@ -87,7 +87,7 @@ export const ShortUrlForm = ( /> ); - const renderDeviceLongUrlInput = (id: keyof DeviceLongUrls, placeholder: string, icon: IconProp) => ( + const renderDeviceLongUrlInput = (id: keyof ShlinkDeviceLongUrls, placeholder: string, icon: IconProp) => ( { longUrl: string; customSlug?: string; shortCodeLength?: number; domain?: string; findIfExists?: boolean; + deviceLongUrls?: { + android?: string; + ios?: string; + desktop?: string; + } } -export interface ShortUrlIdentifier { - shortCode: string; - domain?: OptionalString; +export interface ShlinkDeviceLongUrls { + android?: OptionalString; + ios?: OptionalString; + desktop?: OptionalString; } -export interface ShortUrl { +export interface ShlinkShortUrl { shortCode: string; shortUrl: string; longUrl: string; - deviceLongUrls?: Required, // Optional only before Shlink 3.5.0 + deviceLongUrls?: Required, // Optional only before Shlink 3.5.0 dateCreated: string; /** @deprecated */ visitsCount: number; // Deprecated since Shlink 3.4.0 visitsSummary?: ShlinkVisitsSummary; // Optional only before Shlink 3.4.0 - meta: Required>; + meta: Required>; tags: string[]; domain: string | null; title?: string | null; @@ -51,14 +38,19 @@ export interface ShortUrl { forwardQuery?: boolean; } -export interface ShortUrlMeta { +export interface ShlinkShortUrlMeta { validSince?: string; validUntil?: string; maxVisits?: number; } +export interface ShortUrlIdentifier { + shortCode: string; + domain?: OptionalString; +} + export interface ShortUrlModalProps { - shortUrl: ShortUrl; + shortUrl: ShlinkShortUrl; isOpen: boolean; toggle: () => void; } diff --git a/shlink-web-component/src/short-urls/helpers/ExportShortUrlsBtn.tsx b/shlink-web-component/src/short-urls/helpers/ExportShortUrlsBtn.tsx index c3349719..0146ab72 100644 --- a/shlink-web-component/src/short-urls/helpers/ExportShortUrlsBtn.tsx +++ b/shlink-web-component/src/short-urls/helpers/ExportShortUrlsBtn.tsx @@ -4,7 +4,7 @@ import { useCallback } from 'react'; import type { ShlinkApiClient } from '../../api-contract'; import { ExportBtn } from '../../utils/components/ExportBtn'; import type { ReportExporter } from '../../utils/services/ReportExporter'; -import type { ShortUrl } from '../data'; +import type { ShlinkShortUrl } from '../data'; import { useShortUrlsQuery } from './hooks'; export interface ExportShortUrlsBtnProps { @@ -21,7 +21,7 @@ export const ExportShortUrlsBtn = ( const [loading,, startLoading, stopLoading] = useToggle(); const exportAllUrls = useCallback(async () => { const totalPages = amount / itemsPerPage; - const loadAllUrls = async (page = 1): Promise => { + const loadAllUrls = async (page = 1): Promise => { const { data } = await apiClientFactory().listShortUrls( { page: `${page}`, tags, searchTerm: search, startDate, endDate, orderBy, tagsMode, itemsPerPage }, ); diff --git a/shlink-web-component/src/short-urls/helpers/ShortUrlDetailLink.tsx b/shlink-web-component/src/short-urls/helpers/ShortUrlDetailLink.tsx index e39c9e57..d3b5c531 100644 --- a/shlink-web-component/src/short-urls/helpers/ShortUrlDetailLink.tsx +++ b/shlink-web-component/src/short-urls/helpers/ShortUrlDetailLink.tsx @@ -1,18 +1,18 @@ import type { FC } from 'react'; import { Link } from 'react-router-dom'; import { useRoutesPrefix } from '../../utils/routesPrefix'; -import type { ShortUrl } from '../data'; +import type { ShlinkShortUrl } from '../data'; import { urlEncodeShortCode } from './index'; export type LinkSuffix = 'visits' | 'edit'; export interface ShortUrlDetailLinkProps { - shortUrl?: ShortUrl | null; + shortUrl?: ShlinkShortUrl | null; suffix: LinkSuffix; asLink?: boolean; } -const buildUrl = (routePrefix: string, { shortCode, domain }: ShortUrl, suffix: LinkSuffix) => { +const buildUrl = (routePrefix: string, { shortCode, domain }: ShlinkShortUrl, suffix: LinkSuffix) => { const query = domain ? `?domain=${domain}` : ''; return `${routePrefix}/short-code/${urlEncodeShortCode(shortCode)}/${suffix}${query}`; }; diff --git a/shlink-web-component/src/short-urls/helpers/ShortUrlStatus.tsx b/shlink-web-component/src/short-urls/helpers/ShortUrlStatus.tsx index 2c3d6005..4790304c 100644 --- a/shlink-web-component/src/short-urls/helpers/ShortUrlStatus.tsx +++ b/shlink-web-component/src/short-urls/helpers/ShortUrlStatus.tsx @@ -6,10 +6,10 @@ import { isBefore } from 'date-fns'; import type { FC, ReactNode } from 'react'; import { UncontrolledTooltip } from 'reactstrap'; import { formatHumanFriendly, now, parseISO } from '../../utils/dates/helpers/date'; -import type { ShortUrl } from '../data'; +import type { ShlinkShortUrl } from '../data'; interface ShortUrlStatusProps { - shortUrl: ShortUrl; + shortUrl: ShlinkShortUrl; } interface StatusResult { @@ -18,7 +18,7 @@ interface StatusResult { description: ReactNode; } -const resolveShortUrlStatus = (shortUrl: ShortUrl): StatusResult => { +const resolveShortUrlStatus = (shortUrl: ShlinkShortUrl): StatusResult => { const { meta, visitsCount, visitsSummary } = shortUrl; const { maxVisits, validSince, validUntil } = meta; const totalVisits = visitsSummary?.total ?? visitsCount; diff --git a/shlink-web-component/src/short-urls/helpers/ShortUrlVisitsCount.tsx b/shlink-web-component/src/short-urls/helpers/ShortUrlVisitsCount.tsx index 5b9db463..0dd7ce2d 100644 --- a/shlink-web-component/src/short-urls/helpers/ShortUrlVisitsCount.tsx +++ b/shlink-web-component/src/short-urls/helpers/ShortUrlVisitsCount.tsx @@ -5,12 +5,12 @@ import classNames from 'classnames'; import { UncontrolledTooltip } from 'reactstrap'; import { formatHumanFriendly, parseISO } from '../../utils/dates/helpers/date'; import { prettify } from '../../utils/helpers/numbers'; -import type { ShortUrl } from '../data'; +import type { ShlinkShortUrl } from '../data'; import { ShortUrlDetailLink } from './ShortUrlDetailLink'; import './ShortUrlVisitsCount.scss'; interface ShortUrlVisitsCountProps { - shortUrl?: ShortUrl | null; + shortUrl?: ShlinkShortUrl | null; visitsCount: number; active?: boolean; asLink?: boolean; diff --git a/shlink-web-component/src/short-urls/helpers/ShortUrlsRow.tsx b/shlink-web-component/src/short-urls/helpers/ShortUrlsRow.tsx index ca654432..038b008f 100644 --- a/shlink-web-component/src/short-urls/helpers/ShortUrlsRow.tsx +++ b/shlink-web-component/src/short-urls/helpers/ShortUrlsRow.tsx @@ -6,7 +6,7 @@ import { Time } from '../../utils/dates/Time'; import type { TimeoutToggle } from '../../utils/helpers/hooks'; import type { ColorGenerator } from '../../utils/services/ColorGenerator'; import { useSetting } from '../../utils/settings'; -import type { ShortUrl } from '../data'; +import type { ShlinkShortUrl } from '../data'; import { useShortUrlsQuery } from './hooks'; import type { ShortUrlsRowMenuType } from './ShortUrlsRowMenu'; import { ShortUrlStatus } from './ShortUrlStatus'; @@ -16,7 +16,7 @@ import './ShortUrlsRow.scss'; interface ShortUrlsRowProps { onTagClick?: (tag: string) => void; - shortUrl: ShortUrl; + shortUrl: ShlinkShortUrl; } export type ShortUrlsRowType = FC; diff --git a/shlink-web-component/src/short-urls/helpers/ShortUrlsRowMenu.tsx b/shlink-web-component/src/short-urls/helpers/ShortUrlsRowMenu.tsx index 1bf30fa9..d18bc8db 100644 --- a/shlink-web-component/src/short-urls/helpers/ShortUrlsRowMenu.tsx +++ b/shlink-web-component/src/short-urls/helpers/ShortUrlsRowMenu.tsx @@ -8,11 +8,11 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { RowDropdownBtn, useToggle } from '@shlinkio/shlink-frontend-kit'; import type { FC } from 'react'; import { DropdownItem } from 'reactstrap'; -import type { ShortUrl, ShortUrlModalProps } from '../data'; +import type { ShlinkShortUrl, ShortUrlModalProps } from '../data'; import { ShortUrlDetailLink } from './ShortUrlDetailLink'; interface ShortUrlsRowMenuProps { - shortUrl: ShortUrl; + shortUrl: ShlinkShortUrl; } type ShortUrlModal = FC; diff --git a/shlink-web-component/src/short-urls/helpers/index.ts b/shlink-web-component/src/short-urls/helpers/index.ts index 97d332be..c1e7cbc1 100644 --- a/shlink-web-component/src/short-urls/helpers/index.ts +++ b/shlink-web-component/src/short-urls/helpers/index.ts @@ -2,9 +2,9 @@ import { isNil } from 'ramda'; import type { OptionalString } from '../../utils/helpers'; import type { ShortUrlCreationSettings } from '../../utils/settings'; import { DEFAULT_DOMAIN } from '../../visits/reducers/domainVisits'; -import type { ShortUrl, ShortUrlData } from '../data'; +import type { ShlinkShortUrl, ShortUrlData } from '../data'; -export const shortUrlMatches = (shortUrl: ShortUrl, shortCode: string, domain: OptionalString): boolean => { +export const shortUrlMatches = (shortUrl: ShlinkShortUrl, shortCode: string, domain: OptionalString): boolean => { if (isNil(domain)) { return shortUrl.shortCode === shortCode && !shortUrl.domain; } @@ -12,7 +12,7 @@ export const shortUrlMatches = (shortUrl: ShortUrl, shortCode: string, domain: O return shortUrl.shortCode === shortCode && shortUrl.domain === domain; }; -export const domainMatches = (shortUrl: ShortUrl, domain: string): boolean => { +export const domainMatches = (shortUrl: ShlinkShortUrl, domain: string): boolean => { if (!shortUrl.domain && domain === DEFAULT_DOMAIN) { return true; } @@ -20,7 +20,7 @@ export const domainMatches = (shortUrl: ShortUrl, domain: string): boolean => { return shortUrl.domain === domain; }; -export const shortUrlDataFromShortUrl = (shortUrl?: ShortUrl, settings?: ShortUrlCreationSettings): ShortUrlData => { +export const shortUrlDataFromShortUrl = (shortUrl?: ShlinkShortUrl, settings?: ShortUrlCreationSettings): ShortUrlData => { const validateUrl = settings?.validateUrls ?? false; if (!shortUrl) { @@ -37,7 +37,11 @@ export const shortUrlDataFromShortUrl = (shortUrl?: ShortUrl, settings?: ShortUr maxVisits: shortUrl.meta.maxVisits ?? undefined, crawlable: shortUrl.crawlable, forwardQuery: shortUrl.forwardQuery, - deviceLongUrls: shortUrl.deviceLongUrls, + deviceLongUrls: shortUrl.deviceLongUrls && { + android: shortUrl.deviceLongUrls.android ?? undefined, + ios: shortUrl.deviceLongUrls.ios ?? undefined, + desktop: shortUrl.deviceLongUrls.desktop ?? undefined, + }, validateUrl, }; }; diff --git a/shlink-web-component/src/short-urls/reducers/shortUrlCreation.ts b/shlink-web-component/src/short-urls/reducers/shortUrlCreation.ts index 2fc62b9c..3fa49b35 100644 --- a/shlink-web-component/src/short-urls/reducers/shortUrlCreation.ts +++ b/shlink-web-component/src/short-urls/reducers/shortUrlCreation.ts @@ -3,7 +3,7 @@ import { createSlice } from '@reduxjs/toolkit'; import type { ProblemDetailsError, ShlinkApiClient } from '../../api-contract'; import { parseApiError } from '../../api-contract/utils'; import { createAsyncThunk } from '../../utils/redux'; -import type { ShortUrl, ShortUrlData } from '../data'; +import type { ShlinkShortUrl, ShortUrlData } from '../data'; const REDUCER_PREFIX = 'shlink/shortUrlCreation'; @@ -21,13 +21,13 @@ export type ShortUrlCreation = { error: true; errorData?: ProblemDetailsError; } | { - result: ShortUrl; + result: ShlinkShortUrl; saving: false; saved: true; error: false; }; -export type CreateShortUrlAction = PayloadAction; +export type CreateShortUrlAction = PayloadAction; const initialState: ShortUrlCreation = { saving: false, @@ -37,7 +37,7 @@ const initialState: ShortUrlCreation = { export const createShortUrl = (apiClientFactory: () => ShlinkApiClient) => createAsyncThunk( `${REDUCER_PREFIX}/createShortUrl`, - (data: ShortUrlData): Promise => apiClientFactory().createShortUrl(data), + (data: ShortUrlData): Promise => apiClientFactory().createShortUrl(data), ); export const shortUrlCreationReducerCreator = (createShortUrlThunk: ReturnType) => { diff --git a/shlink-web-component/src/short-urls/reducers/shortUrlDeletion.ts b/shlink-web-component/src/short-urls/reducers/shortUrlDeletion.ts index 2b9f82b3..13c67d10 100644 --- a/shlink-web-component/src/short-urls/reducers/shortUrlDeletion.ts +++ b/shlink-web-component/src/short-urls/reducers/shortUrlDeletion.ts @@ -2,7 +2,7 @@ import { createAction, createSlice } from '@reduxjs/toolkit'; import type { ProblemDetailsError, ShlinkApiClient } from '../../api-contract'; import { parseApiError } from '../../api-contract/utils'; import { createAsyncThunk } from '../../utils/redux'; -import type { ShortUrl, ShortUrlIdentifier } from '../data'; +import type { ShlinkShortUrl, ShortUrlIdentifier } from '../data'; const REDUCER_PREFIX = 'shlink/shortUrlDeletion'; @@ -29,7 +29,7 @@ export const deleteShortUrl = (apiClientFactory: () => ShlinkApiClient) => creat }, ); -export const shortUrlDeleted = createAction(`${REDUCER_PREFIX}/shortUrlDeleted`); +export const shortUrlDeleted = createAction(`${REDUCER_PREFIX}/shortUrlDeleted`); export const shortUrlDeletionReducerCreator = (deleteShortUrlThunk: ReturnType) => { const { actions, reducer } = createSlice({ diff --git a/shlink-web-component/src/short-urls/reducers/shortUrlDetail.ts b/shlink-web-component/src/short-urls/reducers/shortUrlDetail.ts index 9791974f..7a035bfc 100644 --- a/shlink-web-component/src/short-urls/reducers/shortUrlDetail.ts +++ b/shlink-web-component/src/short-urls/reducers/shortUrlDetail.ts @@ -3,19 +3,19 @@ import { createSlice } from '@reduxjs/toolkit'; import type { ProblemDetailsError, ShlinkApiClient } from '../../api-contract'; import { parseApiError } from '../../api-contract/utils'; import { createAsyncThunk } from '../../utils/redux'; -import type { ShortUrl, ShortUrlIdentifier } from '../data'; +import type { ShlinkShortUrl, ShortUrlIdentifier } from '../data'; import { shortUrlMatches } from '../helpers'; const REDUCER_PREFIX = 'shlink/shortUrlDetail'; export interface ShortUrlDetail { - shortUrl?: ShortUrl; + shortUrl?: ShlinkShortUrl; loading: boolean; error: boolean; errorData?: ProblemDetailsError; } -export type ShortUrlDetailAction = PayloadAction; +export type ShortUrlDetailAction = PayloadAction; const initialState: ShortUrlDetail = { loading: false, @@ -25,7 +25,7 @@ const initialState: ShortUrlDetail = { export const shortUrlDetailReducerCreator = (apiClientFactory: () => ShlinkApiClient) => { const getShortUrlDetail = createAsyncThunk( `${REDUCER_PREFIX}/getShortUrlDetail`, - async ({ shortCode, domain }: ShortUrlIdentifier, { getState }): Promise => { + async ({ shortCode, domain }: ShortUrlIdentifier, { getState }): Promise => { const { shortUrlsList } = getState(); const alreadyLoaded = shortUrlsList?.shortUrls?.data.find((url) => shortUrlMatches(url, shortCode, domain)); diff --git a/shlink-web-component/src/short-urls/reducers/shortUrlEdition.ts b/shlink-web-component/src/short-urls/reducers/shortUrlEdition.ts index 93a0987e..3a6efa81 100644 --- a/shlink-web-component/src/short-urls/reducers/shortUrlEdition.ts +++ b/shlink-web-component/src/short-urls/reducers/shortUrlEdition.ts @@ -1,14 +1,13 @@ -import type { PayloadAction } from '@reduxjs/toolkit'; import { createSlice } from '@reduxjs/toolkit'; -import type { ProblemDetailsError, ShlinkApiClient } from '../../api-contract'; +import type { ProblemDetailsError, ShlinkApiClient, ShlinkShortUrlData } from '../../api-contract'; import { parseApiError } from '../../api-contract/utils'; import { createAsyncThunk } from '../../utils/redux'; -import type { EditShortUrlData, ShortUrl, ShortUrlIdentifier } from '../data'; +import type { ShlinkShortUrl, ShortUrlIdentifier } from '../data'; const REDUCER_PREFIX = 'shlink/shortUrlEdition'; export interface ShortUrlEdition { - shortUrl?: ShortUrl; + shortUrl?: ShlinkShortUrl; saving: boolean; saved: boolean; error: boolean; @@ -16,11 +15,9 @@ export interface ShortUrlEdition { } export interface EditShortUrl extends ShortUrlIdentifier { - data: EditShortUrlData; + data: ShlinkShortUrlData; } -export type ShortUrlEditedAction = PayloadAction; - const initialState: ShortUrlEdition = { saving: false, saved: false, @@ -29,7 +26,7 @@ const initialState: ShortUrlEdition = { export const editShortUrl = (apiClientFactory: () => ShlinkApiClient) => createAsyncThunk( `${REDUCER_PREFIX}/editShortUrl`, - ({ shortCode, domain, data }: EditShortUrl): Promise => + ({ shortCode, domain, data }: EditShortUrl): Promise => apiClientFactory().updateShortUrl(shortCode, domain, data as any) // TODO parse dates , ); diff --git a/shlink-web-component/src/short-urls/reducers/shortUrlsList.ts b/shlink-web-component/src/short-urls/reducers/shortUrlsList.ts index 3bbfb5c8..61b026d4 100644 --- a/shlink-web-component/src/short-urls/reducers/shortUrlsList.ts +++ b/shlink-web-component/src/short-urls/reducers/shortUrlsList.ts @@ -3,7 +3,7 @@ import { assocPath, last, pipe, reject } from 'ramda'; import type { ShlinkApiClient, ShlinkShortUrlsListParams, ShlinkShortUrlsResponse } from '../../api-contract'; import { createAsyncThunk } from '../../utils/redux'; import { createNewVisits } from '../../visits/reducers/visitCreation'; -import type { ShortUrl } from '../data'; +import type { ShlinkShortUrl } from '../data'; import { shortUrlMatches } from '../helpers'; import type { createShortUrl } from './shortUrlCreation'; import { shortUrlDeleted } from './shortUrlDeletion'; @@ -82,7 +82,7 @@ export const shortUrlsListReducerCreator = ( pipe( (state, { payload }) => (!state.shortUrls ? state : assocPath( ['shortUrls', 'data'], - reject((shortUrl) => + reject((shortUrl) => shortUrlMatches(shortUrl, payload.shortCode, payload.domain), state.shortUrls.data), state, )), diff --git a/shlink-web-component/src/visits/VisitsHeader.tsx b/shlink-web-component/src/visits/VisitsHeader.tsx index 56584e83..b23007ff 100644 --- a/shlink-web-component/src/visits/VisitsHeader.tsx +++ b/shlink-web-component/src/visits/VisitsHeader.tsx @@ -2,7 +2,7 @@ import { faArrowLeft } from '@fortawesome/free-solid-svg-icons'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import type { FC, PropsWithChildren, ReactNode } from 'react'; import { Button, Card } from 'reactstrap'; -import type { ShortUrl } from '../short-urls/data'; +import type { ShlinkShortUrl } from '../short-urls/data'; import { ShortUrlVisitsCount } from '../short-urls/helpers/ShortUrlVisitsCount'; import type { Visit } from './types'; @@ -10,7 +10,7 @@ type VisitsHeaderProps = PropsWithChildren<{ visits: Visit[]; goBack: () => void; title: ReactNode; - shortUrl?: ShortUrl; + shortUrl?: ShlinkShortUrl; }>; export const VisitsHeader: FC = ({ visits, goBack, shortUrl, children, title }) => ( diff --git a/shlink-web-component/src/visits/types/index.ts b/shlink-web-component/src/visits/types/index.ts index 5d3635dc..619f66b2 100644 --- a/shlink-web-component/src/visits/types/index.ts +++ b/shlink-web-component/src/visits/types/index.ts @@ -1,4 +1,4 @@ -import type { ShortUrl } from '../../short-urls/data'; +import type { ShlinkShortUrl } from '../../short-urls/data'; import type { DateRange } from '../../utils/dates/helpers/dateIntervals'; export type OrphanVisitType = 'base_url' | 'invalid_short_url' | 'regular_404'; @@ -52,7 +52,7 @@ export interface NormalizedOrphanVisit extends NormalizedRegularVisit { export type NormalizedVisit = NormalizedRegularVisit | NormalizedOrphanVisit; export interface CreateVisit { - shortUrl?: ShortUrl; + shortUrl?: ShlinkShortUrl; visit: Visit; } diff --git a/shlink-web-component/test/short-urls/helpers/DeleteShortUrlModal.test.tsx b/shlink-web-component/test/short-urls/helpers/DeleteShortUrlModal.test.tsx index 336254c9..e725dd27 100644 --- a/shlink-web-component/test/short-urls/helpers/DeleteShortUrlModal.test.tsx +++ b/shlink-web-component/test/short-urls/helpers/DeleteShortUrlModal.test.tsx @@ -2,14 +2,14 @@ import { screen, waitFor } from '@testing-library/react'; import { fromPartial } from '@total-typescript/shoehorn'; import type { InvalidShortUrlDeletion } from '../../../src/api-contract'; import { ErrorTypeV2, ErrorTypeV3 } from '../../../src/api-contract'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { DeleteShortUrlModal } from '../../../src/short-urls/helpers/DeleteShortUrlModal'; import type { ShortUrlDeletion } from '../../../src/short-urls/reducers/shortUrlDeletion'; import { renderWithEvents } from '../../__helpers__/setUpTest'; import { TestModalWrapper } from '../../__helpers__/TestModalWrapper'; describe('', () => { - const shortUrl = fromPartial({ + const shortUrl = fromPartial({ tags: [], shortCode: 'abc123', longUrl: 'https://long-domain.com/foo/bar', diff --git a/shlink-web-component/test/short-urls/helpers/ExportShortUrlsBtn.test.tsx b/shlink-web-component/test/short-urls/helpers/ExportShortUrlsBtn.test.tsx index cf7956d0..af7c0660 100644 --- a/shlink-web-component/test/short-urls/helpers/ExportShortUrlsBtn.test.tsx +++ b/shlink-web-component/test/short-urls/helpers/ExportShortUrlsBtn.test.tsx @@ -1,7 +1,7 @@ import { screen } from '@testing-library/react'; import { fromPartial } from '@total-typescript/shoehorn'; import { MemoryRouter } from 'react-router-dom'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { ExportShortUrlsBtn as createExportShortUrlsBtn } from '../../../src/short-urls/helpers/ExportShortUrlsBtn'; import type { ReportExporter } from '../../../src/utils/services/ReportExporter'; import { renderWithEvents } from '../../__helpers__/setUpTest'; @@ -46,7 +46,7 @@ describe('', () => { it('maps short URLs for exporting', async () => { listShortUrls.mockResolvedValue({ - data: [fromPartial({ + data: [fromPartial({ shortUrl: 'https://s.test/short-code', tags: [], })], diff --git a/shlink-web-component/test/short-urls/helpers/ShortUrlDetailLink.test.tsx b/shlink-web-component/test/short-urls/helpers/ShortUrlDetailLink.test.tsx index bf4fac57..0646c92b 100644 --- a/shlink-web-component/test/short-urls/helpers/ShortUrlDetailLink.test.tsx +++ b/shlink-web-component/test/short-urls/helpers/ShortUrlDetailLink.test.tsx @@ -1,7 +1,7 @@ import { render, screen } from '@testing-library/react'; import { fromPartial } from '@total-typescript/shoehorn'; import { MemoryRouter } from 'react-router-dom'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import type { LinkSuffix } from '../../../src/short-urls/helpers/ShortUrlDetailLink'; import { ShortUrlDetailLink } from '../../../src/short-urls/helpers/ShortUrlDetailLink'; import { RoutesPrefixProvider } from '../../../src/utils/routesPrefix'; @@ -12,8 +12,8 @@ describe('', () => { [false, null], [true, null], [true, undefined], - [false, fromPartial({})], - [false, fromPartial({})], + [false, fromPartial({})], + [false, fromPartial({})], ])('only renders a plain span when either server or short URL are not set', (asLink, shortUrl) => { render( @@ -28,25 +28,25 @@ describe('', () => { it.each([ [ '/server/1', - fromPartial({ shortCode: 'abc123' }), + fromPartial({ shortCode: 'abc123' }), 'visits' as LinkSuffix, '/server/1/short-code/abc123/visits', ], [ '/foobar', - fromPartial({ shortCode: 'def456', domain: 'example.com' }), + fromPartial({ shortCode: 'def456', domain: 'example.com' }), 'visits' as LinkSuffix, '/foobar/short-code/def456/visits?domain=example.com', ], [ '/server/1', - fromPartial({ shortCode: 'abc123' }), + fromPartial({ shortCode: 'abc123' }), 'edit' as LinkSuffix, '/server/1/short-code/abc123/edit', ], [ '/server/3', - fromPartial({ shortCode: 'def456', domain: 'example.com' }), + fromPartial({ shortCode: 'def456', domain: 'example.com' }), 'edit' as LinkSuffix, '/server/3/short-code/def456/edit?domain=example.com', ], diff --git a/shlink-web-component/test/short-urls/helpers/ShortUrlStatus.test.tsx b/shlink-web-component/test/short-urls/helpers/ShortUrlStatus.test.tsx index b87d2446..e68311fb 100644 --- a/shlink-web-component/test/short-urls/helpers/ShortUrlStatus.test.tsx +++ b/shlink-web-component/test/short-urls/helpers/ShortUrlStatus.test.tsx @@ -2,41 +2,41 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { fromPartial } from '@total-typescript/shoehorn'; import type { ShlinkVisitsSummary } from '../../../src/api-contract'; -import type { ShortUrl, ShortUrlMeta } from '../../../src/short-urls/data'; +import type { ShlinkShortUrlMeta, ShlinkShortUrl } from '../../../src/short-urls/data'; import { ShortUrlStatus } from '../../../src/short-urls/helpers/ShortUrlStatus'; describe('', () => { - const setUp = (shortUrl: ShortUrl) => ({ + const setUp = (shortUrl: ShlinkShortUrl) => ({ user: userEvent.setup(), ...render(), }); it.each([ [ - fromPartial({ validSince: '2099-01-01T10:30:15' }), + fromPartial({ validSince: '2099-01-01T10:30:15' }), {}, 'This short URL will start working on 2099-01-01 10:30.', ], [ - fromPartial({ validUntil: '2020-01-01T10:30:15' }), + fromPartial({ validUntil: '2020-01-01T10:30:15' }), {}, 'This short URL cannot be visited since 2020-01-01 10:30.', ], [ - fromPartial({ maxVisits: 10 }), + fromPartial({ maxVisits: 10 }), fromPartial({ total: 10 }), 'This short URL cannot be currently visited because it has reached the maximum amount of 10 visits.', ], [ - fromPartial({ maxVisits: 1 }), + fromPartial({ maxVisits: 1 }), fromPartial({ total: 1 }), 'This short URL cannot be currently visited because it has reached the maximum amount of 1 visit.', ], [{}, {}, 'This short URL can be visited normally.'], - [fromPartial({ validUntil: '2099-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'], - [fromPartial({ validSince: '2020-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'], + [fromPartial({ validUntil: '2099-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'], + [fromPartial({ validSince: '2020-01-01T10:30:15' }), {}, 'This short URL can be visited normally.'], [ - fromPartial({ maxVisits: 10 }), + fromPartial({ maxVisits: 10 }), fromPartial({ total: 1 }), 'This short URL can be visited normally.', ], diff --git a/shlink-web-component/test/short-urls/helpers/ShortUrlVisitsCount.test.tsx b/shlink-web-component/test/short-urls/helpers/ShortUrlVisitsCount.test.tsx index b810fa6e..cb8e7304 100644 --- a/shlink-web-component/test/short-urls/helpers/ShortUrlVisitsCount.test.tsx +++ b/shlink-web-component/test/short-urls/helpers/ShortUrlVisitsCount.test.tsx @@ -1,11 +1,11 @@ import { render, screen, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { fromPartial } from '@total-typescript/shoehorn'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { ShortUrlVisitsCount } from '../../../src/short-urls/helpers/ShortUrlVisitsCount'; describe('', () => { - const setUp = (visitsCount: number, shortUrl: ShortUrl) => ({ + const setUp = (visitsCount: number, shortUrl: ShlinkShortUrl) => ({ user: userEvent.setup(), ...render( , diff --git a/shlink-web-component/test/short-urls/helpers/ShortUrlsRow.test.tsx b/shlink-web-component/test/short-urls/helpers/ShortUrlsRow.test.tsx index 080082fa..9a306a55 100644 --- a/shlink-web-component/test/short-urls/helpers/ShortUrlsRow.test.tsx +++ b/shlink-web-component/test/short-urls/helpers/ShortUrlsRow.test.tsx @@ -4,7 +4,7 @@ import { addDays, formatISO, subDays } from 'date-fns'; import { last } from 'ramda'; import { MemoryRouter, useLocation } from 'react-router-dom'; import type { Settings } from '../../../src'; -import type { ShortUrl, ShortUrlMeta } from '../../../src/short-urls/data'; +import type { ShlinkShortUrlMeta, ShlinkShortUrl } from '../../../src/short-urls/data'; import { ShortUrlsRow as createShortUrlsRow } from '../../../src/short-urls/helpers/ShortUrlsRow'; import { now, parseDate } from '../../../src/utils/dates/helpers/date'; import type { TimeoutToggle } from '../../../src/utils/helpers/hooks'; @@ -15,7 +15,7 @@ import { colorGeneratorMock } from '../../utils/services/__mocks__/ColorGenerato interface SetUpOptions { title?: string | null; tags?: string[]; - meta?: ShortUrlMeta; + meta?: ShlinkShortUrlMeta; settings?: Partial; } @@ -27,7 +27,7 @@ vi.mock('react-router-dom', async () => ({ describe('', () => { const timeoutToggle = vi.fn(() => true); const useTimeoutToggle = vi.fn(() => [false, timeoutToggle]) as TimeoutToggle; - const shortUrl: ShortUrl = { + const shortUrl: ShlinkShortUrl = { shortCode: 'abc123', shortUrl: 'https://s.test/abc123', longUrl: 'https://foo.com/bar', diff --git a/shlink-web-component/test/short-urls/helpers/ShortUrlsRowMenu.test.tsx b/shlink-web-component/test/short-urls/helpers/ShortUrlsRowMenu.test.tsx index 84b60a55..e7624d31 100644 --- a/shlink-web-component/test/short-urls/helpers/ShortUrlsRowMenu.test.tsx +++ b/shlink-web-component/test/short-urls/helpers/ShortUrlsRowMenu.test.tsx @@ -1,13 +1,13 @@ import { screen } from '@testing-library/react'; import { fromPartial } from '@total-typescript/shoehorn'; import { MemoryRouter } from 'react-router-dom'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { ShortUrlsRowMenu as createShortUrlsRowMenu } from '../../../src/short-urls/helpers/ShortUrlsRowMenu'; import { renderWithEvents } from '../../__helpers__/setUpTest'; describe('', () => { const ShortUrlsRowMenu = createShortUrlsRowMenu(() => DeleteShortUrlModal, () => QrCodeModal); - const shortUrl = fromPartial({ + const shortUrl = fromPartial({ shortCode: 'abc123', shortUrl: 'https://s.test/abc123', }); diff --git a/shlink-web-component/test/short-urls/helpers/index.test.ts b/shlink-web-component/test/short-urls/helpers/index.test.ts index 6f252950..7c5fe988 100644 --- a/shlink-web-component/test/short-urls/helpers/index.test.ts +++ b/shlink-web-component/test/short-urls/helpers/index.test.ts @@ -1,5 +1,5 @@ import { fromPartial } from '@total-typescript/shoehorn'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { shortUrlDataFromShortUrl, urlDecodeShortCode, urlEncodeShortCode } from '../../../src/short-urls/helpers'; describe('helpers', () => { @@ -8,7 +8,7 @@ describe('helpers', () => { [undefined, { validateUrls: true }, { longUrl: '', validateUrl: true }], [undefined, undefined, { longUrl: '', validateUrl: false }], [ - fromPartial({ meta: {} }), + fromPartial({ meta: {} }), { validateUrls: false }, { longUrl: undefined, diff --git a/shlink-web-component/test/short-urls/reducers/shortUrlCreation.test.ts b/shlink-web-component/test/short-urls/reducers/shortUrlCreation.test.ts index 460f80eb..3d4929c6 100644 --- a/shlink-web-component/test/short-urls/reducers/shortUrlCreation.test.ts +++ b/shlink-web-component/test/short-urls/reducers/shortUrlCreation.test.ts @@ -1,13 +1,13 @@ import { fromPartial } from '@total-typescript/shoehorn'; import type { ShlinkApiClient } from '../../../src/api-contract'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { createShortUrl as createShortUrlCreator, shortUrlCreationReducerCreator, } from '../../../src/short-urls/reducers/shortUrlCreation'; describe('shortUrlCreationReducer', () => { - const shortUrl = fromPartial({}); + const shortUrl = fromPartial({}); const createShortUrlCall = vi.fn(); const buildShlinkApiClient = () => fromPartial({ createShortUrl: createShortUrlCall }); const createShortUrl = createShortUrlCreator(buildShlinkApiClient); diff --git a/shlink-web-component/test/short-urls/reducers/shortUrlDetail.test.ts b/shlink-web-component/test/short-urls/reducers/shortUrlDetail.test.ts index 7d870f4b..460450b3 100644 --- a/shlink-web-component/test/short-urls/reducers/shortUrlDetail.test.ts +++ b/shlink-web-component/test/short-urls/reducers/shortUrlDetail.test.ts @@ -1,7 +1,7 @@ import { fromPartial } from '@total-typescript/shoehorn'; import type { ShlinkApiClient } from '../../../src/api-contract'; import type { RootState } from '../../../src/container/store'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { shortUrlDetailReducerCreator } from '../../../src/short-urls/reducers/shortUrlDetail'; import type { ShortUrlsList } from '../../../src/short-urls/reducers/shortUrlsList'; @@ -25,7 +25,7 @@ describe('shortUrlDetailReducer', () => { }); it('return short URL on GET_SHORT_URL_DETAIL', () => { - const actionShortUrl = fromPartial({ longUrl: 'foo', shortCode: 'bar' }); + const actionShortUrl = fromPartial({ longUrl: 'foo', shortCode: 'bar' }); const state = reducer( { loading: true, error: false }, getShortUrlDetail.fulfilled(actionShortUrl, '', { shortCode: '' }), @@ -58,7 +58,7 @@ describe('shortUrlDetailReducer', () => { }), ], ])('performs API call when short URL is not found in local state', async (shortUrlsList?: ShortUrlsList) => { - const resolvedShortUrl = fromPartial({ longUrl: 'foo', shortCode: 'abc123' }); + const resolvedShortUrl = fromPartial({ longUrl: 'foo', shortCode: 'abc123' }); getShortUrlCall.mockResolvedValue(resolvedShortUrl); await getShortUrlDetail({ shortCode: 'abc123', domain: '' })(dispatchMock, buildGetState(shortUrlsList), {}); @@ -69,8 +69,8 @@ describe('shortUrlDetailReducer', () => { }); it('avoids API calls when short URL is found in local state', async () => { - const foundShortUrl = fromPartial({ longUrl: 'foo', shortCode: 'abc123' }); - getShortUrlCall.mockResolvedValue(fromPartial({})); + const foundShortUrl = fromPartial({ longUrl: 'foo', shortCode: 'abc123' }); + getShortUrlCall.mockResolvedValue(fromPartial({})); await getShortUrlDetail(foundShortUrl)( dispatchMock, diff --git a/shlink-web-component/test/short-urls/reducers/shortUrlEdition.test.ts b/shlink-web-component/test/short-urls/reducers/shortUrlEdition.test.ts index 9a0b22c2..4e36eb99 100644 --- a/shlink-web-component/test/short-urls/reducers/shortUrlEdition.test.ts +++ b/shlink-web-component/test/short-urls/reducers/shortUrlEdition.test.ts @@ -1,5 +1,5 @@ import { fromPartial } from '@total-typescript/shoehorn'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { editShortUrl as editShortUrlCreator, shortUrlEditionReducerCreator, @@ -8,7 +8,7 @@ import { describe('shortUrlEditionReducer', () => { const longUrl = 'https://shlink.io'; const shortCode = 'abc123'; - const shortUrl = fromPartial({ longUrl, shortCode }); + const shortUrl = fromPartial({ longUrl, shortCode }); const updateShortUrl = vi.fn().mockResolvedValue(shortUrl); const buildShlinkApiClient = vi.fn().mockReturnValue({ updateShortUrl }); const editShortUrl = editShortUrlCreator(buildShlinkApiClient); diff --git a/shlink-web-component/test/short-urls/reducers/shortUrlsList.test.ts b/shlink-web-component/test/short-urls/reducers/shortUrlsList.test.ts index a8bb7108..2925d511 100644 --- a/shlink-web-component/test/short-urls/reducers/shortUrlsList.test.ts +++ b/shlink-web-component/test/short-urls/reducers/shortUrlsList.test.ts @@ -1,6 +1,6 @@ import { fromPartial } from '@total-typescript/shoehorn'; import type { ShlinkApiClient, ShlinkShortUrlsResponse } from '../../../src/api-contract'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { createShortUrl as createShortUrlCreator } from '../../../src/short-urls/reducers/shortUrlCreation'; import { shortUrlDeleted } from '../../../src/short-urls/reducers/shortUrlDeletion'; import { editShortUrl as editShortUrlCreator } from '../../../src/short-urls/reducers/shortUrlEdition'; @@ -102,36 +102,36 @@ describe('shortUrlsListReducer', () => { it.each([ [ [ - fromPartial({ shortCode }), - fromPartial({ shortCode, domain: 'example.com' }), - fromPartial({ shortCode: 'foo' }), + fromPartial({ shortCode }), + fromPartial({ shortCode, domain: 'example.com' }), + fromPartial({ shortCode: 'foo' }), ], [{ shortCode: 'newOne' }, { shortCode }, { shortCode, domain: 'example.com' }, { shortCode: 'foo' }], ], [ [ - fromPartial({ shortCode }), - fromPartial({ shortCode: 'code' }), - fromPartial({ shortCode: 'foo' }), - fromPartial({ shortCode: 'bar' }), - fromPartial({ shortCode: 'baz' }), + fromPartial({ shortCode }), + fromPartial({ shortCode: 'code' }), + fromPartial({ shortCode: 'foo' }), + fromPartial({ shortCode: 'bar' }), + fromPartial({ shortCode: 'baz' }), ], [{ shortCode: 'newOne' }, { shortCode }, { shortCode: 'code' }, { shortCode: 'foo' }, { shortCode: 'bar' }], ], [ [ - fromPartial({ shortCode }), - fromPartial({ shortCode: 'code' }), - fromPartial({ shortCode: 'foo' }), - fromPartial({ shortCode: 'bar' }), - fromPartial({ shortCode: 'baz1' }), - fromPartial({ shortCode: 'baz2' }), - fromPartial({ shortCode: 'baz3' }), + fromPartial({ shortCode }), + fromPartial({ shortCode: 'code' }), + fromPartial({ shortCode: 'foo' }), + fromPartial({ shortCode: 'bar' }), + fromPartial({ shortCode: 'baz1' }), + fromPartial({ shortCode: 'baz2' }), + fromPartial({ shortCode: 'baz3' }), ], [{ shortCode: 'newOne' }, { shortCode }, { shortCode: 'code' }, { shortCode: 'foo' }, { shortCode: 'bar' }], ], ])('prepends new short URL and increases total on CREATE_SHORT_URL', (data, expectedData) => { - const newShortUrl = fromPartial({ shortCode: 'newOne' }); + const newShortUrl = fromPartial({ shortCode: 'newOne' }); const state = { shortUrls: fromPartial({ data, @@ -152,15 +152,15 @@ describe('shortUrlsListReducer', () => { }); it.each([ - ((): [ShortUrl, ShortUrl[], ShortUrl[]] => { - const editedShortUrl = fromPartial({ shortCode: 'notMatching' }); - const list: ShortUrl[] = [fromPartial({ shortCode: 'foo' }), fromPartial({ shortCode: 'bar' })]; + ((): [ShlinkShortUrl, ShlinkShortUrl[], ShlinkShortUrl[]] => { + const editedShortUrl = fromPartial({ shortCode: 'notMatching' }); + const list: ShlinkShortUrl[] = [fromPartial({ shortCode: 'foo' }), fromPartial({ shortCode: 'bar' })]; return [editedShortUrl, list, list]; })(), - ((): [ShortUrl, ShortUrl[], ShortUrl[]] => { - const editedShortUrl = fromPartial({ shortCode: 'matching', longUrl: 'new_one' }); - const list: ShortUrl[] = [ + ((): [ShlinkShortUrl, ShlinkShortUrl[], ShlinkShortUrl[]] => { + const editedShortUrl = fromPartial({ shortCode: 'matching', longUrl: 'new_one' }); + const list: ShlinkShortUrl[] = [ fromPartial({ shortCode: 'matching', longUrl: 'old_one' }), fromPartial({ shortCode: 'bar' }), ]; diff --git a/shlink-web-component/test/tags/reducers/tagsList.test.ts b/shlink-web-component/test/tags/reducers/tagsList.test.ts index f7d45a76..c36b9720 100644 --- a/shlink-web-component/test/tags/reducers/tagsList.test.ts +++ b/shlink-web-component/test/tags/reducers/tagsList.test.ts @@ -1,6 +1,6 @@ import { fromPartial } from '@total-typescript/shoehorn'; import type { RootState } from '../../../src/container/store'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { createShortUrl as createShortUrlCreator } from '../../../src/short-urls/reducers/shortUrlCreation'; import { tagDeleted } from '../../../src/tags/reducers/tagDelete'; import { tagEdited } from '../../../src/tags/reducers/tagEdit'; @@ -112,7 +112,7 @@ describe('tagsListReducer', () => { [['new', 'tag'], ['foo', 'bar', 'baz', 'foo2', 'fo', 'new', 'tag']], ])('appends new short URL\'s tags to the list of tags on CREATE_SHORT_URL', (shortUrlTags, expectedTags) => { const tags = ['foo', 'bar', 'baz', 'foo2', 'fo']; - const payload = fromPartial({ tags: shortUrlTags }); + const payload = fromPartial({ tags: shortUrlTags }); expect(reducer(state({ tags }), createShortUrl.fulfilled(payload, '', fromPartial({})))).toEqual({ tags: expectedTags, diff --git a/shlink-web-component/test/visits/reducers/domainVisits.test.ts b/shlink-web-component/test/visits/reducers/domainVisits.test.ts index 7ed47994..5ff7d1bd 100644 --- a/shlink-web-component/test/visits/reducers/domainVisits.test.ts +++ b/shlink-web-component/test/visits/reducers/domainVisits.test.ts @@ -2,7 +2,7 @@ import { fromPartial } from '@total-typescript/shoehorn'; import { addDays, formatISO, subDays } from 'date-fns'; import type { ShlinkApiClient, ShlinkVisits } from '../../../src/api-contract'; import type { RootState } from '../../../src/container/store'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { formatIsoDate } from '../../../src/utils/dates/helpers/date'; import type { DateInterval } from '../../../src/utils/dates/helpers/dateIntervals'; import { rangeOf } from '../../../src/utils/helpers'; @@ -124,7 +124,7 @@ describe('domainVisitsReducer', () => { visitsMocks.length, ], ])('prepends new visits on CREATE_VISIT', (state, shortUrlDomain, expectedVisits) => { - const shortUrl = fromPartial({ domain: shortUrlDomain }); + const shortUrl = fromPartial({ domain: shortUrlDomain }); const { visits } = reducer(buildState({ ...state, visits: visitsMocks }), createNewVisits([ fromPartial({ shortUrl, visit: { date: formatIsoDate(now) ?? undefined } }), ])); diff --git a/shlink-web-component/test/visits/reducers/visitCreation.test.ts b/shlink-web-component/test/visits/reducers/visitCreation.test.ts index 30dbf7e7..607ab8af 100644 --- a/shlink-web-component/test/visits/reducers/visitCreation.test.ts +++ b/shlink-web-component/test/visits/reducers/visitCreation.test.ts @@ -1,11 +1,11 @@ import { fromPartial } from '@total-typescript/shoehorn'; -import type { ShortUrl } from '../../../src/short-urls/data'; +import type { ShlinkShortUrl } from '../../../src/short-urls/data'; import { createNewVisits } from '../../../src/visits/reducers/visitCreation'; import type { Visit } from '../../../src/visits/types'; describe('visitCreationReducer', () => { describe('createNewVisits', () => { - const shortUrl = fromPartial({}); + const shortUrl = fromPartial({}); const visit = fromPartial({}); it('just returns the action with proper type', () => { diff --git a/src/api/services/ShlinkApiClient.ts b/src/api/services/ShlinkApiClient.ts index 89361fff..40e4f9d0 100644 --- a/src/api/services/ShlinkApiClient.ts +++ b/src/api/services/ShlinkApiClient.ts @@ -16,13 +16,14 @@ import type { ShlinkTagsStatsResponse, ShlinkVisits, ShlinkVisitsOverview, - ShlinkVisitsParams } from '@shlinkio/shlink-web-component/api-contract'; + ShlinkVisitsParams, +} from '@shlinkio/shlink-web-component/api-contract'; import { ErrorTypeV2, ErrorTypeV3, } from '@shlinkio/shlink-web-component/api-contract'; import { isEmpty, isNil, reject } from 'ramda'; -import type { ShortUrl, ShortUrlData } from '../../../shlink-web-component/src/short-urls/data'; +import type { ShlinkShortUrl, ShortUrlData } from '../../../shlink-web-component/src/short-urls/data'; import type { HttpClient } from '../../common/services/HttpClient'; import { replaceAuthorityFromUri } from '../../utils/helpers/uri'; import type { OptionalString } from '../../utils/utils'; @@ -71,9 +72,9 @@ export class ShlinkApiClient implements BaseShlinkApiClient { { url: '/short-urls', query: normalizeListParams(params) }, ).then(({ shortUrls }) => shortUrls); - public readonly createShortUrl = async (options: ShortUrlData): Promise => { + public readonly createShortUrl = async (options: ShortUrlData): Promise => { const body = reject((value) => isEmpty(value) || isNil(value), options as any); - return this.performRequest({ url: '/short-urls', method: 'POST', body }); + return this.performRequest({ url: '/short-urls', method: 'POST', body }); }; public readonly getShortUrlVisits = async (shortCode: string, query?: ShlinkVisitsParams): Promise => @@ -95,8 +96,8 @@ export class ShlinkApiClient implements BaseShlinkApiClient { public readonly getVisitsOverview = async (): Promise => this.performRequest<{ visits: ShlinkVisitsOverview }>({ url: '/visits' }).then(({ visits }) => visits); - public readonly getShortUrl = async (shortCode: string, domain?: OptionalString): Promise => - this.performRequest({ url: `/short-urls/${shortCode}`, query: { domain } }); + public readonly getShortUrl = async (shortCode: string, domain?: OptionalString): Promise => + this.performRequest({ url: `/short-urls/${shortCode}`, query: { domain } }); public readonly deleteShortUrl = async (shortCode: string, domain?: OptionalString): Promise => this.performEmptyRequest({ url: `/short-urls/${shortCode}`, method: 'DELETE', query: { domain } }); @@ -105,8 +106,8 @@ export class ShlinkApiClient implements BaseShlinkApiClient { shortCode: string, domain: OptionalString, body: ShlinkShortUrlData, - ): Promise => - this.performRequest({ url: `/short-urls/${shortCode}`, method: 'PATCH', query: { domain }, body }); + ): Promise => + this.performRequest({ url: `/short-urls/${shortCode}`, method: 'PATCH', query: { domain }, body }); public readonly listTags = async (): Promise => this.performRequest<{ tags: ShlinkTagsResponse }>({ url: '/tags', query: { withStats: 'true' } }) diff --git a/test/api/services/ShlinkApiClient.test.ts b/test/api/services/ShlinkApiClient.test.ts index 8377b01d..06c4cdee 100644 --- a/test/api/services/ShlinkApiClient.test.ts +++ b/test/api/services/ShlinkApiClient.test.ts @@ -1,7 +1,7 @@ import type { ShlinkDomain, ShlinkVisits, ShlinkVisitsOverview } from '@shlinkio/shlink-web-component/api-contract'; import { ErrorTypeV2, ErrorTypeV3 } from '@shlinkio/shlink-web-component/api-contract'; import { fromPartial } from '@total-typescript/shoehorn'; -import type { ShortUrl, ShortUrlsOrder } from '../../../shlink-web-component/src/short-urls/data'; +import type { ShlinkShortUrl, ShortUrlsOrder } from '../../../shlink-web-component/src/short-urls/data'; import { ShlinkApiClient } from '../../../src/api/services/ShlinkApiClient'; import type { HttpClient } from '../../../src/common/services/HttpClient'; import type { OptionalString } from '../../../src/utils/utils'; @@ -175,7 +175,7 @@ describe('ShlinkApiClient', () => { maxVisits: 50, validSince: '2025-01-01T10:00:00+01:00', }; - const expectedResp = fromPartial({}); + const expectedResp = fromPartial({}); fetchJson.mockResolvedValue(expectedResp); const { updateShortUrl } = buildApiClient(); const expectedQuery = domain ? `?domain=${domain}` : '';