Skip to content

Commit

Permalink
Merge branch 'main' into test/rate-limiting
Browse files Browse the repository at this point in the history
  • Loading branch information
codeincontext authored Oct 29, 2024
2 parents 4ced188 + bc8ef36 commit 4615bed
Show file tree
Hide file tree
Showing 462 changed files with 5,289 additions and 3,820 deletions.
7 changes: 1 addition & 6 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @type {import("eslint").Linter.Config} */
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
extends: ["eslint-config-custom"],
parserOptions: {
tsconfigRootDir: __dirname,
project: [
Expand All @@ -10,9 +10,4 @@ module.exports = {
"./packages/*/tsconfig.json",
],
},
plugins: ["@typescript-eslint"],
extends: ["plugin:@typescript-eslint/recommended"],
rules: {
"no-console": "warn"
}
};
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
run: pnpm install

- name: Generate prisma client
run: pnpm db-generate
run: pnpm db-generate:no-engine

- name: Inject Doppler env vars
uses: dopplerhq/[email protected]
Expand All @@ -43,4 +43,4 @@ jobs:
inject-env-vars: true

- name: Run tests
run: pnpm turbo test --cache-dir=".turbo"
run: pnpm turbo test --cache-dir=".turbo" -- --maxWorkers=33%
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"turborepo",
"uidotdev",
"unjudged",
"unsets",
"unsummarised",
"untruncate",
"untruncated",
Expand Down Expand Up @@ -193,5 +194,6 @@
"yaml.schemas": {
"file:///c%3A/Users/Simon/.vscode/extensions/atlassian.atlascode-2.8.6/resources/schemas/pipelines-schema.json": "bitbucket-pipelines.yml",
"https://www.artillery.io/schema.json": []
}
},
"typescript.preferences.preferTypeOnlyAutoImports": true
}
31 changes: 31 additions & 0 deletions CHANGE_LOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
## [1.12.1](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.12.0...v1.12.1) (2024-10-28)


### Bug Fixes

* hide streaming status in production ([#281](https://github.com/oaknational/oak-ai-lesson-assistant/issues/281)) ([1efc89e](https://github.com/oaknational/oak-ai-lesson-assistant/commit/1efc89eabd23d226060ad84b60010a5ff5cd9674))

# [1.12.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.11.0...v1.12.0) (2024-10-28)


### Bug Fixes

* ensure that the patch enqueuer exists when enqueuing ([#264](https://github.com/oaknational/oak-ai-lesson-assistant/issues/264)) ([4d4b959](https://github.com/oaknational/oak-ai-lesson-assistant/commit/4d4b9599996482817411237a13174ed55ef6c476))
* logger to stdout for info and warn ([#266](https://github.com/oaknational/oak-ai-lesson-assistant/issues/266)) ([d2dfabc](https://github.com/oaknational/oak-ai-lesson-assistant/commit/d2dfabcb41ed85a731435ed8283540cd974b0de5))
* module resolution with "node" instead of "bundler" ([#271](https://github.com/oaknational/oak-ai-lesson-assistant/issues/271)) ([44ca5f6](https://github.com/oaknational/oak-ai-lesson-assistant/commit/44ca5f6cebd7d9a7f047cfad558030cb206b4f3c))
* reduce turbo errors on local dev, enable running e2e in built mode ([#259](https://github.com/oaknational/oak-ai-lesson-assistant/issues/259)) ([afb4535](https://github.com/oaknational/oak-ai-lesson-assistant/commit/afb453581c3dbe2b01a4e0712df97a7779d59e6c))
* refactor lesson snapshots for improved efficiency ([#234](https://github.com/oaknational/oak-ai-lesson-assistant/issues/234)) ([24f492d](https://github.com/oaknational/oak-ai-lesson-assistant/commit/24f492dc79e6a9dc94e213c4f447802e750c99db))
* reinstate prebuilding the chat route in local dev ([#260](https://github.com/oaknational/oak-ai-lesson-assistant/issues/260)) ([1a4c51f](https://github.com/oaknational/oak-ai-lesson-assistant/commit/1a4c51fa4b2b53e758f860091c85f840c191dc9f))
* remove flash when loading wheel appears ([#268](https://github.com/oaknational/oak-ai-lesson-assistant/issues/268)) ([d7a70f3](https://github.com/oaknational/oak-ai-lesson-assistant/commit/d7a70f353be0c6e1a833f5ec922d2e62f71bba7f))
* remove lessonReferences from prompt ([#253](https://github.com/oaknational/oak-ai-lesson-assistant/issues/253)) ([a0cedec](https://github.com/oaknational/oak-ai-lesson-assistant/commit/a0cedec86924a1bf0cf2466bd7a5ef106d7f8272))
* report chat completion errors ([#256](https://github.com/oaknational/oak-ai-lesson-assistant/issues/256)) ([13729ca](https://github.com/oaknational/oak-ai-lesson-assistant/commit/13729ca4d0d64f436309575bf8be50640604c710))
* update prisma to latest version ([#254](https://github.com/oaknational/oak-ai-lesson-assistant/issues/254)) ([b8b1958](https://github.com/oaknational/oak-ai-lesson-assistant/commit/b8b1958c914b405e859cf39163fa531bef9e99d5))


### Features

* add a test:seq command ([#273](https://github.com/oaknational/oak-ai-lesson-assistant/issues/273)) ([d04d456](https://github.com/oaknational/oak-ai-lesson-assistant/commit/d04d456bd2b3968491088ed39631e11c23d2cf9c))
* hint Aila as to which part of the lesson to update next ([#265](https://github.com/oaknational/oak-ai-lesson-assistant/issues/265)) ([b8b39b8](https://github.com/oaknational/oak-ai-lesson-assistant/commit/b8b39b833c788ca7fc38c9319c401aae2c1d330a))
* ingest scripts ([#200](https://github.com/oaknational/oak-ai-lesson-assistant/issues/200)) ([be824a8](https://github.com/oaknational/oak-ai-lesson-assistant/commit/be824a8d73f8d0e2bc690789314ed7b0d135b090))
* local db setup scripts ([#132](https://github.com/oaknational/oak-ai-lesson-assistant/issues/132)) ([d531a50](https://github.com/oaknational/oak-ai-lesson-assistant/commit/d531a50229c604fa71157609fcde181eefb5e9b3))

# [1.11.0](https://github.com/oaknational/oak-ai-lesson-assistant/compare/v1.10.2...v1.11.0) (2024-10-22)


Expand Down
3 changes: 3 additions & 0 deletions apps/nextjs/.eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ module.exports = {
},
],
},
parserOptions: {
project: __dirname + "/tsconfig.json",
},
};
2 changes: 2 additions & 0 deletions apps/nextjs/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import type { StorybookConfig } from "@storybook/nextjs";
import { join, dirname, resolve } from "path";
import webpack from "webpack";

process.env.NEXT_PUBLIC_DEBUG = process.env.DEBUG;

/**
* This function is used to resolve the absolute path of a package.
* It is needed in projects that use Yarn PnP or are set up within a monorepo.
Expand Down
2 changes: 2 additions & 0 deletions apps/nextjs/jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
require("@testing-library/jest-dom");

process.env.NEXT_PUBLIC_DEBUG = process.env.DEBUG;

// Mock Next.js Image component
jest.mock("next/image", () => ({
__esModule: true,
Expand Down
58 changes: 27 additions & 31 deletions apps/nextjs/next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ const {
RELEASE_STAGE_TESTING,
} = require("./scripts/build_config_helpers.js");
const path = require("path");
const Sentry = require("@sentry/nextjs");

const { PHASE_PRODUCTION_BUILD, PHASE_TEST } = require("next/constants");

Expand Down Expand Up @@ -89,6 +88,7 @@ const getConfig = async (phase) => {
env: {
NEXT_PUBLIC_APP_VERSION: appVersion,
NEXT_PUBLIC_RELEASE_STAGE: releaseStage,
NEXT_PUBLIC_DEBUG: process.env.DEBUG,
},

productionBrowserSourceMaps: true,
Expand Down Expand Up @@ -155,41 +155,37 @@ const getConfig = async (phase) => {

module.exports = getConfig;

if (!process.env.TURBOPACK) {
module.exports = withSentryConfig(module.exports, {
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options
module.exports = withSentryConfig(module.exports, {
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,

// Only print logs for uploading source maps in CI
silent: !process.env.CI,
// Only print logs for uploading source maps in CI
silent: !process.env.CI,

// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,
// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-
// side errors will fail.
tunnelRoute: "/monitoring",

// Hides source maps from generated client bundles
hideSourceMaps: true,
// Hides source maps from generated client bundles
hideSourceMaps: true,

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,

// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
});
}

module.exports.onRequestError = Sentry.captureRequestError;
// Enables automatic instrumentation of Vercel Cron Monitors. (Does not yet work with App Router route handlers.)
// See the following for more information:
// https://docs.sentry.io/product/crons/
// https://vercel.com/docs/cron-jobs
automaticVercelMonitors: true,
});
11 changes: 5 additions & 6 deletions apps/nextjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@
"build:dev": "pnpm with-env next build",
"check": "tsc --noEmit",
"clean": "rm -rf .next .turbo node_modules",
"dev": "FORCE_COLOR=1 concurrently \"pnpm dev-server\" \"node scripts/local-dev.mjs\"",
"dev-turbo": "FORCE_COLOR=1 concurrently \"pnpm dev-server-turbo\" \"node scripts/local-dev.mjs\"",
"dev-server-turbo": "FORCE_COLOR=1 pnpm with-env node scripts/increase-listeners.js next dev --port 2525 --turbo | pino-pretty -C",
"dev-server": "FORCE_COLOR=1 pnpm with-env node scripts/increase-listeners.js next dev --port 2525 | pino-pretty -C",
"dev": "FORCE_COLOR=1 SENTRY_SUPPRESS_TURBOPACK_WARNING=1 pnpm with-env node scripts/increase-listeners.js next dev --port 2525 --turbo | pino-pretty -C",
"dev:sentry": "FORCE_COLOR=1 pnpm with-env node scripts/increase-listeners.js next dev --port 2525 | pino-pretty -C",
"dev-trace-deprecation": "NODE_OPTIONS=\"--trace-deprecation\" next dev --port 2525 | pino-pretty -C",
"lint": "next lint",
"lint-fix": "next lint --fix",
"start": "next start",
"type-check": "tsc --noEmit",
"test": "pnpm with-env jest --colors --config jest.config.js",
"test:seq": "pnpm with-env jest --colors --config jest.config.js --verbose --runInBand --no-cache",
"test-e2e": "pnpm with-env playwright test",
"test-e2e-ui": "pnpm with-env playwright test --ui",
"test-e2e-ui-serve": "pnpm build && pnpm start --port 4848 --turbo",
Expand Down Expand Up @@ -55,7 +54,7 @@
"@radix-ui/react-tooltip": "^1.0.7",
"@radix-ui/themes": "^1.0.0",
"@sanity/client": "^6.21.3",
"@sentry/nextjs": "^8.19.0",
"@sentry/nextjs": "^8.35.0",
"@storybook/testing-react": "^2.0.1",
"@tanstack/react-query": "^4.16.1",
"@testing-library/jest-dom": "^6.4.8",
Expand Down Expand Up @@ -150,7 +149,7 @@
"concurrently": "^8.2.2",
"dotenv-cli": "^6.0.0",
"eslint": "^8.56.0",
"eslint-config-next": "14.0.4",
"eslint-config-next": "15.0.1",
"eslint-plugin-storybook": "^0.8.0",
"graphql": "^16.9.0",
"jest": "^29.7.0",
Expand Down
File renamed without changes.
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
4 changes: 2 additions & 2 deletions apps/nextjs/src/ai-apps/common/state/create-parts.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {
import type {
GenerationPart,
GenerationPartAIGenerated,
GenerationPartType,
GenerationPartUserTweaked,
} from "@oakai/core/src/types";
import { GenerationPartType } from "@oakai/core/src/types";

export function createAIGeneratedPart<Value>(
value: 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
13 changes: 5 additions & 8 deletions apps/nextjs/src/ai-apps/quiz-designer/state/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,12 @@ 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 {
QuizAppState,
QuizAppStateQuestion,
QuizAppStatus,
QuizQuestionType,
} from "./types";
import type { QuizAppAction } from "./actions";
import { QuizAppActions } from "./actions";
import type { QuizAppState, QuizAppStateQuestion } from "./types";
import { QuizAppStatus, QuizQuestionType } from "./types";

export function quizAppReducer(
state: QuizAppState,
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
Loading

0 comments on commit 4615bed

Please sign in to comment.