From 048a477e52c87da6369e8a60b718dce98a2f8f3b Mon Sep 17 00:00:00 2001 From: Anton Gunnarsson Date: Wed, 11 Jun 2025 13:08:39 +0000 Subject: [PATCH] Merged in feat/common-package (pull request #2333) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit feat: Add common package * Add isEdge, safeTry and dataCache to new common package * Add eslint and move prettier config * Fix yarn lock * Clean up tests * Add lint-staged config to common * Add missing dependencies Approved-by: Joakim Jäderberg --- .../sas-x-scandic/callback/route.ts | 4 +- .../(protected)/sas-x-scandic/otp/page.tsx | 3 +- .../app/api/web/revalidate/hotel/route.ts | 3 +- .../api/web/revalidate/loyaltyConfig/route.ts | 3 +- .../app/api/web/revalidate/manually/route.ts | 3 +- .../app/api/web/revalidate/route.ts | 3 +- .../ContentType/HotelPage/index.tsx | 3 +- .../HotelSubpage/MeetingsSubpage/index.tsx | 2 +- .../SelectHotelMapContainer.tsx | 3 +- apps/scandic-web/global.d.ts | 1 + apps/scandic-web/instrumentation.ts | 3 +- apps/scandic-web/lib/graphql/batchRequest.ts | 2 +- apps/scandic-web/lib/graphql/request.ts | 7 +- apps/scandic-web/middlewares/redirect.ts | 3 +- .../netlify/functions/warmup-background.mts | 2 +- apps/scandic-web/package.json | 1 + .../routers/autocomplete/destinations.ts | 6 +- .../destinationOverviewPage/query.ts | 3 +- .../routers/contentstack/reward/utils.ts | 3 +- .../server/routers/hotels/query.ts | 4 +- .../server/routers/hotels/utils.ts | 3 +- .../navigation/mypages/getPrimaryLinks.ts | 3 +- .../server/routers/partners/jobylon/query.ts | 4 +- apps/scandic-web/server/tokenManager.ts | 4 +- .../generateCacheKey/getPrefix.test.ts | 102 ---- .../warmup/warmupHotelIdsByCountry.ts | 4 +- apps/scandic-web/utils/hotelSearchDetails.ts | 3 +- package.json | 3 +- packages/common/.env.test | 2 + .../common}/dataCache/Cache.ts | 0 .../dataCache/DistributedCache/cacheOrGet.ts | 4 +- .../dataCache/DistributedCache/client.ts | 5 +- .../dataCache/DistributedCache/deleteKey.ts | 2 +- .../dataCache/DistributedCache/endpoints.ts | 2 +- .../generateCacheKey/getBranchPrefix.test.ts | 2 +- .../generateCacheKey/getBranchPrefix.ts | 0 .../generateCacheKey/getPrefix.test.ts | 123 ++++ .../generateCacheKey/getPrefix.ts | 3 +- .../generateCacheKey/index.test.ts | 19 +- .../generateCacheKey/index.ts | 0 .../common}/dataCache/DistributedCache/get.ts | 2 +- .../dataCache/DistributedCache/index.ts | 0 .../common}/dataCache/DistributedCache/set.ts | 2 +- .../MemoryCache/InMemoryCache/cacheMap.ts | 0 .../MemoryCache/InMemoryCache/cacheOrGet.ts | 6 +- .../MemoryCache/InMemoryCache/deleteKey.ts | 3 +- .../MemoryCache/InMemoryCache/get.ts | 3 +- .../MemoryCache/InMemoryCache/index.ts | 2 +- .../MemoryCache/InMemoryCache/set.ts | 6 +- .../MemoryCache/createMemoryCache.ts | 3 +- .../common}/dataCache/cacheOrGetOptions.ts | 0 .../common}/dataCache/index.ts | 6 +- .../common}/dataCache/logger.ts | 0 packages/common/env/server.ts | 29 + packages/common/eslint.config.mjs | 87 +++ .../types => packages/common}/global.d.ts | 2 +- packages/common/lint-staged.config.js | 7 + packages/common/package.json | 39 ++ packages/common/tsconfig.json | 3 + .../common}/utils/isEdge.ts | 0 .../common}/utils/safeTry.ts | 0 packages/common/vitest-setup.ts | 3 + packages/common/vitest.config.js | 17 + turbo.json | 3 +- yarn.lock | 548 ++++++++++++++++++ 65 files changed, 939 insertions(+), 182 deletions(-) create mode 100644 apps/scandic-web/global.d.ts delete mode 100644 apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts create mode 100644 packages/common/.env.test rename {apps/scandic-web/services => packages/common}/dataCache/Cache.ts (100%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/cacheOrGet.ts (94%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/client.ts (78%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/deleteKey.ts (94%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/endpoints.ts (86%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.test.ts (96%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.ts (100%) create mode 100644 packages/common/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/generateCacheKey/getPrefix.ts (95%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/generateCacheKey/index.test.ts (68%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/generateCacheKey/index.ts (100%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/get.ts (95%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/index.ts (100%) rename {apps/scandic-web/services => packages/common}/dataCache/DistributedCache/set.ts (93%) rename {apps/scandic-web/services => packages/common}/dataCache/MemoryCache/InMemoryCache/cacheMap.ts (100%) rename {apps/scandic-web/services => packages/common}/dataCache/MemoryCache/InMemoryCache/cacheOrGet.ts (88%) rename {apps/scandic-web/services => packages/common}/dataCache/MemoryCache/InMemoryCache/deleteKey.ts (84%) rename {apps/scandic-web/services => packages/common}/dataCache/MemoryCache/InMemoryCache/get.ts (89%) rename {apps/scandic-web/services => packages/common}/dataCache/MemoryCache/InMemoryCache/index.ts (81%) rename {apps/scandic-web/services => packages/common}/dataCache/MemoryCache/InMemoryCache/set.ts (72%) rename {apps/scandic-web/services => packages/common}/dataCache/MemoryCache/createMemoryCache.ts (70%) rename {apps/scandic-web/services => packages/common}/dataCache/cacheOrGetOptions.ts (100%) rename {apps/scandic-web/services => packages/common}/dataCache/index.ts (89%) rename {apps/scandic-web/services => packages/common}/dataCache/logger.ts (100%) create mode 100644 packages/common/env/server.ts create mode 100644 packages/common/eslint.config.mjs rename {apps/scandic-web/types => packages/common}/global.d.ts (56%) create mode 100644 packages/common/lint-staged.config.js create mode 100644 packages/common/package.json create mode 100644 packages/common/tsconfig.json rename {apps/scandic-web => packages/common}/utils/isEdge.ts (100%) rename {apps/scandic-web => packages/common}/utils/safeTry.ts (100%) create mode 100644 packages/common/vitest-setup.ts create mode 100644 packages/common/vitest.config.js diff --git a/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/callback/route.ts b/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/callback/route.ts index 2122e8d8f..9b6b98399 100644 --- a/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/callback/route.ts +++ b/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/callback/route.ts @@ -2,11 +2,11 @@ import { cookies } from "next/headers" import { redirect } from "next/navigation" import { z } from "zod" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { env } from "@/env/server" import { serverClient } from "@/lib/trpc/server" -import { safeTry } from "@/utils/safeTry" - import { SAS_TOKEN_STORAGE_KEY, stateSchema } from "../sasUtils" import type { NextRequest } from "next/server" diff --git a/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/otp/page.tsx b/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/otp/page.tsx index 9760274d3..cf883bcb6 100644 --- a/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/otp/page.tsx +++ b/apps/scandic-web/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/otp/page.tsx @@ -2,11 +2,12 @@ import { cookies } from "next/headers" import { redirect } from "next/navigation" import { z } from "zod" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { myPages } from "@/constants/routes/myPages" import { serverClient } from "@/lib/trpc/server" import { getIntl } from "@/i18n" -import { safeTry } from "@/utils/safeTry" import { SAS_TOKEN_STORAGE_KEY, SAS_TRANSFER_POINT_KEY } from "../sasUtils" import OneTimePasswordForm, { diff --git a/apps/scandic-web/app/api/web/revalidate/hotel/route.ts b/apps/scandic-web/app/api/web/revalidate/hotel/route.ts index 08190c46d..d7d38ac45 100644 --- a/apps/scandic-web/app/api/web/revalidate/hotel/route.ts +++ b/apps/scandic-web/app/api/web/revalidate/hotel/route.ts @@ -2,11 +2,12 @@ import { revalidateTag } from "next/cache" import { headers } from "next/headers" import { z } from "zod" +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { Lang } from "@/constants/languages" import { env } from "@/env/server" import { badRequest, internalServerError, notFound } from "@/server/errors/next" -import { getCacheClient } from "@/services/dataCache" import { generateHotelUrlTag } from "@/utils/generateTag" import type { NextRequest } from "next/server" diff --git a/apps/scandic-web/app/api/web/revalidate/loyaltyConfig/route.ts b/apps/scandic-web/app/api/web/revalidate/loyaltyConfig/route.ts index 5ee04b948..16e401e48 100644 --- a/apps/scandic-web/app/api/web/revalidate/loyaltyConfig/route.ts +++ b/apps/scandic-web/app/api/web/revalidate/loyaltyConfig/route.ts @@ -2,11 +2,12 @@ import { revalidateTag } from "next/cache" import { headers } from "next/headers" import { z } from "zod" +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { Lang } from "@/constants/languages" import { env } from "@/env/server" import { badRequest, internalServerError, notFound } from "@/server/errors/next" -import { getCacheClient } from "@/services/dataCache" import { generateLoyaltyConfigTag } from "@/utils/generateTag" import type { NextRequest } from "next/server" diff --git a/apps/scandic-web/app/api/web/revalidate/manually/route.ts b/apps/scandic-web/app/api/web/revalidate/manually/route.ts index c17b0e98d..17794e25c 100644 --- a/apps/scandic-web/app/api/web/revalidate/manually/route.ts +++ b/apps/scandic-web/app/api/web/revalidate/manually/route.ts @@ -1,10 +1,11 @@ import { revalidateTag } from "next/cache" import { headers } from "next/headers" +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { env } from "@/env/server" import { badRequest, internalServerError } from "@/server/errors/next" -import { getCacheClient } from "@/services/dataCache" import { generateTag } from "@/utils/generateTag" import type { Lang } from "@/constants/languages" diff --git a/apps/scandic-web/app/api/web/revalidate/route.ts b/apps/scandic-web/app/api/web/revalidate/route.ts index f641b0c41..b6a764a5c 100644 --- a/apps/scandic-web/app/api/web/revalidate/route.ts +++ b/apps/scandic-web/app/api/web/revalidate/route.ts @@ -2,6 +2,8 @@ import { revalidateTag } from "next/cache" import { headers } from "next/headers" import { z } from "zod" +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { Lang } from "@/constants/languages" import { env } from "@/env/server" import { badRequest, internalServerError } from "@/server/errors/next" @@ -10,7 +12,6 @@ import { languageSwitcherAffix } from "@/server/routers/contentstack/languageSwi import { affix as metadataAffix } from "@/server/routers/contentstack/metadata/utils" import { affix as pageSettingsAffix } from "@/server/routers/contentstack/pageSettings/utils" -import { getCacheClient } from "@/services/dataCache" import { generateRefsResponseTag, generateRefTag, diff --git a/apps/scandic-web/components/ContentType/HotelPage/index.tsx b/apps/scandic-web/components/ContentType/HotelPage/index.tsx index 6a079bdf5..4653135bf 100644 --- a/apps/scandic-web/components/ContentType/HotelPage/index.tsx +++ b/apps/scandic-web/components/ContentType/HotelPage/index.tsx @@ -1,6 +1,8 @@ import { notFound } from "next/navigation" import { Suspense } from "react" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { getHotel, getHotelPage, @@ -16,7 +18,6 @@ import { getIntl } from "@/i18n" import { getLang } from "@/i18n/serverContext" import { setFacilityCards } from "@/utils/facilityCards" import { generateHotelSchema } from "@/utils/jsonSchemas" -import { safeTry } from "@/utils/safeTry" import MapCard from "./Map/MapCard" import MapWithCardWrapper from "./Map/MapWithCard" diff --git a/apps/scandic-web/components/ContentType/HotelSubpage/MeetingsSubpage/index.tsx b/apps/scandic-web/components/ContentType/HotelSubpage/MeetingsSubpage/index.tsx index 8a00186ff..bebb848e7 100644 --- a/apps/scandic-web/components/ContentType/HotelSubpage/MeetingsSubpage/index.tsx +++ b/apps/scandic-web/components/ContentType/HotelSubpage/MeetingsSubpage/index.tsx @@ -1,3 +1,4 @@ +import { safeTry } from "@scandic-hotels/common/utils/safeTry" import { Typography } from "@scandic-hotels/design-system/Typography" import { getMeetingRooms } from "@/lib/trpc/memoizedRequests" @@ -7,7 +8,6 @@ import StickyMeetingPackageWidget from "@/components/StickyMeetingPackageWidget" import Divider from "@/components/TempDesignSystem/Divider" import { getIntl } from "@/i18n" import { getLang } from "@/i18n/serverContext" -import { safeTry } from "@/utils/safeTry" import HeroHeader from "../HeroHeader" import HtmlContent from "../HtmlContent" diff --git a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx index 2a9104964..f0102d919 100644 --- a/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx +++ b/apps/scandic-web/components/HotelReservation/SelectHotel/SelectHotelMap/SelectHotelMapContainer.tsx @@ -1,12 +1,13 @@ import { notFound } from "next/navigation" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { env } from "@/env/server" import { getCityCoordinates } from "@/lib/trpc/memoizedRequests" import TrackingSDK from "@/components/TrackingSDK" import { getLang } from "@/i18n/serverContext" import { getHotelSearchDetails } from "@/utils/hotelSearchDetails" -import { safeTry } from "@/utils/safeTry" import { getHotelPins } from "../../HotelCardDialogListing/utils" import { getFiltersFromHotels, getHotels } from "../helpers" diff --git a/apps/scandic-web/global.d.ts b/apps/scandic-web/global.d.ts new file mode 100644 index 000000000..f50285b05 --- /dev/null +++ b/apps/scandic-web/global.d.ts @@ -0,0 +1 @@ +import "@scandic-hotels/common/global.d.ts" diff --git a/apps/scandic-web/instrumentation.ts b/apps/scandic-web/instrumentation.ts index 1b1158491..4fab6c5d5 100644 --- a/apps/scandic-web/instrumentation.ts +++ b/apps/scandic-web/instrumentation.ts @@ -1,7 +1,8 @@ import * as Sentry from "@sentry/nextjs" +import { isEdge } from "@scandic-hotels/common/utils/isEdge" + import { env } from "./env/server" -import { isEdge } from "./utils/isEdge" export async function register() { /* diff --git a/apps/scandic-web/lib/graphql/batchRequest.ts b/apps/scandic-web/lib/graphql/batchRequest.ts index 8c9e74ecd..c47386bca 100644 --- a/apps/scandic-web/lib/graphql/batchRequest.ts +++ b/apps/scandic-web/lib/graphql/batchRequest.ts @@ -6,10 +6,10 @@ import { arrayMerge } from "@/utils/merge" import { request } from "./request" +import type { CacheTime } from "@scandic-hotels/common/dataCache" import type { BatchRequestDocument } from "graphql-request" import type { Data } from "@/types/request" -import type { CacheTime } from "@/services/dataCache" export async function batchRequest( queries: (BatchRequestDocument & { diff --git a/apps/scandic-web/lib/graphql/request.ts b/apps/scandic-web/lib/graphql/request.ts index fc00bf565..569182932 100644 --- a/apps/scandic-web/lib/graphql/request.ts +++ b/apps/scandic-web/lib/graphql/request.ts @@ -3,11 +3,14 @@ import { GraphQLClient } from "graphql-request" import stringify from "json-stable-stringify-without-jsonify" import { cache as reactCache } from "react" +import { + type CacheTime, + getCacheClient, +} from "@scandic-hotels/common/dataCache" + import { env } from "@/env/server" import { getPreviewHash, isPreviewByUid } from "@/lib/previewContext" -import { type CacheTime, getCacheClient } from "@/services/dataCache" - import { request as _request } from "./_request" import { getOperationName } from "./getOperationName" diff --git a/apps/scandic-web/middlewares/redirect.ts b/apps/scandic-web/middlewares/redirect.ts index 0ce81d954..f3797323c 100644 --- a/apps/scandic-web/middlewares/redirect.ts +++ b/apps/scandic-web/middlewares/redirect.ts @@ -1,9 +1,10 @@ import { type NextMiddleware, NextResponse } from "next/server" +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { notFound } from "@/server/errors/next" import { getPublicNextURL } from "@/server/utils" -import { getCacheClient } from "@/services/dataCache" import { findLang } from "@/utils/languages" import { getDefaultRequestHeaders } from "./utils" diff --git a/apps/scandic-web/netlify/functions/warmup-background.mts b/apps/scandic-web/netlify/functions/warmup-background.mts index 4f52a5061..baba07c0f 100644 --- a/apps/scandic-web/netlify/functions/warmup-background.mts +++ b/apps/scandic-web/netlify/functions/warmup-background.mts @@ -5,7 +5,7 @@ import { type WarmupFunctionsKey, warmupKeys, } from "@/services/warmup/warmupKeys" -import { safeTry } from "@/utils/safeTry" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" import { timeout } from "@/utils/timeout" import type { Config, Context } from "@netlify/functions" diff --git a/apps/scandic-web/package.json b/apps/scandic-web/package.json index 2aac3590b..46c879909 100644 --- a/apps/scandic-web/package.json +++ b/apps/scandic-web/package.json @@ -119,6 +119,7 @@ "@eslint/js": "^9.26.0", "@formatjs/cli": "^6.7.1", "@lokalise/node-api": "^14.0.0", + "@scandic-hotels/common": "workspace:*", "@scandic-hotels/typescript-config": "workspace:*", "@svgr/webpack": "^8.1.0", "@testing-library/jest-dom": "^6.6.3", diff --git a/apps/scandic-web/server/routers/autocomplete/destinations.ts b/apps/scandic-web/server/routers/autocomplete/destinations.ts index 2ada552bb..cf2f9d2b2 100644 --- a/apps/scandic-web/server/routers/autocomplete/destinations.ts +++ b/apps/scandic-web/server/routers/autocomplete/destinations.ts @@ -1,12 +1,12 @@ import { z } from "zod" +import { getCacheClient } from "@scandic-hotels/common/dataCache" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { Lang } from "@/constants/languages" import { safeProtectedServiceProcedure } from "@/server/trpc" import { isDefined } from "@/server/utils" -import { getCacheClient } from "@/services/dataCache" -import { safeTry } from "@/utils/safeTry" - import { getCityPageUrls } from "../contentstack/destinationCityPage/utils" import { getCountryPageUrls } from "../contentstack/destinationCountryPage/utils" import { getHotelPageUrls } from "../contentstack/hotelPage/utils" diff --git a/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts b/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts index dafaaf01c..91117d9c0 100644 --- a/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts +++ b/apps/scandic-web/server/routers/contentstack/destinationOverviewPage/query.ts @@ -1,3 +1,5 @@ +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { Lang } from "@/constants/languages" import { GetDestinationOverviewPage, @@ -13,7 +15,6 @@ import { } from "@/server/trpc" import { generateRefsResponseTag, generateTag } from "@/utils/generateTag" -import { safeTry } from "@/utils/safeTry" import { getCitiesByCountry, diff --git a/apps/scandic-web/server/routers/contentstack/reward/utils.ts b/apps/scandic-web/server/routers/contentstack/reward/utils.ts index 00494aa2b..d441708e7 100644 --- a/apps/scandic-web/server/routers/contentstack/reward/utils.ts +++ b/apps/scandic-web/server/routers/contentstack/reward/utils.ts @@ -1,3 +1,5 @@ +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import * as api from "@/lib/api" import { GetRewards as GetRewards, @@ -7,7 +9,6 @@ import { request } from "@/lib/graphql/request" import { notFound } from "@/server/errors/trpc" import { createCounter } from "@/server/telemetry" -import { getCacheClient } from "@/services/dataCache" import { generateLoyaltyConfigTag, generateRefsResponseTag, diff --git a/apps/scandic-web/server/routers/hotels/query.ts b/apps/scandic-web/server/routers/hotels/query.ts index f95775a69..bdd6f8507 100644 --- a/apps/scandic-web/server/routers/hotels/query.ts +++ b/apps/scandic-web/server/routers/hotels/query.ts @@ -1,3 +1,5 @@ +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { REDEMPTION } from "@/constants/booking" import { Lang } from "@/constants/languages" import { env } from "@/env/server" @@ -16,8 +18,6 @@ import { } from "@/server/trpc" import { toApiLang } from "@/server/utils" -import { getCacheClient } from "@/services/dataCache" - import { getHotelPageUrls } from "../contentstack/hotelPage/utils" import { additionalDataSchema } from "./schemas/hotel/include/additionalData" import { meetingRoomsSchema } from "./schemas/meetingRoom" diff --git a/apps/scandic-web/server/routers/hotels/utils.ts b/apps/scandic-web/server/routers/hotels/utils.ts index c912294ef..9e22fb9b2 100644 --- a/apps/scandic-web/server/routers/hotels/utils.ts +++ b/apps/scandic-web/server/routers/hotels/utils.ts @@ -1,6 +1,8 @@ import deepmerge from "deepmerge" import stringify from "json-stable-stringify-without-jsonify" +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { BookingErrorCodeEnum, REDEMPTION } from "@/constants/booking" import { Lang } from "@/constants/languages" import { selectRate } from "@/constants/routes/hotelReservation" @@ -11,7 +13,6 @@ import { createCounter } from "@/server/telemetry" import { toApiLang } from "@/server/utils" import { generateChildrenString } from "@/components/HotelReservation/utils" -import { getCacheClient } from "@/services/dataCache" import { cache } from "@/utils/cache" import { chunk } from "@/utils/chunk" import { sortRoomConfigs } from "@/utils/sort" diff --git a/apps/scandic-web/server/routers/navigation/mypages/getPrimaryLinks.ts b/apps/scandic-web/server/routers/navigation/mypages/getPrimaryLinks.ts index 8febf8a20..addd86e5b 100644 --- a/apps/scandic-web/server/routers/navigation/mypages/getPrimaryLinks.ts +++ b/apps/scandic-web/server/routers/navigation/mypages/getPrimaryLinks.ts @@ -1,10 +1,11 @@ import { cache } from "react" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import * as routes from "@/constants/routes/myPages" import { env } from "@/env/server" import { getIntl } from "@/i18n" -import { safeTry } from "@/utils/safeTry" import { getEurobonusMembership } from "@/utils/user" import type { UserLoyalty } from "@/types/user" diff --git a/apps/scandic-web/server/routers/partners/jobylon/query.ts b/apps/scandic-web/server/routers/partners/jobylon/query.ts index 464b253c6..bc714d72a 100644 --- a/apps/scandic-web/server/routers/partners/jobylon/query.ts +++ b/apps/scandic-web/server/routers/partners/jobylon/query.ts @@ -1,8 +1,8 @@ +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { createCounter } from "@/server/telemetry" import { publicProcedure, router } from "@/server/trpc" -import { getCacheClient } from "@/services/dataCache" - import { jobylonFeedSchema } from "./output" export const TWENTYFOUR_HOURS = 60 * 60 * 24 diff --git a/apps/scandic-web/server/tokenManager.ts b/apps/scandic-web/server/tokenManager.ts index 56bf00947..33b3e72c6 100644 --- a/apps/scandic-web/server/tokenManager.ts +++ b/apps/scandic-web/server/tokenManager.ts @@ -1,10 +1,10 @@ import { trace, type Tracer } from "@opentelemetry/api" +import { getCacheClient } from "@scandic-hotels/common/dataCache" + import { env } from "@/env/server" import { createCounter } from "@/server/telemetry" -import { getCacheClient } from "@/services/dataCache" - import type { ServiceTokenResponse } from "@/types/tokens" export async function getServiceToken() { diff --git a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts b/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts deleted file mode 100644 index 34954260c..000000000 --- a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts +++ /dev/null @@ -1,102 +0,0 @@ -import { describe, expect, it, jest } from "@jest/globals" - -jest.doMock("@/env/server", () => ({ - env: { - NODE_ENV: "test", - }, -})) - -const { env } = require("@/env/server") -const { getPrefix } = require("./getPrefix") - -const mockedEnv = env as { BRANCH: string; GIT_SHA: string } - -describe("getPrefix", () => { - const OLD_ENV = process.env - - beforeEach(() => { - jest.resetModules() - }) - - afterEach(() => { - process.env = OLD_ENV - }) - - it.each([ - "prod", - "production", - "release", - "release-v1", - "release-v2", - "release-v2-alpha", - "release-v2.1-alpha", - "release-v2.1.2-alpha", - ])( - "should return gitsha for production branches when name is '%s'", - (branchName: string) => { - mockedEnv.BRANCH = branchName - mockedEnv.GIT_SHA = "gitsha" - - const result = getPrefix() - - expect(result).toBe("gitsha") - } - ) - - it.each([ - "fix/stuff", - "feat/my-feature", - "feature/my-feature", - "releasee", - "release-vA", - "FEAT", - ])( - "should return branch name and gitsha for non-production branches when name is '%s'", - (branchName: string) => { - mockedEnv.BRANCH = branchName - mockedEnv.GIT_SHA = "gitsha" - - const result = getPrefix() - - expect(result).toBe(`${mockedEnv.BRANCH}:${mockedEnv.GIT_SHA}`) - } - ) - - it("should throw if BRANCH and/or GIT_SHA is not set", () => { - mockedEnv.BRANCH = "" - mockedEnv.GIT_SHA = "" - - expect(getPrefix).toThrow( - "Unable to getPrefix, BRANCH and GIT_SHA must be set" - ) - - mockedEnv.BRANCH = "hasBranch" - mockedEnv.GIT_SHA = "" - - expect(getPrefix).toThrow("Unable to getPrefix, GIT_SHA must be set") - - mockedEnv.BRANCH = "" - mockedEnv.GIT_SHA = "hasGitSha" - - expect(getPrefix).toThrow("Unable to getPrefix, BRANCH must be set") - }) - - it("should return dev or local user if running locally", () => { - ;(process.env.NODE_ENV as any) = "development" - - process.env.USER = "test_user" - process.env.USERNAME = "test_username" - - mockedEnv.BRANCH = "" - mockedEnv.GIT_SHA = "" - - expect(getPrefix()).toBe("test_user") - - process.env.USER = "" - - expect(getPrefix()).toBe("test_username") - - process.env.USERNAME = "" - expect(getPrefix()).toBe("dev") - }) -}) diff --git a/apps/scandic-web/services/warmup/warmupHotelIdsByCountry.ts b/apps/scandic-web/services/warmup/warmupHotelIdsByCountry.ts index f0e6ace33..4fd5b8a19 100644 --- a/apps/scandic-web/services/warmup/warmupHotelIdsByCountry.ts +++ b/apps/scandic-web/services/warmup/warmupHotelIdsByCountry.ts @@ -1,3 +1,5 @@ +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { Lang } from "@/constants/languages" import { getCountries, @@ -5,8 +7,6 @@ import { } from "@/server/routers/hotels/utils" import { getServiceToken } from "@/server/tokenManager" -import { safeTry } from "@/utils/safeTry" - import type { WarmupFunction, WarmupResult } from "." export const warmupHotelIdsByCountry = diff --git a/apps/scandic-web/utils/hotelSearchDetails.ts b/apps/scandic-web/utils/hotelSearchDetails.ts index bdcbbe7ac..946a4afb4 100644 --- a/apps/scandic-web/utils/hotelSearchDetails.ts +++ b/apps/scandic-web/utils/hotelSearchDetails.ts @@ -1,10 +1,11 @@ import { notFound } from "next/navigation" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" + import { REDEMPTION } from "@/constants/booking" import { getLocations } from "@/lib/trpc/memoizedRequests" import { generateChildrenString } from "@/components/HotelReservation/utils" -import { safeTry } from "@/utils/safeTry" import type { BookingSearchType } from "@/types/components/hotelReservation/booking" import type { Child } from "@/types/components/hotelReservation/selectRate/selectRate" diff --git a/package.json b/package.json index 246a46121..f68f015f6 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "dev:ds": "turbo run dev --filter=@scandic-hotels/design-system --output-logs new-only", "test": "turbo run test", "postinstall": "husky", - "icons:update": "node scripts/material-symbols-update.mjs" + "icons:update": "node scripts/material-symbols-update.mjs", + "check-types": "turbo run check-types" }, "workspaces": [ "apps/*", diff --git a/packages/common/.env.test b/packages/common/.env.test new file mode 100644 index 000000000..8ae01e831 --- /dev/null +++ b/packages/common/.env.test @@ -0,0 +1,2 @@ +NODE_ENV="development" +BRANCH="test" \ No newline at end of file diff --git a/apps/scandic-web/services/dataCache/Cache.ts b/packages/common/dataCache/Cache.ts similarity index 100% rename from apps/scandic-web/services/dataCache/Cache.ts rename to packages/common/dataCache/Cache.ts diff --git a/apps/scandic-web/services/dataCache/DistributedCache/cacheOrGet.ts b/packages/common/dataCache/DistributedCache/cacheOrGet.ts similarity index 94% rename from apps/scandic-web/services/dataCache/DistributedCache/cacheOrGet.ts rename to packages/common/dataCache/DistributedCache/cacheOrGet.ts index 69c3181e3..64b9b9c48 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/cacheOrGet.ts +++ b/packages/common/dataCache/DistributedCache/cacheOrGet.ts @@ -1,5 +1,3 @@ -import { type CacheTime, type DataCache } from "@/services/dataCache/Cache" - import { type CacheOrGetOptions, shouldGetFromCache, @@ -9,6 +7,8 @@ import { generateCacheKey } from "./generateCacheKey" import { get } from "./get" import { set } from "./set" +import type { CacheTime, DataCache } from "../Cache" + export const cacheOrGet: DataCache["cacheOrGet"] = async ( key: string | string[], callback: (overrideTTL: (cacheTime: CacheTime) => void) => Promise, diff --git a/apps/scandic-web/services/dataCache/DistributedCache/client.ts b/packages/common/dataCache/DistributedCache/client.ts similarity index 78% rename from apps/scandic-web/services/dataCache/DistributedCache/client.ts rename to packages/common/dataCache/DistributedCache/client.ts index 133b68b3e..3488d825c 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/client.ts +++ b/packages/common/dataCache/DistributedCache/client.ts @@ -1,11 +1,10 @@ -import { env } from "@/env/server" - +import { env } from "../../env/server" import { cacheOrGet } from "./cacheOrGet" import { deleteKey } from "./deleteKey" import { get } from "./get" import { set } from "./set" -import type { DataCache } from "@/services/dataCache/Cache" +import type { DataCache } from "../Cache" export const API_KEY = env.REDIS_API_KEY ?? "" export async function createDistributedCache(): Promise { diff --git a/apps/scandic-web/services/dataCache/DistributedCache/deleteKey.ts b/packages/common/dataCache/DistributedCache/deleteKey.ts similarity index 94% rename from apps/scandic-web/services/dataCache/DistributedCache/deleteKey.ts rename to packages/common/dataCache/DistributedCache/deleteKey.ts index d9071fda8..8dd83f6e8 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/deleteKey.ts +++ b/packages/common/dataCache/DistributedCache/deleteKey.ts @@ -1,6 +1,6 @@ import * as Sentry from "@sentry/nextjs" -import { safeTry } from "@/utils/safeTry" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" import { cacheLogger } from "../logger" import { API_KEY } from "./client" diff --git a/apps/scandic-web/services/dataCache/DistributedCache/endpoints.ts b/packages/common/dataCache/DistributedCache/endpoints.ts similarity index 86% rename from apps/scandic-web/services/dataCache/DistributedCache/endpoints.ts rename to packages/common/dataCache/DistributedCache/endpoints.ts index 0705dccc1..b9b01818f 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/endpoints.ts +++ b/packages/common/dataCache/DistributedCache/endpoints.ts @@ -1,4 +1,4 @@ -import { env } from "@/env/server" +import { env } from "../../env/server" export function getCacheEndpoint(key: string) { if (!env.REDIS_API_HOST) { diff --git a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.test.ts b/packages/common/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.test.ts similarity index 96% rename from apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.test.ts rename to packages/common/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.test.ts index 9f381580a..fd2d8b0b6 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.test.ts +++ b/packages/common/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.test.ts @@ -1,4 +1,4 @@ -import { describe, expect, it } from "@jest/globals" +import { describe, expect, it } from "vitest" import { getBranchPrefix } from "./getBranchPrefix" diff --git a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.ts b/packages/common/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.ts similarity index 100% rename from apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.ts rename to packages/common/dataCache/DistributedCache/generateCacheKey/getBranchPrefix.ts diff --git a/packages/common/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts b/packages/common/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts new file mode 100644 index 000000000..805e8f239 --- /dev/null +++ b/packages/common/dataCache/DistributedCache/generateCacheKey/getPrefix.test.ts @@ -0,0 +1,123 @@ +import { afterEach, beforeEach, describe, expect, it, vi } from "vitest" + +vi.mock("@/env/server", () => ({ + env: { + NODE_ENV: "test", + }, +})) + +import { env } from "../../../env/server" +import { getPrefix } from "./getPrefix" + +const mockedEnv = env as { BRANCH: string; GIT_SHA: string } + +describe("getPrefix", () => { + beforeEach(() => { + vi.resetModules() + }) + + afterEach(() => { + vi.unstubAllEnvs() + }) + + it.each([ + "prod", + "production", + "release", + "release-v1", + "release-v2", + "release-v2-alpha", + "release-v2.1-alpha", + "release-v2.1.2-alpha", + ])( + "should return gitsha for production branches when name is '%s'", + (branchName: string) => { + mockedEnv.BRANCH = branchName + mockedEnv.GIT_SHA = "gitsha" + + const result = getPrefix({ + includeGitHashInKey: true, + includeBranchPrefix: true, + }) + + expect(result).toBe("gitsha") + } + ) + + it.each([ + "fix/stuff", + "feat/my-feature", + "feature/my-feature", + "releasee", + "release-vA", + "FEAT", + ])( + "should return branch name and gitsha for non-production branches when name is '%s'", + (branchName: string) => { + mockedEnv.BRANCH = branchName + mockedEnv.GIT_SHA = "gitsha" + + const result = getPrefix({ + includeGitHashInKey: true, + includeBranchPrefix: true, + }) + + expect(result).toBe(`${"gitsha"}:${branchName}`) + } + ) + + it("should throw if BRANCH and/or GIT_SHA is not set", () => { + mockedEnv.BRANCH = "hasBranch" + mockedEnv.GIT_SHA = "" + + expect(() => + getPrefix({ + includeBranchPrefix: true, + includeGitHashInKey: true, + }) + ).toThrow("Unable to getPrefix, GIT_SHA must be set") + + mockedEnv.BRANCH = "" + mockedEnv.GIT_SHA = "hasGitSha" + + expect(() => + getPrefix({ + includeBranchPrefix: true, + includeGitHashInKey: true, + }) + ).toThrow("Unable to getPrefix, BRANCH must be set") + }) + + it("should return dev or local user if running locally", () => { + vi.stubEnv("NODE_ENV", "development") + vi.stubEnv("USER", "test_user") + vi.stubEnv("USERNAME", "test_username") + + mockedEnv.BRANCH = "" + mockedEnv.GIT_SHA = "" + + expect( + getPrefix({ + includeGitHashInKey: false, + includeBranchPrefix: false, + }) + ).toBe("test_user") + + process.env.USER = "" + + expect( + getPrefix({ + includeGitHashInKey: false, + includeBranchPrefix: false, + }) + ).toBe("test_username") + + process.env.USERNAME = "" + expect( + getPrefix({ + includeGitHashInKey: false, + includeBranchPrefix: false, + }) + ).toBe("dev") + }) +}) diff --git a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getPrefix.ts b/packages/common/dataCache/DistributedCache/generateCacheKey/getPrefix.ts similarity index 95% rename from apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getPrefix.ts rename to packages/common/dataCache/DistributedCache/generateCacheKey/getPrefix.ts index a2dfa2ffd..36b6cb2a0 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/getPrefix.ts +++ b/packages/common/dataCache/DistributedCache/generateCacheKey/getPrefix.ts @@ -1,5 +1,4 @@ -import { env } from "@/env/server" - +import { env } from "../../../env/server" import { getBranchPrefix } from "./getBranchPrefix" export function getPrefix(options: { diff --git a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/index.test.ts b/packages/common/dataCache/DistributedCache/generateCacheKey/index.test.ts similarity index 68% rename from apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/index.test.ts rename to packages/common/dataCache/DistributedCache/generateCacheKey/index.test.ts index dd42a2f96..6c3eda9a5 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/index.test.ts +++ b/packages/common/dataCache/DistributedCache/generateCacheKey/index.test.ts @@ -1,23 +1,14 @@ -import { describe, expect, it, jest } from "@jest/globals" +import { describe, expect, it, vi } from "vitest" -jest.mock("./getPrefix", () => ({ - getPrefix: jest.fn(() => "gitsha"), +vi.mock("./getPrefix", () => ({ + getPrefix: vi.fn(() => "gitsha"), })) -// eslint-disable-next-line @typescript-eslint/consistent-type-imports -const indexModule: typeof import(".") = require(".") - -const { generateCacheKey } = indexModule +import { generateCacheKey } from "./index" describe("generateCacheKey", () => { - const OLD_ENV = process.env - beforeEach(() => { - jest.resetModules() - }) - - afterEach(() => { - process.env = OLD_ENV + vi.resetModules() }) it("generates cachekey with prefix and key using string", () => { diff --git a/apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/index.ts b/packages/common/dataCache/DistributedCache/generateCacheKey/index.ts similarity index 100% rename from apps/scandic-web/services/dataCache/DistributedCache/generateCacheKey/index.ts rename to packages/common/dataCache/DistributedCache/generateCacheKey/index.ts diff --git a/apps/scandic-web/services/dataCache/DistributedCache/get.ts b/packages/common/dataCache/DistributedCache/get.ts similarity index 95% rename from apps/scandic-web/services/dataCache/DistributedCache/get.ts rename to packages/common/dataCache/DistributedCache/get.ts index e8c262089..807164336 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/get.ts +++ b/packages/common/dataCache/DistributedCache/get.ts @@ -1,6 +1,6 @@ import * as Sentry from "@sentry/nextjs" -import { safeTry } from "@/utils/safeTry" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" import { cacheLogger } from "../logger" import { API_KEY } from "./client" diff --git a/apps/scandic-web/services/dataCache/DistributedCache/index.ts b/packages/common/dataCache/DistributedCache/index.ts similarity index 100% rename from apps/scandic-web/services/dataCache/DistributedCache/index.ts rename to packages/common/dataCache/DistributedCache/index.ts diff --git a/apps/scandic-web/services/dataCache/DistributedCache/set.ts b/packages/common/dataCache/DistributedCache/set.ts similarity index 93% rename from apps/scandic-web/services/dataCache/DistributedCache/set.ts rename to packages/common/dataCache/DistributedCache/set.ts index de89ed1d6..bd1435f2b 100644 --- a/apps/scandic-web/services/dataCache/DistributedCache/set.ts +++ b/packages/common/dataCache/DistributedCache/set.ts @@ -1,6 +1,6 @@ import * as Sentry from "@sentry/nextjs" -import { safeTry } from "@/utils/safeTry" +import { safeTry } from "@scandic-hotels/common/utils/safeTry" import { type CacheTime, getCacheTimeInSeconds } from "../Cache" import { API_KEY } from "./client" diff --git a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/cacheMap.ts b/packages/common/dataCache/MemoryCache/InMemoryCache/cacheMap.ts similarity index 100% rename from apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/cacheMap.ts rename to packages/common/dataCache/MemoryCache/InMemoryCache/cacheMap.ts diff --git a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/cacheOrGet.ts b/packages/common/dataCache/MemoryCache/InMemoryCache/cacheOrGet.ts similarity index 88% rename from apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/cacheOrGet.ts rename to packages/common/dataCache/MemoryCache/InMemoryCache/cacheOrGet.ts index 4342e968d..cfac52029 100644 --- a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/cacheOrGet.ts +++ b/packages/common/dataCache/MemoryCache/InMemoryCache/cacheOrGet.ts @@ -1,13 +1,13 @@ -import { type CacheTime, type DataCache } from "@/services/dataCache/Cache" -import { cacheLogger } from "@/services/dataCache/logger" - import { type CacheOrGetOptions, shouldGetFromCache, } from "../../cacheOrGetOptions" +import { cacheLogger } from "../../logger" import { get } from "./get" import { set } from "./set" +import type { CacheTime, DataCache } from "../../Cache" + export const cacheOrGet: DataCache["cacheOrGet"] = async ( key: string | string[], callback: (overrideTTL?: (cacheTime: CacheTime) => void) => Promise, diff --git a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/deleteKey.ts b/packages/common/dataCache/MemoryCache/InMemoryCache/deleteKey.ts similarity index 84% rename from apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/deleteKey.ts rename to packages/common/dataCache/MemoryCache/InMemoryCache/deleteKey.ts index 2cc5ea7f5..ce3900f8b 100644 --- a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/deleteKey.ts +++ b/packages/common/dataCache/MemoryCache/InMemoryCache/deleteKey.ts @@ -1,5 +1,4 @@ -import { cacheLogger } from "@/services/dataCache/logger" - +import { cacheLogger } from "../../logger" import { cacheMap } from "./cacheMap" export async function deleteKey(key: string, opts?: { fuzzy?: boolean }) { diff --git a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/get.ts b/packages/common/dataCache/MemoryCache/InMemoryCache/get.ts similarity index 89% rename from apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/get.ts rename to packages/common/dataCache/MemoryCache/InMemoryCache/get.ts index 62832a416..61773441f 100644 --- a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/get.ts +++ b/packages/common/dataCache/MemoryCache/InMemoryCache/get.ts @@ -1,5 +1,4 @@ -import { cacheLogger } from "@/services/dataCache/logger" - +import { cacheLogger } from "../../logger" import { cacheMap } from "./cacheMap" export async function get(key: string): Promise { diff --git a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/index.ts b/packages/common/dataCache/MemoryCache/InMemoryCache/index.ts similarity index 81% rename from apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/index.ts rename to packages/common/dataCache/MemoryCache/InMemoryCache/index.ts index 13cb45e30..6def95013 100644 --- a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/index.ts +++ b/packages/common/dataCache/MemoryCache/InMemoryCache/index.ts @@ -3,7 +3,7 @@ import { deleteKey } from "./deleteKey" import { get } from "./get" import { set } from "./set" -import type { DataCache } from "@/services/dataCache/Cache" +import type { DataCache } from "../../Cache" export async function createInMemoryCache(): Promise { return { type: "in-memory", cacheOrGet, deleteKey, get, set } diff --git a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/set.ts b/packages/common/dataCache/MemoryCache/InMemoryCache/set.ts similarity index 72% rename from apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/set.ts rename to packages/common/dataCache/MemoryCache/InMemoryCache/set.ts index 62f5e53c7..bc02eb17f 100644 --- a/apps/scandic-web/services/dataCache/MemoryCache/InMemoryCache/set.ts +++ b/packages/common/dataCache/MemoryCache/InMemoryCache/set.ts @@ -1,8 +1,4 @@ -import { - type CacheTime, - getCacheTimeInSeconds, -} from "@/services/dataCache/Cache" - +import { type CacheTime, getCacheTimeInSeconds } from "../../Cache" import { cacheMap } from "./cacheMap" export async function set( diff --git a/apps/scandic-web/services/dataCache/MemoryCache/createMemoryCache.ts b/packages/common/dataCache/MemoryCache/createMemoryCache.ts similarity index 70% rename from apps/scandic-web/services/dataCache/MemoryCache/createMemoryCache.ts rename to packages/common/dataCache/MemoryCache/createMemoryCache.ts index 126ef13cc..addf07744 100644 --- a/apps/scandic-web/services/dataCache/MemoryCache/createMemoryCache.ts +++ b/packages/common/dataCache/MemoryCache/createMemoryCache.ts @@ -1,7 +1,6 @@ +import { type DataCache } from "../Cache" import { createInMemoryCache } from "./InMemoryCache" -import type { DataCache } from "@/services/dataCache/Cache" - export function createMemoryCache(): Promise { return createInMemoryCache() } diff --git a/apps/scandic-web/services/dataCache/cacheOrGetOptions.ts b/packages/common/dataCache/cacheOrGetOptions.ts similarity index 100% rename from apps/scandic-web/services/dataCache/cacheOrGetOptions.ts rename to packages/common/dataCache/cacheOrGetOptions.ts diff --git a/apps/scandic-web/services/dataCache/index.ts b/packages/common/dataCache/index.ts similarity index 89% rename from apps/scandic-web/services/dataCache/index.ts rename to packages/common/dataCache/index.ts index c6463b932..1b3b24f30 100644 --- a/apps/scandic-web/services/dataCache/index.ts +++ b/packages/common/dataCache/index.ts @@ -1,7 +1,5 @@ -import { env } from "@/env/server" - -import { isEdge } from "@/utils/isEdge" - +import { env } from "../env/server" +import { isEdge } from "../utils/isEdge" import { createMemoryCache } from "./MemoryCache/createMemoryCache" import { type DataCache } from "./Cache" import { createDistributedCache } from "./DistributedCache" diff --git a/apps/scandic-web/services/dataCache/logger.ts b/packages/common/dataCache/logger.ts similarity index 100% rename from apps/scandic-web/services/dataCache/logger.ts rename to packages/common/dataCache/logger.ts diff --git a/packages/common/env/server.ts b/packages/common/env/server.ts new file mode 100644 index 000000000..eb5701113 --- /dev/null +++ b/packages/common/env/server.ts @@ -0,0 +1,29 @@ +import { createEnv } from "@t3-oss/env-nextjs" +import { z } from "zod" + +export const env = createEnv({ + /** + * Due to t3-env only checking typeof window === "undefined" + * and Netlify running Deno, window is never "undefined" + * https://github.com/t3-oss/t3-env/issues/154 + */ + isServer: true, + server: { + NODE_ENV: z.enum(["development", "test", "production"]), + REDIS_API_HOST: z.string().optional(), + REDIS_API_KEY: z.string().optional(), + BRANCH: + process.env.NODE_ENV !== "development" + ? z.string() + : z.string().optional().default("dev"), + GIT_SHA: z.string().optional(), + }, + emptyStringAsUndefined: true, + runtimeEnv: { + NODE_ENV: process.env.NODE_ENV, + REDIS_API_HOST: process.env.REDIS_API_HOST, + REDIS_API_KEY: process.env.REDIS_API_KEY, + BRANCH: process.env.BRANCH, + GIT_SHA: process.env.GIT_SHA, + }, +}) diff --git a/packages/common/eslint.config.mjs b/packages/common/eslint.config.mjs new file mode 100644 index 000000000..a50c8ee30 --- /dev/null +++ b/packages/common/eslint.config.mjs @@ -0,0 +1,87 @@ +import { FlatCompat } from "@eslint/eslintrc" +import js from "@eslint/js" +import typescriptEslint from "@typescript-eslint/eslint-plugin" +import tsParser from "@typescript-eslint/parser" +import { defineConfig } from "eslint/config" +import simpleImportSort from "eslint-plugin-simple-import-sort" + +const compat = new FlatCompat({ + recommendedConfig: js.configs.recommended, + allConfig: js.configs.all, +}) + +export default defineConfig([ + { + files: ["**/*.ts", "**/*.tsx"], + extends: compat.extends("plugin:import/typescript"), + plugins: { + "simple-import-sort": simpleImportSort, + "@typescript-eslint": typescriptEslint, + }, + + linterOptions: { + reportUnusedDisableDirectives: true, + }, + + languageOptions: { + parser: tsParser, + }, + + rules: { + "no-unused-vars": "off", + + "simple-import-sort/imports": [ + "error", + { + groups: [ + ["^\\u0000"], + ["^node:"], + ["^@?\\w"], + ["^@scandic-hotels/(?!.*\u0000$).*$"], + [ + "^@/constants/?(?!.*\u0000$).*$", + "^@/env/?(?!.*\u0000$).*$", + "^@/lib/?(?!.*\u0000$).*$", + "^@/server/?(?!.*\u0000$).*$", + "^@/stores/?(?!.*\u0000$).*$", + ], + ["^@/(?!(types|.*\u0000$)).*$"], + [ + "^\\.\\.(?!/?$)", + "^\\.\\./?$", + "^\\./(?=.*/)(?!/?$)", + "^\\.(?!/?$)", + "^\\./?$", + ], + ["^(?!\\u0000).+\\.s?css$"], + ["^node:.*\\u0000$", "^@?\\w.*\\u0000$"], + [ + "^@scandichotels/.*\\u0000$", + "^@/types/.*", + "^@/.*\\u0000$", + "^[^.].*\\u0000$", + "^\\..*\\u0000$", + ], + ], + }, + ], + + "simple-import-sort/exports": "error", + + "@typescript-eslint/consistent-type-imports": "error", + + "@typescript-eslint/no-unused-vars": [ + "error", + { + args: "all", + argsIgnorePattern: "^_", + caughtErrors: "all", + caughtErrorsIgnorePattern: "^_", + destructuredArrayIgnorePattern: "^_", + varsIgnorePattern: "^_", + ignoreRestSiblings: true, + }, + ], + }, + }, +]) diff --git a/apps/scandic-web/types/global.d.ts b/packages/common/global.d.ts similarity index 56% rename from apps/scandic-web/types/global.d.ts rename to packages/common/global.d.ts index ee2a717df..c218bf691 100644 --- a/apps/scandic-web/types/global.d.ts +++ b/packages/common/global.d.ts @@ -1,4 +1,4 @@ -import type { DataCache } from "@/services/dataCache" +import type { DataCache } from "./dataCache/Cache" declare global { var cacheClient: Promise | undefined diff --git a/packages/common/lint-staged.config.js b/packages/common/lint-staged.config.js new file mode 100644 index 000000000..e314384e5 --- /dev/null +++ b/packages/common/lint-staged.config.js @@ -0,0 +1,7 @@ +const config = { + "*.{ts,tsx}": [() => "tsc -p tsconfig.json --noEmit", "prettier --write"], + "*.{json,md}": "prettier --write", + "*.{html,js,cjs,mjs,css}": "prettier --write", +} + +export default config diff --git a/packages/common/package.json b/packages/common/package.json new file mode 100644 index 000000000..2d09ed3a9 --- /dev/null +++ b/packages/common/package.json @@ -0,0 +1,39 @@ +{ + "name": "@scandic-hotels/common", + "version": "1.0.0", + "main": "index.ts", + "scripts": { + "test": "vitest run", + "test:watch": "vitest", + "check-types": "tsc --noEmit", + "lint": "eslint . --max-warnings 0 && tsc --noEmit" + }, + "dependencies": { + "@opentelemetry/api": "^1.9.0", + "@sentry/nextjs": "^8.41.0", + "@t3-oss/env-nextjs": "^0.13.4", + "zod": "^3.24.4" + }, + "devDependencies": { + "@eslint/compat": "^1.2.9", + "@eslint/eslintrc": "^3.3.1", + "@eslint/js": "^9.26.0", + "@scandic-hotels/typescript-config": "workspace:*", + "@typescript-eslint/eslint-plugin": "^8.32.0", + "@typescript-eslint/parser": "^8.32.0", + "dotenv": "^16.5.0", + "eslint": "^9", + "eslint-plugin-import": "^2.31.0", + "eslint-plugin-simple-import-sort": "^12.1.1", + "typescript": "5.8.3", + "vitest": "^3.2.3" + }, + "prettier": { + "semi": false, + "trailingComma": "es5", + "singleQuote": false, + "printWidth": 80, + "tabWidth": 2, + "endOfLine": "lf" + } +} diff --git a/packages/common/tsconfig.json b/packages/common/tsconfig.json new file mode 100644 index 000000000..6a51abe8f --- /dev/null +++ b/packages/common/tsconfig.json @@ -0,0 +1,3 @@ +{ + "extends": "@scandic-hotels/typescript-config/base.json" +} diff --git a/apps/scandic-web/utils/isEdge.ts b/packages/common/utils/isEdge.ts similarity index 100% rename from apps/scandic-web/utils/isEdge.ts rename to packages/common/utils/isEdge.ts diff --git a/apps/scandic-web/utils/safeTry.ts b/packages/common/utils/safeTry.ts similarity index 100% rename from apps/scandic-web/utils/safeTry.ts rename to packages/common/utils/safeTry.ts diff --git a/packages/common/vitest-setup.ts b/packages/common/vitest-setup.ts new file mode 100644 index 000000000..ce8f4053c --- /dev/null +++ b/packages/common/vitest-setup.ts @@ -0,0 +1,3 @@ +import { config } from "dotenv" + +config({ path: "./.env.test" }) diff --git a/packages/common/vitest.config.js b/packages/common/vitest.config.js new file mode 100644 index 000000000..dd7db7046 --- /dev/null +++ b/packages/common/vitest.config.js @@ -0,0 +1,17 @@ +import path from "path" +import { fileURLToPath } from "url" +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) + +export default { + test: { + globals: true, + environment: "jsdom", + setupFiles: ["./vitest-setup.ts"], + }, + resolve: { + alias: { + "@": path.resolve(__dirname, "."), + }, + }, +} diff --git a/turbo.json b/turbo.json index 418072746..c166ec478 100644 --- a/turbo.json +++ b/turbo.json @@ -11,6 +11,7 @@ "cache": false }, "lint": {}, - "test": {} + "test": {}, + "check-types": {} } } diff --git a/yarn.lock b/yarn.lock index 4673ed94d..9f1b2d946 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6424,6 +6424,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-android-arm-eabi@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-android-arm-eabi@npm:4.42.0" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + "@rollup/rollup-android-arm64@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-android-arm64@npm:4.34.9" @@ -6438,6 +6445,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-android-arm64@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-android-arm64@npm:4.42.0" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + "@rollup/rollup-darwin-arm64@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-darwin-arm64@npm:4.34.9" @@ -6452,6 +6466,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-darwin-arm64@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-darwin-arm64@npm:4.42.0" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + "@rollup/rollup-darwin-x64@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-darwin-x64@npm:4.34.9" @@ -6466,6 +6487,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-darwin-x64@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-darwin-x64@npm:4.42.0" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + "@rollup/rollup-freebsd-arm64@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-freebsd-arm64@npm:4.34.9" @@ -6480,6 +6508,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-freebsd-arm64@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-freebsd-arm64@npm:4.42.0" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + "@rollup/rollup-freebsd-x64@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-freebsd-x64@npm:4.34.9" @@ -6494,6 +6529,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-freebsd-x64@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-freebsd-x64@npm:4.42.0" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + "@rollup/rollup-linux-arm-gnueabihf@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.34.9" @@ -6508,6 +6550,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm-gnueabihf@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-arm-gnueabihf@npm:4.42.0" + conditions: os=linux & cpu=arm & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-arm-musleabihf@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.34.9" @@ -6522,6 +6571,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm-musleabihf@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-arm-musleabihf@npm:4.42.0" + conditions: os=linux & cpu=arm & libc=musl + languageName: node + linkType: hard + "@rollup/rollup-linux-arm64-gnu@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.34.9" @@ -6536,6 +6592,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm64-gnu@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-arm64-gnu@npm:4.42.0" + conditions: os=linux & cpu=arm64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-arm64-musl@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-arm64-musl@npm:4.34.9" @@ -6550,6 +6613,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-arm64-musl@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-arm64-musl@npm:4.42.0" + conditions: os=linux & cpu=arm64 & libc=musl + languageName: node + linkType: hard + "@rollup/rollup-linux-loongarch64-gnu@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-loongarch64-gnu@npm:4.34.9" @@ -6564,6 +6634,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-loongarch64-gnu@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-loongarch64-gnu@npm:4.42.0" + conditions: os=linux & cpu=loong64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-powerpc64le-gnu@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.34.9" @@ -6578,6 +6655,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-powerpc64le-gnu@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-powerpc64le-gnu@npm:4.42.0" + conditions: os=linux & cpu=ppc64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-riscv64-gnu@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.34.9" @@ -6592,6 +6676,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-riscv64-gnu@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-riscv64-gnu@npm:4.42.0" + conditions: os=linux & cpu=riscv64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-riscv64-musl@npm:4.40.2": version: 4.40.2 resolution: "@rollup/rollup-linux-riscv64-musl@npm:4.40.2" @@ -6599,6 +6690,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-riscv64-musl@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-riscv64-musl@npm:4.42.0" + conditions: os=linux & cpu=riscv64 & libc=musl + languageName: node + linkType: hard + "@rollup/rollup-linux-s390x-gnu@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.34.9" @@ -6613,6 +6711,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-s390x-gnu@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-s390x-gnu@npm:4.42.0" + conditions: os=linux & cpu=s390x & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-x64-gnu@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-linux-x64-gnu@npm:4.34.9" @@ -6627,6 +6732,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-x64-gnu@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-x64-gnu@npm:4.42.0" + conditions: os=linux & cpu=x64 & libc=glibc + languageName: node + linkType: hard + "@rollup/rollup-linux-x64-gnu@npm:4.9.5": version: 4.9.5 resolution: "@rollup/rollup-linux-x64-gnu@npm:4.9.5" @@ -6648,6 +6760,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-linux-x64-musl@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-linux-x64-musl@npm:4.42.0" + conditions: os=linux & cpu=x64 & libc=musl + languageName: node + linkType: hard + "@rollup/rollup-win32-arm64-msvc@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.34.9" @@ -6662,6 +6781,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-win32-arm64-msvc@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-win32-arm64-msvc@npm:4.42.0" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + "@rollup/rollup-win32-ia32-msvc@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.34.9" @@ -6676,6 +6802,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-win32-ia32-msvc@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-win32-ia32-msvc@npm:4.42.0" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + "@rollup/rollup-win32-x64-msvc@npm:4.34.9": version: 4.34.9 resolution: "@rollup/rollup-win32-x64-msvc@npm:4.34.9" @@ -6690,6 +6823,13 @@ __metadata: languageName: node linkType: hard +"@rollup/rollup-win32-x64-msvc@npm:4.42.0": + version: 4.42.0 + resolution: "@rollup/rollup-win32-x64-msvc@npm:4.42.0" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@rtsao/scc@npm:^1.1.0": version: 1.1.0 resolution: "@rtsao/scc@npm:1.1.0" @@ -6806,6 +6946,29 @@ __metadata: languageName: node linkType: hard +"@scandic-hotels/common@workspace:*, @scandic-hotels/common@workspace:packages/common": + version: 0.0.0-use.local + resolution: "@scandic-hotels/common@workspace:packages/common" + dependencies: + "@eslint/compat": "npm:^1.2.9" + "@eslint/eslintrc": "npm:^3.3.1" + "@eslint/js": "npm:^9.26.0" + "@opentelemetry/api": "npm:^1.9.0" + "@scandic-hotels/typescript-config": "workspace:*" + "@sentry/nextjs": "npm:^8.41.0" + "@t3-oss/env-nextjs": "npm:^0.13.4" + "@typescript-eslint/eslint-plugin": "npm:^8.32.0" + "@typescript-eslint/parser": "npm:^8.32.0" + dotenv: "npm:^16.5.0" + eslint: "npm:^9" + eslint-plugin-import: "npm:^2.31.0" + eslint-plugin-simple-import-sort: "npm:^12.1.1" + typescript: "npm:5.8.3" + vitest: "npm:^3.2.3" + zod: "npm:^3.24.4" + languageName: unknown + linkType: soft + "@scandic-hotels/design-system@workspace:*, @scandic-hotels/design-system@workspace:packages/design-system": version: 0.0.0-use.local resolution: "@scandic-hotels/design-system@workspace:packages/design-system" @@ -6919,6 +7082,7 @@ __metadata: "@opentelemetry/sdk-trace-base": "npm:^1.29.0" "@radix-ui/react-slot": "npm:^1.2.2" "@react-aria/ssr": "npm:^3.9.8" + "@scandic-hotels/common": "workspace:*" "@scandic-hotels/design-system": "workspace:*" "@scandic-hotels/typescript-config": "workspace:*" "@sentry/nextjs": "npm:^8.41.0" @@ -8712,6 +8876,15 @@ __metadata: languageName: node linkType: hard +"@types/chai@npm:^5.2.2": + version: 5.2.2 + resolution: "@types/chai@npm:5.2.2" + dependencies: + "@types/deep-eql": "npm:*" + checksum: 10c0/49282bf0e8246800ebb36f17256f97bd3a8c4fb31f92ad3c0eaa7623518d7e87f1eaad4ad206960fcaf7175854bdff4cb167e4fe96811e0081b4ada83dd533ec + languageName: node + linkType: hard + "@types/connect@npm:3.4.36": version: 3.4.36 resolution: "@types/connect@npm:3.4.36" @@ -8737,6 +8910,13 @@ __metadata: languageName: node linkType: hard +"@types/deep-eql@npm:*": + version: 4.0.2 + resolution: "@types/deep-eql@npm:4.0.2" + checksum: 10c0/bf3f811843117900d7084b9d0c852da9a044d12eb40e6de73b552598a6843c21291a8a381b0532644574beecd5e3491c5ff3a0365ab86b15d59862c025384844 + languageName: node + linkType: hard + "@types/doctrine@npm:^0.0.9": version: 0.0.9 resolution: "@types/doctrine@npm:0.0.9" @@ -9573,6 +9753,19 @@ __metadata: languageName: node linkType: hard +"@vitest/expect@npm:3.2.3": + version: 3.2.3 + resolution: "@vitest/expect@npm:3.2.3" + dependencies: + "@types/chai": "npm:^5.2.2" + "@vitest/spy": "npm:3.2.3" + "@vitest/utils": "npm:3.2.3" + chai: "npm:^5.2.0" + tinyrainbow: "npm:^2.0.0" + checksum: 10c0/5eb6278be8f5294779472d1276e150a1b573274441a68c2681c447179abd22af451813fdfbe87e04f5909ca7a0926700f9b79022f227c9816e5d0fa8e0229e15 + languageName: node + linkType: hard + "@vitest/mocker@npm:3.1.3": version: 3.1.3 resolution: "@vitest/mocker@npm:3.1.3" @@ -9592,6 +9785,25 @@ __metadata: languageName: node linkType: hard +"@vitest/mocker@npm:3.2.3": + version: 3.2.3 + resolution: "@vitest/mocker@npm:3.2.3" + dependencies: + "@vitest/spy": "npm:3.2.3" + estree-walker: "npm:^3.0.3" + magic-string: "npm:^0.30.17" + peerDependencies: + msw: ^2.4.9 + vite: ^5.0.0 || ^6.0.0 || ^7.0.0-0 + peerDependenciesMeta: + msw: + optional: true + vite: + optional: true + checksum: 10c0/b670f229c3b1de5561de3cbbecb18f964d4888355d7f1cb8bbff4350b2cfbe477bef834cc2f66af7727ca7dc567540018885eb652f46e0be1cda4015491dc0a9 + languageName: node + linkType: hard + "@vitest/pretty-format@npm:2.0.5": version: 2.0.5 resolution: "@vitest/pretty-format@npm:2.0.5" @@ -9619,6 +9831,15 @@ __metadata: languageName: node linkType: hard +"@vitest/pretty-format@npm:3.2.3, @vitest/pretty-format@npm:^3.2.3": + version: 3.2.3 + resolution: "@vitest/pretty-format@npm:3.2.3" + dependencies: + tinyrainbow: "npm:^2.0.0" + checksum: 10c0/e8fa7b97822c58404bef07d19fa9a49d5b7edb6797dd355584ad7246585bbbe9c55dd1fb05d0c3939b9c15fba05c3e134e2b96ea0cb64ca79a2b9dab60087a6a + languageName: node + linkType: hard + "@vitest/runner@npm:3.1.3": version: 3.1.3 resolution: "@vitest/runner@npm:3.1.3" @@ -9629,6 +9850,17 @@ __metadata: languageName: node linkType: hard +"@vitest/runner@npm:3.2.3": + version: 3.2.3 + resolution: "@vitest/runner@npm:3.2.3" + dependencies: + "@vitest/utils": "npm:3.2.3" + pathe: "npm:^2.0.3" + strip-literal: "npm:^3.0.0" + checksum: 10c0/c20cb6e2ac4fdfb3d4f5136714ea65f9063562d3afaa1574dc82f53d061444bc01583f9915346768ca75f5ea0658f02fb594752e21abbca5ab50290f58732147 + languageName: node + linkType: hard + "@vitest/snapshot@npm:3.1.3": version: 3.1.3 resolution: "@vitest/snapshot@npm:3.1.3" @@ -9640,6 +9872,17 @@ __metadata: languageName: node linkType: hard +"@vitest/snapshot@npm:3.2.3": + version: 3.2.3 + resolution: "@vitest/snapshot@npm:3.2.3" + dependencies: + "@vitest/pretty-format": "npm:3.2.3" + magic-string: "npm:^0.30.17" + pathe: "npm:^2.0.3" + checksum: 10c0/f6dd0248afb3f3cbcbbb9fd39c2c8273c4ec92176f65e6ba9d36a0c33552d3658013e3a02944e14c7637f51d6702a5c07963b59707ca459bd1ac31f39c81160c + languageName: node + linkType: hard + "@vitest/spy@npm:2.0.5": version: 2.0.5 resolution: "@vitest/spy@npm:2.0.5" @@ -9658,6 +9901,15 @@ __metadata: languageName: node linkType: hard +"@vitest/spy@npm:3.2.3": + version: 3.2.3 + resolution: "@vitest/spy@npm:3.2.3" + dependencies: + tinyspy: "npm:^4.0.3" + checksum: 10c0/ce77d5934ac4741513993aad9d8ff44ff03ff5cf5a177e010c7ffcd8d3060087e56df1938c1100d49de712daf952cd2c72dd83e1684d043e698bd2afe0025f5e + languageName: node + linkType: hard + "@vitest/utils@npm:2.0.5": version: 2.0.5 resolution: "@vitest/utils@npm:2.0.5" @@ -9681,6 +9933,17 @@ __metadata: languageName: node linkType: hard +"@vitest/utils@npm:3.2.3": + version: 3.2.3 + resolution: "@vitest/utils@npm:3.2.3" + dependencies: + "@vitest/pretty-format": "npm:3.2.3" + loupe: "npm:^3.1.3" + tinyrainbow: "npm:^2.0.0" + checksum: 10c0/c7a785a73bc0d7c0202ced0d9912639b9deb6f05dd6c25700a13d97e13320ccec57660f11ad1f9225419ac485339fdf7af28c8d77456bcb9558e6c7d73ad538a + languageName: node + linkType: hard + "@vitest/utils@npm:^2.1.1": version: 2.1.9 resolution: "@vitest/utils@npm:2.1.9" @@ -11986,6 +12249,18 @@ __metadata: languageName: node linkType: hard +"debug@npm:^4.4.1": + version: 4.4.1 + resolution: "debug@npm:4.4.1" + dependencies: + ms: "npm:^2.1.3" + peerDependenciesMeta: + supports-color: + optional: true + checksum: 10c0/d2b44bc1afd912b49bb7ebb0d50a860dc93a4dd7d946e8de94abc957bb63726b7dd5aa48c18c2386c379ec024c46692e15ed3ed97d481729f929201e671fcd55 + languageName: node + linkType: hard + "decimal.js@npm:10, decimal.js@npm:^10.4.2, decimal.js@npm:^10.4.3": version: 10.5.0 resolution: "decimal.js@npm:10.5.0" @@ -13684,6 +13959,18 @@ __metadata: languageName: node linkType: hard +"fdir@npm:^6.4.5": + version: 6.4.6 + resolution: "fdir@npm:6.4.6" + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + checksum: 10c0/45b559cff889934ebb8bc498351e5acba40750ada7e7d6bde197768d2fa67c149be8ae7f8ff34d03f4e1eb20f2764116e56440aaa2f6689e9a4aa7ef06acafe9 + languageName: node + linkType: hard + "fetch-mock@npm:^12.5.2": version: 12.5.2 resolution: "fetch-mock@npm:12.5.2" @@ -16102,6 +16389,13 @@ __metadata: languageName: node linkType: hard +"js-tokens@npm:^9.0.1": + version: 9.0.1 + resolution: "js-tokens@npm:9.0.1" + checksum: 10c0/68dcab8f233dde211a6b5fd98079783cbcd04b53617c1250e3553ee16ab3e6134f5e65478e41d82f6d351a052a63d71024553933808570f04dbf828d7921e80e + languageName: node + linkType: hard + "js-yaml@npm:^3.13.1": version: 3.14.1 resolution: "js-yaml@npm:3.14.1" @@ -17839,6 +18133,15 @@ __metadata: languageName: node linkType: hard +"nanoid@npm:^3.3.11": + version: 3.3.11 + resolution: "nanoid@npm:3.3.11" + bin: + nanoid: bin/nanoid.cjs + checksum: 10c0/40e7f70b3d15f725ca072dfc4f74e81fcf1fbb02e491cf58ac0c79093adc9b0a73b152bcde57df4b79cd097e13023d7504acb38404a4da7bc1cd8e887b82fe0b + languageName: node + linkType: hard + "nanoid@npm:^5.1.5": version: 5.1.5 resolution: "nanoid@npm:5.1.5" @@ -19041,6 +19344,17 @@ __metadata: languageName: node linkType: hard +"postcss@npm:^8.5.4": + version: 8.5.4 + resolution: "postcss@npm:8.5.4" + dependencies: + nanoid: "npm:^3.3.11" + picocolors: "npm:^1.1.1" + source-map-js: "npm:^1.2.1" + checksum: 10c0/0feff648614a834f7cd5396ea6b05b658ca0507e10a4eaad03b56c348f6aec93f42a885fc1b30522630c6a7e49ae53b38a061e3cba526f2d9857afbe095a22bb + languageName: node + linkType: hard + "postgres-array@npm:~2.0.0": version: 2.0.0 resolution: "postgres-array@npm:2.0.0" @@ -20432,6 +20746,81 @@ __metadata: languageName: node linkType: hard +"rollup@npm:^4.40.0": + version: 4.42.0 + resolution: "rollup@npm:4.42.0" + dependencies: + "@rollup/rollup-android-arm-eabi": "npm:4.42.0" + "@rollup/rollup-android-arm64": "npm:4.42.0" + "@rollup/rollup-darwin-arm64": "npm:4.42.0" + "@rollup/rollup-darwin-x64": "npm:4.42.0" + "@rollup/rollup-freebsd-arm64": "npm:4.42.0" + "@rollup/rollup-freebsd-x64": "npm:4.42.0" + "@rollup/rollup-linux-arm-gnueabihf": "npm:4.42.0" + "@rollup/rollup-linux-arm-musleabihf": "npm:4.42.0" + "@rollup/rollup-linux-arm64-gnu": "npm:4.42.0" + "@rollup/rollup-linux-arm64-musl": "npm:4.42.0" + "@rollup/rollup-linux-loongarch64-gnu": "npm:4.42.0" + "@rollup/rollup-linux-powerpc64le-gnu": "npm:4.42.0" + "@rollup/rollup-linux-riscv64-gnu": "npm:4.42.0" + "@rollup/rollup-linux-riscv64-musl": "npm:4.42.0" + "@rollup/rollup-linux-s390x-gnu": "npm:4.42.0" + "@rollup/rollup-linux-x64-gnu": "npm:4.42.0" + "@rollup/rollup-linux-x64-musl": "npm:4.42.0" + "@rollup/rollup-win32-arm64-msvc": "npm:4.42.0" + "@rollup/rollup-win32-ia32-msvc": "npm:4.42.0" + "@rollup/rollup-win32-x64-msvc": "npm:4.42.0" + "@types/estree": "npm:1.0.7" + fsevents: "npm:~2.3.2" + dependenciesMeta: + "@rollup/rollup-android-arm-eabi": + optional: true + "@rollup/rollup-android-arm64": + optional: true + "@rollup/rollup-darwin-arm64": + optional: true + "@rollup/rollup-darwin-x64": + optional: true + "@rollup/rollup-freebsd-arm64": + optional: true + "@rollup/rollup-freebsd-x64": + optional: true + "@rollup/rollup-linux-arm-gnueabihf": + optional: true + "@rollup/rollup-linux-arm-musleabihf": + optional: true + "@rollup/rollup-linux-arm64-gnu": + optional: true + "@rollup/rollup-linux-arm64-musl": + optional: true + "@rollup/rollup-linux-loongarch64-gnu": + optional: true + "@rollup/rollup-linux-powerpc64le-gnu": + optional: true + "@rollup/rollup-linux-riscv64-gnu": + optional: true + "@rollup/rollup-linux-riscv64-musl": + optional: true + "@rollup/rollup-linux-s390x-gnu": + optional: true + "@rollup/rollup-linux-x64-gnu": + optional: true + "@rollup/rollup-linux-x64-musl": + optional: true + "@rollup/rollup-win32-arm64-msvc": + optional: true + "@rollup/rollup-win32-ia32-msvc": + optional: true + "@rollup/rollup-win32-x64-msvc": + optional: true + fsevents: + optional: true + bin: + rollup: dist/bin/rollup + checksum: 10c0/160fdb0874af5f0f619987b4e9abb3b136fc154f759762bfde4d65d864d6d06594ae7d1d8e6d4558d1b8ef329aaa6a8de543e90feead3d872db15cf61f78426c + languageName: node + linkType: hard + "router@npm:^2.2.0": version: 2.2.0 resolution: "router@npm:2.2.0" @@ -21622,6 +22011,15 @@ __metadata: languageName: node linkType: hard +"strip-literal@npm:^3.0.0": + version: 3.0.0 + resolution: "strip-literal@npm:3.0.0" + dependencies: + js-tokens: "npm:^9.0.1" + checksum: 10c0/d81657f84aba42d4bbaf2a677f7e7f34c1f3de5a6726db8bc1797f9c0b303ba54d4660383a74bde43df401cf37cce1dff2c842c55b077a4ceee11f9e31fba828 + languageName: node + linkType: hard + "stubborn-fs@npm:^1.2.5": version: 1.2.5 resolution: "stubborn-fs@npm:1.2.5" @@ -21919,6 +22317,16 @@ __metadata: languageName: node linkType: hard +"tinyglobby@npm:^0.2.14": + version: 0.2.14 + resolution: "tinyglobby@npm:0.2.14" + dependencies: + fdir: "npm:^6.4.4" + picomatch: "npm:^4.0.2" + checksum: 10c0/f789ed6c924287a9b7d3612056ed0cda67306cd2c80c249fd280cf1504742b12583a2089b61f4abbd24605f390809017240e250241f09938054c9b363e51c0a6 + languageName: node + linkType: hard + "tinypool@npm:^1.0.2": version: 1.0.2 resolution: "tinypool@npm:1.0.2" @@ -21926,6 +22334,13 @@ __metadata: languageName: node linkType: hard +"tinypool@npm:^1.1.0": + version: 1.1.0 + resolution: "tinypool@npm:1.1.0" + checksum: 10c0/deb6bde5e3d85d4ba043806c66f43fb5b649716312a47b52761a83668ffc71cd0ea4e24254c1b02a3702e5c27e02605f0189a1460f6284a5930a08bd0c06435c + languageName: node + linkType: hard + "tinyrainbow@npm:^1.2.0": version: 1.2.0 resolution: "tinyrainbow@npm:1.2.0" @@ -21947,6 +22362,13 @@ __metadata: languageName: node linkType: hard +"tinyspy@npm:^4.0.3": + version: 4.0.3 + resolution: "tinyspy@npm:4.0.3" + checksum: 10c0/0a92a18b5350945cc8a1da3a22c9ad9f4e2945df80aaa0c43e1b3a3cfb64d8501e607ebf0305e048e3c3d3e0e7f8eb10cea27dc17c21effb73e66c4a3be36373 + languageName: node + linkType: hard + "tldts-core@npm:^6.1.78": version: 6.1.78 resolution: "tldts-core@npm:6.1.78" @@ -22908,6 +23330,21 @@ __metadata: languageName: node linkType: hard +"vite-node@npm:3.2.3": + version: 3.2.3 + resolution: "vite-node@npm:3.2.3" + dependencies: + cac: "npm:^6.7.14" + debug: "npm:^4.4.1" + es-module-lexer: "npm:^1.7.0" + pathe: "npm:^2.0.3" + vite: "npm:^5.0.0 || ^6.0.0 || ^7.0.0-0" + bin: + vite-node: vite-node.mjs + checksum: 10c0/b952b0d9e45662506ea7303ac87d08e02f1e3355777cf7d426f211292c4f87e8837aef589e552bb11404d1bc0a9bd18871ce6ba874b5f0bb171f8e010de20a11 + languageName: node + linkType: hard + "vite-plugin-dts@npm:^4.5.3": version: 4.5.3 resolution: "vite-plugin-dts@npm:4.5.3" @@ -22996,6 +23433,61 @@ __metadata: languageName: node linkType: hard +"vite@npm:^5.0.0 || ^6.0.0 || ^7.0.0-0": + version: 7.0.0-beta.1 + resolution: "vite@npm:7.0.0-beta.1" + dependencies: + esbuild: "npm:^0.25.0" + fdir: "npm:^6.4.5" + fsevents: "npm:~2.3.3" + picomatch: "npm:^4.0.2" + postcss: "npm:^8.5.4" + rollup: "npm:^4.40.0" + tinyglobby: "npm:^0.2.14" + peerDependencies: + "@types/node": ^20.19.0 || >=22.12.0 + jiti: ">=1.21.0" + less: ^4.0.0 + lightningcss: ^1.21.0 + sass: ^1.70.0 + sass-embedded: ^1.70.0 + stylus: ">=0.54.8" + sugarss: ^5.0.0 + terser: ^5.16.0 + tsx: ^4.8.1 + yaml: ^2.4.2 + dependenciesMeta: + fsevents: + optional: true + peerDependenciesMeta: + "@types/node": + optional: true + jiti: + optional: true + less: + optional: true + lightningcss: + optional: true + sass: + optional: true + sass-embedded: + optional: true + stylus: + optional: true + sugarss: + optional: true + terser: + optional: true + tsx: + optional: true + yaml: + optional: true + bin: + vite: bin/vite.js + checksum: 10c0/0ab20103182244b310fb2bb4a9f3fb21110a61328052e73accfebf3503270bddd1d19417c2d17bd93f1108125da5ffbc52a1f05c8bf3f564907919ffc64d3d78 + languageName: node + linkType: hard + "vite@npm:^6.3.5": version: 6.3.5 resolution: "vite@npm:6.3.5" @@ -23105,6 +23597,62 @@ __metadata: languageName: node linkType: hard +"vitest@npm:^3.2.3": + version: 3.2.3 + resolution: "vitest@npm:3.2.3" + dependencies: + "@types/chai": "npm:^5.2.2" + "@vitest/expect": "npm:3.2.3" + "@vitest/mocker": "npm:3.2.3" + "@vitest/pretty-format": "npm:^3.2.3" + "@vitest/runner": "npm:3.2.3" + "@vitest/snapshot": "npm:3.2.3" + "@vitest/spy": "npm:3.2.3" + "@vitest/utils": "npm:3.2.3" + chai: "npm:^5.2.0" + debug: "npm:^4.4.1" + expect-type: "npm:^1.2.1" + magic-string: "npm:^0.30.17" + pathe: "npm:^2.0.3" + picomatch: "npm:^4.0.2" + std-env: "npm:^3.9.0" + tinybench: "npm:^2.9.0" + tinyexec: "npm:^0.3.2" + tinyglobby: "npm:^0.2.14" + tinypool: "npm:^1.1.0" + tinyrainbow: "npm:^2.0.0" + vite: "npm:^5.0.0 || ^6.0.0 || ^7.0.0-0" + vite-node: "npm:3.2.3" + why-is-node-running: "npm:^2.3.0" + peerDependencies: + "@edge-runtime/vm": "*" + "@types/debug": ^4.1.12 + "@types/node": ^18.0.0 || ^20.0.0 || >=22.0.0 + "@vitest/browser": 3.2.3 + "@vitest/ui": 3.2.3 + happy-dom: "*" + jsdom: "*" + peerDependenciesMeta: + "@edge-runtime/vm": + optional: true + "@types/debug": + optional: true + "@types/node": + optional: true + "@vitest/browser": + optional: true + "@vitest/ui": + optional: true + happy-dom: + optional: true + jsdom: + optional: true + bin: + vitest: vitest.mjs + checksum: 10c0/1d853016622f32020e91cc72348d0dc642bde2ddcbd648655a9d33d420375c7cbd6f1a6f5c4398a5d4f59b8c2b120e62eba49fb37f8042e5d4c688b7e60148ef + languageName: node + linkType: hard + "vscode-uri@npm:^3.0.8": version: 3.1.0 resolution: "vscode-uri@npm:3.1.0"