Merged in feat/sw-2866-move-partners-router-to-trpc-package (pull request #2414)
feat(sw-2866): Move partners router to trpc package * Add eslint to trpc package * Apply lint rules * Use direct imports from trpc package * Add lint-staged config to trpc * Move lang enum to common * Restructure trpc package folder structure * WIP first step * update internal imports in trpc * Fix most errors in scandic-web Just 100 left... * Move Props type out of trpc * Fix CategorizedFilters types * Move more schemas in hotel router * Fix deps * fix getNonContentstackUrls * Fix import error * Fix entry error handling * Fix generateMetadata metrics * Fix alertType enum * Fix duplicated types * lint:fix * Merge branch 'master' into feat/sw-2863-move-contentstack-router-to-trpc-package * Fix broken imports * Move booking router to trpc package * Move partners router to trpc package * Merge branch 'master' into feat/sw-2866-move-partners-router-to-trpc-package Approved-by: Linus Flood
This commit is contained in:
@@ -3,11 +3,12 @@ import { redirect } from "next/navigation"
|
||||
import { z } from "zod"
|
||||
|
||||
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||
import { SAS_TOKEN_STORAGE_KEY } from "@scandic-hotels/trpc/constants/partnerSAS"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import { SAS_TOKEN_STORAGE_KEY, stateSchema } from "../sasUtils"
|
||||
import { stateSchema } from "../sasUtils"
|
||||
|
||||
import type { NextRequest } from "next/server"
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ import Loading from "./loading"
|
||||
|
||||
import styles from "./OneTimePasswordForm.module.css"
|
||||
|
||||
import type { RequestOtpError } from "@/server/routers/partners/sas/otp/request/requestOtpError"
|
||||
import type { RequestOtpError } from "@scandic-hotels/trpc/routers/partners/sas/otp/request/requestOtpError"
|
||||
|
||||
import type { OtpError } from "./page"
|
||||
|
||||
type Redirect = { url: string; type?: "replace" | "push" }
|
||||
|
||||
@@ -3,13 +3,16 @@ import { redirect } from "next/navigation"
|
||||
import { z } from "zod"
|
||||
|
||||
import { safeTry } from "@scandic-hotels/common/utils/safeTry"
|
||||
import {
|
||||
SAS_TOKEN_STORAGE_KEY,
|
||||
SAS_TRANSFER_POINT_KEY,
|
||||
} from "@scandic-hotels/trpc/constants/partnerSAS"
|
||||
|
||||
import { myPages } from "@/constants/routes/myPages"
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import { getIntl } from "@/i18n"
|
||||
|
||||
import { SAS_TOKEN_STORAGE_KEY, SAS_TRANSFER_POINT_KEY } from "../sasUtils"
|
||||
import OneTimePasswordForm, {
|
||||
type OnSubmitHandler,
|
||||
} from "./OneTimePasswordForm"
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { z } from "zod"
|
||||
|
||||
export const SAS_TOKEN_STORAGE_KEY = "sas-x-scandic-token"
|
||||
export const SAS_TRANSFER_POINT_KEY = "sas-x-scandic-eb-points"
|
||||
|
||||
export const stateSchema = z.object({
|
||||
intent: z.enum(["link", "unlink", "transfer"]),
|
||||
})
|
||||
|
||||
@@ -18,8 +18,8 @@ import { useIntl } from "react-intl"
|
||||
import { MaterialIcon } from "@scandic-hotels/design-system/Icons/MaterialIcon"
|
||||
import { Input } from "@scandic-hotels/design-system/Input"
|
||||
import { Typography } from "@scandic-hotels/design-system/Typography"
|
||||
import { SAS_TRANSFER_POINT_KEY } from "@scandic-hotels/trpc/constants/partnerSAS"
|
||||
|
||||
import { SAS_TRANSFER_POINT_KEY } from "@/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/sasUtils"
|
||||
import Image from "@/components/Image"
|
||||
import Modal from "@/components/Modal"
|
||||
import Button from "@/components/TempDesignSystem/Button"
|
||||
|
||||
@@ -2,16 +2,6 @@ import { MembershipLevelEnum } from "@scandic-hotels/common/constants/membership
|
||||
|
||||
import type { EurobonusTier } from "@scandic-hotels/trpc/types/user"
|
||||
|
||||
export const FriendsMembershipLevels = [
|
||||
"L1",
|
||||
"L2",
|
||||
"L3",
|
||||
"L4",
|
||||
"L5",
|
||||
"L6",
|
||||
"L7",
|
||||
] as const
|
||||
|
||||
export enum membershipLevels {
|
||||
L1 = 1,
|
||||
L2 = 2,
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
import { router } from "@scandic-hotels/trpc"
|
||||
import { contentstackRouter } from "@scandic-hotels/trpc/routers/contentstack"
|
||||
import { hotelsRouter } from "@scandic-hotels/trpc/routers/hotels"
|
||||
import { partnerRouter } from "@scandic-hotels/trpc/routers/partners"
|
||||
|
||||
import { autocompleteRouter } from "./routers/autocomplete"
|
||||
import { bookingRouter } from "./routers/booking"
|
||||
import { navigationRouter } from "./routers/navigation"
|
||||
import { partnerRouter } from "./routers/partners"
|
||||
import { userRouter } from "./routers/user"
|
||||
|
||||
export const appRouter = router({
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
import { describe, expect, it } from "@jest/globals"
|
||||
|
||||
import { parseSASRequestOtpError } from "./requestOtpError"
|
||||
|
||||
describe("requestOtpError", () => {
|
||||
it("parses error with invalid error code", () => {
|
||||
const actual = parseSASRequestOtpError({
|
||||
status: "status",
|
||||
error: "error",
|
||||
errorCode: "a" as unknown as number,
|
||||
databaseUUID: "9ffefefe-df0e-4229-9792-5ed31bef1db4",
|
||||
} as any)
|
||||
expect(actual).toEqual({
|
||||
errorCode: "UNKNOWN",
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,24 +0,0 @@
|
||||
import { describe, expect, it } from "@jest/globals"
|
||||
|
||||
import { parseSASVerifyOtpError } from "./verifyOtpError"
|
||||
|
||||
describe("verifyOtpError", () => {
|
||||
it("parses error with invalid error code", () => {
|
||||
const error = {
|
||||
status: "status",
|
||||
error: "error",
|
||||
errorCode: "a",
|
||||
databaseUUID: "9ffefefe-df0e-4229-9792-5ed31bef1db4",
|
||||
}
|
||||
|
||||
const actual = parseSASVerifyOtpError({
|
||||
status: "status",
|
||||
error: "error",
|
||||
errorCode: "a" as unknown as number,
|
||||
databaseUUID: "9ffefefe-df0e-4229-9792-5ed31bef1db4",
|
||||
} as any)
|
||||
expect(actual).toEqual({
|
||||
errorCode: "UNKNOWN",
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -1,5 +1,4 @@
|
||||
import type { jobylonItemSchema } from "@scandic-hotels/trpc/routers/partners/jobylon/output"
|
||||
import type { z } from "zod"
|
||||
|
||||
import type { jobylonItemSchema } from "@/server/routers/partners/jobylon/output"
|
||||
|
||||
export interface JobylonItem extends z.output<typeof jobylonItemSchema> {}
|
||||
|
||||
@@ -1,3 +1,13 @@
|
||||
export const FriendsMembershipLevels = [
|
||||
"L1",
|
||||
"L2",
|
||||
"L3",
|
||||
"L4",
|
||||
"L5",
|
||||
"L6",
|
||||
"L7",
|
||||
] as const
|
||||
|
||||
export enum MembershipLevelEnum {
|
||||
L1 = "L1",
|
||||
L2 = "L2",
|
||||
|
||||
8
packages/trpc/env/server.ts
vendored
8
packages/trpc/env/server.ts
vendored
@@ -16,6 +16,10 @@ export const env = createEnv({
|
||||
isServer: typeof window === "undefined" || "Deno" in window,
|
||||
server: {
|
||||
API_BASEURL: z.string(),
|
||||
SAS_API_ENDPOINT: z.string().default(""),
|
||||
SAS_AUTH_ENDPOINT: z.string().default(""),
|
||||
SAS_OCP_APIM: z.string().default(""),
|
||||
SAS_AUTH_CLIENTID: z.string().default(""),
|
||||
CACHE_TIME_HOTELS: z.coerce
|
||||
.number()
|
||||
.default(TWENTYFOUR_HOURS)
|
||||
@@ -43,6 +47,10 @@ export const env = createEnv({
|
||||
emptyStringAsUndefined: true,
|
||||
runtimeEnv: {
|
||||
API_BASEURL: process.env.API_BASEURL,
|
||||
SAS_API_ENDPOINT: process.env.SAS_API_ENDPOINT,
|
||||
SAS_AUTH_ENDPOINT: process.env.SAS_AUTH_ENDPOINT,
|
||||
SAS_OCP_APIM: process.env.SAS_OCP_APIM,
|
||||
SAS_AUTH_CLIENTID: process.env.SAS_AUTH_CLIENTID,
|
||||
CACHE_TIME_HOTELS: process.env.CACHE_TIME_HOTELS,
|
||||
CACHE_TIME_CITY_SEARCH: process.env.CACHE_TIME_CITY_SEARCH,
|
||||
NODE_ENV: process.env.NODE_ENV,
|
||||
|
||||
2
packages/trpc/lib/constants/partnerSAS.ts
Normal file
2
packages/trpc/lib/constants/partnerSAS.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const SAS_TOKEN_STORAGE_KEY = "sas-x-scandic-token"
|
||||
export const SAS_TRANSFER_POINT_KEY = "sas-x-scandic-eb-points"
|
||||
@@ -6,6 +6,9 @@ import { selectRate } from "@scandic-hotels/common/constants/routes/hotelReserva
|
||||
import { getCacheClient } from "@scandic-hotels/common/dataCache"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
import { chunk } from "@scandic-hotels/common/utils/chunk"
|
||||
import { RoomPackageCodeEnum } from "@scandic-hotels/trpc/enums/roomFilter"
|
||||
import { AvailabilityEnum } from "@scandic-hotels/trpc/enums/selectHotel"
|
||||
import { type RoomFeaturesInput } from "@scandic-hotels/trpc/routers/hotels/input"
|
||||
import {
|
||||
hotelsAvailabilitySchema,
|
||||
packagesSchema,
|
||||
@@ -20,8 +23,6 @@ import { REDEMPTION } from "../../constants/booking"
|
||||
import { cache } from "../../DUPLICATED/cache"
|
||||
import { BookingErrorCodeEnum } from "../../enums/bookingErrorCode"
|
||||
import { HotelTypeEnum } from "../../enums/hotelType"
|
||||
import { RoomPackageCodeEnum } from "../../enums/roomFilter"
|
||||
import { AvailabilityEnum } from "../../enums/selectHotel"
|
||||
import { badRequestError } from "../../errors"
|
||||
import { toApiLang } from "../../utils"
|
||||
import { getHotelPageUrls } from "../contentstack/hotelPage/utils"
|
||||
@@ -60,9 +61,7 @@ import type {
|
||||
CityLocation,
|
||||
} from "../../types/locations"
|
||||
import type { PackagesOutput } from "../../types/packages"
|
||||
import type { RoomFeaturesInput } from "./input"
|
||||
import type { Cities } from "./output"
|
||||
|
||||
export const locationsAffix = "locations"
|
||||
|
||||
export async function getCitiesByCountry({
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { router } from "@scandic-hotels/trpc"
|
||||
|
||||
import { router } from "../.."
|
||||
import { jobylonQueryRouter } from "./jobylon/query"
|
||||
import { sasRouter } from "./sas"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { getCacheClient } from "@scandic-hotels/common/dataCache"
|
||||
import { createCounter } from "@scandic-hotels/common/telemetry"
|
||||
import { router } from "@scandic-hotels/trpc"
|
||||
import { publicProcedure } from "@scandic-hotels/trpc/procedures"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { publicProcedure } from "../../../procedures"
|
||||
import { jobylonFeedSchema } from "./output"
|
||||
|
||||
export const TWENTYFOUR_HOURS = 60 * 60 * 24
|
||||
@@ -1,6 +1,6 @@
|
||||
import { cookies } from "next/headers"
|
||||
|
||||
import { SAS_TOKEN_STORAGE_KEY } from "@/app/[lang]/(partner)/(sas)/(protected)/sas-x-scandic/sasUtils"
|
||||
import { SAS_TOKEN_STORAGE_KEY } from "../../../constants/partnerSAS"
|
||||
|
||||
export async function getSasToken() {
|
||||
const cookieStore = await cookies()
|
||||
@@ -1,5 +1,4 @@
|
||||
import { router } from "@scandic-hotels/trpc"
|
||||
|
||||
import { router } from "../../.."
|
||||
import { requestOtp } from "./otp/request/requestOtp"
|
||||
import { verifyOtp } from "./otp/verify/verifyOtp"
|
||||
import { linkAccount } from "./linkAccount"
|
||||
@@ -1,9 +1,8 @@
|
||||
import * as Sentry from "@sentry/nextjs"
|
||||
import { z } from "zod"
|
||||
|
||||
import * as api from "@scandic-hotels/trpc/api"
|
||||
import { protectedProcedure } from "@scandic-hotels/trpc/procedures"
|
||||
|
||||
import * as api from "../../../api"
|
||||
import { protectedProcedure } from "../../../procedures"
|
||||
import { getOTPState } from "./otp/getOTPState"
|
||||
import { getSasToken } from "./getSasToken"
|
||||
|
||||
@@ -4,10 +4,8 @@ import { cookies } from "next/headers"
|
||||
import { v4 as uuidv4 } from "uuid"
|
||||
import { z } from "zod"
|
||||
|
||||
import { protectedProcedure } from "@scandic-hotels/trpc/procedures"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
|
||||
import { env } from "../../../../../../env/server"
|
||||
import { protectedProcedure } from "../../../../../procedures"
|
||||
import { getSasToken } from "../../getSasToken"
|
||||
import { SAS_REQUEST_OTP_STATE_STORAGE_COOKIE_NAME } from "../constants"
|
||||
import {
|
||||
@@ -1,10 +1,8 @@
|
||||
import { TRPCError } from "@trpc/server"
|
||||
import { z } from "zod"
|
||||
|
||||
import { protectedProcedure } from "@scandic-hotels/trpc/procedures"
|
||||
|
||||
import { env } from "@/env/server"
|
||||
|
||||
import { env } from "../../../../../../env/server"
|
||||
import { protectedProcedure } from "../../../../../procedures"
|
||||
import { getSasToken } from "../../getSasToken"
|
||||
import { getOTPState } from "../getOTPState"
|
||||
import {
|
||||
@@ -2,14 +2,14 @@ import * as Sentry from "@sentry/nextjs"
|
||||
import { cookies } from "next/headers"
|
||||
import { z } from "zod"
|
||||
|
||||
import * as api from "@scandic-hotels/trpc/api"
|
||||
import { protectedProcedure } from "@scandic-hotels/trpc/procedures"
|
||||
import { getUserSchema } from "@scandic-hotels/trpc/routers/user/output"
|
||||
import { getVerifiedUser } from "@scandic-hotels/trpc/routers/user/utils"
|
||||
import { FriendsMembershipLevels } from "@scandic-hotels/common/constants/membershipLevels"
|
||||
|
||||
import { FriendsMembershipLevels } from "@/constants/membershipLevels"
|
||||
import * as api from "../../../api"
|
||||
import { protectedProcedure } from "../../../procedures"
|
||||
import { getUserSchema } from "../../user/output"
|
||||
import { getVerifiedUser } from "../../user/utils"
|
||||
|
||||
import type { FriendsTier } from "@scandic-hotels/trpc/types/user"
|
||||
import type { FriendsTier } from "../../../types/user"
|
||||
|
||||
const matchedSchema = z.object({
|
||||
tierMatchState: z.enum(["matched"]),
|
||||
@@ -1,9 +1,8 @@
|
||||
import * as Sentry from "@sentry/nextjs"
|
||||
import { z } from "zod"
|
||||
|
||||
import * as api from "@scandic-hotels/trpc/api"
|
||||
import { protectedProcedure } from "@scandic-hotels/trpc/procedures"
|
||||
|
||||
import * as api from "../../../api"
|
||||
import { protectedProcedure } from "../../../procedures"
|
||||
import { getOTPState } from "./otp/getOTPState"
|
||||
import { getSasToken } from "./getSasToken"
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { z } from "zod"
|
||||
|
||||
import * as api from "@scandic-hotels/trpc/api"
|
||||
import { protectedProcedure } from "@scandic-hotels/trpc/procedures"
|
||||
|
||||
import * as api from "../../../api"
|
||||
import { protectedProcedure } from "../../../procedures"
|
||||
import { getOTPState } from "./otp/getOTPState"
|
||||
import { getSasToken } from "./getSasToken"
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
"./routers/hotels/*": "./lib/routers/hotels/*.ts",
|
||||
"./routers/booking/*": "./lib/routers/booking/*.ts",
|
||||
"./routers/user/*": "./lib/routers/user/*.ts",
|
||||
"./routers/partners/*": "./lib/routers/partners/*.ts",
|
||||
"./enums/*": "./lib/enums/*.ts",
|
||||
"./types/*": "./lib/types/*.ts",
|
||||
"./constants/*": "./lib/constants/*.ts",
|
||||
@@ -49,12 +50,15 @@
|
||||
"graphql-request": "^7.1.2",
|
||||
"json-stable-stringify-without-jsonify": "^1.0.1",
|
||||
"next-auth": "5.0.0-beta.27",
|
||||
"react": "19.1.0",
|
||||
"server-only": "^0.0.1",
|
||||
"slugify": "^1.6.6",
|
||||
"superjson": "^2.2.2",
|
||||
"zod": "^3.24.4"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"next": "^15",
|
||||
"react": "^19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^1.2.9",
|
||||
"@eslint/eslintrc": "^3.3.1",
|
||||
|
||||
@@ -7262,12 +7262,14 @@ __metadata:
|
||||
graphql-request: "npm:^7.1.2"
|
||||
json-stable-stringify-without-jsonify: "npm:^1.0.1"
|
||||
next-auth: "npm:5.0.0-beta.27"
|
||||
react: "npm:19.1.0"
|
||||
server-only: "npm:^0.0.1"
|
||||
slugify: "npm:^1.6.6"
|
||||
superjson: "npm:^2.2.2"
|
||||
typescript: "npm:5.8.3"
|
||||
zod: "npm:^3.24.4"
|
||||
peerDependencies:
|
||||
next: ^15
|
||||
react: ^19
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
|
||||
Reference in New Issue
Block a user