diff --git a/apps/api/src/graphql/uptodate.ts b/apps/api/src/graphql/uptodate.ts index 731c854f..21d2ec6e 100644 --- a/apps/api/src/graphql/uptodate.ts +++ b/apps/api/src/graphql/uptodate.ts @@ -4,11 +4,12 @@ import { and, asc, cosineDistance, eq } from 'drizzle-orm'; import { uniqueBy } from 'remeda'; import { z } from 'zod'; import { builder } from '@/builder'; -import { db, PageContentChunks, PageContents, Pages } from '@/db'; +import { db, firstOrThrow, PageContentChunks, PageContents, Pages, Sites } from '@/db'; import { PageState } from '@/enums'; import * as langchain from '@/external/langchain'; import { fixByChangePrompt, keywordExtractionPrompt } from '@/prompt/fix-by-change'; import { assertSitePermission } from '@/utils/permissions'; +import { assertTeamPlanRule } from '@/utils/plan'; import { Page } from './objects'; type FindOutdatedContent = { @@ -56,6 +57,19 @@ builder.queryFields((t) => ({ userId: ctx.session.userId, }); + const site = await db + .select({ + teamId: Sites.teamId, + }) + .from(Sites) + .where(eq(Sites.id, args.siteId)) + .then(firstOrThrow); + + await assertTeamPlanRule({ + teamId: site.teamId, + rule: 'aiSearch', + }); + const chain1 = RunnableSequence.from([ ChatPromptTemplate.fromMessages([ ['system', keywordExtractionPrompt], diff --git a/apps/api/src/utils/plan.ts b/apps/api/src/utils/plan.ts index 93da11cd..44278424 100644 --- a/apps/api/src/utils/plan.ts +++ b/apps/api/src/utils/plan.ts @@ -84,5 +84,12 @@ export const assertTeamPlanRule = async (params: GetP } break; } + + default: { + if (!value) { + throw new ReadableError({ code: 'feature_not_available' }); + } + break; + } } };