Skip to content

Commit

Permalink
chore: fix eslint import types on nextjs project
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext committed Oct 29, 2024
1 parent 4e5e1f2 commit 6435a39
Show file tree
Hide file tree
Showing 170 changed files with 425 additions and 329 deletions.
2 changes: 1 addition & 1 deletion apps/nextjs/src/ai-apps/common/parseLocalStorageData.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { aiLogger } from "@oakai/logger";
import * as Sentry from "@sentry/nextjs";
import { z } from "zod";
import type { z } from "zod";

const log = aiLogger("ui");

Expand Down
7 changes: 4 additions & 3 deletions apps/nextjs/src/ai-apps/common/state/create-parts.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import {
import type {
GenerationPart,
GenerationPartAIGenerated,
GenerationPartType,
GenerationPartUserTweaked,
GenerationPartUserTweaked} from "@oakai/core/src/types";
import {
GenerationPartType
} from "@oakai/core/src/types";

export function createAIGeneratedPart<Value>(
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/ai-apps/common/state/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GenerationPart } from "@oakai/core/src/types";
import type { GenerationPart } from "@oakai/core/src/types";

/**
* Apply the `updater` function to the item
Expand Down
10 changes: 5 additions & 5 deletions apps/nextjs/src/ai-apps/lesson-planner/state/actions.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { RateLimitInfo } from "@oakai/api/src/types";
import { KeyStageName, SubjectName } from "@oakai/core";
import {
import type { RateLimitInfo } from "@oakai/api/src/types";
import type { KeyStageName, SubjectName } from "@oakai/core";
import type {
QuizAppQuestion,
QuizAppStateQuestion,
} from "ai-apps/quiz-designer/state/types";

import { DeepPartial } from "@/utils/types/DeepPartial";
import type { DeepPartial } from "@/utils/types/DeepPartial";

import {
import type {
LPKeyLearningPoint,
LPKeyword,
LPMisconception,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/ai-apps/quiz-designer/convertToCSV.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExportableQuizAppState } from "@oakai/exports/src/schema/input.schema";
import type { ExportableQuizAppState } from "@oakai/exports/src/schema/input.schema";

export function convertQuizToCSV(data: ExportableQuizAppState) {
// Define the headers for your CSV
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
ExportableQuizAppState,
ExportableQuizQuestion,
} from "@oakai/exports/src/schema/input.schema";
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/ai-apps/quiz-designer/export-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
import type {
ExportableQuizAppState,
ExportableQuizQuestion,
} from "@oakai/exports/src/schema/input.schema";
import { getGenerationPartValue } from "ai-apps/common/state/helpers";

import { sortAlphabetically } from "@/utils/alphabetiseArray";

import {
import type {
QuizAppQuestion,
QuizAppState,
QuizAppStateQuestion,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { QuizAppState, QuizAppStateQuestion } from "./state/types";
import type { QuizAppState, QuizAppStateQuestion } from "./state/types";

type OtherQuestionForPromptPropos = {
state: QuizAppState;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { GenerationPart } from "@oakai/core/src/types";
import type { GenerationPart } from "@oakai/core/src/types";

import { getAgesFromKeyStage } from "@/utils/getAgesFromKeyStage";

import { extraQuizPromptInfo } from "./extraQuizPromptInfo";
import { QuizAppState, QuizAppStateQuestion } from "./state/types";
import type { QuizAppState, QuizAppStateQuestion } from "./state/types";

type RequestionGenerationInputs = {
lastGenerationId: string | null;
Expand Down
8 changes: 4 additions & 4 deletions apps/nextjs/src/ai-apps/quiz-designer/state/actions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { RateLimitInfo } from "@oakai/api/src/types";
import { KeyStageName, SubjectName } from "@oakai/core";
import { PotentialQuestionsType } from "hooks/useSuggestedQuestions";
import type { RateLimitInfo } from "@oakai/api/src/types";
import type { KeyStageName, SubjectName } from "@oakai/core";
import type { PotentialQuestionsType } from "hooks/useSuggestedQuestions";

import { QuizAppState, QuizQuestionType } from "./types";
import type { QuizAppState, QuizQuestionType } from "./types";

/**
* Our action types are declared as a const enum with string values
Expand Down
10 changes: 6 additions & 4 deletions apps/nextjs/src/ai-apps/quiz-designer/state/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import {
createTweakPart,
} from "ai-apps/common/state/create-parts";
import { removeAtIndex, updateAtIndex } from "ai-apps/common/state/helpers";
import { PotentialQuestionsType } from "hooks/useSuggestedQuestions";
import type { PotentialQuestionsType } from "hooks/useSuggestedQuestions";

import { QuizAppAction, QuizAppActions } from "./actions";
import {
import type { QuizAppAction} from "./actions";
import { QuizAppActions } from "./actions";
import type {
QuizAppState,
QuizAppStateQuestion,
QuizAppStateQuestion} from "./types";
import {
QuizAppStatus,
QuizQuestionType,
} from "./types";
Expand Down
6 changes: 4 additions & 2 deletions apps/nextjs/src/app/actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
"use server";

import { AilaPersistedChat, chatSchema } from "@oakai/aila/src/protocol/schema";
import { Prisma, prisma } from "@oakai/db";
import type { AilaPersistedChat} from "@oakai/aila/src/protocol/schema";
import { chatSchema } from "@oakai/aila/src/protocol/schema";
import type { Prisma} from "@oakai/db";
import { prisma } from "@oakai/db";
import * as Sentry from "@sentry/nextjs";

function parseChatAndReportError({
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/aila/[id]/download/DownloadView.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { AilaPersistedChat } from "@oakai/aila/src/protocol/schema";
import type { AilaPersistedChat } from "@oakai/aila/src/protocol/schema";
import { Box, Flex, Grid } from "@radix-ui/themes";

import Layout from "@/components/AppComponents/Layout";
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/aila/[id]/download/useDownloadView.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getLastAssistantMessage } from "@oakai/aila/src/helpers/chat/getLastAssistantMessage";
import { AilaPersistedChat } from "@oakai/aila/src/protocol/schema";
import type { AilaPersistedChat } from "@oakai/aila/src/protocol/schema";

import { useProgressForDownloads } from "@/components/AppComponents/Chat/Chat/hooks/useProgressForDownloads";
import { ExportsHookProps } from "@/components/ExportsDialogs/exports.types";
import type { ExportsHookProps } from "@/components/ExportsDialogs/exports.types";
import { useExportAdditionalMaterials } from "@/components/ExportsDialogs/useExportAdditionalMaterials";
import { useExportAllLessonAssets } from "@/components/ExportsDialogs/useExportAllLessonAssets";
import { useExportLessonPlanDoc } from "@/components/ExportsDialogs/useExportLessonPlanDoc";
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/aila/[id]/share/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { useEffect, useState } from "react";

import { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import { PersistedModerationBase } from "@oakai/core/src/utils/ailaModeration/moderationSchema";
import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import type { PersistedModerationBase } from "@oakai/core/src/utils/ailaModeration/moderationSchema";
import { OakSmallPrimaryButton } from "@oaknational/oak-components";
import Link from "next/link";

Expand Down
5 changes: 3 additions & 2 deletions apps/nextjs/src/app/aila/[id]/share/page.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { User, clerkClient } from "@clerk/nextjs/server";
import type { User} from "@clerk/nextjs/server";
import { clerkClient } from "@clerk/nextjs/server";
import { getSessionModerations } from "@oakai/aila/src/features/moderation/getSessionModerations";
import { demoUsers } from "@oakai/core";
import { isToxic } from "@oakai/core/src/utils/ailaModeration/helpers";
import { PersistedModerationBase } from "@oakai/core/src/utils/ailaModeration/moderationSchema";
import type { PersistedModerationBase } from "@oakai/core/src/utils/ailaModeration/moderationSchema";
import { type Metadata } from "next";
import { notFound } from "next/navigation";

Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/app/api/aila-download-all/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { auth } from "@clerk/nextjs/server";
import { LessonExportType, prisma } from "@oakai/db";
import type { LessonExportType} from "@oakai/db";
import { prisma } from "@oakai/db";
import { downloadDriveFile } from "@oakai/exports";
import * as Sentry from "@sentry/node";
import { kv } from "@vercel/kv";
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/app/api/aila-download/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { auth } from "@clerk/nextjs/server";
import { LessonExportType, prisma } from "@oakai/db";
import type { LessonExportType} from "@oakai/db";
import { prisma } from "@oakai/db";
import { downloadDriveFile } from "@oakai/exports";
import * as Sentry from "@sentry/node";

Expand Down
14 changes: 8 additions & 6 deletions apps/nextjs/src/app/api/chat/chatHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Aila } from "@oakai/aila";
import type { Aila } from "@oakai/aila";
import type {
AilaInitializationOptions,
AilaOptions,
Expand All @@ -12,21 +12,23 @@ import {
PosthogAnalyticsAdapter,
} from "@oakai/aila/src/features/analytics";
import { AilaRag } from "@oakai/aila/src/features/rag/AilaRag";
import { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import type {
TracingSpan} from "@oakai/core/src/tracing/serverTracing";
import {
TracingSpan,
withTelemetry,
} from "@oakai/core/src/tracing/serverTracing";
import { PrismaClientWithAccelerate, prisma as globalPrisma } from "@oakai/db";
import type { PrismaClientWithAccelerate} from "@oakai/db";
import { prisma as globalPrisma } from "@oakai/db";
import { aiLogger } from "@oakai/logger";
// #TODO StreamingTextResponse is deprecated. If we choose to adopt the "ai" package
// more fully, we should refactor to support its approach to streaming
// but this could be a significant change given we have our record-separator approach
import { StreamingTextResponse } from "ai";
import { NextRequest } from "next/server";
import type { NextRequest } from "next/server";
import invariant from "tiny-invariant";

import { Config } from "./config";
import type { Config } from "./config";
import { handleChatException } from "./errorHandling";
import {
getFixtureLLMService,
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/app/api/chat/config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Aila, AilaInitializationOptions } from "@oakai/aila";
import type { AilaInitializationOptions } from "@oakai/aila";
import { Aila } from "@oakai/aila";
import {
prisma as globalPrisma,
type PrismaClientWithAccelerate,
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/api/chat/errorHandling.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AilaAuthenticationError, AilaThreatDetectionError } from "@oakai/aila";
import * as moderationErrorHandling from "@oakai/aila/src/utils/moderation/moderationErrorHandling";
import { UserBannedError } from "@oakai/core/src/models/safetyViolations";
import { TracingSpan } from "@oakai/core/src/tracing/serverTracing";
import type { TracingSpan } from "@oakai/core/src/tracing/serverTracing";
import { RateLimitExceededError } from "@oakai/core/src/utils/rateLimiting/userBasedRateLimiter";
import { PrismaClientWithAccelerate } from "@oakai/db";
import type { PrismaClientWithAccelerate } from "@oakai/db";
import invariant from "tiny-invariant";

import {
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/api/chat/errorHandling.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AilaAuthenticationError, AilaThreatDetectionError } from "@oakai/aila";
import {
import type {
ActionDocument,
ErrorDocument,
} from "@oakai/aila/src/protocol/jsonPatchProtocol";
import { handleHeliconeError } from "@oakai/aila/src/utils/moderation/moderationErrorHandling";
import { UserBannedError } from "@oakai/core/src/models/safetyViolations";
import { TracingSpan } from "@oakai/core/src/tracing/serverTracing";
import type { TracingSpan } from "@oakai/core/src/tracing/serverTracing";
import { RateLimitExceededError } from "@oakai/core/src/utils/rateLimiting/userBasedRateLimiter";
import { PrismaClientWithAccelerate } from "@oakai/db";
import type { PrismaClientWithAccelerate } from "@oakai/db";

import { streamingJSON } from "./protocol";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Message } from "@oakai/aila";
import { LLMService } from "@oakai/aila/src/core/llm/LLMService";
import type { Message } from "@oakai/aila";
import type { LLMService } from "@oakai/aila/src/core/llm/LLMService";
import { OpenAIService } from "@oakai/aila/src/core/llm/OpenAIService";
import { aiLogger } from "@oakai/logger";
import fs from "fs/promises";
import { ZodSchema } from "zod";
import type { ZodSchema } from "zod";

const log = aiLogger("fixtures");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { OpenAILike } from "@oakai/aila/src/features/moderation/moderators/OpenAiModerator";
import type { OpenAILike } from "@oakai/aila/src/features/moderation/moderators/OpenAiModerator";
import { createOpenAIClient } from "@oakai/core/src/llm/openai";
import { aiLogger } from "@oakai/logger";
import fs from "fs/promises";
import OpenAI from "openai";
import { ChatCompletionCreateParamsNonStreaming } from "openai/resources";
import type OpenAI from "openai";
import type { ChatCompletionCreateParamsNonStreaming } from "openai/resources";

const log = aiLogger("fixtures");

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { OpenAILike } from "@oakai/aila/src/features/moderation/moderators/OpenAiModerator";
import type { OpenAILike } from "@oakai/aila/src/features/moderation/moderators/OpenAiModerator";
import { aiLogger } from "@oakai/logger";
import fs from "fs/promises";
import OpenAI from "openai";
import type OpenAI from "openai";

const log = aiLogger("fixtures");

Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/chat/protocol.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {
import type {
ActionDocument,
ErrorDocument,
} from "@oakai/aila/src/protocol/jsonPatchProtocol";
Expand Down
5 changes: 3 additions & 2 deletions apps/nextjs/src/app/api/chat/route.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { Aila, AilaInitializationOptions } from "@oakai/aila";
import type { AilaInitializationOptions } from "@oakai/aila";
import { Aila } from "@oakai/aila";
import { MockLLMService } from "@oakai/aila/src/core/llm/MockLLMService";
import { MockCategoriser } from "@oakai/aila/src/features/categorisation/categorisers/MockCategoriser";
import { mockTracer } from "@oakai/core/src/tracing/mockTracer";
import { NextRequest } from "next/server";

import { expectTracingSpan } from "../../../utils/testHelpers/tracing";
import { handleChatPostRequest } from "./chatHandler";
import { Config } from "./config";
import type { Config } from "./config";

const chatId = "test-chat-id";
const userId = "test-user-id";
Expand Down
5 changes: 3 additions & 2 deletions apps/nextjs/src/app/api/chat/route.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { NextRequest } from "next/server";
import type { NextRequest } from "next/server";

import { withSentry } from "@/lib/sentry/withSentry";

import { handleChatPostRequest } from "./chatHandler";
import { Config, defaultConfig } from "./config";
import type { Config} from "./config";
import { defaultConfig } from "./config";

async function postHandler(req: NextRequest): Promise<Response> {
const config: Config = defaultConfig;
Expand Down
6 changes: 3 additions & 3 deletions apps/nextjs/src/app/api/chat/webActionsPlugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AilaThreatDetectionError } from "@oakai/aila";
import { AilaPluginContext } from "@oakai/aila/src/core/plugins";
import type { AilaPluginContext } from "@oakai/aila/src/core/plugins";
import { inngest } from "@oakai/core";
import { UserBannedError } from "@oakai/core/src/models/safetyViolations";
import { PrismaClientWithAccelerate } from "@oakai/db";
import { Moderation } from "@prisma/client";
import type { PrismaClientWithAccelerate } from "@oakai/db";
import type { Moderation } from "@prisma/client";

import { createWebActionsPlugin } from "./webActionsPlugin";

Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/api/chat/webActionsPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { AilaThreatDetectionError } from "@oakai/aila";
import { AilaPlugin } from "@oakai/aila/src/core/plugins";
import type { AilaPlugin } from "@oakai/aila/src/core/plugins";
import { handleHeliconeError } from "@oakai/aila/src/utils/moderation/moderationErrorHandling";
import {
SafetyViolations as defaultSafetyViolations,
inngest,
} from "@oakai/core";
import { UserBannedError } from "@oakai/core/src/models/safetyViolations";
import { PrismaClientWithAccelerate } from "@oakai/db";
import type { PrismaClientWithAccelerate } from "@oakai/db";
import { aiLogger } from "@oakai/logger";
import { waitUntil } from "@vercel/functions";

Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/app/api/qd-download/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { auth } from "@clerk/nextjs/server";
import { LessonExportType, prisma } from "@oakai/db";
import type { LessonExportType} from "@oakai/db";
import { prisma } from "@oakai/db";
import { downloadDriveFile } from "@oakai/exports";
import * as Sentry from "@sentry/node";

Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/trpc/chat/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { chatAppRouter } from "@oakai/api/src/router/chat";
import { aiLogger } from "@oakai/logger";
import * as Sentry from "@sentry/nextjs";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { NextRequest, NextResponse } from "next/server";
import type { NextRequest, NextResponse } from "next/server";

import { withSentry } from "@/lib/sentry/withSentry";

Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/trpc/main/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { oakAppRouter } from "@oakai/api/src/router";
import { aiLogger } from "@oakai/logger";
import * as Sentry from "@sentry/nextjs";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { NextRequest, NextResponse } from "next/server";
import type { NextRequest, NextResponse } from "next/server";

import { withSentry } from "@/lib/sentry/withSentry";

Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/trpc/test-support/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { router } from "@oakai/api/src/trpc";
import { aiLogger } from "@oakai/logger";
import * as Sentry from "@sentry/nextjs";
import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { NextRequest, NextResponse } from "next/server";
import type { NextRequest, NextResponse } from "next/server";

import { withSentry } from "@/lib/sentry/withSentry";

Expand Down
Loading

0 comments on commit 6435a39

Please sign in to comment.