From c0039190bd9ab3e4738bcb610a2fa97773895d67 Mon Sep 17 00:00:00 2001 From: Owen Date: Tue, 14 Oct 2025 11:28:56 -0700 Subject: [PATCH] Fix frontend type imports --- .../generatedLicense/generateNewLicense.ts | 20 +---------- .../generatedLicense/listGeneratedLicenses.ts | 13 +------- .../routers/license/activateLicense.ts | 3 -- .../routers/license/deleteLicenseKey.ts | 3 -- .../routers/license/getLicenseStatus.ts | 4 +-- .../routers/license/listLicenseKeys.ts | 4 +-- .../private/routers/license/recheckStatus.ts | 3 -- server/routers/badger/verifySession.ts | 33 ------------------- server/routers/generatedLicense/types.ts | 30 +++++++++++++++++ server/routers/license/types.ts | 11 +++++++ .../settings/(private)/license/page.tsx | 2 +- src/app/layout.tsx | 2 +- src/components/GenerateLicenseKeyForm.tsx | 9 +---- src/components/GenerateLicenseKeysTable.tsx | 4 +-- tsconfig.json | 2 +- 15 files changed, 50 insertions(+), 93 deletions(-) create mode 100644 server/routers/generatedLicense/types.ts create mode 100644 server/routers/license/types.ts diff --git a/server/private/routers/generatedLicense/generateNewLicense.ts b/server/private/routers/generatedLicense/generateNewLicense.ts index cb179a2d..fb6ce835 100644 --- a/server/private/routers/generatedLicense/generateNewLicense.ts +++ b/server/private/routers/generatedLicense/generateNewLicense.ts @@ -4,25 +4,7 @@ import createHttpError from "http-errors"; import logger from "@server/logger"; import { response as sendResponse } from "@server/lib/response"; import privateConfig from "@server/private/lib/config"; - -export type NewLicenseKey = { - licenseKey: { - id: number; - instanceName: string | null; - instanceId: string; - licenseKey: string; - tier: string; - type: string; - quantity: number; - isValid: boolean; - updatedAt: string; - createdAt: string; - expiresAt: string; - orgId: string; - }; -}; - -export type GenerateNewLicenseResponse = NewLicenseKey; +import { GenerateNewLicenseResponse } from "@server/routers/generatedLicense/types"; async function createNewLicense(orgId: string, licenseData: any): Promise { try { diff --git a/server/private/routers/generatedLicense/listGeneratedLicenses.ts b/server/private/routers/generatedLicense/listGeneratedLicenses.ts index ee5f96be..9b219453 100644 --- a/server/private/routers/generatedLicense/listGeneratedLicenses.ts +++ b/server/private/routers/generatedLicense/listGeneratedLicenses.ts @@ -4,18 +4,7 @@ import createHttpError from "http-errors"; import logger from "@server/logger"; import { response as sendResponse } from "@server/lib/response"; import privateConfig from "@server/private/lib/config"; - -export type GeneratedLicenseKey = { - instanceName: string | null; - licenseKey: string; - expiresAt: string; - isValid: boolean; - createdAt: string; - tier: string; - type: string; -}; - -export type ListGeneratedLicenseKeysResponse = GeneratedLicenseKey[]; +import { GeneratedLicenseKey, ListGeneratedLicenseKeysResponse } from "@server/routers/generatedLicense/types"; async function fetchLicenseKeys(orgId: string): Promise { try { diff --git a/server/private/routers/license/activateLicense.ts b/server/private/routers/license/activateLicense.ts index f6d73f6f..f7745489 100644 --- a/server/private/routers/license/activateLicense.ts +++ b/server/private/routers/license/activateLicense.ts @@ -6,7 +6,6 @@ import { response as sendResponse } from "@server/lib/response"; import license from "#private/license/license"; import { z } from "zod"; import { fromError } from "zod-validation-error"; -import { LicenseStatus } from "@server/license/license"; const bodySchema = z .object({ @@ -14,8 +13,6 @@ const bodySchema = z }) .strict(); -export type ActivateLicenseStatus = LicenseStatus; - export async function activateLicense( req: Request, res: Response, diff --git a/server/private/routers/license/deleteLicenseKey.ts b/server/private/routers/license/deleteLicenseKey.ts index bcee5b6a..922da0ad 100644 --- a/server/private/routers/license/deleteLicenseKey.ts +++ b/server/private/routers/license/deleteLicenseKey.ts @@ -9,7 +9,6 @@ import { db } from "@server/db"; import { eq } from "drizzle-orm"; import { licenseKey } from "@server/db"; import license from "#private/license/license"; -import { LicenseStatus } from "@server/license/license"; const paramsSchema = z .object({ @@ -17,8 +16,6 @@ const paramsSchema = z }) .strict(); -export type DeleteLicenseKeyResponse = LicenseStatus; - export async function deleteLicenseKey( req: Request, res: Response, diff --git a/server/private/routers/license/getLicenseStatus.ts b/server/private/routers/license/getLicenseStatus.ts index b36d8dca..838632f2 100644 --- a/server/private/routers/license/getLicenseStatus.ts +++ b/server/private/routers/license/getLicenseStatus.ts @@ -4,9 +4,7 @@ import createHttpError from "http-errors"; import logger from "@server/logger"; import { response as sendResponse } from "@server/lib/response"; import license from "#private/license/license"; -import { LicenseStatus } from "@server/license/license"; - -export type GetLicenseStatusResponse = LicenseStatus; +import { GetLicenseStatusResponse } from "@server/routers/license/types"; export async function getLicenseStatus( req: Request, diff --git a/server/private/routers/license/listLicenseKeys.ts b/server/private/routers/license/listLicenseKeys.ts index 338c92c4..4aa35335 100644 --- a/server/private/routers/license/listLicenseKeys.ts +++ b/server/private/routers/license/listLicenseKeys.ts @@ -4,9 +4,7 @@ import createHttpError from "http-errors"; import logger from "@server/logger"; import { response as sendResponse } from "@server/lib/response"; import license from "#private/license/license"; -import { LicenseKeyCache } from "@server/license/license"; - -export type ListLicenseKeysResponse = LicenseKeyCache[]; +import { ListLicenseKeysResponse } from "@server/routers/license/types"; export async function listLicenseKeys( req: Request, diff --git a/server/private/routers/license/recheckStatus.ts b/server/private/routers/license/recheckStatus.ts index 73e630c8..27bf60bb 100644 --- a/server/private/routers/license/recheckStatus.ts +++ b/server/private/routers/license/recheckStatus.ts @@ -4,9 +4,6 @@ import createHttpError from "http-errors"; import logger from "@server/logger"; import { response as sendResponse } from "@server/lib/response"; import license from "#private/license/license"; -import { LicenseStatus } from "@server/license/license"; - -export type RecheckStatusResponse = LicenseStatus; export async function recheckStatus( req: Request, diff --git a/server/routers/badger/verifySession.ts b/server/routers/badger/verifySession.ts index 7c66ea7b..523163e6 100644 --- a/server/routers/badger/verifySession.ts +++ b/server/routers/badger/verifySession.ts @@ -560,39 +560,6 @@ function allowed(res: Response, userData?: BasicUserData) { return response(res, data); } -async function createAccessTokenSession( - res: Response, - resource: Resource, - tokenItem: ResourceAccessToken -) { - const token = generateSessionToken(); - const sess = await createResourceSession({ - resourceId: resource.resourceId, - token, - accessTokenId: tokenItem.accessTokenId, - sessionLength: tokenItem.sessionLength, - expiresAt: tokenItem.expiresAt, - doNotExtend: tokenItem.expiresAt ? true : false - }); - const cookieName = `${config.getRawConfig().server.session_cookie_name}`; - const cookie = serializeResourceSessionCookie( - cookieName, - resource.fullDomain!, - token, - !resource.ssl, - new Date(sess.expiresAt) - ); - res.appendHeader("Set-Cookie", cookie); - logger.debug("Access token is valid, creating new session"); - return response(res, { - data: { valid: true }, - success: true, - error: false, - message: "Access allowed", - status: HttpCode.OK - }); -} - async function isUserAllowedToAccessResource( userSessionId: string, resource: Resource diff --git a/server/routers/generatedLicense/types.ts b/server/routers/generatedLicense/types.ts new file mode 100644 index 00000000..4c5efed7 --- /dev/null +++ b/server/routers/generatedLicense/types.ts @@ -0,0 +1,30 @@ +export type GeneratedLicenseKey = { + instanceName: string | null; + licenseKey: string; + expiresAt: string; + isValid: boolean; + createdAt: string; + tier: string; + type: string; +}; + +export type ListGeneratedLicenseKeysResponse = GeneratedLicenseKey[]; + +export type NewLicenseKey = { + licenseKey: { + id: number; + instanceName: string | null; + instanceId: string; + licenseKey: string; + tier: string; + type: string; + quantity: number; + isValid: boolean; + updatedAt: string; + createdAt: string; + expiresAt: string; + orgId: string; + }; +}; + +export type GenerateNewLicenseResponse = NewLicenseKey; \ No newline at end of file diff --git a/server/routers/license/types.ts b/server/routers/license/types.ts new file mode 100644 index 00000000..945bd368 --- /dev/null +++ b/server/routers/license/types.ts @@ -0,0 +1,11 @@ +import { LicenseStatus, LicenseKeyCache } from "@server/license/license"; + +export type ActivateLicenseStatus = LicenseStatus; + +export type DeleteLicenseKeyResponse = LicenseStatus; + +export type GetLicenseStatusResponse = LicenseStatus; + +export type ListLicenseKeysResponse = LicenseKeyCache[]; + +export type RecheckStatusResponse = LicenseStatus; \ No newline at end of file diff --git a/src/app/[orgId]/settings/(private)/license/page.tsx b/src/app/[orgId]/settings/(private)/license/page.tsx index 627618f4..1ecc94c1 100644 --- a/src/app/[orgId]/settings/(private)/license/page.tsx +++ b/src/app/[orgId]/settings/(private)/license/page.tsx @@ -1,7 +1,7 @@ import GenerateLicenseKeysTable from "@app/components/GenerateLicenseKeysTable"; import { internal } from "@app/lib/api"; import { authCookieHeader } from "@app/lib/api/cookies"; -import { ListGeneratedLicenseKeysResponse } from "@server/private/routers/generatedLicense"; +import { ListGeneratedLicenseKeysResponse } from "@server/routers/generatedLicense/types"; import { AxiosResponse } from "axios"; type Props = { diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 2d6eb965..fe1fb31b 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -11,7 +11,7 @@ import { priv } from "@app/lib/api"; import { AxiosResponse } from "axios"; import { IsSupporterKeyVisibleResponse } from "@server/routers/supporterKey"; import LicenseStatusProvider from "@app/providers/LicenseStatusProvider"; -import { GetLicenseStatusResponse } from "#private/routers/license"; +import { GetLicenseStatusResponse } from "@server/routers/license/types"; import LicenseViolation from "@app/components/LicenseViolation"; import { cache } from "react"; import { NextIntlClientProvider } from "next-intl"; diff --git a/src/components/GenerateLicenseKeyForm.tsx b/src/components/GenerateLicenseKeyForm.tsx index dfb45a45..a08a5cd1 100644 --- a/src/components/GenerateLicenseKeyForm.tsx +++ b/src/components/GenerateLicenseKeyForm.tsx @@ -10,13 +10,6 @@ import { FormMessage } from "@app/components/ui/form"; import { Input } from "@app/components/ui/input"; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue -} from "@app/components/ui/select"; import { Checkbox } from "@app/components/ui/checkbox"; import { toast } from "@app/hooks/useToast"; import { zodResolver } from "@hookform/resolvers/zod"; @@ -38,7 +31,7 @@ import { import { formatAxiosError } from "@app/lib/api"; import { createApiClient } from "@app/lib/api"; import { useEnvContext } from "@app/hooks/useEnvContext"; -import { GenerateNewLicenseResponse } from "@server/private/routers/generatedLicense/generateNewLicense"; +import { GenerateNewLicenseResponse } from "@server/routers/generatedLicense/types"; import { useTranslations } from "next-intl"; import React from "react"; import { StrategySelect, StrategyOption } from "./StrategySelect"; diff --git a/src/components/GenerateLicenseKeysTable.tsx b/src/components/GenerateLicenseKeysTable.tsx index 580fdba4..835bb70d 100644 --- a/src/components/GenerateLicenseKeysTable.tsx +++ b/src/components/GenerateLicenseKeysTable.tsx @@ -8,14 +8,12 @@ import CopyToClipboard from "./CopyToClipboard"; import { Badge } from "./ui/badge"; import moment from "moment"; import { DataTable } from "./ui/data-table"; -import { GeneratedLicenseKey } from "@server/private/routers/generatedLicense"; +import { GeneratedLicenseKey } from "@server/routers/generatedLicense/types"; import { useState } from "react"; import { useRouter } from "next/navigation"; import { toast } from "@app/hooks/useToast"; import { createApiClient, formatAxiosError } from "@app/lib/api"; import { useEnvContext } from "@app/hooks/useEnvContext"; -import { AxiosResponse } from "axios"; -import { GenerateNewLicenseResponse } from "@server/private/routers/generatedLicense/generateNewLicense"; import GenerateLicenseKeyForm from "./GenerateLicenseKeyForm"; type GnerateLicenseKeysTableProps = { diff --git a/tsconfig.json b/tsconfig.json index 0b856fe0..e32eabd3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,7 +22,7 @@ "#private/*": ["../server/private/*"], "#open/*": ["../server/*"], "#closed/*": ["../server/private/*"], - "#dynamic/*": ["../server/private/*"] + "#dynamic/*": ["../server/*"] }, "plugins": [ {