From 54babf4825acd57ece3ca8120bca0277e9a55dfc Mon Sep 17 00:00:00 2001 From: pglez82 Date: Fri, 7 Feb 2025 12:31:03 +0100 Subject: [PATCH 01/19] updating api endpoint --- llmservice/llm-service.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llmservice/llm-service.js b/llmservice/llm-service.js index da0ff837..4788a50d 100644 --- a/llmservice/llm-service.js +++ b/llmservice/llm-service.js @@ -17,9 +17,9 @@ const llmConfigs = { transformResponse: (response) => response.data.candidates[0]?.content?.parts[0]?.text }, empathy: { - url: () => 'https://empathyai.staging.empathy.co/v1/chat/completions', + url: () => 'https://empathyai.prod.empathy.co/v1/chat/completions', transformRequest: (question) => ({ - model: "qwen/Qwen2.5-Coder-7B-Instruct", + model: "mistralai/Mistral-7B-Instruct-v0.3", messages: [ { role: "system", content: "You are a helpful assistant." }, { role: "user", content: question } From df799eca459dcff937591821b89c3f0f9a3eda84 Mon Sep 17 00:00:00 2001 From: pglez82 Date: Fri, 7 Feb 2025 12:44:19 +0100 Subject: [PATCH 02/19] add code to deploy --- .github/workflows/release.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 4c93e31e..435c180e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -140,18 +140,18 @@ jobs: password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: gatewayservice - # deploy: - # name: Deploy over SSH - # runs-on: ubuntu-latest - # needs: [docker-push-userservice,docker-push-authservice,docker-push-llmservice,docker-push-gatewayservice,docker-push-webapp] - # steps: - # - name: Deploy over SSH - # uses: fifsky/ssh-action@master - # with: - # host: ${{ secrets.DEPLOY_HOST }} - # user: ${{ secrets.DEPLOY_USER }} - # key: ${{ secrets.DEPLOY_KEY }} - # command: | - # wget https://raw.githubusercontent.com/arquisoft/wichat_0/master/docker-compose.yml -O docker-compose.yml - # docker compose --profile prod down - # docker compose --profile prod up -d --pull always + deploy: + name: Deploy over SSH + runs-on: ubuntu-latest + needs: [docker-push-userservice,docker-push-authservice,docker-push-llmservice,docker-push-gatewayservice,docker-push-webapp] + steps: + - name: Deploy over SSH + uses: fifsky/ssh-action@master + with: + host: ${{ secrets.DEPLOY_HOST }} + user: ${{ secrets.DEPLOY_USER }} + key: ${{ secrets.DEPLOY_KEY }} + command: | + wget https://raw.githubusercontent.com/arquisoft/wichat_0/master/docker-compose.yml -O docker-compose.yml + docker compose --profile prod down + docker compose --profile prod up -d --pull always From 03f29baf2f04647eb0a3631c8ab3f3c76ac13da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Gonz=C3=A1lez?= Date: Mon, 17 Feb 2025 19:09:04 +0100 Subject: [PATCH 03/19] Update Dockerfile --- webapp/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index dcf26fe9..ef3983d4 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -4,7 +4,7 @@ COPY . /app WORKDIR /app #Install the dependencies -RUN npm install +RUN npm install --omit=dev ARG API_URI="http://localhost:8000" ARG LLM_API_KEY @@ -17,4 +17,4 @@ RUN npm install serve #Execute npm run prod to run the server CMD [ "npm", "run", "prod" ] -#CMD ["npm", "start"] \ No newline at end of file +#CMD ["npm", "start"] From 16d79276cd03f636ad7d6012a9d24268fe1facf8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Gonz=C3=A1lez?= Date: Mon, 17 Feb 2025 19:12:41 +0100 Subject: [PATCH 04/19] Update Dockerfile --- webapp/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index ef3983d4..3d7f3d1e 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -13,7 +13,7 @@ ENV REACT_APP_LLM_API_KEY=$LLM_API_KEY #Create an optimized version of the webapp RUN npm run build -RUN npm install serve +RUN npm install serve --omit=dev #Execute npm run prod to run the server CMD [ "npm", "run", "prod" ] From 25a54d1ba55b6b7ad2737d65478781d58a1f7f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Gonz=C3=A1lez?= Date: Mon, 17 Feb 2025 19:46:15 +0100 Subject: [PATCH 05/19] Update Dockerfile --- webapp/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/Dockerfile b/webapp/Dockerfile index 3d7f3d1e..e3b39ecf 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -13,7 +13,7 @@ ENV REACT_APP_LLM_API_KEY=$LLM_API_KEY #Create an optimized version of the webapp RUN npm run build -RUN npm install serve --omit=dev +RUN npm install -g serve --production #Execute npm run prod to run the server CMD [ "npm", "run", "prod" ] From 7f08852a283895ed0612a3c43c4371cde21de33a Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 17 Feb 2025 22:43:47 +0100 Subject: [PATCH 06/19] fixing api key exposure --- .github/workflows/release.yml | 6 ++++-- .vscode/settings.json | 3 +++ docker-compose.yml | 10 +++++----- llmservice/.dockerignore | 3 ++- llmservice/Dockerfile | 3 +++ llmservice/llm-service.js | 14 +++++++++++--- llmservice/llm-service.test.js | 2 +- llmservice/package-lock.json | 13 +++++++++++++ llmservice/package.json | 17 +++++++++-------- webapp/Dockerfile | 2 -- webapp/src/components/Login.js | 12 +++--------- 11 files changed, 54 insertions(+), 31 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 435c180e..371e7f88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -54,14 +54,13 @@ jobs: uses: elgohr/Publish-Docker-Github-Action@v5 env: API_URI: http://${{ secrets.DEPLOY_HOST }}:8000 - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} with: name: arquisoft/wichat_0/webapp username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: webapp - buildargs: API_URI,LLM_API_KEY + buildargs: API_URI docker-push-authservice: name: Push auth service Docker Image to GitHub Packages runs-on: ubuntu-latest @@ -112,12 +111,15 @@ jobs: - uses: actions/checkout@v4 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 + env: + LLM_API_KEY: ${{ secrets.LLM_API_KEY }} with: name: arquisoft/wichat_0/llmservice username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: llmservice + buildargs: LLM_API_KEY docker-push-gatewayservice: name: Push gateway service Docker Image to GitHub Packages diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..6b0e5abf --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "postman.settings.dotenv-detection-notification-visibility": false +} \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml index 62347892..ef0619c8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,7 +42,10 @@ services: container_name: llmservice-wichat_0 image: ghcr.io/arquisoft/wichat_0/llmservice:latest profiles: ["dev", "prod"] - build: ./llmservice + build: + context: ./llmservice + args: + LLM_API_KEY: ${LLM_API_KEY} ports: - "8003:8003" networks: @@ -71,10 +74,7 @@ services: container_name: webapp-wichat_0 image: ghcr.io/arquisoft/wichat_0/webapp:latest profiles: ["dev", "prod"] - build: - context: ./webapp - args: - LLM_API_KEY: ${LLM_API_KEY} + build: ./webapp depends_on: - gatewayservice ports: diff --git a/llmservice/.dockerignore b/llmservice/.dockerignore index 3091757a..c92776b4 100644 --- a/llmservice/.dockerignore +++ b/llmservice/.dockerignore @@ -1,2 +1,3 @@ node_modules -coverage \ No newline at end of file +coverage +.env \ No newline at end of file diff --git a/llmservice/Dockerfile b/llmservice/Dockerfile index 01739abd..2a4d9bdc 100644 --- a/llmservice/Dockerfile +++ b/llmservice/Dockerfile @@ -10,6 +10,9 @@ COPY package*.json ./ # Install app dependencies RUN npm install +ARG LLM_API_KEY +ENV LLM_API_KEY=$LLM_API_KEY + # Copy the app source code to the working directory COPY . . diff --git a/llmservice/llm-service.js b/llmservice/llm-service.js index 4788a50d..ddb2743a 100644 --- a/llmservice/llm-service.js +++ b/llmservice/llm-service.js @@ -6,6 +6,8 @@ const port = 8003; // Middleware to parse JSON in request body app.use(express.json()); +// Load enviornment variables +require('dotenv').config(); // Define configurations for different LLM APIs const llmConfigs = { @@ -71,9 +73,15 @@ async function sendQuestionToLLM(question, apiKey, model = 'gemini') { app.post('/ask', async (req, res) => { try { // Check if required fields are present in the request body - validateRequiredFields(req, ['question', 'model', 'apiKey']); - - const { question, model, apiKey } = req.body; + validateRequiredFields(req, ['question', 'model']); + + const { question, model } = req.body; + //load the api key from an environment variable + const apiKey = process.env.LLM_API_KEY; + if (!apiKey) { + console.log("LLM API key missing") + return res.status(400).json({ error: 'API key is missing.' }); + } const answer = await sendQuestionToLLM(question, apiKey, model); res.json({ answer }); diff --git a/llmservice/llm-service.test.js b/llmservice/llm-service.test.js index e8b0b7cf..43c485f7 100644 --- a/llmservice/llm-service.test.js +++ b/llmservice/llm-service.test.js @@ -22,7 +22,7 @@ describe('LLM Service', () => { it('the llm should reply', async () => { const response = await request(app) .post('/ask') - .send({ question: 'a question', apiKey: 'apiKey', model: 'gemini' }); + .send({ question: 'a question', model: 'gemini' }); expect(response.statusCode).toBe(200); expect(response.body.answer).toBe('llmanswer'); diff --git a/llmservice/package-lock.json b/llmservice/package-lock.json index c801c4a7..f88e73de 100644 --- a/llmservice/package-lock.json +++ b/llmservice/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "dependencies": { "axios": "^1.7.9", + "dotenv": "^16.4.7", "express": "^4.21.2" }, "devDependencies": { @@ -1803,6 +1804,18 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dotenv": { + "version": "16.4.7", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", + "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/dunder-proto": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", diff --git a/llmservice/package.json b/llmservice/package.json index 89ca3b7b..b2cd6f08 100644 --- a/llmservice/package.json +++ b/llmservice/package.json @@ -9,12 +9,13 @@ "license": "ISC", "description": "", "homepage": "https://github.com/arquisoft/wichat_0#readme", - "dependencies": { - "axios": "^1.7.9", - "express": "^4.21.2" - }, - "devDependencies": { - "jest": "^29.7.0", - "supertest": "^7.0.0" - } + "dependencies": { + "axios": "^1.7.9", + "dotenv": "^16.4.7", + "express": "^4.21.2" + }, + "devDependencies": { + "jest": "^29.7.0", + "supertest": "^7.0.0" + } } diff --git a/webapp/Dockerfile b/webapp/Dockerfile index e3b39ecf..20c39735 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -7,9 +7,7 @@ WORKDIR /app RUN npm install --omit=dev ARG API_URI="http://localhost:8000" -ARG LLM_API_KEY ENV REACT_APP_API_ENDPOINT=$API_URI -ENV REACT_APP_LLM_API_KEY=$LLM_API_KEY #Create an optimized version of the webapp RUN npm run build diff --git a/webapp/src/components/Login.js b/webapp/src/components/Login.js index c9b4097b..afbe048e 100644 --- a/webapp/src/components/Login.js +++ b/webapp/src/components/Login.js @@ -14,7 +14,7 @@ const Login = () => { const [openSnackbar, setOpenSnackbar] = useState(false); const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000'; - const apiKey = process.env.REACT_APP_LLM_API_KEY || 'None'; + const loginUser = async () => { try { @@ -22,14 +22,8 @@ const Login = () => { const question = "Please, generate a greeting message for a student called " + username + " that is a student of the Software Architecture course in the University of Oviedo. Be nice and polite. Two to three sentences max."; const model = "empathy" - - if (apiKey==='None'){ - setMessage("LLM API key is not set. Cannot contact the LLM."); - } - else{ - const message = await axios.post(`${apiEndpoint}/askllm`, { question, model, apiKey }) - setMessage(message.data.answer); - } + const message = await axios.post(`${apiEndpoint}/askllm`, { question, model }) + setMessage(message.data.answer); // Extract data from the response const { createdAt: userCreatedAt } = response.data; From d5278339ad2296d5bd937d613d378bfbad6f097a Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 17 Feb 2025 22:59:20 +0100 Subject: [PATCH 07/19] fixing tests --- llmservice/llm-service.js | 1 - llmservice/llm-service.test.js | 3 +++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/llmservice/llm-service.js b/llmservice/llm-service.js index ddb2743a..e4bdb3d3 100644 --- a/llmservice/llm-service.js +++ b/llmservice/llm-service.js @@ -79,7 +79,6 @@ app.post('/ask', async (req, res) => { //load the api key from an environment variable const apiKey = process.env.LLM_API_KEY; if (!apiKey) { - console.log("LLM API key missing") return res.status(400).json({ error: 'API key is missing.' }); } const answer = await sendQuestionToLLM(question, apiKey, model); diff --git a/llmservice/llm-service.test.js b/llmservice/llm-service.test.js index 43c485f7..b64a81de 100644 --- a/llmservice/llm-service.test.js +++ b/llmservice/llm-service.test.js @@ -1,3 +1,6 @@ +//set a fake api key +process.env.LLM_API_KEY = 'test-api-key'; + const request = require('supertest'); const axios = require('axios'); const app = require('./llm-service'); From b9e7e1b4890d7e5441a87fa7b79bf711bb51fb32 Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 17 Feb 2025 23:37:11 +0100 Subject: [PATCH 08/19] modify readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 655bcf79..ed3406d9 100644 --- a/README.md +++ b/README.md @@ -30,9 +30,9 @@ First, clone the project: In order to communicate with the LLM integrated in this project, we need to setup an API key. Two integrations are available in this propotipe: gemini and empaphy. The API key provided must match the LLM provider used. We need to create two .env files. -- The first one in the webapp directory (for executing the webapp using ```npm start```). The content of this .env file should be as follows: +- The first one in the llmservice directory (for executing the llmservice using ```npm start```). The content of this .env file should be as follows: ``` -REACT_APP_LLM_API_KEY="YOUR-API-KEY" +LLM_API_KEY="YOUR-API-KEY" ``` - The second one located in the root of the project (along the docker-compose.yml). This .env file is used for the docker-compose when launching the app with docker. The content of this .env file should be as follows: ``` From e60b8741ad49e3d3d2e291a42a9e9c35d791fa9f Mon Sep 17 00:00:00 2001 From: pglez82 Date: Thu, 20 Feb 2025 11:05:29 +0100 Subject: [PATCH 09/19] checking change --- webapp/src/App.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/webapp/src/App.js b/webapp/src/App.js index 1f6f1b29..f1e3fc99 100644 --- a/webapp/src/App.js +++ b/webapp/src/App.js @@ -17,7 +17,7 @@ function App() { - Welcome to the 2025 edition of the Software Architecture course + Welcome to the 2025 edition of the Software Architecture course! {showLogin ? : } From e5dd60489357cf55cef445c6cc810c745ac206fb Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 24 Feb 2025 11:01:33 +0100 Subject: [PATCH 10/19] removing api key from docker image --- .github/workflows/release.yml | 3 --- docker-compose.yml | 2 ++ llmservice/Dockerfile | 3 --- 3 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 371e7f88..efeea9d2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -111,15 +111,12 @@ jobs: - uses: actions/checkout@v4 - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 - env: - LLM_API_KEY: ${{ secrets.LLM_API_KEY }} with: name: arquisoft/wichat_0/llmservice username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io workdir: llmservice - buildargs: LLM_API_KEY docker-push-gatewayservice: name: Push gateway service Docker Image to GitHub Packages diff --git a/docker-compose.yml b/docker-compose.yml index ef0619c8..c3a0607e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -42,6 +42,8 @@ services: container_name: llmservice-wichat_0 image: ghcr.io/arquisoft/wichat_0/llmservice:latest profiles: ["dev", "prod"] + env_file: + - .env build: context: ./llmservice args: diff --git a/llmservice/Dockerfile b/llmservice/Dockerfile index 2a4d9bdc..01739abd 100644 --- a/llmservice/Dockerfile +++ b/llmservice/Dockerfile @@ -10,9 +10,6 @@ COPY package*.json ./ # Install app dependencies RUN npm install -ARG LLM_API_KEY -ENV LLM_API_KEY=$LLM_API_KEY - # Copy the app source code to the working directory COPY . . From 70ae7edb9a21beff108e3fef143008e2f1a08136 Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 24 Feb 2025 11:09:36 +0100 Subject: [PATCH 11/19] modifying readme --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index ed3406d9..e2a18e1d 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,7 @@ LLM_API_KEY="YOUR-API-KEY" Note that these files must NOT be uploaded to the github repository (they are excluded in the .gitignore). -An extra configuration for the LLM to work in the deployed version of the app is to include it as a repository secret (LLM_API_KEY). This secret will be used by GitHub Action when building and deploying the application. - +An extra configuration for the LLM to work in the deployed version of the app is to create the same .env file (with the LLM_API_KEY variable) in the virtual machine (in the home of the azureuser directory). ### Launching Using docker For launching the propotipe using docker compose, just type: From 85f9a59b3eee9fa90babfae13c13fe3d1dbd50c9 Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 24 Feb 2025 12:28:16 +0100 Subject: [PATCH 12/19] updating docker compose --- docker-compose.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index c3a0607e..d3830bb8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -46,8 +46,6 @@ services: - .env build: context: ./llmservice - args: - LLM_API_KEY: ${LLM_API_KEY} ports: - "8003:8003" networks: From 97e6e65c7159a365d6bfcd9a0adaa40936f2d05b Mon Sep 17 00:00:00 2001 From: javiersanabriamiranda Date: Tue, 25 Feb 2025 14:13:29 +0100 Subject: [PATCH 13/19] =?UTF-8?q?Introducci=C3=B3n=20de=20--legacy-peer-de?= =?UTF-8?q?ps=20en=20despliegue=20de=20webapp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Se ha introducido la instrucción para ignorar los conflictos de dependencias entre i18next y typescript --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f6561bb..532fe945 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,7 +16,7 @@ jobs: - run: npm --prefix users/userservice ci - run: npm --prefix llmservice ci - run: npm --prefix gatewayservice ci - - run: npm --prefix webapp ci + - run: npm --prefix webapp ci --legacy-peer-deps - run: npm --prefix users/authservice test -- --coverage - run: npm --prefix users/userservice test -- --coverage - run: npm --prefix llmservice test -- --coverage From 7bbed2a011fbd832498a5b87e09343f72b8ca1e3 Mon Sep 17 00:00:00 2001 From: javiersanabriamiranda Date: Tue, 25 Feb 2025 14:17:12 +0100 Subject: [PATCH 14/19] =?UTF-8?q?Introducci=C3=B3n=20de=20workflow=5Fdispa?= =?UTF-8?q?tch=20en=20build.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9ec1dcf1..0da54a2b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,6 @@ name: Build on: + workflow_dispatch: push: branches: - master From efd026cce8fc1f90991379f38e8395bd662cfa16 Mon Sep 17 00:00:00 2001 From: Aitorsiius Date: Tue, 25 Feb 2025 14:35:45 +0100 Subject: [PATCH 15/19] Eliminado del esquema Topic. Fix templates de preguntas. --- db/Topic.js | 16 -- package-lock.json | 279 ++++++++++++++++++++++++++++++++ package.json | 2 + question/question_template.json | 81 ++++++++++ question/wikidata.js | 83 ++++++++++ 5 files changed, 445 insertions(+), 16 deletions(-) delete mode 100644 db/Topic.js create mode 100644 question/question_template.json create mode 100644 question/wikidata.js diff --git a/db/Topic.js b/db/Topic.js deleted file mode 100644 index d2553569..00000000 --- a/db/Topic.js +++ /dev/null @@ -1,16 +0,0 @@ -// Librería para trabajar con MongoDB -const { Schema, model } = require("mongoose"); - -// Esquema para Topic -const topicSchema = new Schema({ - type: { - type: [String], - required: true - } -}); - -// Se crea el modelo a partir del esquema -const Topic = model("Topic", topicSchema); - -// Exportamos el modelo -module.exports = Topic; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 33ef8d0e..3b15e15e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,9 +5,52 @@ "packages": { "": { "dependencies": { + "axios": "^1.7.9", "node-fetch": "^3.3.2" } }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "license": "MIT" + }, + "node_modules/axios": { + "version": "1.7.9", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", + "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "license": "MIT", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/call-bind-apply-helpers": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", + "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "license": "MIT", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, "node_modules/data-uri-to-buffer": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", @@ -17,6 +60,74 @@ "node": ">= 12" } }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "license": "MIT", + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/dunder-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", + "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.1", + "es-errors": "^1.3.0", + "gopd": "^1.2.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-define-property": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", + "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-object-atoms": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", + "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-set-tostringtag": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", + "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", @@ -40,6 +151,41 @@ "node": "^12.20 || >= 14.13" } }, + "node_modules/follow-redirects": { + "version": "1.15.9", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", + "integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==", + "funding": [ + { + "type": "individual", + "url": "https://github.com/sponsors/RubenVerborgh" + } + ], + "license": "MIT", + "engines": { + "node": ">=4.0" + }, + "peerDependenciesMeta": { + "debug": { + "optional": true + } + } + }, + "node_modules/form-data": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", + "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", + "license": "MIT", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "es-set-tostringtag": "^2.1.0", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -52,6 +198,133 @@ "node": ">=12.20.0" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-intrinsic": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", + "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.2", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "function-bind": "^1.1.2", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "math-intrinsics": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/get-proto": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", + "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/gopd": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", + "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", + "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-tostringtag": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", + "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "license": "MIT", + "dependencies": { + "has-symbols": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/math-intrinsics": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", + "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/node-domexception": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", @@ -89,6 +362,12 @@ "url": "https://opencollective.com/node-fetch" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "license": "MIT" + }, "node_modules/web-streams-polyfill": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", diff --git a/package.json b/package.json index 17973724..a9b58597 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,7 @@ { + "type": "module", "dependencies": { + "axios": "^1.7.9", "node-fetch": "^3.3.2" } } diff --git a/question/question_template.json b/question/question_template.json new file mode 100644 index 00000000..cde132df --- /dev/null +++ b/question/question_template.json @@ -0,0 +1,81 @@ +[ + { + "question": "¿A qué país pertenece esta bandera: ?", + "selector": "", + "topics": ["flag"], + "query": "SELECT ?name ?image WHERE { ?country wdt:P31 wd:Q6256. ?country wdt:P41 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?country rdfs:label ?name. } } LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿A qué país pertenece este contorno: ?", + "selector": "", + "topics": ["geography", "map"], + "query": "SELECT ?name ?image WHERE { ?country wdt:P31 wd:Q6256. ?country wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?country rdfs:label ?name. } } LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿Cuál es la capital de este país: ?", + "selector": "", + "topics": ["geography", "image"], + "query": "SELECT ?name ?image WHERE { ?country wdt:P31 wd:Q6256. ?country wdt:P36 ?capital. ?capital wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?capital rdfs:label ?name. } } LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿Quién es la persona histórica que aparece en esta foto: ?", + "selector": "", + "topics": ["history"], + "query": "SELECT ?name ?image WHERE { ?person wdt:P31 wd:Q5. ?person wdt:P570 ?deathDate. ?person wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?person rdfs:label ?name. } } LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿En qué fecha ocurrió este acontecimiento histórico: ?", + "selector": "", + "topics": ["history", "image"], + "query": "SELECT ?name ?image WHERE { ?event wdt:P31 wd:Q1190554. ?event wdt:P585 ?date. ?event wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?event rdfs:label ?name. } } LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿Dónde ocurrió este acontecimiento histórico: ?", + "selector": "", + "topics": ["history", "location", "image"], + "query": "SELECT ?name ?image WHERE { ?event wdt:P31 wd:Q1190554. ?event wdt:P276 ?location. ?event wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?event rdfs:label ?name. } } LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿Cuál es el nombre del animal: ?", + "selector": "", + "topics": ["science", "image"], + "query": "SELECT ?name ?image WHERE { ?animal wdt:P225 ?name. ?animal wdt:P171 ?taxon. ?animal wdt:P18 ?image.} LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿Cuál es el nombre del deporte: ?", + "selector": "", + "topics": ["sports", "image"], + "query": "SELECT ?name ?image WHERE { ?deporte wdt:P31 wd:Q349. ?deporte wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language 'es,en'. ?deporte rdfs:label ?name. } } LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿Cuál es el nombre de la planta: ?", + "selector": "", + "topics": ["science", "image"], + "query": "SELECT ?name ?image WHERE { ?planta wdt:P225 ?name. ?planta wdt:P18 ?image. ?planta wdt:P5037 ?value.} LIMIT 1 OFFSET ", + "imageurl": "" + }, + + { + "question": "¿Cuál es el nombre del fenómeno natural: ?", + "selector": "", + "topics": ["science", "image"], + "query": "SELECT ?name ?image WHERE { ?fenomeno wdt:P10260 ?value. ?fenomeno rdfs:label ?name. ?fenomeno wdt:P18 ?image.} LIMIT 1 OFFSET ", + "imageurl": "" + } +] diff --git a/question/wikidata.js b/question/wikidata.js new file mode 100644 index 00000000..476a81c5 --- /dev/null +++ b/question/wikidata.js @@ -0,0 +1,83 @@ +import fetch from 'node-fetch'; +import fs from 'fs'; // Requerimos el módulo fs para leer archivos JSON +import path from 'path'; + +const url = "https://query.wikidata.org/sparql"; + +// Función para cargar el archivo JSON de plantillas +function loadQuestionTemplates() { + // Construimos la ruta de manera explícita + const filePath = path.resolve('question', 'question_template.json'); + + // Mostramos la ruta para depurar + console.log("Ruta al archivo JSON:", filePath); + + try { + const data = fs.readFileSync(filePath, 'utf-8'); + return JSON.parse(data); + } catch (error) { + console.error("Error al leer el archivo JSON:", error); + throw error; + } +} + +function loadQuestionTemplatesWithTopic(topic) { + // Construimos la ruta de manera explícita + const filePath = path.resolve('question', 'question_template.json'); + + // Mostramos la ruta para depurar + console.log("Ruta al archivo JSON:", filePath); + + try { + const data = fs.readFileSync(filePath, 'utf-8'); + const templates = JSON.parse(data); + + // Filtrar las plantillas que contienen el topic proporcionado + const filteredTemplates = templates.filter(template => template.topics.includes(topic)); + return filteredTemplates; + } catch (error) { + console.error("Error al leer el archivo JSON:", error); + throw error; + } +} + +async function executeQuery(query) { + const offset = Math.floor(Math.random() * 100); + query += offset; + + const response = await fetch(url, { + method: "POST", + headers: { + "Content-Type": "application/sparql-query", + "Accept": "application/json" + }, + body: query + }); + + if (!response.ok) { + throw new Error(`Error en la consulta SPARQL: ${response.statusText}`); + } + + const data = await response.json(); + return data.results.bindings; +} + +async function main(topic) { + try { + const templates = loadQuestionTemplatesWithTopic(topic) //cogemos solo las plantillas que pasen por el filtrado de topic + + const randomTemplate = templates[Math.floor(Math.random() * templates.length)]; //seleccionamos una plantilla aleatoria + console.log(`Plantilla seleccionada: ${randomTemplate.question}`); + + const query = randomTemplate.query; //obtenemos la consulta SPARQL de la plantilla seleccionada + + const results = await executeQuery(query); + results.forEach((item) => { + console.log(`Datos obtenidos: ${JSON.stringify(item, null, 2)}`); + }); + } catch (error) { + console.error("Error ejecutando el script:", error); + } +} + +main("sports").catch(console.error); \ No newline at end of file From 8d994e07cba4fd9c754b04646b4843de2b09b801 Mon Sep 17 00:00:00 2001 From: Aitorsiius Date: Thu, 27 Feb 2025 18:51:20 +0100 Subject: [PATCH 16/19] =?UTF-8?q?A=C3=B1adidos=202=20nuevos=20templates=20?= =?UTF-8?q?de=20preguntas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- question/question_template.json | 52 +++++++++++++++++++++++++-------- question/wikidata.js | 2 +- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/question/question_template.json b/question/question_template.json index 670f952a..6050d7fc 100644 --- a/question/question_template.json +++ b/question/question_template.json @@ -1,6 +1,6 @@ [ { - "question": "¿A qué país pertenece esta bandera: ?", + "question": "¿A qué país pertenece esta bandera?", "selector": "", "topics": ["flag"], "query": "SELECT ?name ?image WHERE { ?country wdt:P31 wd:Q6256. ?country wdt:P41 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?country rdfs:label ?name. } } LIMIT 1 OFFSET ", @@ -8,14 +8,14 @@ }, { - "question": "¿A qué país pertenece este contorno: ?", + "question": "¿A qué país pertenece este contorno?", "selector": "", "topics": ["geography", "map"], "query": "SELECT ?name ?image WHERE { ?country wdt:P31 wd:Q6256. ?country wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?country rdfs:label ?name. } } LIMIT 1 OFFSET ", "imageurl": "" }, { - "question": "¿Cuál es la capital de este país: ?", + "question": "¿Cuál es la capital de este país?", "selector": "", "topics": ["geography", "image"], "query": "SELECT ?name ?image WHERE { ?country wdt:P31 wd:Q6256. ?country wdt:P36 ?capital. ?capital wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?capital rdfs:label ?name. } } LIMIT 1 OFFSET ", @@ -23,14 +23,14 @@ }, { - "question": "¿Quién es la persona histórica que aparece en esta foto: ?", + "question": "¿Quién es la persona histórica que aparece en esta foto?", "selector": "", "topics": ["history"], "query": "SELECT ?name ?image WHERE { ?person wdt:P31 wd:Q5. ?person wdt:P570 ?deathDate. ?person wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?person rdfs:label ?name. } } LIMIT 1 OFFSET ", "imageurl": "" }, { - "question": "¿En qué fecha ocurrió este acontecimiento histórico: ?", + "question": "¿En qué fecha ocurrió este acontecimiento histórico?", "selector": "", "topics": ["history", "image"], "query": "SELECT ?name ?image WHERE { ?event wdt:P31 wd:Q1190554. ?event wdt:P585 ?date. ?event wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?event rdfs:label ?name. } } LIMIT 1 OFFSET ", @@ -38,14 +38,14 @@ }, { - "question": "¿Dónde ocurrió este acontecimiento histórico: ?", + "question": "¿Dónde ocurrió este acontecimiento histórico?", "selector": "", "topics": ["history", "location", "image"], "query": "SELECT ?name ?image WHERE { ?event wdt:P31 wd:Q1190554. ?event wdt:P276 ?location. ?event wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?event rdfs:label ?name. } } LIMIT 1 OFFSET ", "imageurl": "" }, { - "question": "¿Cuál es el nombre del animal: ?", + "question": "¿Cuál es el nombre del animal?", "selector": "", "topics": ["science", "image"], "query": "SELECT ?name ?image WHERE { ?animal wdt:P225 ?name. ?animal wdt:P171 ?taxon. ?animal wdt:P18 ?image.} LIMIT 1 OFFSET ", @@ -53,24 +53,52 @@ }, { - "question": "¿Cuál es el nombre del deporte: ?", + "question": "¿Cuál es el nombre del deporte?", "selector": "", "topics": ["sports", "image"], "query": "SELECT ?name ?image WHERE { ?deporte wdt:P31 wd:Q349. ?deporte wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language 'es,en'. ?deporte rdfs:label ?name. } } LIMIT 1 OFFSET ", "imageurl": "" }, { - "question": "¿Cuál es el nombre de la planta: ?", + "question": "¿Cuál es el nombre de la planta?", "selector": "", "topics": ["science", "image"], "query": "SELECT ?name ?image WHERE { ?planta wdt:P225 ?name. ?planta wdt:P18 ?image. ?planta wdt:P5037 ?value.} LIMIT 1 OFFSET ", "imageurl": "" }, { - "question": "¿Cuál es el nombre del fenómeno natural: ?", + "question": "¿Cuál es el autor de este libro?", "selector": "", - "topics": ["science", "image"], - "query": "SELECT ?name ?image WHERE { ?fenomeno wdt:P10260 ?value. ?fenomeno rdfs:label ?name. ?fenomeno wdt:P18 ?image.} LIMIT 1 OFFSET ", + "topics": ["literature1", "image"], + "query": "SELECT ?name ?image WHERE { ?libro wdt:P31 wd:Q571. ?libro wdt:P50 ?author. ?libro wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?author rdfs:label ?name. } } LIMIT 1 OFFSET 0", + "imageurl": "" + }, + { + "question": "¿Cuál es el género literario del libro?", + "selector": "", + "topics": ["literature", "image"], + "query": "SELECT ?name ?image WHERE { ?libro wdt:P31 wd:Q571. ?libro wdt:P136 ?genre. ?libro wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?genre rdfs:label ?name. } } LIMIT 1 OFFSET 0", + "imageurl": "" + }, + { + "question": "¿Cuál es el nombre del cuadro?", + "selector": "", + "topics": ["art", "image"], + "query": "SELECT ?name ?image WHERE { ?cuadro wdt:P31 wd:Q3305213. ?cuadro wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?cuadro rdfs:label ?name. } } LIMIT 1 OFFSET 0", + "imageurl": "" + }, + { + "question": "¿Cuál es el nombre del pintor?", + "selector": "", + "topics": ["art", "image"], + "query": "SELECT ?name ?image WHERE { ?cuadro wdt:P31 wd:Q3305213. ?cuadro wdt:P170 ?painter. ?cuadro wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?painter rdfs:label ?name. } } LIMIT 1 OFFSET 0", + "imageurl": "" + }, + { + "question": "¿Cuál es el estilo artístico del cuadro?", + "selector": "", + "topics": ["art", "image"], + "query": "SELECT ?name ?image WHERE { ?cuadro wdt:P31 wd:Q3305213. ?cuadro wdt:P149 ?style. ?cuadro wdt:P18 ?image. SERVICE wikibase:label { bd:serviceParam wikibase:language \"[AUTO_LANGUAGE],es\". ?style rdfs:label ?name. } } LIMIT 1 OFFSET 0", "imageurl": "" } ] diff --git a/question/wikidata.js b/question/wikidata.js index dcf51937..ba8fdfee 100644 --- a/question/wikidata.js +++ b/question/wikidata.js @@ -79,4 +79,4 @@ async function main(topic) { } } -main("sports").catch(console.error); +main("art").catch(console.error); From bc5c62f5c3ed6e92820ce0a7dc6aa8c7e9dc4e2b Mon Sep 17 00:00:00 2001 From: pglez82 Date: Mon, 3 Mar 2025 09:09:05 +0100 Subject: [PATCH 17/19] fixing tests for empathy --- llmservice/llm-service.test.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/llmservice/llm-service.test.js b/llmservice/llm-service.test.js index b64a81de..e72e5d52 100644 --- a/llmservice/llm-service.test.js +++ b/llmservice/llm-service.test.js @@ -16,19 +16,25 @@ describe('LLM Service', () => { axios.post.mockImplementation((url, data) => { if (url.startsWith('https://generativelanguage')) { return Promise.resolve({ data: { candidates: [{ content: { parts: [{ text: 'llmanswer' }] } }] } }); - } else if (url.endsWith('https://empathyai')) { - return Promise.resolve({ data: { answer: 'llmanswer' } }); + } else if (url.startsWith('https://empathyai')) { + return Promise.resolve({ data: { choices: [ {message: { content: 'llmanswer' } } ] } }); } }); // Test /ask endpoint it('the llm should reply', async () => { - const response = await request(app) + const response1 = await request(app) .post('/ask') .send({ question: 'a question', model: 'gemini' }); - expect(response.statusCode).toBe(200); - expect(response.body.answer).toBe('llmanswer'); + const response2 = await request(app) + .post('/ask') + .send({ question: 'a question', model: 'empathy' }); + + expect(response1.statusCode).toBe(200); + expect(response1.body.answer).toBe('llmanswer'); + expect(response2.statusCode).toBe(200); + expect(response2.body.answer).toBe('llmanswer'); }); }); \ No newline at end of file From 8fbc9dd426a033a48bef38e2f2e2faf74c31d5c4 Mon Sep 17 00:00:00 2001 From: Aitorsiius Date: Tue, 4 Mar 2025 00:18:19 +0100 Subject: [PATCH 18/19] Crud User DB Example --- db/Connection.js | 21 +- db/crud.js | 92 +++++++ db/user.js | 50 ++++ package-lock.json | 648 +++++++++++++++++++++++++++++++++------------- package.json | 4 +- 5 files changed, 630 insertions(+), 185 deletions(-) create mode 100644 db/crud.js create mode 100644 db/user.js diff --git a/db/Connection.js b/db/Connection.js index 283ae12d..c48be17a 100644 --- a/db/Connection.js +++ b/db/Connection.js @@ -1,5 +1,7 @@ -const mongoose = require("mongoose"); -const { MongoMemoryServer } = require('mongodb-memory-server'); +import mongoose from "mongoose"; +import { MongoMemoryServer } from "mongodb-memory-server"; + +let mongoServer; //async -> asegura que el código no se bloquee mientras espera que MongoDB se conecte. const connect = async() => { @@ -11,7 +13,7 @@ const connect = async() => { console.log("MongoDB URL server") } else { //si no hay una variable de entorno DB_URL, creamos un servidor de MongoDB en memoria usando MongoMemoryServer - const mongoServer = await MongoMemoryServer.create(); //se crea un servidor de bd en memoria + mongoServer = await MongoMemoryServer.create(); //se crea un servidor de bd en memoria const mongoUri = mongoServer.getUri(); //obtenemos la URL del servidor en memoria await mongoose.connect(mongoUri) //nos conectamos a mongoDB @@ -26,5 +28,16 @@ const connect = async() => { } } +const disconnect = async () => { + try { + await mongoose.disconnect(); + if (mongoServer) { + await mongoServer.stop(); + } + console.log("MongoDB disconnected"); + } catch (error) { + console.error("Error al desconectar de MongoDB:", error); + } +}; -module.exports = connect; \ No newline at end of file +export {connect, disconnect}; \ No newline at end of file diff --git a/db/crud.js b/db/crud.js new file mode 100644 index 00000000..405c5fb3 --- /dev/null +++ b/db/crud.js @@ -0,0 +1,92 @@ +import {connect, disconnect} from './Connection.js'; +import User from './user.js'; +// Y los demás imports necesarios + +// Clase que contiene los métodos para realizar operaciones CRUD sobre cualquier modelo de la base de datos +class Crud { + + static async createUser(data) { + try { + const newUser = new User(data); + const savedUser = await newUser.save(); + return savedUser; + } catch (error) { + error.message = 'Error al crear el usuario: ' + error.message; + throw error; + } + } + + static async getAllUsers() { + try { + const users = await User.find(); + return users; + } catch (error) { + error.message = 'Error al obtener los usuarios: ' + error.message; + throw error; + } + } + + static async getUserById(userId) { + try { + const user = await User.findById(userId); + return user; + } catch (error) { + error.message = 'Error al obtener el usuario: ' + error.message; + throw error; + } + } + + static async updateUser(userId, updateData) { + try { + const updatedUser = await User.findByIdAndUpdate( + userId, + updateData, + { new: true } + ); + return updatedUser; // Devuelve el usuario actualizado + } catch (error) { + error.message = 'Error al actualizar el usuario: ' + error.message; + throw error; + } + } + + static async deleteUser(userId) { + try { + const deletedUser = await User.findByIdAndDelete(userId); + return deletedUser; // Devuelve el usuario eliminado + } catch (error) { + error.message = 'Error al eliminar el usuario: ' + error.message; + throw error; + } + } +} + +connect() + .then(() => { + console.log("Conexión establecida"); + // Se crea el usuario + return Crud.createUser({ + username: 'user1', + password: '123456' + }); + }) + .then(createdUser => { + console.log("Usuario creado:", createdUser); + // Se busca el usuario recién creado usando su _id + return Crud.getUserById(createdUser._id); + }) + .then(foundUser => { + console.log("Usuario encontrado:", foundUser); + console.log(`ID: ${foundUser._id}`); + console.log(`Username: ${foundUser.username}`); + console.log(`Friend Code: ${foundUser.friendCode}`); + console.log(`Password: ${foundUser.password}`); + }) + .catch(error => { + console.error("Error:", error); + }) + .finally(() => { + disconnect(); + }); + +export default Crud; \ No newline at end of file diff --git a/db/user.js b/db/user.js new file mode 100644 index 00000000..0a15cf04 --- /dev/null +++ b/db/user.js @@ -0,0 +1,50 @@ +import { Schema, model } from "mongoose"; + +// Definir el esquema de usuario +const userSchema = new Schema({ + username: { + type: String, + required: true, + trim: true + }, + friendCode: { + type: String, + unique: true, + required: false + }, + password: { + type: String, + required: true + } +}); + +// Función que genera un número entre 100000 y 999999 en formato String. +function generarCodigoAmigo() { + return Math.floor(100000 + Math.random() * 900000).toString(); +} + +// Antes de guardar, se genera y asigna un friendCode único. +// Usamos `this.constructor` para buscar dentro del mismo modelo, ya que "User" +// aún no está definido en el momento de crear el hook. +userSchema.pre("save", async function (next) { + const user = this; + let codigoValido = false; + let codigoAleatorio; + + while (!codigoValido) { + codigoAleatorio = generarCodigoAmigo(); + + // Verifica si ya existe otro usuario con este friendCode + const existe = await this.constructor.findOne({ friendCode: codigoAleatorio }); + if (!existe) { + codigoValido = true; + } + } + + user.friendCode = codigoAleatorio; + next(); +}); + +// Crear el modelo a partir del esquema +const User = model("User", userSchema); +export default User; diff --git a/package-lock.json b/package-lock.json index 3b15e15e..d266025e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,129 +5,134 @@ "packages": { "": { "dependencies": { - "axios": "^1.7.9", + "mongodb-memory-server": "^10.1.4", + "mongoose": "^8.12.0", "node-fetch": "^3.3.2" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", + "node_modules/@mongodb-js/saslprep": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@mongodb-js/saslprep/-/saslprep-1.2.0.tgz", + "integrity": "sha512-+ywrb0AqkfaYuhHs6LxKWgqbh3I72EpEgESCw37o+9qPx9WTCkgDm2B+eMrwehGtHBWHFU4GXvnSCNiFhhausg==", + "license": "MIT", + "dependencies": { + "sparse-bitfield": "^3.0.3" + } + }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.3.tgz", + "integrity": "sha512-CiJJvcRtIgzadHCYXw7dqEnMNRjhGZlYK05Mj9OyktqV8uVT8fD2BFOB7S1uwBE3Kj2Z+4UyPmFw/Ixgw/LAlA==", "license": "MIT" }, - "node_modules/axios": { - "version": "1.7.9", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.9.tgz", - "integrity": "sha512-LhLcE7Hbiryz8oMDdDptSrWowmB4Bl6RCt6sIJKpRB4XtVf0iEgewX3au/pJqm+Py1kCASkb/FFKjxQaLtxJvw==", + "node_modules/@types/whatwg-url": { + "version": "11.0.5", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-11.0.5.tgz", + "integrity": "sha512-coYR071JRaHa+xoEvvYqvnIHaVqaYrLPbsufM9BF63HkwI5Lgmy2QR8Q5K/lYDYo5AK82wOvSOS0UsLTpTG7uQ==", "license": "MIT", "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" + "@types/webidl-conversions": "*" } }, - "node_modules/call-bind-apply-helpers": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", - "integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==", + "node_modules/agent-base": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.3.tgz", + "integrity": "sha512-jRR5wdylq8CkOe6hei19GGZnxM6rBGwFl3Bg0YItGDimvjGtAvdZk4Pu6Cl4u4Igsws4a1fd1Vq3ezrhn4KmFw==", "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "function-bind": "^1.1.2" - }, "engines": { - "node": ">= 0.4" + "node": ">= 14" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "node_modules/async-mutex": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", + "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", "license": "MIT", "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" + "tslib": "^2.4.0" } }, - "node_modules/data-uri-to-buffer": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", - "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", - "license": "MIT", + "node_modules/b4a": { + "version": "1.6.7", + "resolved": "https://registry.npmjs.org/b4a/-/b4a-1.6.7.tgz", + "integrity": "sha512-OnAYlL5b7LEkALw87fUVafQw5rVR9RjwGd4KUwNQ6DrrNmaVaUCgLipfVlzrPQ4tWOR9P0IXGNOx50jYCCdSJg==", + "license": "Apache-2.0" + }, + "node_modules/bare-events": { + "version": "2.5.4", + "resolved": "https://registry.npmjs.org/bare-events/-/bare-events-2.5.4.tgz", + "integrity": "sha512-+gFfDkR8pj4/TrWCGUGWmJIkBwuxPS5F+a5yWjOHQt2hHvNZd5YLzadjmDUtFmMM4y429bnKLa8bYBMHcYdnQA==", + "license": "Apache-2.0", + "optional": true + }, + "node_modules/bson": { + "version": "6.10.3", + "resolved": "https://registry.npmjs.org/bson/-/bson-6.10.3.tgz", + "integrity": "sha512-MTxGsqgYTwfshYWTRdmZRC+M7FnG1b4y7RO7p2k3X24Wq0yv1m77Wsj0BzlPzd/IowgESfsruQCUToa7vbOpPQ==", + "license": "Apache-2.0", "engines": { - "node": ">= 12" + "node": ">=16.20.1" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "node_modules/buffer-crc32": { + "version": "0.2.13", + "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", + "integrity": "sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==", "license": "MIT", "engines": { - "node": ">=0.4.0" + "node": "*" } }, - "node_modules/dunder-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz", - "integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==", + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", "license": "MIT", - "dependencies": { - "call-bind-apply-helpers": "^1.0.1", - "es-errors": "^1.3.0", - "gopd": "^1.2.0" - }, "engines": { - "node": ">= 0.4" + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/es-define-property": { + "node_modules/commondir": { "version": "1.0.1", - "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", - "integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==", - "license": "MIT", - "engines": { - "node": ">= 0.4" - } + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "license": "MIT" }, - "node_modules/es-errors": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "node_modules/data-uri-to-buffer": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", + "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", "license": "MIT", "engines": { - "node": ">= 0.4" + "node": ">= 12" } }, - "node_modules/es-object-atoms": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz", - "integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==", + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", "license": "MIT", "dependencies": { - "es-errors": "^1.3.0" + "ms": "^2.1.3" }, "engines": { - "node": ">= 0.4" - } - }, - "node_modules/es-set-tostringtag": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/es-set-tostringtag/-/es-set-tostringtag-2.1.0.tgz", - "integrity": "sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==", - "license": "MIT", - "dependencies": { - "es-errors": "^1.3.0", - "get-intrinsic": "^1.2.6", - "has-tostringtag": "^1.0.2", - "hasown": "^2.0.2" + "node": ">=6.0" }, - "engines": { - "node": ">= 0.4" + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } } }, + "node_modules/fast-fifo": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/fast-fifo/-/fast-fifo-1.3.2.tgz", + "integrity": "sha512-/d9sfos4yxzpwkDkuN7k2SqFKtYNmCTzgfEpz82x34IM9/zc8KGxQoXg1liNC/izpRM/MBdt44Nmx41ZWqk+FQ==", + "license": "MIT" + }, "node_modules/fetch-blob": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", @@ -151,6 +156,36 @@ "node": "^12.20 || >= 14.13" } }, + "node_modules/find-cache-dir": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.2.tgz", + "integrity": "sha512-wXZV5emFEjrridIgED11OoUKLxiYjAcqot/NJdAkOhlJ+vGzwhOAfcG5OX1jP+S0PcjEn8bdMJv+g2jwQ3Onig==", + "license": "MIT", + "dependencies": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/avajs/find-cache-dir?sponsor=1" + } + }, + "node_modules/find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "license": "MIT", + "dependencies": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/follow-redirects": { "version": "1.15.9", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz", @@ -171,21 +206,6 @@ } } }, - "node_modules/form-data": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.2.tgz", - "integrity": "sha512-hGfm/slu0ZabnNt4oaRZ6uREyfCj6P4fT/n6A1rGV+Z0VdGXjfOhVUpkn6qVQONHGIFwmveGXyDs75+nr6FM8w==", - "license": "MIT", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "es-set-tostringtag": "^2.1.0", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/formdata-polyfill": { "version": "4.0.10", "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", @@ -198,131 +218,222 @@ "node": ">=12.20.0" } }, - "node_modules/function-bind": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, - "node_modules/get-intrinsic": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz", - "integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==", + "node_modules/https-proxy-agent": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-7.0.6.tgz", + "integrity": "sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==", "license": "MIT", "dependencies": { - "call-bind-apply-helpers": "^1.0.2", - "es-define-property": "^1.0.1", - "es-errors": "^1.3.0", - "es-object-atoms": "^1.1.1", - "function-bind": "^1.1.2", - "get-proto": "^1.0.1", - "gopd": "^1.2.0", - "has-symbols": "^1.1.0", - "hasown": "^2.0.2", - "math-intrinsics": "^1.1.0" + "agent-base": "^7.1.2", + "debug": "4" }, "engines": { - "node": ">= 0.4" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "node": ">= 14" } }, - "node_modules/get-proto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz", - "integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==", + "node_modules/kareem": { + "version": "2.6.3", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.6.3.tgz", + "integrity": "sha512-C3iHfuGUXK2u8/ipq9LfjFfXFxAZMQJJq7vLS45r3D9Y2xQ/m4S8zaR4zMLFWh9AsNPXmcFfUDhTEO8UIC/V6Q==", + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", "license": "MIT", "dependencies": { - "dunder-proto": "^1.0.1", - "es-object-atoms": "^1.0.0" + "p-locate": "^4.1.0" }, "engines": { - "node": ">= 0.4" + "node": ">=8" } }, - "node_modules/gopd": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", - "integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==", + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", "license": "MIT", + "dependencies": { + "semver": "^6.0.0" + }, "engines": { - "node": ">= 0.4" + "node": ">=8" }, "funding": { - "url": "https://github.com/sponsors/ljharb" + "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/has-symbols": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", - "integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==", - "license": "MIT", + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + } + }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "license": "MIT" + }, + "node_modules/mongodb": { + "version": "6.14.1", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-6.14.1.tgz", + "integrity": "sha512-GnHWIm4GtgREkssWRv9vYKNvqwbLd8WL5hCW3nCqzI2OxEZ6Q5g6vc3J6L1Grz0x1hx1wmYAprLlRr3kzBLcJg==", + "license": "Apache-2.0", + "dependencies": { + "@mongodb-js/saslprep": "^1.1.9", + "bson": "^6.10.3", + "mongodb-connection-string-url": "^3.0.0" + }, "engines": { - "node": ">= 0.4" + "node": ">=16.20.1" }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.188.0", + "@mongodb-js/zstd": "^1.1.0 || ^2.0.0", + "gcp-metadata": "^5.2.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=6.0.0 <7", + "snappy": "^7.2.2", + "socks": "^2.7.1" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "gcp-metadata": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + }, + "socks": { + "optional": true + } } }, - "node_modules/has-tostringtag": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.2.tgz", - "integrity": "sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==", + "node_modules/mongodb-connection-string-url": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-3.0.2.tgz", + "integrity": "sha512-rMO7CGo/9BFwyZABcKAWL8UJwH/Kc2x0g72uhDWzG48URRax5TCIcJ7Rc3RZqffZzO/Gwff/jyKwCU9TN8gehA==", + "license": "Apache-2.0", + "dependencies": { + "@types/whatwg-url": "^11.0.2", + "whatwg-url": "^14.1.0 || ^13.0.0" + } + }, + "node_modules/mongodb-memory-server": { + "version": "10.1.4", + "resolved": "https://registry.npmjs.org/mongodb-memory-server/-/mongodb-memory-server-10.1.4.tgz", + "integrity": "sha512-+oKQ/kc3CX+816oPFRtaF0CN4vNcGKNjpOQe4bHo/21A3pMD+lC7Xz1EX5HP7siCX4iCpVchDMmCOFXVQSGkUg==", + "hasInstallScript": true, "license": "MIT", "dependencies": { - "has-symbols": "^1.0.3" + "mongodb-memory-server-core": "10.1.4", + "tslib": "^2.7.0" }, "engines": { - "node": ">= 0.4" + "node": ">=16.20.1" + } + }, + "node_modules/mongodb-memory-server-core": { + "version": "10.1.4", + "resolved": "https://registry.npmjs.org/mongodb-memory-server-core/-/mongodb-memory-server-core-10.1.4.tgz", + "integrity": "sha512-o8fgY7ZalEd8pGps43fFPr/hkQu1L8i6HFEGbsTfA2zDOW0TopgpswaBCqDr0qD7ptibyPfB5DmC+UlIxbThzA==", + "license": "MIT", + "dependencies": { + "async-mutex": "^0.5.0", + "camelcase": "^6.3.0", + "debug": "^4.3.7", + "find-cache-dir": "^3.3.2", + "follow-redirects": "^1.15.9", + "https-proxy-agent": "^7.0.5", + "mongodb": "^6.9.0", + "new-find-package-json": "^2.0.0", + "semver": "^7.6.3", + "tar-stream": "^3.1.7", + "tslib": "^2.7.0", + "yauzl": "^3.1.3" }, - "funding": { - "url": "https://github.com/sponsors/ljharb" + "engines": { + "node": ">=16.20.1" } }, - "node_modules/hasown": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "node_modules/mongoose": { + "version": "8.12.0", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-8.12.0.tgz", + "integrity": "sha512-FXZIngJBTt/gvb6uHZHiROy3Mk3EOjNpD0m+GBRfG+twuEntnMjfxwcA94YbYIulf9LkBozt7H8w2OJpqHdUxA==", "license": "MIT", "dependencies": { - "function-bind": "^1.1.2" + "bson": "^6.10.1", + "kareem": "2.6.3", + "mongodb": "~6.14.0", + "mpath": "0.9.0", + "mquery": "5.0.0", + "ms": "2.1.3", + "sift": "17.1.3" }, "engines": { - "node": ">= 0.4" + "node": ">=16.20.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" } }, - "node_modules/math-intrinsics": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz", - "integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==", + "node_modules/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", "license": "MIT", "engines": { - "node": ">= 0.4" + "node": ">=4.0.0" } }, - "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "node_modules/mquery": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", + "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", "license": "MIT", + "dependencies": { + "debug": "4.x" + }, "engines": { - "node": ">= 0.6" + "node": ">=14.0.0" } }, - "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "license": "MIT" + }, + "node_modules/new-find-package-json": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/new-find-package-json/-/new-find-package-json-2.0.0.tgz", + "integrity": "sha512-lDcBsjBSMlj3LXH2v/FW3txlh2pYTjmbOXPYJD93HI5EwuLzI11tdHSIpUMmfq/IOsldj4Ps8M8flhm+pCK4Ew==", "license": "MIT", "dependencies": { - "mime-db": "1.52.0" + "debug": "^4.3.4" }, "engines": { - "node": ">= 0.6" + "node": ">=12.22.0" } }, "node_modules/node-domexception": { @@ -362,12 +473,156 @@ "url": "https://opencollective.com/node-fetch" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==", + "node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "license": "MIT", + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "license": "MIT", + "dependencies": { + "p-limit": "^2.2.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/pend": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz", + "integrity": "sha512-F3asv42UuXchdzt+xXqfW1OGlVBe+mxa2mqI0pg5yAHZPvFmY3Y6drSf/GQ1A86WgWEN9Kzh/WrgKa6iGcHXLg==", "license": "MIT" }, + "node_modules/pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "license": "MIT", + "dependencies": { + "find-up": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/sift": { + "version": "17.1.3", + "resolved": "https://registry.npmjs.org/sift/-/sift-17.1.3.tgz", + "integrity": "sha512-Rtlj66/b0ICeFzYTuNvX/EF1igRbbnGSvEyT79McoZa/DeGhMyC5pWKOEsZKnpkqtSeovd5FL/bjHWC3CIIvCQ==", + "license": "MIT" + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "license": "MIT", + "dependencies": { + "memory-pager": "^1.0.2" + } + }, + "node_modules/streamx": { + "version": "2.22.0", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.22.0.tgz", + "integrity": "sha512-sLh1evHOzBy/iWRiR6d1zRcLao4gGZr3C1kzNz4fopCOKJb6xD9ub8Mpi9Mr1R6id5o43S+d93fI48UC5uM9aw==", + "license": "MIT", + "dependencies": { + "fast-fifo": "^1.3.2", + "text-decoder": "^1.1.0" + }, + "optionalDependencies": { + "bare-events": "^2.2.0" + } + }, + "node_modules/tar-stream": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-3.1.7.tgz", + "integrity": "sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==", + "license": "MIT", + "dependencies": { + "b4a": "^1.6.4", + "fast-fifo": "^1.2.0", + "streamx": "^2.15.0" + } + }, + "node_modules/text-decoder": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/text-decoder/-/text-decoder-1.2.3.tgz", + "integrity": "sha512-3/o9z3X0X0fTupwsYvR03pJ/DjWuqqrfwBgTQzdWDiQSm9KitAyz/9WqsT2JQW7KV2m+bC2ol/zqpW37NHxLaA==", + "license": "Apache-2.0", + "dependencies": { + "b4a": "^1.6.4" + } + }, + "node_modules/tr46": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-5.0.0.tgz", + "integrity": "sha512-tk2G5R2KRwBd+ZN0zaEXpmzdKyOYksXwywulIX95MBODjSzMIuQnQ3m8JxgbhnL1LeVo7lqQKsYa1O3Htl7K5g==", + "license": "MIT", + "dependencies": { + "punycode": "^2.3.1" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/tslib": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", + "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", + "license": "0BSD" + }, "node_modules/web-streams-polyfill": { "version": "3.3.3", "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz", @@ -376,6 +631,41 @@ "engines": { "node": ">= 8" } + }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "14.1.1", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-14.1.1.tgz", + "integrity": "sha512-mDGf9diDad/giZ/Sm9Xi2YcyzaFpbdLpJPr+E9fSkyQ7KpQD4SdFcugkRQYzhmfI4KeV4Qpnn2sKPdo+kmsgRQ==", + "license": "MIT", + "dependencies": { + "tr46": "^5.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/yauzl": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/yauzl/-/yauzl-3.2.0.tgz", + "integrity": "sha512-Ow9nuGZE+qp1u4JIPvg+uCiUr7xGQWdff7JQSk5VGYTAZMDe2q8lxJ10ygv10qmSj031Ty/6FNJpLO4o1Sgc+w==", + "license": "MIT", + "dependencies": { + "buffer-crc32": "~0.2.3", + "pend": "~1.2.0" + }, + "engines": { + "node": ">=12" + } } } } diff --git a/package.json b/package.json index 07861f0c..a57882e2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { - "type": "module", "dependencies": { - "axios": "^1.7.9", + "mongodb-memory-server": "^10.1.4", + "mongoose": "^8.12.0", "node-fetch": "^3.3.2" }, "type": "module" From 75ef2bf904de398e8f907baa7f27b4364249cfd9 Mon Sep 17 00:00:00 2001 From: claudianistal Date: Tue, 4 Mar 2025 14:47:15 +0100 Subject: [PATCH 19/19] =?UTF-8?q?Instalaci=C3=B3n=20de=20nuevas=20Dependen?= =?UTF-8?q?cias=20tra=C3=ADdas=20de=20Arquisoft=200?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/package-lock.json | 71 +++++++++------------------------------- 1 file changed, 15 insertions(+), 56 deletions(-) diff --git a/webapp/package-lock.json b/webapp/package-lock.json index 270554f4..8db60e11 100644 --- a/webapp/package-lock.json +++ b/webapp/package-lock.json @@ -3989,26 +3989,6 @@ "url": "https://github.com/sponsors/gregberge" } }, - "node_modules/@testing-library/dom": { - "version": "10.4.0", - "resolved": "https://registry.npmjs.org/@testing-library/dom/-/dom-10.4.0.tgz", - "integrity": "sha512-pemlzrSESWbdAloYml3bAJMEfNh1Z7EduzqPKprCH5S341frlpYnUEW0H72dLxa6IsYr+mPno20GiSm+h9dEdQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "@babel/code-frame": "^7.10.4", - "@babel/runtime": "^7.12.5", - "@types/aria-query": "^5.0.1", - "aria-query": "5.3.0", - "chalk": "^4.1.0", - "dom-accessibility-api": "^0.5.9", - "lz-string": "^1.5.0", - "pretty-format": "^27.0.2" - }, - "engines": { - "node": ">=18" - } - }, "node_modules/@testing-library/jest-dom": { "version": "5.17.0", "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-5.17.0.tgz", @@ -4475,17 +4455,6 @@ "integrity": "sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==", "license": "MIT" }, - "node_modules/@types/react": { - "version": "18.3.18", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.18.tgz", - "integrity": "sha512-t4yC+vtgnkYjNSKlFx1jkAhH8LgTo2N/7Qvi83kdEaUtMDiwpbLAktKDaAMlRcJ5eSxZkH74eEGt1ky31d7kfQ==", - "license": "MIT", - "peer": true, - "dependencies": { - "@types/prop-types": "*", - "csstype": "^3.0.2" - } - }, "node_modules/@types/react-dom": { "version": "18.3.5", "resolved": "https://registry.npmjs.org/@types/react-dom/-/react-dom-18.3.5.tgz", @@ -10676,6 +10645,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/growly/-/growly-1.3.0.tgz", "integrity": "sha512-+xGQY0YyAWCnqy7Cd++hc2JqMYzlm0dG30Jd0beaA64sROr8C4nt8Yc9V5Ro3avlSUDTN0ulqP/VBKi1/lLygw==", + "dev": true, "license": "MIT", "optional": true }, @@ -13862,7 +13832,7 @@ "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-29.7.0.tgz", "integrity": "sha512-fP8u2pyfqx0K1rGn1R9pyE0/KTn+G7PxktWidOBTqFPLYX0b9ksaMFkhK5vrS3DVun09pckLdlx90QthlW7AmA==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@jest/types": "^29.6.3", @@ -14954,7 +14924,7 @@ "version": "29.6.3", "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-29.6.3.tgz", "integrity": "sha512-KJJBsRCyyLNWCNBOvZyRDnAIfUiRJ8v+hOBQYGn8gDyF3UegwiP4gwRR3/SDa42g1YbVycTidUF3rKjyLFDWbg==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": "^14.15.0 || ^16.10.0 || >=18.0.0" @@ -14964,7 +14934,7 @@ "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-29.7.0.tgz", "integrity": "sha512-IOVhZSrg+UvVAshDSDtHyFCCBUl/Q3AAJv8iZ6ZjnZ74xzvwuzLXid9IIIPgTnY62SJjfuupMKZsZQRsCvxEgA==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "chalk": "^4.0.0", @@ -15198,7 +15168,7 @@ "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-validate/-/jest-validate-29.7.0.tgz", "integrity": "sha512-ZB7wHqaRGVw/9hST/OuFUReG7M8vKeq0/J2egIGLdvjHCmYqGARhzXmtgi+gVeZ5uXFF219aOc3Ls2yLg27tkw==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@jest/types": "^29.6.3", @@ -15216,7 +15186,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-5.2.0.tgz", "integrity": "sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -15229,7 +15199,7 @@ "version": "6.3.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -15242,7 +15212,7 @@ "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", "integrity": "sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@jest/schemas": "^29.6.3", @@ -15257,7 +15227,7 @@ "version": "18.3.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.3.1.tgz", "integrity": "sha512-/LLMVyas0ljjAtoYiPqYiL8VWXzUUdThrmU5+n20DZv+a+ClRoevUzw5JxU+Ieh5/c87ytoTBV9G1FiKfNJdmg==", - "devOptional": true, + "dev": true, "license": "MIT" }, "node_modules/jest-watcher": { @@ -15284,7 +15254,7 @@ "version": "29.7.0", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-29.7.0.tgz", "integrity": "sha512-eIz2msL/EzL9UFTFFx7jBTkeZfku0yUAyZZZmJ93H2TYEiroIx2PQjEXcwYtYl8zXCxb+PAmA2hLIt/6ZEkPHw==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "@types/node": "*", @@ -15300,7 +15270,7 @@ "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", - "devOptional": true, + "dev": true, "license": "MIT", "dependencies": { "has-flag": "^4.0.0" @@ -16493,6 +16463,7 @@ "version": "8.0.2", "resolved": "https://registry.npmjs.org/node-notifier/-/node-notifier-8.0.2.tgz", "integrity": "sha512-oJP/9NAdd9+x2Q+rfphB2RJCHjod70RcRLjosiPMMu5gjIfwVnOUGq2nbTjTUbmy0DJ/tFIVT30+Qe3nzl4TJg==", + "dev": true, "license": "MIT", "optional": true, "dependencies": { @@ -16508,6 +16479,7 @@ "version": "7.6.3", "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, "license": "ISC", "optional": true, "bin": { @@ -21427,7 +21399,7 @@ "version": "2.0.3", "resolved": "https://registry.npmjs.org/resolve.exports/-/resolve.exports-2.0.3.tgz", "integrity": "sha512-OcXjMsGdhL4XnbShKpAcSqPMzQoYkYyhbEaeSko47MjRP9NfEQMhZkXL1DoFlt9LWQn4YttrdnV6X2OiyzBi+A==", - "devOptional": true, + "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -22534,6 +22506,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/shellwords/-/shellwords-0.1.1.tgz", "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", + "dev": true, "license": "MIT", "optional": true }, @@ -24508,20 +24481,6 @@ "is-typedarray": "^1.0.0" } }, - "node_modules/typescript": { - "version": "4.9.5", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz", - "integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==", - "license": "Apache-2.0", - "peer": true, - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=4.2.0" - } - }, "node_modules/unbox-primitive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz",