mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-10 12:46:37 +00:00
Fix frontend type imports
This commit is contained in:
@@ -4,25 +4,7 @@ import createHttpError from "http-errors";
|
|||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { response as sendResponse } from "@server/lib/response";
|
import { response as sendResponse } from "@server/lib/response";
|
||||||
import privateConfig from "@server/private/lib/config";
|
import privateConfig from "@server/private/lib/config";
|
||||||
|
import { GenerateNewLicenseResponse } from "@server/routers/generatedLicense/types";
|
||||||
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;
|
|
||||||
|
|
||||||
async function createNewLicense(orgId: string, licenseData: any): Promise<any> {
|
async function createNewLicense(orgId: string, licenseData: any): Promise<any> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -4,18 +4,7 @@ import createHttpError from "http-errors";
|
|||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { response as sendResponse } from "@server/lib/response";
|
import { response as sendResponse } from "@server/lib/response";
|
||||||
import privateConfig from "@server/private/lib/config";
|
import privateConfig from "@server/private/lib/config";
|
||||||
|
import { GeneratedLicenseKey, ListGeneratedLicenseKeysResponse } from "@server/routers/generatedLicense/types";
|
||||||
export type GeneratedLicenseKey = {
|
|
||||||
instanceName: string | null;
|
|
||||||
licenseKey: string;
|
|
||||||
expiresAt: string;
|
|
||||||
isValid: boolean;
|
|
||||||
createdAt: string;
|
|
||||||
tier: string;
|
|
||||||
type: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export type ListGeneratedLicenseKeysResponse = GeneratedLicenseKey[];
|
|
||||||
|
|
||||||
async function fetchLicenseKeys(orgId: string): Promise<any> {
|
async function fetchLicenseKeys(orgId: string): Promise<any> {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import { response as sendResponse } from "@server/lib/response";
|
|||||||
import license from "#private/license/license";
|
import license from "#private/license/license";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { fromError } from "zod-validation-error";
|
import { fromError } from "zod-validation-error";
|
||||||
import { LicenseStatus } from "@server/license/license";
|
|
||||||
|
|
||||||
const bodySchema = z
|
const bodySchema = z
|
||||||
.object({
|
.object({
|
||||||
@@ -14,8 +13,6 @@ const bodySchema = z
|
|||||||
})
|
})
|
||||||
.strict();
|
.strict();
|
||||||
|
|
||||||
export type ActivateLicenseStatus = LicenseStatus;
|
|
||||||
|
|
||||||
export async function activateLicense(
|
export async function activateLicense(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import { db } from "@server/db";
|
|||||||
import { eq } from "drizzle-orm";
|
import { eq } from "drizzle-orm";
|
||||||
import { licenseKey } from "@server/db";
|
import { licenseKey } from "@server/db";
|
||||||
import license from "#private/license/license";
|
import license from "#private/license/license";
|
||||||
import { LicenseStatus } from "@server/license/license";
|
|
||||||
|
|
||||||
const paramsSchema = z
|
const paramsSchema = z
|
||||||
.object({
|
.object({
|
||||||
@@ -17,8 +16,6 @@ const paramsSchema = z
|
|||||||
})
|
})
|
||||||
.strict();
|
.strict();
|
||||||
|
|
||||||
export type DeleteLicenseKeyResponse = LicenseStatus;
|
|
||||||
|
|
||||||
export async function deleteLicenseKey(
|
export async function deleteLicenseKey(
|
||||||
req: Request,
|
req: Request,
|
||||||
res: Response,
|
res: Response,
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import createHttpError from "http-errors";
|
|||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { response as sendResponse } from "@server/lib/response";
|
import { response as sendResponse } from "@server/lib/response";
|
||||||
import license from "#private/license/license";
|
import license from "#private/license/license";
|
||||||
import { LicenseStatus } from "@server/license/license";
|
import { GetLicenseStatusResponse } from "@server/routers/license/types";
|
||||||
|
|
||||||
export type GetLicenseStatusResponse = LicenseStatus;
|
|
||||||
|
|
||||||
export async function getLicenseStatus(
|
export async function getLicenseStatus(
|
||||||
req: Request,
|
req: Request,
|
||||||
|
|||||||
@@ -4,9 +4,7 @@ import createHttpError from "http-errors";
|
|||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { response as sendResponse } from "@server/lib/response";
|
import { response as sendResponse } from "@server/lib/response";
|
||||||
import license from "#private/license/license";
|
import license from "#private/license/license";
|
||||||
import { LicenseKeyCache } from "@server/license/license";
|
import { ListLicenseKeysResponse } from "@server/routers/license/types";
|
||||||
|
|
||||||
export type ListLicenseKeysResponse = LicenseKeyCache[];
|
|
||||||
|
|
||||||
export async function listLicenseKeys(
|
export async function listLicenseKeys(
|
||||||
req: Request,
|
req: Request,
|
||||||
|
|||||||
@@ -4,9 +4,6 @@ import createHttpError from "http-errors";
|
|||||||
import logger from "@server/logger";
|
import logger from "@server/logger";
|
||||||
import { response as sendResponse } from "@server/lib/response";
|
import { response as sendResponse } from "@server/lib/response";
|
||||||
import license from "#private/license/license";
|
import license from "#private/license/license";
|
||||||
import { LicenseStatus } from "@server/license/license";
|
|
||||||
|
|
||||||
export type RecheckStatusResponse = LicenseStatus;
|
|
||||||
|
|
||||||
export async function recheckStatus(
|
export async function recheckStatus(
|
||||||
req: Request,
|
req: Request,
|
||||||
|
|||||||
@@ -560,39 +560,6 @@ function allowed(res: Response, userData?: BasicUserData) {
|
|||||||
return response<VerifyUserResponse>(res, data);
|
return response<VerifyUserResponse>(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<VerifyUserResponse>(res, {
|
|
||||||
data: { valid: true },
|
|
||||||
success: true,
|
|
||||||
error: false,
|
|
||||||
message: "Access allowed",
|
|
||||||
status: HttpCode.OK
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function isUserAllowedToAccessResource(
|
async function isUserAllowedToAccessResource(
|
||||||
userSessionId: string,
|
userSessionId: string,
|
||||||
resource: Resource
|
resource: Resource
|
||||||
|
|||||||
30
server/routers/generatedLicense/types.ts
Normal file
30
server/routers/generatedLicense/types.ts
Normal file
@@ -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;
|
||||||
11
server/routers/license/types.ts
Normal file
11
server/routers/license/types.ts
Normal file
@@ -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;
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import GenerateLicenseKeysTable from "@app/components/GenerateLicenseKeysTable";
|
import GenerateLicenseKeysTable from "@app/components/GenerateLicenseKeysTable";
|
||||||
import { internal } from "@app/lib/api";
|
import { internal } from "@app/lib/api";
|
||||||
import { authCookieHeader } from "@app/lib/api/cookies";
|
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";
|
import { AxiosResponse } from "axios";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import { priv } from "@app/lib/api";
|
|||||||
import { AxiosResponse } from "axios";
|
import { AxiosResponse } from "axios";
|
||||||
import { IsSupporterKeyVisibleResponse } from "@server/routers/supporterKey";
|
import { IsSupporterKeyVisibleResponse } from "@server/routers/supporterKey";
|
||||||
import LicenseStatusProvider from "@app/providers/LicenseStatusProvider";
|
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 LicenseViolation from "@app/components/LicenseViolation";
|
||||||
import { cache } from "react";
|
import { cache } from "react";
|
||||||
import { NextIntlClientProvider } from "next-intl";
|
import { NextIntlClientProvider } from "next-intl";
|
||||||
|
|||||||
@@ -10,13 +10,6 @@ import {
|
|||||||
FormMessage
|
FormMessage
|
||||||
} from "@app/components/ui/form";
|
} from "@app/components/ui/form";
|
||||||
import { Input } from "@app/components/ui/input";
|
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 { Checkbox } from "@app/components/ui/checkbox";
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { zodResolver } from "@hookform/resolvers/zod";
|
import { zodResolver } from "@hookform/resolvers/zod";
|
||||||
@@ -38,7 +31,7 @@ import {
|
|||||||
import { formatAxiosError } from "@app/lib/api";
|
import { formatAxiosError } from "@app/lib/api";
|
||||||
import { createApiClient } from "@app/lib/api";
|
import { createApiClient } from "@app/lib/api";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
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 { useTranslations } from "next-intl";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { StrategySelect, StrategyOption } from "./StrategySelect";
|
import { StrategySelect, StrategyOption } from "./StrategySelect";
|
||||||
|
|||||||
@@ -8,14 +8,12 @@ import CopyToClipboard from "./CopyToClipboard";
|
|||||||
import { Badge } from "./ui/badge";
|
import { Badge } from "./ui/badge";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { DataTable } from "./ui/data-table";
|
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 { useState } from "react";
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import { toast } from "@app/hooks/useToast";
|
import { toast } from "@app/hooks/useToast";
|
||||||
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
import { createApiClient, formatAxiosError } from "@app/lib/api";
|
||||||
import { useEnvContext } from "@app/hooks/useEnvContext";
|
import { useEnvContext } from "@app/hooks/useEnvContext";
|
||||||
import { AxiosResponse } from "axios";
|
|
||||||
import { GenerateNewLicenseResponse } from "@server/private/routers/generatedLicense/generateNewLicense";
|
|
||||||
import GenerateLicenseKeyForm from "./GenerateLicenseKeyForm";
|
import GenerateLicenseKeyForm from "./GenerateLicenseKeyForm";
|
||||||
|
|
||||||
type GnerateLicenseKeysTableProps = {
|
type GnerateLicenseKeysTableProps = {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
"#private/*": ["../server/private/*"],
|
"#private/*": ["../server/private/*"],
|
||||||
"#open/*": ["../server/*"],
|
"#open/*": ["../server/*"],
|
||||||
"#closed/*": ["../server/private/*"],
|
"#closed/*": ["../server/private/*"],
|
||||||
"#dynamic/*": ["../server/private/*"]
|
"#dynamic/*": ["../server/*"]
|
||||||
},
|
},
|
||||||
"plugins": [
|
"plugins": [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user