diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a2b8c57..799ae3a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,3 +46,16 @@ jobs: run: npm install - name: Run tests run: npm run test + + types: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version-file: ".nvmrc" + - name: Install dependencies + run: npm install + - name: Check types + run: npm run check diff --git a/package-lock.json b/package-lock.json index 343217b..a03ee0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,7 +12,6 @@ "@ai-sdk/anthropic": "^1.2.12", "@ai-sdk/google": "^1.2.22", "@ai-sdk/openai": "^1.3.22", - "@iiif/parser": "^2.2.0", "@langchain/community": "^0.3.53", "@langchain/core": "^0.3.72", "ai": "^4.3.19", @@ -23,7 +22,6 @@ "devDependencies": { "@alcalzone/esm2cjs": "^1.4.1", "@eslint/js": "^9.28.0", - "@iiif/presentation-3": "^2.2.3", "@samvera/clover-iiif": "^2.16.9", "@storybook/addon-a11y": "^9.0.9", "@storybook/addon-docs": "^9.0.9", @@ -56,6 +54,8 @@ "vitest": "^3.2.4" }, "peerDependencies": { + "@iiif/parser": "^2.2.0", + "@iiif/presentation-3": "^2.2.3", "@samvera/clover-iiif": "^2.16.8", "react": "^18.3.1", "react-dom": "^18.3.1" @@ -1758,19 +1758,32 @@ } }, "node_modules/@eslint/plugin-kit": { - "version": "0.3.1", - "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.1.tgz", - "integrity": "sha512-0J+zgWxHN+xXONWIyPWKFMgVuJoZuGiIFu8yxk7RJjxkzpGmyja5wRFqZIVtjDVOQpV+Rw0iOAjYPE2eQyjr0w==", + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.3.5.tgz", + "integrity": "sha512-Z5kJ+wU3oA7MMIqVR9tyZRtjYPr4OC004Q4Rw7pgOKUOKkJfZ3O24nz3WYfGRpMDNmcOi3TwQOmgm7B7Tpii0w==", "dev": true, "license": "Apache-2.0", "dependencies": { - "@eslint/core": "^0.14.0", + "@eslint/core": "^0.15.2", "levn": "^0.4.1" }, "engines": { "node": "^18.18.0 || ^20.9.0 || >=21.1.0" } }, + "node_modules/@eslint/plugin-kit/node_modules/@eslint/core": { + "version": "0.15.2", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.15.2.tgz", + "integrity": "sha512-78Md3/Rrxh83gCxoUc0EiciuOHsIITzLy53m3d9UyiW8y9Dj2D29FeETqyKA+BRK76tnTp6RXWb3pCay8Oyomg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@types/json-schema": "^7.0.15" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@floating-ui/core": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/@floating-ui/core/-/core-1.7.0.tgz", @@ -5130,9 +5143,9 @@ } }, "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", + "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", "dev": true, "license": "MIT", "dependencies": { @@ -6115,9 +6128,9 @@ } }, "node_modules/brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "version": "1.1.12", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.12.tgz", + "integrity": "sha512-9T9UjW3r0UW5c1Q7GTwllptXwhvYmEzFhzMfZ9H7FQWt+uZePjZPjBP/W1ZEyZ1twGWom5/56TF4lPcqjnDHcg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 0aef9d5..4864c0d 100644 --- a/package.json +++ b/package.json @@ -55,6 +55,8 @@ "prepare": "npm run build" }, "peerDependencies": { + "@iiif/parser": "^2.2.0", + "@iiif/presentation-3": "^2.2.3", "@samvera/clover-iiif": "^2.16.8", "react": "^18.3.1", "react-dom": "^18.3.1" @@ -63,7 +65,6 @@ "@ai-sdk/anthropic": "^1.2.12", "@ai-sdk/google": "^1.2.22", "@ai-sdk/openai": "^1.3.22", - "@iiif/parser": "^2.2.0", "@langchain/community": "^0.3.53", "@langchain/core": "^0.3.72", "ai": "^4.3.19", @@ -74,7 +75,6 @@ "devDependencies": { "@alcalzone/esm2cjs": "^1.4.1", "@eslint/js": "^9.28.0", - "@iiif/presentation-3": "^2.2.3", "@samvera/clover-iiif": "^2.16.9", "@storybook/addon-a11y": "^9.0.9", "@storybook/addon-docs": "^9.0.9", diff --git a/src/components/Messages/index.test.tsx b/src/components/Messages/index.test.tsx index 9a126c6..c20837d 100644 --- a/src/components/Messages/index.test.tsx +++ b/src/components/Messages/index.test.tsx @@ -14,7 +14,7 @@ describe("MessagesContainer", () => { }); const messages: IMessage[] = [ - { role: "user", content: [{ type: "text", content: "Hello" }] }, + { role: "user", content: [{ type: "text", content: "Hello" }], context: { canvas: {} as any } }, { role: "assistant", type: "response", content: { type: "text", content: "Hi there!" } }, ]; @@ -43,7 +43,11 @@ describe("MessagesContainer", () => { it("updates filler height when a new user message is added", () => { const initialMessages: IMessage[] = [ - { role: "user", content: [{ type: "text", content: "Hello" }] }, + { + role: "user", + content: [{ type: "text", content: "Hello" }], + context: { canvas: {} as any }, + }, { role: "assistant", type: "response", content: { type: "text", content: "Hi there!" } }, ]; @@ -71,7 +75,11 @@ describe("MessagesContainer", () => { // Add a new user message const updatedMessages: IMessage[] = [ ...initialMessages, - { role: "user", content: [{ type: "text", content: "How are you?" }] }, + { + role: "user", + content: [{ type: "text", content: "How are you?" }], + context: { canvas: {} as any }, + }, ]; rerender(); @@ -86,9 +94,17 @@ describe("MessagesContainer", () => { it("updates filler height when a new assistant message is added", () => { const initialMessages: IMessage[] = [ - { role: "user", content: [{ type: "text", content: "Hello" }] }, + { + role: "user", + content: [{ type: "text", content: "Hello" }], + context: { canvas: {} as any }, + }, { role: "assistant", type: "response", content: { type: "text", content: "Hi there!" } }, - { role: "user", content: [{ type: "text", content: "How are you?" }] }, + { + role: "user", + content: [{ type: "text", content: "How are you?" }], + context: { canvas: {} as any }, + }, ]; // Mock clientHeight with realistic values diff --git a/src/plugin/context/plugin-context.test.tsx b/src/plugin/context/plugin-context.test.tsx index 1dbc44a..3199779 100644 --- a/src/plugin/context/plugin-context.test.tsx +++ b/src/plugin/context/plugin-context.test.tsx @@ -77,7 +77,11 @@ describe("pluginReducer", () => { it("should handle addMessages", () => { const newMessages: Message[] = [ - { role: "user", content: [{ type: "text", content: "Hello" }] }, + { + role: "user", + content: [{ type: "text", content: "Hello" }], + context: { canvas: {} as any }, + }, ]; const action: PluginContextActions = { type: "addMessages", messages: newMessages }; const newState = pluginReducer(mockInitialState, action); @@ -90,7 +94,11 @@ describe("pluginReducer", () => { ...mockInitialState, messages: [ { role: "system", content: { type: "text", content: "System prompt" } }, - { role: "user", content: [{ type: "text", content: "Hello" }] }, + { + role: "user", + content: [{ type: "text", content: "Hello" }], + context: { canvas: {} as any }, + }, ], }; const action: PluginContextActions = { type: "clearConversation" }; @@ -279,7 +287,13 @@ describe("PluginContextProvider", () => { }); it("should initialize with messages from storage", () => { - const storedMessages = [{ role: "user", content: [{ type: "text", content: "from storage" }] }]; + const storedMessages = [ + { + role: "user", + content: [{ type: "text", content: "from storage" }], + context: { canvas: {} as any }, + }, + ]; (loadMessagesFromStorage as Mock).mockReturnValue(storedMessages); const TestMessagesComponent = () => {