From 56cba4cad0a1bbd1be5e67b84472d07377c8f67b Mon Sep 17 00:00:00 2001 From: Peppa Date: Mon, 16 Nov 2026 12:29:10 +0500 Subject: [PATCH] =?UTF-8?q?EA-1:=20=D0=BF=D1=80=D0=B8=D0=BB=D0=BE=D0=B6?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=E2=80=94=20=D0=BF=D0=BE=D0=B4=D0=BA?= =?UTF-8?q?=D0=BB=D1=8E=D1=87=D0=B5=D0=BD=D0=B8=D0=B5=20=D0=BA=D0=B0=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B4=D0=B0=D1=80=D1=8F=20Google=20=D0=B8=20=D1=81?= =?UTF-8?q?=D0=BF=D0=B8=D1=81=D0=BE=D0=BA=20=D0=B4=D0=B5=D0=BB=20=D0=BD?= =?UTF-8?q?=D0=B0=207=20=D0=B4=D0=BD=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Сервер на Hono, клиент Google и его мок, переводы ru/kk/en, тесты по сценариям, проверки и деплой (Dockerfile, /healthz). Co-Authored-By: Claude Fable 5.2 --- .dockerignore | 10 + .gitignore | 1 + .peppa/project.json | 20 +- Dockerfile | 18 + biome.json | 7 + deploy/compose.yml | 10 + docs/glossary.md | 56 +- .../changes/ea-1-calendar-week-view/tasks.md | 20 +- package-lock.json | 2999 +++++++++++++++++ package.json | 30 + src/agenda.ts | 116 + src/app.tsx | 183 + src/config.ts | 30 + src/google/client.ts | 169 + src/google/mock-client.ts | 80 + src/google/mock-events.json | 20 + src/google/types.ts | 34 + src/i18n.ts | 94 + src/index.ts | 18 + src/locales/en.json | 36 + src/locales/kk.json | 36 + src/locales/ru.json | 36 + src/sentry.ts | 31 + src/session.ts | 54 + src/styles.ts | 50 + src/views.tsx | 141 + test/agenda.test.ts | 130 + test/app.test.ts | 425 +++ test/glossary.test.ts | 47 + test/google-client.test.ts | 191 ++ test/helpers.ts | 85 + test/i18n.test.ts | 61 + test/mock-client.test.ts | 55 + test/sentry.test.ts | 45 + test/session.test.ts | 32 + tsconfig.build.json | 5 + tsconfig.json | 19 + vitest.config.ts | 5 + 38 files changed, 5364 insertions(+), 35 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 biome.json create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/agenda.ts create mode 100644 src/app.tsx create mode 100644 src/config.ts create mode 100644 src/google/client.ts create mode 100644 src/google/mock-client.ts create mode 100644 src/google/mock-events.json create mode 100644 src/google/types.ts create mode 100644 src/i18n.ts create mode 100644 src/index.ts create mode 100644 src/locales/en.json create mode 100644 src/locales/kk.json create mode 100644 src/locales/ru.json create mode 100644 src/sentry.ts create mode 100644 src/session.ts create mode 100644 src/styles.ts create mode 100644 src/views.tsx create mode 100644 test/agenda.test.ts create mode 100644 test/app.test.ts create mode 100644 test/glossary.test.ts create mode 100644 test/google-client.test.ts create mode 100644 test/helpers.ts create mode 100644 test/i18n.test.ts create mode 100644 test/mock-client.test.ts create mode 100644 test/sentry.test.ts create mode 100644 test/session.test.ts create mode 100644 tsconfig.build.json create mode 100644 tsconfig.json create mode 100644 vitest.config.ts diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4aedf5d --- /dev/null +++ b/.dockerignore @@ -0,0 +1,10 @@ +node_modules +dist +.git +.env +.env.local +openspec +.agents +.claude +test +docs diff --git a/.gitignore b/.gitignore index 8f85d90..ae3897d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules/ +dist/ .env .env.local .DS_Store diff --git a/.peppa/project.json b/.peppa/project.json index 34ede90..e6a68b9 100644 --- a/.peppa/project.json +++ b/.peppa/project.json @@ -1 +1,19 @@ -{"slug":"executive-ai","key":"EA","name":"Executive AI","peppaUrl":"https://peppa.telecom.quest"} +{ + "slug": "executive-ai", + "key": "EA", + "name": "Executive AI", + "peppaUrl": "https://peppa.telecom.quest", + "checks": { + "install": "npm ci", + "lint": "npm run lint", + "typecheck": "npm run typecheck", + "test": "npm test", + "build": "npm run build" + }, + "deploy": { + "compose": "deploy/compose.yml", + "service": "web", + "port": 3000, + "health": "/healthz" + } +} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..84145d7 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Executive AI: сервер на Node.js, слушает $PORT, отвечает 200 на GET /healthz. +FROM node:22-bookworm-slim AS build +WORKDIR /app +COPY package.json package-lock.json ./ +RUN npm ci +COPY tsconfig.json tsconfig.build.json ./ +COPY src ./src +RUN npm run build && npm prune --omit=dev + +FROM node:22-bookworm-slim +WORKDIR /app +ENV NODE_ENV=production PORT=3000 +COPY --from=build /app/package.json ./ +COPY --from=build /app/node_modules ./node_modules +COPY --from=build /app/dist ./dist +USER node +EXPOSE 3000 +CMD ["node", "dist/index.js"] diff --git a/biome.json b/biome.json new file mode 100644 index 0000000..31feaad --- /dev/null +++ b/biome.json @@ -0,0 +1,7 @@ +{ + "$schema": "./node_modules/@biomejs/biome/configuration_schema.json", + "vcs": { "enabled": true, "clientKind": "git", "useIgnoreFile": true }, + "files": { "includes": ["**", "!openspec", "!.agents", "!.claude", "!dist"] }, + "formatter": { "indentStyle": "space", "indentWidth": 2, "lineWidth": 100 }, + "linter": { "enabled": true, "rules": { "preset": "recommended" } } +} diff --git a/deploy/compose.yml b/deploy/compose.yml index 01936ba..28806ac 100644 --- a/deploy/compose.yml +++ b/deploy/compose.yml @@ -8,6 +8,16 @@ services: restart: unless-stopped environment: PORT: "${APP_PORT:-3000}" + # Ключи календаря Google; пока их нет, продукт работает на примерах (мок). + GOOGLE_CLIENT_ID: "${GOOGLE_CLIENT_ID:-}" + GOOGLE_CLIENT_SECRET: "${GOOGLE_CLIENT_SECRET:-}" + # Необязательно: отдельный секрет шифрования подключения и внешний адрес продукта. + SESSION_SECRET: "${SESSION_SECRET:-}" + PUBLIC_URL: "${PUBLIC_URL:-}" + # Ошибки продукта (Bugsink); без DSN ничего не отправляется. + SENTRY_DSN: "${SENTRY_DSN:-}" + SENTRY_RELEASE: "${SENTRY_RELEASE:-}" + SENTRY_ENVIRONMENT: "${SENTRY_ENVIRONMENT:-}" networks: - traefik_default labels: diff --git a/docs/glossary.md b/docs/glossary.md index 5fa372f..de071d2 100644 --- a/docs/glossary.md +++ b/docs/glossary.md @@ -8,27 +8,35 @@ Новое понятие сначала добавляется сюда, потом на экран. Проверка в CI (PEP-124) читает этот файл: строки таблицы ниже — её входные данные, формат колонок не менять. -| Понятие | Пишем | Нельзя | Пояснение | -|---|---|---|---| -| Обращение | вы, вам, ваш | ты, тебе, твой, тебя | Только на «вы», со строчной буквы | -| Название продукта | Peppa FACTORY | Пеппа, Peppa, фабрика Пеппы | Латиницей на всех языках, не переводится | -| Единица работы | задача | стори, story, таск, тикет, issue | «Задача BS-3» | -| Большая цель | эпик | goal, майлстоун | Набор задач с общим результатом | -| Исполнитель | агент, ИИ-агент | раннер, runner, сессия, процесс, бот | «Агент Шустрик взял задачу» | -| Аналитик проекта | аналитик | LLM, модель, ассистент | ИИ-агент, с которым обсуждают задачи | -| План работы | план | proposal, change, OpenSpec, спека | «Агент составляет план» | -| Сделанная работа | результат, изменения | PR, pull request, merge request, коммит, ветка, мерж, дифф | «Посмотрите результат» | -| Автоматическая проверка | проверки | CI, пайплайн, pipeline, линт, билд | «Проверки пройдены» | -| Версия до показа всем | версия для проверки | staging, стейджинг, preview, превью-стенд, стенд | Кнопка «Посмотреть» | -| Версия для всех | рабочая версия, ваш продукт | прод, production, продакшн | «Ваш продукт работает» | -| Показ всем | показать всем, обновить продукт | деплой, выкатка, выкатить, релиз, deploy | «Показать всем пользователям» | -| Где лежит код | код проекта | репозиторий, репо, Gitea, git | Продакту адрес кода не нужен | -| На чём работают агенты | подписка | провайдер, токен, пул, OAuth, API-ключ | «Подписка Peppa FACTORY», «своя подписка» | -| Ход работы агента | что делает агент, шаг N из M | терминал, tmux, команда, лог, контекст, хук | Подробности — под «Подробнее» | -| Настройки агента | под «Подробнее» | модель, усилия, effort, sonnet, opus, haiku | Только в режиме «Инженер» | -| Расход | не показываем | $, USD, токены, стоимость | Суммы — только в режиме «Инженер» | -| Сбой | ошибка: что случилось и что сделать | exception, стектрейс, traceback, 500, код ошибки | Две фразы, без кодов | -| Принять работу | принять | апрув, approve, смержить | Кнопка «Принять» | -| Вернуть работу | поправить | реджект, вернуть в бэклог, change request | Кнопка «Поправить» | -| Список задач | доска, бэклог | канбан-борд, backlog | «Бэклог» допустим как название колонки | -| Ошибки продукта | баги | инциденты, Bugsink, Sentry | Вкладка «Баги» | +| Понятие | Пишем | Нельзя | Пояснение | +| ------------------------------------------- | ------------------------------------------------------ | --------------------------------------------------------------- | ----------------------------------------- | +| Обращение | вы, вам, ваш | ты, тебе, твой, тебя | Только на «вы», со строчной буквы | +| Название продукта | Peppa FACTORY | Пеппа, Peppa, фабрика Пеппы | Латиницей на всех языках, не переводится | +| Единица работы | задача | стори, story, таск, тикет, issue | «Задача BS-3» | +| Большая цель | эпик | goal, майлстоун | Набор задач с общим результатом | +| Исполнитель | агент, ИИ-агент | раннер, runner, сессия, процесс, бот | «Агент Шустрик взял задачу» | +| Аналитик проекта | аналитик | LLM, модель, ассистент | ИИ-агент, с которым обсуждают задачи | +| План работы | план | proposal, change, OpenSpec, спека | «Агент составляет план» | +| Сделанная работа | результат, изменения | PR, pull request, merge request, коммит, ветка, мерж, дифф | «Посмотрите результат» | +| Автоматическая проверка | проверки | CI, пайплайн, pipeline, линт, билд | «Проверки пройдены» | +| Версия до показа всем | версия для проверки | staging, стейджинг, preview, превью-стенд, стенд | Кнопка «Посмотреть» | +| Версия для всех | рабочая версия, ваш продукт | прод, production, продакшн | «Ваш продукт работает» | +| Показ всем | показать всем, обновить продукт | деплой, выкатка, выкатить, релиз, deploy | «Показать всем пользователям» | +| Где лежит код | код проекта | репозиторий, репо, Gitea, git | Продакту адрес кода не нужен | +| На чём работают агенты | подписка | провайдер, токен, пул, OAuth, API-ключ | «Подписка Peppa FACTORY», «своя подписка» | +| Ход работы агента | что делает агент, шаг N из M | терминал, tmux, команда, лог, контекст, хук | Подробности — под «Подробнее» | +| Настройки агента | под «Подробнее» | модель, усилия, effort, sonnet, opus, haiku | Только в режиме «Инженер» | +| Расход | не показываем | $, USD, токены, стоимость | Суммы — только в режиме «Инженер» | +| Сбой | ошибка: что случилось и что сделать | exception, стектрейс, traceback, 500, код ошибки | Две фразы, без кодов | +| Принять работу | принять | апрув, approve, смержить | Кнопка «Принять» | +| Вернуть работу | поправить | реджект, вернуть в бэклог, change request | Кнопка «Поправить» | +| Список задач | доска, бэклог | канбан-борд, backlog | «Бэклог» допустим как название колонки | +| Ошибки продукта | баги | инциденты, Bugsink, Sentry | Вкладка «Баги» | +| Название этого продукта | Executive AI, EA | ЕА-бот, ассистент | Латиницей на всех языках, не переводится | +| Календарь пользователя | календарь, календарь Google | Google API, интеграция, синхронизация, синк | «Подключите календарь» | +| Запись в календаре | событие, дело | ивент, митинг, слот, запись календаря | «Ваши дела на 7 дней» | +| Связь с календарём | подключить календарь, календарь подключён | авторизация, авторизоваться, залогиниться, scope, refresh-токен | «Календарь подключён» | +| Нет доступа к календарю | доступ к календарю закрыт, подключите календарь заново | отозван токен, сессия истекла, 401, 403 | Две фразы: что случилось и что сделать | +| Событие без времени начала | весь день | all-day, целодневное | Отметка вместо времени | +| Событие, которое началось раньше и ещё идёт | продолжается | carry-over, перенос | Отметка вместо времени | +| Демонстрационные данные | примеры | мок, mock, демо-данные, заглушка, фейк, тестовые данные | «Это примеры, а не ваш календарь» | diff --git a/openspec/changes/ea-1-calendar-week-view/tasks.md b/openspec/changes/ea-1-calendar-week-view/tasks.md index 115997b..e2b05b8 100644 --- a/openspec/changes/ea-1-calendar-week-view/tasks.md +++ b/openspec/changes/ea-1-calendar-week-view/tasks.md @@ -2,32 +2,32 @@ ## 1. Каркас проекта и проверки -- [ ] 1.1 Создать проект Node.js/TypeScript (package.json, tsconfig, Biome, Vitest, Hono) с `GET /healthz`; проверка: `npm run lint`, `npm run typecheck`, `npm test`, `npm run build` проходят, тест `/healthz` возвращает 200 -- [ ] 1.2 Заполнить `checks` в `.peppa/project.json`; проверка: `bash .gitea/peppa-check.sh ` выполняет команды и завершается с кодом 0 +- [x] 1.1 Создать проект Node.js/TypeScript (package.json, tsconfig, Biome, Vitest, Hono) с `GET /healthz`; проверка: `npm run lint`, `npm run typecheck`, `npm test`, `npm run build` проходят, тест `/healthz` возвращает 200 +- [x] 1.2 Заполнить `checks` в `.peppa/project.json`; проверка: `bash .gitea/peppa-check.sh ` выполняет команды и завершается с кодом 0 ## 2. Язык экрана и словарь -- [ ] 2.1 Добавить переводы `src/locales/{ru,kk,en}.json`, выбор языка (адрес → cookie → язык браузера → русский) и форматирование дат; проверка: тесты сценариев `interface-language` и тест совпадения ключей трёх файлов проходят -- [ ] 2.2 Дописать слова продукта в `docs/glossary.md` и тест, сверяющий русские тексты со столбцом «Нельзя»; проверка: тест проходит +- [x] 2.1 Добавить переводы `src/locales/{ru,kk,en}.json`, выбор языка (адрес → cookie → язык браузера → русский) и форматирование дат; проверка: тесты сценариев `interface-language` и тест совпадения ключей трёх файлов проходят +- [x] 2.2 Дописать слова продукта в `docs/glossary.md` и тест, сверяющий русские тексты со столбцом «Нельзя»; проверка: тест проходит ## 3. Список на 7 дней -- [ ] 3.1 Реализовать чистую функцию построения списка (окно 7 дней в поясе календаря, «весь день», порядок, группы по дням, «Без названия»); проверка: тесты сценариев `week-agenda` (окно, пояс, идущее событие, сортировка, пустая неделя) проходят +- [x] 3.1 Реализовать чистую функцию построения списка (окно 7 дней в поясе календаря, «весь день», порядок, группы по дням, «Без названия»); проверка: тесты сценариев `week-agenda` (окно, пояс, идущее событие, сортировка, пустая неделя) проходят ## 4. Подключение календаря Google -- [ ] 4.1 Реализовать интерфейс `GoogleClient`: настоящий клиент (OAuth-обмен, обновление доступа, чтение событий с листанием страниц, классы ошибок) и `mockGoogleClient` с тем же контрактом; проверка: тесты клиента на подставном `fetch` (успех, `invalid_grant`, 401, 500, вторая страница) и тесты мока проходят -- [ ] 4.2 Реализовать шифрованную cookie подключения и маршруты `/connect`, `/auth/google/callback` с проверкой `state`; проверка: тесты сценариев «Успешное подключение», «Подключение сохраняется», «Запрашивается только чтение», «Отказ», «Ответ не от этого браузера», «Подключение не сохранилось» проходят +- [x] 4.1 Реализовать интерфейс `GoogleClient`: настоящий клиент (OAuth-обмен, обновление доступа, чтение событий с листанием страниц, классы ошибок) и `mockGoogleClient` с тем же контрактом; проверка: тесты клиента на подставном `fetch` (успех, `invalid_grant`, 401, 500, вторая страница) и тесты мока проходят +- [x] 4.2 Реализовать шифрованную cookie подключения и маршруты `/connect`, `/auth/google/callback` с проверкой `state`; проверка: тесты сценариев «Успешное подключение», «Подключение сохраняется», «Запрашивается только чтение», «Отказ», «Ответ не от этого браузера», «Подключение не сохранилось» проходят ## 5. Экран -- [ ] 5.1 Сверстать главную страницу: предложение подключить, отметка «Календарь подключён», список по дням, пустая неделя, сообщения об отзыве доступа и сбое, пометка о примерах, переключатель языка; проверка: тесты страницы через `app.request()` по сценариям `calendar-connection` и `week-agenda` («Только просмотр», «Свежие данные») проходят +- [x] 5.1 Сверстать главную страницу: предложение подключить, отметка «Календарь подключён», список по дням, пустая неделя, сообщения об отзыве доступа и сбое, пометка о примерах, переключатель языка; проверка: тесты страницы через `app.request()` по сценариям `calendar-connection` и `week-agenda` («Только просмотр», «Свежие данные») проходят - [ ] 5.2 Открыть экраны в браузере на трёх языках на моке, выписать видимые тексты и сверить со словарём; проверка: снимки состояний просмотрены, нарушений словаря нет ## 6. Деплой и ошибки продукта -- [ ] 6.1 Подключить `@sentry/node` (DSN, release, environment из окружения, `sendDefaultPii: false`); проверка: тест — без `SENTRY_DSN` приложение стартует и не отправляет ничего -- [ ] 6.2 Добавить `Dockerfile`, `deploy` в `.peppa/project.json`, переменные окружения в `deploy/compose.yml`; проверка: `docker build .`, запуск образа с `PORT=3000`, `curl /healthz` возвращает 200, главная страница открывается +- [x] 6.1 Подключить `@sentry/node` (DSN, release, environment из окружения, `sendDefaultPii: false`); проверка: тест — без `SENTRY_DSN` приложение стартует и не отправляет ничего +- [x] 6.2 Добавить `Dockerfile`, `deploy` в `.peppa/project.json`, переменные окружения в `deploy/compose.yml`; проверка: `docker build .`, запуск образа с `PORT=3000`, `curl /healthz` возвращает 200, главная страница открывается ## 7. Итоговая проверка diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..47010d3 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2999 @@ +{ + "name": "executive-ai", + "version": "0.1.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "executive-ai", + "version": "0.1.0", + "dependencies": { + "@hono/node-server": "^2.1.8", + "@sentry/node": "^11.12.0", + "hono": "^4.13.18" + }, + "devDependencies": { + "@biomejs/biome": "^2.6.8", + "@types/node": "^22.20.5", + "tsx": "^4.23.15", + "typescript": "^7.0.2", + "vitest": "^5.1.0" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@biomejs/biome": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.6.8.tgz", + "integrity": "sha512-kqZUFvX6/aYQOmzfRN5ANcfNS9wLH4aHLWWP/dQKyhRZVoA6rdWszA7DGugFcxPbMiznUyVYyukVl+ExZN4PQA==", + "dev": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-android-arm64": "2.6.8", + "@biomejs/cli-android-x64": "2.6.8", + "@biomejs/cli-darwin-arm64": "2.6.8", + "@biomejs/cli-darwin-x64": "2.6.8", + "@biomejs/cli-linux-arm64": "2.6.8", + "@biomejs/cli-linux-arm64-musl": "2.6.8", + "@biomejs/cli-linux-x64": "2.6.8", + "@biomejs/cli-linux-x64-musl": "2.6.8", + "@biomejs/cli-win32-arm64": "2.6.8", + "@biomejs/cli-win32-x64": "2.6.8" + } + }, + "node_modules/@biomejs/cli-android-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-android-arm64/-/cli-android-arm64-2.6.8.tgz", + "integrity": "sha512-X4JKPLK85kfUTwuuaORFplnBfGjKkp62PsFhhcL7F/Tpltc7pyUofjlkkMnlZZLWsifFl7LNB8ngVrwJg1uo1Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-android-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-android-x64/-/cli-android-x64-2.6.8.tgz", + "integrity": "sha512-C3Hk485vl+deEj53K08+SYYelPIPkdSZL3qHuD31Xi+qydVa4q2ze+aCYo1k3iJGWtvWtjHaGkDh7S2sX6wk8w==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.6.8.tgz", + "integrity": "sha512-DHyj+JnRHcn4YdvpiqgTFZMYKSPELMCfFpNNlEuu1L8DKTGXhzW7raIwdsbo2Ie9nCljQLAQkVWQk/mwM0ueiA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.6.8.tgz", + "integrity": "sha512-QWWUPjlA0RnkkgYnFLUHZu+RrDc0FdK0A+wEPA+dENQJwsuSHMH89lspnAw2QUWWc9VHyfluGx1Xmp6Y2GZi8Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.6.8.tgz", + "integrity": "sha512-0Bjim8lKwnrvXUHoI4k3Tb51BjoiLEwDnovCI8nSzkk6wj3dShiuAjrx6+X0Hjf4ejR1sRZgTQiSDHlpy9vB7w==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.6.8.tgz", + "integrity": "sha512-WB9PhOitX+bRc0G3+GNJGlvbKoWn3JoB9z4E04JQizIC9aPCQyIvwvWG7QZHxw6k20Fi+dHLmZ2fSEmBa9HqiA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.6.8.tgz", + "integrity": "sha512-XIk3pLQT56I6Tti+u0DF8FtSNXjCMTPbxVTzfJ9cS2t1ImVKvrqV5b52GuEaJg6/wuiXvz0sjfb5saB4TPRjzA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.6.8.tgz", + "integrity": "sha512-64Yzo+J4fEk7Kf9SMnVdVxC+Y2A2e/L86QTP9JjGQ57lsddyELLpbBcNMxSJggre2T1AvISwwSrOApkBAHDqNA==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.6.8.tgz", + "integrity": "sha512-ezjCEZzHIWE2pdh83a7zLVcAAcDaERcTcvfA7uWlxqz/1CuDxgtfO19pDg9B6YY4wKYIDvYBw2QCMnqIshSwmw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "2.6.8", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.6.8.tgz", + "integrity": "sha512-cD6HvGczZUiAYsY8s2TxxXj2AHFzEdMomvVJfEjzOjBM45nGqIDfBpbtvwGQzDCN8X2yKKk9u1jnDZisT2nxIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@emnapi/core": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-2.0.0-beta.2.tgz", + "integrity": "sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@emnapi/wasi-threads": "2.2.0", + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/runtime": { + "version": "2.0.0-beta.2", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-2.0.0-beta.2.tgz", + "integrity": "sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@emnapi/wasi-threads": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-2.2.0.tgz", + "integrity": "sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.28.2.tgz", + "integrity": "sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.28.2.tgz", + "integrity": "sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.28.2.tgz", + "integrity": "sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.28.2.tgz", + "integrity": "sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.28.2.tgz", + "integrity": "sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.28.2.tgz", + "integrity": "sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.28.2.tgz", + "integrity": "sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.28.2.tgz", + "integrity": "sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.28.2.tgz", + "integrity": "sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.28.2.tgz", + "integrity": "sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.28.2.tgz", + "integrity": "sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.28.2.tgz", + "integrity": "sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.28.2.tgz", + "integrity": "sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.28.2.tgz", + "integrity": "sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.28.2.tgz", + "integrity": "sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.28.2.tgz", + "integrity": "sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.28.2.tgz", + "integrity": "sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.28.2.tgz", + "integrity": "sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.28.2.tgz", + "integrity": "sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.28.2.tgz", + "integrity": "sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.28.2.tgz", + "integrity": "sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.28.2.tgz", + "integrity": "sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.28.2.tgz", + "integrity": "sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.28.2.tgz", + "integrity": "sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.28.2.tgz", + "integrity": "sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.28.2.tgz", + "integrity": "sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@hono/node-server": { + "version": "2.1.8", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.8.tgz", + "integrity": "sha512-jdf7FHh6A1lzjpHHQUgxsg2GeER2vMetnAOfeActzcoli6jamlK+NAwL6Dsr5Fl3BS3tYUQzCdtZjU8Qxv7bEA==", + "license": "MIT", + "engines": { + "node": ">=20" + }, + "peerDependencies": { + "hono": "^4 || ^5.0.0-0" + } + }, + "node_modules/@isaacs/nonrecursive-glob-match": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@isaacs/nonrecursive-glob-match/-/nonrecursive-glob-match-1.1.0.tgz", + "integrity": "sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==", + "license": "BlueOak-1.0.0" + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.3.tgz", + "integrity": "sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.6.0.tgz", + "integrity": "sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==", + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.31", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", + "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@napi-rs/wasm-runtime": { + "version": "1.2.6", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.2.6.tgz", + "integrity": "sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@tybys/wasm-util": "^0.10.3" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/Brooooooklyn" + }, + "peerDependencies": { + "@emnapi/core": "^1.7.1 || 2.0.0-beta.2", + "@emnapi/runtime": "^1.7.1 || 2.0.0-beta.2" + } + }, + "node_modules/@opentelemetry/api": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/@opentelemetry/api/-/api-1.10.0.tgz", + "integrity": "sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=8.0.0" + } + }, + "node_modules/@oxc-parser/binding-android-arm-eabi": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm-eabi/-/binding-android-arm-eabi-0.152.0.tgz", + "integrity": "sha512-393VtirINkae4XHBTkq/yQxhOwEr4V+r0et37P2fp+sYZSdYgZTRDPo5Um8vBh0QjMZ+RmaMy4PP0qwr4cTMwA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-android-arm64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-android-arm64/-/binding-android-arm64-0.152.0.tgz", + "integrity": "sha512-iYFcExATJNZ0rZj0o02THbD1Nc9jAW0nVgIQPee6ejbSASpbZXlIMw8jxtpzaG14JQTWwGSZ6U5dEtRJXE6V3Q==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-darwin-arm64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-arm64/-/binding-darwin-arm64-0.152.0.tgz", + "integrity": "sha512-fnU+DfUzi5/rFy0LzmipYRz06PAUUkOS8kCJQ3Eg6oqlunC1XZXoffFqxmdL51RmcbYtUG3P8DVG1U5fckoa2A==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-darwin-x64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-darwin-x64/-/binding-darwin-x64-0.152.0.tgz", + "integrity": "sha512-Y3U2okryWTs7hDld6UhjJwLNf8/do+x4g4C+1U5SiGwrTLwbO83WJYJA8+l9iFSilWBgnfpd/+U76tfeNxUHzA==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-freebsd-x64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-freebsd-x64/-/binding-freebsd-x64-0.152.0.tgz", + "integrity": "sha512-XkhkRrrPffEw+ZLv/d/5pEni0buxinm/E/N6fLbJCunD1DBbeCTtVP23ESV+4CWCWdSz397asks1ViGslpmWiQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm-gnueabihf": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-0.152.0.tgz", + "integrity": "sha512-MLzsRRbdfmdzo6JEhbC1yKU9ItfvM8tEf18HM32jCiNYZEz6J3bRBRl3cTkKR0vBdrk9ZVlcARXtwHccs+epDA==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm-musleabihf": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm-musleabihf/-/binding-linux-arm-musleabihf-0.152.0.tgz", + "integrity": "sha512-HHerTEJz7Iy10Ji6BGsk4gqG6PU0UzFuBu91jIEOX89FnrI5ECWSEr7BLpkYQhp7U0QFtMnBhNfQKI0hYZK78w==", + "cpu": [ + "arm" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-0.152.0.tgz", + "integrity": "sha512-9Bb8GyzZ2uSLzRDZ27usaKokr07mxiBe2dDF5b6bd2janmaJTT1gL51UfP7AU30yFiXrJvcRyFKREAgKwZYs0w==", + "cpu": [ + "arm64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-arm64-musl": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-arm64-musl/-/binding-linux-arm64-musl-0.152.0.tgz", + "integrity": "sha512-om7iDMUroI74A/lfRRWY9/Ev3VWrVsrUZ4tyvyh8raBey/sdcfyAD7tYWc+iykAiotnmftyKTpUKFr1QnaBrAQ==", + "cpu": [ + "arm64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-ppc64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-0.152.0.tgz", + "integrity": "sha512-Lf1OL2lMTqwDMFC6jnRb30B+WYHKV0XT+bPHcFM6xHtNVwxpobiTzUIvKH6a0LWpvfwyru8Yu6zCGHqqFHH+gg==", + "cpu": [ + "ppc64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-riscv64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-gnu/-/binding-linux-riscv64-gnu-0.152.0.tgz", + "integrity": "sha512-BYWSMQK+YJ9ZILStPcmmiSVq8KEG9Qdq/c4BHPC3rUEq/fEDCVjUIwdj5ZzjgZ9P9is9PKu0tcAXzq1ZXg4urQ==", + "cpu": [ + "riscv64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-riscv64-musl": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-riscv64-musl/-/binding-linux-riscv64-musl-0.152.0.tgz", + "integrity": "sha512-d2LqHNNNqdH185sRK5dPKWZu201JrNu9/CRFuVEuT+ht7n/QaVblEMWT9MALQPrDWYvhG10P+NSKJFquDWZ09w==", + "cpu": [ + "riscv64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-s390x-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-0.152.0.tgz", + "integrity": "sha512-8gBeHt5rA/8+pKhHl+zLggfa3L/V/L2at96p7ty6pBE7id6lFO19nFUc15u2PcjC4OYeYK465MKy1fhhbpFIGw==", + "cpu": [ + "s390x" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-x64-gnu": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-gnu/-/binding-linux-x64-gnu-0.152.0.tgz", + "integrity": "sha512-ltgrSF6L+yPTVsIdaAyqKq3zTqzj/1VlNbxWZuxAe8flR3sWdyNsKvdXukoO8/ucJbLickhmieRBge+o/e8Ugw==", + "cpu": [ + "x64" + ], + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-linux-x64-musl": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-linux-x64-musl/-/binding-linux-x64-musl-0.152.0.tgz", + "integrity": "sha512-LcMp6BvrBnewSfdkLHoSqidhoAq4syKOTBV5TYHWd+2VnGkfD/nPRRVIzTBt/Lkbt7pfOFDGtkiTntFS0p6sQQ==", + "cpu": [ + "x64" + ], + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-openharmony-arm64": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-openharmony-arm64/-/binding-openharmony-arm64-0.152.0.tgz", + "integrity": "sha512-jbhoMCslVxzRCRNQ8TSHxjYdSKRvk8O6ciLVDkahJvmyHDzBqba/bMQHM6ULKj/rgHNNbSzlIiakdx8SEfkJzA==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-win32-arm64-msvc": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-0.152.0.tgz", + "integrity": "sha512-JZYVlhv36mr/nertnRB7vchJECOBb1Lz6lltalILsB+o9M/is+H6BEDRLQKdqA4JKs6NjJszo46+iM5sfwj6jQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-win32-ia32-msvc": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-ia32-msvc/-/binding-win32-ia32-msvc-0.152.0.tgz", + "integrity": "sha512-1X9oganvVsunRH0lH10UU05N+H9atpX6WsOybByUjwnfcd3h/0tYwvuv16XuHglrIUOnxV2TodbLVEwwafd64g==", + "cpu": [ + "ia32" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-parser/binding-win32-x64-msvc": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-parser/binding-win32-x64-msvc/-/binding-win32-x64-msvc-0.152.0.tgz", + "integrity": "sha512-sw0M80/dn9rcpu+Rqqph/C+MjvDDce6MlXmFjsNQtPEymha0eJy3ml6+foSUTqFfpDIDyHZZ4eoJ43IoMe8bJw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@oxc-project/types": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.152.0.tgz", + "integrity": "sha512-oM/5rLBm2tPkg0iBgkH/FOeR3PCDpY19GTgAZjMFM8h9WI9VW7cLgzp6nwtarYKmovavIQZ+Fe/RKX/8C8O/Rw==", + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/@rolldown/binding-android-arm-eabi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm-eabi/-/binding-android-arm-eabi-1.2.19.tgz", + "integrity": "sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-android-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.2.19.tgz", + "integrity": "sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.2.19.tgz", + "integrity": "sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-darwin-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.2.19.tgz", + "integrity": "sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-freebsd-x64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.2.19.tgz", + "integrity": "sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm-gnueabihf": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.2.19.tgz", + "integrity": "sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.2.19.tgz", + "integrity": "sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-arm64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.2.19.tgz", + "integrity": "sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-ppc64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.2.19.tgz", + "integrity": "sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==", + "cpu": [ + "ppc64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-s390x-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.2.19.tgz", + "integrity": "sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==", + "cpu": [ + "s390x" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-gnu": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.2.19.tgz", + "integrity": "sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-linux-x64-musl": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.2.19.tgz", + "integrity": "sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-openharmony-arm64": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.2.19.tgz", + "integrity": "sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openharmony" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-wasm32-wasi": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.2.19.tgz", + "integrity": "sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==", + "cpu": [ + "wasm32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "@emnapi/core": "2.0.0-beta.2", + "@emnapi/runtime": "2.0.0-beta.2", + "@napi-rs/wasm-runtime": "1.2.6" + }, + "engines": { + "node": "^20.19.0 || ^22.13.0 || >=23.5.0" + } + }, + "node_modules/@rolldown/binding-win32-arm64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.2.19.tgz", + "integrity": "sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/binding-win32-x64-msvc": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.2.19.tgz", + "integrity": "sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": "^20.19.0 || >=22.12.0" + } + }, + "node_modules/@rolldown/pluginutils": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.1.1.tgz", + "integrity": "sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==", + "dev": true, + "license": "MIT", + "peer": true + }, + "node_modules/@sentry/bundler-plugins": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@sentry/bundler-plugins/-/bundler-plugins-11.12.0.tgz", + "integrity": "sha512-7vBXoHMoYKjYu08anYv5I0nplSWOfQyl7BqV0VOrLxEtGoOpk1+DxL2dyBiaWoAtISkaqJEV/ft813OsCGuuMg==", + "license": "MIT", + "dependencies": { + "@sentry/core": "11.12.0", + "dotenv": "^17.4.2", + "glob": "^14.0.3", + "magic-string": "~0.30.8 || ^1.0.0", + "oxc-parser": "^0.152.0", + "sentry": "^0.49.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + }, + "peerDependencies": { + "rollup": ">=3.2.0", + "webpack": ">=5.1.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "webpack": { + "optional": true + } + } + }, + "node_modules/@sentry/conventions": { + "version": "0.32.0", + "resolved": "https://registry.npmjs.org/@sentry/conventions/-/conventions-0.32.0.tgz", + "integrity": "sha512-WkSQcDhUUsz1SwxR23LpmyPKba+dgxxiH0DWV4VSM9yaAvhhl87ppW2Ts3g4piIKCVflc31aJeWy+biUbYfsMQ==", + "license": "MIT", + "engines": { + "node": ">=14" + } + }, + "node_modules/@sentry/core": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@sentry/core/-/core-11.12.0.tgz", + "integrity": "sha512-HKER7EcRpPPgC8mLRe5BzP6njfRYFZ53BFLZxVp1whWbY6lp/b2mvTBk4q6+rKsUFhLhRDsd6jL8y/8ddEWv6A==", + "license": "MIT", + "dependencies": { + "@sentry/conventions": "^0.32.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + } + }, + "node_modules/@sentry/node": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@sentry/node/-/node-11.12.0.tgz", + "integrity": "sha512-MNSZDOd92Twrq5Z4ZAkxZdIfhr3YGytFb1T+vh5bNXVHkqByWpI/P2VtTSrzBR4Pi1IDRMz0i8t/OWNOsuAuBg==", + "license": "MIT", + "dependencies": { + "@opentelemetry/api": "^1.9.1", + "@sentry/bundler-plugins": "11.12.0", + "@sentry/conventions": "^0.32.0", + "@sentry/core": "11.12.0", + "@sentry/opentelemetry": "11.12.0", + "@sentry/server-runtime-injection": "11.12.0", + "@sentry/server-utils": "11.12.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + } + }, + "node_modules/@sentry/opentelemetry": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@sentry/opentelemetry/-/opentelemetry-11.12.0.tgz", + "integrity": "sha512-oWJwUdc2OSSvyOPXn/E1nWkC3GV5KNTWfR5prbw/0XxlKJepdlBsW19y+FAE9n3QznZ52aMZmetWEAFMsPJ0KQ==", + "license": "MIT", + "dependencies": { + "@sentry/conventions": "^0.32.0", + "@sentry/core": "11.12.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + }, + "peerDependencies": { + "@opentelemetry/api": "^1.9.0" + } + }, + "node_modules/@sentry/server-runtime-injection": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@sentry/server-runtime-injection/-/server-runtime-injection-11.12.0.tgz", + "integrity": "sha512-fAZjCFyEfhvyfEdbav0/X13Yqbom5Ka1+hG0Nyl6bd7GxkQIWd68unSIw/Rvzfj/DSO8A1JidezST3D6omALkw==", + "license": "MIT", + "dependencies": { + "@sentry/core": "11.12.0", + "@sentry/server-utils": "11.12.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + } + }, + "node_modules/@sentry/server-utils": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/@sentry/server-utils/-/server-utils-11.12.0.tgz", + "integrity": "sha512-gAP5FLhXSiMs9vsU7guc54QNY1OzUJmhqyXMjhiP4SYlhQltoKtipcyo8pFWVsmylIzIkA8e2eGR6e0YA6YF3A==", + "license": "MIT", + "dependencies": { + "@opentelemetry/api": "^1.9.1", + "@sentry/conventions": "^0.32.0", + "@sentry/core": "11.12.0" + }, + "engines": { + "node": ">=20.19.0 <22.0.0 || >=22.12.0 <23.0.0 || >=23.2.0" + } + }, + "node_modules/@tybys/wasm-util": { + "version": "0.10.4", + "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.4.tgz", + "integrity": "sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==", + "dev": true, + "license": "MIT", + "optional": true, + "peer": true, + "dependencies": { + "tslib": "^2.4.0" + } + }, + "node_modules/@types/chai": { + "version": "5.2.3", + "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", + "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/deep-eql": "*", + "assertion-error": "^2.0.1" + } + }, + "node_modules/@types/deep-eql": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", + "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", + "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.20.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", + "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.21.0" + } + }, + "node_modules/@typescript/typescript-aix-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-aix-ppc64/-/typescript-aix-ppc64-7.0.2.tgz", + "integrity": "sha512-MTKKkWB7p/0E9xi1d1tHtZ5PiLkGEMIq88pK2CubZjOsLtYTLqhgIgi6zepFa+9GHZ6h05NMCkQxGKiPXMxXtQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-arm64/-/typescript-darwin-arm64-7.0.2.tgz", + "integrity": "sha512-gowzar9MwS/aRWp6f3a4KUqzRjAZjOsmGNCM6LcTgXum+dBfgsBVMN+AgvOCCbguXyick6LJhpBszxMebJ8syA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-darwin-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-darwin-x64/-/typescript-darwin-x64-7.0.2.tgz", + "integrity": "sha512-SZ9xZInqApNlNGc9s0W1VSsktYSOe9cFqNOIqmN1Gs8SmkjKZYFt017G4VwPxASInODuAdbTW7sXiFUf893RgA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-arm64/-/typescript-freebsd-arm64-7.0.2.tgz", + "integrity": "sha512-W5NH4y/J0plIIS5b2xvTEkU7JFxyqdMAOgf+Ilhl0vHQXKO5dZoxd+C/jEtq56c4F3wk71RB4BMRQ2XdI+bwYQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-freebsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-freebsd-x64/-/typescript-freebsd-x64-7.0.2.tgz", + "integrity": "sha512-UMGDx5sTpzNw3WiPebH7l90IWfJggEd+egHt/q6p7/Cm3zqoV7VxkGXt+3DxPIw8CcmvAB0j3sVVfbhX+M4Tpw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm/-/typescript-linux-arm-7.0.2.tgz", + "integrity": "sha512-gffT3xPz9sR7j/YJExkyPntrI0P2EP9XbOyWzth2/Gs0RstK+90RBcO0ncXoXy/beYll1SXw846Nf2zdnEz0QQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-arm64/-/typescript-linux-arm64-7.0.2.tgz", + "integrity": "sha512-Qh4eU4/y3yDjnfjjyPYihMj5/ODIlmt+Bzu17OI+fiSRDW57QmU5SiN63exPRNJPKUzcc1INa1NXdrJ+MqHjUQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-loong64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-loong64/-/typescript-linux-loong64-7.0.2.tgz", + "integrity": "sha512-uEHck9i8hoAzXPiYRib1O7miOnz23SxIeVl6F4LXox+qov1K35jHcEW6VHKvZI+pyvl7fZEP4MCU5LYvIq1GuQ==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-mips64el": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-mips64el/-/typescript-linux-mips64el-7.0.2.tgz", + "integrity": "sha512-R4KvAMnE43W5Qeqb0Ly56O3mWMWIAgsMyz36DCaycd5nbg/9kzm0liw3JocfRqyJY0KPmzFjbswozXyW0DnIYA==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-ppc64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-ppc64/-/typescript-linux-ppc64-7.0.2.tgz", + "integrity": "sha512-DORx5b3sd/4S7eayxm4FQv+A7CrkUIGRaHiwI8oiHTAI1fAPWhF4J0vAlkC8biAlHSVVwxMQ3tjZ2/DVbnQiiA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-riscv64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-riscv64/-/typescript-linux-riscv64-7.0.2.tgz", + "integrity": "sha512-wf0jqEDOjrPRnKwYRyyJDRo11KMbvMFrU+q4zqKyChODBzvlkbhNQfKvLxQCcwTpdDaXSHZTVuh0JoCrKCUMHQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-s390x": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-s390x/-/typescript-linux-s390x-7.0.2.tgz", + "integrity": "sha512-IkwJc3L7yhytWd/ewjyxNDfOmswCm9GWMJT/ue/dU4aZNbwZeYAetq42VyLmsmSjvoX7z74X6ZaYCtzAr0EuGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-linux-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-linux-x64/-/typescript-linux-x64-7.0.2.tgz", + "integrity": "sha512-EYdf2cNg7rgCWJnxCdJ+F3V39O8ihb37eHAu1LK8oAFizgTQbPOK7zHHXbPt8rX24COqODXeI3sIf0fCXG7H/A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-arm64/-/typescript-netbsd-arm64-7.0.2.tgz", + "integrity": "sha512-+polYF4MF04aPpO5FTkHran9yUQDSXqy5GiSDKpsll5jy3l3+g9QLhpf39T+ePtefhXLOGrLl0QIjkQP6VnelA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-netbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-netbsd-x64/-/typescript-netbsd-x64-7.0.2.tgz", + "integrity": "sha512-8YIT0EHM/3dq10ZOVF/A7pc/YSMtbcecct4rWtexrnSCHOPcpC2KTLXfTCR6vDpnSiY12heNb1GiN/wu+T/FyA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-arm64/-/typescript-openbsd-arm64-7.0.2.tgz", + "integrity": "sha512-APT8+ClYnuYm1u9+kgGXoMj2VzWzcymwh2gNSQVySHfkRDGOTVkoWLjCmOQSaO+PoqQ57B0flRp9SA+7GnnkzQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-openbsd-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-openbsd-x64/-/typescript-openbsd-x64-7.0.2.tgz", + "integrity": "sha512-yX7s+Q0Dln0Dt9tEzZsAjXXR/+ytBM7AlglaqyeMPxQszJ1JhlJdZ6jLA+IzldHtflX81em7lDao1xXu+aRRkg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-sunos-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-sunos-x64/-/typescript-sunos-x64-7.0.2.tgz", + "integrity": "sha512-dLJDGaLZ1D4HPQn62u1n8mBDkJREwMsAkCdkwd4Ieqw+x3TUyTsqY0YiBCtE6H6OzzgGk3iuZ3vFWRS+E8/d1g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-arm64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-arm64/-/typescript-win32-arm64-7.0.2.tgz", + "integrity": "sha512-Gyl1Vy6OsWesLzmq+EP0Fb7b4Nid5232AvcA2SFcdYreldpNtYFFofPjnt62y9hQy7VTaZp65ICJjuAQRaVcIQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@typescript/typescript-win32-x64": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/@typescript/typescript-win32-x64/-/typescript-win32-x64-7.0.2.tgz", + "integrity": "sha512-0BQ3HkAHHlKLSp1qRvf3SUhGpGsDuhB/jgFw75guyqbxJqEaS0Cw/VFO8i2nHglJUzQCRtMMR/IBAKE3ETMC4g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=16.20.0" + } + }, + "node_modules/@vitest/mocker": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-5.1.0.tgz", + "integrity": "sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/trace-mapping": "0.3.31", + "@vitest/spy": "5.1.0", + "estree-walker": "^3.0.3", + "magic-string": "^1.4.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9 || ^3.0.0", + "vite": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/spy": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-5.1.0.tgz", + "integrity": "sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "license": "MIT", + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/brace-expansion": { + "version": "5.0.13", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.13.tgz", + "integrity": "sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==", + "license": "MIT", + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/chai": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.3.0.tgz", + "integrity": "sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/detect-libc": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", + "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/dotenv": { + "version": "17.4.2", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-17.4.2.tgz", + "integrity": "sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, + "node_modules/es-module-lexer": { + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.3.2.tgz", + "integrity": "sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.28.2", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.28.2.tgz", + "integrity": "sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.28.2", + "@esbuild/android-arm": "0.28.2", + "@esbuild/android-arm64": "0.28.2", + "@esbuild/android-x64": "0.28.2", + "@esbuild/darwin-arm64": "0.28.2", + "@esbuild/darwin-x64": "0.28.2", + "@esbuild/freebsd-arm64": "0.28.2", + "@esbuild/freebsd-x64": "0.28.2", + "@esbuild/linux-arm": "0.28.2", + "@esbuild/linux-arm64": "0.28.2", + "@esbuild/linux-ia32": "0.28.2", + "@esbuild/linux-loong64": "0.28.2", + "@esbuild/linux-mips64el": "0.28.2", + "@esbuild/linux-ppc64": "0.28.2", + "@esbuild/linux-riscv64": "0.28.2", + "@esbuild/linux-s390x": "0.28.2", + "@esbuild/linux-x64": "0.28.2", + "@esbuild/netbsd-arm64": "0.28.2", + "@esbuild/netbsd-x64": "0.28.2", + "@esbuild/openbsd-arm64": "0.28.2", + "@esbuild/openbsd-x64": "0.28.2", + "@esbuild/openharmony-arm64": "0.28.2", + "@esbuild/sunos-x64": "0.28.2", + "@esbuild/win32-arm64": "0.28.2", + "@esbuild/win32-ia32": "0.28.2", + "@esbuild/win32-x64": "0.28.2" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/expect-type": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.4.0.tgz", + "integrity": "sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fdir": { + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", + "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "picomatch": "^3 || ^4" + }, + "peerDependenciesMeta": { + "picomatch": { + "optional": true + } + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/glob": { + "version": "14.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-14.0.6.tgz", + "integrity": "sha512-OwXjVP2svY5EyLY75Vek96C8qK43gqrt4xsZ+qSILdnaEiJPXkd62mcfUSNx/TQErQRdu5uM5kF67sfONragKw==", + "license": "BlueOak-1.0.0", + "dependencies": { + "minimatch": "^11.0.5", + "minipass": "^7.1.3", + "path-scurry": "^3.0.0" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/hono": { + "version": "4.13.18", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.18.tgz", + "integrity": "sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==", + "license": "MIT", + "engines": { + "node": ">=16.9.0" + } + }, + "node_modules/lightningcss": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.33.0.tgz", + "integrity": "sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==", + "dev": true, + "license": "MPL-2.0", + "peer": true, + "dependencies": { + "detect-libc": "^2.0.3" + }, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + }, + "optionalDependencies": { + "lightningcss-android-arm64": "1.33.0", + "lightningcss-darwin-arm64": "1.33.0", + "lightningcss-darwin-x64": "1.33.0", + "lightningcss-freebsd-x64": "1.33.0", + "lightningcss-linux-arm-gnueabihf": "1.33.0", + "lightningcss-linux-arm64-gnu": "1.33.0", + "lightningcss-linux-arm64-musl": "1.33.0", + "lightningcss-linux-x64-gnu": "1.33.0", + "lightningcss-linux-x64-musl": "1.33.0", + "lightningcss-win32-arm64-msvc": "1.33.0", + "lightningcss-win32-x64-msvc": "1.33.0" + } + }, + "node_modules/lightningcss-android-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.33.0.tgz", + "integrity": "sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "android" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-arm64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.33.0.tgz", + "integrity": "sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-darwin-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.33.0.tgz", + "integrity": "sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "darwin" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-freebsd-x64": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.33.0.tgz", + "integrity": "sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "freebsd" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm-gnueabihf": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.33.0.tgz", + "integrity": "sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.33.0.tgz", + "integrity": "sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-arm64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.33.0.tgz", + "integrity": "sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-gnu": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.33.0.tgz", + "integrity": "sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "glibc" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-linux-x64-musl": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.33.0.tgz", + "integrity": "sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==", + "cpu": [ + "x64" + ], + "dev": true, + "libc": [ + "musl" + ], + "license": "MPL-2.0", + "optional": true, + "os": [ + "linux" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-arm64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.33.0.tgz", + "integrity": "sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lightningcss-win32-x64-msvc": { + "version": "1.33.0", + "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.33.0.tgz", + "integrity": "sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MPL-2.0", + "optional": true, + "os": [ + "win32" + ], + "peer": true, + "engines": { + "node": ">= 12.0.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/parcel" + } + }, + "node_modules/lru-cache": { + "version": "11.5.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.5.3.tgz", + "integrity": "sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==", + "license": "BlueOak-1.0.0", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/magic-string": { + "version": "1.4.5", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-1.4.5.tgz", + "integrity": "sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==", + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.6.0" + } + }, + "node_modules/minimatch": { + "version": "11.0.8", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-11.0.8.tgz", + "integrity": "sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==", + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/nonrecursive-glob-match": "^1.1.0", + "brace-expansion": "^5.0.12" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "license": "BlueOak-1.0.0", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/nanoid": { + "version": "3.3.20", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.20.tgz", + "integrity": "sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/obug": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/obug/-/obug-3.0.0.tgz", + "integrity": "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==", + "dev": true, + "funding": [ + "https://github.com/sponsors/sxzz", + "https://opencollective.com/debug" + ], + "license": "MIT", + "engines": { + "node": ">=12.20.0" + } + }, + "node_modules/oxc-parser": { + "version": "0.152.0", + "resolved": "https://registry.npmjs.org/oxc-parser/-/oxc-parser-0.152.0.tgz", + "integrity": "sha512-ZztsZgaCWmPeKYMdoTT5e0oV/oxD1NeLWNR3kAtr/G707cUPYaaozRlVDHLCGnszHJRszN9mJwmPNpqgwloC0A==", + "license": "MIT", + "dependencies": { + "@oxc-project/types": "^0.152.0" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/sponsors/oxc-project" + }, + "optionalDependencies": { + "@oxc-parser/binding-android-arm-eabi": "0.152.0", + "@oxc-parser/binding-android-arm64": "0.152.0", + "@oxc-parser/binding-darwin-arm64": "0.152.0", + "@oxc-parser/binding-darwin-x64": "0.152.0", + "@oxc-parser/binding-freebsd-x64": "0.152.0", + "@oxc-parser/binding-linux-arm-gnueabihf": "0.152.0", + "@oxc-parser/binding-linux-arm-musleabihf": "0.152.0", + "@oxc-parser/binding-linux-arm64-gnu": "0.152.0", + "@oxc-parser/binding-linux-arm64-musl": "0.152.0", + "@oxc-parser/binding-linux-ppc64-gnu": "0.152.0", + "@oxc-parser/binding-linux-riscv64-gnu": "0.152.0", + "@oxc-parser/binding-linux-riscv64-musl": "0.152.0", + "@oxc-parser/binding-linux-s390x-gnu": "0.152.0", + "@oxc-parser/binding-linux-x64-gnu": "0.152.0", + "@oxc-parser/binding-linux-x64-musl": "0.152.0", + "@oxc-parser/binding-openharmony-arm64": "0.152.0", + "@oxc-parser/binding-win32-arm64-msvc": "0.152.0", + "@oxc-parser/binding-win32-ia32-msvc": "0.152.0", + "@oxc-parser/binding-win32-x64-msvc": "0.152.0" + } + }, + "node_modules/path-scurry": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-3.0.0.tgz", + "integrity": "sha512-1pTbQqH1wIwMi/eleQ5leFTTCkzFsPcgXNjwOA8YGGW/W4/kHT3dssE7Z6NH+zuqNLOzOB0uaD61yl7cAcVhgg==", + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC", + "peer": true + }, + "node_modules/picomatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.7.tgz", + "integrity": "sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/postcss": { + "version": "8.5.33", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.33.tgz", + "integrity": "sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "peer": true, + "dependencies": { + "nanoid": "^3.3.20", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.2" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/rolldown": { + "version": "1.2.19", + "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.2.19.tgz", + "integrity": "sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "@oxc-project/types": "=0.156.0", + "@rolldown/pluginutils": "^1.0.0" + }, + "bin": { + "rolldown": "bin/cli.mjs" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "optionalDependencies": { + "@rolldown/binding-android-arm-eabi": "1.2.19", + "@rolldown/binding-android-arm64": "1.2.19", + "@rolldown/binding-darwin-arm64": "1.2.19", + "@rolldown/binding-darwin-x64": "1.2.19", + "@rolldown/binding-freebsd-x64": "1.2.19", + "@rolldown/binding-linux-arm-gnueabihf": "1.2.19", + "@rolldown/binding-linux-arm64-gnu": "1.2.19", + "@rolldown/binding-linux-arm64-musl": "1.2.19", + "@rolldown/binding-linux-ppc64-gnu": "1.2.19", + "@rolldown/binding-linux-s390x-gnu": "1.2.19", + "@rolldown/binding-linux-x64-gnu": "1.2.19", + "@rolldown/binding-linux-x64-musl": "1.2.19", + "@rolldown/binding-openharmony-arm64": "1.2.19", + "@rolldown/binding-wasm32-wasi": "1.2.19", + "@rolldown/binding-win32-arm64-msvc": "1.2.19", + "@rolldown/binding-win32-x64-msvc": "1.2.19" + } + }, + "node_modules/rolldown/node_modules/@oxc-project/types": { + "version": "0.156.0", + "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.156.0.tgz", + "integrity": "sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==", + "dev": true, + "license": "MIT", + "peer": true, + "funding": { + "url": "https://github.com/sponsors/oxc-project" + } + }, + "node_modules/sentry": { + "version": "0.49.0", + "resolved": "https://registry.npmjs.org/sentry/-/sentry-0.49.0.tgz", + "integrity": "sha512-9tjS0jTx5FQzhwAGhpcnwvqE0MlQiwJtunsIUNqGkw6E9CBOMbijlamIDUqvZTDtJAveVwa9L5ziP44bOJUzcQ==", + "license": "FSL-1.1-Apache-2.0", + "bin": { + "sentry": "dist/bin.cjs" + }, + "engines": { + "node": ">=20.0" + } + }, + "node_modules/source-map-js": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.2.tgz", + "integrity": "sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==", + "dev": true, + "license": "BSD-3-Clause", + "peer": true, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/std-env": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.3.0.tgz", + "integrity": "sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinybench": { + "version": "6.2.3", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-6.2.3.tgz", + "integrity": "sha512-Al01C2JIBnO2CXCAPbpAl6sUiOZHeThGtHYNTa51JRw9PyWOCdr+9Ong05R4qg/Sk3+H645E8ov1h2c58ityNw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=20.0.0" + } + }, + "node_modules/tinyexec": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", + "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/tinyglobby": { + "version": "0.2.17", + "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.17.tgz", + "integrity": "sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fdir": "^6.5.0", + "picomatch": "^4.0.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/SuperchupuDev" + } + }, + "node_modules/tslib": { + "version": "2.9.1", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.9.1.tgz", + "integrity": "sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==", + "dev": true, + "license": "0BSD", + "optional": true, + "peer": true + }, + "node_modules/tsx": { + "version": "4.23.15", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.23.15.tgz", + "integrity": "sha512-Yiex1Ovn8z2xPpOWckIiysV1SSyRMY9BkLF++q0yKiDxCqRhosKfMg3janKkiLBwZ5c/YryloKwGZcrEmtwxKw==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "~0.28.0" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, + "node_modules/typescript": { + "version": "7.0.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-7.0.2.tgz", + "integrity": "sha512-8FYau96o3NKOhbjKi/qNvG/W5jhzxkbdm5sj9AbZ/5T5sWqn3hJgLfGx27sRKZWTvyzCP8dLRBTf5tBTSRVUNA==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc" + }, + "engines": { + "node": ">=16.20.0" + }, + "optionalDependencies": { + "@typescript/typescript-aix-ppc64": "7.0.2", + "@typescript/typescript-darwin-arm64": "7.0.2", + "@typescript/typescript-darwin-x64": "7.0.2", + "@typescript/typescript-freebsd-arm64": "7.0.2", + "@typescript/typescript-freebsd-x64": "7.0.2", + "@typescript/typescript-linux-arm": "7.0.2", + "@typescript/typescript-linux-arm64": "7.0.2", + "@typescript/typescript-linux-loong64": "7.0.2", + "@typescript/typescript-linux-mips64el": "7.0.2", + "@typescript/typescript-linux-ppc64": "7.0.2", + "@typescript/typescript-linux-riscv64": "7.0.2", + "@typescript/typescript-linux-s390x": "7.0.2", + "@typescript/typescript-linux-x64": "7.0.2", + "@typescript/typescript-netbsd-arm64": "7.0.2", + "@typescript/typescript-netbsd-x64": "7.0.2", + "@typescript/typescript-openbsd-arm64": "7.0.2", + "@typescript/typescript-openbsd-x64": "7.0.2", + "@typescript/typescript-sunos-x64": "7.0.2", + "@typescript/typescript-win32-arm64": "7.0.2", + "@typescript/typescript-win32-x64": "7.0.2" + } + }, + "node_modules/undici-types": { + "version": "6.21.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.21.0.tgz", + "integrity": "sha512-iwDZqg0QAGrg9Rav5H4n0M64c3mkR59cJ6wQp+7C4nI0gsmExaedaYLNO44eT4AtBBwjbTiGPMlt2Md0T9H9JQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/vite": { + "version": "8.3.8", + "resolved": "https://registry.npmjs.org/vite/-/vite-8.3.8.tgz", + "integrity": "sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==", + "dev": true, + "license": "MIT", + "peer": true, + "dependencies": { + "lightningcss": "^1.33.0", + "picomatch": "^4.0.7", + "postcss": "^8.5.32", + "rolldown": "~1.2.18", + "tinyglobby": "^0.2.17" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^20.19.0 || >=22.12.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^20.19.0 || >=22.12.0", + "@vitejs/devtools": "^0.7.1 || ^0.8.0", + "esbuild": "^0.27.0 || ^0.28.0", + "jiti": ">=1.21.0", + "less": "^4.0.0", + "sass": "^1.70.0", + "sass-embedded": "^1.70.0", + "stylus": ">=0.54.8", + "sugarss": "^5.0.0", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "@vitejs/devtools": { + "optional": true + }, + "esbuild": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vitest": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-5.1.0.tgz", + "integrity": "sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/chai": "^5.2.2", + "@vitest/mocker": "5.1.0", + "chai": "^6.3.0", + "es-module-lexer": "^2.3.2", + "expect-type": "^1.4.0", + "magic-string": "^1.4.3", + "obug": "^3.0.0", + "picomatch": "^4.0.7", + "std-env": "^4.3.0", + "tinybench": "^6.2.2", + "tinyexec": "^1.3.1", + "tinyglobby": "^0.2.17", + "why-is-node-running": "3.2.1" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^22.12.0 || ^24.0.0 || >=26.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@opentelemetry/api": "^1.9.0", + "@types/node": "^22.0.0 || >=24.0.0", + "@vitest/browser-playwright": "5.1.0", + "@vitest/browser-preview": "5.1.0", + "@vitest/browser-webdriverio": "^5.0.0-beta.5 || >=5.0.0", + "@vitest/coverage-istanbul": "5.1.0", + "@vitest/coverage-v8": "5.1.0", + "@vitest/ui": "5.1.0", + "happy-dom": "*", + "jsdom": "*", + "vite": "^6.4.0 || ^7.0.0 || ^8.0.0" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@opentelemetry/api": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser-playwright": { + "optional": true + }, + "@vitest/browser-preview": { + "optional": true + }, + "@vitest/browser-webdriverio": { + "optional": true + }, + "@vitest/coverage-istanbul": { + "optional": true + }, + "@vitest/coverage-v8": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + }, + "vite": { + "optional": false + } + } + }, + "node_modules/why-is-node-running": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-3.2.1.tgz", + "integrity": "sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==", + "dev": true, + "license": "MIT", + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=20.11" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..bd6a61b --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "executive-ai", + "version": "0.1.0", + "private": true, + "type": "module", + "engines": { + "node": ">=22" + }, + "scripts": { + "dev": "tsx watch src/index.ts", + "start": "node dist/index.js", + "build": "tsc -p tsconfig.build.json", + "typecheck": "tsc --noEmit", + "lint": "biome check .", + "format": "biome check --write .", + "test": "vitest run" + }, + "dependencies": { + "@hono/node-server": "^2.1.8", + "@sentry/node": "^11.12.0", + "hono": "^4.13.18" + }, + "devDependencies": { + "@biomejs/biome": "^2.6.8", + "@types/node": "^22.20.5", + "tsx": "^4.23.15", + "typescript": "^7.0.2", + "vitest": "^5.1.0" + } +} diff --git a/src/agenda.ts b/src/agenda.ts new file mode 100644 index 0000000..7ef4b8f --- /dev/null +++ b/src/agenda.ts @@ -0,0 +1,116 @@ +/** Событие календаря в том виде, в каком его отдаёт источник (Google или мок). */ +export type CalendarEvent = { + id: string; + /** null — у события нет названия. */ + title: string | null; +} & ( + | { + allDay: true /** YYYY-MM-DD */; + startDate: string /** YYYY-MM-DD, не включая */; + endDate: string; + } + | { allDay: false; start: Date; end: Date } +); + +export type AgendaItem = { + id: string; + title: string | null; + /** allDay — на весь день; ongoing — началось до сегодняшнего дня и ещё идёт; timed — есть время начала. */ + kind: "allDay" | "ongoing" | "timed"; + /** Момент начала для kind = timed. */ + start: Date | null; +}; + +export type AgendaDay = { + /** YYYY-MM-DD в поясе календаря. */ + key: string; + /** 0 — сегодня, 1 — завтра, … 6. */ + offset: number; + items: AgendaItem[]; +}; + +export const WINDOW_DAYS = 7; + +const keyFormatters = new Map(); + +/** Календарная дата момента в заданном поясе: YYYY-MM-DD. */ +export function dayKey(instant: Date, timeZone: string): string { + let fmt = keyFormatters.get(timeZone); + if (!fmt) { + fmt = new Intl.DateTimeFormat("en-US", { + timeZone, + year: "numeric", + month: "2-digit", + day: "2-digit", + }); + keyFormatters.set(timeZone, fmt); + } + const parts = Object.fromEntries(fmt.formatToParts(instant).map((p) => [p.type, p.value])); + return `${parts.year}-${parts.month}-${parts.day}`; +} + +export function addDays(key: string, days: number): string { + const [y = 1970, m = 1, d = 1] = key.split("-").map(Number); + return new Date(Date.UTC(y, m - 1, d + days)).toISOString().slice(0, 10); +} + +function daysBetween(fromKey: string, toKey: string): number { + return Math.round( + (Date.parse(`${toKey}T00:00:00Z`) - Date.parse(`${fromKey}T00:00:00Z`)) / 86_400_000, + ); +} + +const KIND_ORDER = { allDay: 0, ongoing: 1, timed: 2 } as const; + +/** + * Список на 7 дней начиная с сегодняшнего (в поясе календаря): события, пересекающие окно, + * сгруппированы по дню начала; начавшиеся раньше и ещё идущие — в сегодняшнем дне. + * Внутри дня: сначала на весь день, затем продолжающиеся, затем по времени начала. + */ +export function buildAgenda(events: CalendarEvent[], timeZone: string, now: Date): AgendaDay[] { + const todayKey = dayKey(now, timeZone); + const windowEnd = addDays(todayKey, WINDOW_DAYS); + const byDay = new Map(); + + for (const event of events) { + let startKey: string; + let lastKey: string; + if (event.allDay) { + startKey = event.startDate; + lastKey = event.endDate > event.startDate ? addDays(event.endDate, -1) : event.startDate; + } else { + startKey = dayKey(event.start, timeZone); + const lastMoment = + event.end.getTime() > event.start.getTime() + ? new Date(event.end.getTime() - 1) + : event.start; + lastKey = dayKey(lastMoment, timeZone); + } + if (startKey >= windowEnd || lastKey < todayKey) continue; + + const carriedOver = startKey < todayKey; + const item: AgendaItem = { + id: event.id, + title: event.title, + kind: event.allDay ? "allDay" : carriedOver ? "ongoing" : "timed", + start: event.allDay || carriedOver ? null : event.start, + }; + const key = carriedOver ? todayKey : startKey; + const items = byDay.get(key); + if (items) items.push(item); + else byDay.set(key, [item]); + } + + return [...byDay.entries()] + .sort(([a], [b]) => (a < b ? -1 : 1)) + .map(([key, items]) => ({ + key, + offset: daysBetween(todayKey, key), + items: items.sort( + (a, b) => + KIND_ORDER[a.kind] - KIND_ORDER[b.kind] || + (a.start?.getTime() ?? 0) - (b.start?.getTime() ?? 0) || + (a.title ?? "").localeCompare(b.title ?? ""), + ), + })); +} diff --git a/src/app.tsx b/src/app.tsx new file mode 100644 index 0000000..4138108 --- /dev/null +++ b/src/app.tsx @@ -0,0 +1,183 @@ +import { randomBytes, timingSafeEqual } from "node:crypto"; +import { type Context, Hono } from "hono"; +import { deleteCookie, getCookie, setCookie } from "hono/cookie"; +import { buildAgenda } from "./agenda.js"; +import { GoogleAuthError, type GoogleClient } from "./google/types.js"; +import { isLocale, type Locale, pickLocale } from "./i18n.js"; +import { reportError } from "./sentry.js"; +import { createConnectionCodec } from "./session.js"; +import { AgendaPage, ConnectPage, MessagePage, type Notice } from "./views.js"; + +export type AppDeps = { + google: GoogleClient; + sessionSecret: string | Buffer; + publicUrl?: string | null; + now?: () => Date; +}; + +const CONNECTION_COOKIE = "ea_conn"; +const STATE_COOKIE = "ea_state"; +const LANG_COOKIE = "ea_lang"; +const YEAR_SECONDS = 365 * 24 * 60 * 60; +const HOUR_MS = 60 * 60 * 1000; +const CALLBACK_PATH = "/auth/google/callback"; + +type Env = { Variables: { locale: Locale } }; + +function firstHeaderValue(value: string | undefined): string | undefined { + return value?.split(",")[0]?.trim() || undefined; +} + +function sameText(a: string, b: string): boolean { + const left = Buffer.from(a); + const right = Buffer.from(b); + return left.length === right.length && timingSafeEqual(left, right); +} + +export function createApp(deps: AppDeps) { + const { google } = deps; + const now = deps.now ?? (() => new Date()); + const codec = createConnectionCodec(deps.sessionSecret); + const app = new Hono(); + + /** Внешний адрес продукта: настройка или адрес запроса (за обратным прокси). */ + function baseUrl(c: Context): string { + if (deps.publicUrl) return deps.publicUrl; + const url = new URL(c.req.url); + const proto = + firstHeaderValue(c.req.header("x-forwarded-proto")) ?? url.protocol.replace(":", ""); + const host = + firstHeaderValue(c.req.header("x-forwarded-host")) ?? c.req.header("host") ?? url.host; + return `${proto}://${host}`; + } + + function cookieOptions(c: Context, maxAge: number) { + return { + path: "/", + httpOnly: true, + sameSite: "Lax" as const, + secure: baseUrl(c).startsWith("https://"), + maxAge, + }; + } + + app.get("/healthz", (c) => c.text("ok")); + + app.use(async (c, next) => { + const query = c.req.query("lang"); + const locale = pickLocale({ + query, + cookie: getCookie(c, LANG_COOKIE), + acceptLanguage: c.req.header("accept-language"), + }); + if (isLocale(query)) setCookie(c, LANG_COOKIE, query, cookieOptions(c, YEAR_SECONDS)); + c.set("locale", locale); + c.header("Cache-Control", "no-store"); + await next(); + }); + + app.get("/", async (c) => { + const locale = c.get("locale"); + const isMock = google.isMock; + const connection = codec.open(getCookie(c, CONNECTION_COOKIE)); + + if (!connection) { + const param = c.req.query("notice"); + const notice: Notice | null = param === "denied" || param === "failed" ? param : null; + return c.html(); + } + + try { + const moment = now(); + const accessToken = await google.refreshAccessToken(connection.refreshToken); + // Запас по краям: «сегодня» в поясе календаря узнаём только из ответа. + const { timeZone, events } = await google.listEvents(accessToken, { + timeMin: new Date(moment.getTime() - 48 * HOUR_MS), + timeMax: new Date(moment.getTime() + 9 * 24 * HOUR_MS), + }); + const days = buildAgenda(events, timeZone, moment); + return c.html(); + } catch (error) { + if (error instanceof GoogleAuthError) { + deleteCookie(c, CONNECTION_COOKIE, { path: "/" }); + return c.html( + , + ); + } + reportError(error); + return c.html( + , + ); + } + }); + + app.get("/connect", (c) => { + const state = randomBytes(24).toString("base64url"); + setCookie(c, STATE_COOKIE, state, cookieOptions(c, 600)); + return c.redirect(google.authUrl({ state, redirectUri: `${baseUrl(c)}${CALLBACK_PATH}` })); + }); + + app.get(CALLBACK_PATH, async (c) => { + const expected = getCookie(c, STATE_COOKIE); + deleteCookie(c, STATE_COOKIE, { path: "/" }); + const state = c.req.query("state"); + const code = c.req.query("code"); + + if (!expected || !state || !sameText(expected, state)) return c.redirect("/?notice=failed"); + if (c.req.query("error") === "access_denied") return c.redirect("/?notice=denied"); + if (!code) return c.redirect("/?notice=failed"); + + try { + const { refreshToken } = await google.exchangeCode({ + code, + redirectUri: `${baseUrl(c)}${CALLBACK_PATH}`, + }); + setCookie(c, CONNECTION_COOKIE, codec.seal({ refreshToken }), cookieOptions(c, YEAR_SECONDS)); + return c.redirect("/"); + } catch (error) { + reportError(error); + return c.redirect("/?notice=failed"); + } + }); + + app.notFound((c) => + c.html( + , + 404, + ), + ); + + app.onError((error, c) => { + reportError(error); + return c.html( + , + 500, + ); + }); + + return app; +} diff --git a/src/config.ts b/src/config.ts new file mode 100644 index 0000000..750a4b6 --- /dev/null +++ b/src/config.ts @@ -0,0 +1,30 @@ +import { randomBytes } from "node:crypto"; +import { createGoogleClient } from "./google/client.js"; +import { mockGoogleClient } from "./google/mock-client.js"; +import type { GoogleClient } from "./google/types.js"; + +export type Config = { + port: number; + /** Внешний адрес продукта; если не задан, берётся из запроса. */ + publicUrl: string | null; + google: GoogleClient; + /** Секрет для шифрования cookie подключения. */ + sessionSecret: string | Buffer; +}; + +export function loadConfig(env: NodeJS.ProcessEnv): Config { + const clientId = env.GOOGLE_CLIENT_ID?.trim(); + const clientSecret = env.GOOGLE_CLIENT_SECRET?.trim(); + const hasGoogle = Boolean(clientId && clientSecret); + return { + port: Number.parseInt(env.PORT ?? "", 10) || 3000, + publicUrl: env.PUBLIC_URL?.trim().replace(/\/+$/, "") || null, + // Без ключей Google работаем на моке: экран честно говорит, что это примеры. + google: + clientId && clientSecret + ? createGoogleClient({ clientId, clientSecret }) + : mockGoogleClient(), + sessionSecret: + env.SESSION_SECRET?.trim() || (hasGoogle ? (clientSecret as string) : randomBytes(32)), + }; +} diff --git a/src/google/client.ts b/src/google/client.ts new file mode 100644 index 0000000..194df34 --- /dev/null +++ b/src/google/client.ts @@ -0,0 +1,169 @@ +import type { CalendarEvent } from "../agenda.js"; +import { + CALENDAR_SCOPE, + type CalendarEvents, + GoogleAuthError, + type GoogleClient, + GoogleError, +} from "./types.js"; + +const AUTH_URL = "https://accounts.google.com/o/oauth2/v2/auth"; +const TOKEN_URL = "https://oauth2.googleapis.com/token"; +const EVENTS_URL = "https://www.googleapis.com/calendar/v3/calendars/primary/events"; +const TIMEOUT_MS = 10_000; +const MAX_PAGES = 10; +/** 403 с такой причиной — временное ограничение, а не отзыв доступа. */ +const RATE_LIMIT_REASONS = new Set(["rateLimitExceeded", "userRateLimitExceeded", "quotaExceeded"]); + +type Fetch = typeof fetch; + +type GoogleEventTime = { date?: string; dateTime?: string }; +type GoogleEvent = { + id?: string; + status?: string; + summary?: string; + start?: GoogleEventTime; + end?: GoogleEventTime; +}; +type GoogleEventsPage = { timeZone?: string; items?: GoogleEvent[]; nextPageToken?: string }; + +async function readJson(response: Response): Promise> { + try { + const body: unknown = await response.json(); + return body && typeof body === "object" ? (body as Record) : {}; + } catch { + return {}; + } +} + +function toCalendarEvent(event: GoogleEvent): CalendarEvent | null { + if (event.status === "cancelled" || !event.id || !event.start) return null; + const title = event.summary?.trim() || null; + if (event.start.date) { + return { + id: event.id, + title, + allDay: true, + startDate: event.start.date, + endDate: event.end?.date ?? event.start.date, + }; + } + if (!event.start.dateTime) return null; + const start = new Date(event.start.dateTime); + const end = event.end?.dateTime ? new Date(event.end.dateTime) : start; + if (Number.isNaN(start.getTime()) || Number.isNaN(end.getTime())) return null; + return { id: event.id, title, allDay: false, start, end }; +} + +export function createGoogleClient(config: { + clientId: string; + clientSecret: string; + fetch?: Fetch; +}): GoogleClient { + const doFetch: Fetch = config.fetch ?? fetch; + + async function request(url: string, init: RequestInit): Promise { + try { + return await doFetch(url, { ...init, signal: AbortSignal.timeout(TIMEOUT_MS) }); + } catch (cause) { + throw new GoogleError("Google is unreachable", { cause }); + } + } + + async function token(params: Record): Promise> { + const response = await request(TOKEN_URL, { + method: "POST", + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + body: new URLSearchParams({ + client_id: config.clientId, + client_secret: config.clientSecret, + ...params, + }), + }); + const body = await readJson(response); + if (!response.ok) { + const code = typeof body.error === "string" ? body.error : `http_${response.status}`; + // invalid_grant при обновлении — пользователь отозвал доступ или он истёк. + if (params.grant_type === "refresh_token" && code === "invalid_grant") { + throw new GoogleAuthError("Google access was revoked"); + } + throw new GoogleError(`Google token request failed: ${code}`); + } + return body; + } + + return { + isMock: false, + + authUrl({ state, redirectUri }) { + const query = new URLSearchParams({ + client_id: config.clientId, + redirect_uri: redirectUri, + response_type: "code", + scope: CALENDAR_SCOPE, + access_type: "offline", + prompt: "consent", + state, + }); + return `${AUTH_URL}?${query}`; + }, + + async exchangeCode({ code, redirectUri }) { + const body = await token({ + grant_type: "authorization_code", + code, + redirect_uri: redirectUri, + }); + if (typeof body.refresh_token !== "string" || !body.refresh_token) { + throw new GoogleError("Google did not return a refresh token"); + } + return { refreshToken: body.refresh_token }; + }, + + async refreshAccessToken(refreshToken) { + const body = await token({ grant_type: "refresh_token", refresh_token: refreshToken }); + if (typeof body.access_token !== "string" || !body.access_token) { + throw new GoogleError("Google did not return an access token"); + } + return body.access_token; + }, + + async listEvents(accessToken, { timeMin, timeMax }): Promise { + const events: CalendarEvent[] = []; + let timeZone = "UTC"; + let pageToken: string | undefined; + for (let page = 0; page < MAX_PAGES; page++) { + const query = new URLSearchParams({ + singleEvents: "true", + orderBy: "startTime", + timeMin: timeMin.toISOString(), + timeMax: timeMax.toISOString(), + maxResults: "250", + fields: "timeZone,nextPageToken,items(id,status,summary,start,end)", + }); + if (pageToken) query.set("pageToken", pageToken); + const response = await request(`${EVENTS_URL}?${query}`, { + headers: { Authorization: `Bearer ${accessToken}` }, + }); + if (!response.ok) { + const body = await readJson(response); + const error = body.error as { errors?: { reason?: string }[] } | undefined; + const reason = error?.errors?.[0]?.reason ?? ""; + const revoked = + response.status === 401 || (response.status === 403 && !RATE_LIMIT_REASONS.has(reason)); + if (revoked) throw new GoogleAuthError("Google rejected calendar access"); + throw new GoogleError(`Google Calendar request failed: http_${response.status}`); + } + const body = (await readJson(response)) as GoogleEventsPage; + if (body.timeZone) timeZone = body.timeZone; + for (const item of body.items ?? []) { + const event = toCalendarEvent(item); + if (event) events.push(event); + } + pageToken = body.nextPageToken; + if (!pageToken) break; + } + return { timeZone, events }; + }, + }; +} diff --git a/src/google/mock-client.ts b/src/google/mock-client.ts new file mode 100644 index 0000000..307255e --- /dev/null +++ b/src/google/mock-client.ts @@ -0,0 +1,80 @@ +import { addDays, type CalendarEvent, dayKey } from "../agenda.js"; +import mockPayload from "./mock-events.json" with { type: "json" }; +import { type CalendarEvents, GoogleAuthError, type GoogleClient, GoogleError } from "./types.js"; + +/** + * Мок календаря Google: работает, пока владелец не передал ключи Google. + * Повторяет контракт настоящего клиента, включая ошибки: + * - код MOCK_DENIED_CODE не обменивается (как просроченный код у Google); + * - ключ MOCK_REVOKED_TOKEN считается отозванным (invalid_grant у Google). + */ +export const MOCK_CODE = "mock-code"; +export const MOCK_DENIED_CODE = "mock-denied-code"; +export const MOCK_REFRESH_TOKEN = "mock-refresh-token"; +export const MOCK_REVOKED_TOKEN = "mock-revoked-token"; +export const MOCK_ACCESS_TOKEN = "mock-access-token"; + +type MockEvent = { + id: string; + title: string | null; + day: number; + time?: string; + minutes?: number; + allDay?: boolean; + days?: number; +}; + +function mockEvents(now: Date): CalendarEvent[] { + const today = dayKey(now, mockPayload.timeZone); + return (mockPayload.events as MockEvent[]).map((event) => { + const date = addDays(today, event.day); + if (event.allDay) { + return { + id: event.id, + title: event.title, + allDay: true, + startDate: date, + endDate: addDays(date, event.days ?? 1), + }; + } + const start = new Date(`${date}T${event.time ?? "09:00"}:00${mockPayload.utcOffset}`); + const end = new Date(start.getTime() + (event.minutes ?? 60) * 60_000); + return { id: event.id, title: event.title, allDay: false, start, end }; + }); +} + +export function mockGoogleClient(options: { now?: () => Date } = {}): GoogleClient { + const now = options.now ?? (() => new Date()); + return { + isMock: true, + + authUrl({ state, redirectUri }) { + // Страницы согласия у мока нет: сразу возвращаемся с кодом, как после «Разрешить». + return `${redirectUri}?${new URLSearchParams({ code: MOCK_CODE, state })}`; + }, + + async exchangeCode({ code }) { + if (code !== MOCK_CODE) throw new GoogleError("Google token request failed: invalid_grant"); + return { refreshToken: MOCK_REFRESH_TOKEN }; + }, + + async refreshAccessToken(refreshToken) { + if (refreshToken !== MOCK_REFRESH_TOKEN) { + throw new GoogleAuthError("Google access was revoked"); + } + return MOCK_ACCESS_TOKEN; + }, + + async listEvents(accessToken, { timeMin, timeMax }): Promise { + if (accessToken !== MOCK_ACCESS_TOKEN) { + throw new GoogleAuthError("Google rejected calendar access"); + } + const events = mockEvents(now()).filter((event) => { + const start = event.allDay ? new Date(`${event.startDate}T00:00:00Z`) : event.start; + const end = event.allDay ? new Date(`${event.endDate}T00:00:00Z`) : event.end; + return end.getTime() > timeMin.getTime() && start.getTime() < timeMax.getTime(); + }); + return { timeZone: mockPayload.timeZone, events }; + }, + }; +} diff --git a/src/google/mock-events.json b/src/google/mock-events.json new file mode 100644 index 0000000..233a7f8 --- /dev/null +++ b/src/google/mock-events.json @@ -0,0 +1,20 @@ +{ + "timeZone": "Asia/Almaty", + "utcOffset": "+05:00", + "events": [ + { + "id": "mock-1", + "title": "Планёрка с руководителями", + "day": 0, + "time": "10:00", + "minutes": 30 + }, + { "id": "mock-2", "title": "Обед с партнёрами", "day": 0, "time": "13:00", "minutes": 90 }, + { "id": "mock-3", "title": "Отраслевая выставка", "day": 1, "allDay": true, "days": 2 }, + { "id": "mock-4", "title": "Встреча с банком", "day": 1, "time": "11:00", "minutes": 60 }, + { "id": "mock-5", "title": null, "day": 2, "time": "16:30", "minutes": 30 }, + { "id": "mock-6", "title": "Отчёт за квартал", "day": 4, "time": "09:00", "minutes": 120 }, + { "id": "mock-7", "title": "Совет директоров", "day": 6, "time": "15:00", "minutes": 120 }, + { "id": "mock-8", "title": "Отпуск", "day": 8, "allDay": true, "days": 5 } + ] +} diff --git a/src/google/types.ts b/src/google/types.ts new file mode 100644 index 0000000..6af6b17 --- /dev/null +++ b/src/google/types.ts @@ -0,0 +1,34 @@ +import type { CalendarEvent } from "../agenda.js"; + +/** Право, которое EA просит у Google: только чтение событий. */ +export const CALENDAR_SCOPE = "https://www.googleapis.com/auth/calendar.events.readonly"; + +/** Доступ к календарю отозван или недействителен — нужно подключить заново. */ +export class GoogleAuthError extends Error { + override name = "GoogleAuthError"; +} + +/** Любой другой сбой Google или сети — подключение остаётся, стоит повторить позже. */ +export class GoogleError extends Error { + override name = "GoogleError"; +} + +export type CalendarEvents = { + /** Часовой пояс календаря, например «Asia/Almaty». */ + timeZone: string; + events: CalendarEvent[]; +}; + +/** Контракт календаря Google; у настоящего клиента и у мока он один. */ +export interface GoogleClient { + /** true — работаем на примерах, а не на настоящем календаре. */ + readonly isMock: boolean; + /** Адрес страницы согласия. */ + authUrl(params: { state: string; redirectUri: string }): string; + /** Обмен кода со страницы согласия на долгоживущий ключ подключения. */ + exchangeCode(params: { code: string; redirectUri: string }): Promise<{ refreshToken: string }>; + /** Короткоживущий доступ по ключу подключения; GoogleAuthError — доступ отозван. */ + refreshAccessToken(refreshToken: string): Promise; + /** События основного календаря в интервале, повторяющиеся развёрнуты. */ + listEvents(accessToken: string, range: { timeMin: Date; timeMax: Date }): Promise; +} diff --git a/src/i18n.ts b/src/i18n.ts new file mode 100644 index 0000000..fd4bb2b --- /dev/null +++ b/src/i18n.ts @@ -0,0 +1,94 @@ +import en from "./locales/en.json" with { type: "json" }; +import kk from "./locales/kk.json" with { type: "json" }; +import ru from "./locales/ru.json" with { type: "json" }; + +export const LOCALES = ["ru", "kk", "en"] as const; +export type Locale = (typeof LOCALES)[number]; +export type MessageKey = keyof typeof ru; + +export const DEFAULT_LOCALE: Locale = "ru"; + +const messages: Record> = { ru, kk, en }; + +export function isLocale(value: string | undefined | null): value is Locale { + return LOCALES.includes(value as Locale); +} + +export function t(locale: Locale, key: MessageKey, params: Record = {}): string { + return messages[locale][key].replace( + /\{(\w+)\}/g, + (match, name: string) => params[name] ?? match, + ); +} + +/** Язык из заголовка Accept-Language: первый поддерживаемый по убыванию q. */ +export function localeFromAcceptLanguage(header: string | undefined | null): Locale | null { + if (!header) return null; + const ranked = header + .split(",") + .map((part) => { + const [tag = "", ...rest] = part.trim().split(";"); + const q = rest.map((p) => p.trim()).find((p) => p.startsWith("q=")); + const weight = q ? Number.parseFloat(q.slice(2)) : 1; + return { + lang: tag.trim().toLowerCase().split("-")[0], + weight: Number.isNaN(weight) ? 0 : weight, + }; + }) + .filter((item) => item.weight > 0) + .sort((a, b) => b.weight - a.weight); + for (const item of ranked) { + if (isLocale(item.lang)) return item.lang; + } + return null; +} + +/** Порядок: явный выбор в адресе → сохранённый выбор → язык браузера → русский. */ +export function pickLocale(input: { + query?: string | null; + cookie?: string | null; + acceptLanguage?: string | null; +}): Locale { + if (isLocale(input.query)) return input.query; + if (isLocale(input.cookie)) return input.cookie; + return localeFromAcceptLanguage(input.acceptLanguage) ?? DEFAULT_LOCALE; +} + +function capitalize(text: string, locale: Locale): string { + return text.charAt(0).toLocaleUpperCase(locale) + text.slice(1); +} + +function dateFromDayKey(dayKey: string): Date { + const [y = 1970, m = 1, d = 1] = dayKey.split("-").map(Number); + return new Date(Date.UTC(y, m - 1, d, 12)); +} + +/** Заголовок дня: «Сегодня, 16 ноября», «Завтра, 17 ноября», «Среда, 18 ноября». */ +export function formatDayHeading(locale: Locale, dayKey: string, offset: number): string { + const date = dateFromDayKey(dayKey); + if (offset === 0 || offset === 1) { + const short = new Intl.DateTimeFormat(locale, { + day: "numeric", + month: "long", + timeZone: "UTC", + }).format(date); + return t(locale, offset === 0 ? "day.today" : "day.tomorrow", { date: short }); + } + const full = new Intl.DateTimeFormat(locale, { + weekday: "long", + day: "numeric", + month: "long", + timeZone: "UTC", + }).format(date); + return capitalize(full, locale); +} + +/** Время начала в поясе календаря, 24 часа: «09:00». */ +export function formatTime(locale: Locale, instant: Date, timeZone: string): string { + return new Intl.DateTimeFormat(locale, { + hour: "2-digit", + minute: "2-digit", + hourCycle: "h23", + timeZone, + }).format(instant); +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..3c6a37b --- /dev/null +++ b/src/index.ts @@ -0,0 +1,18 @@ +import { serve } from "@hono/node-server"; +import { createApp } from "./app.js"; +import { loadConfig } from "./config.js"; +import { initSentry } from "./sentry.js"; + +initSentry(process.env); +const config = loadConfig(process.env); +const app = createApp(config); + +const server = serve({ fetch: app.fetch, port: config.port, hostname: "0.0.0.0" }, (info) => { + console.log( + `executive-ai listening on :${info.port}${config.google.isMock ? " (mock Google)" : ""}`, + ); +}); + +for (const signal of ["SIGTERM", "SIGINT"] as const) { + process.on(signal, () => server.close(() => process.exit(0))); +} diff --git a/src/locales/en.json b/src/locales/en.json new file mode 100644 index 0000000..9cb1063 --- /dev/null +++ b/src/locales/en.json @@ -0,0 +1,36 @@ +{ + "app.name": "Executive AI", + "lang.label": "Language", + "lang.ru": "Русский", + "lang.kk": "Қазақша", + "lang.en": "English", + "connect.title": "Connect your calendar", + "connect.lead": "EA shows your plans and events for the next 7 days in one list.", + "connect.steps": "Press the button and allow EA to read your calendar on the Google page. Your list will then appear here.", + "connect.readonly": "EA only reads your calendar and never changes anything in it.", + "connect.button": "Connect Google Calendar", + "reconnect.button": "Connect the calendar again", + "notice.denied": "The calendar is not connected. To see your plans, allow EA to read your calendar.", + "notice.failed": "The calendar could not be connected. Please try connecting it again.", + "revoked.title": "Calendar access is closed", + "revoked.message": "Calendar access is closed. Connect the calendar again to see your plans.", + "unavailable.title": "The calendar is temporarily unavailable", + "unavailable.message": "The calendar could not be loaded. Refresh the page in a minute.", + "refresh.button": "Refresh", + "agenda.title": "Your next 7 days", + "agenda.connected": "Calendar connected", + "agenda.lead": "The list comes from your Google Calendar and is view-only. Refresh the page to see new events.", + "agenda.empty": "Nothing planned for the next 7 days", + "agenda.emptyHint": "When an event appears in your calendar, you will see it here after refreshing the page.", + "agenda.allDay": "all day", + "agenda.ongoing": "ongoing", + "agenda.untitled": "Untitled", + "day.today": "Today, {date}", + "day.tomorrow": "Tomorrow, {date}", + "mock.banner": "These are examples, not your calendar. Your real calendar will appear once the product owner finishes the setup.", + "notFound.title": "This page does not exist", + "notFound.message": "This page does not exist. Go back to your list.", + "notFound.button": "Back to the list", + "error.title": "Something went wrong", + "error.message": "The page could not be opened. Refresh it in a minute." +} diff --git a/src/locales/kk.json b/src/locales/kk.json new file mode 100644 index 0000000..8e130c9 --- /dev/null +++ b/src/locales/kk.json @@ -0,0 +1,36 @@ +{ + "app.name": "Executive AI", + "lang.label": "Тіл", + "lang.ru": "Русский", + "lang.kk": "Қазақша", + "lang.en": "English", + "connect.title": "Күнтізбені қосыңыз", + "connect.lead": "EA алдағы 7 күндегі істеріңіз бен оқиғаларыңызды бір тізімде көрсетеді.", + "connect.steps": "Батырманы басып, Google бетінде EA-ға күнтізбені оқуға рұқсат беріңіз. Содан кейін осы жерде істер тізімі пайда болады.", + "connect.readonly": "EA күнтізбені тек оқиды және онда ештеңені өзгертпейді.", + "connect.button": "Google күнтізбесін қосу", + "reconnect.button": "Күнтізбені қайта қосу", + "notice.denied": "Күнтізбе қосылмады. Істерді көру үшін EA-ға күнтізбені оқуға рұқсат беріңіз.", + "notice.failed": "Күнтізбені қосу мүмкін болмады. Оны қайта қосып көріңіз.", + "revoked.title": "Күнтізбеге қол жеткізу жабылды", + "revoked.message": "Күнтізбеге қол жеткізу жабылды. Істерді қайта көру үшін күнтізбені қайта қосыңыз.", + "unavailable.title": "Күнтізбе уақытша қолжетімсіз", + "unavailable.message": "Күнтізбені жүктеу мүмкін болмады. Бір минуттан кейін бетті жаңартыңыз.", + "refresh.button": "Жаңарту", + "agenda.title": "7 күнге арналған істеріңіз", + "agenda.connected": "Күнтізбе қосылған", + "agenda.lead": "Тізім Google күнтізбеңізден алынады және тек қарауға арналған. Жаңа оқиғаларды көру үшін бетті жаңартыңыз.", + "agenda.empty": "Алдағы 7 күнде істер жоқ", + "agenda.emptyHint": "Күнтізбеде оқиға пайда болғанда, ол бетті жаңартқаннан кейін осы жерде көрінеді.", + "agenda.allDay": "күні бойы", + "agenda.ongoing": "жалғасуда", + "agenda.untitled": "Атауы жоқ", + "day.today": "Бүгін, {date}", + "day.tomorrow": "Ертең, {date}", + "mock.banner": "Бұл сіздің күнтізбеңіз емес, мысалдар. Нақты күнтізбе өнім иесі баптауды аяқтағанда пайда болады.", + "notFound.title": "Мұндай бет жоқ", + "notFound.message": "Мұндай бет жоқ. Істер тізіміне оралыңыз.", + "notFound.button": "Істер тізіміне", + "error.title": "Бірдеңе дұрыс болмады", + "error.message": "Бетті ашу мүмкін болмады. Оны бір минуттан кейін жаңартыңыз." +} diff --git a/src/locales/ru.json b/src/locales/ru.json new file mode 100644 index 0000000..c6783a1 --- /dev/null +++ b/src/locales/ru.json @@ -0,0 +1,36 @@ +{ + "app.name": "Executive AI", + "lang.label": "Язык", + "lang.ru": "Русский", + "lang.kk": "Қазақша", + "lang.en": "English", + "connect.title": "Подключите календарь", + "connect.lead": "EA покажет в одном списке ваши дела и события на ближайшие 7 дней.", + "connect.steps": "Нажмите кнопку и на странице Google разрешите EA чтение календаря. После этого здесь появится список дел.", + "connect.readonly": "EA только читает календарь и ничего в нём не меняет.", + "connect.button": "Подключить календарь Google", + "reconnect.button": "Подключить календарь заново", + "notice.denied": "Календарь не подключён. Чтобы видеть дела, разрешите EA чтение календаря.", + "notice.failed": "Не удалось подключить календарь. Попробуйте подключить его заново.", + "revoked.title": "Доступ к календарю закрыт", + "revoked.message": "Доступ к календарю закрыт. Подключите календарь заново, чтобы снова видеть дела.", + "unavailable.title": "Календарь временно недоступен", + "unavailable.message": "Не удалось загрузить календарь. Обновите страницу через минуту.", + "refresh.button": "Обновить", + "agenda.title": "Ваши дела на 7 дней", + "agenda.connected": "Календарь подключён", + "agenda.lead": "Список берётся из вашего календаря Google и доступен только для просмотра. Чтобы увидеть новые события, обновите страницу.", + "agenda.empty": "Дел на ближайшие 7 дней нет", + "agenda.emptyHint": "Когда в календаре появится событие, оно будет видно здесь после обновления страницы.", + "agenda.allDay": "весь день", + "agenda.ongoing": "продолжается", + "agenda.untitled": "Без названия", + "day.today": "Сегодня, {date}", + "day.tomorrow": "Завтра, {date}", + "mock.banner": "Это примеры, а не ваш календарь. Настоящий календарь появится, когда владелец продукта завершит настройку.", + "notFound.title": "Такой страницы нет", + "notFound.message": "Такой страницы нет. Вернитесь к списку дел.", + "notFound.button": "К списку дел", + "error.title": "Что-то пошло не так", + "error.message": "Не удалось открыть страницу. Обновите её через минуту." +} diff --git a/src/sentry.ts b/src/sentry.ts new file mode 100644 index 0000000..74ce991 --- /dev/null +++ b/src/sentry.ts @@ -0,0 +1,31 @@ +import * as Sentry from "@sentry/node"; + +let enabled = false; + +/** Отправка ошибок продукта в Bugsink; без SENTRY_DSN молчит. */ +export function initSentry(env: NodeJS.ProcessEnv): boolean { + if (!env.SENTRY_DSN) return false; + Sentry.init({ + dsn: env.SENTRY_DSN, + release: env.SENTRY_RELEASE, + environment: env.SENTRY_ENVIRONMENT ?? "dev", + // Аналог sendDefaultPii: false (в SDK v11 его заменил dataCollection): персональные + // данные — cookie, заголовки, параметры адреса, тела запросов (в них названия событий + // календаря и ключи подключения) — не отправляем. + dataCollection: { + userInfo: false, + cookies: false, + httpHeaders: false, + httpBodies: [], + urlQueryParams: false, + stackFrameVariables: false, + }, + }); + enabled = true; + return true; +} + +export function reportError(error: unknown): void { + if (enabled) Sentry.captureException(error); + else console.error(error); +} diff --git a/src/session.ts b/src/session.ts new file mode 100644 index 0000000..5f1b6e8 --- /dev/null +++ b/src/session.ts @@ -0,0 +1,54 @@ +import { createCipheriv, createDecipheriv, hkdfSync, randomBytes } from "node:crypto"; + +/** Данные подключения календаря, которые лежат в зашифрованной cookie браузера. */ +export type Connection = { refreshToken: string }; + +export type ConnectionCodec = { + seal(connection: Connection): string; + /** null — значения нет, оно повреждено или зашифровано другим ключом. */ + open(value: string | undefined | null): Connection | null; +}; + +const IV_BYTES = 12; +const TAG_BYTES = 16; + +/** AES-256-GCM; ключ выводится из секрета через HKDF. */ +export function createConnectionCodec(secret: string | Buffer): ConnectionCodec { + const key = Buffer.from(hkdfSync("sha256", secret, Buffer.alloc(0), "ea-connection-v1", 32)); + return { + seal(connection) { + const iv = randomBytes(IV_BYTES); + const cipher = createCipheriv("aes-256-gcm", key, iv); + const data = Buffer.concat([ + cipher.update(JSON.stringify(connection), "utf8"), + cipher.final(), + ]); + return Buffer.concat([iv, cipher.getAuthTag(), data]).toString("base64url"); + }, + open(value) { + if (!value) return null; + try { + const raw = Buffer.from(value, "base64url"); + if (raw.length <= IV_BYTES + TAG_BYTES) return null; + const decipher = createDecipheriv("aes-256-gcm", key, raw.subarray(0, IV_BYTES)); + decipher.setAuthTag(raw.subarray(IV_BYTES, IV_BYTES + TAG_BYTES)); + const text = Buffer.concat([ + decipher.update(raw.subarray(IV_BYTES + TAG_BYTES)), + decipher.final(), + ]).toString("utf8"); + const parsed: unknown = JSON.parse(text); + if ( + parsed && + typeof parsed === "object" && + typeof (parsed as Connection).refreshToken === "string" && + (parsed as Connection).refreshToken + ) { + return { refreshToken: (parsed as Connection).refreshToken }; + } + return null; + } catch { + return null; + } + }, + }; +} diff --git a/src/styles.ts b/src/styles.ts new file mode 100644 index 0000000..abea80c --- /dev/null +++ b/src/styles.ts @@ -0,0 +1,50 @@ +export const styles = ` +:root { + color-scheme: light dark; + --bg: #f6f5f1; --card: #ffffff; --text: #1c1b19; --muted: #6b6860; --line: #e4e1d8; + --accent: #1f5fd1; --accent-text: #ffffff; --ok: #1d7a46; --warn-bg: #fff4d6; --warn-text: #6b4a00; + --err-bg: #fde8e6; --err-text: #8a1f14; +} +@media (prefers-color-scheme: dark) { + :root { + --bg: #151514; --card: #1f1f1d; --text: #f1efe9; --muted: #a29f96; --line: #33322e; + --accent: #7aa7ff; --accent-text: #10203f; --ok: #6fcf97; --warn-bg: #3b3115; --warn-text: #f3d98b; + --err-bg: #402019; --err-text: #ffb4a8; + } +} +* { box-sizing: border-box; } +body { + margin: 0; background: var(--bg); color: var(--text); + font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; +} +.wrap { max-width: 720px; margin: 0 auto; padding: 16px 16px 48px; } +header.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0 24px; } +.brand { font-weight: 700; letter-spacing: 0.02em; } +nav.langs { display: flex; gap: 4px; font-size: 14px; } +nav.langs a { color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: 6px; } +nav.langs a[aria-current="true"] { color: var(--text); background: var(--card); border: 1px solid var(--line); } +h1 { font-size: 28px; line-height: 1.2; margin: 0 0 8px; text-wrap: balance; } +p { margin: 0 0 12px; } +.lead { color: var(--muted); max-width: 60ch; } +.status { display: inline-flex; align-items: center; gap: 8px; color: var(--ok); font-weight: 600; margin-bottom: 8px; } +.status::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: currentColor; } +.button { + display: inline-block; margin-top: 12px; padding: 12px 20px; border-radius: 10px; + background: var(--accent); color: var(--accent-text); font-weight: 600; text-decoration: none; +} +.button:focus-visible, nav.langs a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; } +.note { padding: 12px 16px; border-radius: 10px; margin: 0 0 20px; } +.note.warn { background: var(--warn-bg); color: var(--warn-text); } +.note.error { background: var(--err-bg); color: var(--err-text); } +.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 24px; } +section.day { margin-top: 28px; } +section.day h2 { font-size: 16px; margin: 0 0 8px; color: var(--muted); font-weight: 600; } +ul.items { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; } +ul.items li { display: flex; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--line); } +ul.items li:first-child { border-top: 0; } +.when { flex: 0 0 104px; color: var(--muted); font-variant-numeric: tabular-nums; } +.what { flex: 1; min-width: 0; overflow-wrap: anywhere; } +.what.untitled { color: var(--muted); font-style: italic; } +.empty { margin-top: 28px; text-align: center; } +.empty strong { display: block; font-size: 20px; margin-bottom: 6px; } +`; diff --git a/src/views.tsx b/src/views.tsx new file mode 100644 index 0000000..d54eff7 --- /dev/null +++ b/src/views.tsx @@ -0,0 +1,141 @@ +import { raw } from "hono/html"; +import type { Child } from "hono/jsx"; +import type { AgendaDay, AgendaItem } from "./agenda.js"; +import { formatDayHeading, formatTime, LOCALES, type Locale, type MessageKey, t } from "./i18n.js"; +import { styles } from "./styles.js"; + +type LayoutProps = { locale: Locale; isMock: boolean; children?: Child }; + +function Layout({ locale, isMock, children }: LayoutProps) { + return ( + + + + + + {t(locale, "app.name")} + + + +
+
+ {t(locale, "app.name")} + +
+ {isMock && ( +

+ {t(locale, "mock.banner")} +

+ )} +
{children}
+
+ + + ); +} + +export type Notice = "denied" | "failed"; + +/** Календарь не подключён: что это, что сделать и что будет дальше. */ +export function ConnectPage(props: { locale: Locale; isMock: boolean; notice?: Notice | null }) { + const { locale, notice } = props; + return ( + + {notice && ( + + )} +
+

{t(locale, "connect.title")}

+

{t(locale, "connect.lead")}

+

{t(locale, "connect.steps")}

+

{t(locale, "connect.readonly")}

+ + {t(locale, notice ? "reconnect.button" : "connect.button")} + +
+
+ ); +} + +/** Сообщение из двух фраз и одно действие. */ +export function MessagePage(props: { + locale: Locale; + isMock: boolean; + title: MessageKey; + message: MessageKey; + action: { href: string; label: MessageKey }; +}) { + const { locale } = props; + return ( + +
+

{t(locale, props.title)}

+

{t(locale, props.message)}

+ + {t(locale, props.action.label)} + +
+
+ ); +} + +function Item({ item, locale, timeZone }: { item: AgendaItem; locale: Locale; timeZone: string }) { + const when = + item.kind === "timed" && item.start + ? formatTime(locale, item.start, timeZone) + : t(locale, item.kind === "ongoing" ? "agenda.ongoing" : "agenda.allDay"); + return ( +
  • + {when} + + {item.title ?? t(locale, "agenda.untitled")} + +
  • + ); +} + +/** Календарь подключён: список на 7 дней или сообщение о пустой неделе. Только просмотр. */ +export function AgendaPage(props: { + locale: Locale; + isMock: boolean; + days: AgendaDay[]; + timeZone: string; +}) { + const { locale, days, timeZone } = props; + return ( + +

    {t(locale, "agenda.title")}

    +
    {t(locale, "agenda.connected")}
    +

    {t(locale, "agenda.lead")}

    + {days.length === 0 ? ( +
    + {t(locale, "agenda.empty")} + {t(locale, "agenda.emptyHint")} +
    + ) : ( + days.map((day) => ( +
    +

    {formatDayHeading(locale, day.key, day.offset)}

    +
      + {day.items.map((item) => ( + + ))} +
    +
    + )) + )} +
    + ); +} diff --git a/test/agenda.test.ts b/test/agenda.test.ts new file mode 100644 index 0000000..0857fe4 --- /dev/null +++ b/test/agenda.test.ts @@ -0,0 +1,130 @@ +import { describe, expect, it } from "vitest"; +import { buildAgenda, dayKey } from "../src/agenda.js"; +import { ALMATY, allDay, MONDAY_10, timed } from "./helpers.js"; + +const titles = (days: ReturnType) => + days.flatMap((d) => d.items.map((i) => i.title)); + +describe("week-agenda / Окно в 7 дней от сегодняшнего дня", () => { + it("Scenario: События внутри и вне окна", () => { + const days = buildAgenda( + [ + timed("Планёрка", "2026-11-16T10:00"), + timed("Совет директоров", "2026-11-22T15:00"), + allDay("Отпуск", "2026-11-23", "2026-11-28"), + ], + ALMATY, + MONDAY_10, + ); + expect(titles(days)).toEqual(["Планёрка", "Совет директоров"]); + }); + + it("Scenario: Вчерашнее событие не показывается", () => { + const days = buildAgenda( + [timed("Ужин с партнёрами", "2026-11-15T19:00", "2026-11-15T21:00")], + ALMATY, + MONDAY_10, + ); + expect(days).toEqual([]); + }); + + it("событие, закончившееся ровно в полночь, не попадает в сегодня", () => { + const days = buildAgenda( + [timed("Приём", "2026-11-15T20:00", "2026-11-16T00:00")], + ALMATY, + MONDAY_10, + ); + expect(days).toEqual([]); + }); + + it("Scenario: День считается по часовому поясу календаря", () => { + const now = new Date("2026-11-15T20:30:00Z"); // 16 ноября, 01:30 по Алматы + expect(dayKey(now, ALMATY)).toBe("2026-11-16"); + const days = buildAgenda([timed("Звонок", "2026-11-16T09:00")], ALMATY, now); + expect(days).toHaveLength(1); + expect(days[0]).toMatchObject({ key: "2026-11-16", offset: 0 }); + expect(days[0]?.items[0]).toMatchObject({ title: "Звонок", kind: "timed" }); + }); + + it("Scenario: Событие, начавшееся раньше и ещё идущее", () => { + const days = buildAgenda( + [allDay("Командировка", "2026-11-14", "2026-11-18")], + ALMATY, + MONDAY_10, + ); + expect(days).toHaveLength(1); + expect(days[0]).toMatchObject({ key: "2026-11-16", offset: 0 }); + expect(days[0]?.items[0]).toMatchObject({ title: "Командировка", kind: "allDay" }); + }); + + it("событие со временем, начавшееся вчера и идущее сегодня, помечено как продолжающееся", () => { + const days = buildAgenda( + [timed("Ночной перелёт", "2026-11-15T23:00", "2026-11-16T04:00")], + ALMATY, + MONDAY_10, + ); + expect(days[0]?.items[0]).toMatchObject({ + title: "Ночной перелёт", + kind: "ongoing", + start: null, + }); + }); + + it("последний день окна — сегодня + 6, седьмой день после сегодня не входит", () => { + const days = buildAgenda( + [timed("Последний", "2026-11-22T23:30"), timed("За окном", "2026-11-23T00:00")], + ALMATY, + MONDAY_10, + ); + expect(titles(days)).toEqual(["Последний"]); + expect(days[0]?.offset).toBe(6); + }); +}); + +describe("week-agenda / Порядок и группировка по дням", () => { + it("Scenario: Сортировка внутри дня и между днями", () => { + const days = buildAgenda( + [ + timed("Обед", "2026-11-16T13:00"), + timed("Планёрка", "2026-11-16T10:00"), + timed("Отчёт", "2026-11-17T09:00"), + allDay("Выставка", "2026-11-16", "2026-11-17"), + ], + ALMATY, + MONDAY_10, + ); + expect(titles(days)).toEqual(["Выставка", "Планёрка", "Обед", "Отчёт"]); + expect(days.map((d) => [d.key, d.offset, d.items.length])).toEqual([ + ["2026-11-16", 0, 3], + ["2026-11-17", 1, 1], + ]); + }); + + it("Scenario: День без событий пропускается", () => { + const days = buildAgenda( + [timed("А", "2026-11-16T10:00"), timed("Б", "2026-11-19T10:00")], + ALMATY, + MONDAY_10, + ); + expect(days.map((d) => d.key)).toEqual(["2026-11-16", "2026-11-19"]); + }); + + it("Scenario: Повторяющееся событие — отдельный пункт в каждом дне", () => { + const events = [16, 17, 18, 19, 20].map((d) => timed("Планёрка", `2026-11-${d}T10:00`)); + const days = buildAgenda(events, ALMATY, MONDAY_10); + expect(days.map((d) => d.key)).toEqual([ + "2026-11-16", + "2026-11-17", + "2026-11-18", + "2026-11-19", + "2026-11-20", + ]); + expect(days.every((d) => d.items.length === 1)).toBe(true); + }); +}); + +describe("week-agenda / Пустая неделя", () => { + it("Scenario: Ничего не запланировано — список пуст", () => { + expect(buildAgenda([], ALMATY, MONDAY_10)).toEqual([]); + }); +}); diff --git a/test/app.test.ts b/test/app.test.ts new file mode 100644 index 0000000..87cb949 --- /dev/null +++ b/test/app.test.ts @@ -0,0 +1,425 @@ +import { describe, expect, it, vi } from "vitest"; +import { createApp } from "../src/app.js"; +import { MOCK_REVOKED_TOKEN, mockGoogleClient } from "../src/google/mock-client.js"; +import { GoogleAuthError, GoogleError } from "../src/google/types.js"; +import { createConnectionCodec } from "../src/session.js"; +import { + ALMATY, + allDay, + appWith, + browser, + MONDAY_10, + stubGoogle, + timed, + visibleText, +} from "./helpers.js"; + +vi.mock("../src/sentry.js", () => ({ reportError: vi.fn(), initSentry: vi.fn() })); + +const page = async (res: Response) => visibleText(await res.text()); + +describe("служебное", () => { + it("GET /healthz отвечает 200", async () => { + const res = await appWith(stubGoogle().client).request("/healthz"); + expect(res.status).toBe(200); + expect(await res.text()).toBe("ok"); + }); + + it("неизвестная страница — понятное сообщение и ссылка на список", async () => { + const res = await browser(appWith(stubGoogle().client)).get("/nope"); + expect(res.status).toBe(404); + expect(await page(res)).toContain("Такой страницы нет. Вернитесь к списку дел."); + }); +}); + +describe("calendar-connection / Предложение подключить календарь", () => { + it("Scenario: Первый визит без подключения", async () => { + const { client } = stubGoogle([timed("Планёрка", "2026-11-16T10:00")]); + const res = await browser(appWith(client)).get("/"); + const html = await res.text(); + const text = visibleText(html); + expect(res.status).toBe(200); + expect(text).toContain("Подключите календарь"); + expect(html).toMatch(/Подключить календарь Google<\/a>/); + expect(text).not.toContain("Планёрка"); + expect(text).not.toContain("Календарь подключён"); + expect(client.listEvents).not.toHaveBeenCalled(); + }); + + it("Scenario: Подключение не сохранилось в браузере", async () => { + const { client } = stubGoogle(); + const visitor = browser(appWith(client)); + visitor.jar.set( + "ea_conn", + createConnectionCodec("another-install").seal({ refreshToken: "x" }), + ); + const text = await page(await visitor.get("/")); + expect(text).toContain("Подключить календарь Google"); + expect(text).not.toContain("Не удалось"); + expect(client.refreshAccessToken).not.toHaveBeenCalled(); + }); +}); + +describe("calendar-connection / Подключение с доступом только на чтение", () => { + it("Scenario: Успешное подключение", async () => { + const { client } = stubGoogle([timed("Планёрка", "2026-11-16T10:00")]); + const visitor = browser(appWith(client)); + const text = await page(await visitor.connect("allow")); + expect(text).toContain("Календарь подключён"); + expect(text).toContain("Планёрка"); + expect(client.exchangeCode).toHaveBeenCalledWith({ + code: "stub-code", + redirectUri: "http://ea.test/auth/google/callback", + }); + expect(visitor.jar.has("ea_state")).toBe(false); + }); + + it("Scenario: Подключение сохраняется", async () => { + const { client } = stubGoogle([timed("Планёрка", "2026-11-16T10:00")]); + const visitor = browser(appWith(client)); + await visitor.connect("allow"); + const text = await page(await visitor.get("/")); + expect(text).toContain("Календарь подключён"); + expect(client.authUrl).toHaveBeenCalledTimes(1); + expect(client.refreshAccessToken).toHaveBeenLastCalledWith("stub-refresh-token"); + }); + + it("ключ подключения лежит в cookie зашифрованным и недоступен скриптам страницы", async () => { + const { client } = stubGoogle(); + const app = appWith(client); + const visitor = browser(app, { "x-forwarded-proto": "https" }); + const start = await visitor.get("/connect"); + const state = new URL(start.headers.get("location") ?? "").searchParams.get("state"); + const back = await visitor.get(`/auth/google/callback?code=stub-code&state=${state}`); + const cookie = back.headers.getSetCookie().find((c) => c.startsWith("ea_conn=")) ?? ""; + expect(cookie).not.toContain("stub-refresh-token"); + expect(cookie).toMatch(/HttpOnly/i); + expect(cookie).toMatch(/Secure/i); + expect(cookie).toMatch(/SameSite=Lax/i); + }); + + it("адрес возврата строится по внешнему адресу продукта", async () => { + const { client } = stubGoogle(); + await browser(appWith(client), { + "x-forwarded-proto": "https", + "x-forwarded-host": "executive-ai-prod.telecom.quest", + }).get("/connect"); + expect(client.authUrl).toHaveBeenCalledWith( + expect.objectContaining({ + redirectUri: "https://executive-ai-prod.telecom.quest/auth/google/callback", + }), + ); + const fixed = createApp({ + google: client, + sessionSecret: "s", + publicUrl: "https://ea.example", + }); + await browser(fixed).get("/connect"); + expect(client.authUrl).toHaveBeenLastCalledWith( + expect.objectContaining({ redirectUri: "https://ea.example/auth/google/callback" }), + ); + }); +}); + +describe("calendar-connection / Отказ или сбой при подключении", () => { + it("Scenario: Руководитель отказал в доступе", async () => { + const { client } = stubGoogle(); + const visitor = browser(appWith(client)); + const html = await (await visitor.connect("deny")).text(); + expect(visibleText(html)).toContain( + "Календарь не подключён. Чтобы видеть дела, разрешите EA чтение календаря.", + ); + expect(html).toMatch(/href="\/connect">Подключить календарь заново { + const { client } = stubGoogle(); + client.exchangeCode.mockRejectedValueOnce(new GoogleError("invalid_grant")); + const visitor = browser(appWith(client)); + const html = await (await visitor.connect("allow")).text(); + expect(visibleText(html)).toContain( + "Не удалось подключить календарь. Попробуйте подключить его заново.", + ); + expect(html).toMatch(/href="\/connect">Подключить календарь заново { + const { client } = stubGoogle(); + const visitor = browser(appWith(client)); + let state = ""; + if (start) { + const res = await visitor.get("/connect"); + state = new URL(res.headers.get("location") ?? "").searchParams.get("state") ?? ""; + } + const back = await visitor.get(`/auth/google/callback?${query.replace("__STATE__", state)}`); + expect(back.headers.get("location")).toBe("/?notice=failed"); + expect(client.exchangeCode).not.toHaveBeenCalled(); + expect(visitor.jar.has("ea_conn")).toBe(false); + expect(await page(await visitor.get("/?notice=failed"))).toContain( + "Не удалось подключить календарь. Попробуйте подключить его заново.", + ); + }); +}); + +describe("calendar-connection / Отозванный доступ", () => { + it("Scenario: Доступ отозван в настройках Google", async () => { + const { client } = stubGoogle([timed("Планёрка", "2026-11-16T10:00")]); + const visitor = browser(appWith(client)); + await visitor.connect("allow"); + client.refreshAccessToken.mockRejectedValueOnce(new GoogleAuthError("revoked")); + const res = await visitor.get("/"); + const html = await res.text(); + const text = visibleText(html); + expect(res.status).toBe(200); + expect(text).toContain( + "Доступ к календарю закрыт. Подключите календарь заново, чтобы снова видеть дела.", + ); + expect(html).toMatch(/href="\/connect">Подключить календарь заново { + const { client } = stubGoogle(); + const visitor = browser(appWith(client)); + await visitor.connect("allow"); + client.listEvents.mockRejectedValueOnce(new GoogleAuthError("401")); + expect(await page(await visitor.get("/"))).toContain("Доступ к календарю закрыт."); + }); + + it("Scenario: После отзыва подключение проходит заново", async () => { + const { client } = stubGoogle([timed("Планёрка", "2026-11-16T10:00")]); + const visitor = browser(appWith(client)); + await visitor.connect("allow"); + client.refreshAccessToken.mockRejectedValueOnce(new GoogleAuthError("revoked")); + await visitor.get("/"); + const text = await page(await visitor.connect("allow")); + expect(text).toContain("Календарь подключён"); + expect(text).toContain("Планёрка"); + }); +}); + +describe("calendar-connection / Временный сбой календаря", () => { + it("Scenario: Google не отвечает", async () => { + const { client } = stubGoogle([timed("Планёрка", "2026-11-16T10:00")]); + const visitor = browser(appWith(client)); + await visitor.connect("allow"); + client.listEvents.mockRejectedValueOnce(new GoogleError("http_503")); + const res = await visitor.get("/"); + const html = await res.text(); + expect(res.status).toBe(200); + expect(visibleText(html)).toContain( + "Не удалось загрузить календарь. Обновите страницу через минуту.", + ); + expect(html).toMatch(/Обновить<\/a>/); + expect(visitor.jar.has("ea_conn")).toBe(true); + }); + + it("Scenario: После восстановления список виден без повторного подключения", async () => { + const { client } = stubGoogle([timed("Планёрка", "2026-11-16T10:00")]); + const visitor = browser(appWith(client)); + await visitor.connect("allow"); + client.listEvents.mockRejectedValueOnce(new GoogleError("http_503")); + await visitor.get("/"); + const text = await page(await visitor.get("/")); + expect(text).toContain("Календарь подключён"); + expect(text).toContain("Планёрка"); + expect(client.authUrl).toHaveBeenCalledTimes(1); + }); +}); + +describe("calendar-connection / Работа на примерах без ключей Google", () => { + const mockApp = () => + createApp({ + google: mockGoogleClient({ now: () => MONDAY_10 }), + sessionSecret: "s", + now: () => MONDAY_10, + }); + + it("Scenario: Ключи не заданы", async () => { + const visitor = browser(mockApp()); + const start = await visitor.get("/connect"); + const back = await visitor.get( + new URL(start.headers.get("location") ?? "").pathname + + new URL(start.headers.get("location") ?? "").search, + ); + expect(back.headers.get("location")).toBe("/"); + const text = await page(await visitor.get("/")); + expect(text).toContain("Это примеры, а не ваш календарь"); + expect(text).toContain("Календарь подключён"); + expect(text).toContain("Планёрка с руководителями"); + }); + + it("Scenario: Ключи заданы — пометки о примерах нет", async () => { + const text = await page(await browser(appWith(stubGoogle().client)).get("/")); + expect(text).not.toContain("Это примеры"); + }); + + it("мок повторяет отзыв доступа", async () => { + const visitor = browser(mockApp()); + visitor.jar.set( + "ea_conn", + createConnectionCodec("s").seal({ refreshToken: MOCK_REVOKED_TOKEN }), + ); + expect(await page(await visitor.get("/"))).toContain("Доступ к календарю закрыт."); + }); +}); + +describe("week-agenda / экран списка", () => { + async function agenda(events: Parameters[0], now = MONDAY_10) { + const stub = stubGoogle(events); + const visitor = browser(appWith(stub.client, now)); + const res = await visitor.connect("allow"); + const html = await res.text(); + return { ...stub, visitor, html, text: visibleText(html) }; + } + + it("Scenario: Событие со временем / на весь день / без названия", async () => { + const { text } = await agenda([ + timed("Планёрка", "2026-11-16T10:00"), + timed(null, "2026-11-17T12:00"), + allDay("День рождения Айгуль", "2026-11-18", "2026-11-19"), + ]); + expect(text).toContain("Сегодня, 16 ноября 10:00 Планёрка"); + expect(text).toContain("Завтра, 17 ноября 12:00 Без названия"); + expect(text).toContain("Среда, 18 ноября весь день День рождения Айгуль"); + }); + + it("Scenario: Сортировка внутри дня и между днями", async () => { + const { text } = await agenda([ + timed("Обед", "2026-11-16T13:00"), + timed("Планёрка", "2026-11-16T10:00"), + timed("Отчёт", "2026-11-17T09:00"), + allDay("Выставка", "2026-11-16", "2026-11-17"), + ]); + expect(text).toContain( + "Сегодня, 16 ноября весь день Выставка 10:00 Планёрка 13:00 Обед Завтра, 17 ноября 09:00 Отчёт", + ); + }); + + it("Scenario: День считается по часовому поясу календаря", async () => { + const { text, client } = await agenda( + [timed("Звонок", "2026-11-16T09:00")], + new Date("2026-11-15T20:30:00Z"), + ); + expect(text).toContain("Сегодня, 16 ноября 09:00 Звонок"); + const [, range] = client.listEvents.mock.calls[0] as unknown as [ + string, + { timeMin: Date; timeMax: Date }, + ]; + expect(range.timeMin.toISOString()).toBe("2026-11-13T20:30:00.000Z"); + expect(range.timeMax.toISOString()).toBe("2026-11-24T20:30:00.000Z"); + }); + + it("Scenario: Событие, начавшееся раньше и ещё идущее", async () => { + const { text } = await agenda([allDay("Командировка", "2026-11-14", "2026-11-18")]); + expect(text).toContain("Сегодня, 16 ноября весь день Командировка"); + }); + + it("Scenario: Ничего не запланировано", async () => { + const { text } = await agenda([]); + expect(text).toContain("Дел на ближайшие 7 дней нет"); + expect(text).toContain("Календарь подключён"); + }); + + it("Scenario: Есть хотя бы одно событие", async () => { + const { text } = await agenda([timed("Отчёт", "2026-11-22T09:00")]); + expect(text).not.toContain("Дел на ближайшие 7 дней нет"); + expect(text).toContain("Отчёт"); + }); + + it("Scenario: Новое событие появляется после обновления", async () => { + const { visitor, state, text, client } = await agenda([timed("Планёрка", "2026-11-16T10:00")]); + expect(text).not.toContain("Встреча с банком"); + state.events = [...state.events, timed("Встреча с банком", "2026-11-17T11:00")]; + const res = await visitor.get("/"); + expect(res.headers.get("cache-control")).toBe("no-store"); + expect(await page(res)).toContain("Завтра, 17 ноября 11:00 Встреча с банком"); + expect(client.listEvents).toHaveBeenCalledTimes(2); + }); + + it("Scenario: Удалённое событие исчезает после обновления", async () => { + const { visitor, state, text } = await agenda([timed("Обед", "2026-11-16T13:00")]); + expect(text).toContain("Обед"); + state.events = []; + expect(await page(await visitor.get("/"))).not.toContain("Обед"); + }); + + it("Scenario: На экране списка нет действий над событиями", async () => { + const { html, text } = await agenda([timed("Планёрка", "2026-11-16T10:00")]); + expect(html).not.toMatch(/<(form|button|input|select|textarea|script)\b/i); + const links = [...html.matchAll(/]*href="([^"]+)"/g)].map((m) => m[1]); + expect(links).toEqual(["/?lang=ru", "/?lang=kk", "/?lang=en"]); + expect(text).not.toMatch(/Создать|Изменить|Удалить|Добавить/); + }); + + it.each([ + ["POST", "/"], + ["POST", "/events"], + ["DELETE", "/events/1"], + ["PUT", "/"], + ["PATCH", "/events/1"], + ])("Scenario: Запрос на изменение события отклоняется — %s %s", async (method, path) => { + const { visitor, client } = await agenda([timed("Планёрка", "2026-11-16T10:00")]); + const calls = client.listEvents.mock.calls.length; + const res = await visitor.get(path, method); + expect(res.status).toBe(404); + expect(client.listEvents.mock.calls.length).toBe(calls); + }); + + it("название события выводится как текст, а не как разметка", async () => { + const { html } = await agenda([timed('', "2026-11-16T10:00")]); + expect(html).not.toContain(" { + it.each([ + ["ru-RU", "Подключить календарь Google", "ru"], + ["kk-KZ", "Google күнтізбесін қосу", "kk"], + ["en-US", "Connect Google Calendar", "en"], + ["de-DE", "Подключить календарь Google", "ru"], + ])("Scenario Outline: Язык по языку браузера — %s", async (lang, button, code) => { + const html = await ( + await browser(appWith(stubGoogle().client), { "accept-language": lang }).get("/") + ).text(); + expect(visibleText(html)).toContain(button); + expect(html).toContain(``); + }); + + it("Scenario: Переключение на английский запоминается", async () => { + const visitor = browser(appWith(stubGoogle().client)); + expect(await page(await visitor.get("/?lang=en"))).toContain("Connect Google Calendar"); + expect(await page(await visitor.get("/"))).toContain("Connect Google Calendar"); + }); + + it("Scenario: Неизвестный язык в адресе", async () => { + const visitor = browser(appWith(stubGoogle().client)); + await visitor.get("/?lang=kk"); + expect(await page(await visitor.get("/?lang=xx"))).toContain("Google күнтізбесін қосу"); + }); + + it("список на казахском и английском: даты и отметки переведены", async () => { + const { client } = stubGoogle( + [timed("Планёрка", "2026-11-16T10:00"), allDay("Выставка", "2026-11-18", "2026-11-19")], + ALMATY, + ); + const visitor = browser(appWith(client)); + await visitor.connect("allow"); + const en = await page(await visitor.get("/?lang=en")); + expect(en).toContain("Today, November 16 10:00 Планёрка"); + expect(en).toContain("Wednesday, November 18 all day Выставка"); + const kk = await page(await visitor.get("/?lang=kk")); + expect(kk).toContain("Бүгін, 16 қараша 10:00 Планёрка"); + expect(kk).toContain("күні бойы Выставка"); + }); +}); diff --git a/test/glossary.test.ts b/test/glossary.test.ts new file mode 100644 index 0000000..9546409 --- /dev/null +++ b/test/glossary.test.ts @@ -0,0 +1,47 @@ +import { readFileSync } from "node:fs"; +import { describe, expect, it } from "vitest"; +import en from "../src/locales/en.json" with { type: "json" }; +import kk from "../src/locales/kk.json" with { type: "json" }; +import ru from "../src/locales/ru.json" with { type: "json" }; + +/** Слова из колонки «Нельзя» словаря docs/glossary.md. */ +function bannedWords(): string[] { + const lines = readFileSync(new URL("../docs/glossary.md", import.meta.url), "utf8").split("\n"); + return lines + .filter( + (line) => line.startsWith("|") && !line.startsWith("|---") && !line.startsWith("| Понятие"), + ) + .flatMap((line) => (line.split("|")[3] ?? "").split(",")) + .map((word) => word.trim()) + .filter(Boolean); +} + +function findBanned(text: string, banned: string[]): string[] { + return banned.filter((word) => { + const escaped = word.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + return new RegExp(`(? { + const banned = bannedWords(); + + it("словарь читается", () => { + expect(banned).toContain("стори"); + expect(banned).toContain("мок"); + }); + + it.each([ + ["ru", ru], + ["kk", kk], + ["en", en], + ])("в текстах %s нет слов из колонки «Нельзя»", (_name, file) => { + for (const [key, value] of Object.entries(file)) { + expect(findBanned(value, banned), `${key}: ${value}`).toEqual([]); + } + }); + + it("русские тексты обращаются на «вы» со строчной буквы", () => { + for (const value of Object.values(ru)) expect(value).not.toMatch(/(? + new Response(JSON.stringify(body), { status, headers: { "content-type": "application/json" } }); + +function clientWith(...responses: (Response | Error)[]) { + const fetchMock = vi.fn(async (_url: string | URL | Request, _init?: RequestInit) => { + const next = responses.shift(); + if (!next) throw new Error("unexpected request"); + if (next instanceof Error) throw next; + return next; + }); + const client = createGoogleClient({ + clientId: "client-id", + clientSecret: "client-secret", + fetch: fetchMock as typeof fetch, + }); + return { client, fetchMock }; +} + +const range = { + timeMin: new Date("2026-11-14T05:00:00Z"), + timeMax: new Date("2026-11-25T05:00:00Z"), +}; + +describe("клиент Google: страница согласия", () => { + it("Scenario: Запрашивается только чтение", () => { + const { client } = clientWith(); + const url = new URL( + client.authUrl({ state: "s-1", redirectUri: "https://ea.test/auth/google/callback" }), + ); + expect(url.origin + url.pathname).toBe("https://accounts.google.com/o/oauth2/v2/auth"); + expect(url.searchParams.get("scope")).toBe(CALENDAR_SCOPE); + expect(CALENDAR_SCOPE).toBe("https://www.googleapis.com/auth/calendar.events.readonly"); + expect(url.searchParams.get("client_id")).toBe("client-id"); + expect(url.searchParams.get("redirect_uri")).toBe("https://ea.test/auth/google/callback"); + expect(url.searchParams.get("state")).toBe("s-1"); + expect(url.searchParams.get("access_type")).toBe("offline"); + expect(url.searchParams.get("response_type")).toBe("code"); + }); +}); + +describe("клиент Google: обмен кода и обновление доступа", () => { + it("меняет код на ключ подключения", async () => { + const { client, fetchMock } = clientWith(json({ access_token: "a", refresh_token: "r-1" })); + await expect( + client.exchangeCode({ code: "c-1", redirectUri: "https://ea.test/cb" }), + ).resolves.toEqual({ refreshToken: "r-1" }); + const [url, init] = fetchMock.mock.calls[0] ?? []; + expect(String(url)).toBe("https://oauth2.googleapis.com/token"); + const body = new URLSearchParams(String(init?.body)); + expect(Object.fromEntries(body)).toEqual({ + client_id: "client-id", + client_secret: "client-secret", + grant_type: "authorization_code", + code: "c-1", + redirect_uri: "https://ea.test/cb", + }); + }); + + it("Scenario: Google не подтвердил подключение — ошибка обмена кода", async () => { + const { client } = clientWith(json({ error: "invalid_grant" }, 400)); + const failure = client.exchangeCode({ code: "old", redirectUri: "https://ea.test/cb" }); + await expect(failure).rejects.toBeInstanceOf(GoogleError); + await expect(failure).rejects.not.toBeInstanceOf(GoogleAuthError); + }); + + it("ответ без ключа подключения — ошибка", async () => { + const { client } = clientWith(json({ access_token: "a" })); + await expect( + client.exchangeCode({ code: "c", redirectUri: "https://ea.test/cb" }), + ).rejects.toBeInstanceOf(GoogleError); + }); + + it("обновляет доступ по ключу подключения", async () => { + const { client, fetchMock } = clientWith(json({ access_token: "a-2" })); + await expect(client.refreshAccessToken("r-1")).resolves.toBe("a-2"); + const body = new URLSearchParams(String(fetchMock.mock.calls[0]?.[1]?.body)); + expect(body.get("grant_type")).toBe("refresh_token"); + expect(body.get("refresh_token")).toBe("r-1"); + }); + + it("Scenario: Доступ отозван в настройках Google — invalid_grant", async () => { + const { client } = clientWith(json({ error: "invalid_grant" }, 400)); + await expect(client.refreshAccessToken("r-1")).rejects.toBeInstanceOf(GoogleAuthError); + }); + + it("Scenario: Google не отвечает — сбой сети и 500 не считаются отзывом", async () => { + const offline = clientWith(new TypeError("fetch failed")); + const failure = offline.client.refreshAccessToken("r-1"); + await expect(failure).rejects.toBeInstanceOf(GoogleError); + await expect(failure).rejects.not.toBeInstanceOf(GoogleAuthError); + const broken = clientWith(new Response("oops", { status: 500 })); + await expect(broken.client.refreshAccessToken("r-1")).rejects.toBeInstanceOf(GoogleError); + }); +}); + +describe("клиент Google: чтение событий", () => { + it("читает события основного календаря: со временем, на весь день, без названия", async () => { + const { client, fetchMock } = clientWith( + json({ + timeZone: "Asia/Almaty", + items: [ + { + id: "1", + status: "confirmed", + summary: "Планёрка", + start: { dateTime: "2026-11-16T10:00:00+05:00" }, + end: { dateTime: "2026-11-16T10:30:00+05:00" }, + }, + { + id: "2", + summary: "Выставка", + start: { date: "2026-11-17" }, + end: { date: "2026-11-19" }, + }, + { + id: "3", + summary: " ", + start: { dateTime: "2026-11-17T12:00:00+05:00" }, + end: { dateTime: "2026-11-17T13:00:00+05:00" }, + }, + { id: "4", status: "cancelled", summary: "Отменено", start: { date: "2026-11-17" } }, + ], + }), + ); + const result = await client.listEvents("a-1", range); + expect(result.timeZone).toBe("Asia/Almaty"); + expect(result.events).toEqual([ + { + id: "1", + title: "Планёрка", + allDay: false, + start: new Date("2026-11-16T05:00:00Z"), + end: new Date("2026-11-16T05:30:00Z"), + }, + { id: "2", title: "Выставка", allDay: true, startDate: "2026-11-17", endDate: "2026-11-19" }, + { + id: "3", + title: null, + allDay: false, + start: new Date("2026-11-17T07:00:00Z"), + end: new Date("2026-11-17T08:00:00Z"), + }, + ]); + + const [rawUrl, init] = fetchMock.mock.calls[0] ?? []; + const url = new URL(String(rawUrl)); + expect(url.origin + url.pathname).toBe( + "https://www.googleapis.com/calendar/v3/calendars/primary/events", + ); + expect(url.searchParams.get("singleEvents")).toBe("true"); + expect(url.searchParams.get("orderBy")).toBe("startTime"); + expect(url.searchParams.get("timeMin")).toBe("2026-11-14T05:00:00.000Z"); + expect(url.searchParams.get("timeMax")).toBe("2026-11-25T05:00:00.000Z"); + expect(init?.method ?? "GET").toBe("GET"); + expect(new Headers(init?.headers).get("authorization")).toBe("Bearer a-1"); + }); + + it("листает страницы", async () => { + const event = (id: string) => ({ id, summary: id, start: { date: "2026-11-17" } }); + const { client, fetchMock } = clientWith( + json({ timeZone: "Asia/Almaty", items: [event("a")], nextPageToken: "p2" }), + json({ timeZone: "Asia/Almaty", items: [event("b")] }), + ); + const result = await client.listEvents("a-1", range); + expect(result.events.map((e) => e.id)).toEqual(["a", "b"]); + expect(new URL(String(fetchMock.mock.calls[1]?.[0])).searchParams.get("pageToken")).toBe("p2"); + }); + + it.each([ + [401, { error: { errors: [{ reason: "authError" }] } }], + [403, { error: { errors: [{ reason: "insufficientPermissions" }] } }], + ])("Scenario: Доступ отозван — ответ %i", async (status, body) => { + const { client } = clientWith(json(body, status)); + await expect(client.listEvents("a-1", range)).rejects.toBeInstanceOf(GoogleAuthError); + }); + + it.each([ + [403, { error: { errors: [{ reason: "rateLimitExceeded" }] } }], + [500, {}], + [503, {}], + ])("Scenario: Google не отвечает — ответ %i не считается отзывом", async (status, body) => { + const { client } = clientWith(json(body, status)); + const failure = client.listEvents("a-1", range); + await expect(failure).rejects.toBeInstanceOf(GoogleError); + await expect(failure).rejects.not.toBeInstanceOf(GoogleAuthError); + }); +}); diff --git a/test/helpers.ts b/test/helpers.ts new file mode 100644 index 0000000..d567acd --- /dev/null +++ b/test/helpers.ts @@ -0,0 +1,85 @@ +import { vi } from "vitest"; +import type { CalendarEvent } from "../src/agenda.js"; +import { createApp } from "../src/app.js"; +import type { GoogleClient } from "../src/google/types.js"; + +export const ALMATY = "Asia/Almaty"; +/** Понедельник 16 ноября 2026, 10:00 по Алматы. */ +export const MONDAY_10 = new Date("2026-11-16T10:00:00+05:00"); + +export function timed(title: string | null, start: string, end?: string): CalendarEvent { + const startDate = new Date(`${start}:00+05:00`); + const endDate = end ? new Date(`${end}:00+05:00`) : new Date(startDate.getTime() + 3_600_000); + return { id: `${title}-${start}`, title, allDay: false, start: startDate, end: endDate }; +} + +export function allDay(title: string | null, startDate: string, endDate: string): CalendarEvent { + return { id: `${title}-${startDate}`, title, allDay: true, startDate, endDate }; +} + +/** Подставной календарь Google с заданными событиями; вызовы можно проверять. */ +export function stubGoogle(initial: CalendarEvent[] = [], timeZone = ALMATY) { + const state = { events: initial }; + const client = { + isMock: false, + authUrl: vi.fn( + ({ state: s, redirectUri }: { state: string; redirectUri: string }) => + `https://accounts.google.test/consent?state=${s}&redirect_uri=${encodeURIComponent(redirectUri)}`, + ), + exchangeCode: vi.fn(async () => ({ refreshToken: "stub-refresh-token" })), + refreshAccessToken: vi.fn(async () => "stub-access-token"), + listEvents: vi.fn(async () => ({ timeZone, events: state.events })), + } satisfies GoogleClient; + return { client, state }; +} + +/** Браузер для тестов: хранит cookie между запросами. */ +export function browser(app: ReturnType, headers: Record = {}) { + const jar = new Map(); + return { + jar, + async get(path: string, method = "GET") { + const cookie = [...jar].map(([k, v]) => `${k}=${v}`).join("; "); + const res = await app.request(`http://ea.test${path}`, { + method, + headers: { "accept-language": "ru-RU", ...headers, ...(cookie ? { cookie } : {}) }, + }); + for (const line of res.headers.getSetCookie()) { + const [pair = "", ...attrs] = line.split(";"); + const eq = pair.indexOf("="); + const name = pair.slice(0, eq); + const value = pair.slice(eq + 1); + const expired = attrs.some((a) => /^\s*max-age=0$/i.test(a)); + if (expired || value === "") jar.delete(name); + else jar.set(name, value); + } + return res; + }, + /** Проходит подключение: кнопка → страница согласия → возврат в EA. */ + async connect(answer: "allow" | "deny" = "allow") { + const start = await this.get("/connect"); + const consent = new URL(start.headers.get("location") ?? ""); + const state = consent.searchParams.get("state") ?? ""; + const query = + answer === "allow" ? `code=stub-code&state=${state}` : `error=access_denied&state=${state}`; + const back = await this.get(`/auth/google/callback?${query}`); + return this.get(back.headers.get("location") ?? "/"); + }, + }; +} + +export function appWith(google: GoogleClient, now: Date = MONDAY_10) { + return createApp({ google, sessionSecret: "test-secret", now: () => now }); +} + +/** Видимый текст страницы без разметки и стилей. */ +export function visibleText(html: string): string { + return html + .replace(//g, " ") + .replace(//g, " ") + .replace(/<[^>]+>/g, " ") + .replace(/"/g, '"') + .replace(/&/g, "&") + .replace(/\s+/g, " ") + .trim(); +} diff --git a/test/i18n.test.ts b/test/i18n.test.ts new file mode 100644 index 0000000..751c35b --- /dev/null +++ b/test/i18n.test.ts @@ -0,0 +1,61 @@ +import { describe, expect, it } from "vitest"; +import { formatDayHeading, formatTime, LOCALES, pickLocale, t } from "../src/i18n.js"; +import en from "../src/locales/en.json" with { type: "json" }; +import kk from "../src/locales/kk.json" with { type: "json" }; +import ru from "../src/locales/ru.json" with { type: "json" }; + +describe("interface-language / Три языка экрана", () => { + it.each([ + ["ru-RU", "Подключить календарь Google"], + ["kk-KZ", "Google күнтізбесін қосу"], + ["en-US", "Connect Google Calendar"], + ])("Scenario Outline: Язык по языку браузера — %s", (acceptLanguage, button) => { + expect(t(pickLocale({ acceptLanguage }), "connect.button")).toBe(button); + }); + + it("Scenario: Неподдерживаемый язык браузера — русский", () => { + expect(pickLocale({ acceptLanguage: "de-DE,de;q=0.9" })).toBe("ru"); + expect(pickLocale({})).toBe("ru"); + }); + + it("учитывает веса языков браузера", () => { + expect(pickLocale({ acceptLanguage: "de-DE,en;q=0.5,kk;q=0.8" })).toBe("kk"); + }); + + it("в трёх файлах переводов одинаковые ключи и нет пустых текстов", () => { + const keys = Object.keys(ru).sort(); + expect(Object.keys(kk).sort()).toEqual(keys); + expect(Object.keys(en).sort()).toEqual(keys); + for (const file of [ru, kk, en]) { + for (const value of Object.values(file)) expect(value.trim()).not.toBe(""); + } + }); +}); + +describe("interface-language / Выбор языка", () => { + it("выбор в адресе важнее сохранённого, сохранённый — важнее языка браузера", () => { + expect(pickLocale({ query: "en", cookie: "kk", acceptLanguage: "ru" })).toBe("en"); + expect(pickLocale({ cookie: "kk", acceptLanguage: "ru" })).toBe("kk"); + }); + + it("Scenario: Неизвестный язык в адресе не меняет выбор", () => { + expect(pickLocale({ query: "xx", cookie: "kk" })).toBe("kk"); + }); +}); + +describe("даты и время", () => { + it("заголовки дней на трёх языках", () => { + expect(formatDayHeading("ru", "2026-11-16", 0)).toBe("Сегодня, 16 ноября"); + expect(formatDayHeading("ru", "2026-11-17", 1)).toBe("Завтра, 17 ноября"); + expect(formatDayHeading("ru", "2026-11-18", 2)).toBe("Среда, 18 ноября"); + expect(formatDayHeading("en", "2026-11-16", 0)).toBe("Today, November 16"); + expect(formatDayHeading("en", "2026-11-18", 2)).toBe("Wednesday, November 18"); + expect(formatDayHeading("kk", "2026-11-16", 0)).toMatch(/^Бүгін, 16 қараша$/); + }); + + it("время — 24 часа в поясе календаря на всех языках", () => { + const instant = new Date("2026-11-16T04:00:00Z"); + for (const locale of LOCALES) expect(formatTime(locale, instant, "Asia/Almaty")).toBe("09:00"); + expect(formatTime("en", new Date("2026-11-16T10:30:00Z"), "Asia/Almaty")).toBe("15:30"); + }); +}); diff --git a/test/mock-client.test.ts b/test/mock-client.test.ts new file mode 100644 index 0000000..396e3f1 --- /dev/null +++ b/test/mock-client.test.ts @@ -0,0 +1,55 @@ +import { describe, expect, it } from "vitest"; +import { buildAgenda } from "../src/agenda.js"; +import { + MOCK_ACCESS_TOKEN, + MOCK_CODE, + MOCK_DENIED_CODE, + MOCK_REFRESH_TOKEN, + MOCK_REVOKED_TOKEN, + mockGoogleClient, +} from "../src/google/mock-client.js"; +import { GoogleAuthError, GoogleError } from "../src/google/types.js"; +import { MONDAY_10 } from "./helpers.js"; + +describe("мок календаря Google повторяет контракт настоящего клиента", () => { + const mock = mockGoogleClient({ now: () => MONDAY_10 }); + const range = { + timeMin: new Date(MONDAY_10.getTime() - 48 * 3_600_000), + timeMax: new Date(MONDAY_10.getTime() + 9 * 24 * 3_600_000), + }; + + it("помечен как мок и возвращает на адрес завершения подключения с кодом и state", () => { + expect(mock.isMock).toBe(true); + const url = new URL( + mock.authUrl({ state: "s-1", redirectUri: "http://ea.test/auth/google/callback" }), + ); + expect(url.origin + url.pathname).toBe("http://ea.test/auth/google/callback"); + expect(url.searchParams.get("code")).toBe(MOCK_CODE); + expect(url.searchParams.get("state")).toBe("s-1"); + }); + + it("успешный путь: код → ключ подключения → доступ → события", async () => { + const { refreshToken } = await mock.exchangeCode({ code: MOCK_CODE, redirectUri: "x" }); + expect(refreshToken).toBe(MOCK_REFRESH_TOKEN); + const accessToken = await mock.refreshAccessToken(refreshToken); + expect(accessToken).toBe(MOCK_ACCESS_TOKEN); + const { timeZone, events } = await mock.listEvents(accessToken, range); + expect(timeZone).toBe("Asia/Almaty"); + const days = buildAgenda(events, timeZone, MONDAY_10); + expect(days[0]?.key).toBe("2026-11-16"); + expect(days.flatMap((d) => d.items).some((i) => i.kind === "allDay")).toBe(true); + expect(days.flatMap((d) => d.items).some((i) => i.title === null)).toBe(true); + // «Отпуск» через 8 дней — за окном. + expect(days.flatMap((d) => d.items.map((i) => i.title))).not.toContain("Отпуск"); + }); + + it("ошибки — те же классы, что у настоящего клиента", async () => { + await expect( + mock.exchangeCode({ code: MOCK_DENIED_CODE, redirectUri: "x" }), + ).rejects.toBeInstanceOf(GoogleError); + await expect(mock.refreshAccessToken(MOCK_REVOKED_TOKEN)).rejects.toBeInstanceOf( + GoogleAuthError, + ); + await expect(mock.listEvents("wrong", range)).rejects.toBeInstanceOf(GoogleAuthError); + }); +}); diff --git a/test/sentry.test.ts b/test/sentry.test.ts new file mode 100644 index 0000000..23960e0 --- /dev/null +++ b/test/sentry.test.ts @@ -0,0 +1,45 @@ +import { describe, expect, it, vi } from "vitest"; + +const init = vi.fn(); +const captureException = vi.fn(); +vi.mock("@sentry/node", () => ({ init, captureException })); + +describe("ошибки продукта (Bugsink)", () => { + it("без SENTRY_DSN ничего не включается и не отправляется", async () => { + const { initSentry, reportError } = await import("../src/sentry.js"); + const log = vi.spyOn(console, "error").mockImplementation(() => {}); + expect(initSentry({})).toBe(false); + reportError(new Error("boom")); + expect(init).not.toHaveBeenCalled(); + expect(captureException).not.toHaveBeenCalled(); + log.mockRestore(); + }); + + it("с SENTRY_DSN: release и environment из окружения, персональные данные не собираются", async () => { + const { initSentry, reportError } = await import("../src/sentry.js"); + expect( + initSentry({ + SENTRY_DSN: "https://k@bugs.test/1", + SENTRY_RELEASE: "abc123", + SENTRY_ENVIRONMENT: "prod", + }), + ).toBe(true); + expect(init).toHaveBeenCalledWith( + expect.objectContaining({ + dsn: "https://k@bugs.test/1", + release: "abc123", + environment: "prod", + dataCollection: expect.objectContaining({ + userInfo: false, + cookies: false, + httpHeaders: false, + httpBodies: [], + urlQueryParams: false, + }), + }), + ); + const error = new Error("boom"); + reportError(error); + expect(captureException).toHaveBeenCalledWith(error); + }); +}); diff --git a/test/session.test.ts b/test/session.test.ts new file mode 100644 index 0000000..2ec241c --- /dev/null +++ b/test/session.test.ts @@ -0,0 +1,32 @@ +import { describe, expect, it } from "vitest"; +import { createConnectionCodec } from "../src/session.js"; + +describe("cookie подключения", () => { + const codec = createConnectionCodec("secret-a"); + + it("шифрует и расшифровывает подключение, не раскрывая ключ в значении", () => { + const sealed = codec.seal({ refreshToken: "1//refresh-value" }); + expect(sealed).not.toContain("refresh-value"); + expect(Buffer.from(sealed, "base64url").toString("latin1")).not.toContain("refresh-value"); + expect(codec.open(sealed)).toEqual({ refreshToken: "1//refresh-value" }); + }); + + it("одно и то же подключение каждый раз шифруется по-разному", () => { + expect(codec.seal({ refreshToken: "x" })).not.toBe(codec.seal({ refreshToken: "x" })); + }); + + it.each([ + ["пустое значение", ""], + ["мусор", "not-a-cookie"], + ["короткое значение", "AAAA"], + ])("Scenario: Подключение не сохранилось в браузере — %s", (_name, value) => { + expect(codec.open(value)).toBeNull(); + }); + + it("значение, зашифрованное другим ключом или изменённое, не открывается", () => { + const sealed = codec.seal({ refreshToken: "x" }); + expect(createConnectionCodec("secret-b").open(sealed)).toBeNull(); + const tampered = `${sealed.slice(0, -2)}${sealed.endsWith("AA") ? "BB" : "AA"}`; + expect(codec.open(tampered)).toBeNull(); + }); +}); diff --git a/tsconfig.build.json b/tsconfig.build.json new file mode 100644 index 0000000..525ebaf --- /dev/null +++ b/tsconfig.build.json @@ -0,0 +1,5 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions": { "noEmit": false, "outDir": "dist", "rootDir": "src", "sourceMap": true }, + "include": ["src"] +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..46686e9 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "target": "ES2023", + "lib": ["ES2023"], + "module": "NodeNext", + "moduleResolution": "NodeNext", + "strict": true, + "noUncheckedIndexedAccess": true, + "noImplicitOverride": true, + "resolveJsonModule": true, + "esModuleInterop": true, + "skipLibCheck": true, + "jsx": "react-jsx", + "jsxImportSource": "hono/jsx", + "types": ["node"], + "noEmit": true + }, + "include": ["src", "test", "vitest.config.ts"] +} diff --git a/vitest.config.ts b/vitest.config.ts new file mode 100644 index 0000000..5634e03 --- /dev/null +++ b/vitest.config.ts @@ -0,0 +1,5 @@ +import { defineConfig } from "vitest/config"; + +export default defineConfig({ + test: { include: ["test/**/*.test.ts", "test/**/*.test.tsx"] }, +});