261027_02_ENH: kric-internal에 project-list 추가

This commit is contained in:
2026-10-27 14:55:05 +09:00
parent 8420a22e67
commit c6cc7edfc7
2 changed files with 60 additions and 33 deletions

View File

@@ -4,6 +4,7 @@ import {
isQuotaResultPath,
isReportStreamPath,
isProjectReadPath,
projectReadQuery,
} from "@/lib/project-proxy-policy";
import { isRecord, validDateRange } from "@/types/kart";
import { readReportBatch } from "@/lib/report-contract";
@@ -12,9 +13,21 @@ import { reportUrl } from "@/types/share";
type Target = {
path: string;
kind: "list" | "quota" | "report" | "excel" | "respondent" | "share";
kind: "list" | "projects" | "quota" | "report" | "excel" | "respondent" | "share";
};
/** Linked lookup only: without all three keys the server would list the API key owner's projects. */
export function readInternalProjectListQuery(search: URLSearchParams) {
const query = projectReadQuery(["list"], search);
if (
!["0", "1"].includes(query.projectType ?? "") ||
!query.intranetCode?.trim() ||
!query.userTeam?.trim()
)
throw new Error("projectType(0|1), intranetCode, userTeam을 함께 입력해 주세요.");
return query;
}
/** URL Copy only: the server resolves the project from the authenticated path. */
export function readInternalShareRequest(value: unknown) {
if (!isRecord(value) || value.mode !== "U")
@@ -39,6 +52,8 @@ export function internalTarget(method: string, slug: string[]): Target | null {
const path = "/" + slug.map(encodeURIComponent).join("/");
if (method === "GET" && area === "quota" && isQuotaListPath(parts))
return { path, kind: "list" };
if (method === "GET" && area === "project" && parts.length === 1 && parts[0] === "list")
return { path, kind: "projects" };
if (method !== "POST") return null;
if (
area === "project" &&