chore: remove unused cache files (#5700)

This commit is contained in:
Matti Nannt
2025-05-07 15:26:13 +02:00
committed by GitHub
parent 07e9a7c007
commit b338c6d28d
5 changed files with 0 additions and 173 deletions

View File

@@ -1,66 +0,0 @@
import { revalidateTag } from "next/cache";
import { type TSurveyQuestionId } from "@formbricks/types/surveys/types";
interface RevalidateProps {
id?: string;
environmentId?: string | null;
surveyId?: string | null;
responseId?: string | null;
questionId?: string | null;
insightId?: string | null;
}
export const documentCache = {
tag: {
byId(id: string) {
return `documents-${id}`;
},
byEnvironmentId(environmentId: string) {
return `environments-${environmentId}-documents`;
},
byResponseId(responseId: string) {
return `responses-${responseId}-documents`;
},
byResponseIdQuestionId(responseId: string, questionId: TSurveyQuestionId) {
return `responses-${responseId}-questions-${questionId}-documents`;
},
bySurveyId(surveyId: string) {
return `surveys-${surveyId}-documents`;
},
bySurveyIdQuestionId(surveyId: string, questionId: TSurveyQuestionId) {
return `surveys-${surveyId}-questions-${questionId}-documents`;
},
byInsightId(insightId: string) {
return `insights-${insightId}-documents`;
},
byInsightIdSurveyIdQuestionId(insightId: string, surveyId: string, questionId: TSurveyQuestionId) {
return `insights-${insightId}-surveys-${surveyId}-questions-${questionId}-documents`;
},
},
revalidate: ({ id, environmentId, surveyId, responseId, questionId, insightId }: RevalidateProps): void => {
if (id) {
revalidateTag(documentCache.tag.byId(id));
}
if (environmentId) {
revalidateTag(documentCache.tag.byEnvironmentId(environmentId));
}
if (responseId) {
revalidateTag(documentCache.tag.byResponseId(responseId));
}
if (surveyId) {
revalidateTag(documentCache.tag.bySurveyId(surveyId));
}
if (responseId && questionId) {
revalidateTag(documentCache.tag.byResponseIdQuestionId(responseId, questionId));
}
if (surveyId && questionId) {
revalidateTag(documentCache.tag.bySurveyIdQuestionId(surveyId, questionId));
}
if (insightId) {
revalidateTag(documentCache.tag.byInsightId(insightId));
}
if (insightId && surveyId && questionId) {
revalidateTag(documentCache.tag.byInsightIdSurveyIdQuestionId(insightId, surveyId, questionId));
}
},
};

View File

@@ -1,25 +0,0 @@
import { revalidateTag } from "next/cache";
interface RevalidateProps {
id?: string;
environmentId?: string;
}
export const insightCache = {
tag: {
byId(id: string) {
return `documentGroups-${id}`;
},
byEnvironmentId(environmentId: string) {
return `environments-${environmentId}-documentGroups`;
},
},
revalidate: ({ id, environmentId }: RevalidateProps): void => {
if (id) {
revalidateTag(insightCache.tag.byId(id));
}
if (environmentId) {
revalidateTag(insightCache.tag.byEnvironmentId(environmentId));
}
},
};

View File

@@ -1,12 +0,0 @@
import { type Insight } from "@prisma/client";
import { z } from "zod";
export const ZInsight = z.object({
id: z.string().cuid2(),
createdAt: z.date(),
updatedAt: z.date(),
environmentId: z.string().cuid2(),
title: z.string(),
description: z.string(),
category: z.enum(["featureRequest", "complaint", "praise", "other"]),
}) satisfies z.ZodType<Insight>;

View File

@@ -1,9 +0,0 @@
import { z } from "zod";
import { ZId } from "./common";
export const ZDocumentInsight = z.object({
documentId: ZId,
insightId: ZId,
});
export type TDocumentInsight = z.infer<typeof ZDocumentInsight>;

View File

@@ -1,61 +0,0 @@
import { z } from "zod";
import { ZInsight } from "@formbricks/database/zod/insights";
import { ZId } from "./common";
import { ZSurveyQuestionId } from "./surveys/types";
export const ZDocumentSentiment = z.enum(["positive", "negative", "neutral"]);
export type TDocumentSentiment = z.infer<typeof ZDocumentSentiment>;
export const ZDocument = z.object({
id: ZId,
createdAt: z.date(),
updatedAt: z.date(),
environmentId: ZId,
responseId: ZId.nullable(),
questionId: ZSurveyQuestionId.nullable(),
sentiment: ZDocumentSentiment,
text: z.string(),
});
export type TDocument = z.infer<typeof ZDocument>;
export const ZDocumentCreateInput = z.object({
environmentId: ZId,
surveyId: ZId,
responseId: ZId,
questionId: ZSurveyQuestionId,
text: z.string(),
});
export type TDocumentCreateInput = z.infer<typeof ZDocumentCreateInput>;
export const ZDocumentFilterCriteria = z.object({
createdAt: z
.object({
min: z.date().optional(),
max: z.date().optional(),
})
.optional(),
});
export type TDocumentFilterCriteria = z.infer<typeof ZDocumentFilterCriteria>;
export const ZGenerateDocumentObjectSchema = z.object({
sentiment: ZDocumentSentiment,
insights: z.array(
z.object({
title: z.string().describe("insight title, very specific"),
description: z.string().describe("very brief insight description"),
category: ZInsight.shape.category,
})
),
isSpam: z.boolean(),
});
export type TGenerateDocumentObjectSchema = z.infer<typeof ZGenerateDocumentObjectSchema>;
export type TCreatedDocument = TDocument & {
isSpam: boolean;
insights: TGenerateDocumentObjectSchema["insights"];
};