Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update imports (type prefixes, paths) #298

Merged
merged 2 commits into from
Oct 29, 2024
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
1 change: 0 additions & 1 deletion apps/nextjs/.storybook/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import "@fontsource/lexend/800.css";
import "@fontsource/lexend/900.css";
import { OakThemeProvider, oakDefaultTheme } from "@oaknational/oak-components";
import type { Preview, Decorator } from "@storybook/react";
import { GeistMono } from "geist/font/mono";

// ModerationProvider is coming in the main Chat.tsx refactor
//import { ModerationProvider } from "../src/components/AppComponents/Chat/Chat/ModerationProvider";
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/scripts/aila-cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Aila } from "@oakai/aila";
import { Aila } from "@oakai/aila/src/core/Aila";
import { AilaPlugin } from "@oakai/aila/src/core/plugins";

const cliPlugin: AilaPlugin = {
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/ai-apps/common/getSessionOutput.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Apps } from "@oakai/core";
import { Apps } from "@oakai/core/src/models/apps";
import { prisma } from "@oakai/db";
import { outputSchema } from "ai-apps/generations/types";

Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/admin/aila/[chatId]/view.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useState } from "react";

import { type AilaPersistedChat } from "@oakai/aila/src/protocol/schema";
import type { AilaPersistedChat } from "@oakai/aila/src/protocol/schema";
import { getSafetyResult } from "@oakai/core/src/utils/ailaModeration/helpers";
import { type Moderation } from "@oakai/db";
import type { Moderation } from "@oakai/db";
import { OakAccordion, OakPrimaryButton } from "@oaknational/oak-components";

import { trpc } from "@/utils/trpc";
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/aila/[id]/download/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { auth } from "@clerk/nextjs/server";
import { type Metadata } from "next";
import type { Metadata } from "next";
import { notFound, redirect } from "next/navigation";

import { getChatById } from "@/app/actions";
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/aila/[id]/share/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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 { demoUsers } from "@oakai/core/src/models/demoUsers";
import { isToxic } from "@oakai/core/src/utils/ailaModeration/helpers";
import type { PersistedModerationBase } from "@oakai/core/src/utils/ailaModeration/moderationSchema";
import { type Metadata } from "next";
import type { Metadata } from "next";
import { notFound } from "next/navigation";

import { getSharedChatById } from "@/app/actions";
Expand Down
12 changes: 6 additions & 6 deletions apps/nextjs/src/app/api/chat/chatHandler.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { Aila } from "@oakai/aila";
import type { Aila } from "@oakai/aila/src/core/Aila";
import type { AilaServices } from "@oakai/aila/src/core/AilaServices";
import type { Message } from "@oakai/aila/src/core/chat";
import type { AilaInitializationOptions } from "@oakai/aila/src/core/types";
import type {
AilaInitializationOptions,
AilaOptions,
AilaPublicChatOptions,
AilaServices,
Message,
} from "@oakai/aila";
} from "@oakai/aila/src/core/types";
import { AilaAmericanisms } from "@oakai/aila/src/features/americanisms/AilaAmericanisms";
import {
DatadogAnalyticsAdapter,
Expand All @@ -16,7 +16,7 @@ import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import type { TracingSpan } from "@oakai/core/src/tracing/serverTracing";
import { withTelemetry } from "@oakai/core/src/tracing/serverTracing";
import type { PrismaClientWithAccelerate } from "@oakai/db";
import { prisma as globalPrisma } from "@oakai/db";
import { prisma as globalPrisma } from "@oakai/db/client";
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
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/api/chat/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AilaInitializationOptions } from "@oakai/aila";
import { Aila } from "@oakai/aila";
import { Aila } from "@oakai/aila/src/core/Aila";
import type { AilaInitializationOptions } from "@oakai/aila/src/core/types";
import {
prisma as globalPrisma,
type PrismaClientWithAccelerate,
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/app/api/chat/errorHandling.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { AilaAuthenticationError, AilaThreatDetectionError } from "@oakai/aila";
import { AilaAuthenticationError } from "@oakai/aila/src/core/AilaError";
import { AilaThreatDetectionError } from "@oakai/aila/src/features/threatDetection";
import type {
ActionDocument,
ErrorDocument,
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/api/chat/route.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AilaInitializationOptions } from "@oakai/aila";
import { Aila } from "@oakai/aila";
import { Aila } from "@oakai/aila/src/core/Aila";
import { MockLLMService } from "@oakai/aila/src/core/llm/MockLLMService";
import type { AilaInitializationOptions } from "@oakai/aila/src/core/types";
import { MockCategoriser } from "@oakai/aila/src/features/categorisation/categorisers/MockCategoriser";
import { mockTracer } from "@oakai/core/src/tracing/mockTracer";
import { NextRequest } from "next/server";
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/src/app/api/chat/user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { auth, clerkClient } from "@clerk/nextjs/server";
import { AilaAuthenticationError } from "@oakai/aila/src/core/AilaError";
import { demoUsers, inngest } from "@oakai/core";
import { demoUsers } from "@oakai/core";
import { posthogAiBetaServerClient } from "@oakai/core/src/analytics/posthogAiBetaServerClient";
import { inngest } from "@oakai/core/src/inngest";
import { UserBannedError } from "@oakai/core/src/models/userBannedError";
import { withTelemetry } from "@oakai/core/src/tracing/serverTracing";
import { rateLimits } from "@oakai/core/src/utils/rateLimiting/rateLimit";
Expand Down
3 changes: 1 addition & 2 deletions apps/nextjs/src/app/api/chat/webActionsPlugin.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AilaPluginContext } from "@oakai/aila/src/core/plugins";
import { AilaThreatDetectionError } from "@oakai/aila/src/features/threatDetection/types";
import { inngest } from "@oakai/core/src/inngest";
import { UserBannedError } from "@oakai/core/src/models/userBannedError";
import type { PrismaClientWithAccelerate } from "@oakai/db";
import type { Moderation } from "@prisma/client";
Expand Down Expand Up @@ -68,8 +69,6 @@ describe("webActionsPlugin", () => {
enqueue: mockEnqueue,
};

const { inngest } = await import("@oakai/core/src/inngest");

const plugin = createWebActionsPlugin(prisma, safetyViolations);
await plugin.onToxicModeration(moderation, pluginContext);

Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/app/lesson-planner/preview/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Apps } from "@oakai/core";
import { prisma } from "@oakai/db";
import { Apps } from "@oakai/core/src/models/apps";
import { prisma } from "@oakai/db/client";
import { aiLogger } from "@oakai/logger";

import { LessonPlanPreview } from "./preview";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "@oakai/aila/src/protocol/jsonPatchProtocol";
import type { LooseLessonPlan } from "@oakai/aila/src/protocol/schema";
import { useThrottle } from "@uidotdev/usehooks";
import { type Message } from "ai/react";
import type { Message } from "ai/react";
import { deepClone } from "fast-json-patch";
import hash from "object-hash";
import { equals } from "remeda";
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/utils/checkFeatureFlag.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type PostHog } from "posthog-js";
import type { PostHog } from "posthog-js";

export function checkFeatureFlag(
posthogClient: PostHog,
Expand Down
4 changes: 2 additions & 2 deletions apps/nextjs/src/utils/trpc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import { useState } from "react";

import { type AppRouter } from "@oakai/api/src/router";
import { type ChatAppRouter } from "@oakai/api/src/router/chat";
import type { AppRouter } from "@oakai/api/src/router";
import type { ChatAppRouter } from "@oakai/api/src/router/chat";
import { transformer } from "@oakai/api/transformer";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import type { TRPCLink } from "@trpc/client";
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/tests-e2e/config/common-persona.setup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Page, test as setup } from "@playwright/test";
import type { Page } from "@playwright/test";
import { test as setup } from "@playwright/test";
import path from "path";

import { prepareUser } from "../helpers/auth";
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/tests-e2e/helpers/auth/clerkHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Page, expect } from "@playwright/test";
import type { Page } from "@playwright/test";
import { expect } from "@playwright/test";

/**
* This file replicates helpers provided by @clerk/testing
Expand Down
5 changes: 3 additions & 2 deletions apps/nextjs/tests-e2e/helpers/auth/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { setupClerkTestingToken } from "@clerk/testing/playwright";
import { TestSupportRouter } from "@oakai/api/src/router/testSupport";
import type { TestSupportRouter } from "@oakai/api/src/router/testSupport";
import { transformer } from "@oakai/api/transformer";
import { test, Page } from "@playwright/test";
import type { Page } from "@playwright/test";
import { test } from "@playwright/test";
import { createTRPCProxyClient, httpBatchLink, loggerLink } from "@trpc/client";

import {
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/tests-e2e/helpers/vercel.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BrowserContext, Page } from "@playwright/test";
import type { BrowserContext, Page } from "@playwright/test";

import {
TEST_BASE_URL,
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/tests-e2e/tests/aila-chat/downloads.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { setupClerkTestingToken } from "@clerk/testing/playwright";
import { test, expect, Page } from "@playwright/test";
import type { Page } from "@playwright/test";
import { test, expect } from "@playwright/test";

import { TEST_BASE_URL } from "../../config/config";
import { bypassVercelProtection } from "../../helpers/vercel";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { setupClerkTestingToken } from "@clerk/testing/playwright";
import { test, expect, Page } from "@playwright/test";
import type { Page } from "@playwright/test";
import { test, expect } from "@playwright/test";

import { TEST_BASE_URL } from "../../config/config";
import { bypassVercelProtection } from "../../helpers/vercel";
import type { FixtureMode } from "./helpers";
import {
FixtureMode,
applyLlmFixtures,
continueChat,
expectFinished,
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/tests-e2e/tests/aila-chat/full-romans.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { test, expect } from "@playwright/test";

import { TEST_BASE_URL } from "../../config/config";
import { bypassVercelProtection } from "../../helpers/vercel";
import type { FixtureMode } from "./helpers";
import {
FixtureMode,
applyLlmFixtures,
continueChat,
expectFinished,
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/tests-e2e/tests/auth.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { setupClerkTestingToken } from "@clerk/testing/playwright";
import { Page, expect, test } from "@playwright/test";
import type { Page } from "@playwright/test";
import { expect, test } from "@playwright/test";

import {
TEST_USER_EMAIL,
Expand Down
3 changes: 2 additions & 1 deletion apps/nextjs/tests-e2e/tests/sharing.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { test, expect, Page } from "@playwright/test";
import type { Page } from "@playwright/test";
import { test, expect } from "@playwright/test";

import { TEST_BASE_URL } from "../config/config";
import { prepareUser } from "../helpers/auth";
Expand Down
2 changes: 1 addition & 1 deletion packages/ingest/src/import-lessons/importLessons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { aiLogger } from "@oakai/logger";

import { IngestError } from "../IngestError";
import { getDataHash } from "../utils/getDataHash";
import type { RawLesson} from "../zod-schema/zodSchema";
import type { RawLesson } from "../zod-schema/zodSchema";
import { RawLessonSchema } from "../zod-schema/zodSchema";
import { graphqlClient } from "./graphql/client";
import { query } from "./graphql/query";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { prisma } from "@oakai/db";
import { IngestError } from "../IngestError";
import type { IngestLogger } from "../types";
import { getDataHash } from "../utils/getDataHash";
import type { RawLesson} from "../zod-schema/zodSchema";
import type { RawLesson } from "../zod-schema/zodSchema";
import { RawLessonSchema } from "../zod-schema/zodSchema";
import { graphqlClient } from "./graphql/client";
import { query } from "./graphql/query";
Expand Down
15 changes: 11 additions & 4 deletions packages/ingest/src/openai-batches/handleOpenAiBatchErrorFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { PrismaClientWithAccelerate } from "@oakai/db";
import type { Step } from "../db-helpers/step";
import { updateLessonsState } from "../db-helpers/updateLessonsState";
import { jsonlToArray } from "../utils/jsonlToArray";
import type { BatchTask} from "./customId";
import type { BatchTask } from "./customId";
import { getLessonIdFromCustomId } from "./customId";
import { downloadOpenAiFile } from "./downloadOpenAiFile";

Expand Down Expand Up @@ -34,9 +34,16 @@ export async function handleOpenAiBatchErrorFile({
});
const text = await file.text();
const jsonArray = jsonlToArray(text);
const lessonIds = jsonArray.map((json) =>
getLessonIdFromCustomId(json.custom_id),
);
const lessonIds = jsonArray
.map((json) =>
typeof json === "object" &&
json !== null &&
"custom_id" in json &&
typeof json.custom_id === "string"
? getLessonIdFromCustomId(json.custom_id)
: undefined,
)
.filter((lessonId): lessonId is string => lessonId !== undefined);

await updateLessonsState({
ingestId,
Expand Down
9 changes: 3 additions & 6 deletions packages/ingest/src/openai-batches/startBatch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ import { aiLogger } from "@oakai/logger";
import { splitJsonlByRowsOrSize } from "../utils/splitJsonlByRowsOrSize";
import { OPEN_AI_BATCH_MAX_ROWS, OPEN_AI_BATCH_MAX_SIZE_MB } from "./constants";
import { getCustomIdsFromJsonlFile } from "./getCustomIdsFromJsonlFile";
import type {
OpenAiBatchSubmitCallback} from "./submitOpenAiBatch";
import {
submitOpenAiBatch,
} from "./submitOpenAiBatch";
import type { OpenAiBatchSubmitCallback } from "./submitOpenAiBatch";
import { submitOpenAiBatch } from "./submitOpenAiBatch";
import { uploadOpenAiBatchFile } from "./uploadOpenAiBatchFile";
import type { GetBatchFileLine} from "./writeBatchFile";
import type { GetBatchFileLine } from "./writeBatchFile";
import { writeBatchFile } from "./writeBatchFile";

const log = aiLogger("ingest");
Expand Down
2 changes: 1 addition & 1 deletion packages/ingest/src/steps/1-captions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { createCaptionsRecord } from "../db-helpers/createCaptionsRecord";
import { createErrorRecord } from "../db-helpers/createErrorRecord";
import { getIngestById } from "../db-helpers/getIngestById";
import { loadLessonsAndUpdateState } from "../db-helpers/loadLessonsAndUpdateState";
import type { Step} from "../db-helpers/step";
import type { Step } from "../db-helpers/step";
import { getPrevStep } from "../db-helpers/step";
import { updateLessonsState } from "../db-helpers/updateLessonsState";
import type { IngestLogger } from "../types";
Expand Down
9 changes: 3 additions & 6 deletions packages/ingest/src/steps/4-lp-chunking.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import type {
CompletedLessonPlan} from "@oakai/aila/src/protocol/schema";
import {
CompletedLessonPlanSchema,
} from "@oakai/aila/src/protocol/schema";
import type { CompletedLessonPlan } from "@oakai/aila/src/protocol/schema";
import { CompletedLessonPlanSchema } from "@oakai/aila/src/protocol/schema";
import type { PrismaClientWithAccelerate } from "@oakai/db";

import { getLessonPlanParts } from "../chunking/getLessonPlanParts";
import { loadLessonsAndUpdateState } from "../db-helpers/loadLessonsAndUpdateState";
import type { Step} from "../db-helpers/step";
import type { Step } from "../db-helpers/step";
import { getPrevStep } from "../db-helpers/step";
import { updateLessonsState } from "../db-helpers/updateLessonsState";
import type { IngestLogger } from "../types";
Expand Down
2 changes: 1 addition & 1 deletion packages/ingest/src/steps/5-lp-parts-embed-start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { PrismaClientWithAccelerate } from "@oakai/db";

import { getIngestById } from "../db-helpers/getIngestById";
import { loadLessonsAndUpdateState } from "../db-helpers/loadLessonsAndUpdateState";
import type { Step} from "../db-helpers/step";
import type { Step } from "../db-helpers/step";
import { getPrevStep } from "../db-helpers/step";
import { startEmbedding } from "../embedding/startEmbedding";
import { parseCustomId } from "../openai-batches/customId";
Expand Down
Loading