From dd9cf4ce43c68dfbeba6dea36268804bdce8a9bc Mon Sep 17 00:00:00 2001 From: Jose Selesan Date: Fri, 6 Nov 2026 11:59:17 -0300 Subject: [PATCH 1/2] feat(api): ship logs and HTTP metrics to OpenObserve Replace Pino with LogTape and add OpenTelemetry metrics, both pushed to OpenObserve over OTLP/HTTP when OPENOBSERVE_URL is set (console only otherwise). - lib/logger.ts: console sink (pretty in dev, JSON lines in production) plus an OpenObserve sink via @logtape/otel. Each request runs inside withContext({ requestId }), so every record logged during it carries the id. - The request middleware logs method, path, route pattern, status, durationMs, userId and user agent, at error/warning/info by status (/api/health at debug). - lib/metrics.ts: http.server.request.duration (histogram, 5 ms to 10 s) and http.server.active_requests, attributed by method, route pattern and status, exported every METRICS_EXPORT_INTERVAL_MS (15 s). - lib/openobserve.ts holds the shared endpoint and Basic auth settings; logs and metrics are flushed on SIGINT/SIGTERM. - docs/openobserve-dashboard.md explains the dashboard and its queries, and docs/openobserve-dashboard.json can be imported as is. - New variables are declared in turbo.json, the .env examples and the compose. Co-Authored-By: Claude Opus 5.5 --- .env.example | 12 +- AGENTS.md | 25 +- README.md | 2 +- STACK.md | 2 +- apps/api/.env.example | 12 +- apps/api/package.json | 9 +- apps/api/src/app.ts | 64 +- apps/api/src/index.ts | 18 +- apps/api/src/lib/auth.ts | 2 +- apps/api/src/lib/logger.ts | 108 +++- apps/api/src/lib/mailer.ts | 11 +- apps/api/src/lib/metrics.ts | 92 +++ apps/api/src/lib/openobserve.ts | 30 + apps/api/src/lib/problem-details.ts | 2 +- .../modules/invitations/create/use-case.ts | 4 +- apps/api/src/modules/voice/split/use-case.ts | 5 +- bun.lock | 131 +++-- docker-compose.yml | 7 + docs/openobserve-dashboard.json | 555 ++++++++++++++++++ docs/openobserve-dashboard.md | 184 ++++++ turbo.json | 18 +- 21 files changed, 1191 insertions(+), 102 deletions(-) create mode 100644 apps/api/src/lib/metrics.ts create mode 100644 apps/api/src/lib/openobserve.ts create mode 100644 docs/openobserve-dashboard.json create mode 100644 docs/openobserve-dashboard.md diff --git a/.env.example b/.env.example index 04d5844..65949a5 100644 --- a/.env.example +++ b/.env.example @@ -11,8 +11,18 @@ BETTER_AUTH_SECRET="change-me-with-openssl-rand-base64-32" BETTER_AUTH_URL="http://localhost:4100" # "development" enables pretty logs, "production" emits JSON NODE_ENV="development" -# Optional: Pino log level (defaults to "debug" outside production, "info" in production) +# Optional: log level (trace, debug, info, warning, error, fatal) (defaults to "debug" outside production, "info" in production) # LOG_LEVEL="info" +# Optional: ship logs to OpenObserve over OTLP/HTTP. Without OPENOBSERVE_URL logs only go to the console. +# OPENOBSERVE_URL="http://localhost:5080" +# Optional: organization (defaults to "default") and stream (defaults to "superlist") +# OPENOBSERVE_ORG="default" +# OPENOBSERVE_STREAM="superlist" +# OpenObserve user email and password (sent as Basic auth) +# OPENOBSERVE_USER="root@example.com" +# OPENOBSERVE_PASSWORD="" +# Optional: how often HTTP metrics are pushed to OpenObserve, in milliseconds (defaults to 15000) +# METRICS_EXPORT_INTERVAL_MS="15000" # Resend API key used to send invitation and password reset emails. Without it, emails are logged instead. # RESEND_API_KEY="re_xxxxxxxx" # From address for outgoing email (must be a verified Resend sender) diff --git a/AGENTS.md b/AGENTS.md index c8a55ce..8ecbbf4 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -15,7 +15,7 @@ The `health` module is the reference example. - Monorepo orchestrated with **Turborepo** (see the managed block at the end of this file) - Backend: **Bun** + **Hono**, **Prisma 7** against **Postgres** (via `@prisma/adapter-pg`), **Zod** for - validation, **Pino** for logging, **BetterAuth** for auth + validation, **LogTape** for logging (shipped to **OpenObserve**), **BetterAuth** for auth - Frontend: **React + Vite + TypeScript**, **Tailwind v4**, UI components from **shadcn/ui** - Frontend routing: **TanStack Router** (file-based) · server state: **TanStack Query** · forms: **React Hook Form + Zod** @@ -197,9 +197,26 @@ export class CreateAlert { (`problemResponse`, `notFoundHandler`, `errorHandler`) in `apps/api/src/lib/problem-details.ts`. - Zod is the only validation library, and Zod 4 is what is installed. Define schemas next to the feature that uses them (`schema.ts`); share them through `@superlist/shared` only when more than one module needs them. -- **Logging: Pino** — one shared logger in `apps/api/src/lib/logger.ts`, reachable from handlers as - `c.get('logger')` (already enriched with the request id); never `console.log` in the backend. Level comes from - `LOG_LEVEL`, defaulting to `debug` (pretty) outside production and `info` (JSON) in production. +- **Logging: LogTape** — root logger (`superlist` category) exported from `apps/api/src/lib/logger.ts`, reachable + from handlers as `c.get('logger')`; never `console.log` in the backend. The call shape is + `logger.info('message {prop}', { prop })` (message first, properties second; pass errors as `{ error }`). + `configureLogging()` runs once in `src/index.ts` (tests never call it, so logging is silent there) and + `dispose()` flushes on SIGINT/SIGTERM. Sinks: console (`@logtape/pretty` outside production, JSON lines in + production) plus OpenObserve over OTLP/HTTP (`@logtape/otel`, `/api//v1/logs`, Basic auth, `stream-name` + header) when `OPENOBSERVE_URL` is set (`OPENOBSERVE_ORG`, `OPENOBSERVE_STREAM`, `OPENOBSERVE_USER`, + `OPENOBSERVE_PASSWORD`). Level comes from `LOG_LEVEL` (`debug` in dev, `info` in production; `warn` is accepted + for `warning`). The request middleware in `app.ts` wraps each request in `withContext({ requestId })`, so every + record logged during it carries the request id, and logs one `superlist.http` record per request with + `method`, `path`, `route` (the Hono pattern, e.g. `/api/lists/:listId`), `status`, `durationMs`, `userId` and + `userAgent` — `error` for 5xx, `warning` for 4xx, `debug` for `/api/health`, `info` otherwise. SSE routes + return their `Response` immediately, so their duration is the time to open the stream. +- **Metrics: OpenTelemetry SDK** (`apps/api/src/lib/metrics.ts`), pushed to OpenObserve over OTLP/HTTP + (`/api//v1/metrics`, cumulative temporality) every `METRICS_EXPORT_INTERVAL_MS` (15 s) when + `OPENOBSERVE_URL` is set; otherwise the global meter is a no-op. The same request middleware records + `http.server.request.duration` (histogram, seconds; attributes `http.request.method`, `http.route`, + `http.response.status_code`) and `http.server.active_requests`. Always use the route pattern + (`routePath(c, -1)`), never the raw path, as an attribute. The OpenObserve settings live in + `lib/openobserve.ts`, shared by logs and metrics. Dashboard guide: `docs/openobserve-dashboard.md` (importable JSON: `docs/openobserve-dashboard.json`). - Unexpected throws are turned into Problem Details by `app.onError`; unmatched routes by `app.notFound` (both in `apps/api/src/lib/problem-details.ts`). - `createApp()` middleware order matters: `secureHeaders` → `cors` (origins from `CORS_ORIGIN`, credentials on) diff --git a/README.md b/README.md index 5574566..61fbf7f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Monorepo with a Bun + Hono API and a React + Vite admin app. | Workspace | What it is | | ----------------- | ----------------------------------------------------------------------- | -| `apps/api` | Bun + Hono backend, Prisma (Postgres), Zod validation, Pino logging | +| `apps/api` | Bun + Hono backend, Prisma (Postgres), Zod validation, LogTape logging | | `apps/web` | React + Vite + TypeScript frontend, shadcn/ui, TanStack Router + Query | | `packages/shared` | `@superlist/shared` — Result pattern and RFC 9457 Problem Details types | diff --git a/STACK.md b/STACK.md index 66e313a..0f15af9 100644 --- a/STACK.md +++ b/STACK.md @@ -1,5 +1,5 @@ - Monorepo con TURBO -- Backend en Bun con Hono. Acceso a DB Postgres con Prisma. Validación con Zod. Logging con Pino +- Backend en Bun con Hono. Acceso a DB Postgres con Prisma. Validación con Zod. Logging con LogTape (consola + OpenObserve vía OTLP) - Salidas del backend según RFC 9457 (Problem Details) - Frontend en React con vite y typescript. Componentes Shadcn - Rutas del frontend con TanStack Router usando file-based routing diff --git a/apps/api/.env.example b/apps/api/.env.example index d580278..c1a9b07 100644 --- a/apps/api/.env.example +++ b/apps/api/.env.example @@ -4,8 +4,18 @@ CORS_ORIGIN="http://localhost:7153" BETTER_AUTH_SECRET="change-me-with-openssl-rand-base64-32" BETTER_AUTH_URL="http://localhost:4100" NODE_ENV="development" -# Optional: Pino log level (defaults to "debug" outside production, "info" in production) +# Optional: log level (trace, debug, info, warning, error, fatal) (defaults to "debug" outside production, "info" in production) # LOG_LEVEL="info" +# Optional: ship logs to OpenObserve over OTLP/HTTP. Without OPENOBSERVE_URL logs only go to the console. +# OPENOBSERVE_URL="http://localhost:5080" +# Optional: organization (defaults to "default") and stream (defaults to "superlist") +# OPENOBSERVE_ORG="default" +# OPENOBSERVE_STREAM="superlist" +# OpenObserve user email and password (sent as Basic auth) +# OPENOBSERVE_USER="root@example.com" +# OPENOBSERVE_PASSWORD="" +# Optional: how often HTTP metrics are pushed to OpenObserve, in milliseconds (defaults to 15000) +# METRICS_EXPORT_INTERVAL_MS="15000" # Resend API key used to send invitation and password reset emails. Without it, emails are logged instead. # RESEND_API_KEY="re_xxxxxxxx" # From address for outgoing email (must be a verified Resend sender) diff --git a/apps/api/package.json b/apps/api/package.json index 31c150b..f2c63e9 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -18,14 +18,19 @@ "dependencies": { "@better-auth/passkey": "1.7.7", "@hono/zod-validator": "^0.9.1", + "@logtape/logtape": "^2.4.2", + "@logtape/otel": "^2.4.2", + "@logtape/pretty": "^2.4.2", + "@opentelemetry/api": "1.9.0", + "@opentelemetry/exporter-metrics-otlp-http": "0.208.0", + "@opentelemetry/resources": "2.2.0", + "@opentelemetry/sdk-metrics": "2.2.0", "@prisma/adapter-pg": "^7.10.0", "@prisma/client": "^7.10.0", "@superlist/shared": "workspace:*", "better-auth": "^1.7.7", "hono": "^4.13.13", "pg": "^8.23.1", - "pino": "^10.4.0", - "pino-pretty": "^13.2.0", "resend": "^6.32.1", "zod": "^4.6.7" }, diff --git a/apps/api/src/app.ts b/apps/api/src/app.ts index 78d7579..938cdc7 100644 --- a/apps/api/src/app.ts +++ b/apps/api/src/app.ts @@ -1,16 +1,21 @@ +import { withContext } from '@logtape/logtape' import { Hono } from 'hono' import { cors } from 'hono/cors' import { requestId } from 'hono/request-id' +import { routePath } from 'hono/route' import { secureHeaders } from 'hono/secure-headers' import { auth } from '@/lib/auth' import { logger } from '@/lib/logger' +import { httpMetrics } from '@/lib/metrics' import { errorHandler, notFoundHandler } from '@/lib/problem-details' import { healthModule } from '@/modules/health' import { invitationsModule } from '@/modules/invitations' import { listsModule } from '@/modules/lists' import { voiceModule } from '@/modules/voice' -import type { AppEnv } from '@/types' +import type { AppEnv, SessionUser } from '@/types' + +const httpLogger = logger.getChild('http') const allowedOrigins = (process.env.CORS_ORIGIN ?? 'http://localhost:7153') .split(',') @@ -24,20 +29,53 @@ export function createApp() { app.use(cors({ origin: allowedOrigins, credentials: true })) app.use(requestId()) app.use(async (c, next) => { - const requestLogger = logger.child({ requestId: c.get('requestId') }) - c.set('logger', requestLogger) + const requestId = c.get('requestId') + c.set('logger', httpLogger.with({ requestId })) + + const http = httpMetrics() + const method = c.req.method + http.activeRequests.add(1, { 'http.request.method': method }) const start = performance.now() - await next() - requestLogger.info( - { - method: c.req.method, - path: c.req.path, - status: c.res.status, - durationMs: Math.round(performance.now() - start), - }, - 'request', - ) + try { + // Every record logged while the request runs (module loggers included) + // inherits the requestId through LogTape's implicit context. + await withContext({ requestId }, next) + } finally { + http.activeRequests.add(-1, { 'http.request.method': method }) + } + const elapsedMs = performance.now() - start + const durationMs = Math.round(elapsedMs * 10) / 10 + + const status = c.res.status + const route = routePath(c, -1) + // SSE streams (/events) return their Response right away, so for them this is + // the time to open the stream, not the lifetime of the connection. + http.duration.record(elapsedMs / 1000, { + 'http.request.method': method, + // The Hono pattern (/api/lists/:listId), never the raw path, to keep cardinality low. + 'http.route': route, + 'http.response.status_code': status, + }) + + const userId = (c.get('user') as SessionUser | undefined)?.id + const properties = { + requestId, + method, + path: c.req.path, + route, + status, + durationMs, + userAgent: c.req.header('user-agent'), + ...(userId && { userId }), + } + const message = '{method} {path} {status} in {durationMs} ms' + + if (status >= 500) httpLogger.error(message, properties) + else if (status >= 400) httpLogger.warn(message, properties) + // The container healthcheck hits /api/health every 10 s. + else if (c.req.path === '/api/health') httpLogger.debug(message, properties) + else httpLogger.info(message, properties) }) // Every API route lives under /api: in production nginx serves the SPA on the diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 04cbdb3..0b2ed5b 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -1,11 +1,25 @@ +import { dispose } from '@logtape/logtape' + import { createApp } from '@/app' -import { logger } from '@/lib/logger' +import { configureLogging, logger } from '@/lib/logger' +import { configureMetrics, shutdownMetrics } from '@/lib/metrics' + +await configureLogging() +const metricsEnabled = configureMetrics() const port = Number(process.env.PORT ?? 4100) const app = createApp() -logger.info({ port }, 'api listening') +logger.info('api listening on port {port}', { port, metricsEnabled }) + +// Flush buffered logs and the last metrics batch before exiting. +for (const signal of ['SIGINT', 'SIGTERM'] as const) { + process.once(signal, async () => { + await Promise.allSettled([shutdownMetrics(), dispose()]) + process.exit(0) + }) +} export default { port, diff --git a/apps/api/src/lib/auth.ts b/apps/api/src/lib/auth.ts index d28da11..9730dc2 100644 --- a/apps/api/src/lib/auth.ts +++ b/apps/api/src/lib/auth.ts @@ -55,7 +55,7 @@ export const auth = betterAuth({ to: email, ...passwordResetEmail({ otp, expiresInMinutes: OTP_EXPIRES_IN_SECONDS / 60 }), }).catch((error: unknown) => { - logger.error({ err: error, to: email }, 'failed to send the password reset email') + logger.error('failed to send the password reset email', { error, to: email }) }) }, }), diff --git a/apps/api/src/lib/logger.ts b/apps/api/src/lib/logger.ts index 03fda00..f8d43ad 100644 --- a/apps/api/src/lib/logger.ts +++ b/apps/api/src/lib/logger.ts @@ -1,21 +1,99 @@ -import { pino } from 'pino' +import { AsyncLocalStorage } from 'node:async_hooks' + +import { + configure, + getConsoleSink, + getLogger, + isLogLevel, + jsonLinesFormatter, + type Logger, + type LogLevel, + type Sink, +} from '@logtape/logtape' +import { getOpenTelemetrySink } from '@logtape/otel' +import { getPrettyFormatter } from '@logtape/pretty' + +import { getOpenObserveConfig, SERVICE_NAME } from '@/lib/openobserve' + +export type { Logger } from '@logtape/logtape' const isProduction = process.env.NODE_ENV === 'production' /** - * Single logger instance for the whole API. Import it wherever you need to log — - * never use `console.log` in the backend. + * Root logger of the API (category `superlist`). Import it wherever you need to + * log — never use `console.log` in the backend. Inside a request, prefer + * `c.get('logger')`; either way every record emitted while the request runs + * carries its `requestId` (see `withContext` in `app.ts`). + * + * LogTape loggers are inert until `configureLogging()` runs (from `index.ts`), + * so tests that import modules using it stay silent. */ -export const logger = pino({ - level: process.env.LOG_LEVEL || (isProduction ? 'info' : 'debug'), - ...(isProduction - ? {} - : { - transport: { - target: 'pino-pretty', - options: { colorize: true, translateTime: 'HH:MM:ss', ignore: 'pid,hostname' }, - }, - }), -}) +export const logger: Logger = getLogger(['superlist']) -export type Logger = typeof logger +/** Accepts LogTape levels plus Pino-style aliases (`warn`) for `LOG_LEVEL`. */ +function resolveLevel(value: string | undefined): LogLevel { + const level = value?.trim().toLowerCase() + if (level === 'warn') return 'warning' + if (level && isLogLevel(level)) return level + + return isProduction ? 'info' : 'debug' +} + +/** + * Ships logs to OpenObserve over OTLP/HTTP (`/api//v1/logs`), routed to a + * stream by the `stream-name` header. Returns `null` when it is not configured. + */ +function openObserveSink(): Sink | null { + const config = getOpenObserveConfig() + if (!config) return null + + return getOpenTelemetrySink({ + serviceName: SERVICE_NAME, + // Nested property objects become JSON instead of util.inspect output. + objectRenderer: 'json', + otlpExporterConfig: { + url: `${config.otlpBaseUrl}/v1/logs`, + headers: { Authorization: config.authorization, 'stream-name': config.logStream }, + }, + }) +} + +/** + * Configures LogTape once, at startup: console output (pretty in development, + * JSON lines in production) plus OpenObserve when `OPENOBSERVE_URL` is set. + * Call `dispose()` from `@logtape/logtape` on shutdown to flush pending records. + */ +export async function configureLogging(): Promise { + const consoleSink = getConsoleSink({ + formatter: isProduction + ? jsonLinesFormatter + : getPrettyFormatter({ + properties: true, + categoryWidth: 16, + wordWrap: false, + // Interpolate strings bare ("GET /api/lists") instead of quoted. + value: 'bare', + }), + }) + const openObserve = openObserveSink() + + const sinks: Record = { console: consoleSink } + if (openObserve) sinks.openObserve = openObserve + + await configure({ + sinks, + contextLocalStorage: new AsyncLocalStorage(), + loggers: [ + { + category: ['superlist'], + sinks: Object.keys(sinks), + lowestLevel: resolveLevel(process.env.LOG_LEVEL), + }, + { category: ['logtape', 'meta'], sinks: ['console'], lowestLevel: 'warning' }, + ], + }) + + if (openObserve) { + logger.info('shipping logs to OpenObserve at {url}', { url: process.env.OPENOBSERVE_URL }) + } +} diff --git a/apps/api/src/lib/mailer.ts b/apps/api/src/lib/mailer.ts index b3fb2fb..c8f1896 100644 --- a/apps/api/src/lib/mailer.ts +++ b/apps/api/src/lib/mailer.ts @@ -24,17 +24,18 @@ function getClient(): Resend | null { /** * Sends an email through Resend. Without `RESEND_API_KEY` (local development) - * it logs the message with Pino instead of sending it, so invitation links are + * it logs the message instead of sending it, so invitation links are * still discoverable in the terminal. */ export async function sendEmail(email: Email): Promise { const resend = getClient() if (!resend) { - logger.info( - { to: email.to, subject: email.subject, text: email.text }, - 'email not sent (RESEND_API_KEY is not set) — logging payload instead', - ) + logger.info('email not sent (RESEND_API_KEY is not set) — logging payload instead', { + to: email.to, + subject: email.subject, + text: email.text, + }) return } diff --git a/apps/api/src/lib/metrics.ts b/apps/api/src/lib/metrics.ts new file mode 100644 index 0000000..c639ee1 --- /dev/null +++ b/apps/api/src/lib/metrics.ts @@ -0,0 +1,92 @@ +import { type Histogram, metrics, type UpDownCounter } from '@opentelemetry/api' +import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http' +import { resourceFromAttributes } from '@opentelemetry/resources' +import { + AggregationTemporality, + AggregationType, + MeterProvider, + PeriodicExportingMetricReader, +} from '@opentelemetry/sdk-metrics' + +import { getOpenObserveConfig, SERVICE_NAME } from '@/lib/openobserve' + +const DEFAULT_EXPORT_INTERVAL_MS = 15_000 + +/** Bucket bounds (seconds) of the request duration histogram: 5 ms … 10 s. */ +const DURATION_BUCKETS = [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10] + +let provider: MeterProvider | null = null + +/** + * Starts exporting metrics to OpenObserve (`/api//v1/metrics`) every + * `METRICS_EXPORT_INTERVAL_MS` (15 s by default). Without `OPENOBSERVE_URL` the + * global meter stays a no-op, so instruments cost nothing in tests or locally. + */ +export function configureMetrics(): boolean { + const config = getOpenObserveConfig() + if (!config) return false + + const exporter = new OTLPMetricExporter({ + url: `${config.otlpBaseUrl}/v1/metrics`, + headers: { Authorization: config.authorization }, + // Cumulative is what OpenObserve's PromQL (rate, histogram_quantile) expects. + temporalityPreference: AggregationTemporality.CUMULATIVE, + }) + + provider = new MeterProvider({ + resource: resourceFromAttributes({ 'service.name': SERVICE_NAME }), + views: [ + { + instrumentName: 'http.server.request.duration', + aggregation: { + type: AggregationType.EXPLICIT_BUCKET_HISTOGRAM, + options: { boundaries: DURATION_BUCKETS }, + }, + }, + ], + readers: [ + new PeriodicExportingMetricReader({ + exporter, + exportIntervalMillis: + Number(process.env.METRICS_EXPORT_INTERVAL_MS) || DEFAULT_EXPORT_INTERVAL_MS, + }), + ], + }) + metrics.setGlobalMeterProvider(provider) + + return true +} + +/** Flushes the last batch and stops the exporter (call on shutdown). */ +export async function shutdownMetrics(): Promise { + await provider?.shutdown() +} + +type HttpInstruments = { + duration: Histogram + activeRequests: UpDownCounter +} + +let http: HttpInstruments | null = null + +/** + * HTTP server instruments, following the OpenTelemetry semantic conventions. + * Created lazily so they bind to the provider set by `configureMetrics()`. + */ +export function httpMetrics(): HttpInstruments { + if (!http) { + const meter = metrics.getMeter(SERVICE_NAME) + http = { + duration: meter.createHistogram('http.server.request.duration', { + description: 'Duration of HTTP server requests.', + unit: 's', + }), + activeRequests: meter.createUpDownCounter('http.server.active_requests', { + description: 'Number of HTTP server requests in flight.', + unit: '{request}', + }), + } + } + + return http +} diff --git a/apps/api/src/lib/openobserve.ts b/apps/api/src/lib/openobserve.ts new file mode 100644 index 0000000..54402f3 --- /dev/null +++ b/apps/api/src/lib/openobserve.ts @@ -0,0 +1,30 @@ +/** Service name reported to OpenObserve for logs and metrics. */ +export const SERVICE_NAME = 'superlist-api' + +export type OpenObserveConfig = { + /** Base of the OTLP/HTTP endpoints: `/api/` (append `/v1/logs`, `/v1/metrics`). */ + otlpBaseUrl: string + /** Basic auth (user email + password) for every OTLP request. */ + authorization: string + /** Stream that receives the logs (`stream-name` header); metrics get one stream per metric. */ + logStream: string +} + +/** + * Reads the OpenObserve settings from the environment, or `null` when + * `OPENOBSERVE_URL` is not set (logs and metrics then stay local). + */ +export function getOpenObserveConfig(): OpenObserveConfig | null { + const baseUrl = process.env.OPENOBSERVE_URL?.trim().replace(/\/+$/, '') + if (!baseUrl) return null + + const org = process.env.OPENOBSERVE_ORG || 'default' + const user = process.env.OPENOBSERVE_USER ?? '' + const password = process.env.OPENOBSERVE_PASSWORD ?? '' + + return { + otlpBaseUrl: `${baseUrl}/api/${org}`, + authorization: `Basic ${btoa(`${user}:${password}`)}`, + logStream: process.env.OPENOBSERVE_STREAM || 'superlist', + } +} diff --git a/apps/api/src/lib/problem-details.ts b/apps/api/src/lib/problem-details.ts index 067dcd3..790d614 100644 --- a/apps/api/src/lib/problem-details.ts +++ b/apps/api/src/lib/problem-details.ts @@ -25,7 +25,7 @@ export function errorHandler(error: Error, c: Context) { ) } - logger.error({ err: error, path: c.req.path }, 'unhandled error') + logger.error('unhandled error on {path}', { error, path: c.req.path }) return problemResponse( c, diff --git a/apps/api/src/modules/invitations/create/use-case.ts b/apps/api/src/modules/invitations/create/use-case.ts index ea1bc77..cb351f4 100644 --- a/apps/api/src/modules/invitations/create/use-case.ts +++ b/apps/api/src/modules/invitations/create/use-case.ts @@ -137,7 +137,7 @@ export class CreateInvitation { // Best effort: the person already sees the list, so a mail failure is not fatal. await this.mailer(message).catch((error: unknown) => { - logger.warn({ err: error, to: email }, 'could not send the invitation email') + logger.warn('could not send the invitation email', { error, to: email }) }) return Ok({ status: 'added', email }) @@ -148,7 +148,7 @@ export class CreateInvitation { } catch (error) { // Without the email the invitee cannot know about the list: undo everything. await this.db.shoppingListInvitation.delete({ where: { id: invitation.id } }) - logger.error({ err: error, to: email }, 'failed to send the invitation email') + logger.error('failed to send the invitation email', { error, to: email }) return Failure( problems.unavailable('No pudimos enviar la invitación por correo. Inténtalo de nuevo.'), diff --git a/apps/api/src/modules/voice/split/use-case.ts b/apps/api/src/modules/voice/split/use-case.ts index 7893a88..4c8c6e0 100644 --- a/apps/api/src/modules/voice/split/use-case.ts +++ b/apps/api/src/modules/voice/split/use-case.ts @@ -47,7 +47,10 @@ export class SplitVoiceText { } private fallback(text: string, reason: string): Result { - this.logger.warn({ reason, textLength: text.length }, 'voice split: using the fallback split') + this.logger.warn('voice split: using the fallback split ({reason})', { + reason, + textLength: text.length, + }) return Ok({ items: fallbackSplit(text) }) } diff --git a/bun.lock b/bun.lock index e9cd4e4..bba1e16 100644 --- a/bun.lock +++ b/bun.lock @@ -16,14 +16,19 @@ "dependencies": { "@better-auth/passkey": "1.7.7", "@hono/zod-validator": "^0.9.1", + "@logtape/logtape": "^2.4.2", + "@logtape/otel": "^2.4.2", + "@logtape/pretty": "^2.4.2", + "@opentelemetry/api": "1.9.0", + "@opentelemetry/exporter-metrics-otlp-http": "0.208.0", + "@opentelemetry/resources": "2.2.0", + "@opentelemetry/sdk-metrics": "2.2.0", "@prisma/adapter-pg": "^7.10.0", "@prisma/client": "^7.10.0", "@superlist/shared": "workspace:*", "better-auth": "^1.7.7", "hono": "^4.13.13", "pg": "^8.23.1", - "pino": "^10.4.0", - "pino-pretty": "^13.2.0", "resend": "^6.32.1", "zod": "^4.6.7", }, @@ -344,6 +349,10 @@ "@fontsource-variable/geist": ["@fontsource-variable/geist@5.3.0", "", {}, "sha512-j0m+vLQuG5XAYoHtGCVu0spvlGreR3EzpECUVzkFmI1mTVnAO38l/NEPDCFgZ177JxzYJCLSmTQibIiYPilGrA=="], + "@grpc/grpc-js": ["@grpc/grpc-js@1.14.7", "", { "dependencies": { "@grpc/proto-loader": "^0.8.0", "@js-sdsl/ordered-map": "^4.4.2" } }, "sha512-W4W/fcBMGRVtG6dW2c7cw2mnpS3hvbBd+oQXjh2iYFTZDk1JJmcNqkM5KSaPubQpamlUUurrlb7G1s9NJeERmQ=="], + + "@grpc/proto-loader": ["@grpc/proto-loader@0.8.1", "", { "dependencies": { "lodash.camelcase": "^4.3.0", "long": "^5.0.0", "protobufjs": "^7.5.5", "yargs": "^17.7.2" }, "bin": { "proto-loader-gen-types": "build/bin/proto-loader-gen-types.js" } }, "sha512-wtF6h+DY6M3YaDBPAmvuuA6jV8Sif9MjtOI5euKFWRgCDl5PeDpPsHR9u2l6St5ceY8AZgoNDww5+HvEsXFsGg=="], + "@hexagon/base64": ["@hexagon/base64@1.1.28", "", {}, "sha512-lhqDEAvWixy3bZ+UOYbPwUbBkwBq5C1LAJ/xPC8Oi+lL54oyakv/npbA0aU2hgCsx/1NUd4IBvV03+aUBWxerw=="], "@hono/node-server": ["@hono/node-server@1.19.9", "", { "peerDependencies": { "hono": "^4" } }, "sha512-vHL6w3ecZsky+8P5MD+eFfaGTyCeOHUIFYMGpQGbrBTSmNNoxv0if69rEZ5giu36weC5saFuznL411gRX7bJDw=="], @@ -368,12 +377,20 @@ "@jridgewell/trace-mapping": ["@jridgewell/trace-mapping@0.3.31", "", { "dependencies": { "@jridgewell/resolve-uri": "^3.1.0", "@jridgewell/sourcemap-codec": "^1.4.14" } }, "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw=="], + "@js-sdsl/ordered-map": ["@js-sdsl/ordered-map@4.4.2", "", {}, "sha512-iUKgm52T8HOE/makSxjqoWhe95ZJA1/G1sYsGev2JDKUSS14KAgg1LHb+Ba+IPow0xflbnSkOsZcO08C7w1gYw=="], + "@kobalte/core": ["@kobalte/core@0.13.14", "", { "dependencies": { "@floating-ui/dom": "^1.5.1", "@internationalized/number": "^3.2.1", "@kobalte/utils": "^0.9.2", "@solid-primitives/props": "^3.1.8", "@solid-primitives/resize-observer": "^2.0.26", "solid-presence": "^0.2.0", "solid-prevent-scroll": "^0.1.11" }, "peerDependencies": { "solid-js": "^1.9.8" } }, "sha512-SBVB1lnvYbYt2x3t7fG0lo5fGLEbHQ6PII3NDPva8vD5e2v53On84ZVQiuIk0XI/55R4GQhden7Yem+R/XR8uQ=="], "@kobalte/utils": ["@kobalte/utils@0.9.2", "", { "dependencies": { "@solid-primitives/event-listener": "^2.2.14", "@solid-primitives/keyed": "^1.2.0", "@solid-primitives/map": "^0.4.7", "@solid-primitives/media": "^2.2.4", "@solid-primitives/props": "^3.1.8", "@solid-primitives/refs": "^1.0.5", "@solid-primitives/utils": "^6.2.1" }, "peerDependencies": { "solid-js": "^1.8.8" } }, "sha512-jRVXr+zsVHxzDXRoh+CDeXzvCsFJ6uiHhqqNQ26Cw9ZsZ3D6nqPUBt1gGVtj2ZPmRL3a9Uk1v8D1aJ8/I12Dow=="], "@levischuck/tiny-cbor": ["@levischuck/tiny-cbor@0.2.11", "", {}, "sha512-llBRm4dT4Z89aRsm6u2oEZ8tfwL/2l6BwpZ7JcyieouniDECM5AqNgr/y08zalEIvW3RSK4upYyybDcmjXqAow=="], + "@logtape/logtape": ["@logtape/logtape@2.4.2", "", {}, "sha512-YJyC1gEMgWmTqJTRtKkjgasEbi8/0gP7Dj8n6bL46gQIAhpTY8uXJ+1QYMOgF5asotlGMvy3G7ejXUe45Yd1MQ=="], + + "@logtape/otel": ["@logtape/otel@2.4.2", "", { "dependencies": { "@opentelemetry/api": "^1.9.0", "@opentelemetry/api-logs": "^0.208.0", "@opentelemetry/exporter-logs-otlp-grpc": "^0.208.0", "@opentelemetry/exporter-logs-otlp-http": "^0.208.0", "@opentelemetry/exporter-logs-otlp-proto": "^0.208.0", "@opentelemetry/otlp-exporter-base": "^0.208.0", "@opentelemetry/resources": "^2.2.0", "@opentelemetry/sdk-logs": "^0.208.0", "@opentelemetry/semantic-conventions": "^1.38.0" }, "peerDependencies": { "@logtape/logtape": "^2.4.2" } }, "sha512-65xTJ1MdaUmegfqVEUil2btaMv//gqe4v2Nxip1Zh2kuC20jMcJYoxVZZqIJzkZpwzwzUFBFvj4/j1TNaQE/4A=="], + + "@logtape/pretty": ["@logtape/pretty@2.4.2", "", { "peerDependencies": { "@logtape/logtape": "^2.4.2" } }, "sha512-WcsJYsBwjL2DypJO4vJSZ7MAgbbEIm7//JE1G61kCV7ttiPqiX+5e+IB4h01bBdTE8FH2IkEIC4dMss7SwHPTg=="], + "@modelcontextprotocol/sdk": ["@modelcontextprotocol/sdk@1.32.1", "", { "dependencies": { "@hono/node-server": "^1.19.9 || ^2.0.5", "ajv": "^8.17.1", "ajv-formats": "^3.0.1", "content-type": "^1.0.5", "cors": "^2.8.5", "cross-spawn": "^7.0.5", "eventsource": "^3.0.2", "eventsource-parser": "^3.0.0", "express": "^5.2.1", "express-rate-limit": "^8.2.1", "hono": "^4.11.4", "jose": "^6.1.3", "json-schema-typed": "^8.0.2", "pkce-challenge": "^5.0.0", "raw-body": "^3.0.0", "zod": "^3.25 || ^4.0", "zod-to-json-schema": "^3.25.1" }, "peerDependencies": { "@cfworker/json-schema": "^4.1.1" }, "optionalPeers": ["@cfworker/json-schema"] }, "sha512-2DdE+SJDtzLEEWzY1ZjY7Q+VcPhcV1KisD3zI4u0XZyktsjHum1mwbMI+JaulUBi2OZk+KJAi2uPXzxichPkdw=="], "@napi-rs/lzma-linux-x64-gnu": ["@napi-rs/lzma-linux-x64-gnu@1.5.1", "", { "os": "linux", "cpu": "x64" }, "sha512-oTXEIha4SsuXdTA4Iyskj0kpdx2yVXdhd75c2v3xGrHFfVMsbhTPZU/nMPL4sWKo4pBHm3aucLaqGlF696dTyQ=="], @@ -388,6 +405,34 @@ "@nodelib/fs.walk": ["@nodelib/fs.walk@1.2.8", "", { "dependencies": { "@nodelib/fs.scandir": "2.1.5", "fastq": "^1.6.0" } }, "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg=="], + "@opentelemetry/api": ["@opentelemetry/api@1.9.0", "", {}, "sha512-3giAOQvZiH5F9bMlMiv8+GSPMeqg0dbaeo58/0SlA9sxSqZhnUtxzX9/2FzyhS9sWQf5S0GJE0AKBrFqjpeYcg=="], + + "@opentelemetry/api-logs": ["@opentelemetry/api-logs@0.208.0", "", { "dependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-CjruKY9V6NMssL/T1kAFgzosF1v9o6oeN+aX5JB/C/xPNtmgIJqcXHG7fA82Ou1zCpWGl4lROQUKwUNE1pMCyg=="], + + "@opentelemetry/core": ["@opentelemetry/core@2.2.0", "", { "dependencies": { "@opentelemetry/semantic-conventions": "^1.29.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, "sha512-FuabnnUm8LflnieVxs6eP7Z383hgQU4W1e3KJS6aOG3RxWxcHyBxH8fDMHNgu/gFx/M2jvTOW/4/PHhLz6bjWw=="], + + "@opentelemetry/exporter-logs-otlp-grpc": ["@opentelemetry/exporter-logs-otlp-grpc@0.208.0", "", { "dependencies": { "@grpc/grpc-js": "^1.7.1", "@opentelemetry/core": "2.2.0", "@opentelemetry/otlp-exporter-base": "0.208.0", "@opentelemetry/otlp-grpc-exporter-base": "0.208.0", "@opentelemetry/otlp-transformer": "0.208.0", "@opentelemetry/sdk-logs": "0.208.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-AmZDKFzbq/idME/yq68M155CJW1y056MNBekH9OZewiZKaqgwYN4VYfn3mXVPftYsfrCM2r4V6tS8H2LmfiDCg=="], + + "@opentelemetry/exporter-logs-otlp-http": ["@opentelemetry/exporter-logs-otlp-http@0.208.0", "", { "dependencies": { "@opentelemetry/api-logs": "0.208.0", "@opentelemetry/core": "2.2.0", "@opentelemetry/otlp-exporter-base": "0.208.0", "@opentelemetry/otlp-transformer": "0.208.0", "@opentelemetry/sdk-logs": "0.208.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-jOv40Bs9jy9bZVLo/i8FwUiuCvbjWDI+ZW13wimJm4LjnlwJxGgB+N/VWOZUTpM+ah/awXeQqKdNlpLf2EjvYg=="], + + "@opentelemetry/exporter-logs-otlp-proto": ["@opentelemetry/exporter-logs-otlp-proto@0.208.0", "", { "dependencies": { "@opentelemetry/api-logs": "0.208.0", "@opentelemetry/core": "2.2.0", "@opentelemetry/otlp-exporter-base": "0.208.0", "@opentelemetry/otlp-transformer": "0.208.0", "@opentelemetry/resources": "2.2.0", "@opentelemetry/sdk-logs": "0.208.0", "@opentelemetry/sdk-trace-base": "2.2.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-Wy8dZm16AOfM7yddEzSFzutHZDZ6HspKUODSUJVjyhnZFMBojWDjSNgduyCMlw6qaxJYz0dlb0OEcb4Eme+BfQ=="], + + "@opentelemetry/exporter-metrics-otlp-http": ["@opentelemetry/exporter-metrics-otlp-http@0.208.0", "", { "dependencies": { "@opentelemetry/core": "2.2.0", "@opentelemetry/otlp-exporter-base": "0.208.0", "@opentelemetry/otlp-transformer": "0.208.0", "@opentelemetry/resources": "2.2.0", "@opentelemetry/sdk-metrics": "2.2.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-QZ3TrI90Y0i1ezWQdvreryjY0a5TK4J9gyDLIyhLBwV+EQUvyp5wR7TFPKCAexD4TDSWM0t3ulQDbYYjVtzTyA=="], + + "@opentelemetry/otlp-exporter-base": ["@opentelemetry/otlp-exporter-base@0.208.0", "", { "dependencies": { "@opentelemetry/core": "2.2.0", "@opentelemetry/otlp-transformer": "0.208.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-gMd39gIfVb2OgxldxUtOwGJYSH8P1kVFFlJLuut32L6KgUC4gl1dMhn+YC2mGn0bDOiQYSk/uHOdSjuKp58vvA=="], + + "@opentelemetry/otlp-grpc-exporter-base": ["@opentelemetry/otlp-grpc-exporter-base@0.208.0", "", { "dependencies": { "@grpc/grpc-js": "^1.7.1", "@opentelemetry/core": "2.2.0", "@opentelemetry/otlp-exporter-base": "0.208.0", "@opentelemetry/otlp-transformer": "0.208.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-fGvAg3zb8fC0oJAzfz7PQppADI2HYB7TSt/XoCaBJFi1mSquNUjtHXEoviMgObLAa1NRIgOC1lsV1OUKi+9+lQ=="], + + "@opentelemetry/otlp-transformer": ["@opentelemetry/otlp-transformer@0.208.0", "", { "dependencies": { "@opentelemetry/api-logs": "0.208.0", "@opentelemetry/core": "2.2.0", "@opentelemetry/resources": "2.2.0", "@opentelemetry/sdk-logs": "0.208.0", "@opentelemetry/sdk-metrics": "2.2.0", "@opentelemetry/sdk-trace-base": "2.2.0", "protobufjs": "^7.3.0" }, "peerDependencies": { "@opentelemetry/api": "^1.3.0" } }, "sha512-DCFPY8C6lAQHUNkzcNT9R+qYExvsk6C5Bto2pbNxgicpcSWbe2WHShLxkOxIdNcBiYPdVHv/e7vH7K6TI+C+fQ=="], + + "@opentelemetry/resources": ["@opentelemetry/resources@2.2.0", "", { "dependencies": { "@opentelemetry/core": "2.2.0", "@opentelemetry/semantic-conventions": "^1.29.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.3.0 <1.10.0" } }, "sha512-1pNQf/JazQTMA0BiO5NINUzH0cbLbbl7mntLa4aJNmCCXSj0q03T5ZXXL0zw4G55TjdL9Tz32cznGClf+8zr5A=="], + + "@opentelemetry/sdk-logs": ["@opentelemetry/sdk-logs@0.208.0", "", { "dependencies": { "@opentelemetry/api-logs": "0.208.0", "@opentelemetry/core": "2.2.0", "@opentelemetry/resources": "2.2.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.4.0 <1.10.0" } }, "sha512-QlAyL1jRpOeaqx7/leG1vJMp84g0xKP6gJmfELBpnI4O/9xPX+Hu5m1POk9Kl+veNkyth5t19hRlN6tNY1sjbA=="], + + "@opentelemetry/sdk-metrics": ["@opentelemetry/sdk-metrics@2.2.0", "", { "dependencies": { "@opentelemetry/core": "2.2.0", "@opentelemetry/resources": "2.2.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.9.0 <1.10.0" } }, "sha512-G5KYP6+VJMZzpGipQw7Giif48h6SGQ2PFKEYCybeXJsOCB4fp8azqMAAzE5lnnHK3ZVwYQrgmFbsUJO/zOnwGw=="], + + "@opentelemetry/sdk-trace-base": ["@opentelemetry/sdk-trace-base@2.2.0", "", { "dependencies": { "@opentelemetry/core": "2.2.0", "@opentelemetry/resources": "2.2.0", "@opentelemetry/semantic-conventions": "^1.29.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.3.0 <1.10.0" } }, "sha512-xWQgL0Bmctsalg6PaXExmzdedSp3gyKV8mQBwK/j9VGdCDu2fmXIb2gAehBKbkXCpJ4HPkgv3QfoJWRT4dHWbw=="], + "@opentelemetry/semantic-conventions": ["@opentelemetry/semantic-conventions@1.43.0", "", {}, "sha512-eSYWTm620tTk45EKSedaUL8MFYI8hW164hIXsgIHyxu3VobUB3fFCu5t0hQby6OoWRPsG1KkKUG2M5UadiLiVg=="], "@oxc-project/types": ["@oxc-project/types@0.153.0", "", {}, "sha512-jSNrRIyvPVLL5E1z/tS5zLAprosGz/FuI1PWwEOz59j3E4TTTzSpqKb/RDGqJhhW0QHYISGXxq582wGx6T11Tw=="], @@ -418,8 +463,6 @@ "@peculiar/x509": ["@peculiar/x509@1.14.3", "", { "dependencies": { "@peculiar/asn1-cms": "^2.6.0", "@peculiar/asn1-csr": "^2.6.0", "@peculiar/asn1-ecc": "^2.6.0", "@peculiar/asn1-pkcs9": "^2.6.0", "@peculiar/asn1-rsa": "^2.6.0", "@peculiar/asn1-schema": "^2.6.0", "@peculiar/asn1-x509": "^2.6.0", "pvtsutils": "^1.3.6", "reflect-metadata": "^0.2.2", "tslib": "^2.8.1", "tsyringe": "^4.10.0" } }, "sha512-C2Xj8FZ0uHWeCXXqX5B4/gVFQmtSkiuOolzAgutjTfseNOHT3pUjljDZsTSxXFGgio54bCzVFqmEOUrIVk8RDA=="], - "@pinojs/redact": ["@pinojs/redact@0.4.0", "", {}, "sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg=="], - "@prisma/adapter-pg": ["@prisma/adapter-pg@7.10.0", "", { "dependencies": { "@prisma/driver-adapter-utils": "7.10.0", "@types/pg": "^8.16.0", "pg": "^8.16.3", "postgres-array": "3.0.4" } }, "sha512-N7nwSor0HO1Kz6xBv0TPAjAPysKK0fac6p4fVN3ensLOuzc/83Fgmln5k92eK/cvzqdkSR/2kkAqlbcdwVrwpw=="], "@prisma/client": ["@prisma/client@7.10.0", "", { "dependencies": { "@prisma/client-runtime-utils": "7.10.0" }, "peerDependencies": { "prisma": "*", "typescript": ">=5.4.0" }, "optionalPeers": ["prisma", "typescript"] }, "sha512-Ubw/QS9JGIBSBUsyxAUQuK/Jcu0Tsva7le7QbLd91Kix9yJvYDdj5QkwgEbbZniH80dd+sziQcALPc+HnvQC8Q=="], @@ -448,6 +491,24 @@ "@prisma/studio-core": ["@prisma/studio-core@0.33.0", "", { "dependencies": { "@radix-ui/react-toggle": "1.1.10", "@visx/curve": "4.0.1-alpha.0", "@visx/event": "4.0.1-alpha.0", "@visx/grid": "4.0.1-alpha.0", "@visx/group": "4.0.1-alpha.0", "@visx/responsive": "4.0.1-alpha.0", "@visx/scale": "4.0.1-alpha.0", "@visx/shape": "4.0.1-alpha.0", "d3-array": "3.2.4", "d3-shape": "3.2.0", "elkjs": "0.11.1" }, "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" } }, "sha512-V2fX/nKEymNTrHXwfP26PGjoLStO35Ogu+ex7CFJbLrMYEcZxxZpiSNOs7px23Hk5mzLWvM5RsqG6Ka+rha+wg=="], + "@protobufjs/aspromise": ["@protobufjs/aspromise@1.1.2", "", {}, "sha512-j+gKExEuLmKwvz3OgROXtrJ2UG2x8Ch2YZUxahh+s1F2HZ+wAceUNLkvy6zKCPVRkU++ZWQrdxsUeQXmcg4uoQ=="], + + "@protobufjs/base64": ["@protobufjs/base64@1.1.2", "", {}, "sha512-AZkcAA5vnN/v4PDqKyMR5lx7hZttPDgClv83E//FMNhR2TMcLUhfRUBHCmSl0oi9zMgDDqRUJkSxO3wm85+XLg=="], + + "@protobufjs/codegen": ["@protobufjs/codegen@2.0.5", "", {}, "sha512-zgXFLzW3Ap33e6d0Wlj4MGIm6Ce8O89n/apUaGNB/jx+hw+ruWEp7EwGUshdLKVRCxZW12fp9r40E1mQrf/34g=="], + + "@protobufjs/eventemitter": ["@protobufjs/eventemitter@1.1.1", "", {}, "sha512-vW1GmwMZNnL+gMRaovlh9yZX74kc+TTU3FObkkurpMaRtBfLP3ldjS9KQWlwZgraRE0+dheEEoAxdzcJQ8eXZg=="], + + "@protobufjs/fetch": ["@protobufjs/fetch@1.1.1", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.1" } }, "sha512-GpptLrs57adMSuHi3VNj0mAF8dwh36LMaYF6XyJ6JMWlVsc+t42tm1HSEDmOs3A8fC9yyeisgLhsTVQokOZ0zw=="], + + "@protobufjs/float": ["@protobufjs/float@1.0.2", "", {}, "sha512-Ddb+kVXlXst9d+R9PfTIxh1EdNkgoRe5tOX6t01f1lYWOvJnSPDBlG241QLzcyPdoNTsblLUdujGSE4RzrTZGQ=="], + + "@protobufjs/path": ["@protobufjs/path@1.1.2", "", {}, "sha512-6JOcJ5Tm08dOHAbdR3GrvP+yUUfkjG5ePsHYczMFLq3ZmMkAD98cDgcT2iA1lJ9NVwFd4tH/iSSoe44YWkltEA=="], + + "@protobufjs/pool": ["@protobufjs/pool@1.1.0", "", {}, "sha512-0kELaGSIDBKvcgS4zkjz1PeddatrjYcmMWOlAuAPwAeccUrPHdUqo/J6LiymHHEiJT5NrF1UVwxY14f+fy4WQw=="], + + "@protobufjs/utf8": ["@protobufjs/utf8@1.1.2", "", {}, "sha512-b1UQwcEZ4yCnMCD8DAL1VlbvBJE9/IX4FTIp7BG1xYpf29SLazLSrqUkj4w7Y5y7cCVP6E5tcqqcI0xemPkHug=="], + "@radix-ui/number": ["@radix-ui/number@1.1.3", "", {}, "sha512-Road2bidD0uu/1BGDOWNdPI06g0lIRy6IF9GZcIrDK2KGItfor8IQwQa+yM2ERgHM1MmHxaxpTzk0/Jp42lNfA=="], "@radix-ui/primitive": ["@radix-ui/primitive@1.2.0", "", {}, "sha512-KABY+VMIRPJL+Vyzv/335FEhXXD/xDv8BMb1kl48/aXJZMH0LtHCTx5ga5RnxaEP3nZHtmTLf1P9vanmFX46bw=="], @@ -904,8 +965,6 @@ "at-least-node": ["at-least-node@1.0.0", "", {}, "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg=="], - "atomic-sleep": ["atomic-sleep@1.0.0", "", {}, "sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ=="], - "atomically": ["atomically@1.7.0", "", {}, "sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w=="], "available-typed-arrays": ["available-typed-arrays@1.0.7", "", { "dependencies": { "possible-typed-array-names": "^1.0.0" } }, "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ=="], @@ -982,8 +1041,6 @@ "color-name": ["color-name@1.1.4", "", {}, "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA=="], - "colorette": ["colorette@2.0.20", "", {}, "sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w=="], - "commander": ["commander@14.0.3", "", {}, "sha512-H+y0Jo/T1RZ9qPP4Eh1pkcQcLRglraJaSLoyOtHxu6AapkjWVCy2Sit1QQ4x3Dng8qDlSsZEet7g5Pq06MvTgw=="], "common-tags": ["common-tags@1.8.2", "", {}, "sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA=="], @@ -1050,8 +1107,6 @@ "data-view-byte-offset": ["data-view-byte-offset@1.0.1", "", { "dependencies": { "call-bound": "^1.0.2", "es-errors": "^1.3.0", "is-data-view": "^1.0.1" } }, "sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ=="], - "dateformat": ["dateformat@4.6.3", "", {}, "sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA=="], - "debounce-fn": ["debounce-fn@4.0.0", "", { "dependencies": { "mimic-fn": "^3.0.0" } }, "sha512-8pYCQiL9Xdcg0UPSD3d+0KMlOjp+KGU5EPwYddgzQ7DATsg4fuUDjQtsYLmWjnk2obnNHgV3vE2Y4jejSOJVBQ=="], "debug": ["debug@4.4.3", "", { "dependencies": { "ms": "^2.1.3" } }, "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA=="], @@ -1112,8 +1167,6 @@ "encodeurl": ["encodeurl@2.0.0", "", {}, "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg=="], - "end-of-stream": ["end-of-stream@1.4.5", "", { "dependencies": { "once": "^1.4.0" } }, "sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg=="], - "enhanced-resolve": ["enhanced-resolve@5.26.0", "", { "dependencies": { "graceful-fs": "^4.2.4", "tapable": "^2.3.3" } }, "sha512-9vhedylFonb2YGogzUKX6+Ja72gOJbN1QHAqdrvqLwhdl/QWbKopzoUC9EbQNVsAns/bx/4uyqalrQAoy1IByw=="], "enquirer": ["enquirer@2.4.1", "", { "dependencies": { "ansi-colors": "^4.1.1", "strip-ansi": "^6.0.1" } }, "sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ=="], @@ -1170,8 +1223,6 @@ "fast-check": ["fast-check@3.23.2", "", { "dependencies": { "pure-rand": "^6.1.0" } }, "sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A=="], - "fast-copy": ["fast-copy@4.1.2", "", {}, "sha512-DUHggaYcouhy5I1LacDJ+JDSqGlumVJP2EAi5Nwt1pWPeLpSvIjkrY+x4fsoI1/+GlTyq+DM9zdgWCFSfqNODA=="], - "fast-decode-uri-component": ["fast-decode-uri-component@1.0.1", "", {}, "sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg=="], "fast-deep-equal": ["fast-deep-equal@3.1.3", "", {}, "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="], @@ -1182,8 +1233,6 @@ "fast-querystring": ["fast-querystring@1.1.2", "", { "dependencies": { "fast-decode-uri-component": "^1.0.1" } }, "sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg=="], - "fast-safe-stringify": ["fast-safe-stringify@2.1.1", "", {}, "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA=="], - "fast-sha256": ["fast-sha256@1.3.0", "", {}, "sha512-n11RGP/lrWEFI/bWdygLxhI+pVeo1ZYIVwvvPkW7azl/rOy+F3HYRZ2K5zeE9mmkhQppyv9sQFx0JM9UabnpPQ=="], "fast-uri": ["fast-uri@3.1.8", "", {}, "sha512-GZMtZUTNRpOVIECoXwLNZS5xUGE+mVNbTB8h/7Rwh2TFWcBQiPzTgyZi05BF9UMZKkLJv8XBRJTlU7zg8+ZfMg=="], @@ -1280,8 +1329,6 @@ "hasown": ["hasown@2.0.4", "", { "dependencies": { "function-bind": "^1.1.2" } }, "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A=="], - "help-me": ["help-me@5.0.0", "", {}, "sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg=="], - "hono": ["hono@4.13.13", "", {}, "sha512-CQ46U0ZkAGmbT/4UxdzzGJpacP2IeKgY4a5/tOI9AABbpOMfK739wfDXmv1usCk+3RkKj1hQy4/fjhiwa2xlrA=="], "http-errors": ["http-errors@2.0.1", "", { "dependencies": { "depd": "~2.0.0", "inherits": "~2.0.4", "setprototypeof": "~1.2.0", "statuses": "~2.0.2", "toidentifier": "~1.0.1" } }, "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ=="], @@ -1400,8 +1447,6 @@ "jose": ["jose@6.2.12", "", {}, "sha512-9NiFmJEex0sy2Dk58j2UGBSHgUs2ypF9eZSu4L6vjOX3Dp96Sw1F3uL+H+D1sx02jZZdzUT0HgvCy59CuvXcWw=="], - "joycon": ["joycon@3.1.1", "", {}, "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw=="], - "js-tokens": ["js-tokens@4.0.0", "", {}, "sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ=="], "jsesc": ["jsesc@3.1.0", "", { "bin": { "jsesc": "bin/jsesc" } }, "sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA=="], @@ -1450,6 +1495,8 @@ "lodash": ["lodash@4.17.21", "", {}, "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="], + "lodash.camelcase": ["lodash.camelcase@4.3.0", "", {}, "sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA=="], + "lodash.debounce": ["lodash.debounce@4.0.8", "", {}, "sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow=="], "log-symbols": ["log-symbols@6.0.0", "", { "dependencies": { "chalk": "^5.3.0", "is-unicode-supported": "^1.3.0" } }, "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw=="], @@ -1520,8 +1567,6 @@ "ohash": ["ohash@2.0.12", "", {}, "sha512-65S/5gk9YSsaRjcyf7Nfa6h/d3E8/1gslpXfI4W7Dxn/oap8IKRuNT5VXkLQ1YFKIEg4apRY4Pj6aiwFzrDdmw=="], - "on-exit-leak-free": ["on-exit-leak-free@2.1.2", "", {}, "sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA=="], - "on-finished": ["on-finished@2.4.1", "", { "dependencies": { "ee-first": "1.1.1" } }, "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg=="], "once": ["once@1.4.0", "", { "dependencies": { "wrappy": "1" } }, "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w=="], @@ -1582,14 +1627,6 @@ "picomatch": ["picomatch@4.0.7", "", {}, "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA=="], - "pino": ["pino@10.4.0", "", { "dependencies": { "@pinojs/redact": "^0.4.0", "atomic-sleep": "^1.0.0", "on-exit-leak-free": "^2.1.0", "pino-abstract-transport": "^3.0.0", "pino-std-serializers": "^7.0.0", "process-warning": "^5.0.0", "quick-format-unescaped": "^4.0.3", "real-require": "^1.0.0", "safe-stable-stringify": "^2.3.1", "sonic-boom": "^4.0.1", "thread-stream": "^4.0.0" }, "bin": { "pino": "bin.js" } }, "sha512-bk1ZMTwG/Vymx+zPoa28MhNzucFvXJWp3csrSuxuHPSMeUettaCoQ5Jvg07mtC4JGNpcfTwz41oVCnNgBK9+vA=="], - - "pino-abstract-transport": ["pino-abstract-transport@3.0.0", "", { "dependencies": { "split2": "^4.0.0" } }, "sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg=="], - - "pino-pretty": ["pino-pretty@13.2.0", "", { "dependencies": { "colorette": "^2.0.7", "dateformat": "^4.6.3", "fast-copy": "^4.0.0", "fast-safe-stringify": "^2.1.1", "help-me": "^5.0.0", "joycon": "^3.1.1", "minimist": "^1.2.6", "on-exit-leak-free": "^2.1.2", "pino-abstract-transport": "^3.0.0", "pump": "^3.0.3", "secure-json-parse": "^4.1.0", "sonic-boom": "^5.0.0", "strip-json-comments": "^5.0.3" }, "bin": { "pino-pretty": "bin.js" } }, "sha512-jjghD1ML+Di/WxjJDz6j6Y4FT7hIXOlb8h27AyJ+ohtAXJXH4PS/xkv7si+RCCIW59HMgZsMKTDgzdr0RhuRrg=="], - - "pino-std-serializers": ["pino-std-serializers@7.1.0", "", {}, "sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw=="], - "pkce-challenge": ["pkce-challenge@5.0.1", "", {}, "sha512-wQ0b/W4Fr01qtpHlqSqspcj3EhBvimsdh0KlHhH8HRZnMsEa0ea2fTULOXOS9ccQr3om+GcGRk4e+isrZWV8qQ=="], "pkg-types": ["pkg-types@2.3.3", "", { "dependencies": { "confbox": "^0.3.1", "exsolve": "^1.1.1", "pathe": "^2.0.3" } }, "sha512-j/lCFdcppV0JxWpCEITdbDltBxPP6cHT+yNJ6Go2OgoSA9518X847X9z0p6LtA4Nc16+eQzCZjRrWanTGvHJ5w=="], @@ -1624,15 +1661,13 @@ "prisma": ["prisma@7.10.0", "", { "dependencies": { "@prisma/config": "7.10.0", "@prisma/dev": "0.24.17", "@prisma/engines": "7.10.0", "@prisma/studio-core": "0.33.0", "mysql2": "3.15.3", "postgres": "3.4.7" }, "peerDependencies": { "better-sqlite3": ">=9.0.0", "typescript": ">=5.4.0" }, "optionalPeers": ["better-sqlite3", "typescript"], "bin": { "prisma": "build/index.js" } }, "sha512-o0ornyJOWgygVAzGCpr8PdXV8EJLHyVGDDUr/voBQt8Azzw8cYTByzzPGcA/m4tCkPcnJA8raEOv2CslsKhPEw=="], - "process-warning": ["process-warning@5.1.1", "", {}, "sha512-oCkNVj4OKnKEcocVBcDfiIugN1/cE6rgfT3nCtzeqZPA8+rIxMaQ0xXzIkGP8Gj2qUaP1UR7uhJ1VD8lUCpzCg=="], - "prompts": ["prompts@2.4.2", "", { "dependencies": { "kleur": "^3.0.3", "sisteransi": "^1.0.5" } }, "sha512-NxNv/kLguCA7p3jE8oL2aEBsrJWgAakBpgmgK6lpPWV+WuOmY6r2/zbAVnP+T8bQlA0nzHXSJSJW0Hq7ylaD2Q=="], "proper-lockfile": ["proper-lockfile@4.1.2", "", { "dependencies": { "graceful-fs": "^4.2.4", "retry": "^0.12.0", "signal-exit": "^3.0.2" } }, "sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA=="], - "proxy-addr": ["proxy-addr@2.0.8", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ=="], + "protobufjs": ["protobufjs@7.6.6", "", { "dependencies": { "@protobufjs/aspromise": "^1.1.2", "@protobufjs/base64": "^1.1.2", "@protobufjs/codegen": "^2.0.5", "@protobufjs/eventemitter": "^1.1.1", "@protobufjs/fetch": "^1.1.1", "@protobufjs/float": "^1.0.2", "@protobufjs/path": "^1.1.2", "@protobufjs/pool": "^1.1.0", "@protobufjs/utf8": "^1.1.1", "@types/node": ">=13.7.0", "long": "^5.3.2" } }, "sha512-dYDWdjSl5RNb7SgPxGQcRU+GtvP7s2fpkrY0r432PcOIaZ0/rBcxEZnQN67iJhFuQiVw754JDoPruPCNdGsbjg=="], - "pump": ["pump@3.0.4", "", { "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" } }, "sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA=="], + "proxy-addr": ["proxy-addr@2.0.8", "", { "dependencies": { "forwarded": "0.2.0", "ipaddr.js": "1.9.1" } }, "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ=="], "pure-rand": ["pure-rand@6.1.0", "", {}, "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA=="], @@ -1644,8 +1679,6 @@ "queue-microtask": ["queue-microtask@1.2.3", "", {}, "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A=="], - "quick-format-unescaped": ["quick-format-unescaped@4.0.4", "", {}, "sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg=="], - "radix-ui": ["radix-ui@1.8.0", "", { "dependencies": { "@radix-ui/primitive": "1.2.0", "@radix-ui/react-accessible-icon": "1.2.0", "@radix-ui/react-accordion": "1.3.0", "@radix-ui/react-alert-dialog": "1.2.0", "@radix-ui/react-arrow": "1.1.17", "@radix-ui/react-aspect-ratio": "1.2.0", "@radix-ui/react-avatar": "1.3.0", "@radix-ui/react-checkbox": "1.4.0", "@radix-ui/react-collapsible": "1.2.0", "@radix-ui/react-collection": "1.2.0", "@radix-ui/react-compose-refs": "1.1.5", "@radix-ui/react-context": "1.3.0", "@radix-ui/react-context-menu": "2.4.0", "@radix-ui/react-dialog": "1.3.0", "@radix-ui/react-direction": "1.2.0", "@radix-ui/react-dismissable-layer": "1.2.0", "@radix-ui/react-dropdown-menu": "2.2.0", "@radix-ui/react-focus-guards": "1.2.0", "@radix-ui/react-focus-scope": "1.3.0", "@radix-ui/react-form": "0.3.0", "@radix-ui/react-hover-card": "1.2.0", "@radix-ui/react-label": "2.1.17", "@radix-ui/react-menu": "2.2.0", "@radix-ui/react-menubar": "1.2.0", "@radix-ui/react-navigation-menu": "1.4.0", "@radix-ui/react-one-time-password-field": "0.2.0", "@radix-ui/react-password-toggle-field": "0.2.0", "@radix-ui/react-popover": "1.3.0", "@radix-ui/react-popper": "1.4.0", "@radix-ui/react-portal": "1.2.0", "@radix-ui/react-presence": "1.1.11", "@radix-ui/react-primitive": "2.2.0", "@radix-ui/react-progress": "1.2.0", "@radix-ui/react-radio-group": "1.5.0", "@radix-ui/react-roving-focus": "1.2.0", "@radix-ui/react-scroll-area": "1.4.0", "@radix-ui/react-select": "2.4.0", "@radix-ui/react-separator": "1.2.0", "@radix-ui/react-slider": "1.6.0", "@radix-ui/react-slot": "1.5.0", "@radix-ui/react-switch": "1.4.0", "@radix-ui/react-tabs": "1.2.0", "@radix-ui/react-toast": "1.3.0", "@radix-ui/react-toggle": "1.2.0", "@radix-ui/react-toggle-group": "1.2.0", "@radix-ui/react-toolbar": "1.2.0", "@radix-ui/react-tooltip": "1.4.0", "@radix-ui/react-use-callback-ref": "1.1.5", "@radix-ui/react-use-controllable-state": "1.3.0", "@radix-ui/react-use-effect-event": "0.0.5", "@radix-ui/react-use-escape-keydown": "1.1.6", "@radix-ui/react-use-is-hydrated": "0.1.3", "@radix-ui/react-use-layout-effect": "1.1.4", "@radix-ui/react-use-size": "1.1.5", "@radix-ui/react-visually-hidden": "1.2.13" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-d2p7l6XzZ9agJABImQYTFSbALCqaieTEXs2TmVNpT4cFam6RD91rsucu0VhMs45Oe35rQVWJk8PoDej0z/w3yg=="], "range-parser": ["range-parser@1.3.0", "", {}, "sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw=="], @@ -1672,8 +1705,6 @@ "readdirp": ["readdirp@5.1.1", "", {}, "sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA=="], - "real-require": ["real-require@1.0.0", "", {}, "sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g=="], - "recast": ["recast@0.23.21", "", { "dependencies": { "ast-types": "^0.16.1", "esprima": "~4.0.0", "source-map": "~0.6.1", "tiny-invariant": "^1.3.3", "tslib": "^2.0.1" } }, "sha512-mFAyJq9vUbSTARLZUvAEf1z3YxlvAwswbmxMx2mPA/MSm4KmpwvwvhsH/NIrZhyOuwD60Lzyw2qh83uCbgTPYw=="], "recharts": ["recharts@3.10.1", "", { "dependencies": { "@reduxjs/toolkit": "^1.9.0 || 2.x.x", "clsx": "^2.1.1", "decimal.js-light": "^2.5.1", "es-toolkit": "^1.39.3", "eventemitter3": "^5.0.1", "immer": "^11.1.8", "react-redux": "8.x.x || 9.x.x", "reselect": "5.2.0", "tiny-invariant": "^1.3.3", "use-sync-external-store": "^1.2.2", "victory-vendor": "^37.0.2" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-dom": "^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0", "react-is": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" } }, "sha512-QXFrvt6IVcw7eeZCoyXTwkIJAX3Dv1nyVhMicXJ47GsGDDpcN8z6o644DibE9XjpBTThtsomLKnTV6lc+cVFUA=="], @@ -1742,14 +1773,10 @@ "safe-regex2": ["safe-regex2@5.1.2", "", { "dependencies": { "ret": "~0.5.0" }, "bin": { "safe-regex2": "bin/safe-regex2.js" } }, "sha512-tAtCGFPPP02VroDVzp4daGi6bC7jWG+41D47GKf18FeH/ubvKQHT9VmhAkvtjNOmJwqtApzWeUpEhkyEYULvmw=="], - "safe-stable-stringify": ["safe-stable-stringify@2.5.0", "", {}, "sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA=="], - "safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="], "scheduler": ["scheduler@0.28.0", "", {}, "sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw=="], - "secure-json-parse": ["secure-json-parse@4.1.1", "", {}, "sha512-lnd81MQEZKjhW/Gd2TQqdd4XP6QYNdDW/EP+I7nTrFHP9y2LmaGPIHk9xsnzcOiEr1c39c/e84xFgGviQKBTRw=="], - "semver": ["semver@6.3.1", "", { "bin": { "semver": "bin/semver.js" } }, "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA=="], "send": ["send@1.2.1", "", { "dependencies": { "debug": "^4.4.3", "encodeurl": "^2.0.0", "escape-html": "^1.0.3", "etag": "^1.8.1", "fresh": "^2.0.0", "http-errors": "^2.0.1", "mime-types": "^3.0.2", "ms": "^2.1.3", "on-finished": "^2.4.1", "range-parser": "^1.2.1", "statuses": "^2.0.2" } }, "sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ=="], @@ -1806,8 +1833,6 @@ "solid-transition-group": ["solid-transition-group@0.2.3", "", { "dependencies": { "@solid-primitives/refs": "^1.0.5", "@solid-primitives/transition-group": "^1.0.2" }, "peerDependencies": { "solid-js": "^1.6.12" } }, "sha512-iB72c9N5Kz9ykRqIXl0lQohOau4t0dhel9kjwFvx81UZJbVwaChMuBuyhiZmK24b8aKEK0w3uFM96ZxzcyZGdg=="], - "sonic-boom": ["sonic-boom@4.2.1", "", { "dependencies": { "atomic-sleep": "^1.0.0" } }, "sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q=="], - "sonner": ["sonner@2.0.8", "", { "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0 || ^19.0.0-rc", "react-dom": "^18.0.0 || ^19.0.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react"] }, "sha512-UM/ByIoFra8yzV75n1o0Puu0bw5U/9UNnDacrJNspekBewIfsQ3D6ez1nvlWpt7aTsO6rujQtifBpycwIivqlg=="], "source-map": ["source-map@0.6.1", "", {}, "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g=="], @@ -1850,8 +1875,6 @@ "strip-final-newline": ["strip-final-newline@4.0.0", "", {}, "sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw=="], - "strip-json-comments": ["strip-json-comments@5.0.3", "", {}, "sha512-1tB5mhVo7U+ETBKNf92xT4hrQa3pm0MZ0PQvuDnWgAAGHDsfp4lPSpiS6psrSiet87wyGPh9ft6wmhOMQ0hDiw=="], - "superjson": ["superjson@2.2.6", "", { "dependencies": { "copy-anything": "^4" } }, "sha512-H+ue8Zo4vJmV2nRjpx86P35lzwDT3nItnIsocgumgr0hHMQ+ZGq5vrERg9kJBo5AWGmxZDhzDo+WVIJqkB0cGA=="], "supports-preserve-symlinks-flag": ["supports-preserve-symlinks-flag@1.0.0", "", {}, "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w=="], @@ -1870,8 +1893,6 @@ "terser": ["terser@5.51.2", "", { "dependencies": { "@jridgewell/source-map": "^0.3.3", "acorn": "^8.15.0", "commander": "^2.20.0", "source-map-support": "~0.5.20" }, "bin": { "terser": "bin/terser" } }, "sha512-bWnjSNscmuI+GJze6ZupnHP8G/cTcsJF+bXCeQknk2SHQsgbNJnLrqiH9jZ2W4STPVXH2mDKKRX3iwPhc9Cn/Q=="], - "thread-stream": ["thread-stream@4.2.0", "", { "dependencies": { "real-require": "^1.0.0" } }, "sha512-e2zZ96wSChazBsbENf/Pcm/4swHt2cEKQ92rhUjkL9GCKiTDJIaTBenjE/m9DXi0QBmTMDkFDdOomUy20A1tDQ=="], - "tiny-invariant": ["tiny-invariant@1.3.3", "", {}, "sha512-+FbBPE1o9QAYvviau/qC5SE3caw21q3xkvWKBtja5vgqOWIHHJ3ioaq1VPfn/Szqctz2bU/oYeKd9/z5BL+PVg=="], "tinybench": ["tinybench@6.2.2", "", {}, "sha512-nIZ2N2dFpjBsg2hgitKu7mA+FvsIJuGJOwysRngmVRRmWgR/UyPjwJj8c/fT/dhm8EkHnF5EOogRf+0Z2qrimA=="], @@ -2040,6 +2061,12 @@ "@dotenvx/dotenvx/open": ["open@8.4.2", "", { "dependencies": { "define-lazy-prop": "^2.0.0", "is-docker": "^2.1.1", "is-wsl": "^2.2.0" } }, "sha512-7x81NCL719oNbsq/3mh+hVrAWmFuEYUqrq/Iw3kUzH8ReypT9QQ0BLoJS7/G9k6N81XjW4qHWtjWwe/9eLy1EQ=="], + "@logtape/otel/@opentelemetry/api": ["@opentelemetry/api@1.10.0", "", {}, "sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ=="], + + "@logtape/otel/@opentelemetry/resources": ["@opentelemetry/resources@2.12.0", "", { "dependencies": { "@opentelemetry/core": "2.12.0", "@opentelemetry/semantic-conventions": "^1.29.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.3.0 <1.10.0" } }, "sha512-+rSRoOdln6NhXTVcBdHSlZxJDNzwxadeweK2ltZO3tVtfp6aklABc06xclDk6ovRR+EiGgIcSbh/6NgjFhnb3A=="], + + "@opentelemetry/api-logs/@opentelemetry/api": ["@opentelemetry/api@1.10.0", "", {}, "sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ=="], + "@prisma/dev/std-env": ["std-env@3.10.0", "", {}, "sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg=="], "@prisma/engines/@prisma/get-platform": ["@prisma/get-platform@7.10.0", "", { "dependencies": { "@prisma/debug": "7.10.0" } }, "sha512-0bra1LFYi8xNw0yqV62bHJNQk4BKleOngZiqPWIQc7a3+9q6rqsnqJ15BuepP8943PFMvtmgnP52juZsyYkA6w=="], @@ -2144,14 +2171,14 @@ "pg-types/postgres-array": ["postgres-array@2.0.0", "", {}, "sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA=="], - "pino-pretty/sonic-boom": ["sonic-boom@5.0.2", "", { "dependencies": { "atomic-sleep": "^1.0.0" } }, "sha512-/JEruzo6yhNVhsLblTRchgTQHIt7SsdJP0YyrfWaNKjIOQDfrdZv9gwYraYCAsmKV39/LAdV31FLL5NCDpoL/A=="], - "pkg-types/confbox": ["confbox@0.3.1", "", {}, "sha512-cKUSoKa8YxFZZSmraVi7onONx3amu77ngK3kGpsYHDH7drPwCRkQE1RYMPlLRrMtnciRj274XNRxcHxnKmDSnA=="], "prompts/kleur": ["kleur@3.0.3", "", {}, "sha512-eTIzlVOSUR+JxdDFepEYcBMtZ9Qqdef+rnzWdRZuMbOywu5tO2w2N7rqjoANZ5k9vywhL6Br1VRjUIgTQx4E8w=="], "proper-lockfile/signal-exit": ["signal-exit@3.0.7", "", {}, "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ=="], + "protobufjs/@types/node": ["@types/node@26.6.5", "", { "dependencies": { "undici-types": "~8.9.0" } }, "sha512-uMzsv9stDdofIZBx4UGh4Z9ZgXnGC9seRDscilBcTHAeOFk67MZg/k9bWVfO+bk4qZmG+l52hRnLwUiH2LnJTg=="], + "restore-cursor/onetime": ["onetime@7.0.0", "", { "dependencies": { "mimic-function": "^5.0.0" } }, "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ=="], "shadcn/cn": ["cn@0.2.6", "", { "bin": { "cn": "bin/cn.mjs" } }, "sha512-+i4L0zUGgRcEnhsxueVrP7iBGxBx5iD0WOTYg1MwFEu2ZyCmH5Ov2V1cul2Ht5UchRQQgftCf4be/RxspuW6QQ=="], @@ -2196,6 +2223,8 @@ "@dotenvx/dotenvx/open/define-lazy-prop": ["define-lazy-prop@2.0.0", "", {}, "sha512-Ds09qNh8yw3khSjiJjiUInaGX9xlqZDY7JVryGxdxV7NPeuqQfplOpQ66yJFZut3jLa5zOwkXw1g9EI2uKh4Og=="], + "@logtape/otel/@opentelemetry/resources/@opentelemetry/core": ["@opentelemetry/core@2.12.0", "", { "dependencies": { "@opentelemetry/semantic-conventions": "^1.29.0" }, "peerDependencies": { "@opentelemetry/api": ">=1.0.0 <1.10.0" } }, "sha512-1HsSAuvT4/my0QrXWsyXFdWjKaPeCHsismKZgEEIb8NK13LP6DrMRlsUbvD/0F9mDWK3xDom9AMv3IscxgOnOQ=="], + "@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/primitive": ["@radix-ui/primitive@1.1.3", "", {}, "sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg=="], "@prisma/studio-core/@radix-ui/react-toggle/@radix-ui/react-primitive": ["@radix-ui/react-primitive@2.1.3", "", { "dependencies": { "@radix-ui/react-slot": "1.2.3" }, "peerDependencies": { "@types/react": "*", "@types/react-dom": "*", "react": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc", "react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc" }, "optionalPeers": ["@types/react", "@types/react-dom"] }, "sha512-m9gTwRkhy2lvCPe6QJp4d3G1TYEUHn/FzJUtq9MjH46an1wJU+GdoGC5VLof8RX8Ft/DlpshApkhswDLZzHIcQ=="], @@ -2240,6 +2269,8 @@ "ora/string-width/emoji-regex": ["emoji-regex@10.6.0", "", {}, "sha512-toUI84YS5YmxW219erniWD0CIVOo46xGKColeNQRgOzDorgBi1v4D71/OFzgD9GO2UGKIv1C3Sp8DAn0+j5w7A=="], + "protobufjs/@types/node/undici-types": ["undici-types@8.9.0", "", {}, "sha512-KTDyRTYX8sWmKXAikPHHSyc63CRPETMctyjKFupcC6OBLXT3xsN0e9aF7m+mIXutFWpUXuedtowG7iLOzp0kQg=="], + "string-width/strip-ansi/ansi-regex": ["ansi-regex@5.0.1", "", {}, "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ=="], "workbox-build/stringify-object/is-obj": ["is-obj@1.0.1", "", {}, "sha512-l4RyHgRqGN4Y3+9JHVrNqO+tN0rV5My76uW5/nuO4K1b6vw5G8d/cmFjP9tRfEsdhZNt0IFdZuK/c2Vr4Nb+Qg=="], diff --git a/docker-compose.yml b/docker-compose.yml index 6a0d3ec..d4bc306 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -22,6 +22,13 @@ services: NODE_ENV: ${NODE_ENV:-production} PORT: ${PORT:-4100} LOG_LEVEL: ${LOG_LEVEL:-} + # Logs to OpenObserve (optional): without OPENOBSERVE_URL they only go to stdout. + OPENOBSERVE_URL: ${OPENOBSERVE_URL:-} + OPENOBSERVE_ORG: ${OPENOBSERVE_ORG:-default} + OPENOBSERVE_STREAM: ${OPENOBSERVE_STREAM:-superlist} + OPENOBSERVE_USER: ${OPENOBSERVE_USER:-} + OPENOBSERVE_PASSWORD: ${OPENOBSERVE_PASSWORD:-} + METRICS_EXPORT_INTERVAL_MS: ${METRICS_EXPORT_INTERVAL_MS:-15000} RESEND_API_KEY: ${RESEND_API_KEY:-} MAIL_FROM: ${MAIL_FROM:-} # Dictation (optional): Groq when its key is set, else Gemini; without any key, diff --git a/docs/openobserve-dashboard.json b/docs/openobserve-dashboard.json new file mode 100644 index 0000000..7c6d7f3 --- /dev/null +++ b/docs/openobserve-dashboard.json @@ -0,0 +1,555 @@ +{ + "version": 8, + "title": "Superlist API", + "description": "Métricas HTTP de la API (OTLP) y requests lentos (logs)", + "role": "", + "owner": "", + "created": "1970-01-01T00:00:00Z", + "dashboardId": "", + "defaultDatetimeDuration": { + "type": "relative", + "relativeTimePeriod": "1h", + "startTime": null, + "endTime": null + }, + "variables": { + "list": [], + "showDynamicFilters": false + }, + "tabs": [ + { + "tabId": "default", + "name": "Default", + "panels": [ + { + "id": "Panel_rps", + "type": "line", + "title": "Requests por segundo por ruta", + "description": "Sin /api/health", + "config": { + "show_legends": true, + "legends_position": null, + "unit": "default", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "", + "mark_line": [], + "override_config": [] + }, + "queryType": "promql", + "queries": [ + { + "query": "sum by (http_route) (rate(http_server_request_duration_count{service_name=\"superlist-api\", http_route!=\"/api/health\"}[5m]))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_count", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "{http_route}", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 0, + "y": 0, + "w": 24, + "h": 9, + "i": 1 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + }, + { + "id": "Panel_latency", + "type": "line", + "title": "Latencia p50 / p95 / p99", + "description": "Percentiles interpolados en buckets de 5 ms a 10 s", + "config": { + "show_legends": true, + "legends_position": null, + "unit": "seconds", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "", + "mark_line": [], + "override_config": [] + }, + "queryType": "promql", + "queries": [ + { + "query": "histogram_quantile(0.5, sum by (le) (rate(http_server_request_duration_bucket{http_route!=\"/api/health\"}[5m])))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_bucket", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "p50", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + }, + { + "query": "histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_bucket{http_route!=\"/api/health\"}[5m])))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_bucket", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "p95", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + }, + { + "query": "histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_bucket{http_route!=\"/api/health\"}[5m])))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_bucket", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "p99", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 24, + "y": 0, + "w": 24, + "h": 9, + "i": 2 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + }, + { + "id": "Panel_errors", + "type": "metric", + "title": "Tasa de error 5xx", + "description": "Porcentaje de requests con status 5xx (vacío = 0 %)", + "config": { + "show_legends": true, + "legends_position": null, + "unit": "percent", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "0", + "mark_line": [], + "override_config": [] + }, + "queryType": "promql", + "queries": [ + { + "query": "100 * sum(rate(http_server_request_duration_count{http_response_status_code=~\"5..\"}[5m])) / sum(rate(http_server_request_duration_count[5m]))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_count", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "5xx %", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 0, + "y": 9, + "w": 12, + "h": 9, + "i": 3 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + }, + { + "id": "Panel_active", + "type": "metric", + "title": "Requests en curso", + "description": "SSE no cuenta: responde enseguida", + "config": { + "show_legends": true, + "legends_position": null, + "unit": "default", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "0", + "mark_line": [], + "override_config": [] + }, + "queryType": "promql", + "queries": [ + { + "query": "sum(http_server_active_requests)", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_active_requests", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "en curso", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 12, + "y": 9, + "w": 12, + "h": 9, + "i": 4 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + }, + { + "id": "Panel_status", + "type": "stacked", + "title": "Requests por status", + "description": "Requests/s por código de respuesta (sin /api/health)", + "config": { + "show_legends": true, + "legends_position": null, + "unit": "default", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "", + "mark_line": [], + "override_config": [] + }, + "queryType": "promql", + "queries": [ + { + "query": "sum by (http_response_status_code) (rate(http_server_request_duration_count{http_route!=\"/api/health\"}[5m]))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_count", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "{http_response_status_code}", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 24, + "y": 9, + "w": 24, + "h": 9, + "i": 5 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + }, + { + "id": "Panel_p95_route", + "type": "line", + "title": "p95 por ruta", + "description": "Para encontrar el endpoint lento", + "config": { + "show_legends": true, + "legends_position": null, + "unit": "seconds", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "", + "mark_line": [], + "override_config": [] + }, + "queryType": "promql", + "queries": [ + { + "query": "histogram_quantile(0.95, sum by (le, http_route) (rate(http_server_request_duration_bucket{http_route!=\"/api/health\"}[5m])))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_bucket", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "{http_route}", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 0, + "y": 18, + "w": 24, + "h": 9, + "i": 6 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + }, + { + "id": "Panel_avg_route", + "type": "line", + "title": "Latencia media por ruta", + "description": "sum / count de la duración", + "config": { + "show_legends": true, + "legends_position": null, + "unit": "seconds", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "", + "mark_line": [], + "override_config": [] + }, + "queryType": "promql", + "queries": [ + { + "query": "sum by (http_route) (rate(http_server_request_duration_sum{http_route!=\"/api/health\"}[5m])) / sum by (http_route) (rate(http_server_request_duration_count{http_route!=\"/api/health\"}[5m]))", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "http_server_request_duration_sum", + "stream_type": "metrics", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "{http_route}", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 24, + "y": 18, + "w": 24, + "h": 9, + "i": 7 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + }, + { + "id": "Panel_slowest", + "type": "table", + "title": "Requests más lentos", + "description": "Desde los logs: usa requestid en Logs para ver el detalle", + "config": { + "show_legends": false, + "legends_position": null, + "unit": "default", + "decimals": 2, + "axis_border_show": false, + "line_thickness": 1.5, + "connect_nulls": false, + "no_value_replacement": "", + "mark_line": [], + "override_config": [] + }, + "queryType": "sql", + "queries": [ + { + "query": "SELECT _timestamp, method, path, status, durationms, requestid FROM \"superlist\" WHERE durationms IS NOT NULL AND path != '/api/health' ORDER BY durationms DESC LIMIT 20", + "vrlFunctionQuery": "", + "customQuery": true, + "joins": [], + "fields": { + "stream": "superlist", + "stream_type": "logs", + "x": [], + "y": [], + "z": [], + "breakdown": [], + "filter": { + "filterType": "group", + "logicalOperator": "AND", + "conditions": [] + } + }, + "config": { + "promql_legend": "", + "layer_type": "scatter", + "weight_fixed": 1, + "limit": 0, + "min": 0, + "max": 100, + "time_shift": [] + } + } + ], + "layout": { + "x": 0, + "y": 27, + "w": 48, + "h": 12, + "i": 8 + }, + "htmlContent": "", + "markdownContent": "", + "customChartContent": "" + } + ] + } + ] +} diff --git a/docs/openobserve-dashboard.md b/docs/openobserve-dashboard.md new file mode 100644 index 0000000..3e4e5cb --- /dev/null +++ b/docs/openobserve-dashboard.md @@ -0,0 +1,184 @@ +# Dashboard de la API en OpenObserve + +Guía para armar en OpenObserve un dashboard con las métricas HTTP de la API (latencia, tráfico, errores) y +una tabla de requests lentos a partir de los logs. + +## 1. Qué datos llegan + +Con `OPENOBSERVE_URL`, `OPENOBSERVE_USER` y `OPENOBSERVE_PASSWORD` en `apps/api/.env`, la API envía: + +**Métricas** (OTLP, cada `METRICS_EXPORT_INTERVAL_MS`, 15 s por defecto). OpenObserve cambia los puntos por +guiones bajos y crea un stream por serie: + +| Stream (tipo `metrics`) | Qué es | +| ---------------------------------------- | --------------------------------------------------------- | +| `http_server_request_duration_bucket` | Histograma de duración (segundos), un contador por `le` | +| `http_server_request_duration_count` | Cantidad de requests (contador acumulado) | +| `http_server_request_duration_sum` | Suma de duraciones en segundos (contador acumulado) | +| `http_server_active_requests` | Requests en curso (gauge) | + +Labels disponibles: `http_route` (patrón de Hono, ej. `/api/lists/:listId`), `http_request_method`, +`http_response_status_code`, `service_name` (`superlist-api`) y `le` (solo en `_bucket`). + +Los buckets van de 5 ms a 10 s: `0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10`. + +**Logs** (stream `superlist`, tipo `logs`). OpenObserve pasa los nombres de campo a **minúsculas**: +`method`, `path`, `route`, `status`, `durationms`, `requestid`, `userid`, `useragent`, `severity`, `body`, +`category`. + +> Los requests a `/api/health` se loguean en `debug`: en desarrollo (nivel por defecto `debug`) llegan a +> OpenObserve, en producción (`info`) no. En las métricas están siempre; los filtros de abajo los excluyen. +> +> Las rutas que no existen (404 de `notFound`) aparecen con `http_route="/*"`. Agrega `http_route!="/*"` al +> selector si no las quieres ver en los paneles de latencia. + +## 2. Comprobar que hay datos + +1. **Streams**: deberías ver los streams de la tabla anterior (filtro *Metrics*) y `superlist` (filtro *Logs*). +2. **Logs** → stream `superlist` → *Run query*: aparecen los requests con `durationms`. +3. **Metrics** → elegir `http_server_request_duration_count` → aparecen series por `http_route`. + +Si los streams existen pero no tienen registros, mira los logs del contenedor de OpenObserve +(`docker logs openobserve`) antes de seguir (ver *Problemas frecuentes*). + +## 3. Crear el dashboard + +> **Atajo:** el dashboard completo (paneles 1–8) está en `docs/openobserve-dashboard.json`. En OpenObserve: +> **Dashboards** → **Import** → pegar o subir el JSON. También se puede crear por API: +> `curl -u "$OPENOBSERVE_USER:$OPENOBSERVE_PASSWORD" -X POST "$OPENOBSERVE_URL/api/default/dashboards?folder=default" -H 'content-type: application/json' --data-binary @docs/openobserve-dashboard.json`. +> Los pasos de abajo explican cada panel por si quieres armarlo o cambiarlo a mano. + +1. **Dashboards** → **New Dashboard** → nombre `Superlist API` → *Save*. +2. Rango de tiempo arriba a la derecha: *Past 1 hour*; autorrefresco: *30s* (no tiene sentido menos que el + intervalo de exportación). +3. Para cada panel: **Add Panel** → tipo de gráfico → en el panel de la izquierda elegir **Stream Type + `metrics`** y el stream → cambiar el modo de consulta a **PromQL** → pegar la consulta → en *Legend* poner + el label (ej. `{http_route}`) → **Apply** → título → **Save**. + +Todas las consultas usan una ventana de `[5m]`: con contadores acumulados, `rate()` necesita al menos dos +muestras dentro de la ventana, y con exportación cada 15 s 5 minutos dan margen de sobra. + +### Panel 1 — Requests por segundo por ruta (línea) + +```promql +sum by (http_route) ( + rate(http_server_request_duration_count{service_name="superlist-api", http_route!="/api/health"}[5m]) +) +``` + +Legend: `{http_route}`. Unidad: *req/s* (o *Default*). + +### Panel 2 — Latencia p50 / p95 / p99 (línea) + +Agregar tres consultas en el mismo panel (botón **+** junto a la query): + +```promql +histogram_quantile(0.50, sum by (le) (rate(http_server_request_duration_bucket{http_route!="/api/health"}[5m]))) +histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_bucket{http_route!="/api/health"}[5m]))) +histogram_quantile(0.99, sum by (le) (rate(http_server_request_duration_bucket{http_route!="/api/health"}[5m]))) +``` + +Legends: `p50`, `p95`, `p99`. Unidad: **Seconds** (la métrica está en segundos; OpenObserve la muestra como +ms cuando corresponde). + +Los percentiles se interpolan dentro de cada bucket: si casi todo tarda menos de 5 ms (el primer bucket), verás +valores como `4.75 ms` aunque el request real tarde 0.2 ms. Para la duración exacta usa el panel 4 (media) o +la tabla del panel 8. + +### Panel 3 — p95 por ruta (línea o barras horizontales) + +```promql +histogram_quantile(0.95, + sum by (le, http_route) (rate(http_server_request_duration_bucket{http_route!="/api/health"}[5m])) +) +``` + +Legend: `{http_route}`. Unidad: *Seconds*. Es el panel para encontrar el endpoint lento. + +### Panel 4 — Latencia media por ruta (línea) + +```promql +sum by (http_route) (rate(http_server_request_duration_sum{http_route!="/api/health"}[5m])) +/ +sum by (http_route) (rate(http_server_request_duration_count{http_route!="/api/health"}[5m])) +``` + +### Panel 5 — Requests por status (barras apiladas) + +```promql +sum by (http_response_status_code) (rate(http_server_request_duration_count{http_route!="/api/health"}[5m])) +``` + +Legend: `{http_response_status_code}`. Los 401 son normales (sesión vencida, `/api/lists` sin login); fíjate +en los 5xx. + +### Panel 6 — Tasa de error 5xx (métrica única / *Metric*) + +```promql +100 * sum(rate(http_server_request_duration_count{http_response_status_code=~"5.."}[5m])) + / sum(rate(http_server_request_duration_count[5m])) +``` + +Unidad: *Percent*. Sin errores la consulta no devuelve nada (no hay serie 5xx); eso es *0 %*. + +### Panel 7 — Requests en curso (métrica única) + +```promql +sum(http_server_active_requests) +``` + +Normalmente 0–1: las conexiones SSE (`/events`) devuelven la respuesta enseguida y no cuentan mientras están +abiertas. + +### Panel 8 — Requests más lentos (tabla, desde logs) + +Este sale de los logs, así que tiene el `requestid` para ir al detalle. **Add Panel** → *Table* → **Stream Type +`logs`**, stream `superlist` → modo **Custom SQL**: + +```sql +SELECT _timestamp, method, path, status, durationms, requestid +FROM "superlist" +WHERE durationms IS NOT NULL AND path != '/api/health' +ORDER BY durationms DESC +LIMIT 20 +``` + +Con el `requestid` de una fila, en **Logs** filtra `requestid = ''` y verás todo lo que se logueó durante +ese request (emails, fallbacks de dictado, errores). + +### Opcional — Variable para filtrar por ruta + +**Settings** del dashboard (engranaje) → **Variables** → **Add Variable**: + +- Type: *Query Values* · Name: `route` · Stream type: `metrics` · Stream: `http_server_request_duration_count` + · Field: `http_route` · habilitar *Multi select* e *Include All*. + +Después, en las consultas, agrega `http_route=~"$route"` al selector, por ejemplo: + +```promql +sum by (http_route) (rate(http_server_request_duration_count{http_route=~"$route"}[5m])) +``` + +## 4. Alertas sugeridas + +En **Alerts** → **Add alert**, tipo *Scheduled*, stream `metrics`, modo PromQL, cada 5 minutos: + +- **p95 alto**: `histogram_quantile(0.95, sum by (le) (rate(http_server_request_duration_bucket{http_route!="/api/health"}[5m]))) > 1` +- **Errores 5xx**: `sum(rate(http_server_request_duration_count{http_response_status_code=~"5.."}[5m])) > 0` + +## Problemas frecuentes + +- **No aparece ningún stream**: falta `OPENOBSERVE_URL` o las credenciales están mal (OpenObserve responde + 401 y el exporter no muestra nada en consola). El log de arranque dice `metricsEnabled: true` si las métricas + están activas. +- **Los streams existen pero están vacíos y `docker logs openobserve` muestra + `wal file create error: ... File exists`**: el directorio de datos de OpenObserve está roto. Pasa, por + ejemplo, si la carpeta del host montada en `/data` se borró con el contenedor corriendo. Recrea el contenedor + con un volumen con nombre o una carpeta fuera del repo (`-v ~/personal-projects/openobserve-data:/data`). +- **Rutas con valores `NaN`** en los paneles de latencia: no tuvieron tráfico en la ventana de 5 minutos + (división 0/0). Es normal; desaparecen solas. +- **Campo desconocido en SQL (`unknown field 'durationMs'`)**: los nombres de campo de los logs están en + minúsculas (`durationms`, `requestid`). +- **`rate()` vacío al principio**: hacen falta al menos dos exportaciones dentro de la ventana; espera ~30 s + después de arrancar la API. +- **`/events` con duraciones muy bajas**: es lo esperado, se mide el tiempo hasta abrir el stream SSE. diff --git a/turbo.json b/turbo.json index 4ad7638..755ac7f 100644 --- a/turbo.json +++ b/turbo.json @@ -24,7 +24,14 @@ "GEMINI_TIMEOUT_MS", "GROQ_API_KEY", "GROQ_MODEL", - "GROQ_TIMEOUT_MS" + "GROQ_TIMEOUT_MS", + "LOG_LEVEL", + "OPENOBSERVE_URL", + "OPENOBSERVE_ORG", + "OPENOBSERVE_STREAM", + "OPENOBSERVE_USER", + "OPENOBSERVE_PASSWORD", + "METRICS_EXPORT_INTERVAL_MS" ] }, "dev": { @@ -46,7 +53,14 @@ "GROQ_API_KEY", "GROQ_MODEL", "GROQ_TIMEOUT_MS", - "VITE_API_URL" + "VITE_API_URL", + "LOG_LEVEL", + "OPENOBSERVE_URL", + "OPENOBSERVE_ORG", + "OPENOBSERVE_STREAM", + "OPENOBSERVE_USER", + "OPENOBSERVE_PASSWORD", + "METRICS_EXPORT_INTERVAL_MS" ] }, "db:generate": { -- 2.49.1 From b9c6ab92e3c5095f4cf51944c3acab1da0aeead8 Mon Sep 17 00:00:00 2001 From: Jose Selesan Date: Wed, 25 Nov 2026 09:24:13 -0300 Subject: [PATCH 2/2] feat(lists): pin lists with an icon and a live pending badge Each member can pin up to four lists and pick an icon for them (per-user settings on shopping_list_members, PATCH /api/lists/:listId/preferences). Pinned lists stay visible with their pending count, kept live over each list's SSE stream: a chip bar above the bottom nav on mobile and a "Fijadas" group in the sidebar on desktop. GET /api/lists now returns pendingCount, isPinned and icon. The page padding, install prompt and dictation button now read --bottom-nav-height, which grows with the pinned bar. Co-Authored-By: Claude Opus 5.5 --- .../20261125121747_pinned_lists/migration.sql | 7 + apps/api/prisma/schema.prisma | 7 + .../src/modules/lists/create/use-case.test.ts | 7 +- apps/api/src/modules/lists/create/use-case.ts | 6 +- apps/api/src/modules/lists/index.ts | 2 + .../src/modules/lists/list/use-case.test.ts | 60 ++++++ apps/api/src/modules/lists/list/use-case.ts | 28 +-- .../src/modules/lists/preferences/route.ts | 30 +++ .../src/modules/lists/preferences/schema.ts | 14 ++ .../lists/preferences/use-case.test.ts | 147 ++++++++++++++ .../src/modules/lists/preferences/use-case.ts | 76 ++++++++ apps/api/src/modules/lists/serialize.ts | 36 +++- apps/api/src/modules/lists/update/use-case.ts | 14 +- apps/web/src/components/install-prompt.tsx | 2 +- apps/web/src/components/items/dictate-fab.tsx | 2 +- .../web/src/components/layout/app-sidebar.tsx | 2 + apps/web/src/components/layout/bottom-nav.tsx | 2 + .../src/components/layout/list-switcher.tsx | 4 + .../src/components/layout/pinned-lists.tsx | 183 ++++++++++++++++++ apps/web/src/components/lists/list-card.tsx | 65 +++++-- apps/web/src/components/lists/list-glyph.tsx | 29 +++ .../lists/list-preferences-card.tsx | 94 +++++++++ apps/web/src/hooks/use-lists.ts | 61 +++++- apps/web/src/hooks/use-pending-count.ts | 22 +++ apps/web/src/lib/list-icons.ts | 45 +++++ .../_authenticated/lists/$listId/settings.tsx | 3 + apps/web/src/routes/_authenticated/route.tsx | 19 +- packages/shared/src/shopping-list.ts | 47 +++++ 28 files changed, 965 insertions(+), 49 deletions(-) create mode 100644 apps/api/prisma/migrations/20261125121747_pinned_lists/migration.sql create mode 100644 apps/api/src/modules/lists/list/use-case.test.ts create mode 100644 apps/api/src/modules/lists/preferences/route.ts create mode 100644 apps/api/src/modules/lists/preferences/schema.ts create mode 100644 apps/api/src/modules/lists/preferences/use-case.test.ts create mode 100644 apps/api/src/modules/lists/preferences/use-case.ts create mode 100644 apps/web/src/components/layout/pinned-lists.tsx create mode 100644 apps/web/src/components/lists/list-glyph.tsx create mode 100644 apps/web/src/components/lists/list-preferences-card.tsx create mode 100644 apps/web/src/hooks/use-pending-count.ts create mode 100644 apps/web/src/lib/list-icons.ts diff --git a/apps/api/prisma/migrations/20261125121747_pinned_lists/migration.sql b/apps/api/prisma/migrations/20261125121747_pinned_lists/migration.sql new file mode 100644 index 0000000..9c6c955 --- /dev/null +++ b/apps/api/prisma/migrations/20261125121747_pinned_lists/migration.sql @@ -0,0 +1,7 @@ +-- AlterTable +ALTER TABLE "shopping_list_members" ADD COLUMN "icon" TEXT, +ADD COLUMN "is_pinned" BOOLEAN NOT NULL DEFAULT false, +ADD COLUMN "pinned_order" INTEGER; + +-- CreateIndex +CREATE INDEX "shopping_list_members_user_id_is_pinned_idx" ON "shopping_list_members"("user_id", "is_pinned"); diff --git a/apps/api/prisma/schema.prisma b/apps/api/prisma/schema.prisma index e6f2267..63ad81c 100644 --- a/apps/api/prisma/schema.prisma +++ b/apps/api/prisma/schema.prisma @@ -168,11 +168,18 @@ model ShoppingListMember { user User @relation(fields: [userId], references: [id], onDelete: Cascade) role ListRole @default(collaborator) isPrimary Boolean @default(false) @map("is_primary") + /// Per user: the list is pinned to the always-visible bar (at most 4 per user). + isPinned Boolean @default(false) @map("is_pinned") + /// Position among the user's pinned lists (pin order); null when not pinned. + pinnedOrder Int? @map("pinned_order") + /// Per user: key of the icon chosen for the list (see `LIST_ICONS` in `@superlist/shared`). + icon String? createdAt DateTime @default(now()) @map("created_at") updatedAt DateTime @updatedAt @map("updated_at") @@unique([listId, userId]) @@index([userId, isPrimary]) + @@index([userId, isPinned]) @@map("shopping_list_members") } diff --git a/apps/api/src/modules/lists/create/use-case.test.ts b/apps/api/src/modules/lists/create/use-case.test.ts index 8e72158..fe006a7 100644 --- a/apps/api/src/modules/lists/create/use-case.test.ts +++ b/apps/api/src/modules/lists/create/use-case.test.ts @@ -33,12 +33,14 @@ function createDb({ name: input.data.name, createdAt: new Date('2026-10-15T00:00:00.000Z'), updatedAt: new Date('2026-10-15T00:00:00.000Z'), - _count: { members: membershipsOnCreate }, + _count: { members: membershipsOnCreate, items: 0 }, members: [ { id: 'member-1', role: 'owner', isPrimary: input.data.members.create.isPrimary, + isPinned: false, + icon: null, }, ], } @@ -65,6 +67,9 @@ describe('CreateShoppingList', () => { name: 'Compra semanal', role: 'owner', isPrimary: true, + isPinned: false, + icon: null, + pendingCount: 0, memberCount: 1, createdAt: '2026-10-15T00:00:00.000Z', updatedAt: '2026-10-15T00:00:00.000Z', diff --git a/apps/api/src/modules/lists/create/use-case.ts b/apps/api/src/modules/lists/create/use-case.ts index 80c97b1..fa596ee 100644 --- a/apps/api/src/modules/lists/create/use-case.ts +++ b/apps/api/src/modules/lists/create/use-case.ts @@ -2,7 +2,7 @@ import { Ok, type ProblemDetails, type Result, type ShoppingListSummary } from ' import type { Database } from '@/lib/prisma' -import { toSummary } from '../serialize' +import { summaryCountInclude, toSummary } from '../serialize' /** Creates a shopping list owned by the user. The first list becomes primary. */ export class CreateShoppingList { @@ -29,7 +29,7 @@ export class CreateShoppingList { }, }, include: { - _count: { select: { members: true } }, + ...summaryCountInclude, members: { where: { userId: input.userId } }, }, }) @@ -44,6 +44,8 @@ export class CreateShoppingList { toSummary({ role: membership.role, isPrimary: membership.isPrimary, + isPinned: membership.isPinned, + icon: membership.icon, list: { id: list.id, name: list.name, diff --git a/apps/api/src/modules/lists/index.ts b/apps/api/src/modules/lists/index.ts index 59e5d78..fcb07bf 100644 --- a/apps/api/src/modules/lists/index.ts +++ b/apps/api/src/modules/lists/index.ts @@ -7,6 +7,7 @@ import { listEventsRoute } from './events/route' import { getListRoute } from './get/route' import { listItemsModule } from './items' import { listListsRoute } from './list/route' +import { updateListPreferencesRoute } from './preferences/route' import { setPrimaryListRoute } from './set-primary/route' import { updateListRoute } from './update/route' @@ -17,5 +18,6 @@ export const listsModule = new Hono() .route('/', getListRoute) .route('/', updateListRoute) .route('/', setPrimaryListRoute) + .route('/', updateListPreferencesRoute) .route('/:listId/items', listItemsModule) .route('/:listId/events', listEventsRoute) diff --git a/apps/api/src/modules/lists/list/use-case.test.ts b/apps/api/src/modules/lists/list/use-case.test.ts new file mode 100644 index 0000000..e147044 --- /dev/null +++ b/apps/api/src/modules/lists/list/use-case.test.ts @@ -0,0 +1,60 @@ +import { describe, expect, it } from 'bun:test' + +import type { Database } from '@/lib/prisma' + +import { ListShoppingLists } from './use-case' + +describe('ListShoppingLists', () => { + it('returns the pending count and the user preferences of each list', async () => { + const queries: unknown[] = [] + const db = { + shoppingListMember: { + findMany: async (args: unknown) => { + queries.push(args) + + return [ + { + role: 'owner', + isPrimary: false, + isPinned: true, + icon: 'unknown-icon', + list: { + id: 'list-1', + name: 'Verdulería', + createdAt: new Date('2026-11-01T00:00:00.000Z'), + updatedAt: new Date('2026-11-02T00:00:00.000Z'), + _count: { members: 1, items: 4 }, + }, + }, + ] + }, + }, + } + + const result = await new ListShoppingLists(db as unknown as Database).execute({ + userId: 'user-1', + }) + + expect(result.ok).toBe(true) + if (!result.ok) throw new Error('expected the use case to succeed') + expect(result.value).toEqual([ + { + id: 'list-1', + name: 'Verdulería', + role: 'owner', + isPrimary: false, + isPinned: true, + icon: null, + pendingCount: 4, + memberCount: 1, + createdAt: '2026-11-01T00:00:00.000Z', + updatedAt: '2026-11-02T00:00:00.000Z', + }, + ]) + expect(queries[0]).toMatchObject({ + include: { + list: { include: { _count: { select: { items: { where: { completed: false } } } } } }, + }, + }) + }) +}) diff --git a/apps/api/src/modules/lists/list/use-case.ts b/apps/api/src/modules/lists/list/use-case.ts index 6a12446..c0ed8cd 100644 --- a/apps/api/src/modules/lists/list/use-case.ts +++ b/apps/api/src/modules/lists/list/use-case.ts @@ -2,27 +2,27 @@ import { Ok, type ProblemDetails, type Result, type ShoppingListSummary } from ' import type { Database } from '@/lib/prisma' -/** Lists every shopping list the user belongs to (owned or shared). */ +import { summaryCountInclude, toSummary } from '../serialize' + +/** + * Lists every shopping list the user belongs to (owned or shared): the primary + * one first, then the pinned ones in pin order, then the rest, newest first. + */ export class ListShoppingLists { constructor(private readonly db: Database) {} async execute(input: { userId: string }): Promise> { const memberships = await this.db.shoppingListMember.findMany({ where: { userId: input.userId }, - include: { list: { include: { _count: { select: { members: true } } } } }, - orderBy: [{ isPrimary: 'desc' }, { list: { createdAt: 'desc' } }], + include: { list: { include: summaryCountInclude } }, + orderBy: [ + { isPrimary: 'desc' }, + { isPinned: 'desc' }, + { pinnedOrder: { sort: 'asc', nulls: 'last' } }, + { list: { createdAt: 'desc' } }, + ], }) - const lists = memberships.map((membership) => ({ - id: membership.list.id, - name: membership.list.name, - role: membership.role, - isPrimary: membership.isPrimary, - memberCount: membership.list._count.members, - createdAt: membership.list.createdAt.toISOString(), - updatedAt: membership.list.updatedAt.toISOString(), - })) - - return Ok(lists) + return Ok(memberships.map(toSummary)) } } diff --git a/apps/api/src/modules/lists/preferences/route.ts b/apps/api/src/modules/lists/preferences/route.ts new file mode 100644 index 0000000..61bf951 --- /dev/null +++ b/apps/api/src/modules/lists/preferences/route.ts @@ -0,0 +1,30 @@ +import { Hono } from 'hono' + +import { requireSession } from '@/lib/auth-session' +import { prisma } from '@/lib/prisma' +import { resultJson } from '@/lib/result-json' +import { validate } from '@/lib/validate' +import type { AppEnv } from '@/types' + +import { ListParamsSchema } from '../schema' +import { UpdateListPreferencesSchema } from './schema' +import { UpdateListPreferences } from './use-case' + +/** PATCH /lists/:listId/preferences — pins the list or changes its icon (per user). */ +export const updateListPreferencesRoute = new Hono().patch( + '/:listId/preferences', + requireSession, + validate.param(ListParamsSchema), + validate.json(UpdateListPreferencesSchema), + async (c) => { + const { listId } = c.req.valid('param') + const body = c.req.valid('json') + const result = await new UpdateListPreferences(prisma).execute({ + listId, + userId: c.get('user').id, + ...body, + }) + + return resultJson(c, result) + }, +) diff --git a/apps/api/src/modules/lists/preferences/schema.ts b/apps/api/src/modules/lists/preferences/schema.ts new file mode 100644 index 0000000..f12bfe9 --- /dev/null +++ b/apps/api/src/modules/lists/preferences/schema.ts @@ -0,0 +1,14 @@ +import { ListIconSchema } from '@superlist/shared' +import { z } from 'zod' + +/** Body of `PATCH /lists/:listId/preferences`: the user's own settings for the list. */ +export const UpdateListPreferencesSchema = z + .object({ + isPinned: z.boolean().optional(), + icon: ListIconSchema.nullable().optional(), + }) + .refine((body) => body.isPinned !== undefined || body.icon !== undefined, { + message: 'Indica al menos una preferencia para actualizar', + }) + +export type UpdateListPreferencesInput = z.infer diff --git a/apps/api/src/modules/lists/preferences/use-case.test.ts b/apps/api/src/modules/lists/preferences/use-case.test.ts new file mode 100644 index 0000000..07c4320 --- /dev/null +++ b/apps/api/src/modules/lists/preferences/use-case.test.ts @@ -0,0 +1,147 @@ +import { describe, expect, it } from 'bun:test' + +import type { Database } from '@/lib/prisma' + +import { UpdateListPreferences } from './use-case' + +type Membership = { + role: 'owner' | 'collaborator' + isPrimary: boolean + isPinned: boolean + icon: string | null +} + +function createDb({ + membership, + pinnedCount = 0, + maxPinnedOrder = null, +}: { + membership: Membership | null + pinnedCount?: number + maxPinnedOrder?: number | null +}) { + const updates: Array<{ data: Record }> = [] + + const tx = { + shoppingListMember: { + findUnique: async () => membership, + aggregate: async () => ({ + _count: { _all: pinnedCount }, + _max: { pinnedOrder: maxPinnedOrder }, + }), + update: async (args: { data: Record }) => { + updates.push(args) + + return { + ...membership, + ...args.data, + list: { + id: 'list-1', + name: 'Casa de fin de semana', + createdAt: new Date('2026-11-01T00:00:00.000Z'), + updatedAt: new Date('2026-11-01T00:00:00.000Z'), + _count: { members: 2, items: 3 }, + }, + } + }, + }, + } + + const db = { $transaction: async (fn: (client: typeof tx) => unknown) => fn(tx) } + + return { db: db as unknown as Database, updates } +} + +const collaborator: Membership = { + role: 'collaborator', + isPrimary: false, + isPinned: false, + icon: null, +} + +describe('UpdateListPreferences', () => { + it('answers 404 when the user does not belong to the list', async () => { + const { db, updates } = createDb({ membership: null }) + const result = await new UpdateListPreferences(db).execute({ + listId: 'list-1', + userId: 'user-1', + isPinned: true, + }) + + expect(result.ok).toBe(false) + if (result.ok) throw new Error('expected the use case to fail') + expect(result.error.status).toBe(404) + expect(updates).toHaveLength(0) + }) + + it('pins the list after the last pinned one and returns its pending count', async () => { + const { db, updates } = createDb({ + membership: collaborator, + pinnedCount: 2, + maxPinnedOrder: 5, + }) + const result = await new UpdateListPreferences(db).execute({ + listId: 'list-1', + userId: 'user-1', + isPinned: true, + icon: 'park', + }) + + expect(result.ok).toBe(true) + if (!result.ok) throw new Error('expected the use case to succeed') + expect(updates[0]?.data).toEqual({ isPinned: true, pinnedOrder: 6, icon: 'park' }) + expect(result.value).toMatchObject({ + isPinned: true, + icon: 'park', + pendingCount: 3, + memberCount: 2, + }) + }) + + it('refuses to pin more than four lists', async () => { + const { db, updates } = createDb({ + membership: collaborator, + pinnedCount: 4, + maxPinnedOrder: 4, + }) + const result = await new UpdateListPreferences(db).execute({ + listId: 'list-1', + userId: 'user-1', + isPinned: true, + }) + + expect(result.ok).toBe(false) + if (result.ok) throw new Error('expected the use case to fail') + expect(result.error.status).toBe(409) + expect(updates).toHaveLength(0) + }) + + it('unpins the list and clears its position', async () => { + const { db, updates } = createDb({ membership: { ...collaborator, isPinned: true } }) + const result = await new UpdateListPreferences(db).execute({ + listId: 'list-1', + userId: 'user-1', + isPinned: false, + }) + + expect(result.ok).toBe(true) + expect(updates[0]?.data).toEqual({ isPinned: false, pinnedOrder: null }) + }) + + it('changes only the icon of an already pinned list', async () => { + const { db, updates } = createDb({ + membership: { ...collaborator, isPinned: true, icon: 'carrot' }, + }) + const result = await new UpdateListPreferences(db).execute({ + listId: 'list-1', + userId: 'user-1', + isPinned: true, + icon: null, + }) + + expect(result.ok).toBe(true) + if (!result.ok) throw new Error('expected the use case to succeed') + expect(updates[0]?.data).toEqual({ icon: null }) + expect(result.value.icon).toBeNull() + }) +}) diff --git a/apps/api/src/modules/lists/preferences/use-case.ts b/apps/api/src/modules/lists/preferences/use-case.ts new file mode 100644 index 0000000..493f325 --- /dev/null +++ b/apps/api/src/modules/lists/preferences/use-case.ts @@ -0,0 +1,76 @@ +import { + Failure, + type ListIcon, + MAX_PINNED_LISTS, + Ok, + type ProblemDetails, + problems, + type Result, + type ShoppingListSummary, +} from '@superlist/shared' + +import type { Database } from '@/lib/prisma' + +import { summaryCountInclude, toSummary } from '../serialize' + +/** + * Updates the user's own settings for a list: whether it is pinned to the + * always-visible bar and which icon it shows. Any member may do it, because + * the settings are per user (like the primary list), not shared with the list. + */ +export class UpdateListPreferences { + constructor(private readonly db: Database) {} + + async execute(input: { + listId: string + userId: string + isPinned?: boolean + icon?: ListIcon | null + }): Promise> { + const where = { listId_userId: { listId: input.listId, userId: input.userId } } + + return this.db.$transaction(async (tx) => { + const membership = await tx.shoppingListMember.findUnique({ where }) + + if (!membership) { + return Failure(problems.notFound('La lista no existe o no tienes acceso.')) + } + + const data: { isPinned?: boolean; pinnedOrder?: number | null; icon?: ListIcon | null } = {} + + if (input.icon !== undefined) data.icon = input.icon + + if (input.isPinned === true && !membership.isPinned) { + const pinned = await tx.shoppingListMember.aggregate({ + where: { userId: input.userId, isPinned: true }, + _count: { _all: true }, + _max: { pinnedOrder: true }, + }) + + if (pinned._count._all >= MAX_PINNED_LISTS) { + return Failure( + problems.conflict( + `Puedes fijar hasta ${MAX_PINNED_LISTS} listas. Desfija otra para fijar esta.`, + ), + ) + } + + data.isPinned = true + data.pinnedOrder = (pinned._max.pinnedOrder ?? 0) + 1 + } + + if (input.isPinned === false && membership.isPinned) { + data.isPinned = false + data.pinnedOrder = null + } + + const updated = await tx.shoppingListMember.update({ + where, + data, + include: { list: { include: summaryCountInclude } }, + }) + + return Ok(toSummary(updated)) + }) + } +} diff --git a/apps/api/src/modules/lists/serialize.ts b/apps/api/src/modules/lists/serialize.ts index 0a86889..60efa42 100644 --- a/apps/api/src/modules/lists/serialize.ts +++ b/apps/api/src/modules/lists/serialize.ts @@ -1,4 +1,17 @@ -import type { ListMember, ShoppingListDetail, ShoppingListSummary } from '@superlist/shared' +import { + type ListIcon, + ListIconSchema, + type ListMember, + type ShoppingListDetail, + type ShoppingListSummary, +} from '@superlist/shared' + +/** Reads a stored icon key; unknown keys (e.g. one removed from the set) fall back to none. */ +export function toListIcon(icon: string | null): ListIcon | null { + const parsed = ListIconSchema.safeParse(icon) + + return parsed.success ? parsed.data : null +} type ListRow = { id: string @@ -10,16 +23,29 @@ type ListRow = { type MemberRow = { role: 'owner' | 'collaborator' isPrimary: boolean - list: ListRow & { _count: { members: number } } + isPinned: boolean + icon: string | null + list: ListRow & { _count: { members: number; items: number } } } -/** Maps a membership (with its list and member count) to the summary DTO. */ +/** + * Prisma `include` for a summary: the member count plus the pending items + * (`items` counts only the ones not bought yet). + */ +export const summaryCountInclude = { + _count: { select: { members: true, items: { where: { completed: false } } } }, +} as const + +/** Maps a membership (with its list, member and pending counts) to the summary DTO. */ export function toSummary(member: MemberRow): ShoppingListSummary { return { id: member.list.id, name: member.list.name, role: member.role, isPrimary: member.isPrimary, + isPinned: member.isPinned, + icon: toListIcon(member.icon), + pendingCount: member.list._count.items, memberCount: member.list._count.members, createdAt: member.list.createdAt.toISOString(), updatedAt: member.list.updatedAt.toISOString(), @@ -29,6 +55,8 @@ export function toSummary(member: MemberRow): ShoppingListSummary { type DetailRow = { role: 'owner' | 'collaborator' isPrimary: boolean + isPinned: boolean + icon: string | null list: ListRow & { members: Array<{ id: string @@ -65,6 +93,8 @@ export function toDetail(member: DetailRow): ShoppingListDetail { name: member.list.name, role: member.role, isPrimary: member.isPrimary, + isPinned: member.isPinned, + icon: toListIcon(member.icon), members, invitations: member.list.invitations.map((invitation) => ({ id: invitation.id, diff --git a/apps/api/src/modules/lists/update/use-case.ts b/apps/api/src/modules/lists/update/use-case.ts index a78abe5..a39b1c4 100644 --- a/apps/api/src/modules/lists/update/use-case.ts +++ b/apps/api/src/modules/lists/update/use-case.ts @@ -10,6 +10,8 @@ import { import { type ListEvents, listEvents } from '@/lib/events' import type { Database } from '@/lib/prisma' +import { summaryCountInclude, toSummary } from '../serialize' + /** Renames a list. Only the owner (`role: owner`) may do it. */ export class UpdateShoppingList { constructor( @@ -37,19 +39,11 @@ export class UpdateShoppingList { const list = await this.db.shoppingList.update({ where: { id: input.listId }, data: { name: input.name }, - include: { _count: { select: { members: true } } }, + include: summaryCountInclude, }) this.events.publish({ type: 'list.updated', listId: list.id, name: list.name }) - return Ok({ - id: list.id, - name: list.name, - role: membership.role, - isPrimary: membership.isPrimary, - memberCount: list._count.members, - createdAt: list.createdAt.toISOString(), - updatedAt: list.updatedAt.toISOString(), - }) + return Ok(toSummary({ ...membership, list })) } } diff --git a/apps/web/src/components/install-prompt.tsx b/apps/web/src/components/install-prompt.tsx index 2036845..7546b77 100644 --- a/apps/web/src/components/install-prompt.tsx +++ b/apps/web/src/components/install-prompt.tsx @@ -9,7 +9,7 @@ export function InstallPrompt() { if (!visible) return null return ( -
+
{needsManualInstructions ? ( diff --git a/apps/web/src/components/items/dictate-fab.tsx b/apps/web/src/components/items/dictate-fab.tsx index 0161bbd..fe44548 100644 --- a/apps/web/src/components/items/dictate-fab.tsx +++ b/apps/web/src/components/items/dictate-fab.tsx @@ -57,7 +57,7 @@ export function DictateFab({ listId }: DictateFabProps) { aria-label="Dictar ítems" aria-haspopup="dialog" aria-expanded={open} - className="fixed right-4 bottom-[calc(4.5rem+env(safe-area-inset-bottom)+0.75rem)] z-40 size-14 rounded-full shadow-lg md:right-6 md:bottom-6" + className="fixed right-4 bottom-[calc(var(--bottom-nav-height,4.5rem)+env(safe-area-inset-bottom)+0.75rem)] z-40 size-14 rounded-full shadow-lg md:right-6 md:bottom-6" onClick={() => { setOpen(true) // Called right in the click, before any state update, so the browser still diff --git a/apps/web/src/components/layout/app-sidebar.tsx b/apps/web/src/components/layout/app-sidebar.tsx index 8fc79f1..ee81376 100644 --- a/apps/web/src/components/layout/app-sidebar.tsx +++ b/apps/web/src/components/layout/app-sidebar.tsx @@ -3,6 +3,7 @@ import { AppLogo } from '@/components/app-logo' import { focusNewItemInput } from '@/components/items/create-item-form' import { isNavItemActive, NAV_ITEMS } from '@/components/layout/nav-items' import { NavUser } from '@/components/layout/nav-user' +import { PinnedListsSidebarGroup } from '@/components/layout/pinned-lists' import { Sidebar, SidebarContent, @@ -60,6 +61,7 @@ export function AppSidebar() { ))} + diff --git a/apps/web/src/components/layout/bottom-nav.tsx b/apps/web/src/components/layout/bottom-nav.tsx index 54a6c6a..d338d7a 100644 --- a/apps/web/src/components/layout/bottom-nav.tsx +++ b/apps/web/src/components/layout/bottom-nav.tsx @@ -2,6 +2,7 @@ import { Link, useRouterState } from '@tanstack/react-router' import { focusNewItemInput } from '@/components/items/create-item-form' import { isNavItemActive, NAV_ITEMS } from '@/components/layout/nav-items' +import { PinnedListsBar } from '@/components/layout/pinned-lists' import { cn } from '@/lib/utils' export function BottomNav() { @@ -9,6 +10,7 @@ export function BottomNav() { return (