Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e281bd4fa8 | |||
| 52b5b72cfb | |||
| 84bf5f3f79 | |||
| 4370d3c35c | |||
| 5ae3ebecee | |||
| 20cc399731 | |||
| 6fa12b12d9 | |||
| 731b51ff48 | |||
| ca4a9671e7 | |||
| 241d362528 | |||
| 13cf7b66ee | |||
| 39868d95c6 | |||
| 2d839b9082 | |||
| 1a2e9aafb2 | |||
| edfe7d6390 | |||
| b7ca3633e6 | |||
| e48ef31fee | |||
| ee42562e13 | |||
| 484220a0f6 | |||
| 930b9434c6 | |||
| 1318243841 | |||
| b8b8655634 | |||
| 839c64c12a |
@@ -31,32 +31,36 @@ jobs:
|
|||||||
needs: detect-changes
|
needs: detect-changes
|
||||||
if: needs.detect-changes.outputs.backend == 'true'
|
if: needs.detect-changes.outputs.backend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '24'
|
node-version: '22'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci --ignore-scripts
|
||||||
|
- name: Install backend native deps
|
||||||
|
run: npm rebuild sqlite3 bcrypt --workspace=farma-clic-backend
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npm test --workspace=farma-clic-backend -- --ci
|
run: npm test --workspace=farma-clic-backend
|
||||||
|
|
||||||
test-frontend:
|
test-frontend:
|
||||||
name: Frontend Tests
|
name: Frontend Tests
|
||||||
needs: detect-changes
|
needs: detect-changes
|
||||||
if: needs.detect-changes.outputs.frontend == 'true'
|
if: needs.detect-changes.outputs.frontend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '24'
|
node-version: '22'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm ci
|
run: npm ci --ignore-scripts
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
run: npm test --workspace=farma-clic-frontend -- --run --reporter=basic
|
run: npm test --workspace=farma-clic-frontend -- --run --reporter=basic
|
||||||
|
|
||||||
|
|||||||
@@ -34,40 +34,36 @@ jobs:
|
|||||||
needs: detect-changes
|
needs: detect-changes
|
||||||
if: needs.detect-changes.outputs.backend == 'true'
|
if: needs.detect-changes.outputs.backend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '24'
|
node-version: '22'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
- name: Install dependencies
|
||||||
- name: Install Dependencies
|
run: npm ci --ignore-scripts
|
||||||
run: npm ci
|
- name: Install backend native deps
|
||||||
|
run: npm rebuild sqlite3 bcrypt --workspace=farma-clic-backend
|
||||||
- name: Run Backend Tests
|
- name: Run Backend Tests
|
||||||
run: npm test --workspace=farma-clic-backend -- --ci
|
run: npm test --workspace=farma-clic-backend
|
||||||
|
|
||||||
test-frontend:
|
test-frontend:
|
||||||
name: Frontend Tests
|
name: Frontend Tests
|
||||||
needs: detect-changes
|
needs: detect-changes
|
||||||
if: needs.detect-changes.outputs.frontend == 'true'
|
if: needs.detect-changes.outputs.frontend == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '24'
|
node-version: '22'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
- name: Install dependencies
|
||||||
- name: Install Dependencies
|
run: npm ci --ignore-scripts
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Run Frontend Tests
|
- name: Run Frontend Tests
|
||||||
run: npm test --workspace=farma-clic-frontend -- --run --reporter=basic
|
run: npm test --workspace=farma-clic-frontend -- --run --reporter=basic
|
||||||
|
|
||||||
@@ -76,19 +72,16 @@ jobs:
|
|||||||
needs: detect-changes
|
needs: detect-changes
|
||||||
if: needs.detect-changes.outputs.frontend-mobile == 'true'
|
if: needs.detect-changes.outputs.frontend-mobile == 'true'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- uses: actions/checkout@v4
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v4
|
||||||
with:
|
with:
|
||||||
node-version: '24'
|
node-version: '22'
|
||||||
cache: 'npm'
|
cache: 'npm'
|
||||||
|
- name: Install dependencies
|
||||||
- name: Install Dependencies
|
run: npm ci --ignore-scripts
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Run Frontend Mobile Tests
|
- name: Run Frontend Mobile Tests
|
||||||
run: npm test --workspace=frontend-mobile -- --ci
|
run: npm test --workspace=frontend-mobile -- --ci
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
import { transformOFFProduct, searchBabyProducts, getBabyProductDetails } from '../off-service.js';
|
||||||
|
|
||||||
|
describe('transformOFFProduct', () => {
|
||||||
|
test('transforms a valid OFF product to unified model', () => {
|
||||||
|
const offProduct = {
|
||||||
|
_id: '12345',
|
||||||
|
product_name: 'Baby Rice',
|
||||||
|
brands: 'Nestlé',
|
||||||
|
image_url: 'https://example.com/image.jpg',
|
||||||
|
nutriscore_grade: 'a',
|
||||||
|
ingredients_text: 'Rice, Iron, Vitamins',
|
||||||
|
nova_group: 1,
|
||||||
|
ecoscore_grade: 'b',
|
||||||
|
categories_tags: ['en:baby-foods', 'en:baby-rice'],
|
||||||
|
};
|
||||||
|
|
||||||
|
const result = transformOFFProduct(offProduct);
|
||||||
|
|
||||||
|
expect(result).toEqual({
|
||||||
|
id: '12345',
|
||||||
|
source: 'openfoodfacts',
|
||||||
|
name: 'Baby Rice',
|
||||||
|
brand: 'Nestlé',
|
||||||
|
category: 'baby_food',
|
||||||
|
image_url: 'https://example.com/image.jpg',
|
||||||
|
nutriscore: 'a',
|
||||||
|
ingredients: 'Rice, Iron, Vitamins',
|
||||||
|
nova_group: 1,
|
||||||
|
eco_score: 'b',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns null for null/undefined input', () => {
|
||||||
|
expect(transformOFFProduct(null)).toBeNull();
|
||||||
|
expect(transformOFFProduct(undefined)).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns null when missing required fields', () => {
|
||||||
|
expect(transformOFFProduct({ _id: '123' })).toBeNull();
|
||||||
|
expect(transformOFFProduct({ product_name: 'Test' })).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('sets default brand to empty string when missing', () => {
|
||||||
|
const result = transformOFFProduct({
|
||||||
|
_id: '999',
|
||||||
|
product_name: 'Plain Product',
|
||||||
|
});
|
||||||
|
expect(result.brand).toBe('');
|
||||||
|
expect(result.image_url).toBeNull();
|
||||||
|
expect(result.nutriscore).toBeNull();
|
||||||
|
expect(result.ingredients).toBeNull();
|
||||||
|
expect(result.nova_group).toBeNull();
|
||||||
|
expect(result.eco_score).toBeNull();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('detects baby_milk category from tags', () => {
|
||||||
|
const result = transformOFFProduct({
|
||||||
|
_id: '200',
|
||||||
|
product_name: 'Infant Formula',
|
||||||
|
categories_tags: ['en:infant-milk'],
|
||||||
|
});
|
||||||
|
expect(result.category).toBe('baby_milk');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('detects baby_cereal category from tags', () => {
|
||||||
|
const result = transformOFFProduct({
|
||||||
|
_id: '300',
|
||||||
|
product_name: 'Baby Cereal',
|
||||||
|
categories_tags: ['en:baby-cereals'],
|
||||||
|
});
|
||||||
|
expect(result.category).toBe('baby_cereal');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('searchBabyProducts', () => {
|
||||||
|
test('returns empty array for short query', async () => {
|
||||||
|
const result = await searchBabyProducts('a');
|
||||||
|
expect(result).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('returns empty array for null/empty query', async () => {
|
||||||
|
expect(await searchBabyProducts(null)).toEqual([]);
|
||||||
|
expect(await searchBabyProducts('')).toEqual([]);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('getBabyProductDetails', () => {
|
||||||
|
test('returns null for null barcode', async () => {
|
||||||
|
const result = await getBabyProductDetails(null);
|
||||||
|
expect(result).toBeNull();
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -3,6 +3,12 @@ import { jest } from '@jest/globals'
|
|||||||
jest.unstable_mockModule('../cima-service.js', () => ({
|
jest.unstable_mockModule('../cima-service.js', () => ({
|
||||||
searchMedicines: jest.fn(async () => []),
|
searchMedicines: jest.fn(async () => []),
|
||||||
getMedicineDetails: jest.fn(async () => null),
|
getMedicineDetails: jest.fn(async () => null),
|
||||||
|
searchOTC: jest.fn(async () => []),
|
||||||
|
}))
|
||||||
|
|
||||||
|
jest.unstable_mockModule('../off-service.js', () => ({
|
||||||
|
searchBabyProducts: jest.fn(async () => []),
|
||||||
|
getBabyProductDetails: jest.fn(async () => null),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
jest.unstable_mockModule('../farmacias-webhook-import.js', () => ({
|
jest.unstable_mockModule('../farmacias-webhook-import.js', () => ({
|
||||||
|
|||||||
+112
-11
@@ -1,9 +1,27 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import redisClient from './redis-client.js';
|
import redisClient from './redis-client.js';
|
||||||
|
import * as appMetrics from './src/metrics.js';
|
||||||
|
|
||||||
const CIMA_API_BASE_URL = 'https://cima.aemps.es/cima/rest';
|
const CIMA_API_BASE_URL = 'https://cima.aemps.es/cima/rest';
|
||||||
const CACHE_TTL = 3600;
|
const CACHE_TTL = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps a CIMA API GET with duration + success/error metrics.
|
||||||
|
*/
|
||||||
|
async function trackedCimaGet(url, params) {
|
||||||
|
const start = Date.now();
|
||||||
|
try {
|
||||||
|
const response = await axios.get(url, { params, timeout: 5000 });
|
||||||
|
appMetrics.cimaRequestDuration.record(Date.now() - start);
|
||||||
|
appMetrics.cimaRequestsTotal.add(1, { status: 'ok' });
|
||||||
|
return response;
|
||||||
|
} catch (err) {
|
||||||
|
appMetrics.cimaRequestDuration.record(Date.now() - start);
|
||||||
|
appMetrics.cimaRequestsTotal.add(1, { status: 'error' });
|
||||||
|
throw err;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Separa los términos de dosis (ej: "1g", "1000 mg") del nombre del
|
* Separa los términos de dosis (ej: "1g", "1000 mg") del nombre del
|
||||||
* medicamento, para poder buscar en CIMA solo con el nombre y luego
|
* medicamento, para poder buscar en CIMA solo con el nombre y luego
|
||||||
@@ -69,23 +87,24 @@ export async function searchMedicines(query) {
|
|||||||
const cacheKey = `medicines:search:v3:${searchTerm}`;
|
const cacheKey = `medicines:search:v3:${searchTerm}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
appMetrics.medicineSearchesTotal.add(1);
|
||||||
|
|
||||||
// Intentar obtener del caché
|
// Intentar obtener del caché
|
||||||
const cachedData = await redisClient.get(cacheKey);
|
const cachedData = await redisClient.get(cacheKey);
|
||||||
|
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
console.log(`📦 Cache hit for: ${searchTerm}`);
|
console.log(`📦 Cache hit for: ${searchTerm}`);
|
||||||
|
appMetrics.cacheHitsTotal.add(1);
|
||||||
return JSON.parse(cachedData);
|
return JSON.parse(cachedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appMetrics.cacheMissesTotal.add(1);
|
||||||
const parsed = parseSearchQuery(searchTerm);
|
const parsed = parseSearchQuery(searchTerm);
|
||||||
const apiSearchTerm = parsed.nameQuery || searchTerm;
|
const apiSearchTerm = parsed.nameQuery || searchTerm;
|
||||||
|
|
||||||
console.log(`🌐 Fetching from CIMA API: ${apiSearchTerm}`);
|
console.log(`🌐 Fetching from CIMA API: ${apiSearchTerm}`);
|
||||||
const response = await axios.get(`${CIMA_API_BASE_URL}/medicamentos`, {
|
const response = await trackedCimaGet(`${CIMA_API_BASE_URL}/medicamentos`, {
|
||||||
params: {
|
nombre: apiSearchTerm,
|
||||||
nombre: apiSearchTerm
|
|
||||||
},
|
|
||||||
timeout: 5000
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.data && response.data.resultados) {
|
if (response.data && response.data.resultados) {
|
||||||
@@ -143,20 +162,23 @@ export async function getMedicineDetails(nregistro) {
|
|||||||
const cacheKey = `medicine:${nregistro}`;
|
const cacheKey = `medicine:${nregistro}`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
appMetrics.medicineSearchesTotal.add(1);
|
||||||
|
|
||||||
// Intentar obtener del caché
|
// Intentar obtener del caché
|
||||||
const cachedData = await redisClient.get(cacheKey);
|
const cachedData = await redisClient.get(cacheKey);
|
||||||
|
|
||||||
if (cachedData) {
|
if (cachedData) {
|
||||||
console.log(`📦 Cache hit for medicine: ${nregistro}`);
|
console.log(`📦 Cache hit for medicine: ${nregistro}`);
|
||||||
|
appMetrics.cacheHitsTotal.add(1);
|
||||||
return JSON.parse(cachedData);
|
return JSON.parse(cachedData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
appMetrics.cacheMissesTotal.add(1);
|
||||||
|
|
||||||
// Intentar obtener de la API de CIMA (endpoint individual puede no existir)
|
// Intentar obtener de la API de CIMA (endpoint individual puede no existir)
|
||||||
console.log(`🌐 Fetching medicine details from CIMA: ${nregistro}`);
|
console.log(`🌐 Fetching medicine details from CIMA: ${nregistro}`);
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(`${CIMA_API_BASE_URL}/medicamento/${nregistro}`, {
|
const response = await trackedCimaGet(`${CIMA_API_BASE_URL}/medicamento/${nregistro}`);
|
||||||
timeout: 5000
|
|
||||||
});
|
|
||||||
|
|
||||||
if (response.data) {
|
if (response.data) {
|
||||||
const med = response.data;
|
const med = response.data;
|
||||||
@@ -185,9 +207,8 @@ export async function getMedicineDetails(nregistro) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Fallback: buscar por nregistro usando el endpoint de búsqueda
|
// Fallback: buscar por nregistro usando el endpoint de búsqueda
|
||||||
const searchResponse = await axios.get(`${CIMA_API_BASE_URL}/medicamentos`, {
|
const searchResponse = await trackedCimaGet(`${CIMA_API_BASE_URL}/medicamentos`, {
|
||||||
params: { nregistro },
|
params: { nregistro },
|
||||||
timeout: 5000
|
|
||||||
});
|
});
|
||||||
|
|
||||||
if (searchResponse.data?.resultados?.length > 0) {
|
if (searchResponse.data?.resultados?.length > 0) {
|
||||||
@@ -231,9 +252,89 @@ export async function getMedicineDetails(nregistro) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Busca medicamentos OTC (Sin Receta) en la API de CIMA con caché de Redis
|
||||||
|
* @param {string} query - Término de búsqueda
|
||||||
|
* @returns {Promise<Array>} - Lista de medicamentos OTC encontrados
|
||||||
|
*/
|
||||||
|
export async function searchOTC(query) {
|
||||||
|
if (!query || query.trim().length < 2) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchTerm = query.trim().toLowerCase();
|
||||||
|
const cacheKey = `cima:otc:${searchTerm}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Intentar obtener del caché
|
||||||
|
const cachedData = await redisClient.get(cacheKey);
|
||||||
|
|
||||||
|
if (cachedData) {
|
||||||
|
console.log(`📦 Cache hit for OTC search: ${searchTerm}`);
|
||||||
|
return JSON.parse(cachedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parsed = parseSearchQuery(searchTerm);
|
||||||
|
const apiSearchTerm = parsed.nameQuery || searchTerm;
|
||||||
|
|
||||||
|
console.log(`🌐 Fetching OTC from CIMA API: ${apiSearchTerm}`);
|
||||||
|
const response = await axios.get(`${CIMA_API_BASE_URL}/medicamentos`, {
|
||||||
|
params: {
|
||||||
|
nombre: apiSearchTerm,
|
||||||
|
cpresc: 'Sin Receta'
|
||||||
|
},
|
||||||
|
timeout: 5000
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.data && response.data.resultados) {
|
||||||
|
// Transformar los datos de CIMA al modelo unificado Product
|
||||||
|
const medicines = response.data.resultados.map(med => ({
|
||||||
|
id: med.nregistro,
|
||||||
|
source: 'cima',
|
||||||
|
name: med.nombre,
|
||||||
|
brand: med.labtitular || '',
|
||||||
|
category: 'otc',
|
||||||
|
image_url: med.fotos?.[0]?.url || null,
|
||||||
|
active_ingredient: med.vtm?.nombre || null,
|
||||||
|
dosage: med.dosis || null,
|
||||||
|
form: med.formaFarmaceutica?.nombre || null,
|
||||||
|
prescription: med.cpresc,
|
||||||
|
commercialized: med.comerc,
|
||||||
|
photos: med.fotos || [],
|
||||||
|
docs: med.docs || []
|
||||||
|
}));
|
||||||
|
|
||||||
|
const filtered = filterMedicinesByFullQuery(medicines, searchTerm);
|
||||||
|
|
||||||
|
// Guardar en caché (1h TTL)
|
||||||
|
await redisClient.setEx(cacheKey, CACHE_TTL, JSON.stringify(filtered));
|
||||||
|
|
||||||
|
console.log(`✅ Cached ${filtered.length} OTC medicines for: ${searchTerm}`);
|
||||||
|
return filtered;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error searching OTC medicines from CIMA:', error.message);
|
||||||
|
|
||||||
|
// Si falla, intentar devolver datos cacheados aunque hayan expirado
|
||||||
|
try {
|
||||||
|
const staleData = await redisClient.get(cacheKey);
|
||||||
|
if (staleData) {
|
||||||
|
console.log('⚠️ Returning stale OTC cache data due to API error');
|
||||||
|
return JSON.parse(staleData);
|
||||||
|
}
|
||||||
|
} catch (cacheError) {
|
||||||
|
console.error('OTC cache fallback also failed:', cacheError);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Limpia el caché de búsquedas (útil para testing o mantenimiento)
|
* Limpia el caché de búsquedas (útil para testing o mantenimiento)
|
||||||
* @param {string} pattern - Patrón de claves a eliminar (ej: 'medicines:search:*')
|
* @param {string} pattern - Patrón de claves a eliminar (ej: 'medicines:*')
|
||||||
* @returns {Promise<number>} - Número de claves eliminadas
|
* @returns {Promise<number>} - Número de claves eliminadas
|
||||||
*/
|
*/
|
||||||
export async function clearCache(pattern = 'medicines:*') {
|
export async function clearCache(pattern = 'medicines:*') {
|
||||||
|
|||||||
@@ -3,4 +3,8 @@ export default {
|
|||||||
transform: {},
|
transform: {},
|
||||||
moduleFileExtensions: ['js', 'json'],
|
moduleFileExtensions: ['js', 'json'],
|
||||||
testMatch: ['**/__tests__/**/*.test.js'],
|
testMatch: ['**/__tests__/**/*.test.js'],
|
||||||
|
testTimeout: 15000,
|
||||||
|
openHandlesTimeout: 5000,
|
||||||
|
// Run test files in parallel (not individual tests within a file)
|
||||||
|
// workerIdleMemoryLimit: '512MB',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,141 @@
|
|||||||
|
import axios from 'axios';
|
||||||
|
import redisClient from './redis-client.js';
|
||||||
|
|
||||||
|
const OFF_API_BASE = 'https://world.openfoodfacts.org/api/v2';
|
||||||
|
const CACHE_TTL = 3600;
|
||||||
|
|
||||||
|
export function transformOFFProduct(offProduct) {
|
||||||
|
if (!offProduct || !offProduct._id || !offProduct.product_name) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const categoriesTags = offProduct.categories_tags || [];
|
||||||
|
let category = 'baby_food';
|
||||||
|
for (const tag of categoriesTags) {
|
||||||
|
const lower = tag.toLowerCase();
|
||||||
|
if (lower.includes('baby-milk') || lower.includes('infant-milk')) {
|
||||||
|
category = 'baby_milk';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (lower.includes('baby-cereal') || lower.includes('infant-cereal')) {
|
||||||
|
category = 'baby_cereal';
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: offProduct._id,
|
||||||
|
source: 'openfoodfacts',
|
||||||
|
name: offProduct.product_name,
|
||||||
|
brand: offProduct.brands || '',
|
||||||
|
category,
|
||||||
|
image_url: offProduct.image_url || null,
|
||||||
|
nutriscore: offProduct.nutriscore_grade || null,
|
||||||
|
ingredients: offProduct.ingredients_text || null,
|
||||||
|
nova_group: offProduct.nova_group || null,
|
||||||
|
eco_score: offProduct.ecoscore_grade || null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function searchBabyProducts(query) {
|
||||||
|
if (!query || query.trim().length < 2) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
const searchTerm = query.trim().toLowerCase();
|
||||||
|
const cacheKey = `off:baby:${searchTerm}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cachedData = await redisClient.get(cacheKey);
|
||||||
|
if (cachedData) {
|
||||||
|
console.log(`Cache hit for OFF search: ${searchTerm}`);
|
||||||
|
return JSON.parse(cachedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Fetching from OFF API: ${searchTerm}`);
|
||||||
|
const response = await axios.get(`${OFF_API_BASE}/search`, {
|
||||||
|
params: {
|
||||||
|
categories_tags: 'baby-food',
|
||||||
|
search_terms: searchTerm,
|
||||||
|
json: true,
|
||||||
|
fields: 'product_name,brands,image_url,nutriscore_grade,ingredients_text,nova_group,ecoscore_grade,categories_tags',
|
||||||
|
page_size: 20,
|
||||||
|
},
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.data && response.data.products) {
|
||||||
|
const products = response.data.products
|
||||||
|
.map(transformOFFProduct)
|
||||||
|
.filter(Boolean);
|
||||||
|
|
||||||
|
try {
|
||||||
|
await redisClient.setEx(cacheKey, CACHE_TTL, JSON.stringify(products));
|
||||||
|
console.log(`Cached ${products.length} OFF products for: ${searchTerm}`);
|
||||||
|
} catch (cacheErr) {
|
||||||
|
// cache write failed, still return the data
|
||||||
|
}
|
||||||
|
return products;
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error searching baby products from OFF:', error.message);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getBabyProductDetails(barcode) {
|
||||||
|
if (!barcode) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const cacheKey = `off:product:${barcode}`;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const cachedData = await redisClient.get(cacheKey);
|
||||||
|
if (cachedData) {
|
||||||
|
console.log(`Cache hit for OFF product: ${barcode}`);
|
||||||
|
return JSON.parse(cachedData);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`Fetching OFF product details: ${barcode}`);
|
||||||
|
const response = await axios.get(`${OFF_API_BASE}/product/${barcode}.json`, {
|
||||||
|
timeout: 5000,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.data && response.data.product) {
|
||||||
|
const product = transformOFFProduct(response.data.product);
|
||||||
|
|
||||||
|
if (product) {
|
||||||
|
try {
|
||||||
|
await redisClient.setEx(cacheKey, CACHE_TTL, JSON.stringify(product));
|
||||||
|
console.log(`Cached OFF product: ${barcode}`);
|
||||||
|
} catch (cacheErr) {
|
||||||
|
// cache write failed, still return the data
|
||||||
|
}
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error fetching OFF product ${barcode}:`, error.message);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function clearCache(pattern = 'off:*') {
|
||||||
|
try {
|
||||||
|
const keys = await redisClient.keys(pattern);
|
||||||
|
if (keys.length > 0) {
|
||||||
|
await redisClient.del(keys);
|
||||||
|
console.log(`Cleared ${keys.length} OFF cache entries`);
|
||||||
|
return keys.length;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error clearing OFF cache:', error);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
"migrate": "node migrate.js",
|
"migrate": "node migrate.js",
|
||||||
"reset-db": "bash reset-db.sh",
|
"reset-db": "bash reset-db.sh",
|
||||||
"import-farmacias": "node import-farmacias.js",
|
"import-farmacias": "node import-farmacias.js",
|
||||||
"test": "NODE_OPTIONS='--experimental-vm-modules' npx jest --forceExit"
|
"test": "NODE_OPTIONS='--experimental-vm-modules' npx jest --ci --forceExit --forceExitTimeout=30000"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
@@ -21,10 +21,12 @@
|
|||||||
"@opentelemetry/api": "^1.9.0",
|
"@opentelemetry/api": "^1.9.0",
|
||||||
"@opentelemetry/auto-instrumentations-node": "^0.52.0",
|
"@opentelemetry/auto-instrumentations-node": "^0.52.0",
|
||||||
"@opentelemetry/exporter-logs-otlp-grpc": "^0.55.0",
|
"@opentelemetry/exporter-logs-otlp-grpc": "^0.55.0",
|
||||||
|
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.55.0",
|
||||||
"@opentelemetry/exporter-trace-otlp-grpc": "^0.55.0",
|
"@opentelemetry/exporter-trace-otlp-grpc": "^0.55.0",
|
||||||
"@opentelemetry/instrumentation-pino": "^0.45.0",
|
"@opentelemetry/instrumentation-pino": "^0.45.0",
|
||||||
"@opentelemetry/resources": "^1.28.0",
|
"@opentelemetry/resources": "^1.28.0",
|
||||||
"@opentelemetry/sdk-logs": "^0.55.0",
|
"@opentelemetry/sdk-logs": "^0.55.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "^1.28.0",
|
||||||
"@opentelemetry/sdk-node": "^0.55.0",
|
"@opentelemetry/sdk-node": "^0.55.0",
|
||||||
"@opentelemetry/sdk-trace-base": "^1.28.0",
|
"@opentelemetry/sdk-trace-base": "^1.28.0",
|
||||||
"@opentelemetry/semantic-conventions": "^1.28.0",
|
"@opentelemetry/semantic-conventions": "^1.28.0",
|
||||||
|
|||||||
@@ -1,16 +1,22 @@
|
|||||||
import { createClient } from 'redis';
|
import { createClient } from 'redis';
|
||||||
|
import * as appMetrics from './src/metrics.js';
|
||||||
|
|
||||||
// Create Redis client
|
// Create Redis client
|
||||||
const redisClient = createClient({
|
const redisClient = createClient({
|
||||||
socket: {
|
socket: {
|
||||||
host: process.env.REDIS_HOST || 'localhost',
|
host: process.env.REDIS_HOST || 'localhost',
|
||||||
port: process.env.REDIS_PORT || 6379
|
port: process.env.REDIS_PORT || 6379,
|
||||||
|
reconnectStrategy: (retries) => {
|
||||||
|
if (retries > 10) return new Error('Redis max retries reached');
|
||||||
|
return Math.min(retries * 100, 3000);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
password: process.env.REDIS_PASSWORD || undefined
|
password: process.env.REDIS_PASSWORD || undefined
|
||||||
});
|
});
|
||||||
|
|
||||||
// Error handler
|
// Error handler
|
||||||
redisClient.on('error', (err) => {
|
redisClient.on('error', (err) => {
|
||||||
|
appMetrics.redisErrorsTotal.add(1);
|
||||||
console.error('Redis Client Error:', err);
|
console.error('Redis Client Error:', err);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -19,7 +25,32 @@ redisClient.on('connect', () => {
|
|||||||
console.log('✅ Connected to Redis');
|
console.log('✅ Connected to Redis');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Instrument get/setEx with command duration (used by the CIMA cache path).
|
||||||
|
const origGet = redisClient.get.bind(redisClient);
|
||||||
|
redisClient.get = async (...args) => {
|
||||||
|
const start = performance.now();
|
||||||
|
try {
|
||||||
|
return await origGet(...args);
|
||||||
|
} finally {
|
||||||
|
appMetrics.redisCmdDuration.record(performance.now() - start);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const origSetEx = redisClient.setEx.bind(redisClient);
|
||||||
|
redisClient.setEx = async (...args) => {
|
||||||
|
const start = performance.now();
|
||||||
|
try {
|
||||||
|
return await origSetEx(...args);
|
||||||
|
} finally {
|
||||||
|
appMetrics.redisCmdDuration.record(performance.now() - start);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Connect to Redis
|
// Connect to Redis
|
||||||
await redisClient.connect();
|
await redisClient.connect();
|
||||||
|
// Connect to Redis — skip in test (services are mocked) or when REDIS_URL is unset
|
||||||
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
|
await redisClient.connect();
|
||||||
|
}
|
||||||
|
|
||||||
export default redisClient;
|
export default redisClient;
|
||||||
|
|||||||
+157
-20
@@ -1,7 +1,12 @@
|
|||||||
// OpenTelemetry SDK — must be imported first to instrument http, express, pg, etc.
|
// OpenTelemetry SDK — must be imported first to instrument http, express, pg, etc.
|
||||||
import './src/tracing.js';
|
// Skipped in test to avoid gRPC connection attempts to a non-existent collector.
|
||||||
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
|
await import('./src/tracing.js');
|
||||||
|
}
|
||||||
|
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
|
import redisClient from './redis-client.js';
|
||||||
|
import * as appMetrics from './src/metrics.js';
|
||||||
import cors from 'cors';
|
import cors from 'cors';
|
||||||
import sqlite3 from 'sqlite3';
|
import sqlite3 from 'sqlite3';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
@@ -17,9 +22,8 @@ import webpush from 'web-push';
|
|||||||
import pino from 'pino';
|
import pino from 'pino';
|
||||||
import pinoHttp from 'pino-http';
|
import pinoHttp from 'pino-http';
|
||||||
import multer from 'multer';
|
import multer from 'multer';
|
||||||
import { createWorker } from 'tesseract.js';
|
import { searchMedicines, getMedicineDetails, searchOTC } from './cima-service.js';
|
||||||
import { BarcodeDetector } from 'barcode-detector';
|
import { searchBabyProducts, getBabyProductDetails } from './off-service.js';
|
||||||
import { searchMedicines, getMedicineDetails } from './cima-service.js';
|
|
||||||
import { runFarmaciaWebhookImport, DEFAULT_FARMACIAS_WEBHOOK, importPharmaciesFromRows } from './farmacias-webhook-import.js';
|
import { runFarmaciaWebhookImport, DEFAULT_FARMACIAS_WEBHOOK, importPharmaciesFromRows } from './farmacias-webhook-import.js';
|
||||||
import { fetchPharmaciesExternal } from '../API/index.js';
|
import { fetchPharmaciesExternal } from '../API/index.js';
|
||||||
|
|
||||||
@@ -56,6 +60,19 @@ app.use(cors({
|
|||||||
app.use(express.json({ limit: '10mb' }));
|
app.use(express.json({ limit: '10mb' }));
|
||||||
app.use(pinoHttp({ logger }));
|
app.use(pinoHttp({ logger }));
|
||||||
|
|
||||||
|
// Explicit HTTP request metrics (count by route + status class, duration).
|
||||||
|
// Auto-instrumentation gives duration histograms but no discrete error count.
|
||||||
|
app.use((req, res, next) => {
|
||||||
|
const start = performance.now();
|
||||||
|
res.on('finish', () => {
|
||||||
|
const route = req.route?.path || req.path;
|
||||||
|
const statusClass = `${Math.floor(res.statusCode / 100)}xx`;
|
||||||
|
appMetrics.httpRequestsTotal.add(1, { route, status_class: statusClass });
|
||||||
|
appMetrics.httpRequestDuration.record(performance.now() - start, { route });
|
||||||
|
});
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
const PG_URL = process.env.PG_URL;
|
const PG_URL = process.env.PG_URL;
|
||||||
let pgPool = null;
|
let pgPool = null;
|
||||||
if (PG_URL) {
|
if (PG_URL) {
|
||||||
@@ -88,10 +105,16 @@ if (process.env.NODE_ENV !== 'test') {
|
|||||||
// Configure session
|
// Configure session
|
||||||
app.use(session(sessionConfig));
|
app.use(session(sessionConfig));
|
||||||
|
|
||||||
const searchLimiter = rateLimit({ windowMs: 60_000, max: 30, standardHeaders: true, legacyHeaders: false });
|
// Shared handler so every limiter emits a counter (route label) on rejection.
|
||||||
const loginLimiter = rateLimit({ windowMs: 60_000, max: 5, standardHeaders: true, legacyHeaders: false });
|
const limitHandler = (route) => (req, res, next) => {
|
||||||
const registerLimiter = rateLimit({ windowMs: 60 * 60_000, max: 10, standardHeaders: true, legacyHeaders: false });
|
appMetrics.rateLimitRejectedTotal.add(1, { route });
|
||||||
const geocodeLimiter = rateLimit({ windowMs: 60_000, max: 10, standardHeaders: true, legacyHeaders: false });
|
res.status(429).json({ error: 'Too many requests, please try again later.' });
|
||||||
|
};
|
||||||
|
|
||||||
|
const searchLimiter = rateLimit({ windowMs: 60_000, max: 30, standardHeaders: true, legacyHeaders: false, handler: limitHandler('search') });
|
||||||
|
const loginLimiter = rateLimit({ windowMs: 60_000, max: 5, standardHeaders: true, legacyHeaders: false, handler: limitHandler('login') });
|
||||||
|
const registerLimiter = rateLimit({ windowMs: 60 * 60_000, max: 10, standardHeaders: true, legacyHeaders: false, handler: limitHandler('register') });
|
||||||
|
const geocodeLimiter = rateLimit({ windowMs: 60_000, max: 10, standardHeaders: true, legacyHeaders: false, handler: limitHandler('geocode') });
|
||||||
|
|
||||||
const VAPID_PUBLIC_KEY = process.env.VAPID_PUBLIC_KEY || '';
|
const VAPID_PUBLIC_KEY = process.env.VAPID_PUBLIC_KEY || '';
|
||||||
const VAPID_PRIVATE_KEY = process.env.VAPID_PRIVATE_KEY || '';
|
const VAPID_PRIVATE_KEY = process.env.VAPID_PRIVATE_KEY || '';
|
||||||
@@ -128,27 +151,54 @@ function toPositional(sql) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function userDbGet(sql, params = []) {
|
async function userDbGet(sql, params = []) {
|
||||||
if (pgPool) {
|
const engine = pgPool ? 'pg' : 'sqlite';
|
||||||
const res = await pgPool.query(toPositional(sql), params);
|
const start = performance.now();
|
||||||
return res.rows[0] ?? null;
|
try {
|
||||||
|
if (pgPool) {
|
||||||
|
const res = await pgPool.query(toPositional(sql), params);
|
||||||
|
return res.rows[0] ?? null;
|
||||||
|
}
|
||||||
|
return await dbGet(sql, params);
|
||||||
|
} catch (err) {
|
||||||
|
appMetrics.dbErrorsTotal.add(1, { engine });
|
||||||
|
throw err;
|
||||||
|
} finally {
|
||||||
|
appMetrics.dbQueryDuration.record(performance.now() - start, { engine });
|
||||||
}
|
}
|
||||||
return dbGet(sql, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function userDbRun(sql, params = []) {
|
async function userDbRun(sql, params = []) {
|
||||||
if (pgPool) {
|
const engine = pgPool ? 'pg' : 'sqlite';
|
||||||
const res = await pgPool.query(toPositional(sql), params);
|
const start = performance.now();
|
||||||
return { lastID: res.rows[0]?.id, changes: res.rowCount };
|
try {
|
||||||
|
if (pgPool) {
|
||||||
|
const res = await pgPool.query(toPositional(sql), params);
|
||||||
|
return { lastID: res.rows[0]?.id, changes: res.rowCount };
|
||||||
|
}
|
||||||
|
return await dbRun(sql.replace(/\s+RETURNING\s+\w+\s*$/i, ''), params);
|
||||||
|
} catch (err) {
|
||||||
|
appMetrics.dbErrorsTotal.add(1, { engine });
|
||||||
|
throw err;
|
||||||
|
} finally {
|
||||||
|
appMetrics.dbQueryDuration.record(performance.now() - start, { engine });
|
||||||
}
|
}
|
||||||
return dbRun(sql.replace(/\s+RETURNING\s+\w+\s*$/i, ''), params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function userDbAll(sql, params = []) {
|
async function userDbAll(sql, params = []) {
|
||||||
if (pgPool) {
|
const engine = pgPool ? 'pg' : 'sqlite';
|
||||||
const res = await pgPool.query(toPositional(sql), params);
|
const start = performance.now();
|
||||||
return res.rows;
|
try {
|
||||||
|
if (pgPool) {
|
||||||
|
const res = await pgPool.query(toPositional(sql), params);
|
||||||
|
return res.rows;
|
||||||
|
}
|
||||||
|
return await dbAll(sql, params);
|
||||||
|
} catch (err) {
|
||||||
|
appMetrics.dbErrorsTotal.add(1, { engine });
|
||||||
|
throw err;
|
||||||
|
} finally {
|
||||||
|
appMetrics.dbQueryDuration.record(performance.now() - start, { engine });
|
||||||
}
|
}
|
||||||
return dbAll(sql, params);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Accept opening_hours as either an object or a JSON string from the client
|
// Accept opening_hours as either an object or a JSON string from the client
|
||||||
@@ -598,6 +648,54 @@ app.get('/api/medicines/:medicineId', async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// ========== UNIFIED PRODUCT SEARCH ==========
|
||||||
|
|
||||||
|
app.get('/api/products/search', searchLimiter, async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { q } = req.query;
|
||||||
|
if (!q || q.trim().length < 2) {
|
||||||
|
return res.json({ results: [], total: 0 });
|
||||||
|
}
|
||||||
|
const searchTerm = q.trim();
|
||||||
|
const [cimaResults, offResults] = await Promise.allSettled([
|
||||||
|
searchOTC(searchTerm),
|
||||||
|
searchBabyProducts(searchTerm)
|
||||||
|
]);
|
||||||
|
const cimaProducts = cimaResults.status === 'fulfilled' ? cimaResults.value : [];
|
||||||
|
const offProducts = offResults.status === 'fulfilled' ? offResults.value : [];
|
||||||
|
const allProducts = [...cimaProducts, ...offProducts]
|
||||||
|
.sort((a, b) => a.name.localeCompare(b.name));
|
||||||
|
res.json({
|
||||||
|
results: allProducts,
|
||||||
|
total: allProducts.length,
|
||||||
|
sources: { cima: cimaProducts.length, openfoodfacts: offProducts.length }
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[Products] Search error:', err);
|
||||||
|
res.status(500).json({ error: 'Error searching products' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/api/products/:source/:id', async (req, res) => {
|
||||||
|
try {
|
||||||
|
const { source, id } = req.params;
|
||||||
|
if (source === 'cima') {
|
||||||
|
const product = await getMedicineDetails(id);
|
||||||
|
if (!product) return res.status(404).json({ error: 'Product not found' });
|
||||||
|
return res.json({ ...product, source: 'cima', category: 'otc' });
|
||||||
|
}
|
||||||
|
if (source === 'openfoodfacts') {
|
||||||
|
const product = await getBabyProductDetails(id);
|
||||||
|
if (!product) return res.status(404).json({ error: 'Product not found' });
|
||||||
|
return res.json(product);
|
||||||
|
}
|
||||||
|
res.status(400).json({ error: 'Invalid source' });
|
||||||
|
} catch (err) {
|
||||||
|
console.error('[Products] Detail error:', err);
|
||||||
|
res.status(500).json({ error: 'Error fetching product details' });
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ========== AUTHENTICATION MIDDLEWARE ==========
|
// ========== AUTHENTICATION MIDDLEWARE ==========
|
||||||
|
|
||||||
// Middleware to check if user is authenticated
|
// Middleware to check if user is authenticated
|
||||||
@@ -817,6 +915,7 @@ app.post('/api/tsi/ocr', upload.single('photo'), async (req, res) => {
|
|||||||
|
|
||||||
console.log('[OCR] Processing image, size:', req.file.size, 'bytes');
|
console.log('[OCR] Processing image, size:', req.file.size, 'bytes');
|
||||||
|
|
||||||
|
const { createWorker } = await import('tesseract.js');
|
||||||
const worker = await createWorker('spa+eng');
|
const worker = await createWorker('spa+eng');
|
||||||
const { data } = await worker.recognize(req.file.buffer);
|
const { data } = await worker.recognize(req.file.buffer);
|
||||||
await worker.terminate();
|
await worker.terminate();
|
||||||
@@ -861,6 +960,7 @@ app.post('/api/auth/login', loginLimiter, async (req, res) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
appMetrics.loginFailureTotal.add(1);
|
||||||
return res.status(401).json({ error: 'Invalid username or password' });
|
return res.status(401).json({ error: 'Invalid username or password' });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -868,6 +968,7 @@ app.post('/api/auth/login', loginLimiter, async (req, res) => {
|
|||||||
const isValidPassword = await bcrypt.compare(password, user.password_hash);
|
const isValidPassword = await bcrypt.compare(password, user.password_hash);
|
||||||
|
|
||||||
if (!isValidPassword) {
|
if (!isValidPassword) {
|
||||||
|
appMetrics.loginFailureTotal.add(1);
|
||||||
return res.status(401).json({ error: 'Invalid username or password' });
|
return res.status(401).json({ error: 'Invalid username or password' });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -876,6 +977,7 @@ app.post('/api/auth/login', loginLimiter, async (req, res) => {
|
|||||||
req.session.username = user.username;
|
req.session.username = user.username;
|
||||||
req.session.isAdmin = Boolean(user.is_admin);
|
req.session.isAdmin = Boolean(user.is_admin);
|
||||||
|
|
||||||
|
appMetrics.loginSuccessTotal.add(1);
|
||||||
res.json({
|
res.json({
|
||||||
message: 'Login successful',
|
message: 'Login successful',
|
||||||
user: {
|
user: {
|
||||||
@@ -1583,6 +1685,7 @@ app.post('/api/admin/pharmacies', requireAdmin, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.status(201).json(newPharmacy);
|
res.status(201).json(newPharmacy);
|
||||||
|
appMetrics.pharmacyWriteTotal.add(1, { op: 'create' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error adding pharmacy:', error);
|
console.error('Error adding pharmacy:', error);
|
||||||
if (error.message.includes('UNIQUE constraint')) {
|
if (error.message.includes('UNIQUE constraint')) {
|
||||||
@@ -1620,6 +1723,7 @@ app.put('/api/admin/pharmacies/:id', requireAdmin, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.json(updatedPharmacy);
|
res.json(updatedPharmacy);
|
||||||
|
appMetrics.pharmacyWriteTotal.add(1, { op: 'update' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating pharmacy:', error);
|
console.error('Error updating pharmacy:', error);
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
@@ -1638,6 +1742,7 @@ app.delete('/api/admin/pharmacies/:id', requireAdmin, async (req, res) => {
|
|||||||
await userDbRun('DELETE FROM pharmacies WHERE id = ?', [pharmacyId]);
|
await userDbRun('DELETE FROM pharmacies WHERE id = ?', [pharmacyId]);
|
||||||
|
|
||||||
res.json({ message: 'Pharmacy deleted successfully' });
|
res.json({ message: 'Pharmacy deleted successfully' });
|
||||||
|
appMetrics.pharmacyWriteTotal.add(1, { op: 'delete' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting pharmacy:', error);
|
console.error('Error deleting pharmacy:', error);
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
@@ -1807,6 +1912,7 @@ app.post('/api/admin/pharmacy-medicines', requireAdmin, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.status(201).json(relationship);
|
res.status(201).json(relationship);
|
||||||
|
appMetrics.pharmacyMedicineLinkTotal.add(1, { op: 'create' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error adding medicine to pharmacy:', error);
|
console.error('Error adding medicine to pharmacy:', error);
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
@@ -1834,6 +1940,7 @@ app.put('/api/admin/pharmacy-medicines/:id', requireAdmin, async (req, res) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
res.json(updated);
|
res.json(updated);
|
||||||
|
appMetrics.pharmacyMedicineLinkTotal.add(1, { op: 'update' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error updating pharmacy-medicine:', error);
|
console.error('Error updating pharmacy-medicine:', error);
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
@@ -1846,6 +1953,7 @@ app.delete('/api/admin/pharmacy-medicines/:id', requireAdmin, async (req, res) =
|
|||||||
const id = parseInt(req.params.id);
|
const id = parseInt(req.params.id);
|
||||||
await userDbRun('DELETE FROM pharmacy_medicines WHERE id = ?', [id]);
|
await userDbRun('DELETE FROM pharmacy_medicines WHERE id = ?', [id]);
|
||||||
res.json({ message: 'Medicine removed from pharmacy successfully' });
|
res.json({ message: 'Medicine removed from pharmacy successfully' });
|
||||||
|
appMetrics.pharmacyMedicineLinkTotal.add(1, { op: 'delete' });
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error deleting pharmacy-medicine:', error);
|
console.error('Error deleting pharmacy-medicine:', error);
|
||||||
res.status(500).json({ error: 'Internal server error' });
|
res.status(500).json({ error: 'Internal server error' });
|
||||||
@@ -2157,8 +2265,10 @@ async function sendPushForMedicine({ medicine_nregistro, medicine_name, pharmacy
|
|||||||
payload
|
payload
|
||||||
);
|
);
|
||||||
sent++;
|
sent++;
|
||||||
|
appMetrics.pushSentTotal.add(1, { channel: 'web' });
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
failed++;
|
failed++;
|
||||||
|
appMetrics.pushFailedTotal.add(1, { channel: 'web' });
|
||||||
const status = err?.statusCode;
|
const status = err?.statusCode;
|
||||||
if (status === 404 || status === 410) {
|
if (status === 404 || status === 410) {
|
||||||
try {
|
try {
|
||||||
@@ -2214,8 +2324,10 @@ async function sendPushForMedicine({ medicine_nregistro, medicine_name, pharmacy
|
|||||||
for (const ticket of result.data) {
|
for (const ticket of result.data) {
|
||||||
if (ticket.status === 'ok') {
|
if (ticket.status === 'ok') {
|
||||||
sent++;
|
sent++;
|
||||||
|
appMetrics.pushSentTotal.add(1, { channel: 'expo' });
|
||||||
} else {
|
} else {
|
||||||
failed++;
|
failed++;
|
||||||
|
appMetrics.pushFailedTotal.add(1, { channel: 'expo' });
|
||||||
// Prune invalid tokens
|
// Prune invalid tokens
|
||||||
if (ticket.message?.includes('InvalidCredentials') || ticket.message?.includes('DeviceNotRegistered')) {
|
if (ticket.message?.includes('InvalidCredentials') || ticket.message?.includes('DeviceNotRegistered')) {
|
||||||
const expoEndpoint = `expo://${ticket.id || ''}`;
|
const expoEndpoint = `expo://${ticket.id || ''}`;
|
||||||
@@ -2230,13 +2342,16 @@ async function sendPushForMedicine({ medicine_nregistro, medicine_name, pharmacy
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sent += chunk.length;
|
sent += chunk.length;
|
||||||
|
appMetrics.pushSentTotal.add(chunk.length, { channel: 'expo' });
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
failed += chunk.length;
|
failed += chunk.length;
|
||||||
|
appMetrics.pushFailedTotal.add(chunk.length, { channel: 'expo' });
|
||||||
console.error('[push] expo send failed:', response.status);
|
console.error('[push] expo send failed:', response.status);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
failed += chunk.length;
|
failed += chunk.length;
|
||||||
|
appMetrics.pushFailedTotal.add(chunk.length, { channel: 'expo' });
|
||||||
console.error('[push] expo send error:', err.message);
|
console.error('[push] expo send error:', err.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2245,6 +2360,28 @@ async function sendPushForMedicine({ medicine_nregistro, medicine_name, pharmacy
|
|||||||
return { sent, failed, pruned };
|
return { sent, failed, pruned };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- Health & readiness probes --------------------------------------------
|
||||||
|
// /healthz: liveness (process is up). /readyz: dependencies reachable.
|
||||||
|
app.get('/healthz', (_req, res) => {
|
||||||
|
res.json({ status: 'ok', uptime: process.uptime() });
|
||||||
|
});
|
||||||
|
|
||||||
|
app.get('/readyz', async (_req, res) => {
|
||||||
|
const checks = { redis: 'ok', db: 'ok' };
|
||||||
|
try {
|
||||||
|
await redisClient.ping();
|
||||||
|
} catch {
|
||||||
|
checks.redis = 'fail';
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
await userDbGet('SELECT 1');
|
||||||
|
} catch {
|
||||||
|
checks.db = 'fail';
|
||||||
|
}
|
||||||
|
const ready = checks.redis === 'ok' && checks.db === 'ok';
|
||||||
|
res.status(ready ? 200 : 503).json({ status: ready ? 'ok' : 'degraded', checks });
|
||||||
|
});
|
||||||
|
|
||||||
export { app, initDatabase, db };
|
export { app, initDatabase, db };
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
|
|||||||
@@ -0,0 +1,108 @@
|
|||||||
|
// OpenTelemetry metrics for the FarmaFinder backend.
|
||||||
|
//
|
||||||
|
// Uses the global MeterProvider configured in `tracing.js` (imported first in
|
||||||
|
// server.js). Metrics flow OTLP → Alloy → Prometheus remote_write, exactly like
|
||||||
|
// the tracing pipeline, so no extra Prometheus scrape job is required.
|
||||||
|
import { metrics } from '@opentelemetry/api';
|
||||||
|
|
||||||
|
const meter = metrics.getMeter('farmafinder-backend', '1.0.0');
|
||||||
|
|
||||||
|
// --- Heartbeat -------------------------------------------------------------
|
||||||
|
// Emitted continuously so we can alert on "backend not sending telemetry"
|
||||||
|
// (remote_write has no `up` metric).
|
||||||
|
export const heartbeatTotal = meter.createCounter('app_heartbeat_total', {
|
||||||
|
description: 'Heartbeat ticks from the backend process (liveness signal).',
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Medicine search / CIMA upstream --------------------------------------
|
||||||
|
export const medicineSearchesTotal = meter.createCounter('medicine_searches_total', {
|
||||||
|
description: 'Total medicine searches handled (cache or upstream).',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cimaRequestsTotal = meter.createCounter('cima_requests_total', {
|
||||||
|
description: 'Total upstream CIMA API requests.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cimaRequestDuration = meter.createHistogram('cima_request_duration_ms', {
|
||||||
|
description: 'Duration of upstream CIMA API requests.',
|
||||||
|
unit: 'ms',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cacheHitsTotal = meter.createCounter('cache_hits_total', {
|
||||||
|
description: 'Total Redis cache hits.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const cacheMissesTotal = meter.createCounter('cache_misses_total', {
|
||||||
|
description: 'Total Redis cache misses (fell through to upstream).',
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Auth ------------------------------------------------------------------
|
||||||
|
export const loginSuccessTotal = meter.createCounter('login_success_total', {
|
||||||
|
description: 'Successful login attempts.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const loginFailureTotal = meter.createCounter('login_failure_total', {
|
||||||
|
description: 'Failed login attempts.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const rateLimitRejectedTotal = meter.createCounter('rate_limit_rejected_total', {
|
||||||
|
description: 'Requests rejected by a rate limiter.',
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Admin operations ------------------------------------------------------
|
||||||
|
export const pharmacyWriteTotal = meter.createCounter('pharmacy_write_total', {
|
||||||
|
description: 'Admin pharmacy write operations.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const pharmacyMedicineLinkTotal = meter.createCounter('pharmacy_medicine_link_total', {
|
||||||
|
description: 'Pharmacy-medicine link operations.',
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Push notifications ----------------------------------------------------
|
||||||
|
export const pushSentTotal = meter.createCounter('push_sent_total', {
|
||||||
|
description: 'Push notifications successfully sent.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const pushFailedTotal = meter.createCounter('push_failed_total', {
|
||||||
|
description: 'Push notifications that failed to send.',
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Datastores ------------------------------------------------------------
|
||||||
|
export const dbQueryDuration = meter.createHistogram('db_query_duration_ms', {
|
||||||
|
description: 'Duration of user DB queries.',
|
||||||
|
unit: 'ms',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const dbErrorsTotal = meter.createCounter('db_errors_total', {
|
||||||
|
description: 'User DB query errors.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const redisErrorsTotal = meter.createCounter('redis_errors_total', {
|
||||||
|
description: 'Redis client errors.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const redisCmdDuration = meter.createHistogram('redis_cmd_duration_ms', {
|
||||||
|
description: 'Duration of Redis commands.',
|
||||||
|
unit: 'ms',
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- HTTP (explicit, so we get status class + per-route breakdowns) --------
|
||||||
|
// OTel's http auto-instrumentation records duration but not a discrete
|
||||||
|
// error count, so we track requests explicitly for error-rate alerting.
|
||||||
|
export const httpRequestsTotal = meter.createCounter('http_requests_total', {
|
||||||
|
description: 'Total HTTP requests, labelled by route and status class.',
|
||||||
|
});
|
||||||
|
|
||||||
|
export const httpRequestDuration = meter.createHistogram('http_request_duration_ms', {
|
||||||
|
description: 'HTTP request duration.',
|
||||||
|
unit: 'ms',
|
||||||
|
});
|
||||||
|
|
||||||
|
// --- Heartbeat loop (guarded against --watch duplicate intervals) ----------
|
||||||
|
const HEARTBEAT_INTERVAL_MS = 30_000;
|
||||||
|
if (process.env.NODE_ENV !== 'test' && !globalThis.__farmafinderHeartbeat) {
|
||||||
|
globalThis.__farmafinderHeartbeat = setInterval(() => {
|
||||||
|
heartbeatTotal.add(1);
|
||||||
|
}, HEARTBEAT_INTERVAL_MS);
|
||||||
|
globalThis.__farmafinderHeartbeat?.unref?.();
|
||||||
|
}
|
||||||
@@ -9,28 +9,40 @@
|
|||||||
// routed to Tempo.
|
// routed to Tempo.
|
||||||
|
|
||||||
import { NodeSDK } from '@opentelemetry/sdk-node';
|
import { NodeSDK } from '@opentelemetry/sdk-node';
|
||||||
|
import { PeriodicExportingMetricReader } from '@opentelemetry/sdk-metrics';
|
||||||
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node';
|
||||||
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-grpc';
|
||||||
|
import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-grpc';
|
||||||
import * as resources from '@opentelemetry/resources';
|
import * as resources from '@opentelemetry/resources';
|
||||||
import { ATTR_SERVICE_NAME, ATTR_SERVICE_NAMESPACE } from '@opentelemetry/semantic-conventions';
|
|
||||||
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
|
import { PinoInstrumentation } from '@opentelemetry/instrumentation-pino';
|
||||||
|
|
||||||
const serviceName = process.env.OTEL_SERVICE_NAME || 'farmaclic-backend';
|
const serviceName = process.env.OTEL_SERVICE_NAME || 'farmaclic-backend';
|
||||||
const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317';
|
const otlpEndpoint = process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'http://localhost:4317';
|
||||||
|
|
||||||
|
// Use plain string attribute keys (not the semantic-conventions named exports)
|
||||||
|
// so we don't depend on a specific @opentelemetry/semantic-conventions version.
|
||||||
const resource = typeof resources.resourceFromAttributes === 'function'
|
const resource = typeof resources.resourceFromAttributes === 'function'
|
||||||
? resources.resourceFromAttributes({
|
? resources.resourceFromAttributes({
|
||||||
[ATTR_SERVICE_NAME]: serviceName,
|
'service.name': serviceName,
|
||||||
[ATTR_SERVICE_NAMESPACE]: 'farmaclic',
|
'service.namespace': 'farmaclic',
|
||||||
})
|
})
|
||||||
: new resources.Resource({
|
: new resources.Resource({
|
||||||
[ATTR_SERVICE_NAME]: serviceName,
|
'service.name': serviceName,
|
||||||
[ATTR_SERVICE_NAMESPACE]: 'farmaclic',
|
'service.namespace': 'farmaclic',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Metrics → OTLP → Alloy → Prometheus remote_write. The PeriodicExportingMetricReader
|
||||||
|
// makes the auto-instrumentations (http/express/redis) emit request duration/error
|
||||||
|
// metrics with no extra code, on top of the custom business metrics in src/metrics.js.
|
||||||
|
const metricReader = new PeriodicExportingMetricReader({
|
||||||
|
exportIntervalMillis: 15_000,
|
||||||
|
exporter: new OTLPMetricExporter({ url: otlpEndpoint }),
|
||||||
|
});
|
||||||
|
|
||||||
const sdk = new NodeSDK({
|
const sdk = new NodeSDK({
|
||||||
resource,
|
resource,
|
||||||
traceExporter: new OTLPTraceExporter({ url: otlpEndpoint }),
|
traceExporter: new OTLPTraceExporter({ url: otlpEndpoint }),
|
||||||
|
metricReader,
|
||||||
instrumentations: [
|
instrumentations: [
|
||||||
getNodeAutoInstrumentations({
|
getNodeAutoInstrumentations({
|
||||||
// Disable fs by default — it is noisy and rarely useful.
|
// Disable fs by default — it is noisy and rarely useful.
|
||||||
|
|||||||
@@ -6,3 +6,8 @@ EXPO_PUBLIC_API_URL=http://localhost:3001/api
|
|||||||
|
|
||||||
# For production builds, update this to:
|
# For production builds, update this to:
|
||||||
# EXPO_PUBLIC_API_URL=https://api.yourdomain.com/api
|
# EXPO_PUBLIC_API_URL=https://api.yourdomain.com/api
|
||||||
|
|
||||||
|
# Grafana Alloy OTLP/HTTP endpoint for Faro RUM (must be reachable from the
|
||||||
|
# device — use a LAN IP / public hostname, NOT localhost).
|
||||||
|
# Open router :4318 → srv84-macos:4318, or proxy /faro via Nginx Proxy Manager.
|
||||||
|
EXPO_PUBLIC_FARO_URL=http://grafana.hacecalor.net:4318
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { View, FlatList, StyleSheet, Text, TouchableOpacity, useWindowDimensions } from 'react-native';
|
import { View, FlatList, StyleSheet, Text, TouchableOpacity, useWindowDimensions } from 'react-native';
|
||||||
import { Ionicons } from '@expo/vector-icons';
|
import { Ionicons } from '@expo/vector-icons';
|
||||||
import { useNavigation } from 'expo-router';
|
import { useNavigation, useRouter } from 'expo-router';
|
||||||
import { SearchBar } from '../../components/SearchBar';
|
import { SearchBar } from '../../components/SearchBar';
|
||||||
import { MedicineCard } from '../../components/MedicineCard';
|
import { MedicineCard } from '../../components/MedicineCard';
|
||||||
import { LoadingSpinner } from '../../components/LoadingSpinner';
|
import { LoadingSpinner } from '../../components/LoadingSpinner';
|
||||||
@@ -9,6 +9,7 @@ import { useDebounce } from '../../hooks/useDebounce';
|
|||||||
import { useAuth } from '../../hooks/useAuth';
|
import { useAuth } from '../../hooks/useAuth';
|
||||||
import { useRecentSearches } from '../../hooks/useRecentSearches';
|
import { useRecentSearches } from '../../hooks/useRecentSearches';
|
||||||
import { searchMedicines } from '../../services/medicines';
|
import { searchMedicines } from '../../services/medicines';
|
||||||
|
import { searchProducts, Product } from '../../services/products';
|
||||||
import { useThemeContext } from '../../components/ThemeProvider';
|
import { useThemeContext } from '../../components/ThemeProvider';
|
||||||
import { spacing, borderRadius } from '../../constants/theme';
|
import { spacing, borderRadius } from '../../constants/theme';
|
||||||
import { Medicine } from '../../types';
|
import { Medicine } from '../../types';
|
||||||
@@ -31,11 +32,14 @@ export default function SearchScreen() {
|
|||||||
const { colors } = useThemeContext();
|
const { colors } = useThemeContext();
|
||||||
const [query, setQuery] = useState('');
|
const [query, setQuery] = useState('');
|
||||||
const [results, setResults] = useState<Medicine[]>([]);
|
const [results, setResults] = useState<Medicine[]>([]);
|
||||||
|
const [products, setProducts] = useState<Product[]>([]);
|
||||||
|
const [searchMode, setSearchMode] = useState<'all' | 'medicines' | 'products'>('all');
|
||||||
const [isLoading, setIsLoading] = useState(false);
|
const [isLoading, setIsLoading] = useState(false);
|
||||||
const [error, setError] = useState<string | null>(null);
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
|
||||||
const debouncedQuery = useDebounce(query, config.SEARCH_DEBOUNCE_MS);
|
const debouncedQuery = useDebounce(query, config.SEARCH_DEBOUNCE_MS);
|
||||||
const navigation = useNavigation();
|
const navigation = useNavigation();
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const parent = navigation.getParent();
|
const parent = navigation.getParent();
|
||||||
@@ -43,6 +47,8 @@ export default function SearchScreen() {
|
|||||||
const unsubscribe = parent.addListener('tabPress', () => {
|
const unsubscribe = parent.addListener('tabPress', () => {
|
||||||
setQuery('');
|
setQuery('');
|
||||||
setResults([]);
|
setResults([]);
|
||||||
|
setProducts([]);
|
||||||
|
setSearchMode('all');
|
||||||
setIsLoading(false);
|
setIsLoading(false);
|
||||||
setError(null);
|
setError(null);
|
||||||
});
|
});
|
||||||
@@ -52,6 +58,7 @@ export default function SearchScreen() {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (debouncedQuery.length < 2) {
|
if (debouncedQuery.length < 2) {
|
||||||
setResults([]);
|
setResults([]);
|
||||||
|
setProducts([]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +76,17 @@ export default function SearchScreen() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fetchProducts = async () => {
|
||||||
|
try {
|
||||||
|
const productResults = await searchProducts(debouncedQuery);
|
||||||
|
setProducts(productResults);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Product search error:', err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
fetchResults();
|
fetchResults();
|
||||||
|
fetchProducts();
|
||||||
}, [debouncedQuery]);
|
}, [debouncedQuery]);
|
||||||
|
|
||||||
const handleSearch = (searchQuery: string) => {
|
const handleSearch = (searchQuery: string) => {
|
||||||
@@ -77,7 +94,7 @@ export default function SearchScreen() {
|
|||||||
if (searchQuery.trim()) addSearch(searchQuery);
|
if (searchQuery.trim()) addSearch(searchQuery);
|
||||||
};
|
};
|
||||||
|
|
||||||
const showSuggestions = !query && !isLoading && results.length === 0;
|
const showSuggestions = !query && !isLoading && results.length === 0 && products.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={[styles.container, { backgroundColor: colors.background }]}>
|
<View style={[styles.container, { backgroundColor: colors.background }]}>
|
||||||
@@ -87,6 +104,20 @@ export default function SearchScreen() {
|
|||||||
onChangeText={setQuery}
|
onChangeText={setQuery}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{query.length >= 2 && (
|
||||||
|
<View style={styles.filterContainer}>
|
||||||
|
<TouchableOpacity style={[styles.filterTab, searchMode === 'all' && styles.filterTabActive]} onPress={() => setSearchMode('all')}>
|
||||||
|
<Text style={[styles.filterText, searchMode === 'all' && styles.filterTextActive]}>Todos</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={[styles.filterTab, searchMode === 'medicines' && styles.filterTabActive]} onPress={() => setSearchMode('medicines')}>
|
||||||
|
<Text style={[styles.filterText, searchMode === 'medicines' && styles.filterTextActive]}>Medicamentos</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
<TouchableOpacity style={[styles.filterTab, searchMode === 'products' && styles.filterTabActive]} onPress={() => setSearchMode('products')}>
|
||||||
|
<Text style={[styles.filterText, searchMode === 'products' && styles.filterTextActive]}>Parafarmacia</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
{showSuggestions && (
|
{showSuggestions && (
|
||||||
<>
|
<>
|
||||||
<View style={[styles.suggestionsSection, isTablet && styles.suggestionsSectionTablet]}>
|
<View style={[styles.suggestionsSection, isTablet && styles.suggestionsSectionTablet]}>
|
||||||
@@ -130,7 +161,7 @@ export default function SearchScreen() {
|
|||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{isLoading && <LoadingSpinner message="Buscando medicamentos..." />}
|
{isLoading && <LoadingSpinner message="Buscando..." />}
|
||||||
|
|
||||||
{error && (
|
{error && (
|
||||||
<View style={[styles.errorContainer, isTablet && styles.errorContainerTablet, { backgroundColor: colors.dangerContainer }]}>
|
<View style={[styles.errorContainer, isTablet && styles.errorContainerTablet, { backgroundColor: colors.dangerContainer }]}>
|
||||||
@@ -138,16 +169,43 @@ export default function SearchScreen() {
|
|||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!isLoading && !error && results.length === 0 && query.length >= 2 && (
|
{!isLoading && !error && results.length === 0 && products.length === 0 && query.length >= 2 && (
|
||||||
<View style={styles.emptyContainer}>
|
<View style={styles.emptyContainer}>
|
||||||
<Text style={[styles.emptyText, { color: colors.textSecondary }]}>No se encontraron medicamentos</Text>
|
<Text style={[styles.emptyText, { color: colors.textSecondary }]}>No se encontraron resultados</Text>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<FlatList
|
<FlatList
|
||||||
data={results}
|
data={(searchMode === 'medicines' || searchMode === 'all') ? results : []}
|
||||||
keyExtractor={(item) => item.nregistro}
|
keyExtractor={(item) => item.nregistro}
|
||||||
renderItem={({ item }) => <MedicineCard medicine={item} />}
|
renderItem={({ item }) => <MedicineCard medicine={item} />}
|
||||||
|
ListHeaderComponent={
|
||||||
|
<>
|
||||||
|
{(searchMode === 'all' || searchMode === 'products') && products.length > 0 && (
|
||||||
|
<View style={styles.section}>
|
||||||
|
<Text style={[styles.sectionTitle, { color: colors.text }]}>Parafarmacia y Bebé</Text>
|
||||||
|
{products.map((product) => (
|
||||||
|
<TouchableOpacity
|
||||||
|
key={`${product.source}-${product.id}`}
|
||||||
|
style={[styles.productCard, { backgroundColor: colors.card, borderColor: colors.border }]}
|
||||||
|
onPress={() => router.push(`/product/${product.source}/${product.id}`)}
|
||||||
|
activeOpacity={0.7}
|
||||||
|
>
|
||||||
|
<View style={styles.productInfo}>
|
||||||
|
<View style={styles.badges}>
|
||||||
|
<View style={[styles.sourceBadge, { backgroundColor: product.source === 'cima' ? '#2563eb' : '#16a34a' }]}>
|
||||||
|
<Text style={styles.badgeText}>{product.source === 'cima' ? 'CIMA' : 'OFF'}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
<Text style={[styles.productName, { color: colors.text }]} numberOfLines={1}>{product.name}</Text>
|
||||||
|
<Text style={[styles.productBrand, { color: colors.textSecondary }]} numberOfLines={1}>{product.brand}</Text>
|
||||||
|
</View>
|
||||||
|
</TouchableOpacity>
|
||||||
|
))}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
}
|
||||||
contentContainerStyle={[styles.list, isTablet && styles.listTablet]}
|
contentContainerStyle={[styles.list, isTablet && styles.listTablet]}
|
||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
/>
|
/>
|
||||||
@@ -159,6 +217,34 @@ const styles = StyleSheet.create({
|
|||||||
container: {
|
container: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
},
|
},
|
||||||
|
filterContainer: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'center',
|
||||||
|
gap: spacing.sm,
|
||||||
|
paddingVertical: spacing.sm,
|
||||||
|
paddingHorizontal: spacing.md,
|
||||||
|
},
|
||||||
|
filterTab: {
|
||||||
|
paddingHorizontal: spacing.md,
|
||||||
|
paddingVertical: spacing.sm,
|
||||||
|
borderRadius: borderRadius.full,
|
||||||
|
backgroundColor: 'rgba(0,0,0,0.05)',
|
||||||
|
},
|
||||||
|
filterTabActive: {
|
||||||
|
backgroundColor: '#7fbf8f',
|
||||||
|
},
|
||||||
|
filterText: {
|
||||||
|
fontSize: 14,
|
||||||
|
fontWeight: '600',
|
||||||
|
color: '#41493e',
|
||||||
|
},
|
||||||
|
filterTextActive: {
|
||||||
|
color: '#ffffff',
|
||||||
|
},
|
||||||
|
section: {
|
||||||
|
paddingHorizontal: spacing.lg,
|
||||||
|
marginTop: spacing.md,
|
||||||
|
},
|
||||||
suggestionsSection: {
|
suggestionsSection: {
|
||||||
marginTop: spacing.sm,
|
marginTop: spacing.sm,
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
@@ -245,4 +331,38 @@ const styles = StyleSheet.create({
|
|||||||
emptyText: {
|
emptyText: {
|
||||||
fontSize: 16,
|
fontSize: 16,
|
||||||
},
|
},
|
||||||
|
productCard: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
alignItems: 'center',
|
||||||
|
borderRadius: borderRadius.lg,
|
||||||
|
borderWidth: 1,
|
||||||
|
padding: spacing.md,
|
||||||
|
marginBottom: spacing.sm,
|
||||||
|
},
|
||||||
|
productInfo: {
|
||||||
|
flex: 1,
|
||||||
|
gap: 4,
|
||||||
|
},
|
||||||
|
badges: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
gap: spacing.sm,
|
||||||
|
marginBottom: 2,
|
||||||
|
},
|
||||||
|
sourceBadge: {
|
||||||
|
paddingHorizontal: spacing.sm,
|
||||||
|
paddingVertical: 2,
|
||||||
|
borderRadius: borderRadius.sm,
|
||||||
|
},
|
||||||
|
badgeText: {
|
||||||
|
color: '#ffffff',
|
||||||
|
fontSize: 11,
|
||||||
|
fontWeight: '700',
|
||||||
|
},
|
||||||
|
productName: {
|
||||||
|
fontSize: 15,
|
||||||
|
fontWeight: '600',
|
||||||
|
},
|
||||||
|
productBrand: {
|
||||||
|
fontSize: 13,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ import { SafeAreaProvider } from 'react-native-safe-area-context';
|
|||||||
import { useAuthStore } from '../store/authStore';
|
import { useAuthStore } from '../store/authStore';
|
||||||
import { registerForPushNotifications, addNotificationListener, addNotificationResponseListener } from '../services/notifications';
|
import { registerForPushNotifications, addNotificationListener, addNotificationResponseListener } from '../services/notifications';
|
||||||
import { ThemeProvider, useThemeContext } from '../components/ThemeProvider';
|
import { ThemeProvider, useThemeContext } from '../components/ThemeProvider';
|
||||||
|
import { initFaro } from '../services/faro';
|
||||||
|
|
||||||
|
// Boot Faro RUM once, as early as possible.
|
||||||
|
initFaro();
|
||||||
|
|
||||||
const queryClient = new QueryClient();
|
const queryClient = new QueryClient();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,249 @@
|
|||||||
|
import React, { useEffect, useState } from 'react';
|
||||||
|
import { View, Text, ScrollView, StyleSheet, Image, ActivityIndicator } from 'react-native';
|
||||||
|
import { useLocalSearchParams } from 'expo-router';
|
||||||
|
import { getProduct, Product } from '../../../services/products';
|
||||||
|
import { LoadingSpinner } from '../../../components/LoadingSpinner';
|
||||||
|
import { useThemeContext } from '../../../components/ThemeProvider';
|
||||||
|
import { spacing, borderRadius } from '../../../constants/theme';
|
||||||
|
|
||||||
|
export default function ProductDetailScreen() {
|
||||||
|
const { source, id } = useLocalSearchParams<{ source: string; id: string }>();
|
||||||
|
const { colors } = useThemeContext();
|
||||||
|
const [product, setProduct] = useState<Product | null>(null);
|
||||||
|
const [isLoading, setIsLoading] = useState(true);
|
||||||
|
const [error, setError] = useState(false);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!source || !id) return;
|
||||||
|
|
||||||
|
const fetchProduct = async () => {
|
||||||
|
try {
|
||||||
|
const data = await getProduct(source, id);
|
||||||
|
if (data) {
|
||||||
|
setProduct(data);
|
||||||
|
} else {
|
||||||
|
setError(true);
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
setError(true);
|
||||||
|
} finally {
|
||||||
|
setIsLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
fetchProduct();
|
||||||
|
}, [source, id]);
|
||||||
|
|
||||||
|
if (isLoading) {
|
||||||
|
return <LoadingSpinner message="Cargando producto..." />;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (error || !product) {
|
||||||
|
return (
|
||||||
|
<View style={[styles.errorContainer, { backgroundColor: colors.background }]}>
|
||||||
|
<Text style={[styles.errorText, { color: colors.textSecondary }]}>Producto no encontrado</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const isCima = product.source === 'cima';
|
||||||
|
|
||||||
|
return (
|
||||||
|
<ScrollView style={[styles.container, { backgroundColor: colors.background }]}>
|
||||||
|
{product.image_url ? (
|
||||||
|
<Image source={{ uri: product.image_url }} style={styles.image} resizeMode="contain" />
|
||||||
|
) : (
|
||||||
|
<View style={[styles.imagePlaceholder, { backgroundColor: colors.surfaceLow }]}>
|
||||||
|
<Text style={[styles.placeholderText, { color: colors.textSecondary }]}>Sin imagen</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<View style={[styles.header, { backgroundColor: colors.card }]}>
|
||||||
|
<View style={styles.nameRow}>
|
||||||
|
<Text style={[styles.name, { color: colors.text }]}>{product.name}</Text>
|
||||||
|
<View style={[styles.badge, { backgroundColor: isCima ? '#2b5bb5' : '#4caf50' }]}>
|
||||||
|
<Text style={styles.badgeText}>{isCima ? 'CIMA' : 'OFF'}</Text>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
{product.brand ? (
|
||||||
|
<Text style={[styles.brand, { color: colors.textSecondary }]}>{product.brand}</Text>
|
||||||
|
) : null}
|
||||||
|
{product.category ? (
|
||||||
|
<Text style={[styles.category, { color: colors.textSecondary }]}>{product.category}</Text>
|
||||||
|
) : null}
|
||||||
|
</View>
|
||||||
|
|
||||||
|
{isCima ? (
|
||||||
|
<View style={[styles.infoSection, { backgroundColor: colors.card }]}>
|
||||||
|
<Text style={[styles.sectionTitle, { color: colors.text }]}>Detalles CIMA</Text>
|
||||||
|
{product.active_ingredient && (
|
||||||
|
<InfoRow label="Principio activo" value={product.active_ingredient} colors={colors} />
|
||||||
|
)}
|
||||||
|
{product.dosage && (
|
||||||
|
<InfoRow label="Dosificación" value={product.dosage} colors={colors} />
|
||||||
|
)}
|
||||||
|
{product.form && (
|
||||||
|
<InfoRow label="Forma farmacéutica" value={product.form} colors={colors} />
|
||||||
|
)}
|
||||||
|
{product.prescription && (
|
||||||
|
<InfoRow label="Tipo de dispensación" value={product.prescription} colors={colors} />
|
||||||
|
)}
|
||||||
|
<InfoRow label="Comercializado" value={product.commercialized ? 'Sí' : 'No'} colors={colors} />
|
||||||
|
</View>
|
||||||
|
) : (
|
||||||
|
<View style={[styles.infoSection, { backgroundColor: colors.card }]}>
|
||||||
|
<Text style={[styles.sectionTitle, { color: colors.text }]}>Información nutricional</Text>
|
||||||
|
{product.nutriscore && (
|
||||||
|
<InfoRow label="Nutri-Score" value={product.nutriscore.toUpperCase()} colors={colors} />
|
||||||
|
)}
|
||||||
|
{product.nova_group != null && (
|
||||||
|
<InfoRow label="Grupo NOVA" value={String(product.nova_group)} colors={colors} />
|
||||||
|
)}
|
||||||
|
{product.eco_score && (
|
||||||
|
<InfoRow label="Eco-Score" value={product.eco_score.toUpperCase()} colors={colors} />
|
||||||
|
)}
|
||||||
|
{product.ingredients && (
|
||||||
|
<View style={[styles.infoRow, { borderBottomColor: colors.border }]}>
|
||||||
|
<Text style={[styles.infoLabel, { color: colors.textSecondary }]}>Ingredientes</Text>
|
||||||
|
<Text style={[styles.infoValueMultiline, { color: colors.text }]}>{product.ingredients}</Text>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isCima && product.photos && product.photos.length > 0 && (
|
||||||
|
<View style={[styles.infoSection, { backgroundColor: colors.card }]}>
|
||||||
|
<Text style={[styles.sectionTitle, { color: colors.text }]}>Imágenes</Text>
|
||||||
|
<ScrollView horizontal showsHorizontalScrollIndicator={false} style={styles.photosScroll}>
|
||||||
|
{product.photos.map((photo, i) => (
|
||||||
|
<View key={i} style={styles.photoItem}>
|
||||||
|
<Image source={{ uri: photo.url }} style={styles.photoImage} resizeMode="contain" />
|
||||||
|
<Text style={[styles.photoLabel, { color: colors.textSecondary }]}>{photo.tipo}</Text>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</ScrollView>
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
</ScrollView>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function InfoRow({ label, value, colors }: { label: string; value: string; colors: any }) {
|
||||||
|
return (
|
||||||
|
<View style={[styles.infoRow, { borderBottomColor: colors.border }]}>
|
||||||
|
<Text style={[styles.infoLabel, { color: colors.textSecondary }]}>{label}</Text>
|
||||||
|
<Text style={[styles.infoValue, { color: colors.text }]}>{value}</Text>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
image: {
|
||||||
|
width: '100%',
|
||||||
|
height: 260,
|
||||||
|
backgroundColor: '#f5f5f5',
|
||||||
|
},
|
||||||
|
imagePlaceholder: {
|
||||||
|
width: '100%',
|
||||||
|
height: 160,
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
|
},
|
||||||
|
placeholderText: {
|
||||||
|
fontSize: 14,
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
padding: spacing.lg,
|
||||||
|
},
|
||||||
|
nameRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
gap: spacing.sm,
|
||||||
|
},
|
||||||
|
name: {
|
||||||
|
flex: 1,
|
||||||
|
fontSize: 22,
|
||||||
|
fontWeight: 'bold',
|
||||||
|
},
|
||||||
|
badge: {
|
||||||
|
paddingHorizontal: spacing.sm,
|
||||||
|
paddingVertical: spacing.xs,
|
||||||
|
borderRadius: borderRadius.full,
|
||||||
|
overflow: 'hidden',
|
||||||
|
},
|
||||||
|
badgeText: {
|
||||||
|
color: '#fff',
|
||||||
|
fontSize: 12,
|
||||||
|
fontWeight: '700',
|
||||||
|
},
|
||||||
|
brand: {
|
||||||
|
fontSize: 15,
|
||||||
|
marginTop: spacing.xs,
|
||||||
|
},
|
||||||
|
category: {
|
||||||
|
fontSize: 13,
|
||||||
|
marginTop: spacing.xs,
|
||||||
|
},
|
||||||
|
infoSection: {
|
||||||
|
marginTop: spacing.sm,
|
||||||
|
padding: spacing.lg,
|
||||||
|
},
|
||||||
|
sectionTitle: {
|
||||||
|
fontSize: 16,
|
||||||
|
fontWeight: '600',
|
||||||
|
marginBottom: spacing.sm,
|
||||||
|
},
|
||||||
|
infoRow: {
|
||||||
|
flexDirection: 'row',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
paddingVertical: spacing.sm,
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
},
|
||||||
|
infoLabel: {
|
||||||
|
fontSize: 13,
|
||||||
|
flexShrink: 0,
|
||||||
|
marginRight: spacing.sm,
|
||||||
|
},
|
||||||
|
infoValue: {
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: '500',
|
||||||
|
flex: 1,
|
||||||
|
textAlign: 'right',
|
||||||
|
},
|
||||||
|
infoValueMultiline: {
|
||||||
|
fontSize: 13,
|
||||||
|
fontWeight: '500',
|
||||||
|
flex: 1,
|
||||||
|
textAlign: 'right',
|
||||||
|
},
|
||||||
|
photosScroll: {
|
||||||
|
marginTop: spacing.xs,
|
||||||
|
},
|
||||||
|
photoItem: {
|
||||||
|
marginRight: spacing.md,
|
||||||
|
alignItems: 'center',
|
||||||
|
width: 120,
|
||||||
|
},
|
||||||
|
photoImage: {
|
||||||
|
width: 120,
|
||||||
|
height: 120,
|
||||||
|
borderRadius: borderRadius.md,
|
||||||
|
backgroundColor: '#f5f5f5',
|
||||||
|
},
|
||||||
|
photoLabel: {
|
||||||
|
fontSize: 11,
|
||||||
|
marginTop: spacing.xs,
|
||||||
|
},
|
||||||
|
errorContainer: {
|
||||||
|
flex: 1,
|
||||||
|
justifyContent: 'center',
|
||||||
|
alignItems: 'center',
|
||||||
|
},
|
||||||
|
errorText: {
|
||||||
|
fontSize: 16,
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
"expo-constants": "~57.0.3",
|
"expo-constants": "~57.0.3",
|
||||||
"expo-dev-client": "~57.0.5",
|
"expo-dev-client": "~57.0.5",
|
||||||
"expo-device": "~7.0.2",
|
"expo-device": "~7.0.2",
|
||||||
|
"@grafana/faro-react-native": "^1.2.1",
|
||||||
"expo-image-picker": "~57.0.2",
|
"expo-image-picker": "~57.0.2",
|
||||||
"expo-linking": "~57.0.1",
|
"expo-linking": "~57.0.1",
|
||||||
"expo-local-authentication": "~57.0.0",
|
"expo-local-authentication": "~57.0.0",
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
import { initializeFaro } from '@grafana/faro-react-native';
|
||||||
|
|
||||||
|
let initialized = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes Grafana Faro RUM for the React Native app.
|
||||||
|
*
|
||||||
|
* Telemetry (crashes, JS errors, console, app-start, memory/ANR vitals,
|
||||||
|
* session + screen tracking) is sent OTLP/HTTP to the Alloy collector.
|
||||||
|
*
|
||||||
|
* NOTE: `@grafana/faro-react-native` ships a native module, so it requires a
|
||||||
|
* custom dev build / EAS build (not Expo Go). Initialization is wrapped in a
|
||||||
|
* try/catch so a collector outage never crashes the app.
|
||||||
|
*/
|
||||||
|
export function initFaro(): void {
|
||||||
|
if (initialized) return;
|
||||||
|
initialized = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const url =
|
||||||
|
process.env.EXPO_PUBLIC_FARO_URL || 'http://grafana.hacecalor.net:4318';
|
||||||
|
|
||||||
|
initializeFaro({
|
||||||
|
app: {
|
||||||
|
name: 'farmafinder-mobile',
|
||||||
|
version: '1.0.0',
|
||||||
|
environment: __DEV__ ? 'development' : 'production',
|
||||||
|
},
|
||||||
|
url,
|
||||||
|
sessionTracking: { enabled: true },
|
||||||
|
// Crash/JS error/console capture are on by default.
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[faro] initialization failed:', err);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
import api from './api';
|
||||||
|
|
||||||
|
export interface Product {
|
||||||
|
id: string;
|
||||||
|
source: 'cima' | 'openfoodfacts';
|
||||||
|
name: string;
|
||||||
|
brand: string;
|
||||||
|
category: string;
|
||||||
|
image_url: string | null;
|
||||||
|
active_ingredient?: string;
|
||||||
|
dosage?: string;
|
||||||
|
form?: string;
|
||||||
|
prescription?: string;
|
||||||
|
commercialized?: boolean;
|
||||||
|
photos?: { tipo: string; url: string }[];
|
||||||
|
docs?: { tipo: number; url: string }[];
|
||||||
|
nutriscore?: string;
|
||||||
|
ingredients?: string;
|
||||||
|
nova_group?: number;
|
||||||
|
eco_score?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProductSearchResponse {
|
||||||
|
results: Product[];
|
||||||
|
total: number;
|
||||||
|
sources: {
|
||||||
|
cima: number;
|
||||||
|
openfoodfacts: number;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function searchProducts(query: string): Promise<Product[]> {
|
||||||
|
if (!query || query.trim().length < 2) return [];
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<ProductSearchResponse>('/products/search', {
|
||||||
|
params: { q: query }
|
||||||
|
});
|
||||||
|
return data.results || [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[Products] Search error:', error);
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getProduct(source: string, id: string): Promise<Product | null> {
|
||||||
|
try {
|
||||||
|
const { data } = await api.get<Product>(`/products/${source}/${id}`);
|
||||||
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[Products] Detail error:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
.product-results {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
|
||||||
|
gap: 1rem;
|
||||||
|
margin-top: 0.5rem;
|
||||||
|
max-height: 70vh;
|
||||||
|
overflow-y: auto;
|
||||||
|
overflow-x: hidden;
|
||||||
|
overscroll-behavior: contain;
|
||||||
|
animation: fadeInUp 0.5s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1024px) {
|
||||||
|
.product-results {
|
||||||
|
max-height: 76vh;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card {
|
||||||
|
background: var(--surface-container-lowest);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
padding: 1.25rem;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: transform 0.15s, box-shadow 0.15s;
|
||||||
|
border: 1px solid var(--outline-variant);
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-between;
|
||||||
|
box-shadow: var(--shadow-soft);
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
|
||||||
|
border-color: var(--primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-image {
|
||||||
|
width: 100%;
|
||||||
|
height: 120px;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
background: var(--surface-container-low);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-image img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-image-placeholder {
|
||||||
|
color: var(--outline-variant);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-content {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-badges {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
|
margin-bottom: 0.75rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.source-badge {
|
||||||
|
color: white;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
text-transform: uppercase;
|
||||||
|
letter-spacing: 0.02em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.category-badge {
|
||||||
|
background: var(--surface-container-high);
|
||||||
|
color: var(--on-surface-variant);
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.nutri-score-badge {
|
||||||
|
color: white;
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
|
border-radius: var(--radius-sm);
|
||||||
|
font-size: 0.7rem;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-header {
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-header h3 {
|
||||||
|
color: var(--on-surface);
|
||||||
|
font-size: 1.15rem;
|
||||||
|
font-weight: 700;
|
||||||
|
letter-spacing: -0.01em;
|
||||||
|
flex: 1;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-body {
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-body p {
|
||||||
|
font-size: 0.9rem;
|
||||||
|
color: var(--on-surface-variant);
|
||||||
|
line-height: 1.55;
|
||||||
|
margin-bottom: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-body strong {
|
||||||
|
color: var(--on-surface);
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card-footer {
|
||||||
|
padding-top: 0.75rem;
|
||||||
|
border-top: 1px solid var(--outline-variant);
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-details {
|
||||||
|
color: var(--primary);
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 0.9rem;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.view-details::after {
|
||||||
|
content: "→";
|
||||||
|
transition: transform 0.2s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.product-card:hover .view-details::after {
|
||||||
|
transform: translateX(4px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.no-results {
|
||||||
|
text-align: center;
|
||||||
|
padding: 2.5rem 1.5rem;
|
||||||
|
background: var(--surface-container-low);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
color: var(--on-surface-variant);
|
||||||
|
border: 1px dashed var(--outline-variant);
|
||||||
|
}
|
||||||
@@ -0,0 +1,114 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import './ProductResults.css';
|
||||||
|
|
||||||
|
const categoryLabels = {
|
||||||
|
otc: 'Sin Receta',
|
||||||
|
baby_food: 'Alimentación Infantil',
|
||||||
|
baby_milk: 'Leche de Fórmula',
|
||||||
|
baby_cereal: 'Cereales Bebé'
|
||||||
|
};
|
||||||
|
|
||||||
|
const sourceColors = {
|
||||||
|
cima: '#2563eb',
|
||||||
|
openfoodfacts: '#16a34a'
|
||||||
|
};
|
||||||
|
|
||||||
|
const sourceLabels = {
|
||||||
|
cima: 'CIMA',
|
||||||
|
openfoodfacts: 'Open Food Facts'
|
||||||
|
};
|
||||||
|
|
||||||
|
function ProductResults({ products, onSelect }) {
|
||||||
|
if (!products || products.length === 0) {
|
||||||
|
return (
|
||||||
|
<div className="no-results">
|
||||||
|
<p>No se encontraron productos</p>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="product-results">
|
||||||
|
{products.map((product) => (
|
||||||
|
<ProductCard
|
||||||
|
key={product.id}
|
||||||
|
product={product}
|
||||||
|
onSelect={onSelect}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function ProductCard({ product, onSelect }) {
|
||||||
|
const nutriScore = product.nutriscore;
|
||||||
|
const nutriScoreColors = {
|
||||||
|
a: '#16a34a',
|
||||||
|
b: '#65a30d',
|
||||||
|
c: '#eab308',
|
||||||
|
d: '#f97316',
|
||||||
|
e: '#dc2626'
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="product-card" onClick={() => onSelect(product)}>
|
||||||
|
<div className="product-card-image">
|
||||||
|
{product.image_url ? (
|
||||||
|
<img src={product.image_url} alt={product.name} loading="lazy" />
|
||||||
|
) : (
|
||||||
|
<div className="product-image-placeholder">
|
||||||
|
<svg width="48" height="48" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="1.5" strokeLinecap="round" strokeLinejoin="round">
|
||||||
|
<rect x="3" y="3" width="18" height="18" rx="2" ry="2" />
|
||||||
|
<circle cx="8.5" cy="8.5" r="1.5" />
|
||||||
|
<polyline points="21 15 16 10 5 21" />
|
||||||
|
</svg>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="product-card-content">
|
||||||
|
<div className="product-card-badges">
|
||||||
|
<span
|
||||||
|
className="source-badge"
|
||||||
|
style={{ backgroundColor: sourceColors[product.source] }}
|
||||||
|
>
|
||||||
|
{sourceLabels[product.source]}
|
||||||
|
</span>
|
||||||
|
<span className="category-badge">
|
||||||
|
{categoryLabels[product.category] || product.category}
|
||||||
|
</span>
|
||||||
|
{product.source === 'openfoodfacts' && nutriScore && (
|
||||||
|
<span
|
||||||
|
className="nutri-score-badge"
|
||||||
|
style={{ backgroundColor: nutriScoreColors[nutriScore.toLowerCase()] || '#9ca3af' }}
|
||||||
|
>
|
||||||
|
Nutri-Score {nutriScore.toUpperCase()}
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="product-card-header">
|
||||||
|
<h3>{product.name}</h3>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="product-card-body">
|
||||||
|
{product.brand && (
|
||||||
|
<p><strong>Marca:</strong> {product.brand}</p>
|
||||||
|
)}
|
||||||
|
{product.source === 'cima' && product.active_ingredient && (
|
||||||
|
<p><strong>Principio Activo:</strong> {product.active_ingredient}</p>
|
||||||
|
)}
|
||||||
|
{product.source === 'cima' && product.dosage && (
|
||||||
|
<p><strong>Dosis:</strong> {product.dosage}</p>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div className="product-card-footer">
|
||||||
|
<span className="view-details">Ver detalles →</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default ProductResults;
|
||||||
@@ -2,6 +2,7 @@ import React, { useState, useEffect, useMemo } from 'react';
|
|||||||
import '../App.css';
|
import '../App.css';
|
||||||
import SearchBar from '../components/SearchBar';
|
import SearchBar from '../components/SearchBar';
|
||||||
import MedicineResults from '../components/MedicineResults';
|
import MedicineResults from '../components/MedicineResults';
|
||||||
|
import ProductResults from '../components/ProductResults';
|
||||||
import PharmacyList from '../components/PharmacyList';
|
import PharmacyList from '../components/PharmacyList';
|
||||||
import PharmacyMap from '../components/PharmacyMap';
|
import PharmacyMap from '../components/PharmacyMap';
|
||||||
import HomeView from './HomeView';
|
import HomeView from './HomeView';
|
||||||
@@ -22,6 +23,8 @@ function PublicView({
|
|||||||
|
|
||||||
const [searchQuery, setSearchQuery] = useState('');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [medicines, setMedicines] = useState([]);
|
const [medicines, setMedicines] = useState([]);
|
||||||
|
const [products, setProducts] = useState([]);
|
||||||
|
const [searchMode, setSearchMode] = useState('all'); // 'all' | 'medicines' | 'products'
|
||||||
const [selectedMedicine, setSelectedMedicine] = useState(null);
|
const [selectedMedicine, setSelectedMedicine] = useState(null);
|
||||||
const [pharmacies, setPharmacies] = useState([]);
|
const [pharmacies, setPharmacies] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
@@ -35,6 +38,7 @@ function PublicView({
|
|||||||
const searchMedicines = async () => {
|
const searchMedicines = async () => {
|
||||||
if (searchQuery.trim().length < 2) {
|
if (searchQuery.trim().length < 2) {
|
||||||
setMedicines([]);
|
setMedicines([]);
|
||||||
|
setProducts([]);
|
||||||
setSelectedMedicine(null);
|
setSelectedMedicine(null);
|
||||||
setPharmacies([]);
|
setPharmacies([]);
|
||||||
return;
|
return;
|
||||||
@@ -50,6 +54,16 @@ function PublicView({
|
|||||||
} finally {
|
} finally {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const productsResponse = await fetch(`/api/products/search?q=${encodeURIComponent(searchQuery)}`);
|
||||||
|
if (productsResponse.ok) {
|
||||||
|
const productsData = await productsResponse.json();
|
||||||
|
setProducts(productsData.results || []);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Product search error:', err);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const timeoutId = setTimeout(searchMedicines, 300);
|
const timeoutId = setTimeout(searchMedicines, 300);
|
||||||
@@ -219,7 +233,42 @@ function PublicView({
|
|||||||
|
|
||||||
{loading && <div className="loading">Buscando...</div>}
|
{loading && <div className="loading">Buscando...</div>}
|
||||||
|
|
||||||
{searchQuery && !selectedMedicine && (
|
{searchQuery && (
|
||||||
|
<div className="flex gap-2 mb-4">
|
||||||
|
<button
|
||||||
|
onClick={() => setSearchMode('all')}
|
||||||
|
className={`px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${
|
||||||
|
searchMode === 'all'
|
||||||
|
? 'bg-blue-600 text-white'
|
||||||
|
: 'bg-gray-100 text-gray-600 hover:bg-gray-200'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
Todos
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setSearchMode('medicines')}
|
||||||
|
className={`px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${
|
||||||
|
searchMode === 'medicines'
|
||||||
|
? 'bg-blue-600 text-white'
|
||||||
|
: 'bg-gray-100 text-gray-600 hover:bg-gray-200'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
Medicamentos
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
onClick={() => setSearchMode('products')}
|
||||||
|
className={`px-3 py-1.5 rounded-full text-sm font-medium transition-colors ${
|
||||||
|
searchMode === 'products'
|
||||||
|
? 'bg-blue-600 text-white'
|
||||||
|
: 'bg-gray-100 text-gray-600 hover:bg-gray-200'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
Parafarmacia
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{searchQuery && !selectedMedicine && (searchMode === 'all' || searchMode === 'medicines') && (
|
||||||
<MedicineResults
|
<MedicineResults
|
||||||
medicines={medicines}
|
medicines={medicines}
|
||||||
onSelect={setSelectedMedicine}
|
onSelect={setSelectedMedicine}
|
||||||
@@ -229,6 +278,18 @@ function PublicView({
|
|||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{(searchMode === 'all' || searchMode === 'products') && products.length > 0 && (
|
||||||
|
<div className="mt-6">
|
||||||
|
<h3 className="text-lg font-semibold mb-3">Parafarmacia y Bebé</h3>
|
||||||
|
<ProductResults
|
||||||
|
products={products}
|
||||||
|
onSelect={(product) => {
|
||||||
|
window.location.href = `/product/${product.source}/${product.id}`;
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{selectedMedicine && (
|
{selectedMedicine && (
|
||||||
<div className="selected-medicine-section">
|
<div className="selected-medicine-section">
|
||||||
<div className="medicine-info">
|
<div className="medicine-info">
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ services:
|
|||||||
OTEL_SERVICE_NAME: farmafinder-backend
|
OTEL_SERVICE_NAME: farmafinder-backend
|
||||||
OTEL_EXPORTER_OTLP_ENDPOINT: http://host.docker.internal:4317
|
OTEL_EXPORTER_OTLP_ENDPOINT: http://host.docker.internal:4317
|
||||||
OTEL_TRACES_EXPORTER: otlp
|
OTEL_TRACES_EXPORTER: otlp
|
||||||
|
OTEL_METRICS_EXPORTER: otlp
|
||||||
OTEL_LOGS_EXPORTER: otlp
|
OTEL_LOGS_EXPORTER: otlp
|
||||||
OTEL_RESOURCE_ATTRIBUTES: service.namespace=farmafinder
|
OTEL_RESOURCE_ATTRIBUTES: service.namespace=farmafinder
|
||||||
volumes:
|
volumes:
|
||||||
@@ -61,6 +62,28 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
|
|
||||||
|
# --- Observability exporters (scraped by the shared Prometheus on srv84-macos) ---
|
||||||
|
redis-exporter:
|
||||||
|
image: oliver006/redis_exporter:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "9121:9121"
|
||||||
|
environment:
|
||||||
|
REDIS_ADDR: redis://redis:6379
|
||||||
|
REDIS_PASSWORD: ${REDIS_PASSWORD:-}
|
||||||
|
depends_on:
|
||||||
|
- redis
|
||||||
|
|
||||||
|
postgres-exporter:
|
||||||
|
image: prometheuscommunity/postgres-exporter:latest
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "9187:9187"
|
||||||
|
environment:
|
||||||
|
DATA_SOURCE_NAME: postgresql://farmafinder:${PG_PASSWORD:-change-me-in-production}@postgres:5432/farmafinder?sslmode=disable
|
||||||
|
depends_on:
|
||||||
|
- postgres
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
backend_data:
|
backend_data:
|
||||||
postgres_data:
|
postgres_data:
|
||||||
|
|||||||
@@ -0,0 +1,208 @@
|
|||||||
|
# FarmaFinder — End-to-End Observability Plan & Progress
|
||||||
|
|
||||||
|
> **Purpose:** Single source of truth for adding metrics + monitoring across the
|
||||||
|
> FarmaFinder stack. If the session runs out of tokens, a fresh session can read
|
||||||
|
> this file and continue from the **Status** section.
|
||||||
|
>
|
||||||
|
> Created: 2026-07-13
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Current State (verified)
|
||||||
|
|
||||||
|
### 1.1 Monitoring stack — `srv84-macos:/root/Monitoring` (Docker Compose)
|
||||||
|
Running services (verified live):
|
||||||
|
|
||||||
|
| Service | Port | Role |
|
||||||
|
|---|---|---|
|
||||||
|
| Prometheus `v2.55.1` | 9090 | metrics + alerting (config `/etc/prometheus/`) |
|
||||||
|
| Grafana `grafana/grafana` | 3000 | dashboards (admin `foobar`) |
|
||||||
|
| Alertmanager `v0.27.0` | 9093 | **Telegram** notifications (already configured) |
|
||||||
|
| Loki `latest` | 3100 | logs (`/otlp` receiver enabled) |
|
||||||
|
| Tempo `latest` | 3200 | traces |
|
||||||
|
| cAdvisor | 8080 | container metrics |
|
||||||
|
| node-exporter | 9100 | host metrics (srv84-macos + srv102-hosting + srv104-omv) |
|
||||||
|
| **Alloy `v1.6.1`** | 4317 gRPC / 4318 HTTP / 12345 self | unified OTel collector |
|
||||||
|
|
||||||
|
**Alloy pipeline (`alloy-config.alloy`):**
|
||||||
|
`otelcol.receiver.otlp` (gRPC+HTTP) → `batch` →
|
||||||
|
- traces → `otelp.tempo` (Tempo:4317)
|
||||||
|
- logs → `otlphttp.loki` (Loki:3100/otlp)
|
||||||
|
- metrics → `exporter.prometheus` → `prometheus.remote_write` → `http://prometheus:9090/api/v1/write`
|
||||||
|
|
||||||
|
So **any OTLP metrics sent to Alloy land in Prometheus automatically** — no new scrape job needed for app services.
|
||||||
|
|
||||||
|
### 1.2 Grafana datasources (provisioned, sufficient)
|
||||||
|
Prometheus (default), Tempo, Loki, PostgreSQL, Alertmanager.
|
||||||
|
|
||||||
|
### 1.3 Grafana plugins (installed, sufficient)
|
||||||
|
Built-in panels + **Drilldown apps**: `grafana-lokiexplore-app`, `grafana-metricsdrilldown-app`, `grafana-exploretraces-app`, `grafana-pyroscope-app`.
|
||||||
|
**No extra plugins required.**
|
||||||
|
|
||||||
|
### 1.4 Existing app instrumentation
|
||||||
|
| App | Traces | Metrics | Logs | Health | Notes |
|
||||||
|
|---|---|---|---|---|---|
|
||||||
|
| backend (Express) | ✅ OTel→Alloy | ❌ **none** | ✅ pino→Alloy | ❌ none | `src/tracing.js` boots NodeSDK; only traces+logs exported |
|
||||||
|
| frontend (React/Vite PWA) | ✅ Faro→Alloy:4318 | ❌ | ✅ Faro→Loki | — | `src/utils/faro.js`; dashboards `faro-overview/-web-vitals/-js-errors` exist |
|
||||||
|
| frontend-mobile (Expo RN) | ❌ | ❌ | console only | — | **no observability at all** |
|
||||||
|
| pip-platform (FastAPI) | ✅ OTel | ✅ `/metrics` (prometheus_client) | ✅ structlog | ✅ /system/health,/ready,/status | **not scraped by Prometheus yet** |
|
||||||
|
| scraper (Puppeteer) | ✅ OTel | ❌ | console | — | |
|
||||||
|
|
||||||
|
### 1.5 Prometheus scrape jobs (today)
|
||||||
|
`prometheus`, `cadvisor`, `node-exporter` (x3 hosts). **No farmafinder/pip/redis/postgres jobs.**
|
||||||
|
Comment in `prometheus.yml`: app metrics are expected via OTLP→Alloy→remote_write.
|
||||||
|
|
||||||
|
### 1.6 Existing Prometheus alerts (`alert.rules`)
|
||||||
|
`service_down`, `high_load`, `high_memory`, `disk_almost_full`, `pm2_process_down`, `container_down`. All infra-level.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Decisions (confirmed with user)
|
||||||
|
|
||||||
|
- **Metrics transport = OTLP** for backend + mobile (aligns with stack design; no new app scrape jobs). Infra exporters (Redis/Postgres/pip) stay as scrape jobs.
|
||||||
|
- **Mobile Faro endpoint:** env-configurable `EXPO_PUBLIC_FARO_URL`, default
|
||||||
|
`http://grafana.hacecalor.net:4318`. User will **open router port 4318 → srv84-macos:4318**
|
||||||
|
(and/or fix Nginx Proxy Manager `/faro` proxy to Alloy:4318). Devices are NOT on the docker
|
||||||
|
host, so `localhost` will NOT work.
|
||||||
|
- **Alertmanager:** Telegram already configured — **no contact-point change**. New rules just route to it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Design / Tasks
|
||||||
|
|
||||||
|
### Task A — Backend metrics (OTel → Alloy → Prometheus)
|
||||||
|
**Files:** `apps/backend/src/tracing.js`, `apps/backend/src/metrics.js` (new), `apps/backend/package.json`, `docker-compose.yml`.
|
||||||
|
|
||||||
|
1. Add metrics SDK to `tracing.js`:
|
||||||
|
- `MeterProvider` + `OTLPMetricExporter` + `PeriodicExportingMetricReader` (interval 15s).
|
||||||
|
- Reuse existing `resource` + `getNodeAutoInstrumentations` (already includes http/express/redis → gives `http.server.request.duration`, `http.client.request.duration`, `redis.client.commands.duration`, etc.).
|
||||||
|
- Keep `PinoInstrumentation`. Gate on `NODE_ENV !== 'test'`.
|
||||||
|
2. New `src/metrics.js` using `@opentelemetry/api` `metrics`:
|
||||||
|
- `medicine_searches_total` (counter)
|
||||||
|
- `cima_request_duration_ms` (histogram), `cima_errors_total` (counter)
|
||||||
|
- `cache_hits_total` / `cache_misses_total` (counters)
|
||||||
|
- `login_success_total` / `login_failure_total` (counters)
|
||||||
|
- `rate_limit_rejected_total` (counter, label `route`)
|
||||||
|
- `pharmacy_write_total` (counter, label `op`)
|
||||||
|
- `pharmacy_medicine_link_total` (counter)
|
||||||
|
- `push_sent_total` / `push_failed_total` (counters, label `channel=expo|web`)
|
||||||
|
- `db_query_duration_ms` (histogram), `db_errors_total` (counter, label `engine=sqlite|pg`)
|
||||||
|
- `redis_errors_total` (counter), `redis_cmd_duration_ms` (histogram)
|
||||||
|
- `heartbeat_total` (counter, incremented every 30s) → drives "backend down" alert
|
||||||
|
- Node runtime metrics via `views`/runtime instrumentation (event loop lag, heap, gc).
|
||||||
|
3. Instrument the relevant handlers in `server.js` (search, auth, admin, notifications, db, redis) by importing the meters.
|
||||||
|
4. `docker-compose.yml`: add `OTEL_METRICS_EXPORTER: otlp` under backend env (alongside existing traces/logs exporters).
|
||||||
|
5. `package.json`: ensure `@opentelemetry/sdk-metrics` + `@opentelemetry/exporter-metrics-otlp-grpc` are present (add if missing; align versions with existing `^0.55.0`).
|
||||||
|
|
||||||
|
### Task B — Backend health endpoints
|
||||||
|
**File:** `apps/backend/server.js`.
|
||||||
|
- `GET /healthz` → `{status:"ok"}` (liveness).
|
||||||
|
- `GET /readyz` → ping Redis + run a trivial DB query; return 200/503 JSON.
|
||||||
|
- Used by Docker healthcheck / k8s; not scraped.
|
||||||
|
|
||||||
|
### Task C — Mobile RUM (Expo / React Native)
|
||||||
|
**Files:** `apps/frontend-mobile/package.json`, `apps/frontend-mobile/app/_layout.tsx` (root), `.env.example`.
|
||||||
|
- Add dependency `@grafana/faro-react-native` (`^1.2.1`).
|
||||||
|
- Init in `_layout.tsx` (or `App.tsx`) entry:
|
||||||
|
```ts
|
||||||
|
import { initializeFaro } from '@grafana/faro-react-native';
|
||||||
|
initializeFaro({
|
||||||
|
app: { name: 'farmafinder-mobile', version: '1.0.0', environment: 'production' },
|
||||||
|
url: process.env.EXPO_PUBLIC_FARO_URL || 'http://grafana.hacecalor.net:4318',
|
||||||
|
sessionTracking: { enabled: true },
|
||||||
|
// captures crashes, JS errors, console, ANR(Android), app-start, memory vitals
|
||||||
|
});
|
||||||
|
```
|
||||||
|
- `EXPO_PUBLIC_FARO_URL` in `.env.example` (default the public URL above).
|
||||||
|
- Optional follow-up: `@grafana/faro-react-native-tracing` for distributed traces + `@grafana/faro-metro-plugin` for source maps (post-MVP).
|
||||||
|
|
||||||
|
### Task D — Infra exporters (scrape jobs on `srv84-macos`)
|
||||||
|
**Files (remote):** `/root/Monitoring/docker-compose.yml`, `/root/Monitoring/prometheus/prometheus.yml`.
|
||||||
|
- Add containers `redis-exporter` (→ farmafinder redis) and `postgres-exporter` (→ farmafinder postgres) to the Monitoring compose. Reach farmafinder's redis/postgres via the docker gateway / service DNS on the same host.
|
||||||
|
- Add scrape jobs in `prometheus.yml`:
|
||||||
|
- `farmafinder-redis` → redis-exporter
|
||||||
|
- `farmafinder-postgres` → postgres-exporter
|
||||||
|
- `pip-platform` → `http://<pip-host>:8000/metrics` (pip already exposes it)
|
||||||
|
- Reload Prometheus (`POST /-/reload`).
|
||||||
|
|
||||||
|
### Task E — Grafana dashboards (provisioned JSON)
|
||||||
|
**Files:** `/root/Monitoring/grafana/provisioning/dashboards/*.json` + `dashboard.yml` entry.
|
||||||
|
1. `farmafinder-backend.json` — req rate, error %, latency p50/p95/p99 by route, CIMA latency/errors, cache hit rate, Redis/DB errors, push counts, auth failures, rate-limit hits, Node runtime.
|
||||||
|
2. `farmafinder-datastores.json` — Redis + Postgres + (SQLite via app metric) panels.
|
||||||
|
3. `farmafinder-mobile-rum.json` — Faro RN data from Loki (`app.name="farmafinder-mobile"`).
|
||||||
|
4. `farmafinder-overview.json` — combined RUM + backend metrics + deep-links to Tempo (traces) & Loki (logs).
|
||||||
|
(Keep existing `faro-*` PWA dashboards.)
|
||||||
|
|
||||||
|
### Task F — Alerts
|
||||||
|
**Files (remote):** `/root/Monitoring/prometheus/alert.rules` + Grafana-managed alert.
|
||||||
|
Prometheus rules (group `farmafinder`):
|
||||||
|
- `farmafinder_backend_down` — `absent(heartbeat_total{job="farmafinder-backend"}) > 0` for 5m → critical
|
||||||
|
- `farmafinder_backend_5xx` — `rate(http.server.request.errors ...)` ratio > 5% over 5m → warning
|
||||||
|
- `farmafinder_cima_errors` — CIMA error rate high → warning
|
||||||
|
- `farmafinder_high_latency` — p95 `http.server.request.duration` > threshold → warning
|
||||||
|
- `farmafinder_redis_down` / `farmafinder_postgres_down` / `pip_platform_down` — `up==0`
|
||||||
|
Grafana-managed alert (Loki): **mobile/PWA JS-error spike** — count of Faro exceptions over 10m > N.
|
||||||
|
All route to existing Alertmanager (Telegram).
|
||||||
|
|
||||||
|
### Task G — Mobile Faro reachability (user action)
|
||||||
|
- Open router `TCP 4318 → srv84-macos:4318`, **or** fix Nginx Proxy Manager `grafana.hacecalor.net/faro` → `http://<alloy-host>:4318` ensuring OTLP HTTP paths (`/v1/logs`,`/v1/metrics`,`/v1/traces`) are proxied. Verify from a phone / external curl that `POST http://grafana.hacecalor.net:4318/v1/logs` is accepted.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Status (update as you go)
|
||||||
|
|
||||||
|
| Task | Status | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| A. Backend metrics | ✅ done (code) | `src/metrics.js`, `tracing.js` meter provider, instrumented server.js/cima-service.js/redis-client.js. Needs backend rebuild+redeploy to take effect. |
|
||||||
|
| B. Backend health | ✅ done (code) | `/healthz`, `/readyz` added. |
|
||||||
|
| C. Mobile Faro | ✅ done (code) | `services/faro.ts` + `_layout.tsx` init + dep `@grafana/faro-react-native`. Requires dev/EAS build (native module). |
|
||||||
|
| D. Infra exporters | ✅ done | redis/postgres exporters added to farmafinder `docker-compose.yml`; Prometheus scrape jobs + alert rules applied on srv84-macos. Needs farmafinder redeploy. |
|
||||||
|
| E. Dashboards | ✅ done + LIVE | 4 dashboards pushed to `/root/Monitoring/grafana/provisioning/dashboards/` and provisioned in Grafana. |
|
||||||
|
| F. Alerts | ✅ done + LIVE | `farmafinder` group applied to `alert.rules`; routes to existing Alertmanager (Telegram). |
|
||||||
|
| G. Mobile Faro URL | ⏳ user action | open :4318 → srv84-macos:4318, or fix Nginx Proxy Manager `/faro`. |
|
||||||
|
|
||||||
|
## 5. Deployment & Verification
|
||||||
|
|
||||||
|
### Backend (apply on next deploy)
|
||||||
|
The running `farmafinder-backend-1` still runs old code. To activate metrics:
|
||||||
|
```bash
|
||||||
|
# from repo root on srv84-macos (or wherever farmafinder is deployed)
|
||||||
|
docker compose build backend && docker compose up -d backend
|
||||||
|
# or push to main and let .gitea deploy
|
||||||
|
```
|
||||||
|
Verify:
|
||||||
|
```bash
|
||||||
|
# after ~30s, a heartbeat sample should exist
|
||||||
|
curl -s "http://srv84-macos:9090/api/v1/query?query=app_heartbeat_total{job=%22farmafinder-backend%22}"
|
||||||
|
# health probes
|
||||||
|
curl -s http://localhost:3001/healthz ; curl -s http://localhost:3001/readyz
|
||||||
|
# dashboards populate: Grafana → FarmaFinder — Backend
|
||||||
|
```
|
||||||
|
|
||||||
|
### Mobile (user)
|
||||||
|
1. `cd apps/frontend-mobile && npm install` (pulls `@grafana/faro-react-native`).
|
||||||
|
2. Build a **dev/EAS build** (not Expo Go — native module).
|
||||||
|
3. Set `EXPO_PUBLIC_FARO_URL` (default `http://grafana.hacecalor.net:4318`) reachable from device.
|
||||||
|
4. Verify in Grafana → FarmaFinder — Mobile RUM (Loki `{app="farmafinder-mobile"}`).
|
||||||
|
|
||||||
|
### Datastore exporters (apply on farmafinder redeploy)
|
||||||
|
`docker compose up -d` brings up `redis-exporter` (`:9121`) and `postgres-exporter` (`:9187`);
|
||||||
|
Prometheus already scrapes them. Verify: `up{job="farmafinder-redis"}`, `up{job="farmafinder-postgres"}`.
|
||||||
|
|
||||||
|
## 6. Verification checklist (end)
|
||||||
|
- [x] 4 Grafana dashboards live (backend, datastores, mobile-rum, overview)
|
||||||
|
- [x] Prometheus scrape jobs `farmafinder-redis` / `farmafinder-postgres` present
|
||||||
|
- [x] Alert rules `farmafinder_*` loaded (no config errors)
|
||||||
|
- [ ] Backend redeployed → `app_heartbeat_total`, `http_requests_total`, `cima_requests_total`, etc. appear
|
||||||
|
- [ ] `/healthz`, `/readyz` return 200
|
||||||
|
- [ ] Mobile build → Faro data in Loki + Mobile RUM dashboard
|
||||||
|
- [ ] Trigger a test alert (stop backend) → Telegram receives it
|
||||||
|
|
||||||
|
## 7. Key commands / references
|
||||||
|
- Remote stack: `ssh root@srv84-macos`, configs under `/root/Monitoring`.
|
||||||
|
- Prometheus reload: `curl -X POST http://srv84-macos:9090/-/reload`.
|
||||||
|
- Grafana dashboards reload: `curl -u admin:foobar -X POST http://srv84-macos:3000/api/admin/provisioning/dashboards/reload`.
|
||||||
|
- Grafana API: `curl -u admin:foobar http://srv84-macos:3000/api/...` (admin password `foobar`).
|
||||||
|
- Backend OTel env (in `docker-compose.yml`): `OTEL_SERVICE_NAME=farmafinder-backend`, `OTEL_EXPORTER_OTLP_ENDPOINT=http://host.docker.internal:4317`, `OTEL_TRACES_EXPORTER=otlp`, **`OTEL_METRICS_EXPORTER=otlp`** (added), `OTEL_LOGS_EXPORTER=otlp`.
|
||||||
|
- New metrics module: `apps/backend/src/metrics.js`.
|
||||||
|
- Dashboards source: `monitoring/dashboards/*.json` (mirrored on the host).
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
{
|
||||||
|
"annotations": { "list": [] },
|
||||||
|
"editable": true,
|
||||||
|
"fiscalYearStartMonth": 0,
|
||||||
|
"graphTooltip": 1,
|
||||||
|
"id": null,
|
||||||
|
"links": [],
|
||||||
|
"liveNow": false,
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"id": 1, "title": "Request rate (req/s)", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 0, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum(rate(http_requests_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "req/s" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2, "title": "Requests by status class", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 8, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum by (status_class) (rate(http_requests_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "{{status_class}}" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3, "title": "5xx error rate", "type": "stat",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 16, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum(rate(http_requests_total{status_class=\"5xx\",job=\"farmafinder-backend\"}[5m])) / sum(rate(http_requests_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "5xx ratio" }
|
||||||
|
],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "steps": [ { "color": "green", "value": 0 }, { "color": "yellow", "value": 0.01 }, { "color": "red", "value": 0.05 } ] } } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4, "title": "HTTP p95 latency (route)", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 6 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "histogram_quantile(0.95, sum by (le, route) (rate(http_request_duration_ms_bucket{job=\"farmafinder-backend\"}[5m])))", "legendFormat": "{{route}} p95" }
|
||||||
|
],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "ms" } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5, "title": "Medicine searches / CIMA requests", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 6 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum(rate(medicine_searches_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "searches/s" },
|
||||||
|
{ "expr": "sum(rate(cima_requests_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "cima req/s" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6, "title": "Cache hit ratio", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 0, "y": 12 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum(rate(cache_hits_total{job=\"farmafinder-backend\"}[5m])) / (sum(rate(cache_hits_total{job=\"farmafinder-backend\"}[5m])) + sum(rate(cache_misses_total{job=\"farmafinder-backend\"}[5m])))", "legendFormat": "hit ratio" }
|
||||||
|
],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percentunit" } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7, "title": "CIMA API errors", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 8, "y": 12 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum(rate(cima_requests_total{status=\"error\",job=\"farmafinder-backend\"}[5m]))", "legendFormat": "errors/s" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 8, "title": "Logins (success / failure)", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 16, "y": 12 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum(rate(login_success_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "success/s" },
|
||||||
|
{ "expr": "sum(rate(login_failure_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "failure/s" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9, "title": "Rate-limit rejections (by route)", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 18 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum by (route) (rate(rate_limit_rejected_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "{{route}}" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 10, "title": "Push notifications (sent / failed)", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 18 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum by (channel) (rate(push_sent_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "sent {{channel}}" },
|
||||||
|
{ "expr": "sum by (channel) (rate(push_failed_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "failed {{channel}}" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 11, "title": "DB query p95 latency & errors", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 24 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "histogram_quantile(0.95, sum by (le, engine) (rate(db_query_duration_ms_bucket{job=\"farmafinder-backend\"}[5m])))", "legendFormat": "p95 {{engine}}" },
|
||||||
|
{ "expr": "sum by (engine) (rate(db_errors_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "errors {{engine}}" }
|
||||||
|
],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "ms" } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 12, "title": "Redis cmd p95 & errors", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 24 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "histogram_quantile(0.95, sum by (le) (rate(redis_cmd_duration_ms_bucket{job=\"farmafinder-backend\"}[5m])))", "legendFormat": "p95 redis" },
|
||||||
|
{ "expr": "sum(rate(redis_errors_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "redis errors/s" }
|
||||||
|
],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "ms" } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 13, "title": "Admin ops (pharmacy writes / links)", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 30 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "sum by (op) (rate(pharmacy_write_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "pharmacy {{op}}" },
|
||||||
|
{ "expr": "sum by (op) (rate(pharmacy_medicine_link_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "link {{op}}" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 14, "title": "Liveness (heartbeat)", "type": "stat",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 30 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "max(app_heartbeat_total{job=\"farmafinder-backend\"})", "legendFormat": "heartbeat total" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"schemaVersion": 39,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": ["farmafinder", "backend"],
|
||||||
|
"templating": { "list": [] },
|
||||||
|
"time": { "from": "now-6h", "to": "now" },
|
||||||
|
"timepicker": {},
|
||||||
|
"timezone": "browser",
|
||||||
|
"title": "FarmaFinder — Backend",
|
||||||
|
"uid": "farmafinder-backend",
|
||||||
|
"version": 1,
|
||||||
|
"weekStart": ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
{
|
||||||
|
"annotations": { "list": [] },
|
||||||
|
"editable": true,
|
||||||
|
"fiscalYearStartMonth": 0,
|
||||||
|
"graphTooltip": 1,
|
||||||
|
"id": null,
|
||||||
|
"links": [],
|
||||||
|
"liveNow": false,
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"id": 1, "title": "Redis up", "type": "stat",
|
||||||
|
"gridPos": { "h": 5, "w": 6, "x": 0, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "redis_up{job=\"farmafinder-redis\"}", "legendFormat": "redis" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2, "title": "Connected clients", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 5, "w": 9, "x": 6, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "redis_connected_clients{job=\"farmafinder-redis\"}", "legendFormat": "clients" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3, "title": "Memory used", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 5, "w": 9, "x": 15, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "redis_memory_used_bytes{job=\"farmafinder-redis\"}", "legendFormat": "bytes" } ],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "bytes" } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4, "title": "Commands/sec", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 5 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "rate(redis_commands_processed_total{job=\"farmafinder-redis\"}[5m])", "legendFormat": "cmd/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5, "title": "Keyspace hit ratio", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 5 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "sum(rate(redis_keyspace_hits_total{job=\"farmafinder-redis\"}[5m])) / (sum(rate(redis_keyspace_hits_total{job=\"farmafinder-redis\"}[5m])) + sum(rate(redis_keyspace_misses_total{job=\"farmafinder-redis\"}[5m])))", "legendFormat": "hit ratio" } ],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percentunit" } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6, "title": "Postgres up", "type": "stat",
|
||||||
|
"gridPos": { "h": 5, "w": 6, "x": 0, "y": 11 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "pg_up{job=\"farmafinder-postgres\"}", "legendFormat": "pg" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 7, "title": "Active connections", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 5, "w": 9, "x": 6, "y": 11 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "pg_stat_activity_count{job=\"farmafinder-postgres\"}", "legendFormat": "connections" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 8, "title": "Tuples returned / fetched", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 5, "w": 9, "x": 15, "y": 11 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "rate(pg_stat_database_tup_returned{job=\"farmafinder-postgres\"}[5m])", "legendFormat": "returned/s" }, { "expr": "rate(pg_stat_database_tup_fetched{job=\"farmafinder-postgres\"}[5m])", "legendFormat": "fetched/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 9, "title": "Deadlocks / conflicts", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 0, "y": 16 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "rate(pg_stat_database_deadlocks{job=\"farmafinder-postgres\"}[5m])", "legendFormat": "deadlocks/s" }, { "expr": "rate(pg_stat_database_conflicts{job=\"farmafinder-postgres\"}[5m])", "legendFormat": "conflicts/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 10, "title": "Cache hit ratio (blocks)", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 12, "x": 12, "y": 16 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "pg_stat_database_blk_hit{job=\"farmafinder-postgres\"} / (pg_stat_database_blk_hit{job=\"farmafinder-postgres\"} + pg_stat_database_blk_read{job=\"farmafinder-postgres\"})", "legendFormat": "block hit ratio" } ],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percentunit" } }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"schemaVersion": 39,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": ["farmafinder", "datastores"],
|
||||||
|
"templating": { "list": [] },
|
||||||
|
"time": { "from": "now-6h", "to": "now" },
|
||||||
|
"timepicker": {},
|
||||||
|
"timezone": "browser",
|
||||||
|
"title": "FarmaFinder — Datastores",
|
||||||
|
"uid": "farmafinder-datastores",
|
||||||
|
"version": 1,
|
||||||
|
"weekStart": ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
{
|
||||||
|
"annotations": { "list": [] },
|
||||||
|
"editable": true,
|
||||||
|
"fiscalYearStartMonth": 0,
|
||||||
|
"graphTooltip": 1,
|
||||||
|
"id": null,
|
||||||
|
"links": [],
|
||||||
|
"liveNow": false,
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"id": 1, "title": "Events/sec", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 0, "y": 0 },
|
||||||
|
"datasource": { "type": "loki", "uid": "bfowk7qjoccu8b" },
|
||||||
|
"targets": [ { "expr": "sum(count_over_time({app=\"farmafinder-mobile\"}[5m]))", "legendFormat": "events/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2, "title": "Active sessions", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 8, "y": 0 },
|
||||||
|
"datasource": { "type": "loki", "uid": "bfowk7qjoccu8b" },
|
||||||
|
"targets": [ { "expr": "count(count by (session_id) (count_over_time({app=\"farmafinder-mobile\"}[5m])))", "legendFormat": "sessions" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3, "title": "Errors/sec", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 6, "w": 8, "x": 16, "y": 0 },
|
||||||
|
"datasource": { "type": "loki", "uid": "bfowk7qjoccu8b" },
|
||||||
|
"targets": [ { "expr": "sum(count_over_time({app=\"farmafinder-mobile\"} |~ \"(?i)error|exception|crash\"[5m]))", "legendFormat": "errors/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4, "title": "Events by type", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 7, "w": 12, "x": 0, "y": 6 },
|
||||||
|
"datasource": { "type": "loki", "uid": "bfowk7qjoccu8b" },
|
||||||
|
"targets": [ { "expr": "sum by (type) (count_over_time({app=\"farmafinder-mobile\"}[5m]))", "legendFormat": "{{type}}" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5, "title": "Top error messages", "type": "timeseries",
|
||||||
|
"gridPos": { "h": 7, "w": 12, "x": 12, "y": 6 },
|
||||||
|
"datasource": { "type": "loki", "uid": "bfowk7qjoccu8b" },
|
||||||
|
"targets": [ { "expr": "sum by (message) (count_over_time({app=\"farmafinder-mobile\"} |~ \"(?i)error|exception|crash\"[5m]))", "legendFormat": "{{message}}" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6, "title": "Recent logs", "type": "logs",
|
||||||
|
"gridPos": { "h": 10, "w": 24, "x": 0, "y": 13 },
|
||||||
|
"datasource": { "type": "loki", "uid": "bfowk7qjoccu8b" },
|
||||||
|
"targets": [ { "expr": "{app=\"farmafinder-mobile\"}", "legendFormat": "" } ]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"schemaVersion": 39,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": ["farmafinder", "mobile", "rum"],
|
||||||
|
"templating": { "list": [] },
|
||||||
|
"time": { "from": "now-6h", "to": "now" },
|
||||||
|
"timepicker": {},
|
||||||
|
"timezone": "browser",
|
||||||
|
"title": "FarmaFinder — Mobile RUM",
|
||||||
|
"uid": "farmafinder-mobile-rum",
|
||||||
|
"version": 1,
|
||||||
|
"weekStart": ""
|
||||||
|
}
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
{
|
||||||
|
"annotations": { "list": [] },
|
||||||
|
"editable": true,
|
||||||
|
"fiscalYearStartMonth": 0,
|
||||||
|
"graphTooltip": 1,
|
||||||
|
"id": null,
|
||||||
|
"links": [],
|
||||||
|
"liveNow": false,
|
||||||
|
"panels": [
|
||||||
|
{
|
||||||
|
"id": 1, "title": "Backend req/s", "type": "stat",
|
||||||
|
"gridPos": { "h": 5, "w": 6, "x": 0, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "sum(rate(http_requests_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "req/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2, "title": "Backend 5xx ratio", "type": "stat",
|
||||||
|
"gridPos": { "h": 5, "w": 6, "x": 6, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "sum(rate(http_requests_total{status_class=\"5xx\",job=\"farmafinder-backend\"}[5m])) / sum(rate(http_requests_total{job=\"farmafinder-backend\"}[5m]))", "legendFormat": "5xx" } ],
|
||||||
|
"fieldConfig": { "defaults": { "unit": "percentunit", "thresholds": { "steps": [ { "color": "green", "value": 0 }, { "color": "yellow", "value": 0.01 }, { "color": "red", "value": 0.05 } ] } } }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3, "title": "CIMA errors/s", "type": "stat",
|
||||||
|
"gridPos": { "h": 5, "w": 6, "x": 12, "y": 0 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [ { "expr": "sum(rate(cima_requests_total{status=\"error\",job=\"farmafinder-backend\"}[5m]))", "legendFormat": "cima err/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 4, "title": "Mobile events/s", "type": "stat",
|
||||||
|
"gridPos": { "h": 5, "w": 6, "x": 18, "y": 0 },
|
||||||
|
"datasource": { "type": "loki", "uid": "bfowk7qjoccu8b" },
|
||||||
|
"targets": [ { "expr": "sum(count_over_time({app=\"farmafinder-mobile\"}[5m]))", "legendFormat": "mobile/s" } ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 5, "title": "Datastore health", "type": "stat",
|
||||||
|
"gridPos": { "h": 5, "w": 12, "x": 0, "y": 5 },
|
||||||
|
"datasource": { "type": "prometheus", "uid": "PBFA97CFB590B2093" },
|
||||||
|
"targets": [
|
||||||
|
{ "expr": "redis_up{job=\"farmafinder-redis\"}", "legendFormat": "redis" },
|
||||||
|
{ "expr": "pg_up{job=\"farmafinder-postgres\"}", "legendFormat": "postgres" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 6, "title": "Navigation", "type": "text",
|
||||||
|
"gridPos": { "h": 5, "w": 12, "x": 12, "y": 5 },
|
||||||
|
"options": {
|
||||||
|
"mode": "markdown",
|
||||||
|
"content": "**Dashboards**\n- [Backend](/d/farmafinder-backend/farmafinder-backend)\n- [Datastores](/d/farmafinder-datastores/farmafinder-datastores)\n- [Mobile RUM](/d/farmafinder-mobile-rum/farmafinder-mobile-rum)\n- [Faro Web RUM](/d/faro-overview/faro-farmafinder-rum-overview)\n\n**Explore**\n- [Tempo (traces)](/explore?orgId=1&left=%5B%22now-6h%22,%22now%22,%22tempo%22,%7B%7D%5D)\n- [Loki (logs)](/explore?orgId=1&left=%5B%22now-6h%22,%22now%22,%22loki%22,%7B%7D%5D)\n- [Prometheus (metrics)](/explore?orgId=1&left=%5B%22now-6h%22,%22now%22,%22PBFA97CFB590B2093%22,%7B%7D%5D)"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"schemaVersion": 39,
|
||||||
|
"style": "dark",
|
||||||
|
"tags": ["farmafinder", "overview"],
|
||||||
|
"templating": { "list": [] },
|
||||||
|
"time": { "from": "now-6h", "to": "now" },
|
||||||
|
"timepicker": {},
|
||||||
|
"timezone": "browser",
|
||||||
|
"title": "FarmaFinder — Overview",
|
||||||
|
"uid": "farmafinder-overview",
|
||||||
|
"version": 1,
|
||||||
|
"weekStart": ""
|
||||||
|
}
|
||||||
Generated
+466
@@ -35,10 +35,12 @@
|
|||||||
"@opentelemetry/api": "^1.9.0",
|
"@opentelemetry/api": "^1.9.0",
|
||||||
"@opentelemetry/auto-instrumentations-node": "^0.52.0",
|
"@opentelemetry/auto-instrumentations-node": "^0.52.0",
|
||||||
"@opentelemetry/exporter-logs-otlp-grpc": "^0.55.0",
|
"@opentelemetry/exporter-logs-otlp-grpc": "^0.55.0",
|
||||||
|
"@opentelemetry/exporter-metrics-otlp-grpc": "^0.55.0",
|
||||||
"@opentelemetry/exporter-trace-otlp-grpc": "^0.55.0",
|
"@opentelemetry/exporter-trace-otlp-grpc": "^0.55.0",
|
||||||
"@opentelemetry/instrumentation-pino": "^0.45.0",
|
"@opentelemetry/instrumentation-pino": "^0.45.0",
|
||||||
"@opentelemetry/resources": "^1.28.0",
|
"@opentelemetry/resources": "^1.28.0",
|
||||||
"@opentelemetry/sdk-logs": "^0.55.0",
|
"@opentelemetry/sdk-logs": "^0.55.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "^1.28.0",
|
||||||
"@opentelemetry/sdk-node": "^0.55.0",
|
"@opentelemetry/sdk-node": "^0.55.0",
|
||||||
"@opentelemetry/sdk-trace-base": "^1.28.0",
|
"@opentelemetry/sdk-trace-base": "^1.28.0",
|
||||||
"@opentelemetry/semantic-conventions": "^1.28.0",
|
"@opentelemetry/semantic-conventions": "^1.28.0",
|
||||||
@@ -65,6 +67,43 @@
|
|||||||
"supertest": "^7.2.2"
|
"supertest": "^7.2.2"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apps/backend/node_modules/@opentelemetry/core": {
|
||||||
|
"version": "1.30.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.30.1.tgz",
|
||||||
|
"integrity": "sha512-OOCM2C/QIURhJMuKaekP3TRBxBKxG/TWWA0TL2J6nXUtDnuCtccy49LUJF8xPFXMX+0LMcxFpCo8M9cGY1W6rQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/semantic-conventions": "1.28.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/backend/node_modules/@opentelemetry/sdk-metrics": {
|
||||||
|
"version": "1.30.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.30.1.tgz",
|
||||||
|
"integrity": "sha512-q9zcZ0Okl8jRgmy7eNW3Ku1XSgg3sDLa5evHZpCwjspw7E8Is4K/haRPDJrBcX3YSn/Y7gUvFnByNYEKQNbNog==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.30.1",
|
||||||
|
"@opentelemetry/resources": "1.30.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.3.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/backend/node_modules/@opentelemetry/semantic-conventions": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-lp4qAiMTD4sNWW4DbKLBkfiMZ4jbAboJIGOQr5DvciMRI494OapieI9qiODpOt0XBr1LjIDy1xAGAnVs5supTA==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"apps/frontend": {
|
"apps/frontend": {
|
||||||
"name": "farma-clic-frontend",
|
"name": "farma-clic-frontend",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
@@ -99,6 +138,7 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/vector-icons": "^15.0.2",
|
"@expo/vector-icons": "^15.0.2",
|
||||||
|
"@grafana/faro-react-native": "^1.2.1",
|
||||||
"@react-native-async-storage/async-storage": "2.2.0",
|
"@react-native-async-storage/async-storage": "2.2.0",
|
||||||
"@tanstack/react-query": "^5.101.2",
|
"@tanstack/react-query": "^5.101.2",
|
||||||
"axios": "^1.18.1",
|
"axios": "^1.18.1",
|
||||||
@@ -363,6 +403,157 @@
|
|||||||
"react-native": "*"
|
"react-native": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@grafana/faro-core": {
|
||||||
|
"version": "2.8.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/@grafana/faro-core/-/faro-core-2.8.2.tgz",
|
||||||
|
"integrity": "sha512-63C6+N/P9/ySUMaGut8yVb1DkPuHS5I/lfRm97+aDXFj3+8pxRT/QzyXNe0r6KMU5O95wC9FLVGxG9ZvkwEhJQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api": "^1.9.0",
|
||||||
|
"@opentelemetry/otlp-transformer": "^0.219.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@grafana/faro-react-native": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@grafana/faro-react-native/-/faro-react-native-1.3.0.tgz",
|
||||||
|
"integrity": "sha512-KeohD3S2xmiukL5YW3mOGDqvFiwpD9IzJ2EtZ50ktEsnA+6EMt2AtJ8RzJfAamGTYqemBpDiw51rqB4ID+C2xg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@grafana/faro-core": "^2.7.0",
|
||||||
|
"@react-native-async-storage/async-storage": "^1.21.0",
|
||||||
|
"react-native-device-info": "^11.1.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@react-navigation/native": ">=6.0.0",
|
||||||
|
"react": ">=18.0.0",
|
||||||
|
"react-native": ">=0.70.0",
|
||||||
|
"react-native-mmkv": ">=2.0.0"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@react-navigation/native": {
|
||||||
|
"optional": true
|
||||||
|
},
|
||||||
|
"react-native-mmkv": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@grafana/faro-react-native/node_modules/@react-native-async-storage/async-storage": {
|
||||||
|
"version": "1.24.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-1.24.0.tgz",
|
||||||
|
"integrity": "sha512-W4/vbwUOYOjco0x3toB8QCr7EjIP6nE9G7o8PMguvvjYT5Awg09lyV4enACRx4s++PPulBiBSjL0KTFx2u0Z/g==",
|
||||||
|
"dependencies": {
|
||||||
|
"merge-options": "^3.0.4"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"react-native": "^0.0.0-0 || >=0.60 <1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@opentelemetry/api-logs": {
|
||||||
|
"version": "0.219.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.219.0.tgz",
|
||||||
|
"integrity": "sha512-FFx7YnaYJlIjqWW/AG/yAZ0L/NEY724PipXXXQLdtZPbLwBGbUMTGL1i/esI56TWfTUXxhLfpgrnWJCG8aUJyg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@opentelemetry/core": {
|
||||||
|
"version": "2.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-2.8.0.tgz",
|
||||||
|
"integrity": "sha512-hd1Lfh8p545nNz+jq1Ejfz+Mn1hyLuxYn1YzTfFNrxr8urEWMNQLPf1Th8kjOH+HxwawCrtgBp8JpBUR4ZSgww==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/semantic-conventions": "^1.29.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.19.0 || >=20.6.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@opentelemetry/otlp-transformer": {
|
||||||
|
"version": "0.219.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.219.0.tgz",
|
||||||
|
"integrity": "sha512-aaYKAyXhw9VchKZVGOopD3Gw/kPsyrX2c6IQ0AW32mTjqmZOh5Y6Gf5OYqTNqVktAeBjmFinhyFaCwW6GYK9YQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api-logs": "0.219.0",
|
||||||
|
"@opentelemetry/core": "2.8.0",
|
||||||
|
"@opentelemetry/resources": "2.8.0",
|
||||||
|
"@opentelemetry/sdk-logs": "0.219.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "2.8.0",
|
||||||
|
"@opentelemetry/sdk-trace-base": "2.8.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.19.0 || >=20.6.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@opentelemetry/resources": {
|
||||||
|
"version": "2.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-2.8.0.tgz",
|
||||||
|
"integrity": "sha512-qmXQ27ilDbUK/vGMqwL8D4/rhn76C+sherM4wTbjlfknR8Nvfc/hCxjRJPhkzZzUsPiNg16SA31NxMabwttRjg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "2.8.0",
|
||||||
|
"@opentelemetry/semantic-conventions": "^1.29.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.19.0 || >=20.6.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.3.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@opentelemetry/sdk-logs": {
|
||||||
|
"version": "0.219.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-logs/-/sdk-logs-0.219.0.tgz",
|
||||||
|
"integrity": "sha512-s6lTKRakaPClvKoWHRChxnXjDMkM/TQ30ff78jN6EBGf7MI7VzANE5PU3f4z9qDUudWjvZjOLHG0rBnBKYvoXA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api-logs": "0.219.0",
|
||||||
|
"@opentelemetry/core": "2.8.0",
|
||||||
|
"@opentelemetry/resources": "2.8.0",
|
||||||
|
"@opentelemetry/semantic-conventions": "^1.29.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.19.0 || >=20.6.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.4.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@opentelemetry/sdk-metrics": {
|
||||||
|
"version": "2.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-2.8.0.tgz",
|
||||||
|
"integrity": "sha512-UDBGaj6W0Rgy5rTTaoxs8gVGF/aGkAKyjurJv7se6wjRxJu7FoquTLT/vt54DZfo4crbprYfhX/SOK9+BPw1qg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "2.8.0",
|
||||||
|
"@opentelemetry/resources": "2.8.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.19.0 || >=20.6.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.9.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/@opentelemetry/sdk-trace-base": {
|
||||||
|
"version": "2.8.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-2.8.0.tgz",
|
||||||
|
"integrity": "sha512-mhU4jp+vW0mGbFRd+GeXHvmfA4aDqWjBjLC3pE5XMpLs0IE2ryYb019Ts2AQrOq67gaTF25D91+fgvEHDZEnuQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "2.8.0",
|
||||||
|
"@opentelemetry/resources": "2.8.0",
|
||||||
|
"@opentelemetry/semantic-conventions": "^1.29.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^18.19.0 || >=20.6.0"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.3.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"apps/frontend-mobile/node_modules/@react-native-async-storage/async-storage": {
|
"apps/frontend-mobile/node_modules/@react-native-async-storage/async-storage": {
|
||||||
"version": "2.2.0",
|
"version": "2.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-2.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/@react-native-async-storage/async-storage/-/async-storage-2.2.0.tgz",
|
||||||
@@ -1085,6 +1276,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"apps/frontend-mobile/node_modules/react-native-device-info": {
|
||||||
|
"version": "11.1.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-native-device-info/-/react-native-device-info-11.1.0.tgz",
|
||||||
|
"integrity": "sha512-hzXJSObJdezEz0hF7MAJ3tGeoesuQWenXXt9mrQR9Mjb8kXpZ09rqSsZ/quNpJdZpQ3rYiFa3/0GFG5KNn9PBg==",
|
||||||
|
"peerDependencies": {
|
||||||
|
"react-native": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"apps/frontend-mobile/node_modules/react-native-drawer-layout": {
|
"apps/frontend-mobile/node_modules/react-native-drawer-layout": {
|
||||||
"version": "4.2.7",
|
"version": "4.2.7",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-drawer-layout/-/react-native-drawer-layout-4.2.7.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-drawer-layout/-/react-native-drawer-layout-4.2.7.tgz",
|
||||||
@@ -7141,6 +7340,273 @@
|
|||||||
"node": ">=14"
|
"node": ">=14"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-grpc/-/exporter-metrics-otlp-grpc-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-9V6t3Tz1yFmXKXDjphgPSAsfQuG0bz9PlAVRY28D+wuG7Ut/Fv43XuccktdAcdrXx1MvCHdCcVmINLyYXLqTIg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@grpc/grpc-js": "^1.7.1",
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/exporter-metrics-otlp-http": "0.55.0",
|
||||||
|
"@opentelemetry/otlp-exporter-base": "0.55.0",
|
||||||
|
"@opentelemetry/otlp-grpc-exporter-base": "0.55.0",
|
||||||
|
"@opentelemetry/otlp-transformer": "0.55.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "1.28.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/api-logs": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-3cpa+qI45VHYcA5c0bHM6VHo9gicv3p5mlLHNG3rLyjQU8b7e0st1rWtrUn3JbZ3DwwCfhKop4eQ9UuYlC6Pkg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/core": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-ZLwRMV+fNDpVmF2WYUdBHlq0eOWtEaUJSusrzjGnBt7iSRvfjFE3RXYUZJrqou/wIDWV0DwQ5KIfYe9WXg9Xqw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/semantic-conventions": "1.27.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/otlp-exporter-base": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-iHQI0Zzq3h1T6xUJTVFwmFl5Dt5y1es+fl4kM+k5T/3YvmVyeYkSiF+wHCg6oKrlUAJfk+t55kaAu3sYmt7ZYA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/otlp-transformer": "0.55.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/otlp-transformer": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-kVqEfxtp6mSN2Dhpy0REo1ghP4PYhC1kMHQJ2qVlO99Pc+aigELjZDfg7/YKmL71gR6wVGIeJfiql/eXL7sQPA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api-logs": "0.55.0",
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0",
|
||||||
|
"@opentelemetry/sdk-logs": "0.55.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "1.28.0",
|
||||||
|
"@opentelemetry/sdk-trace-base": "1.28.0",
|
||||||
|
"protobufjs": "^7.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/resources": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-cIyXSVJjGeTICENN40YSvLDAq4Y2502hGK3iN7tfdynQLKWb3XWZQEkPc+eSx47kiy11YeFAlYkEfXwR1w8kfw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/semantic-conventions": "1.27.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/sdk-metrics": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-43tqMK/0BcKTyOvm15/WQ3HLr0Vu/ucAl/D84NO7iSlv6O4eOprxSHa3sUtmYkaZWHqdDJV0AHVz/R6u4JALVQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.3.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/sdk-trace-base": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-ceUVWuCpIao7Y5xE02Xs3nQi0tOGmMea17ecBdwtCvdo9ekmO+ijc9RFDgfifMl7XCBf41zne/1POM3LqSTZDA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0",
|
||||||
|
"@opentelemetry/semantic-conventions": "1.27.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-grpc/node_modules/@opentelemetry/semantic-conventions": {
|
||||||
|
"version": "1.27.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.27.0.tgz",
|
||||||
|
"integrity": "sha512-sAay1RrB+ONOem0OZanAR1ZI/k7yDpnOQSQmTMuGImUQb2y8EbSaCJ94FQluM74xoU03vlb2d2U90hZluL6nQg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/exporter-metrics-otlp-http/-/exporter-metrics-otlp-http-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-3MqDNZzgXmLaiVo9gs9kCw/zPEaZYKIT0+jeMWscWHL/jrA9BNArTOYWUHEPabAQmWQ2BbvgNC7yzlqjoynQwA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/otlp-exporter-base": "0.55.0",
|
||||||
|
"@opentelemetry/otlp-transformer": "0.55.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "1.28.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/api-logs": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/api-logs/-/api-logs-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-3cpa+qI45VHYcA5c0bHM6VHo9gicv3p5mlLHNG3rLyjQU8b7e0st1rWtrUn3JbZ3DwwCfhKop4eQ9UuYlC6Pkg==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/core": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/core/-/core-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-ZLwRMV+fNDpVmF2WYUdBHlq0eOWtEaUJSusrzjGnBt7iSRvfjFE3RXYUZJrqou/wIDWV0DwQ5KIfYe9WXg9Xqw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/semantic-conventions": "1.27.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/otlp-exporter-base": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/otlp-exporter-base/-/otlp-exporter-base-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-iHQI0Zzq3h1T6xUJTVFwmFl5Dt5y1es+fl4kM+k5T/3YvmVyeYkSiF+wHCg6oKrlUAJfk+t55kaAu3sYmt7ZYA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/otlp-transformer": "0.55.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/otlp-transformer": {
|
||||||
|
"version": "0.55.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/otlp-transformer/-/otlp-transformer-0.55.0.tgz",
|
||||||
|
"integrity": "sha512-kVqEfxtp6mSN2Dhpy0REo1ghP4PYhC1kMHQJ2qVlO99Pc+aigELjZDfg7/YKmL71gR6wVGIeJfiql/eXL7sQPA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/api-logs": "0.55.0",
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0",
|
||||||
|
"@opentelemetry/sdk-logs": "0.55.0",
|
||||||
|
"@opentelemetry/sdk-metrics": "1.28.0",
|
||||||
|
"@opentelemetry/sdk-trace-base": "1.28.0",
|
||||||
|
"protobufjs": "^7.3.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": "^1.3.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/resources": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/resources/-/resources-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-cIyXSVJjGeTICENN40YSvLDAq4Y2502hGK3iN7tfdynQLKWb3XWZQEkPc+eSx47kiy11YeFAlYkEfXwR1w8kfw==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/semantic-conventions": "1.27.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/sdk-metrics": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-metrics/-/sdk-metrics-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-43tqMK/0BcKTyOvm15/WQ3HLr0Vu/ucAl/D84NO7iSlv6O4eOprxSHa3sUtmYkaZWHqdDJV0AHVz/R6u4JALVQ==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.3.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/sdk-trace-base": {
|
||||||
|
"version": "1.28.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/sdk-trace-base/-/sdk-trace-base-1.28.0.tgz",
|
||||||
|
"integrity": "sha512-ceUVWuCpIao7Y5xE02Xs3nQi0tOGmMea17ecBdwtCvdo9ekmO+ijc9RFDgfifMl7XCBf41zne/1POM3LqSTZDA==",
|
||||||
|
"dependencies": {
|
||||||
|
"@opentelemetry/core": "1.28.0",
|
||||||
|
"@opentelemetry/resources": "1.28.0",
|
||||||
|
"@opentelemetry/semantic-conventions": "1.27.0"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@opentelemetry/api": ">=1.0.0 <1.10.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@opentelemetry/exporter-metrics-otlp-http/node_modules/@opentelemetry/semantic-conventions": {
|
||||||
|
"version": "1.27.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@opentelemetry/semantic-conventions/-/semantic-conventions-1.27.0.tgz",
|
||||||
|
"integrity": "sha512-sAay1RrB+ONOem0OZanAR1ZI/k7yDpnOQSQmTMuGImUQb2y8EbSaCJ94FQluM74xoU03vlb2d2U90hZluL6nQg==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=14"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@opentelemetry/exporter-trace-otlp-grpc": {
|
"node_modules/@opentelemetry/exporter-trace-otlp-grpc": {
|
||||||
"version": "0.55.0",
|
"version": "0.55.0",
|
||||||
"resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-grpc/-/exporter-trace-otlp-grpc-0.55.0.tgz",
|
"resolved": "https://registry.npmjs.org/@opentelemetry/exporter-trace-otlp-grpc/-/exporter-trace-otlp-grpc-0.55.0.tgz",
|
||||||
|
|||||||
Reference in New Issue
Block a user