mirror of
https://github.com/formbricks/formbricks.git
synced 2026-02-08 23:59:38 -06:00
chore: remove unused cache files (#5700)
This commit is contained in:
66
apps/web/lib/cache/document.ts
vendored
66
apps/web/lib/cache/document.ts
vendored
@@ -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));
|
||||
}
|
||||
},
|
||||
};
|
||||
25
apps/web/lib/cache/insight.ts
vendored
25
apps/web/lib/cache/insight.ts
vendored
@@ -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));
|
||||
}
|
||||
},
|
||||
};
|
||||
@@ -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>;
|
||||
@@ -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>;
|
||||
@@ -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"];
|
||||
};
|
||||
Reference in New Issue
Block a user