Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/web/app/api/mcp/route.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { type NextRequest } from "next/server";
import { DEFAULT_REQUEST_BODY_LIMIT_BYTES } from "@/app/lib/api/request-body";
import { problemPayloadTooLarge } from "@/app/api/v3/lib/response";
import { DEFAULT_REQUEST_BODY_LIMIT_BYTES } from "@/app/lib/api/request-body";
import { handleAuthenticatedMcpRequest } from "@/modules/mcp/auth";
import { mcpHandler } from "@/modules/mcp/server";

Expand Down
2 changes: 1 addition & 1 deletion apps/web/app/api/v3/surveys/[surveyId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { z } from "zod";
import { withV3ApiWrapper } from "@/app/api/v3/lib/api-wrapper";
import { deleteV3Survey, getV3Survey, patchV3SurveyResponse } from "../lib/operations";
import { parseV3SurveyLanguageQuery } from "../language";
import { deleteV3Survey, getV3Survey, patchV3SurveyResponse } from "../lib/operations";
import { ZV3EmptyQuery } from "../schemas";

const surveyParamsSchema = z.object({
Expand Down
10 changes: 4 additions & 6 deletions apps/web/app/api/v3/surveys/lib/operations.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { describe, expect, test, vi, beforeEach } from "vitest";
import { beforeEach, describe, expect, test, vi } from "vitest";
import { DatabaseError, ResourceNotFoundError } from "@formbricks/types/errors";
import { problemForbidden } from "@/app/api/v3/lib/response";
import { requireV3WorkspaceAccess } from "@/app/api/v3/lib/auth";
import { problemForbidden } from "@/app/api/v3/lib/response";
import { deleteSurvey } from "@/modules/survey/lib/surveys";
import { getSurveyCount } from "@/modules/survey/list/lib/survey";
import { getSurveyListPage } from "@/modules/survey/list/lib/survey-page";
Expand All @@ -17,6 +17,7 @@ import {
serializeV3SurveyListItem,
serializeV3SurveyResource,
} from "../serializers";
import { V3SurveyWritePermissionError } from "../write-permissions";
import {
createV3SurveyResponse,
deleteV3Survey,
Expand All @@ -25,7 +26,6 @@ import {
patchV3SurveyResponse,
validateV3Survey,
} from "./operations";
import { V3SurveyWritePermissionError } from "../write-permissions";

vi.mock("@formbricks/logger", () => ({
logger: {
Expand Down Expand Up @@ -205,9 +205,7 @@ describe("listV3Surveys", () => {
});

expect(response.status).toBe(400);
expect((await readJson(response)).invalid_params).toEqual([
{ name: "workspaceId", reason: "Required" },
]);
expect((await readJson(response)).invalid_params).toEqual([{ name: "workspaceId", reason: "Required" }]);
});

test("returns authorization responses from workspace access", async () => {
Expand Down
21 changes: 12 additions & 9 deletions apps/web/app/api/v3/surveys/lib/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,10 @@ export async function patchV3SurveyResponse({
}

if (error instanceof V3SurveyWritePermissionError) {
log.warn({ statusCode: 403, workspaceId, errorCode: error.name }, "Survey patch permission check failed");
log.warn(
{ statusCode: 403, workspaceId, errorCode: error.name },
"Survey patch permission check failed"
);
return problemForbidden(requestId, error.message, instance);
}

Expand Down Expand Up @@ -491,17 +494,17 @@ export async function validateV3Survey({
});

if (response) {
log.warn({ statusCode: response.status, surveyId: body.surveyId }, "Survey not found or not accessible");
log.warn(
{ statusCode: response.status, surveyId: body.surveyId },
"Survey not found or not accessible"
);
return response;
}

return successResponse(
serializeValidationResult("patch", prepareV3SurveyPatchInput(survey, body.data)),
{
requestId,
cache: "private, no-store",
}
);
return successResponse(serializeValidationResult("patch", prepareV3SurveyPatchInput(survey, body.data)), {
requestId,
cache: "private, no-store",
});
} catch (error) {
if (error instanceof DatabaseError) {
log.error({ error, statusCode: 500 }, "Database error");
Expand Down
8 changes: 5 additions & 3 deletions apps/web/modules/mcp/tools/schemas.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { z } from "zod";
import type { TV3CreateSurveyBody, TV3SurveyValidationRequestBody } from "@/app/api/v3/surveys/schemas";
import { ZV3CreateSurveyBody, ZV3SurveyValidationRequestBody } from "@/app/api/v3/surveys/schemas";
import { ZId } from "@formbricks/types/common";
import { ZSurveyFilters, ZSurveyStatus, ZSurveyType } from "@formbricks/types/surveys/types";
import type { TV3CreateSurveyBody, TV3SurveyValidationRequestBody } from "@/app/api/v3/surveys/schemas";
import { ZV3CreateSurveyBody, ZV3SurveyValidationRequestBody } from "@/app/api/v3/surveys/schemas";

export const ZMcpListSurveysInput = z.object({
workspaceId: ZId.describe("Workspace ID whose surveys should be listed."),
Expand All @@ -20,7 +20,9 @@ export const ZMcpListSurveysInput = z.object({
.describe("Opaque pagination cursor from a previous list_surveys response."),
includeTotalCount: z
.boolean()
.describe("Whether to include the total matching survey count in the response metadata. Defaults to true.")
.describe(
"Whether to include the total matching survey count in the response metadata. Defaults to true."
)
.default(true),
filter: z
.object({
Expand Down
4 changes: 2 additions & 2 deletions packages/jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
"devDependencies": {
"@formbricks/config-typescript": "workspace:*",
"@formbricks/eslint-config": "workspace:*",
"@vitest/coverage-v8": "4.0.18",
"@vitest/coverage-v8": "4.1.6",
"vite": "7.3.2",
"vite-plugin-dts": "4.5.4",
"vitest": "4.0.18"
"vitest": "4.1.6"
}
}
Loading
Loading