diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..8fbc239 --- /dev/null +++ b/.env.example @@ -0,0 +1,41 @@ +# Required +DISCORD_TOKEN= +DATABASE_URL=postgres://lapbot:lapbot@localhost:5432/lapbot + +# Commands register at startup. With DISCORD_GUILD_ID set, commands are +# registered to that server only and update instantly. +DISCORD_APPLICATION_ID= +DISCORD_GUILD_ID= + +LOG_LEVEL=info +LOG_DATABASE_PATH=logs/lapbot.sqlite +DEFAULT_TIMEZONE=Europe/Tallinn + +# Legacy reaction role panel. Leave ROLE_SELECTION_CHANNEL_ID empty to disable. +ROLE_SELECTION_CHANNEL_ID= +TARKVARA_ROLE_ID= +HELPDESK_ROLE_ID= +KULTUUR_ROLE_ID= + +# Movie details (optional). A TMDB "API Read Access Token" from +# https://www.themoviedb.org/settings/api fills in trailers, posters and synopses. +TMDB_ACCESS_TOKEN= + +# Club Google Calendar (optional): lapikud@gmail.com, and the service +# account's JSON key on one line. Share the calendar with the service +# account's email with "Make changes to events". +GOOGLE_CALENDAR_ID= +GOOGLE_SERVICE_ACCOUNT_KEY= + +# Web UI. Off unless WEB_PORT is set; needs DISCORD_GUILD_ID and Discord +# sign-in: DISCORD_CLIENT_SECRET from the developer portal (OAuth2), with +# /login added there as a redirect. +WEB_PORT= +WEB_HOST=127.0.0.1 +WEB_URL= +DISCORD_CLIENT_SECRET= +# openssl rand -hex 32; keeps people signed in across restarts. +SESSION_SECRET= + +# Juhatus role members are application administrators (all bot permissions). +JUHATUS_ROLE_ID= diff --git a/.env.test b/.env.test new file mode 100644 index 0000000..256b979 --- /dev/null +++ b/.env.test @@ -0,0 +1 @@ +TEST_DATABASE_URL=postgres://lapbot:lapbot@127.0.0.1:5433/lapbot_test diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml new file mode 100644 index 0000000..9b641f8 --- /dev/null +++ b/.gitea/workflows/deploy.yml @@ -0,0 +1,16 @@ +name: Deploy to production + +on: + push: + branches: [main] + +jobs: + deploy: + name: Deploy to LXC + runs-on: lapbot + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Run deploy script + run: scripts/deploy/deploy.py diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000..1a9943f --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,9 @@ +## Summary + + + +## Testing + + + +Closes # diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..fec9784 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,63 @@ +name: CI + +on: + pull_request: + workflow_call: + +jobs: + check: + name: Lint, test and build + runs-on: ubuntu-latest + timeout-minutes: 20 + + services: + postgres: + image: postgres:17-alpine + env: + POSTGRES_USER: lapbot + POSTGRES_PASSWORD: lapbot + POSTGRES_DB: lapbot_test + ports: + - 5432:5432 + options: >- + --health-cmd "pg_isready -U lapbot" + --health-interval 5s + --health-timeout 5s + --health-retries 10 + + env: + TEST_DATABASE_URL: postgres://lapbot:lapbot@localhost:5432/lapbot_test + + steps: + - name: Check out code + uses: actions/checkout@v4 + + - name: Set up pnpm + uses: pnpm/action-setup@v4 + + - name: Set up Node + uses: actions/setup-node@v4 + with: + node-version: 24 + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Check formatting + run: pnpm format:check + + - name: Lint + run: pnpm lint + + - name: Check types + run: pnpm typecheck + + - name: Run tests + run: pnpm test + + - name: Test the deploy script + run: python3 scripts/ci/deploy-test.py + + - name: Build + run: pnpm build diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..326beba --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,31 @@ +name: Deploy to production + +on: + push: + branches: [main] + +jobs: + check: + name: CI + uses: ./.github/workflows/ci.yml + + mirror: + name: Push main to Gitea + needs: check + runs-on: ubuntu-latest + timeout-minutes: 5 + environment: production + concurrency: + group: mirror + cancel-in-progress: false + + steps: + - name: Check out code + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Push to Gitea + env: + GITEA_REMOTE: ${{ secrets.GITEA_REMOTE }} + run: git push --force "$GITEA_REMOTE" HEAD:main diff --git a/.gitignore b/.gitignore index da3e65b..c80d268 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ node_modules # Log files -logs +/logs/ *.log npm-debug.log* diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..76d5b5d --- /dev/null +++ b/.prettierignore @@ -0,0 +1,8 @@ +node_modules +dist +coverage +pnpm-lock.yaml +drizzle/meta + +# Ignored execution artifacts +.superpowers diff --git a/.prettierrc.json b/.prettierrc.json new file mode 100644 index 0000000..0f9df28 --- /dev/null +++ b/.prettierrc.json @@ -0,0 +1,13 @@ +{ + "singleQuote": true, + "semi": true, + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "trailingComma": "all", + "bracketSpacing": true, + "bracketSameLine": false, + "arrowParens": "always", + "objectWrap": "preserve", + "endOfLine": "lf" +} diff --git a/README.md b/README.md index 9d1b284..46ce924 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,187 @@ # LAPbot -### SETUP -Install node_modules using `npm install`
-Create a `.env` file
-Put there `BOT TOKEN`, `CHANNELS IDs` and `ROLES IDs` +The Lapikud Discord bot and web dashboard. -`DISCORD_TOKEN=`
-`ROLE_SELECTION_CHANNEL_ID=` - Separate channel where bots role message goes. NB! MAKE SURE THAT NOBODY CAN SEND MESSAGES HERE (except for admins (bot has admin privileges))
-`TARKVARA_ROLE_ID=`
-`HELPDESK_ROLE_ID=`
-`KULTUUR_ROLE_ID=`
+## Setup +Requires Node.js 24, pnpm and Docker. + +```sh +pnpm install +cp .env.example .env +docker compose up -d +pnpm dev +``` + +Migrations and command registration run on start. + +### Discord permissions + +View Channels, Send Messages, Embed Links, Read Message History, Add Reactions, +Manage Messages and Manage Roles. The bot's role must be +above every role it hands out. + +### Configuration + +Settings are documented in `.env.example`. + +- Application administrators: set `JUHATUS_ROLE_ID` to the Juhatus Discord role ID. +- Role selection: `ROLE_SELECTION_CHANNEL_ID` and the role IDs. +- Movie details: `TMDB_ACCESS_TOKEN`. +- Google Calendar: `GOOGLE_CALENDAR_ID=lapikud@gmail.com` and + `GOOGLE_SERVICE_ACCOUNT_KEY`. +- Dashboard: `WEB_PORT`, `DISCORD_GUILD_ID`, `DISCORD_CLIENT_SECRET` and + `SESSION_SECRET`, with `/login` as an OAuth2 redirect. + +## Permissions + +| Command | Who | +| ------------------------------------------------------------------- | ------------------------------------------------------ | +| `/remindme`, `/reminders list/edit/cancel` | everyone; channel reminders need `reminder:channel` | +| `/announce create/edit` | `announcement:create`, `:publish`, `:schedule` | +| `/event create/edit/cancel/list/view/attendees` | `event:create`; the organizer or `event:manage` edits | +| `/birthday set/remove/view/upcoming/post/settings` | everyone; `post` and `settings` need `birthday:manage` | +| `/poll create/list/results/close/cancel` | `poll:create`; the creator or `poll:manage` manages | +| `/movie suggest/suggestions/link/remove/vote/night/watched/history` | `vote`, `night` and `watched` need `movie:manage` | +| `/permissions grant/revoke/list` | `permissions:manage` | +| Web dashboard | `web:access` | + +Discord administrators and members of `JUHATUS_ROLE_ID` hold every bot permission. +Roles and Logs are admin-only. Losing Juhatus removes its admin access. + +Grant permissions to a role or member with `/permissions grant/revoke`, using +`role:` or `user:`. Personal and role grants combine. Non-admins can only grant +permissions they hold, to roles or members below their own. Only admins can +delegate `permissions:manage`. + +### Events + +`/event suggest text:going to the park` saves an idea and posts it in the current +channel without pings. The dashboard inbox needs `event:suggestions:manage`, +which grants inbox access without `web:access`. + +Calendar crossposting is opt-in and needs `event:calendar:publish`. Choose it when +creating an event, or use `/event calendar id:` or the dashboard to post an +existing event. Only public-channel events can be crossposted. Editing linked +calendar details needs the same permission; cancellation removes the entry. +Retry failed calendar posts from the existing event. + +## Development + +| Script | Purpose | +| -------------------------------------------------- | ------------------------------------- | +| `pnpm dev` | Run with reload | +| `pnpm typecheck`, `pnpm lint`, `pnpm format:check` | Static checks | +| `pnpm test:db`, `pnpm test:integration` | Run all tests against a test database | +| `pnpm db:generate` | Create a migration | + +The integration tests reset the database schema. Never point +`TEST_DATABASE_URL` at real data. + +```text +src/ + core/ shared primitives and ports + features// models, rules and services + integrations/ adapters, including db// tables and repositories + web/ dashboard + discord/ commands and listeners + app.ts wiring +tests/ role message, permissions, delivery, integrity +``` + +## Deploying + +Pull requests run CI. A push to `main` runs CI, then mirrors to +`git.lapikud.ee`, where a runner in the LXC container runs +`scripts/deploy/deploy.py`. It builds a new release, restarts the `lapbot` +service and rolls back if the bot doesn't log `Ready` within 90 seconds. +Migrations are not rolled back, so each must work with the previous release. + +`deploy.py` reads these from the runner's environment: + +| Variable | Default | Purpose | +| ---------------------- | ------------------------------------- | ------------------------------ | +| `LAPBOT_ROOT` | `/opt/lapbot` | Where releases and `.env` live | +| `LAPBOT_SERVICE` | `lapbot` | The systemd service | +| `LAPBOT_READY_TIMEOUT` | `90` | Seconds to wait for `Ready` | +| `LAPBOT_REMOTE` | `origin` of the checkout it runs from | Where to clone `repo/` from | + +If you change the root or service, change the unit files below to match. + +### Server setup + +As root, with PostgreSQL running: + +1. Install Node 24, Python 3, git and act_runner, and run `corepack enable`. +2. Create the user and root: + + ```sh + useradd --system --create-home --shell /usr/sbin/nologin lapbot + usermod -aG systemd-journal lapbot + install -d -o lapbot -g lapbot /opt/lapbot + ``` + +3. Write `/opt/lapbot/.env` (owner `lapbot`, mode `600`). +4. Add `/etc/systemd/system/lapbot.service`: + + ```ini + [Unit] + Description=LAPbot + After=network-online.target postgresql.service + + [Service] + User=lapbot + WorkingDirectory=/opt/lapbot/current + EnvironmentFile=/opt/lapbot/.env + Environment=NODE_ENV=production + ExecStart=/usr/bin/node --enable-source-maps dist/index.mjs + Restart=on-failure + TimeoutStopSec=30 + + [Install] + WantedBy=multi-user.target + ``` + +5. Add the restart trigger, since `lapbot` has no sudo. + `/etc/systemd/system/lapbot-restart.path`: + + ```ini + [Path] + PathModified=/opt/lapbot/.restart + + [Install] + WantedBy=multi-user.target + ``` + + `/etc/systemd/system/lapbot-restart.service`: + + ```ini + [Service] + Type=oneshot + ExecStart=/usr/bin/systemctl restart lapbot + ``` + + ```sh + systemctl daemon-reload + systemctl enable lapbot + systemctl enable --now lapbot-restart.path + ``` + +6. Register a repository-only runner and run `act_runner daemon` as `lapbot`: + + ```sh + cd /home/lapbot && runuser -u lapbot -- act_runner register --no-interactive \ + --instance https://git.lapikud.ee --token --name lapbot-lxc --labels lapbot:host + ``` + + The runner can read production secrets. Restrict Gitea pushes to trusted + maintainers or use a read-only mirror. + + Private repo: set `LAPBOT_REMOTE` in the runner environment. Use an SSH URL, + a read-only deploy key and configured known hosts. + +7. On GitHub, add a `production` environment with the secret `GITEA_REMOTE`: + `https://:@git.lapikud.ee//lapbot.git`. +8. Push to `main`. The first deploy clones `/opt/lapbot/repo`. + +Logs: `journalctl -u lapbot`. Back up the database and `/opt/lapbot/logs`. diff --git a/compose.test.yaml b/compose.test.yaml new file mode 100644 index 0000000..eea9345 --- /dev/null +++ b/compose.test.yaml @@ -0,0 +1,16 @@ +services: + postgres-test: + image: postgres:17-alpine + environment: + POSTGRES_USER: lapbot + POSTGRES_PASSWORD: lapbot + POSTGRES_DB: lapbot_test + ports: + - '127.0.0.1:5433:5432' + tmpfs: + - /var/lib/postgresql/data + healthcheck: + test: ['CMD-SHELL', 'pg_isready -U lapbot -d lapbot_test'] + interval: 2s + timeout: 3s + retries: 15 diff --git a/compose.yaml b/compose.yaml new file mode 100644 index 0000000..398bae0 --- /dev/null +++ b/compose.yaml @@ -0,0 +1,20 @@ +services: + postgres: + image: postgres:17-alpine + restart: unless-stopped + environment: + POSTGRES_USER: lapbot + POSTGRES_PASSWORD: lapbot + POSTGRES_DB: lapbot + ports: + - '127.0.0.1:5432:5432' + volumes: + - pgdata:/var/lib/postgresql/data + healthcheck: + test: ['CMD-SHELL', 'pg_isready -U lapbot -d lapbot'] + interval: 5s + timeout: 3s + retries: 10 + +volumes: + pgdata: diff --git a/drizzle.config.ts b/drizzle.config.ts new file mode 100644 index 0000000..3b69ecd --- /dev/null +++ b/drizzle.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'drizzle-kit'; + +export default defineConfig({ + dialect: 'postgresql', + schema: './src/integrations/db/*/table.ts', + out: './drizzle', +}); diff --git a/drizzle.logs.config.ts b/drizzle.logs.config.ts new file mode 100644 index 0000000..c79b14a --- /dev/null +++ b/drizzle.logs.config.ts @@ -0,0 +1,7 @@ +import { defineConfig } from 'drizzle-kit'; + +export default defineConfig({ + dialect: 'sqlite', + schema: './src/integrations/logging/table.ts', + out: './drizzle/logs', +}); diff --git a/drizzle/0000_init.sql b/drizzle/0000_init.sql new file mode 100644 index 0000000..4dbf5d6 --- /dev/null +++ b/drizzle/0000_init.sql @@ -0,0 +1,209 @@ +CREATE TYPE "public"."announcement_status" AS ENUM('draft', 'scheduled', 'published', 'cancelled');--> statement-breakpoint +CREATE TYPE "public"."birthday_visibility" AS ENUM('public', 'announce', 'private');--> statement-breakpoint +CREATE TYPE "public"."event_status" AS ENUM('scheduled', 'cancelled');--> statement-breakpoint +CREATE TYPE "public"."rsvp_status" AS ENUM('going', 'maybe', 'not_going');--> statement-breakpoint +CREATE TYPE "public"."poll_result_visibility" AS ENUM('live', 'closed');--> statement-breakpoint +CREATE TYPE "public"."poll_status" AS ENUM('open', 'closed', 'cancelled');--> statement-breakpoint +CREATE TYPE "public"."reminder_recurrence" AS ENUM('daily', 'weekly', 'monthly');--> statement-breakpoint +CREATE TYPE "public"."reminder_status" AS ENUM('active', 'done', 'cancelled', 'failed');--> statement-breakpoint +CREATE TYPE "public"."role_panel_kind" AS ENUM('reaction', 'select');--> statement-breakpoint +CREATE TABLE "announcements" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "author_id" text NOT NULL, + "channel_id" text NOT NULL, + "title" text, + "content" text NOT NULL, + "mention_role_ids" text[] DEFAULT '{}' NOT NULL, + "status" "announcement_status" DEFAULT 'draft' NOT NULL, + "scheduled_at" timestamp with time zone, + "published_at" timestamp with time zone, + "message_ids" text[] DEFAULT '{}' NOT NULL, + "failure" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "birthday_settings" ( + "guild_id" text PRIMARY KEY NOT NULL, + "channel_id" text NOT NULL, + "hour" smallint DEFAULT 9 NOT NULL +); +--> statement-breakpoint +CREATE TABLE "birthdays" ( + "guild_id" text NOT NULL, + "user_id" text NOT NULL, + "month" smallint NOT NULL, + "day" smallint NOT NULL, + "visibility" "birthday_visibility" DEFAULT 'public' NOT NULL, + "last_announced_year" integer, + CONSTRAINT "birthdays_guild_id_user_id_pk" PRIMARY KEY("guild_id","user_id") +); +--> statement-breakpoint +CREATE TABLE "event_suggestions" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "author_id" text NOT NULL, + "text" text NOT NULL, + "channel_id" text NOT NULL, + "message_id" text, + "status" text DEFAULT 'new' NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "event_suggestions_status" CHECK ("event_suggestions"."status" IN ('new', 'reviewed', 'dismissed')) +); +--> statement-breakpoint +CREATE TABLE "event_rsvps" ( + "event_id" integer NOT NULL, + "user_id" text NOT NULL, + "status" "rsvp_status" NOT NULL, + "updated_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "event_rsvps_event_id_user_id_pk" PRIMARY KEY("event_id","user_id") +); +--> statement-breakpoint +CREATE TABLE "events" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "title" text NOT NULL, + "description" text, + "starts_at" timestamp with time zone NOT NULL, + "ends_at" timestamp with time zone, + "timezone" text NOT NULL, + "location" text, + "organizer_id" text NOT NULL, + "channel_id" text NOT NULL, + "message_id" text, + "capacity" integer, + "mention_role_id" text, + "reminder_minutes" integer[] DEFAULT '{}' NOT NULL, + "icons" boolean DEFAULT true NOT NULL, + "calendar_event_id" text, + "status" "event_status" DEFAULT 'scheduled' NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "movie_screenings" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "suggestion_id" integer NOT NULL, + "event_id" integer, + "poll_id" integer, + "scheduled_for" timestamp with time zone, + "watched_at" timestamp with time zone, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "movie_suggestions" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "title" text NOT NULL, + "normalized_title" text NOT NULL, + "year" smallint, + "note" text, + "suggested_by" text NOT NULL, + "tmdb_id" integer, + "overview" text, + "poster_url" text, + "trailer_url" text, + "links" text[] DEFAULT '{}' NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + "removed_at" timestamp with time zone +); +--> statement-breakpoint +CREATE TABLE "role_permissions" ( + "guild_id" text NOT NULL, + "role_id" text NOT NULL, + "subject_type" text DEFAULT 'role' NOT NULL, + "permission" text NOT NULL, + "granted_by" text NOT NULL, + "granted_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "role_permissions_guild_id_role_id_subject_type_permission_pk" PRIMARY KEY("guild_id","role_id","subject_type","permission"), + CONSTRAINT "role_permissions_subject_type_check" CHECK ("role_permissions"."subject_type" IN ('role', 'user')) +); +--> statement-breakpoint +CREATE TABLE "poll_options" ( + "id" serial PRIMARY KEY NOT NULL, + "poll_id" integer NOT NULL, + "position" integer NOT NULL, + "label" text NOT NULL, + "ref" text, + "url" text, + CONSTRAINT "poll_options_position_unique" UNIQUE("poll_id","position") +); +--> statement-breakpoint +CREATE TABLE "poll_votes" ( + "poll_id" integer NOT NULL, + "option_id" integer NOT NULL, + "user_id" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "poll_votes_poll_id_user_id_option_id_pk" PRIMARY KEY("poll_id","user_id","option_id") +); +--> statement-breakpoint +CREATE TABLE "polls" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "channel_id" text NOT NULL, + "message_id" text, + "creator_id" text NOT NULL, + "question" text NOT NULL, + "multiple" boolean DEFAULT false NOT NULL, + "anonymous" boolean DEFAULT false NOT NULL, + "show_results" "poll_result_visibility" DEFAULT 'live' NOT NULL, + "closes_at" timestamp with time zone, + "status" "poll_status" DEFAULT 'open' NOT NULL, + "source" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "reminders" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "user_id" text NOT NULL, + "channel_id" text, + "message" text NOT NULL, + "run_at" timestamp with time zone NOT NULL, + "recurrence" "reminder_recurrence", + "timezone" text NOT NULL, + "status" "reminder_status" DEFAULT 'active' NOT NULL, + "failure" text, + "created_at" timestamp with time zone DEFAULT now() NOT NULL +); +--> statement-breakpoint +CREATE TABLE "role_panel_roles" ( + "panel_id" integer NOT NULL, + "role_id" text NOT NULL, + "label" text NOT NULL, + "emoji" text, + "position" integer NOT NULL, + CONSTRAINT "role_panel_roles_panel_id_role_id_pk" PRIMARY KEY("panel_id","role_id") +); +--> statement-breakpoint +CREATE TABLE "role_panels" ( + "id" serial PRIMARY KEY NOT NULL, + "guild_id" text NOT NULL, + "channel_id" text NOT NULL, + "message_id" text, + "kind" "role_panel_kind" NOT NULL, + "title" text NOT NULL, + "created_by" text NOT NULL, + "created_at" timestamp with time zone DEFAULT now() NOT NULL, + CONSTRAINT "role_panels_message_id_unique" UNIQUE("message_id") +); +--> statement-breakpoint +ALTER TABLE "event_rsvps" ADD CONSTRAINT "event_rsvps_event_id_events_id_fk" FOREIGN KEY ("event_id") REFERENCES "public"."events"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "movie_screenings" ADD CONSTRAINT "movie_screenings_suggestion_id_movie_suggestions_id_fk" FOREIGN KEY ("suggestion_id") REFERENCES "public"."movie_suggestions"("id") ON DELETE no action ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "poll_options" ADD CONSTRAINT "poll_options_poll_id_polls_id_fk" FOREIGN KEY ("poll_id") REFERENCES "public"."polls"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "poll_votes" ADD CONSTRAINT "poll_votes_poll_id_polls_id_fk" FOREIGN KEY ("poll_id") REFERENCES "public"."polls"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "poll_votes" ADD CONSTRAINT "poll_votes_option_id_poll_options_id_fk" FOREIGN KEY ("option_id") REFERENCES "public"."poll_options"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +ALTER TABLE "role_panel_roles" ADD CONSTRAINT "role_panel_roles_panel_id_role_panels_id_fk" FOREIGN KEY ("panel_id") REFERENCES "public"."role_panels"("id") ON DELETE cascade ON UPDATE no action;--> statement-breakpoint +CREATE INDEX "announcements_guild_idx" ON "announcements" USING btree ("guild_id","status");--> statement-breakpoint +CREATE INDEX "birthdays_date_idx" ON "birthdays" USING btree ("guild_id","month","day");--> statement-breakpoint +CREATE INDEX "event_suggestions_guild_id_id" ON "event_suggestions" USING btree ("guild_id","id");--> statement-breakpoint +CREATE INDEX "event_rsvps_status_idx" ON "event_rsvps" USING btree ("event_id","status");--> statement-breakpoint +CREATE INDEX "events_guild_start_idx" ON "events" USING btree ("guild_id","starts_at");--> statement-breakpoint +CREATE INDEX "movie_screenings_guild_idx" ON "movie_screenings" USING btree ("guild_id","watched_at");--> statement-breakpoint +CREATE UNIQUE INDEX "movie_suggestions_unique_idx" ON "movie_suggestions" USING btree ("guild_id","normalized_title") WHERE "movie_suggestions"."removed_at" is null;--> statement-breakpoint +CREATE INDEX "poll_votes_option_idx" ON "poll_votes" USING btree ("option_id");--> statement-breakpoint +CREATE INDEX "polls_guild_status_idx" ON "polls" USING btree ("guild_id","status");--> statement-breakpoint +CREATE INDEX "polls_source_idx" ON "polls" USING btree ("guild_id","source","created_at");--> statement-breakpoint +CREATE INDEX "reminders_user_idx" ON "reminders" USING btree ("guild_id","user_id","status");--> statement-breakpoint +CREATE INDEX "role_panels_guild_idx" ON "role_panels" USING btree ("guild_id");--> statement-breakpoint +CREATE UNIQUE INDEX "role_panels_reaction_channel_idx" ON "role_panels" USING btree ("guild_id","channel_id") WHERE "role_panels"."kind" = 'reaction'; diff --git a/drizzle/logs/0000_logs.sql b/drizzle/logs/0000_logs.sql new file mode 100644 index 0000000..2a979f8 --- /dev/null +++ b/drizzle/logs/0000_logs.sql @@ -0,0 +1,8 @@ +CREATE TABLE `logs` ( + `id` integer PRIMARY KEY NOT NULL, + `time` integer NOT NULL, + `level` integer NOT NULL, + `message` text NOT NULL, + `source` text NOT NULL, + `details` text NOT NULL +); diff --git a/drizzle/logs/meta/0000_snapshot.json b/drizzle/logs/meta/0000_snapshot.json new file mode 100644 index 0000000..6ea0bdf --- /dev/null +++ b/drizzle/logs/meta/0000_snapshot.json @@ -0,0 +1,70 @@ +{ + "version": "6", + "dialect": "sqlite", + "id": "26ac5a8b-41f9-49fc-a99d-fa03a77da199", + "prevId": "00000000-0000-0000-0000-000000000000", + "tables": { + "logs": { + "name": "logs", + "columns": { + "id": { + "name": "id", + "type": "integer", + "primaryKey": true, + "notNull": true, + "autoincrement": false + }, + "time": { + "name": "time", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "level": { + "name": "level", + "type": "integer", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + }, + "details": { + "name": "details", + "type": "text", + "primaryKey": false, + "notNull": true, + "autoincrement": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "checkConstraints": {} + } + }, + "views": {}, + "enums": {}, + "_meta": { + "schemas": {}, + "tables": {}, + "columns": {} + }, + "internal": { + "indexes": {} + } +} diff --git a/drizzle/logs/meta/_journal.json b/drizzle/logs/meta/_journal.json new file mode 100644 index 0000000..6310b88 --- /dev/null +++ b/drizzle/logs/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "sqlite", + "entries": [ + { + "idx": 0, + "version": "6", + "when": 1794917871103, + "tag": "0000_logs", + "breakpoints": true + } + ] +} diff --git a/drizzle/meta/0000_snapshot.json b/drizzle/meta/0000_snapshot.json new file mode 100644 index 0000000..fcba89d --- /dev/null +++ b/drizzle/meta/0000_snapshot.json @@ -0,0 +1,1538 @@ +{ + "id": "a4d70267-c709-42ad-8ab1-52ab79967e09", + "prevId": "00000000-0000-0000-0000-000000000000", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.announcements": { + "name": "announcements", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "content": { + "name": "content", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "mention_role_ids": { + "name": "mention_role_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "status": { + "name": "status", + "type": "announcement_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'draft'" + }, + "scheduled_at": { + "name": "scheduled_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "published_at": { + "name": "published_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "message_ids": { + "name": "message_ids", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "announcements_guild_idx": { + "name": "announcements_guild_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.birthday_settings": { + "name": "birthday_settings", + "schema": "", + "columns": { + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "hour": { + "name": "hour", + "type": "smallint", + "primaryKey": false, + "notNull": true, + "default": 9 + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.birthdays": { + "name": "birthdays", + "schema": "", + "columns": { + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "month": { + "name": "month", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "day": { + "name": "day", + "type": "smallint", + "primaryKey": false, + "notNull": true + }, + "visibility": { + "name": "visibility", + "type": "birthday_visibility", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'public'" + }, + "last_announced_year": { + "name": "last_announced_year", + "type": "integer", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "birthdays_date_idx": { + "name": "birthdays_date_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "month", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "day", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": { + "birthdays_guild_id_user_id_pk": { + "name": "birthdays_guild_id_user_id_pk", + "columns": [ + "guild_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.event_suggestions": { + "name": "event_suggestions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "author_id": { + "name": "author_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "text": { + "name": "text", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'new'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "event_suggestions_guild_id_id": { + "name": "event_suggestions_guild_id_id", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "event_suggestions_status": { + "name": "event_suggestions_status", + "value": "\"event_suggestions\".\"status\" IN ('new', 'reviewed', 'dismissed')" + } + }, + "isRLSEnabled": false + }, + "public.event_rsvps": { + "name": "event_rsvps", + "schema": "", + "columns": { + "event_id": { + "name": "event_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "rsvp_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "event_rsvps_status_idx": { + "name": "event_rsvps_status_idx", + "columns": [ + { + "expression": "event_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "event_rsvps_event_id_events_id_fk": { + "name": "event_rsvps_event_id_events_id_fk", + "tableFrom": "event_rsvps", + "tableTo": "events", + "columnsFrom": [ + "event_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "event_rsvps_event_id_user_id_pk": { + "name": "event_rsvps_event_id_user_id_pk", + "columns": [ + "event_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.events": { + "name": "events", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "starts_at": { + "name": "starts_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "ends_at": { + "name": "ends_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "location": { + "name": "location", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "organizer_id": { + "name": "organizer_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "capacity": { + "name": "capacity", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "mention_role_id": { + "name": "mention_role_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "reminder_minutes": { + "name": "reminder_minutes", + "type": "integer[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "icons": { + "name": "icons", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": true + }, + "calendar_event_id": { + "name": "calendar_event_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "event_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'scheduled'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "events_guild_start_idx": { + "name": "events_guild_start_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "starts_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.movie_screenings": { + "name": "movie_screenings", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "suggestion_id": { + "name": "suggestion_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "event_id": { + "name": "event_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "poll_id": { + "name": "poll_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "scheduled_for": { + "name": "scheduled_for", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "watched_at": { + "name": "watched_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "movie_screenings_guild_idx": { + "name": "movie_screenings_guild_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "watched_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "movie_screenings_suggestion_id_movie_suggestions_id_fk": { + "name": "movie_screenings_suggestion_id_movie_suggestions_id_fk", + "tableFrom": "movie_screenings", + "tableTo": "movie_suggestions", + "columnsFrom": [ + "suggestion_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.movie_suggestions": { + "name": "movie_suggestions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "normalized_title": { + "name": "normalized_title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "year": { + "name": "year", + "type": "smallint", + "primaryKey": false, + "notNull": false + }, + "note": { + "name": "note", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "suggested_by": { + "name": "suggested_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "tmdb_id": { + "name": "tmdb_id", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "overview": { + "name": "overview", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "poster_url": { + "name": "poster_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "trailer_url": { + "name": "trailer_url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "links": { + "name": "links", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "removed_at": { + "name": "removed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "movie_suggestions_unique_idx": { + "name": "movie_suggestions_unique_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "normalized_title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"movie_suggestions\".\"removed_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.role_permissions": { + "name": "role_permissions", + "schema": "", + "columns": { + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "subject_type": { + "name": "subject_type", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "'role'" + }, + "permission": { + "name": "permission", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_by": { + "name": "granted_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "granted_at": { + "name": "granted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": { + "role_permissions_guild_id_role_id_subject_type_permission_pk": { + "name": "role_permissions_guild_id_role_id_subject_type_permission_pk", + "columns": [ + "guild_id", + "role_id", + "subject_type", + "permission" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": { + "role_permissions_subject_type_check": { + "name": "role_permissions_subject_type_check", + "value": "\"role_permissions\".\"subject_type\" IN ('role', 'user')" + } + }, + "isRLSEnabled": false + }, + "public.poll_options": { + "name": "poll_options", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "poll_id": { + "name": "poll_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "ref": { + "name": "ref", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "poll_options_poll_id_polls_id_fk": { + "name": "poll_options_poll_id_polls_id_fk", + "tableFrom": "poll_options", + "tableTo": "polls", + "columnsFrom": [ + "poll_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "poll_options_position_unique": { + "name": "poll_options_position_unique", + "nullsNotDistinct": false, + "columns": [ + "poll_id", + "position" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.poll_votes": { + "name": "poll_votes", + "schema": "", + "columns": { + "poll_id": { + "name": "poll_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "option_id": { + "name": "option_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "poll_votes_option_idx": { + "name": "poll_votes_option_idx", + "columns": [ + { + "expression": "option_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "poll_votes_poll_id_polls_id_fk": { + "name": "poll_votes_poll_id_polls_id_fk", + "tableFrom": "poll_votes", + "tableTo": "polls", + "columnsFrom": [ + "poll_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "poll_votes_option_id_poll_options_id_fk": { + "name": "poll_votes_option_id_poll_options_id_fk", + "tableFrom": "poll_votes", + "tableTo": "poll_options", + "columnsFrom": [ + "option_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "poll_votes_poll_id_user_id_option_id_pk": { + "name": "poll_votes_poll_id_user_id_option_id_pk", + "columns": [ + "poll_id", + "user_id", + "option_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.polls": { + "name": "polls", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "creator_id": { + "name": "creator_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "question": { + "name": "question", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "multiple": { + "name": "multiple", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "anonymous": { + "name": "anonymous", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "show_results": { + "name": "show_results", + "type": "poll_result_visibility", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'live'" + }, + "closes_at": { + "name": "closes_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "status": { + "name": "status", + "type": "poll_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'open'" + }, + "source": { + "name": "source", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "polls_guild_status_idx": { + "name": "polls_guild_status_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "polls_source_idx": { + "name": "polls_source_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "source", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.reminders": { + "name": "reminders", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "run_at": { + "name": "run_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "recurrence": { + "name": "recurrence", + "type": "reminder_recurrence", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "timezone": { + "name": "timezone", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "reminder_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'active'" + }, + "failure": { + "name": "failure", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "reminders_user_idx": { + "name": "reminders_user_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.role_panel_roles": { + "name": "role_panel_roles", + "schema": "", + "columns": { + "panel_id": { + "name": "panel_id", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "role_id": { + "name": "role_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "emoji": { + "name": "emoji", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "position": { + "name": "position", + "type": "integer", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "role_panel_roles_panel_id_role_panels_id_fk": { + "name": "role_panel_roles_panel_id_role_panels_id_fk", + "tableFrom": "role_panel_roles", + "tableTo": "role_panels", + "columnsFrom": [ + "panel_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "role_panel_roles_panel_id_role_id_pk": { + "name": "role_panel_roles_panel_id_role_id_pk", + "columns": [ + "panel_id", + "role_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.role_panels": { + "name": "role_panels", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "serial", + "primaryKey": true, + "notNull": true + }, + "guild_id": { + "name": "guild_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "channel_id": { + "name": "channel_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message_id": { + "name": "message_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "kind": { + "name": "kind", + "type": "role_panel_kind", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_by": { + "name": "created_by", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "role_panels_guild_idx": { + "name": "role_panels_guild_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "role_panels_reaction_channel_idx": { + "name": "role_panels_reaction_channel_idx", + "columns": [ + { + "expression": "guild_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "channel_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"role_panels\".\"kind\" = 'reaction'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": { + "role_panels_message_id_unique": { + "name": "role_panels_message_id_unique", + "nullsNotDistinct": false, + "columns": [ + "message_id" + ] + } + }, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.announcement_status": { + "name": "announcement_status", + "schema": "public", + "values": [ + "draft", + "scheduled", + "published", + "cancelled" + ] + }, + "public.birthday_visibility": { + "name": "birthday_visibility", + "schema": "public", + "values": [ + "public", + "announce", + "private" + ] + }, + "public.event_status": { + "name": "event_status", + "schema": "public", + "values": [ + "scheduled", + "cancelled" + ] + }, + "public.rsvp_status": { + "name": "rsvp_status", + "schema": "public", + "values": [ + "going", + "maybe", + "not_going" + ] + }, + "public.poll_result_visibility": { + "name": "poll_result_visibility", + "schema": "public", + "values": [ + "live", + "closed" + ] + }, + "public.poll_status": { + "name": "poll_status", + "schema": "public", + "values": [ + "open", + "closed", + "cancelled" + ] + }, + "public.reminder_recurrence": { + "name": "reminder_recurrence", + "schema": "public", + "values": [ + "daily", + "weekly", + "monthly" + ] + }, + "public.reminder_status": { + "name": "reminder_status", + "schema": "public", + "values": [ + "active", + "done", + "cancelled", + "failed" + ] + }, + "public.role_panel_kind": { + "name": "role_panel_kind", + "schema": "public", + "values": [ + "reaction", + "select" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} diff --git a/drizzle/meta/_journal.json b/drizzle/meta/_journal.json new file mode 100644 index 0000000..f988eca --- /dev/null +++ b/drizzle/meta/_journal.json @@ -0,0 +1,13 @@ +{ + "version": "7", + "dialect": "postgresql", + "entries": [ + { + "idx": 0, + "version": "7", + "when": 1794987918522, + "tag": "0000_init", + "breakpoints": true + } + ] +} \ No newline at end of file diff --git a/eslint.config.ts b/eslint.config.ts new file mode 100644 index 0000000..502a210 --- /dev/null +++ b/eslint.config.ts @@ -0,0 +1,419 @@ +import js from '@eslint/js'; +import type { Linter } from 'eslint'; +import { defineConfig, globalIgnores } from 'eslint/config'; +import tseslint from 'typescript-eslint'; +import react from 'eslint-plugin-react'; +import { configs as sonarConfigs } from 'eslint-plugin-sonarjs'; +import unicorn from 'eslint-plugin-unicorn'; +import prettier from 'eslint-config-prettier'; +import globals from 'globals'; +import importX from 'eslint-plugin-import-x'; +import { createTypeScriptImportResolver } from 'eslint-import-resolver-typescript'; + +const javascriptFiles = ['**/*.{js,mjs,cjs,jsx}']; +const typescriptFiles = ['**/*.{ts,mts,cts,tsx}']; +const sourceFiles = [...javascriptFiles, ...typescriptFiles]; + +const qualityRules: Linter.RulesRecord = { + 'no-alert': 'error', + 'no-console': ['warn', { allow: ['warn', 'error'] }], + 'no-eval': 'error', + 'no-implied-eval': 'error', + 'no-new-func': 'error', + 'no-new-wrappers': 'error', + 'no-promise-executor-return': 'error', + 'no-unmodified-loop-condition': 'error', + 'no-unreachable-loop': 'error', + 'no-template-curly-in-string': 'error', + 'no-useless-call': 'error', + 'no-useless-concat': 'error', + 'no-useless-return': 'error', + 'no-else-return': 'error', + 'no-lonely-if': 'error', + 'no-param-reassign': 'error', + 'no-shadow': 'error', + + 'array-callback-return': ['error', { checkForEach: true }], + 'consistent-return': 'error', + 'default-case-last': 'error', + 'default-param-last': 'error', + eqeqeq: ['error', 'always'], + curly: ['error', 'all'], + 'dot-notation': 'error', + 'guard-for-in': 'error', + radix: 'error', + yoda: 'error', + + 'object-shorthand': ['error', 'always'], + 'prefer-const': 'error', + 'prefer-template': 'error', + 'prefer-object-spread': 'error', + 'prefer-rest-params': 'error', + 'prefer-spread': 'error', + 'prefer-exponentiation-operator': 'error', + 'prefer-numeric-literals': 'error', + 'prefer-promise-reject-errors': 'error', + + 'no-duplicate-imports': ['error', { allowSeparateTypeImports: true }], + + complexity: ['error', { max: 15 }], + 'max-depth': ['error', { max: 4 }], + 'max-params': ['error', { max: 4 }], + 'no-await-in-loop': 'error', + 'max-nested-callbacks': ['error', { max: 4 }], +}; + +const noDiscordImport = { + name: 'discord.js', + message: 'Only Discord adapters may use discord.js.', +}; + +const unicornRules: Linter.RulesRecord = { + 'unicorn/prefer-set-has': 'error', + 'unicorn/prefer-array-some': 'error', + 'unicorn/prefer-array-find': 'error', + 'unicorn/prefer-array-flat': 'error', + 'unicorn/prefer-array-flat-map': 'error', + 'unicorn/prefer-array-index-of': 'error', + 'unicorn/prefer-includes': 'error', + 'unicorn/prefer-string-starts-ends-with': 'error', + 'unicorn/prefer-string-slice': 'error', + 'unicorn/prefer-string-replace-all': 'error', + 'unicorn/prefer-string-raw': 'error', + 'unicorn/prefer-number-properties': 'error', + 'unicorn/prefer-regexp-test': 'error', + 'unicorn/prefer-type-error': 'error', + 'unicorn/prefer-date-now': 'error', + 'unicorn/prefer-at': 'error', + + 'unicorn/no-useless-switch-case': 'error', + 'unicorn/no-useless-promise-resolve-reject': 'error', + 'unicorn/no-useless-spread': 'error', + 'unicorn/no-useless-length-check': 'error', + 'unicorn/no-unnecessary-await': 'error', + 'unicorn/no-useless-undefined': 'error', + 'unicorn/no-await-expression-member': 'error', + 'unicorn/no-for-loop': 'error', + + 'unicorn/no-array-callback-reference': 'error', +}; + +export default defineConfig( + globalIgnores([ + '**/node_modules/**', + '**/dist/**', + '**/build/**', + '**/coverage/**', + '**/.next/**', + '**/.nuxt/**', + '**/.output/**', + '**/.cache/**', + '**/.turbo/**', + '**/.vercel/**', + '**/vendor/**', + '**/generated/**', + '**/*.generated.*', + '**/*.min.js', + '**/*.d.ts', + ]), + + { + files: sourceFiles, + extends: [js.configs.recommended, sonarConfigs.recommended], + languageOptions: { + ecmaVersion: 'latest', + globals: globals.builtin, + }, + rules: qualityRules, + }, + + { + files: sourceFiles, + plugins: { unicorn }, + rules: unicornRules, + }, + + { + files: ['**/*.tsx'], + plugins: { react }, + settings: { react: { version: '19' } }, + rules: { + 'react/jsx-key': ['error', { checkFragmentShorthand: true }], + 'react/no-array-index-key': 'error', + 'react/button-has-type': 'error', + }, + }, + + { + files: javascriptFiles, + languageOptions: { + sourceType: 'module', + }, + rules: { + 'no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + }, + }, + + { + files: ['**/*.cjs'], + languageOptions: { + sourceType: 'commonjs', + globals: globals.node, + }, + }, + + { + files: typescriptFiles, + extends: [ + tseslint.configs.strictTypeChecked, + tseslint.configs.stylisticTypeChecked, + ], + languageOptions: { + parserOptions: { + projectService: true, + tsconfigRootDir: import.meta.dirname, + }, + }, + rules: { + 'no-unused-vars': 'off', + 'no-shadow': 'off', + 'default-param-last': 'off', + + '@typescript-eslint/no-shadow': 'error', + '@typescript-eslint/default-param-last': 'error', + '@typescript-eslint/no-redeclare': 'error', + + '@typescript-eslint/no-unsafe-type-assertion': 'error', + + '@typescript-eslint/consistent-type-imports': [ + 'error', + { + prefer: 'type-imports', + fixStyle: 'separate-type-imports', + }, + ], + '@typescript-eslint/consistent-type-exports': 'error', + '@typescript-eslint/consistent-type-definitions': ['error', 'interface'], + '@typescript-eslint/consistent-generic-constructors': [ + 'error', + 'constructor', + ], + '@typescript-eslint/array-type': ['error', { default: 'array-simple' }], + '@typescript-eslint/method-signature-style': ['error', 'property'], + + '@typescript-eslint/no-unused-vars': [ + 'error', + { + argsIgnorePattern: '^_', + varsIgnorePattern: '^_', + caughtErrorsIgnorePattern: '^_', + ignoreRestSiblings: true, + }, + ], + + '@typescript-eslint/restrict-template-expressions': [ + 'error', + { + allowNumber: true, + allowBoolean: true, + }, + ], + + '@typescript-eslint/no-confusing-void-expression': [ + 'error', + { ignoreArrowShorthand: true }, + ], + + '@typescript-eslint/no-misused-promises': [ + 'error', + { checksVoidReturn: true }, + ], + '@typescript-eslint/prefer-readonly': 'error', + '@typescript-eslint/switch-exhaustiveness-check': 'error', + '@typescript-eslint/strict-boolean-expressions': 'error', + }, + }, + + { + files: [ + '**/*.{test,spec}.{js,jsx,ts,tsx}', + '**/__tests__/**/*.{js,jsx,ts,tsx}', + ], + rules: { + 'max-params': 'off', + }, + }, + + { + files: ['**/*.config.{js,mjs,cjs,ts,mts,cts}'], + languageOptions: { + globals: globals.node, + }, + rules: { + 'no-console': 'off', + }, + }, + + { + files: ['src/**/*.{ts,tsx}', 'tests/**/*.ts', '*.config.ts'], + languageOptions: { + globals: globals.node, + }, + plugins: { 'import-x': importX }, + settings: { + 'import-x/resolver-next': [createTypeScriptImportResolver()], + }, + rules: { + 'import-x/no-cycle': 'error', + 'import-x/no-self-import': 'error', + 'import-x/no-useless-path-segments': 'error', + 'import-x/no-extraneous-dependencies': [ + 'error', + { + devDependencies: ['tests/**', '**/*.test.ts', '*.config.ts'], + }, + ], + 'import-x/no-duplicates': 'error', + 'import-x/no-restricted-paths': [ + 'error', + { + zones: [ + { + target: './src/core', + from: [ + './src/features', + './src/integrations', + './src/web', + './src/discord', + './src/config', + './src/app.ts', + ], + message: + 'Core primitives cannot depend on features or their adapters.', + }, + { + target: './src/features', + from: [ + './src/config', + './src/app.ts', + './src/integrations/db', + './src/integrations/discord', + './src/web', + './src/discord', + './src/integrations/scheduler', + './src/integrations/logging', + './src/integrations/tmdb/catalog.ts', + ], + message: 'Feature logic uses contracts, never concrete adapters.', + }, + { + target: [ + './src/features', + './src/integrations', + './src/web', + './src/discord', + ], + from: ['./src/app.ts', './src/index.ts'], + message: + 'Features and adapters must not import the composition root.', + }, + ], + }, + ], + }, + }, + + { + files: ['src/**/*.{ts,tsx}'], + ignores: [ + 'src/app.ts', + 'src/integrations/discord/**', + 'src/discord/**', + '**/*.test.ts', + ], + rules: { + 'no-restricted-imports': ['error', { paths: [noDiscordImport] }], + }, + }, + + { + files: ['src/features/**/*.ts', 'src/core/**/*.ts'], + ignores: ['**/*.test.ts'], + rules: { + 'no-restricted-imports': [ + 'error', + { + paths: [noDiscordImport], + patterns: [ + { + group: [ + 'drizzle-orm', + 'drizzle-orm/*', + 'postgres', + 'pg-boss', + 'hono', + 'hono/*', + 'tmdb-ts', + 'pino', + ], + message: + 'Pure rules and operations use contracts, not platform libraries.', + }, + ], + }, + ], + }, + }, + + { + files: ['**/*.test.ts', 'tests/**/*.ts'], + rules: { + '@typescript-eslint/no-unsafe-type-assertion': 'off', + '@typescript-eslint/unbound-method': 'off', + '@typescript-eslint/require-await': 'off', + 'unicorn/no-useless-undefined': 'off', + 'unicorn/no-await-expression-member': 'off', + 'no-restricted-imports': 'off', + 'no-await-in-loop': 'off', + }, + }, + + { + files: [ + 'src/core/helpers/async.ts', + 'src/integrations/scheduler/runner.ts', + ], + rules: { 'no-await-in-loop': 'off' }, + }, + + prettier, + + { + files: typescriptFiles, + rules: { + curly: ['error', 'all'], + 'no-restricted-syntax': [ + 'error', + { + selector: + 'ImportDeclaration[source.value=/^\\.{1,2}\\/.*\\.js$/], ImportExpression[source.value=/^\\.{1,2}\\/.*\\.js$/]', + message: 'Import local modules without the .js extension.', + }, + ], + 'padding-line-between-statements': [ + 'error', + { blankLine: 'always', prev: '*', next: 'return' }, + { blankLine: 'always', prev: ['const', 'let'], next: '*' }, + { blankLine: 'any', prev: ['const', 'let'], next: ['const', 'let'] }, + { blankLine: 'always', prev: 'block-like', next: '*' }, + ], + }, + }, +); diff --git a/index.js b/index.js deleted file mode 100644 index 77b0a25..0000000 --- a/index.js +++ /dev/null @@ -1,111 +0,0 @@ -'use strict'; - -require("dotenv").config({ path: "./.env" }); - -const { Client, Events, GatewayIntentBits, EmbedBuilder } = require("discord.js"); - -const client = new Client({ - intents: [ - GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMembers, - GatewayIntentBits.MessageContent, - GatewayIntentBits.GuildMessageReactions - ], -}); - -const roleMap = { - '1️⃣': process.env.TARKVARA_ROLE_ID, - '2️⃣': process.env.HELPDESK_ROLE_ID, - '3️⃣': process.env.KULTUUR_ROLE_ID, - // '4️⃣': process.env.TURUNDUS_ROLE_ID -}; - -client.once(Events.ClientReady, async c => { - console.log(`Logged in as ${c.user.tag}`); - - const roleMessage = "Valige endale rolli:\n1 - Tarkvara\n2 - Helpdesk\n3 - Kultuur"; - await createMessageWithReactions(roleMessage); -}); - -async function createMessageWithReactions(roleMessage) { - const channel = await client.channels.fetch(process.env.ROLE_SELECTION_CHANNEL_ID); // make sure no one can send messages in this channel - const messages = await channel.messages.fetch({ limit: 5 }); // if more than 5 messages in channel, increase limit, - // if not planning to send any other messages in the channel - // can set limit to 1 - const existingMessage = messages.find(msg => msg.content === roleMessage); - - if (!existingMessage) { - const sentMessage = await channel.send(roleMessage); - - await sentMessage.react('1️⃣'); - await sentMessage.react('2️⃣'); - await sentMessage.react('3️⃣'); // kultuuritiim (turundus + üritused) - // await sentMessage.react('4️⃣'); // was turundus/uritused - - console.log("Message sent."); - } else { - console.log("Message already exists."); - } -} - -async function handleReaction(reaction, user, addRole) { - if (reaction.message.partial){ - await reaction.message.fetch(); - } - if (reaction.partial) { - await reaction.fetch(); - } - if (user.bot) { - return; - } - - const roleId = roleMap[reaction.emoji.name]; - - if (!roleId) { - return; - } - - const member = await reaction.message.guild.members.fetch(user.id); - if (addRole) { - await member.roles.add(roleId); - const role = await reaction.message.guild.roles.fetch(roleId); - console.log(`Assigned role ${role.name} to user ${user.tag}`); - } else { - await member.roles.remove(roleId); - const role = await reaction.message.guild.roles.fetch(roleId); - console.log(`Removed role ${role.name} from user ${user.tag}`); - } -} - -client.on(Events.MessageReactionAdd, async (reaction, user) => { - await handleReaction(reaction, user, true); -}); - -client.on(Events.MessageReactionRemove, async (reaction, user) => { - await handleReaction(reaction, user, false); -}); - -// Welcome message (not needer rn) - -// client.on(Events.GuildMemberAdd, async (member) => { -// try { -// const welcomeChannel = member.guild.channels.cache.get(process.env.WELCOME_CHANNEL_ID); - -// if (!welcomeChannel) { -// return console.error("Welcome channel not found!"); -// } - -// const highlight = `<@${member.user.id}>`; - -// const embed = new EmbedBuilder() -// .setTitle("Welcome to the Server!") -// .setDescription(`Hei <@${member.user.id}>! Valige endale sobiva rolli siin: <#${process.env.ROLE_SELECTION_CHANNEL_ID}>`) -// .setColor("#FFAC1C"); - -// await welcomeChannel.send({ content: highlight, embeds: [embed] }); -// } catch (error) { -// console.error("Error sending welcome message:", error); -// } -// }); - -client.login(process.env.DISCORD_TOKEN); diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index 8a1f302..0000000 --- a/package-lock.json +++ /dev/null @@ -1,321 +0,0 @@ -{ - "name": "lapbot", - "version": "1.0.0", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "lapbot", - "version": "1.0.0", - "license": "ISC", - "dependencies": { - "discord.js": "^14.18.0", - "dotenv": "^16.4.7" - } - }, - "node_modules/@discordjs/builders": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.10.1.tgz", - "integrity": "sha512-OWo1fY4ztL1/M/DUyRPShB4d/EzVfuUvPTRRHRIt/YxBrUYSz0a+JicD5F5zHFoNs2oTuWavxCOVFV1UljHTng==", - "license": "Apache-2.0", - "dependencies": { - "@discordjs/formatters": "^0.6.0", - "@discordjs/util": "^1.1.1", - "@sapphire/shapeshift": "^4.0.0", - "discord-api-types": "^0.37.119", - "fast-deep-equal": "^3.1.3", - "ts-mixer": "^6.0.4", - "tslib": "^2.6.3" - }, - "engines": { - "node": ">=16.11.0" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/@discordjs/collection": { - "version": "1.5.3", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz", - "integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==", - "license": "Apache-2.0", - "engines": { - "node": ">=16.11.0" - } - }, - "node_modules/@discordjs/formatters": { - "version": "0.6.0", - "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.6.0.tgz", - "integrity": "sha512-YIruKw4UILt/ivO4uISmrGq2GdMY6EkoTtD0oS0GvkJFRZbTSdPhzYiUILbJ/QslsvC9H9nTgGgnarnIl4jMfw==", - "license": "Apache-2.0", - "dependencies": { - "discord-api-types": "^0.37.114" - }, - "engines": { - "node": ">=16.11.0" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/@discordjs/rest": { - "version": "2.4.3", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.4.3.tgz", - "integrity": "sha512-+SO4RKvWsM+y8uFHgYQrcTl/3+cY02uQOH7/7bKbVZsTfrfpoE62o5p+mmV+s7FVhTX82/kQUGGbu4YlV60RtA==", - "license": "Apache-2.0", - "dependencies": { - "@discordjs/collection": "^2.1.1", - "@discordjs/util": "^1.1.1", - "@sapphire/async-queue": "^1.5.3", - "@sapphire/snowflake": "^3.5.3", - "@vladfrangu/async_event_emitter": "^2.4.6", - "discord-api-types": "^0.37.119", - "magic-bytes.js": "^1.10.0", - "tslib": "^2.6.3", - "undici": "6.21.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/@discordjs/rest/node_modules/@discordjs/collection": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", - "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", - "license": "Apache-2.0", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/@discordjs/util": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.1.tgz", - "integrity": "sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==", - "license": "Apache-2.0", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/@discordjs/ws": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.2.1.tgz", - "integrity": "sha512-PBvenhZG56a6tMWF/f4P6f4GxZKJTBG95n7aiGSPTnodmz4N5g60t79rSIAq7ywMbv8A4jFtexMruH+oe51aQQ==", - "license": "Apache-2.0", - "dependencies": { - "@discordjs/collection": "^2.1.0", - "@discordjs/rest": "^2.4.3", - "@discordjs/util": "^1.1.0", - "@sapphire/async-queue": "^1.5.2", - "@types/ws": "^8.5.10", - "@vladfrangu/async_event_emitter": "^2.2.4", - "discord-api-types": "^0.37.119", - "tslib": "^2.6.2", - "ws": "^8.17.0" - }, - "engines": { - "node": ">=16.11.0" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/@discordjs/ws/node_modules/@discordjs/collection": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", - "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", - "license": "Apache-2.0", - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/@sapphire/async-queue": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.5.tgz", - "integrity": "sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==", - "license": "MIT", - "engines": { - "node": ">=v14.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/@sapphire/shapeshift": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-4.0.0.tgz", - "integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==", - "license": "MIT", - "dependencies": { - "fast-deep-equal": "^3.1.3", - "lodash": "^4.17.21" - }, - "engines": { - "node": ">=v16" - } - }, - "node_modules/@sapphire/snowflake": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz", - "integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==", - "license": "MIT", - "engines": { - "node": ">=v14.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/@types/node": { - "version": "22.13.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.2.tgz", - "integrity": "sha512-Z+r8y3XL9ZpI2EY52YYygAFmo2/oWfNSj4BCpAXE2McAexDk8VcnBMGC9Djn9gTKt4d2T/hhXqmPzo4hfIXtTg==", - "license": "MIT", - "dependencies": { - "undici-types": "~6.20.0" - } - }, - "node_modules/@types/ws": { - "version": "8.5.14", - "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.14.tgz", - "integrity": "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw==", - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, - "node_modules/@vladfrangu/async_event_emitter": { - "version": "2.4.6", - "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.6.tgz", - "integrity": "sha512-RaI5qZo6D2CVS6sTHFKg1v5Ohq/+Bo2LZ5gzUEwZ/WkHhwtGTCB/sVLw8ijOkAUxasZ+WshN/Rzj4ywsABJ5ZA==", - "license": "MIT", - "engines": { - "node": ">=v14.0.0", - "npm": ">=7.0.0" - } - }, - "node_modules/discord-api-types": { - "version": "0.37.119", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.119.tgz", - "integrity": "sha512-WasbGFXEB+VQWXlo6IpW3oUv73Yuau1Ig4AZF/m13tXcTKnMpc/mHjpztIlz4+BM9FG9BHQkEXiPto3bKduQUg==", - "license": "MIT" - }, - "node_modules/discord.js": { - "version": "14.18.0", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.18.0.tgz", - "integrity": "sha512-SvU5kVUvwunQhN2/+0t55QW/1EHfB1lp0TtLZUSXVHDmyHTrdOj5LRKdR0zLcybaA15F+NtdWuWmGOX9lE+CAw==", - "license": "Apache-2.0", - "dependencies": { - "@discordjs/builders": "^1.10.1", - "@discordjs/collection": "1.5.3", - "@discordjs/formatters": "^0.6.0", - "@discordjs/rest": "^2.4.3", - "@discordjs/util": "^1.1.1", - "@discordjs/ws": "^1.2.1", - "@sapphire/snowflake": "3.5.3", - "discord-api-types": "^0.37.119", - "fast-deep-equal": "3.1.3", - "lodash.snakecase": "4.1.1", - "tslib": "^2.6.3", - "undici": "6.21.1" - }, - "engines": { - "node": ">=18" - }, - "funding": { - "url": "https://github.com/discordjs/discord.js?sponsor" - } - }, - "node_modules/dotenv": { - "version": "16.4.7", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.7.tgz", - "integrity": "sha512-47qPchRCykZC03FhkYAhrvwU4xDBFIj1QPqaarj6mdM/hgUzfPHcpkHJOn3mJAufFeeAxAzeGsr5X0M4k6fLZQ==", - "license": "BSD-2-Clause", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://dotenvx.com" - } - }, - "node_modules/fast-deep-equal": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", - "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "license": "MIT" - }, - "node_modules/lodash": { - "version": "4.17.21", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "license": "MIT" - }, - "node_modules/lodash.snakecase": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", - "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==", - "license": "MIT" - }, - "node_modules/magic-bytes.js": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.10.0.tgz", - "integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ==", - "license": "MIT" - }, - "node_modules/ts-mixer": { - "version": "6.0.4", - "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz", - "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==", - "license": "MIT" - }, - "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD" - }, - "node_modules/undici": { - "version": "6.21.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-6.21.1.tgz", - "integrity": "sha512-q/1rj5D0/zayJB2FraXdaWxbhWiNKDvu8naDT2dl1yTlvJp4BLtOcp2a5BvgGNQpYYJzau7tf1WgKv3b+7mqpQ==", - "license": "MIT", - "engines": { - "node": ">=18.17" - } - }, - "node_modules/undici-types": { - "version": "6.20.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", - "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", - "license": "MIT" - }, - "node_modules/ws": { - "version": "8.18.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", - "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", - "license": "MIT", - "engines": { - "node": ">=10.0.0" - }, - "peerDependencies": { - "bufferutil": "^4.0.1", - "utf-8-validate": ">=5.0.2" - }, - "peerDependenciesMeta": { - "bufferutil": { - "optional": true - }, - "utf-8-validate": { - "optional": true - } - } - } - } -} diff --git a/package.json b/package.json index d953f6e..048b8cd 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,67 @@ { "name": "lapbot", - "version": "1.0.0", - "main": "index.js", + "version": "2.0.0", + "private": true, + "description": "Lapikud community Discord bot", + "license": "ISC", + "type": "module", + "engines": { + "node": ">=24" + }, + "packageManager": "pnpm@11.22.0", "scripts": { - "test": "echo \"Error: no test specified\" && exit 1" + "dev": "tsx watch --env-file-if-exists=.env src/index.ts", + "build": "tsdown", + "start": "node --env-file-if-exists=.env --enable-source-maps dist/index.mjs", + "typecheck": "tsc --noEmit", + "lint": "eslint .", + "lint:fix": "eslint . --fix", + "format": "prettier . --write", + "format:check": "prettier . --check", + "test": "vitest run", + "test:db": "docker compose -f compose.test.yaml up -d --wait", + "test:integration": "node --env-file=.env.test ./node_modules/vitest/vitest.mjs run", + "db:generate": "drizzle-kit generate" }, - "keywords": [], - "author": "", - "license": "ISC", - "description": "", "dependencies": { - "discord.js": "^14.18.0", - "dotenv": "^16.4.7" + "@date-fns/tz": "^1.5.0", + "@googleapis/calendar": "^20.2.0", + "@hono/node-server": "^2.1.8", + "@hono/oauth-providers": "^0.9.1", + "better-sqlite3": "^13.2.0", + "chrono-node": "^2.10.3", + "date-fns": "^4.4.0", + "discord.js": "^14.28.1", + "drizzle-orm": "^0.45.4", + "hono": "^4.13.18", + "pg-boss": "^12.38.2", + "pino": "^10.4.0", + "postgres": "^3.4.9", + "tmdb-ts": "^2.3.0", + "zod": "^4.6.7" + }, + "devDependencies": { + "@eslint/js": "^10.0.1", + "@stylistic/eslint-plugin": "^6.0.0", + "@total-typescript/ts-reset": "^0.6.1", + "@types/better-sqlite3": "^9.6.0", + "@types/node": "^24.19.2", + "drizzle-kit": "^0.31.11", + "eslint": "^10.15.0", + "eslint-config-prettier": "^10.1.8", + "eslint-import-resolver-typescript": "^4.4.5", + "eslint-plugin-import-x": "^4.18.1", + "eslint-plugin-react": "^7.37.5", + "eslint-plugin-sonarjs": "^4.2.2", + "eslint-plugin-unicorn": "^79.0.0", + "globals": "^17.14.0", + "jiti": "^2.7.0", + "pino-pretty": "^13.2.0", + "prettier": "^3.10.1", + "tsdown": "^0.23.7", + "tsx": "^4.23.15", + "typescript": "~6.0.3", + "typescript-eslint": "^8.72.2", + "vitest": "^5.1.0" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml new file mode 100644 index 0000000..7070ea8 --- /dev/null +++ b/pnpm-lock.yaml @@ -0,0 +1,6015 @@ +lockfileVersion: '9.0' + +settings: + autoInstallPeers: true + excludeLinksFromLockfile: false + +importers: + + .: + dependencies: + '@date-fns/tz': + specifier: ^1.5.0 + version: 1.5.0 + '@googleapis/calendar': + specifier: ^20.2.0 + version: 20.2.0 + '@hono/node-server': + specifier: ^2.1.8 + version: 2.1.8(hono@4.13.18) + '@hono/oauth-providers': + specifier: ^0.9.1 + version: 0.9.1(hono@4.13.18) + better-sqlite3: + specifier: ^13.2.0 + version: 13.2.0 + chrono-node: + specifier: ^2.10.3 + version: 2.10.3 + date-fns: + specifier: ^4.4.0 + version: 4.4.0 + discord.js: + specifier: ^14.28.1 + version: 14.28.1 + drizzle-orm: + specifier: ^0.45.4 + version: 0.45.4(@opentelemetry/api@1.10.0)(@types/better-sqlite3@9.6.0)(better-sqlite3@13.2.0)(pg@8.23.1)(postgres@3.4.9) + hono: + specifier: ^4.13.18 + version: 4.13.18 + pg-boss: + specifier: ^12.38.2 + version: 12.38.2(@opentelemetry/api@1.10.0) + pino: + specifier: ^10.4.0 + version: 10.4.0 + postgres: + specifier: ^3.4.9 + version: 3.4.9 + tmdb-ts: + specifier: ^2.3.0 + version: 2.3.0 + zod: + specifier: ^4.6.7 + version: 4.6.7 + devDependencies: + '@eslint/js': + specifier: ^10.0.1 + version: 10.0.1(eslint@10.15.0(jiti@2.7.0)) + '@stylistic/eslint-plugin': + specifier: ^6.0.0 + version: 6.0.0(eslint@10.15.0(jiti@2.7.0)) + '@total-typescript/ts-reset': + specifier: ^0.6.1 + version: 0.6.1 + '@types/better-sqlite3': + specifier: ^9.6.0 + version: 9.6.0 + '@types/node': + specifier: ^24.19.2 + version: 24.19.2 + drizzle-kit: + specifier: ^0.31.11 + version: 0.31.11 + eslint: + specifier: ^10.15.0 + version: 10.15.0(jiti@2.7.0) + eslint-config-prettier: + specifier: ^10.1.8 + version: 10.1.8(eslint@10.15.0(jiti@2.7.0)) + eslint-import-resolver-typescript: + specifier: ^4.4.5 + version: 4.4.5(eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.15.0(jiti@2.7.0)))(eslint@10.15.0(jiti@2.7.0)) + eslint-plugin-import-x: + specifier: ^4.18.1 + version: 4.18.1(@typescript-eslint/utils@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.15.0(jiti@2.7.0)) + eslint-plugin-react: + specifier: ^7.37.5 + version: 7.37.5(eslint@10.15.0(jiti@2.7.0)) + eslint-plugin-sonarjs: + specifier: ^4.2.2 + version: 4.2.2(eslint@10.15.0(jiti@2.7.0)) + eslint-plugin-unicorn: + specifier: ^79.0.0 + version: 79.0.0(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + globals: + specifier: ^17.14.0 + version: 17.14.0 + jiti: + specifier: ^2.7.0 + version: 2.7.0 + pino-pretty: + specifier: ^13.2.0 + version: 13.2.0 + prettier: + specifier: ^3.10.1 + version: 3.10.1 + tsdown: + specifier: ^0.23.7 + version: 0.23.7(tsx@4.23.15)(typescript@6.0.3) + tsx: + specifier: ^4.23.15 + version: 4.23.15 + typescript: + specifier: ~6.0.3 + version: 6.0.3 + typescript-eslint: + specifier: ^8.72.2 + version: 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + vitest: + specifier: ^5.1.0 + version: 5.1.0(@opentelemetry/api@1.10.0)(@types/node@24.19.2)(vite@8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)) + +packages: + + '@cacheable/memory@2.2.0': + resolution: {integrity: sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==} + + '@cacheable/utils@2.5.0': + resolution: {integrity: sha512-buipgOVDkkPXNR5+xBpDw7Zk2n1EvU7qBJCNUcL7rhQ//kfpOXPAvQ511Os0vpLYJ1pZnvudNytkQt2hst3wqA==} + + '@date-fns/tz@1.5.0': + resolution: {integrity: sha512-lwYN/vDPeNRULcepoE/LO2Pgx+7/RV+S9ARfbc9lr2DtGkOD7pAiruHvbR1RX3Qyf6ja47EWJDMsNK5vK08DJg==} + + '@discordjs/builders@1.15.0': + resolution: {integrity: sha512-AifaDWTw6WUDhKBn8E6mwwoyjDAcfsYq+ZE0nKSu1dMH1NLR22D3hGkNx+ctEv8NqHEHdAZnP5REteHDmn1lkA==} + engines: {node: '>=16.11.0'} + + '@discordjs/collection@1.5.3': + resolution: {integrity: sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==} + engines: {node: '>=16.11.0'} + + '@discordjs/collection@2.1.1': + resolution: {integrity: sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==} + engines: {node: '>=18'} + + '@discordjs/formatters@0.6.2': + resolution: {integrity: sha512-y4UPwWhH6vChKRkGdMB4odasUbHOUwy7KL+OVwF86PvT6QVOwElx+TiI1/6kcmcEe+g5YRXJFiXSXUdabqZOvQ==} + engines: {node: '>=16.11.0'} + + '@discordjs/rest@2.6.3': + resolution: {integrity: sha512-wvOylxNYJkwKjctS/Mn5GP1w9r3/rzyH+ThD1JlAca6zEdlHs8QWBBUQJpU5Q+W6DoIj/Ljh1IPlZs7hTU+UAg==} + engines: {node: '>=18'} + + '@discordjs/util@1.2.0': + resolution: {integrity: sha512-3LKP7F2+atl9vJFhaBjn4nOaSWahZ/yWjOvA4e5pnXkt2qyXRCHLxoBQy81GFtLGCq7K9lPm9R517M1U+/90Qg==} + engines: {node: '>=18'} + + '@discordjs/ws@1.2.3': + resolution: {integrity: sha512-wPlQDxEmlDg5IxhJPuxXr3Vy9AjYq5xCvFWGJyD7w7Np8ZGu+Mc+97LCoEc/+AYCo2IDpKioiH0/c/mj5ZR9Uw==} + engines: {node: '>=16.11.0'} + + '@drizzle-team/brocli@0.10.2': + resolution: {integrity: sha512-z33Il7l5dKjUgGULTqBsQBQwckHh5AbIuxhdsIxDDiZAzBOrZO6q9ogcWC65kU382AfynTfgNumVcNIjuIua6w==} + + '@emnapi/core@2.0.0-beta.2': + resolution: {integrity: sha512-MzCVoWtcg4Pm2B3je5mMvYMvj3MmBKw+fU7vbsJc9/iT8ip6/eYIHo/Dsm/mr+wsHB6SEyJDuxB09Yy6r/8+4A==} + + '@emnapi/runtime@2.0.0-beta.2': + resolution: {integrity: sha512-JcrSPzPvZuNZvJqPTF9Fw25LbOJ8avzFVlaf2grmH4Cku0oGP47tRgqPZadcfj3YoZMHkFVnCYFbQM8I+i5QEw==} + + '@emnapi/wasi-threads@2.2.0': + resolution: {integrity: sha512-JP7OYH38Q7+pyTAe14raZHLQIK7BDKbdwji+Xi3pcd/6QkJYQH3SX4wu6EplGrGJWRepoNzedfm0G3B9Z4e9Rw==} + + '@esbuild-kit/core-utils@3.3.2': + resolution: {integrity: sha512-sPRAnw9CdSsRmEtnsl2WXWdyquogVpB3yZ3dgwJfe8zrOzTsV7cJvmwrKVa+0ma5BoiGJ+BoqkMvawbayKUsqQ==} + deprecated: 'Merged into tsx: https://tsx.hirok.io' + + '@esbuild-kit/esm-loader@2.6.5': + resolution: {integrity: sha512-FxEMIkJKnodyA1OaCUoEvbYRkoZlLZ4d/eXFu9Fh8CbBBgP5EmZxrfTRyN0qpXZ4vOvqnE5YdRdcrmUUXuU+dA==} + deprecated: 'Merged into tsx: https://tsx.hirok.io' + + '@esbuild/aix-ppc64@0.25.12': + resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/aix-ppc64@0.28.2': + resolution: {integrity: sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + + '@esbuild/android-arm64@0.18.20': + resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm64@0.25.12': + resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm64@0.28.2': + resolution: {integrity: sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + + '@esbuild/android-arm@0.18.20': + resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + + '@esbuild/android-arm@0.25.12': + resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-arm@0.28.2': + resolution: {integrity: sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + + '@esbuild/android-x64@0.18.20': + resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + + '@esbuild/android-x64@0.25.12': + resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/android-x64@0.28.2': + resolution: {integrity: sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + + '@esbuild/darwin-arm64@0.18.20': + resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-arm64@0.25.12': + resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-arm64@0.28.2': + resolution: {integrity: sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + + '@esbuild/darwin-x64@0.18.20': + resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + + '@esbuild/darwin-x64@0.25.12': + resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/darwin-x64@0.28.2': + resolution: {integrity: sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + + '@esbuild/freebsd-arm64@0.18.20': + resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-arm64@0.25.12': + resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-arm64@0.28.2': + resolution: {integrity: sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.18.20': + resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.25.12': + resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/freebsd-x64@0.28.2': + resolution: {integrity: sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + + '@esbuild/linux-arm64@0.18.20': + resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm64@0.25.12': + resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm64@0.28.2': + resolution: {integrity: sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + + '@esbuild/linux-arm@0.18.20': + resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-arm@0.25.12': + resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-arm@0.28.2': + resolution: {integrity: sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + + '@esbuild/linux-ia32@0.18.20': + resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-ia32@0.25.12': + resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-ia32@0.28.2': + resolution: {integrity: sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + + '@esbuild/linux-loong64@0.18.20': + resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-loong64@0.25.12': + resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-loong64@0.28.2': + resolution: {integrity: sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + + '@esbuild/linux-mips64el@0.18.20': + resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-mips64el@0.25.12': + resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-mips64el@0.28.2': + resolution: {integrity: sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + + '@esbuild/linux-ppc64@0.18.20': + resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-ppc64@0.25.12': + resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-ppc64@0.28.2': + resolution: {integrity: sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + + '@esbuild/linux-riscv64@0.18.20': + resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-riscv64@0.25.12': + resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-riscv64@0.28.2': + resolution: {integrity: sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + + '@esbuild/linux-s390x@0.18.20': + resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-s390x@0.25.12': + resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-s390x@0.28.2': + resolution: {integrity: sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + + '@esbuild/linux-x64@0.18.20': + resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + + '@esbuild/linux-x64@0.25.12': + resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/linux-x64@0.28.2': + resolution: {integrity: sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.25.12': + resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-arm64@0.28.2': + resolution: {integrity: sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.18.20': + resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.25.12': + resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/netbsd-x64@0.28.2': + resolution: {integrity: sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.25.12': + resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-arm64@0.28.2': + resolution: {integrity: sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.18.20': + resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.25.12': + resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openbsd-x64@0.28.2': + resolution: {integrity: sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.25.12': + resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/openharmony-arm64@0.28.2': + resolution: {integrity: sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + + '@esbuild/sunos-x64@0.18.20': + resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + + '@esbuild/sunos-x64@0.25.12': + resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/sunos-x64@0.28.2': + resolution: {integrity: sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + + '@esbuild/win32-arm64@0.18.20': + resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-arm64@0.25.12': + resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-arm64@0.28.2': + resolution: {integrity: sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + + '@esbuild/win32-ia32@0.18.20': + resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-ia32@0.25.12': + resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-ia32@0.28.2': + resolution: {integrity: sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + + '@esbuild/win32-x64@0.18.20': + resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + + '@esbuild/win32-x64@0.25.12': + resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@esbuild/win32-x64@0.28.2': + resolution: {integrity: sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + + '@eslint-community/eslint-utils@4.10.1': + resolution: {integrity: sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + peerDependencies: + eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 + + '@eslint-community/regexpp@4.12.3': + resolution: {integrity: sha512-R76UKbvsqI68DJJVTVyqFKqU98CN4+B+acxNfEA2IFarSzP0SjtKf/3+fFiXzTyv5Fj3PxLkGHe2wnVWWMxobQ==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + + '@eslint/config-array@0.23.6': + resolution: {integrity: sha512-WrTH7nioI9QPY4NZGnsywmecswJdgeq4BCM76qok9VgjTO29ZgUzUvcuJLVPYVQM4uDbaPBU0M33R9DIxI8X3w==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/config-helpers@0.7.0': + resolution: {integrity: sha512-DObd/KKUsU+FaFv4PLxSRenpXfQWmPXXP3pPZ6/K1PCrMu2vQpMDMuQe/BqYeoLcz8ro0bVDF1RxOJgfVEdhUw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/core@1.2.1': + resolution: {integrity: sha512-MwcE1P+AZ4C6DWlpin/OmOA54mmIZ/+xZuJiQd4SyB29oAJjN30UW9wkKNptW2ctp4cEsvhlLY/CsQ1uoHDloQ==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/css-tree@4.1.2': + resolution: {integrity: sha512-rVcxLmwSkEL3aWS3vAgsTRrQHoYE1b0XcgDtKHDJ92XOkyUpcbS/g0tUJKhvCtlEhYzgKBWsgDd+Z/aPhd166w==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/js@10.0.1': + resolution: {integrity: sha512-zeR9k5pd4gxjZ0abRoIaxdc7I3nDktoXZk2qOv9gCNWx3mVwEn32VRhyLaRsDiJjTs0xq/T8mfPtyuXu7GWBcA==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + peerDependencies: + eslint: ^10.0.0 + peerDependenciesMeta: + eslint: + optional: true + + '@eslint/object-schema@3.0.5': + resolution: {integrity: sha512-vqTaUEgxzm+YDSdElad6PiRoX4t8VGDjCtt05zn4nU810UIx/uNEV7/lZJ6KwFThKZOzOxzXy48da+No7HZaMw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@eslint/plugin-kit@0.7.3': + resolution: {integrity: sha512-IkO+/KEUvwbVpiURZg+P7zF74z5Jxe0UgJxVni+RtoHQ6IZieXaO02kmadomap/q+l6bc/jdPGGqTjhuZnuz1Q==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + '@googleapis/calendar@20.2.0': + resolution: {integrity: sha512-w5z+D0z3RlikxjT311ykEcWQpPFN5CJPbA8QkISGIPfA8D2tbyFoFYLBwXZQwq8u+twZdpp1FnboSiLY/bjLcA==} + engines: {node: '>=22.0.0'} + + '@hono/node-server@2.1.8': + resolution: {integrity: sha512-jdf7FHh6A1lzjpHHQUgxsg2GeER2vMetnAOfeActzcoli6jamlK+NAwL6Dsr5Fl3BS3tYUQzCdtZjU8Qxv7bEA==} + engines: {node: '>=20'} + peerDependencies: + hono: ^4 || ^5.0.0-0 + + '@hono/oauth-providers@0.9.1': + resolution: {integrity: sha512-dpnw9xJbYMyHsmlv+jYHB6jk4BY2FlwiRNVMiM7h0y19eprq11+7XaSBrBoTApHgY7sB0XpilH9VEVuY52aqnw==} + engines: {node: '>=18.4.0'} + peerDependencies: + hono: '>=3.0.0' + + '@humanfs/core@0.19.2': + resolution: {integrity: sha512-UhXNm+CFMWcbChXywFwkmhqjs3PRCmcSa/hfBgLIb7oQ5HNb1wS0icWsGtSAUNgefHeI+eBrA8I1fxmbHsGdvA==} + engines: {node: '>=18.18.0'} + + '@humanfs/node@0.16.8': + resolution: {integrity: sha512-gE1eQNZ3R++kTzFUpdGlpmy8kDZD/MLyHqDwqjkVQI0JMdI1D51sy1H958PNXYkM2rAac7e5/CnIKZrHtPh3BQ==} + engines: {node: '>=18.18.0'} + + '@humanfs/types@0.15.0': + resolution: {integrity: sha512-ZZ1w0aoQkwuUuC7Yf+7sdeaNfqQiiLcSRbfI08oAxqLtpXQr9AIVX7Ay7HLDuiLYAaFPu8oBYNq/QIi9URHJ3Q==} + engines: {node: '>=18.18.0'} + + '@humanwhocodes/module-importer@1.0.1': + resolution: {integrity: sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==} + engines: {node: '>=12.22'} + + '@humanwhocodes/retry@0.4.3': + resolution: {integrity: sha512-bV0Tgo9K4hfPCek+aMAn81RppFKv2ySDQeMoSZuvTASywNTnVJCArCZE2FWqpvIatKu7VMRLWlR1EazvVhDyhQ==} + engines: {node: '>=18.18'} + + '@isaacs/nonrecursive-glob-match@1.1.0': + resolution: {integrity: sha512-GPm/Dbvk5RLmhRnxXIa7nTpK0xtl4E0wj0MslsuNiJ1FIROU+2+9lgUC/dgF7Ey4QCWhfEsgxilMRMCdHPfDfw==} + + '@jridgewell/resolve-uri@3.1.3': + resolution: {integrity: sha512-lhTtjtoEArWBjismtfS761S9Hlyn+nIZqOZVYoZ1Xn82PMNMVnk+jj/NhC4fAXGTs7ydONcJiR5vyQBTMDu27g==} + engines: {node: '>=6.0.0'} + + '@jridgewell/sourcemap-codec@1.6.0': + resolution: {integrity: sha512-T7jf+5zgsZHwNJ4lvQ7/aezbyk0nNX+zJVWpmHA7VYsEx7a7qr5Rg5IbtJFqkgze5Y2sruq1RUY8Q837Od7iFw==} + + '@jridgewell/trace-mapping@0.3.31': + resolution: {integrity: sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==} + + '@keyv/bigmap@1.3.1': + resolution: {integrity: sha512-WbzE9sdmQtKy8vrNPa9BRnwZh5UF4s1KTmSK0KUVLo3eff5BlQNNWDnFOouNpKfPKDnms9xynJjsMYjMaT/aFQ==} + engines: {node: '>= 18'} + peerDependencies: + keyv: ^5.6.0 + + '@keyv/serialize@1.1.1': + resolution: {integrity: sha512-dXn3FZhPv0US+7dtJsIi2R+c7qWYiReoEh5zUntWCf4oSpMNib8FDhSoed6m3QyZdx5hK7iLFkYk3rNxwt8vTA==} + + '@napi-rs/wasm-runtime@1.2.6': + resolution: {integrity: sha512-mRyDmEw9/fCDXCGfL1sbgIw/GUK0PVxRW4YwgPN61F3LQ+fSyoBFarJVzgGyhF6kRzEQZ0FejDqm4WLXSeqQmw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + peerDependencies: + '@emnapi/core': ^1.7.1 || 2.0.0-beta.2 + '@emnapi/runtime': ^1.7.1 || 2.0.0-beta.2 + + '@opentelemetry/api@1.10.0': + resolution: {integrity: sha512-lMkyes8iHrG+mk6WH7X70MdCLI2RS0FwNBY1PyQ8UemaijE2m5mv5A0Niy3HtbYTFrgkUEQjFMXmSAk2hQDuPQ==} + engines: {node: '>=8.0.0'} + + '@oxc-project/types@0.156.0': + resolution: {integrity: sha512-1Duyg48TdJNdyhEB8Xn1L36bT9Pv6GUtlKjHxOys8xkaF/rQq3XJE+bAurSK/AgIz5mGFsb77cn9Pb20+WCScw==} + + '@oxc-project/types@0.158.0': + resolution: {integrity: sha512-xZ66qA4WmLbTLlxH3mqMd8f9UKbaOzOT0ATwFf4DH/14pMgpUrtqtjyYzOQmgfl2a0iRAAMbQ9G1th/67jRzGw==} + + '@pinojs/redact@0.4.0': + resolution: {integrity: sha512-k2ENnmBugE/rzQfEcdWHcCY+/FM3VLzH9cYEsbdsoqrvzAKRhUZeRNhAZvB8OitQJ1TBed3yqWtdjzS6wJKBwg==} + + '@quansync/fs@1.1.0': + resolution: {integrity: sha512-qAPG/t3HqML1TlN7sY/pTbEjzFVAKsMjNNMGheyDosro+kT4iw2KCUoHcVdmliwWjorm4elZbgNQyU2eD97eDg==} + + '@rolldown/binding-android-arm-eabi@1.2.19': + resolution: {integrity: sha512-e+Ebe0WT+9tbXmNKPIiC8YrWAHYwug3m6i4p3rZGGulfZri1jtI4HslT+OZnFf/OIHowWF71DTlHwXBP2SiA7A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm-eabi@1.3.2': + resolution: {integrity: sha512-kqR2xcygEx3WwDY69LsKeyf7SVmx4yzMtKZRknyaHieVJdRvvnAM97L0Gq6tUFc9T2YXcW/Ghij2+Um6He0LTw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [android] + + '@rolldown/binding-android-arm64@1.2.19': + resolution: {integrity: sha512-hOombrTJ+szt2ciEzS7oCA78lMPBgF5UMQWCJIyNfnrI7GLl8HYoFqCnpL2gcPOaXMqryGCU5ExdQKyDDcC+yA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-android-arm64@1.3.2': + resolution: {integrity: sha512-gXM4GAAvvIZA7qUuSCQS+Zz91H2fagKa5MNppUdjzysJ8LXMWm9D/gQj4nfOKo6okquDQ5pkjsuo2SUMXNW0Rw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [android] + + '@rolldown/binding-darwin-arm64@1.2.19': + resolution: {integrity: sha512-XoMA2pwCKGTQzUjPgtRwkedH4WmXhdIPKT6l6oOxd1PUbNodGI6DcBekgN7EC//+x3pfBYX/qL1gNmZAqivw5g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-arm64@1.3.2': + resolution: {integrity: sha512-OBs5hp3W+LwMEUmDMMMnu08ncG0t6DDgnFU+6TAucKtAfNgerYLZSr2jtREKb/JuPQ1J7bJnWIgKKkxvjuAw1g==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.2.19': + resolution: {integrity: sha512-zo8EsSSwMZCY/e+fRnGaX02YGgvJD0yvhNi/9hpGPA2MJ9ZF8dPCw75UGfpI6OpQ/myR/dIYmogRvqiZD0TrXg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-darwin-x64@1.3.2': + resolution: {integrity: sha512-X0VGYd4v/gdjfa/IP6uHuMhofPoUDYvK/byk3bC0jQ1pKKgt6RZ4B4puMqP0AHkjmIHAsxA471mM6AxZ39IaTA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [darwin] + + '@rolldown/binding-freebsd-x64@1.2.19': + resolution: {integrity: sha512-O8ISAOfI1nj7AuBPd30FSF47z7f7lzlk5poQVGgiikvQuGEBFYvW8ki+UEnT+YJPnNGjQzn304klt4O9FUE7mA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-freebsd-x64@1.3.2': + resolution: {integrity: sha512-mr04K4cp9J/fj9fknrX8e4QvI/V48Sp+4v64PoLwhoirIH8b8L8EBrF/0bTjV1It2IL91hoNG13GblnWLglkxA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [freebsd] + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + resolution: {integrity: sha512-/lYCba5NO0yq4S0jGMH8QTBtkvQxoXjoQWzF5BcWp9MjB9jxVRD1GQDNofkVjcOj30DWyhLIN/4Oe60JKzaONw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm-gnueabihf@1.3.2': + resolution: {integrity: sha512-VgWy02HU9Tiy6tU8U+kF3Fd4TQwTNdIBvs2MlgViP1ksMtAnQQTIPAj0ZsJzIQXKIOugqQSpqxQgELJ3fkuL5w==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm] + os: [linux] + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + resolution: {integrity: sha512-pm/apFMBnSbFb3O6nG5pHO1iqHhZrjGDFEjSm+ot9J17XXPvH9L90y5h+jgfHCE+Qdlsvy8qKEcU4VKxgjD+vA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-gnu@1.3.2': + resolution: {integrity: sha512-0wloJFYqV844gv6boiERbHpErxbxHbmlgnMX5VxP1Ux+DLBqGrUOn0cIpBmCZEcTITes3QUelxya4u8c9ziQvQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-arm64-musl@1.2.19': + resolution: {integrity: sha512-K1SmQp3FFichn8oqrNIwvFoZ5wcvjC7goBzpaMNvLf9FZc+QB/QvLmnpJZgAAGHiD980tP8FZZnXk2K94rvlxg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-arm64-musl@1.3.2': + resolution: {integrity: sha512-Kys8wgFQy8H8vua0MNpC0akMBFoNO8455RHk2yycBM0iayMIAtVAL6xmV9TWAkehFgrrlImTL2fZdX5LXfYtAA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + resolution: {integrity: sha512-I0xwD57jP/3A7+5UPZin2w8Y7XHEmEM5zqpYZOcQ45MlNW6tUJUziymV3yRr7rL4vwyfEcRsRksC4a7Kc08p5Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-ppc64-gnu@1.3.2': + resolution: {integrity: sha512-L8eej7+/StRxUHHOPsOVl7Fzx/3tumuGB4hGQZKT73xRI16KZhaSJr0gi3C3WBjNRxeJRKKps2UD4lQukP+oBw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + resolution: {integrity: sha512-BrtEHT24SNXj9HiXqy+s/kXiSiQGt6EKCPUlRirAoIioVxKGnbXBUEkbZASAei7iZJB0/Ynm+0JP00Ipx7AnSw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-s390x-gnu@1.3.2': + resolution: {integrity: sha512-MV5CEb/nV8neQOj7l6945q1vy62HXtWO8zPDvfySPusoUzdBoLoJ/DfXXwaYThGTXZCniF+5bCf253WTPPK7Yw==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.2.19': + resolution: {integrity: sha512-rm75/9DkHKeU2WnA8w4X94WGYgLlDCFCfkQC+4bguVJmC/jvDRv2B+2wLOYhyE0fVuv7//Ckk39OoOufyCu76Q==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-gnu@1.3.2': + resolution: {integrity: sha512-3qssvvVvkwQookZ1/1avlKWc5orAR85vgKdzDd5noZS8nnHiI/ejOAEt0xfNYvtBBF7/DZmP8dANWkRBJVOBCA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@rolldown/binding-linux-x64-musl@1.2.19': + resolution: {integrity: sha512-irh/4+iYFM4GAzpluDErgjz89bj6NDtqqMAG/6O1LG38Ed3NpyebzCpcVNkFW8uhy+/3/BocUvnXDR33CXWe9A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-linux-x64-musl@1.3.2': + resolution: {integrity: sha512-rJqoFTm/bCZFKKgaT4NzWn/TuJkFDToZ/rzYFnYVBL28jH1nIfg6snx2mDri30nal9H+wcYfKpoPR9jrMQgQQg==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [linux] + libc: [musl] + + '@rolldown/binding-openharmony-arm64@1.2.19': + resolution: {integrity: sha512-+KWTWNoPt+CfSq94CiceWu3yPE+QzkaG+phPyz9G60tmZLwfQkcA4AeksafzvJAw4pvg1mcd5a1TkUqVv0s4JA==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-openharmony-arm64@1.3.2': + resolution: {integrity: sha512-ozdbCjHfh0N//wJNExjJlSlcDaeIKo8k1ktzkLUyESr2Gu/Qw7nBYxKe3jgtoaxda570vg10WdYosre82263hQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [openharmony] + + '@rolldown/binding-wasm32-wasi@1.2.19': + resolution: {integrity: sha512-7EH+skOsl5qpWnK0vzamgJFhOv1cwxQpsxm8tI883K9fur5c27p8q87fzEO6BbBPabA2/+s/zR63/pLc137iOg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + + '@rolldown/binding-wasm32-wasi@1.3.2': + resolution: {integrity: sha512-p5VA6Vk/2cXZPVWf+dDbuE0dkhrcoAo6pISTJmzUnsSdQqNJdusyR8lZgHku095+r27zrYISNLZnJoqrcePW0A==} + engines: {node: ^20.19.0 || ^22.13.0 || >=23.5.0} + cpu: [wasm32] + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + resolution: {integrity: sha512-3Q1Yg1Q7tEvBWoZf5rFvG/GKZQPgwfru+p4wBajDfJFBs0SHCpL++dfTjW9gyAKd1T7ZpIYvdaUax7Pa/IhFVQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-arm64-msvc@1.3.2': + resolution: {integrity: sha512-XDb2U14Orf4r76SwzvJ7avePL00w4gHBmi1Ig4B/itYFEUTmYMNDHVU0dcYuBa0LgNBqyREoJOrQKxQlyYJA7A==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [arm64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.2.19': + resolution: {integrity: sha512-y/sqRRc6d7hECzOFc5n3LSeqctmIp9mMjY1Kq4s14uLPd/LZ4z7i1zrW6fMtp2mPeuQIC4e6ULMcwQzMomqQag==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/binding-win32-x64-msvc@1.3.2': + resolution: {integrity: sha512-lEsKzKJqIUDZVCBhS4lkZuyQUhV1oRg5UHkI72qlOAqJn7qEXcoVdTridFS7PHNWdZknBl95EAF/4P1Xv0K1eQ==} + engines: {node: ^20.19.0 || >=22.12.0} + cpu: [x64] + os: [win32] + + '@rolldown/pluginutils@1.1.1': + resolution: {integrity: sha512-glFIJDvLNDtJhT9qrMFWLPbvS+skxgt4L0K8Ei2YtnhPysAJnsI7nyxSJxKj4ADeKX0OLjC4ntRkwpLOoS3rwA==} + + '@sapphire/async-queue@1.5.5': + resolution: {integrity: sha512-cvGzxbba6sav2zZkH8GPf2oGk9yYoD5qrNWdu9fRehifgnFZJMV+nuy2nON2roRO4yQQ+v7MK/Pktl/HgfsUXg==} + engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + + '@sapphire/shapeshift@4.0.0': + resolution: {integrity: sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==} + engines: {node: '>=v16'} + + '@sapphire/snowflake@3.5.5': + resolution: {integrity: sha512-xzvBr1Q1c4lCe7i6sRnrofxeO1QTP/LKQ6A6qy0iB4x5yfiSfARMEQEghojzTNALDTcv8En04qYNIco9/K9eZQ==} + engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + + '@sonarsource/analyzer-commons-configurations@2.31.0-5284': + resolution: {integrity: sha512-ruk3blMs9BE9RNSp9LPpWZAIjxJmq4Cp00E3cELIHz7Kym3WxdWGRlKOMYLRQ5tJg/de7jN5AtEElY3bGIfTcw==} + + '@stylistic/eslint-plugin@6.0.0': + resolution: {integrity: sha512-phICSey4OqR8nkSwmoeXsl9EBzv30Zqbge4jrK3CU02GhjTgZ+y5qhTTg92EDK5j7JhX2xzp4VvH+YYUknQ8/Q==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + peerDependencies: + eslint: ^9.0.0 || ^10.0.0 + oxlint: ^1.55.0 + peerDependenciesMeta: + eslint: + optional: true + oxlint: + optional: true + + '@total-typescript/ts-reset@0.6.1': + resolution: {integrity: sha512-cka47fVSo6lfQDIATYqb/vO1nvFfbPw7uWLayIXIhGETj0wcOOlrlkobOMDNQOFr9QOafegUPq13V2+6vtD7yg==} + + '@tybys/wasm-util@0.10.4': + resolution: {integrity: sha512-W3c4gRigFS0T/Ma4qIYF3GDAc5AQdHb1yL5znJT1Zv1YaD9Kitx656wBjvr19qbiosmZT8lWDM5BEMynUqX65A==} + + '@types/better-sqlite3@9.6.0': + resolution: {integrity: sha512-ZEEwBSgMu7GYJOynoagg5X9JbxfL6dTJDsgViJIqh67jV44kyOr9RXfmFjLK5rzC4MWssP06t9hu/JwGDnUbCg==} + + '@types/chai@5.2.3': + resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + + '@types/debug@4.1.13': + resolution: {integrity: sha512-KSVgmQmzMwPlmtljOomayoR89W4FynCAi3E8PPs7vmDVPe84hT+vGPKkJfThkmXs0x0jAaa9U8uW8bbfyS2fWw==} + + '@types/deep-eql@4.0.2': + resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} + + '@types/esrecurse@4.3.1': + resolution: {integrity: sha512-xJBAbDifo5hpffDBuHl0Y8ywswbiAp/Wi7Y/GtAgSlZyIABppyurxVueOPE8LUQOxdlgi6Zqce7uoEpqNTeiUw==} + + '@types/estree@1.0.10': + resolution: {integrity: sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==} + + '@types/json-schema@7.0.15': + resolution: {integrity: sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==} + + '@types/ms@2.1.0': + resolution: {integrity: sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==} + + '@types/node@24.19.2': + resolution: {integrity: sha512-93d49wCWJkCyN87MxLpNN6KXPCwFw7bVUg79mGUV1OS40JGWwVCr8n61DXCSqz7CV6/VfPkb7xec7uP2M+QHWQ==} + + '@types/ws@8.18.2': + resolution: {integrity: sha512-67MQl+fpWKVTT1NYdnmo3U4sc/xPo/zQBncVnI74qmQa0z/b+1g6iYqNmGCPbxO+zz2aklb08a0oHfegiVd0/w==} + + '@typescript-eslint/eslint-plugin@8.72.2': + resolution: {integrity: sha512-222PKFXKihmFpi/pS5njoBgdAqsPhj2/GBmFbrNw8Tq8gEG9Sv+kSlKFy4u2q+mJv9ZzJgM2Gkv/bUzRZwZw5g==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/parser': ^8.72.2 + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/parser@8.72.2': + resolution: {integrity: sha512-llP+T1YuJOLlxEciP6OyQGtz5SMxyn+9LA2BvZw5RmToGVa1y4beEDVQL6Gje7T5WFYh19WREjDCN9Ev4gm5AA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/project-service@8.72.2': + resolution: {integrity: sha512-6y5dLTZdHhI8Eh3yIQ/bfQhRKwn5e+TpJj64o18Cngc0iW/BCrVvrr6zGYqXPnYH31u6YXAYiFh0+qxX5mybJw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/scope-manager@8.72.2': + resolution: {integrity: sha512-iIoMJ6/8c1/QpFNyFjU0d1YzPco4MsZjQw0k3V+vfzNWAFmUmvhlyMoYEoYYDQZXc+J6Gi1X5XcxlzW2taIIGQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/tsconfig-utils@8.72.2': + resolution: {integrity: sha512-+h3iCgZXuTNtoLXcnnjP12ZUHLMqoUcIHPfQrFEXTUqvb9dF8QK9b5nv5VtSo5fLkdHuks8ehbTzZj3rImAm9w==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/type-utils@8.72.2': + resolution: {integrity: sha512-STfkR38qIdhfkLpgtXnUjAzsNy4xouqiBO0lrVc/Wpk9Kem5/aHXUx1J8dGC16zpdYN1+yc2ILQ28er1kXX7ag==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/types@8.72.2': + resolution: {integrity: sha512-Xfn37OLZx03+PCU7qWx9DTv2FCRh1E6fk2+wONeNY15HXIwtcwuveaSwVpGAUptkNmPQegRxW5JyRel9T7wrog==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@typescript-eslint/typescript-estree@8.72.2': + resolution: {integrity: sha512-pQEGqIK/cqEvKivVWaFLYpe7XYejFxfuAOi4mu1oAWFvIo36aRHI9esRFTUxcIy/z8N482RJyH+LpZB0ZIU7Ow==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/utils@8.72.2': + resolution: {integrity: sha512-hv3eRYbpPbbpezuax1EfGrzpa3C4ySgNZkPUkLOWOAjU8HsOKowEDAr8C7nsNl1C+SBSKDpvno6VKHnlhvp9iA==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + '@typescript-eslint/visitor-keys@8.72.2': + resolution: {integrity: sha512-NAGrjn0Pitjqzq/GkgMC4kBYm233PQ8GffyQ9+kTA3AlNQYEzOf25EIM02BAHZv5FRJSpHpJk+OGUxVkOB93GQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + '@unrs/resolver-binding-android-arm-eabi@1.13.0': + resolution: {integrity: sha512-60E5mvmIiW+i1E/HYeSX4iE4A8s9NJSGYPu7UM0DJght1c2tTkWwuyDyAwzsEXhKM/XbbndfnTiXdfrf27d2hw==} + cpu: [arm] + os: [android] + + '@unrs/resolver-binding-android-arm64@1.13.0': + resolution: {integrity: sha512-qlh/JR3Tuy1cJ7xtf5pR4ykvLiK6os7X7EL2+zXZbrVc/s+yB8DoFdQrCAW9/a2TOxPVbR7QVNpkPWh7UWIsEQ==} + cpu: [arm64] + os: [android] + + '@unrs/resolver-binding-darwin-arm64@1.13.0': + resolution: {integrity: sha512-yynnnnJXUC99WeD1GfvuXPKsKNfvgzGYC2eRayFnUfsHVROjqrbFOkFQLZiSx1H8+PLy5BzU8vqyPyLqbRfeBQ==} + cpu: [arm64] + os: [darwin] + + '@unrs/resolver-binding-darwin-x64@1.13.0': + resolution: {integrity: sha512-t8PXE0Ip9tmGyhRlfVsnEbzGM5iSvJIeNIXciUACjzpg0mmPs13fGv2x7W8sBa0S8zbIiohxKXS9fL/LXW/ERQ==} + cpu: [x64] + os: [darwin] + + '@unrs/resolver-binding-freebsd-x64@1.13.0': + resolution: {integrity: sha512-qdtl9GDWDoDx6rhzF4RU5SJutV3lcLOiTiyqD6nBxYfEO6lAgLNukfrA+HJ2u2OiyWvV8JW5iEWD3LoONw7lYA==} + cpu: [x64] + os: [freebsd] + + '@unrs/resolver-binding-linux-arm-gnueabihf@1.13.0': + resolution: {integrity: sha512-VrMUVwdrScTarsh4B6aUhTtziUavSlglo4Hi8XZ6CpAe4+j3nquY+XoP+tYkiSBDsXZ8386ne4pv4YYYBNi02w==} + cpu: [arm] + os: [linux] + + '@unrs/resolver-binding-linux-arm-musleabihf@1.13.0': + resolution: {integrity: sha512-zSbTVwaxiTC+zYJ9xVNTC6c+BYO/kOV/odcTI3bHuFFXa+XmjLoUkb/8UxsZeU5YF4K000m17wrXoTblNWuzOg==} + cpu: [arm] + os: [linux] + + '@unrs/resolver-binding-linux-arm64-gnu@1.13.0': + resolution: {integrity: sha512-Z/Rax87moZHsuvJ8awdfP+zrMlsCt3d7mggUPIiPe32KpeagimyzJWnZSMQoV67an9uVQghyh92Pc0VprITnYA==} + cpu: [arm64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-arm64-musl@1.13.0': + resolution: {integrity: sha512-oUzXz8hNvFLNEAag8lBKJe1euiV2dmGHAR+eQ5fNpsZO0F1K7IMRb4J6pqYsd7uLMRQNPiu5A1WKUJHbFLWbbw==} + cpu: [arm64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-linux-loong64-gnu@1.13.0': + resolution: {integrity: sha512-BxhGYvZBg0YrvNOeSEGR3eNklwXYy0mUJk7oeGJvZoQMKM68zYvbbf52+fQI3Le4X0fW276FTKIoTwjpMob80A==} + cpu: [loong64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-loong64-musl@1.13.0': + resolution: {integrity: sha512-nZcIuup9Ar3gAlqoZfX/KW6x83TMI11tLpCjldZG5M1KeY8qNUPNJJ71+sPvG8HMBpoh+ix1pAm5gkMFvcSAcQ==} + cpu: [loong64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-linux-ppc64-gnu@1.13.0': + resolution: {integrity: sha512-AG6AgdDrkRNjAPwD/cftFJGgZUWCiJX+E8vpYCDEnwFHLTHZ7ppBiU6/vyPPwrfjcPUPQCDbbxE/eZUXsx49jQ==} + cpu: [ppc64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-riscv64-gnu@1.13.0': + resolution: {integrity: sha512-6vOqYGcAmzpRWpUURWutzvpf1qJ6eOu5cfYObdtPJnzZ0+Kw4cw+ZkZJqIYEh8fPuTBwSYDL/FwlUhma1G/JVQ==} + cpu: [riscv64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-riscv64-musl@1.13.0': + resolution: {integrity: sha512-4HeIn0S2KVUowK0A+EweXrDvZ8CKHEfTtif0kx9vt3ORNsqcXNFFIFnHE0tizma3/Gt5OGrU2ovYNuj+D/bN4g==} + cpu: [riscv64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-linux-s390x-gnu@1.13.0': + resolution: {integrity: sha512-JfkvqY7NZbxyhexLE+g6Z8Hsx4utHOGaVazAVghPiBn8Upw2iERZPpKYnW1FBVU4WStv/BiIsoK/Muke0E7asA==} + cpu: [s390x] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-x64-gnu@1.13.0': + resolution: {integrity: sha512-iwjLeVdZo/8v5OKAeRIC+4VQV045t1EPZr5B/AVLgUQ04IdtNthWzg6not2cNjZgH2gHpSf4fOXMmN83aLO1FA==} + cpu: [x64] + os: [linux] + libc: [glibc] + + '@unrs/resolver-binding-linux-x64-musl@1.13.0': + resolution: {integrity: sha512-TOh1fqOjyq1OPoht3BDLd7Y+HeMJRwd5g2VNmCQclknEbjp4py5GFRmT4L/rOybF5Af8q0LT9zHs2WGkwlqtrw==} + cpu: [x64] + os: [linux] + libc: [musl] + + '@unrs/resolver-binding-openharmony-arm64@1.13.0': + resolution: {integrity: sha512-3T2MNtF2dd1yjaXCVqrsi+/3VZeksEzU1hygPzqqkBLVVjn+2iJzXEkxxCKIVFrWnpmEbazeHJp/ruYD0RUVWA==} + cpu: [arm64] + os: [openharmony] + + '@unrs/resolver-binding-win32-arm64-msvc@1.13.0': + resolution: {integrity: sha512-hKWfSLiN3L4cIxg0jrpyP/66AXLTcyD37jmSn//rGdOUYGlizYxTEFdJ+GZbp2NnaML3YS/A73nCysze8FaJdg==} + cpu: [arm64] + os: [win32] + + '@unrs/resolver-binding-win32-ia32-msvc@1.13.0': + resolution: {integrity: sha512-N4gDKkDoiyIQEcn3vTqe2ksRxUAtBvQ8c5TiT+WonSa6FHgCAY5+RggnZ134hXJoRj57JEjv4/m+i/pAKHWrTQ==} + cpu: [ia32] + os: [win32] + + '@unrs/resolver-binding-win32-x64-msvc@1.13.0': + resolution: {integrity: sha512-DpLMlAqlrk4zBVK3DiDjwKD0oq7pZNy+8BiIBRuByqb6dm5jsdoLMhIiyh/xR7+WejaW/1Ui+XgbgMNa4+zWJg==} + cpu: [x64] + os: [win32] + + '@vitest/mocker@5.1.0': + resolution: {integrity: sha512-5umB9/jlWcqVS6fsrFmv5Gdnpu6wAUio/lEOwAmvB7v+lFo/IW2B9FhAD0p19GCULTgMzLCdUmuCDCnAzWgppQ==} + 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 + + '@vitest/spy@5.1.0': + resolution: {integrity: sha512-2DPO5OMHWKrBngC+fCmTQqemNF0gidRhp3lxbBmRhW+M1XJrfgPpqNqWVevXtn2f2ufD5ZaR1B6B641aAlcX5A==} + + '@vladfrangu/async_event_emitter@2.4.7': + resolution: {integrity: sha512-Xfe6rpCTxSxfbswi/W/Pz7zp1WWSNn4A0eW4mLkQUewCrXXtMj31lCg+iQyTkh/CkusZSq9eDflu7tjEDXUY6g==} + engines: {node: '>=v14.0.0', npm: '>=7.0.0'} + + '@yuku-toolchain/darwin-arm64@0.28.0': + resolution: {integrity: sha512-ub1u+JMRrLcuDMN2VofXS1GMau5Irl/HKj8raDUN6hYihe/Ed7IVpT9ycqs7vWxQx1j4BPyXr+UOV3gVXVFooA==} + cpu: [arm64] + os: [darwin] + + '@yuku-toolchain/darwin-x64@0.28.0': + resolution: {integrity: sha512-S3XmN4T7nXBUdBAvIM/7/O1LpNXFg0E/9iaZO4S2fZrlxeYuvOKcgI9y6i0/2ddsWMJvMZ51cuxFTeesvRC41A==} + cpu: [x64] + os: [darwin] + + '@yuku-toolchain/linux-arm64@0.28.0': + resolution: {integrity: sha512-kIK5JcpiGGBFZlLKuvjVmzqOmnCYSFXa1P8Vl+gZN6B+3G/1rTusBJqyMjKMNuXyMb+AYac6roGRpbcGH/LFUw==} + cpu: [arm64] + os: [linux] + + '@yuku-toolchain/linux-x64@0.28.0': + resolution: {integrity: sha512-yCz0KECLdtk8G7VCwzYlC0xi70W29oB65oRUW7MA+lvaNEHkhK+ZLZzCveVkl3BVpLpkyBrznODX8UdbVBmpCg==} + cpu: [x64] + os: [linux] + + '@yuku-toolchain/win32-arm64@0.28.0': + resolution: {integrity: sha512-d6M/3YJ/vJNQP32Yw/58KaVtp1D9nmP4C3C8HSTdhjiVTSmVQ4UX0+QT/iftH4G7VLGVZeI8wo5QhLF4rC2jgw==} + cpu: [arm64] + os: [win32] + + '@yuku-toolchain/win32-x64@0.28.0': + resolution: {integrity: sha512-aJ4h8oy9jYtfjh5hXXuIBrDvnkXfPUlKhxFumAArkK9TrnDAXo3Ixk3/S6xmjnPkkqobS7NyDLcSC/HZb2gjOg==} + cpu: [x64] + os: [win32] + + acorn-jsx@5.3.2: + resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} + peerDependencies: + acorn: ^6.0.0 || ^7.0.0 || ^8.0.0 + + acorn@8.19.0: + resolution: {integrity: sha512-oJlA3XiRm7Cyk6qFD2Jn8ak9B7jSy0qy00ADO3+8dpT0LSjFihQYv4C02LFCSYJV3Q37xYwwRy5m+IpIiUzqWw==} + engines: {node: '>=0.4.0'} + hasBin: true + + agent-base@7.1.4: + resolution: {integrity: sha512-MnA+YT8fwfJPgBx3m60MNqakm30XOkyIoH1y6huTQvC0PwZG7ki8NacLBcrPbNoo8vEZy7Jpuk7+jMO+CUovTQ==} + engines: {node: '>= 14'} + + ajv@6.15.0: + resolution: {integrity: sha512-fgFx7Hfoq60ytK2c7DhnF8jIvzYgOMxfugjLOSMHjLIPgenqa7S7oaagATUq99mV6IYvN2tRmC0wnTYX6iPbMw==} + + array-buffer-byte-length@1.0.2: + resolution: {integrity: sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==} + engines: {node: '>= 0.4'} + + array-includes@3.2.0: + resolution: {integrity: sha512-VXY5eFRarnXcYxwBjJzPmEhH55+rmP79/+ueDhi0F+TuqfHCItagIHqxeUZrmgrOPa31QTh9H85DjX3FfJ0FTg==} + engines: {node: '>= 0.4'} + + array.prototype.findlast@1.2.5: + resolution: {integrity: sha512-CVvd6FHg1Z3POpBLxO6E6zr+rSKEQ9L6rZHAaY7lLfhKsWYUBBOuMs0e9o24oopj6H+geRCX0YJ+TJLBK2eHyQ==} + engines: {node: '>= 0.4'} + + array.prototype.flat@1.3.3: + resolution: {integrity: sha512-rwG/ja1neyLqCuGZ5YYrznA62D4mZXg0i1cIskIUKSiqF3Cje9/wXAls9B9s1Wa2fomMsIv8czB8jZcPmxCXFg==} + engines: {node: '>= 0.4'} + + array.prototype.flatmap@1.3.3: + resolution: {integrity: sha512-Y7Wt51eKJSyi80hFrJCePGGNo5ktJCslFuboqJsbf57CCPcm5zztluPlc4/aD8sWsKvlwatezpV4U1efk8kpjg==} + engines: {node: '>= 0.4'} + + array.prototype.tosorted@1.1.4: + resolution: {integrity: sha512-p6Fx8B7b7ZhL/gmUsAy0D15WhvDccw3mnGNbZpi3pmeJdxtWsj2jEaI4Y6oo3XiHfzuSgPwKc04MYt6KgvC/wA==} + engines: {node: '>= 0.4'} + + arraybuffer.prototype.slice@1.0.4: + resolution: {integrity: sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==} + engines: {node: '>= 0.4'} + + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} + + async-function@1.0.0: + resolution: {integrity: sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==} + engines: {node: '>= 0.4'} + + atomic-sleep@1.0.0: + resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} + engines: {node: '>=8.0.0'} + + available-typed-arrays@1.0.7: + resolution: {integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==} + engines: {node: '>= 0.4'} + + balanced-match@1.0.2: + resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} + + balanced-match@4.0.4: + resolution: {integrity: sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==} + engines: {node: 18 || 20 || >=22} + + base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + + baseline-browser-mapping@2.11.37: + resolution: {integrity: sha512-QYph+vfurmaxhNwi9FprfmtkT5cx2Keg8FzZ0vnjO8ukscIybVyZGMFwdllKGlTI6qyU8ck43OM9UXh+IFJihQ==} + engines: {node: '>=6.0.0'} + hasBin: true + + better-sqlite3@13.2.0: + resolution: {integrity: sha512-Z8Q/9x/uNyKxA1v4FNodyItRVRw1TeKBrmj32JhxhR0ceNcBY+wMobt/Bv7M7TzwPAXjnZRtNaEsATnUZSKWZQ==} + engines: {node: '>=22'} + + bignumber.js@9.3.1: + resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==} + + brace-expansion@1.1.22: + resolution: {integrity: sha512-CKLDTuSsN0+r1ThM0WkzzBI7dnPI6xEGfa/JnVYIK9JNBA1N1NyPwXVHor//NKD/y3sDxp764sZdLhFK7pH8XQ==} + + brace-expansion@5.0.13: + resolution: {integrity: sha512-Vh3dmFbc4wZeox7M9I/0L9GfFd83Su4+yCck/OF9Gi/P/dAHn0RT7X4K9R7gMNMhDck3DvhR6QXsnQdjjgwNvQ==} + engines: {node: 20 || >=22} + + browserslist@4.29.5: + resolution: {integrity: sha512-khTmKu5NGYTotqcYo8Bew2k4RAE9PuXRSFRXG2lQBrCEQHyeQ/vX6gKMxfokwywBsLiXZMnHsmWMG1pnO8J7uQ==} + engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} + hasBin: true + + buffer-equal-constant-time@1.0.1: + resolution: {integrity: sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==} + + buffer-from@1.1.2: + resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + + builtin-modules@3.3.0: + resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} + engines: {node: '>=6'} + + builtin-modules@5.5.0: + resolution: {integrity: sha512-2uhx+Lkzc2fnAcNEpzbJziSzwdv6cJjxxsi9oByBhSuy2wffAPzmazVDiWJk2xDKULFONl5gNOEOLOupQ8gsPg==} + engines: {node: '>=18.20'} + + bytes@3.1.2: + resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} + engines: {node: '>= 0.8'} + + cac@7.1.0: + resolution: {integrity: sha512-LMDU/U2yA4IPIY8KT0NsNPWEYZvAMkbgyspxJ6btJaYV+WMDOHAZCmB0lsTObiHaRS1V/ztKAl7+TSkTqXyeoA==} + engines: {node: '>=20.19.0'} + + cacheable@2.5.0: + resolution: {integrity: sha512-60cyAOytib/OzBw1JNSoSV/boK1AtHryDIjvVBk7XbN4ugfkM3+Sry7fEjNgPMGgOjuaZPAp8ruZ0Cxafwyq9g==} + + call-bind-apply-helpers@1.0.2: + resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} + engines: {node: '>= 0.4'} + + call-bind@1.0.9: + resolution: {integrity: sha512-a/hy+pNsFUTR+Iz8TCJvXudKVLAnz/DyeSUo10I5yvFDQJBFU2s9uqQpoSrJlroHUKoKqzg+epxyP9lqFdzfBQ==} + engines: {node: '>= 0.4'} + + call-bound@1.0.4: + resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} + engines: {node: '>= 0.4'} + + caniuse-lite@1.0.30001826: + resolution: {integrity: sha512-wTB+9tIbLro/BCXwLuNV1meHE4L9dS6dArMDwgYfNBPMYScqClHyGunhkCSDtHhe/69Xl0sHlKgBVZ+fNsYtWA==} + + chai@6.3.0: + resolution: {integrity: sha512-XWAtwJ6OHO+tj0EKCs0Y2UamnyOxseZWltU4x2U2wh8g4AigdjwvtUjvLP2tqkA/avxHEtzxNaqGq/YGNwckKg==} + engines: {node: '>=18'} + + change-case@5.4.4: + resolution: {integrity: sha512-HRQyTk2/YPEkt9TnUPbOpr64Uw3KOicFWPVBb+xiHvd6eBx/qPr9xqfBFDT8P2vWsvvz4jbEkfDe71W3VyNu2w==} + + character-entities@2.0.2: + resolution: {integrity: sha512-shx7oQ0Awen/BRIdkjkvz54PnEEI/EjwXDSIZp86/KKdbafHh1Df/RYGBhn4hbe2+uKC9FnT5UCEdyPz3ai9hQ==} + + chrono-node@2.10.3: + resolution: {integrity: sha512-MOfrzXgSMZTH4SZ5gyRKQCVwiCrCKY+uYkSJiWoRLXS88DA6WGJm8UjgS+VVEuUQeew/UUXaxrO+SeDn/WCisg==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + ci-info@4.5.0: + resolution: {integrity: sha512-d1uM8k5UZEyPza1n/MG3ko8nKupKN0KJpFsipgPcgaCCvV+IqIfJ+NzTjetlLM+UcXZx3+cLrNr76+eAO7G1Mw==} + engines: {node: '>=8'} + + cjs-module-lexer@2.3.0: + resolution: {integrity: sha512-lmNyBzi6iYiqyrExTctfmjd8tInx+dHu9PBomTfH5RXS53c27JMFJgzNv5TyAnm3PgGf+MLy0+Ws41/HlVxdKQ==} + + colorette@2.0.20: + resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} + + comment-parser@1.4.9: + resolution: {integrity: sha512-+2AvZKjJaNq9GQljm3tr0utwrig5BL+jgJGvz5rDpGKNIp+ojcRXWUwBbh/sGIi1QCprR6PsKFakub+w1v+4hQ==} + engines: {node: '>= 12.0.0'} + + concat-map@0.0.1: + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} + + core-js-compat@3.51.0: + resolution: {integrity: sha512-52r6fkXgxv4GLMjmFcMWRx7X9bw071xTTdrDcdyPGRqU2oE+9pCG0bAOMifSBdLw0JRBZKEF0q3B55qPlLuE8g==} + engines: {node: '>=6.4.0'} + + cron-parser@5.10.6: + resolution: {integrity: sha512-kpoxgQyveO1l29nw+FWdvmotyV7eOSzGHQpxiXOEZIDOjqO1iR6kfgJ0PVHTuV26uBemKq3ppzma7dHFAG7viw==} + engines: {node: '>=18'} + + cross-spawn@7.0.6: + resolution: {integrity: sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==} + engines: {node: '>= 8'} + + data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + + data-view-buffer@1.0.2: + resolution: {integrity: sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==} + engines: {node: '>= 0.4'} + + data-view-byte-length@1.0.2: + resolution: {integrity: sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==} + engines: {node: '>= 0.4'} + + data-view-byte-offset@1.0.1: + resolution: {integrity: sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==} + engines: {node: '>= 0.4'} + + date-fns@4.4.0: + resolution: {integrity: sha512-+1UMbeh68lH1SegH83CGWwpb6OHHbpSgr3+s5Eww5M4CAgswBpoWS0AjTOfEJ33HiYKz1hdj/KTFprzXHmq/6w==} + + dateformat@4.6.3: + resolution: {integrity: sha512-2P0p0pFGzHS5EMnhdxQi7aJN+iMheud0UhG4dlE1DLAlvL8JHjJJTX/CSm4JXwV0Ka5nGk3zC5mcb5bUQUxxMA==} + + debug@4.4.3: + resolution: {integrity: sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + + decode-named-character-reference@1.3.0: + resolution: {integrity: sha512-GtpQYB283KrPp6nRw50q3U9/VfOutZOe103qlN7BPP6Ad27xYnOIWv4lPzo8HCAL+mMZofJ9KEy30fq6MfaK6Q==} + + deep-is@0.1.4: + resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + + define-data-property@1.1.4: + resolution: {integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==} + engines: {node: '>= 0.4'} + + define-properties@1.2.1: + resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} + engines: {node: '>= 0.4'} + + defu@6.1.7: + resolution: {integrity: sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==} + + dequal@2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + + detect-indent@7.0.2: + resolution: {integrity: sha512-y+8xyqdGLL+6sh0tVeHcfP/QDd8gUgbasolJJpY7NgeQGSZ739bDtSiaiDgtoicy+mtYB81dKLxO9xRhCyIB3A==} + engines: {node: '>=12.20'} + + detect-libc@2.1.2: + resolution: {integrity: sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==} + engines: {node: '>=8'} + + devlop@1.1.0: + resolution: {integrity: sha512-RWmIqhcFf1lRYBvNmr7qTNuyCt/7/ns2jbpp1+PalgE/rDQcBT0fioSMUpJ93irlUhC5hrg4cYqe6U+0ImW0rA==} + + discord-api-types@0.38.59: + resolution: {integrity: sha512-LZqh8gvWU/Bhl9qEVIRLeLJuaPGO7rA26IXLrXnMcjXxofh/h5UhP6notfCTj4X5kR1ogMvVgcrVYIuynY/CxQ==} + + discord.js@14.28.1: + resolution: {integrity: sha512-Je5OcqgurnIUQK4vR+gQnmzOf/lNQsD6d/UkV8ZOj+bFa5zJXPyiGXlbywp2EagwshVT18y7YNQNSRd3FjYkDw==} + engines: {node: '>=18'} + + doctrine@2.1.0: + resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} + engines: {node: '>=0.10.0'} + + drizzle-kit@0.31.11: + resolution: {integrity: sha512-YCYqxTLIB2OCqf6w9/Vef13baBVbwQIPcbT4Y56AfO6B9ajZhDhD8Jkveg/hJvT/iuMloKD/IYYkyMMNhr7Kqg==} + hasBin: true + + drizzle-orm@0.45.4: + resolution: {integrity: sha512-NiM1YZpJ2UxyeE67DpDDZ+Tsw4YLX3trSlkNT7Tm9eKoUNb1LvaAaQzXgYQsWs+AQ9TUmmwMmBOCXuqqxUWKKQ==} + peerDependencies: + '@aws-sdk/client-rds-data': '>=3' + '@cloudflare/workers-types': '>=4' + '@electric-sql/pglite': '>=0.2.0' + '@libsql/client': '>=0.10.0' + '@libsql/client-wasm': '>=0.10.0' + '@neondatabase/serverless': '>=0.10.0' + '@netlify/db': '>=0.4.0' + '@op-engineering/op-sqlite': '>=2' + '@opentelemetry/api': ^1.4.1 + '@planetscale/database': '>=1.13' + '@prisma/client': '*' + '@tidbcloud/serverless': '*' + '@types/better-sqlite3': '*' + '@types/pg': '*' + '@types/sql.js': '*' + '@upstash/redis': '>=1.34.7' + '@vercel/postgres': '>=0.8.0' + '@xata.io/client': '*' + better-sqlite3: '>=7' + bun-types: '*' + expo-sqlite: '>=14.0.0' + gel: '>=2' + knex: '*' + kysely: '*' + mysql2: '>=2' + pg: '>=8' + postgres: '>=3' + prisma: '*' + sql.js: '>=1' + sqlite3: '>=5' + peerDependenciesMeta: + '@aws-sdk/client-rds-data': + optional: true + '@cloudflare/workers-types': + optional: true + '@electric-sql/pglite': + optional: true + '@libsql/client': + optional: true + '@libsql/client-wasm': + optional: true + '@neondatabase/serverless': + optional: true + '@netlify/db': + optional: true + '@op-engineering/op-sqlite': + optional: true + '@opentelemetry/api': + optional: true + '@planetscale/database': + optional: true + '@prisma/client': + optional: true + '@tidbcloud/serverless': + optional: true + '@types/better-sqlite3': + optional: true + '@types/pg': + optional: true + '@types/sql.js': + optional: true + '@upstash/redis': + optional: true + '@vercel/postgres': + optional: true + '@xata.io/client': + optional: true + better-sqlite3: + optional: true + bun-types: + optional: true + expo-sqlite: + optional: true + gel: + optional: true + knex: + optional: true + kysely: + optional: true + mysql2: + optional: true + pg: + optional: true + postgres: + optional: true + prisma: + optional: true + sql.js: + optional: true + sqlite3: + optional: true + + dts-resolver@3.0.0: + resolution: {integrity: sha512-1T1f+z+4tl9XD+m+0HBgWoL/nm0bOIffyWaUuUSBlFg/86IWvfx+wjNaO/ybU0AJzG9/Mi5hBUgGV6zCmWEN7Q==} + engines: {node: ^22.18.0 || >=24.0.0} + peerDependencies: + oxc-resolver: '>=11.0.0' + peerDependenciesMeta: + oxc-resolver: + optional: true + + dunder-proto@1.0.1: + resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} + engines: {node: '>= 0.4'} + + ecdsa-sig-formatter@1.0.11: + resolution: {integrity: sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==} + + electron-to-chromium@1.5.485: + resolution: {integrity: sha512-m3uadzR0Z+sR19HGWgfxoZcKv9hE/edVM9OZ+FJ4wNRyfuFtkwZJIDoehEty5sisYVwmge8lKV1tenWOyClVgw==} + + empathic@2.1.0: + resolution: {integrity: sha512-AnfC1ATldl49/cvZdLPDjBfrRNwbDO05aibiOtzQu3qtlbJtomNLhF30HEtn/7iBz50dlMECqATo3fG0LrdEgw==} + engines: {node: '>=14'} + + end-of-stream@1.4.5: + resolution: {integrity: sha512-ooEGc6HP26xXq/N+GCGOT0JKCLDGrq2bQUZrQ7gyrJiZANJ/8YDTxTpQBXGMn+WbIQXNVpyWymm7KYVICQnyOg==} + + entities@8.1.0: + resolution: {integrity: sha512-kxL7msIffSuh9aaFAMD7rxAIuTRMAHMeBtgHW2yUdWw732ZNh4MehkF2gdjvtdmikkaIP9bFDDJOPlsvm7avrA==} + engines: {node: '>=20.19.0'} + + entities@9.0.0: + resolution: {integrity: sha512-oJFNDJg3kTPwAD1cNn2+WmUq4wFoo09npc3Ydf1D7ED4smRiWrsKnaLxykrTWgyGEcusc87P5dxlAleol9kpkg==} + engines: {node: '>=20.19.0'} + + es-abstract-get@1.0.0: + resolution: {integrity: sha512-6PMWXpdhshVvFp+FoWYs1EvG1Nj0tvk0dZM+XcK0xMEM1czRVcP6ohqPWHy6qPagSpC8j4+p89WXlT+xXJs/fg==} + engines: {node: '>= 0.4'} + + es-abstract@1.24.2: + resolution: {integrity: sha512-2FpH9Q5i2RRwyEP1AylXe6nYLR5OhaJTZwmlcP0dL/+JCbgg7yyEo/sEK6HeGZRf3dFpWwThaRHVApXSkW3xeg==} + engines: {node: '>= 0.4'} + + es-define-property@1.0.1: + resolution: {integrity: sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==} + engines: {node: '>= 0.4'} + + es-errors@1.3.0: + resolution: {integrity: sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==} + engines: {node: '>= 0.4'} + + es-iterator-helpers@1.4.0: + resolution: {integrity: sha512-c/A0P0oxkACDc+cKWw8evLXK83oBKgn0qPOqCYT4x9uolpCIJAcYvJC9QYKNDRPsTeGyCrQ326jrvgZWdCdK5Q==} + engines: {node: '>= 0.4'} + + es-module-lexer@2.3.2: + resolution: {integrity: sha512-poHGpORABojJJucnV9KbOavETW8lBVnphkW77ER5/BQ5Fz7oXSoCNek7IH3vR5nRjdsEz926ibFYX8KtLQmdyw==} + + es-module-lexer@3.0.4: + resolution: {integrity: sha512-BldNY5mwkVu+cQ5Ymn3e6hB9Sx8XHx4ZevWbiUyZbfKxJxYO27Hf0wfzkxIaD5CAJMaGl3YspKELj0ff/7nCMA==} + + es-object-atoms@1.1.2: + resolution: {integrity: sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==} + engines: {node: '>= 0.4'} + + es-set-tostringtag@2.1.0: + resolution: {integrity: sha512-j6vWzfrGVfyXxge+O0x5sh6cvxAog0a/4Rdd2K36zCMV5eJ+/+tOAngRO8cODMNWbVRdVlmGZQL2YS3yR8bIUA==} + engines: {node: '>= 0.4'} + + es-shim-unscopables@1.1.0: + resolution: {integrity: sha512-d9T8ucsEhh8Bi1woXCf+TIKDIROLG5WCkxg8geBCbvk22kzwC5G2OnXVMO6FUsvQlgUUXQ2itephWDLqDzbeCw==} + engines: {node: '>= 0.4'} + + es-to-primitive@1.3.4: + resolution: {integrity: sha512-yPDz7wqpg1/mmHLmS3tcfTfbw5f1eryXvyghYBffGdERwe+mV7ZcWzTR8LR17Kvqt3qfPurjlonmnq3MKXIOXw==} + engines: {node: '>= 0.4'} + + esbuild@0.18.20: + resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} + engines: {node: '>=12'} + hasBin: true + + esbuild@0.25.12: + resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==} + engines: {node: '>=18'} + hasBin: true + + esbuild@0.28.2: + resolution: {integrity: sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==} + engines: {node: '>=18'} + hasBin: true + + escalade@3.2.0: + resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} + engines: {node: '>=6'} + + escape-string-regexp@4.0.0: + resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} + engines: {node: '>=10'} + + eslint-config-prettier@10.1.8: + resolution: {integrity: sha512-82GZUjRS0p/jganf6q1rEO25VSoHH0hKPCTrgillPjdI/3bgBhAE1QzHrHTizjpRvy6pGAvKjDJtk2pF9NDq8w==} + hasBin: true + peerDependencies: + eslint: '>=7.0.0' + + eslint-import-context@0.1.9: + resolution: {integrity: sha512-K9Hb+yRaGAGUbwjhFNHvSmmkZs9+zbuoe3kFQ4V1wYjrepUFYM2dZAfNtjbbj3qsPfUfsA68Bx/ICWQMi+C8Eg==} + engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + peerDependencies: + unrs-resolver: ^1.0.0 + peerDependenciesMeta: + unrs-resolver: + optional: true + + eslint-import-resolver-typescript@4.4.5: + resolution: {integrity: sha512-nbE5XLph6TLtGYcu/U6e6ZVXyKBhbDWK5cLGk76eJ7NdZpwf1P9EFkpt1Z01mNZNrrilsAYWKH6zUkL4reoXbw==} + engines: {node: ^16.17.0 || >=18.6.0} + peerDependencies: + eslint: '*' + eslint-plugin-import: '*' + eslint-plugin-import-x: '*' + peerDependenciesMeta: + eslint-plugin-import: + optional: true + eslint-plugin-import-x: + optional: true + + eslint-plugin-import-x@4.18.1: + resolution: {integrity: sha512-D1h++38NS2Z40zf8jbd2OHqDrnIFRKpdp8sL0jP4xSDGZj6MNwEQua8F+r3tOWjcHrsWuhHOJ7wASWioJ31tfg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/utils': ^8.56.0 + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + eslint-import-resolver-node: '*' + peerDependenciesMeta: + '@typescript-eslint/utils': + optional: true + eslint-import-resolver-node: + optional: true + + eslint-plugin-react@7.37.5: + resolution: {integrity: sha512-Qteup0SqU15kdocexFNAJMvCJEfa2xUKNV4CC1xsVMrIIqEy3SQ/rqyxCWNzfrd3/ldy6HMlD2e0JDVpDg2qIA==} + engines: {node: '>=4'} + peerDependencies: + eslint: ^3 || ^4 || ^5 || ^6 || ^7 || ^8 || ^9.7 + + eslint-plugin-sonarjs@4.2.2: + resolution: {integrity: sha512-usNF9GfP89ibwhfxpZaCMW40sC7UEOusDgDCk7lyqAhh4AYdbBaAgLVL5Y/QS0jSed8eJ2ACGH6zzE8ezd/yZQ==} + peerDependencies: + eslint: ^8.0.0 || ^9.0.0 || ^10.0.0 + + eslint-plugin-unicorn@79.0.0: + resolution: {integrity: sha512-k7MWrjoVTVCnjKpgaxBuScPNSPomLvDpsd9uADpWrIFzrnwiec27eWhGrmmyuTj1bC3xVNYP4QfG3MEzEw6ifg==} + engines: {node: '>=22'} + peerDependencies: + eslint: '>=10.4' + typescript: '*' + peerDependenciesMeta: + typescript: + optional: true + + eslint-scope@9.1.2: + resolution: {integrity: sha512-xS90H51cKw0jltxmvmHy2Iai1LIqrfbw57b79w/J7MfvDfkIkFZ+kj6zC3BjtUwh150HsSSdxXZcsuv72miDFQ==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + eslint-visitor-keys@3.4.3: + resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} + engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} + + eslint-visitor-keys@5.0.1: + resolution: {integrity: sha512-tD40eHxA35h0PEIZNeIjkHoDR4YjjJp34biM0mDvplBe//mB+IHCqHDGV7pxF+7MklTvighcCPPZC7ynWyjdTA==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + eslint@10.15.0: + resolution: {integrity: sha512-+5Wg4p+ze3sG1WErYgUO/3H1IQIfFBymVUA0Fo/XTeBOLS6UQIUekpSJ8sdRkn7O7wjh84b55w/roqavH2aScg==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + hasBin: true + peerDependencies: + jiti: '*' + peerDependenciesMeta: + jiti: + optional: true + + espree@11.2.0: + resolution: {integrity: sha512-7p3DrVEIopW1B1avAGLuCSh1jubc01H2JHc8B4qqGblmg5gI9yumBgACjWo4JlIc04ufug4xJ3SQI8HkS/Rgzw==} + engines: {node: ^20.19.0 || ^22.13.0 || >=24} + + esquery@1.7.0: + resolution: {integrity: sha512-Ap6G0WQwcU/LHsvLwON1fAQX9Zp0A2Y6Y/cJBl9r/JbW90Zyg4/zbG6zzKa2OTALELarYHmKu0GhpM5EO+7T0g==} + engines: {node: '>=0.10'} + + esrecurse@4.3.0: + resolution: {integrity: sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==} + engines: {node: '>=4.0'} + + estraverse@5.3.0: + resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} + engines: {node: '>=4.0'} + + estree-walker@3.0.3: + resolution: {integrity: sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==} + + esutils@2.0.3: + resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} + engines: {node: '>=0.10.0'} + + expect-type@1.4.0: + resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} + engines: {node: '>=12.0.0'} + + extend@3.0.2: + resolution: {integrity: sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==} + + fast-copy@4.3.1: + resolution: {integrity: sha512-CRzQaTFOFUs6PuhsAq7lk9Zqr995soJBcFNZlfJS/5keTSl1awREV9dZW4xS2nX4pWbhIIR0xp4h+J8PQxCkvg==} + + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fast-json-stable-stringify@2.1.0: + resolution: {integrity: sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==} + + fast-levenshtein@2.0.6: + resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + + fast-safe-stringify@2.1.1: + resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} + + fdir@6.5.0: + resolution: {integrity: sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==} + engines: {node: '>=12.0.0'} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + + fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + + file-entry-cache@11.1.5: + resolution: {integrity: sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==} + + find-up-simple@1.0.1: + resolution: {integrity: sha512-afd4O7zpqHeRyg4PfDQsXmlDe2PfdHtJt6Akt8jOWaApLOZk5JXs6VMR29lz03pRe9mpykrRCYIYxaJYcfpncQ==} + engines: {node: '>=18'} + + find-up@5.0.0: + resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} + engines: {node: '>=10'} + + flat-cache@6.1.23: + resolution: {integrity: sha512-f++BY9pTk+983xK1FLzlLpmM0i0z+jHmx3QESGkURMXujQZz1k5wzwX6hjnQ8goaD0B+sYnDK1yZ6MTyZfUaqA==} + + flatted@3.4.4: + resolution: {integrity: sha512-5+ybhBZANEJxaH3X5evAFatUxLfEHSr7n6kYJ+1Qd0mUqr4eu9gIf6GDbWHf8RJijHrjjO8G+la14SlL2SeS1Q==} + + for-each@0.3.5: + resolution: {integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==} + engines: {node: '>= 0.4'} + + formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + + function-bind@1.1.2: + resolution: {integrity: sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==} + + function.prototype.name@1.2.0: + resolution: {integrity: sha512-jObKIik1P2QjPHP5nz5BaOtUlfgS0fWo8IUByNXkM+o+02sJOi94em77GwJKQSJ3gfPHdgzLNrHc1uokV4P/ew==} + engines: {node: '>= 0.4'} + + functional-red-black-tree@1.0.1: + resolution: {integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==} + + functions-have-names@1.2.3: + resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} + + gaxios@8.3.3: + resolution: {integrity: sha512-zqPbbtW5bAOZ8BRjS7bxj5VG7PBY5PwKRxpku9NplLqAPmYMoXExL1KOdaK5fHvwRETu3bPplLEsFGDdUUlrpw==} + engines: {node: '>=22'} + + gcp-metadata@9.2.3: + resolution: {integrity: sha512-d2OI/dJJ3IIaeOz3c9jvr5j5G5beI5fQzbgilNiWhDKGwvJN9o10Qub70NkbF6PNJSUoNKZ77JKYGz0Fs4+9Lg==} + engines: {node: '>=22'} + + generator-function@2.0.1: + resolution: {integrity: sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==} + engines: {node: '>= 0.4'} + + get-intrinsic@1.3.0: + resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} + engines: {node: '>= 0.4'} + + get-proto@1.0.1: + resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} + engines: {node: '>= 0.4'} + + get-symbol-description@1.1.0: + resolution: {integrity: sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==} + engines: {node: '>= 0.4'} + + get-tsconfig@4.14.3: + resolution: {integrity: sha512-++QEw4DIY7WGoukz+/+A/8dGYPT9l9yIadnmSgZ8Rjr3YVSVDipQSO9CdnJo9ePqFqUUqh+wk9uIaoiAwsiPkA==} + + get-tsconfig@5.0.0-beta.6: + resolution: {integrity: sha512-X6fBC0pmImC70gvX2zm56go9hx0MyoGVdG0tUCkg/D+Xnh5TJsOZ7iDbOdI3PvmtrDxnu1YdDufpK2QJX1Meqw==} + engines: {node: '>=20.20.0'} + + glob-parent@6.0.2: + resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} + engines: {node: '>=10.13.0'} + + globals@17.14.0: + resolution: {integrity: sha512-UtdkTVyAJePQv0J2M9Xe4L0ruNSDV314XiIJsADI2Zf40bcdAonE/D/OhAU8AT99oij9mhLByb+NvA3QWZYgCg==} + engines: {node: '>=18'} + + globalthis@1.0.4: + resolution: {integrity: sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==} + engines: {node: '>= 0.4'} + + google-auth-library@11.3.4: + resolution: {integrity: sha512-RaYCDoeYIIFTRgH8hesSxqLrmtC2l+DB3cSCS/SN1TPGjI2VpPdJmF3bfRLUn8VvP/4I2Af9fsktw2f9SvVSVg==} + engines: {node: '>=22'} + + google-logging-utils@2.2.0: + resolution: {integrity: sha512-Q6HuSEyoaxi0AgqUrOYb2gc77fDl4QugRoHpreI8VpW/VzPsoKyxjL8tGKLmZpWlvC1uVBXM85tykoQpCGBF5g==} + engines: {node: '>=22'} + + googleapis-common@9.3.1: + resolution: {integrity: sha512-wtv/e7JYgmtpIPcSez2EFD/Wx49DPsRX2rj15D7hTwc7tDsP82dcwoX/I4+zE38mu6S9PcghizzzADLf+ZMunA==} + engines: {node: '>=22'} + + gopd@1.2.0: + resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} + engines: {node: '>= 0.4'} + + has-bigints@1.1.0: + resolution: {integrity: sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==} + engines: {node: '>= 0.4'} + + has-property-descriptors@1.0.2: + resolution: {integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==} + + has-proto@1.2.0: + resolution: {integrity: sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==} + engines: {node: '>= 0.4'} + + has-symbols@1.1.0: + resolution: {integrity: sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==} + engines: {node: '>= 0.4'} + + has-tostringtag@1.0.2: + resolution: {integrity: sha512-NqADB8VjPFLM2V0VvHUewwwsw0ZWBaIdgo+ieHtK3hasLz4qeCRjYcqfB6AQrBggRKppKF8L52/VqdVsO47Dlw==} + engines: {node: '>= 0.4'} + + hashery@1.5.1: + resolution: {integrity: sha512-iZyKG96/JwPz1N55vj2Ie2vXbhu440zfUfJvSwEqEbeLluk7NnapfGqa7LH0mOsnDxTF85Mx8/dyR6HfqcbmbQ==} + engines: {node: '>=20'} + + hasown@2.0.4: + resolution: {integrity: sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==} + engines: {node: '>= 0.4'} + + help-me@5.0.0: + resolution: {integrity: sha512-7xgomUX6ADmcYzFik0HzAxh/73YlKR9bmFzf51CZwR+b6YtzU2m0u49hQCqV6SvlqIqsaxovfwdvbnsw3b/zpg==} + + hono@4.13.18: + resolution: {integrity: sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==} + engines: {node: '>=16.9.0'} + + hookable@6.1.2: + resolution: {integrity: sha512-+abwxtiEA52GCVIsQqut3S/uKTbUwYIp4Pe/vv+6py5XiXBCqMZHg6pA6Y5qhgLSEys0/cYuPbO0z1QFj5ZCmg==} + + hookified@1.15.1: + resolution: {integrity: sha512-MvG/clsADq1GPM2KGo2nyfaWVyn9naPiXrqIe4jYjXNZQt238kWyOGrsyc/DmRAQ+Re6yeo6yX/yoNCG5KAEVg==} + + hookified@2.2.0: + resolution: {integrity: sha512-p/LgFzRN5FeoD3DLS6bkUapeye6E4SI6yJs6KetENd18S+FBthqYq2amJUWpt5z0EQwwHemidjY5OqJGEKm5uA==} + + https-proxy-agent@7.0.6: + resolution: {integrity: sha512-vK9P5/iUfdl95AI+JVyUuIcVtd4ofvtrOr3HNtM2yxC9bnMbEdp3x01OhQNnjb8IJYi38VlTE3mBXwcfvywuSw==} + engines: {node: '>= 14'} + + identifier-regex@1.1.0: + resolution: {integrity: sha512-SLX4H/vtcYlYnL7XqnuJKHU7Z8517TgsW9nmQiGOgMCjQ8V/deLYu6bEmbGoXe7WMMhc9+EUGyFFneHja8KabA==} + engines: {node: '>=18'} + + ignore@5.3.2: + resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} + engines: {node: '>= 4'} + + ignore@7.0.14: + resolution: {integrity: sha512-wCBiZ77u1tuWde6G/nfOtLaCTYcFDU5yCzARzK10y+rLhzYoL7a7yEemcopcc2Mzow7gZOIjnV2ym1NYmdiJOQ==} + engines: {node: '>= 4'} + + import-without-cache@0.4.1: + resolution: {integrity: sha512-vXoV9PjKHEednCUu01e98TkImxy67e3BJXbTIOmIq4Hyzw3IAwYRcuPkfeTzJzwyyts4kjuA73x+pWJLc4f86A==} + engines: {node: ^22.18.0 || >=24.0.0} + + imurmurhash@0.1.4: + resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} + engines: {node: '>=0.8.19'} + + indent-string@5.0.0: + resolution: {integrity: sha512-m6FAo/spmsW2Ab2fU35JTYwtOKa2yAwXSwgjSv1TJzh4Mh7mC3lzAOVLBprb72XsTrgkEIsl7YrFNAiDiRhIGg==} + engines: {node: '>=12'} + + internal-slot@1.1.0: + resolution: {integrity: sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==} + engines: {node: '>= 0.4'} + + is-array-buffer@3.0.5: + resolution: {integrity: sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==} + engines: {node: '>= 0.4'} + + is-async-function@2.1.1: + resolution: {integrity: sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==} + engines: {node: '>= 0.4'} + + is-bigint@1.1.0: + resolution: {integrity: sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==} + engines: {node: '>= 0.4'} + + is-boolean-object@1.2.2: + resolution: {integrity: sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==} + engines: {node: '>= 0.4'} + + is-builtin-module@5.0.0: + resolution: {integrity: sha512-f4RqJKBUe5rQkJ2eJEJBXSticB3hGbN9j0yxxMQFqIW89Jp9WYFtzfTcRlstDKVUTRzSOTLKRfO9vIztenwtxA==} + engines: {node: '>=18.20'} + + is-bun-module@2.0.0: + resolution: {integrity: sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ==} + + is-callable@1.2.7: + resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} + engines: {node: '>= 0.4'} + + is-core-module@2.18.0: + resolution: {integrity: sha512-qyax9fgaKOEC4qK8WZn7Q4IcoZC9RC1O1fFxRcRTq/oMMkWT/uXpqpXa12kzWR409zAt1drYN9N9BO26UmBCmw==} + engines: {node: '>= 0.4'} + + is-data-view@1.0.2: + resolution: {integrity: sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==} + engines: {node: '>= 0.4'} + + is-date-object@1.1.0: + resolution: {integrity: sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==} + engines: {node: '>= 0.4'} + + is-document.all@1.0.0: + resolution: {integrity: sha512-+XSoyS05OdBbhFuELhgTCpFNHkpBOJqtsZfUFFpe5QTw+9Sjbh8zitxhQkYAo6wV7e1Vb8cAPvpCk9jGam/82g==} + engines: {node: '>= 0.4'} + + is-extglob@2.1.1: + resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==} + engines: {node: '>=0.10.0'} + + is-finalizationregistry@1.1.1: + resolution: {integrity: sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==} + engines: {node: '>= 0.4'} + + is-generator-function@1.1.2: + resolution: {integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==} + engines: {node: '>= 0.4'} + + is-glob@4.0.3: + resolution: {integrity: sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==} + engines: {node: '>=0.10.0'} + + is-map@2.0.3: + resolution: {integrity: sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==} + engines: {node: '>= 0.4'} + + is-negative-zero@2.0.3: + resolution: {integrity: sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==} + engines: {node: '>= 0.4'} + + is-number-object@1.1.1: + resolution: {integrity: sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==} + engines: {node: '>= 0.4'} + + is-regex@1.2.1: + resolution: {integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==} + engines: {node: '>= 0.4'} + + is-set@2.0.3: + resolution: {integrity: sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==} + engines: {node: '>= 0.4'} + + is-shared-array-buffer@1.0.4: + resolution: {integrity: sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==} + engines: {node: '>= 0.4'} + + is-string@1.1.1: + resolution: {integrity: sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==} + engines: {node: '>= 0.4'} + + is-symbol@1.1.1: + resolution: {integrity: sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==} + engines: {node: '>= 0.4'} + + is-typed-array@1.1.15: + resolution: {integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==} + engines: {node: '>= 0.4'} + + is-weakmap@2.0.2: + resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==} + engines: {node: '>= 0.4'} + + is-weakref@1.1.1: + resolution: {integrity: sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==} + engines: {node: '>= 0.4'} + + is-weakset@2.0.4: + resolution: {integrity: sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==} + engines: {node: '>= 0.4'} + + isarray@2.0.5: + resolution: {integrity: sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==} + + isexe@2.0.0: + resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + + iterator.prototype@1.1.5: + resolution: {integrity: sha512-H0dkQoCa3b2VEeKQBOxFph+JAbcrQdE7KC0UkqwpLmv2EC4P41QXP+rqo9wYodACiG5/WM5s9oDApTU8utwj9g==} + engines: {node: '>= 0.4'} + + jiti@2.7.0: + resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==} + hasBin: true + + joycon@3.1.1: + resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} + engines: {node: '>=10'} + + js-tokens@4.0.0: + resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} + + jsesc@3.1.0: + resolution: {integrity: sha512-/sM3dO2FOzXjKQhJuo0Q173wf2KOo8t4I8vHy6lF9poUp7bKT0/NHE8fPX23PwfhnykfqnC2xRxOnVw5XuGIaA==} + engines: {node: '>=6'} + hasBin: true + + json-bigint@1.0.0: + resolution: {integrity: sha512-SiPv/8VpZuWbvLSMtTDU8hEfrZWg/mH/nV/b4o0CYbSxu1UIQPLdwKOCIyLQX+VIPO5vrLX3i8qtqFyhdPSUSQ==} + + json-schema-traverse@0.4.1: + resolution: {integrity: sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==} + + json-stable-stringify-without-jsonify@1.0.1: + resolution: {integrity: sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==} + + jsx-ast-utils-x@0.1.0: + resolution: {integrity: sha512-eQQBjBnsVtGacsG9uJNB8qOr3yA8rga4wAaGG1qRcBzSIvfhERLrWxMAM1hp5fcS6Abo8M4+bUBTekYR0qTPQw==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + + jsx-ast-utils@3.3.5: + resolution: {integrity: sha512-ZZow9HBI5O6EPgSJLUb8n2NKgmVWTwCvHGwFuJlMjvLFqlGG6pjirPhtdsseaLZjSibD8eegzmYpUZwoIlj2cQ==} + engines: {node: '>=4.0'} + + jwa@2.0.1: + resolution: {integrity: sha512-hRF04fqJIP8Abbkq5NKGN0Bbr3JxlQ+qhZufXVr0DvujKy93ZCbXZMHDL4EOtodSbCWxOqR8MS1tXA5hwqCXDg==} + + jws@4.0.1: + resolution: {integrity: sha512-EKI/M/yqPncGUUh44xz0PxSidXFr/+r0pA70+gIYhjv+et7yxM+s29Y+VGDkovRofQem0fs7Uvf4+YmAdyRduA==} + + keyv@5.6.0: + resolution: {integrity: sha512-CYDD3SOtsHtyXeEORYRx2qBtpDJFjRTGXUtmNEMGyzYOKj1TE3tycdlho7kA1Ufx9OYWZzg52QFBGALTirzDSw==} + + levn@0.4.1: + resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} + engines: {node: '>= 0.8.0'} + + lightningcss-android-arm64@1.33.0: + resolution: {integrity: sha512-gEpRTalKdosp4Bb8qWtc2iOgE5SeIHlpS1up9bFq2wAyYhl1UdTObYiHe98zEM9SQvSoqQZ1IQD0JNpg3Ml5pg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [android] + + lightningcss-darwin-arm64@1.33.0: + resolution: {integrity: sha512-Sciaz8eenNTKn9b3t7+xr0ipTp9YxKQY4npwQ3mrRuL0BAVHBLyZxofhaKBAVtzmtRZ/zTyo0/to4B1uWG/Djg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [darwin] + + lightningcss-darwin-x64@1.33.0: + resolution: {integrity: sha512-Z5UPAxzrjlWNNyGy6i65cJzzvgJ5D3T6wMvs+gWpY9d7qRhANrxqAp6LhxIgZhWEw18RfJTGcRxjuLIBr+m8XQ==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [darwin] + + lightningcss-freebsd-x64@1.33.0: + resolution: {integrity: sha512-QQM/Ti/hQajJwCY+RiWuCZ9sdtI/XQk7nDK5vC8kkdwixezOlDgvDx7+RT+QjK6FcFT4MpsuoBnHIo/O3StRRg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [freebsd] + + lightningcss-linux-arm-gnueabihf@1.33.0: + resolution: {integrity: sha512-N7FVBe6iS24MlM6R/4RBTxGhQheZGs7tiQ9U32UtF75NzP5Q7xWPRqLBCKxlRQRk3rY1jCIPLzx7WzOhuUIRLQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm] + os: [linux] + + lightningcss-linux-arm64-gnu@1.33.0: + resolution: {integrity: sha512-j2v/itmy4HlNxlc6voKXYgBqNi0Ng2LShg4z7GufpEgs05P+2suBVyi9I6YHq5uoVFx9ETin3eCEhLVyXGQnKg==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [glibc] + + lightningcss-linux-arm64-musl@1.33.0: + resolution: {integrity: sha512-yiO5ROMuYQgXbC60yjZU5CYSFZGKXL0HFATXt9mHJn1+zW55oCtMI9NfcVhYLMFDL7gV7oBPon/EmMMGg2OvtQ==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [linux] + libc: [musl] + + lightningcss-linux-x64-gnu@1.33.0: + resolution: {integrity: sha512-ar+Ju7LmcN0Jo4FpL4hpFybwNG9/3A/Br5KW2n2jyODg3MEZXaDYADdemoNS+BDNfMgKvylJLj4S5tyRActuAg==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [glibc] + + lightningcss-linux-x64-musl@1.33.0: + resolution: {integrity: sha512-RYiYbkokw0trfKqqzfF55lginwEPrD3OJDfTuJzFs1MK6iFnDenaz1fqLLtX4ITG3OktJQXOeTaw1awrBAlZPw==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [linux] + libc: [musl] + + lightningcss-win32-arm64-msvc@1.33.0: + resolution: {integrity: sha512-1K+MPfLSFVpphzpdbfkhlWk6wBrTObBzS2T6db10PNOZgR9GoVsAWzwNyuhUYYbTp23j+4RrncfujZ4uAzXvwA==} + engines: {node: '>= 12.0.0'} + cpu: [arm64] + os: [win32] + + lightningcss-win32-x64-msvc@1.33.0: + resolution: {integrity: sha512-OlEICDx/Xl0FqSp4bry8zFnCvGpig3Gl4gCquvYwHuqJKEC1+n9NgDniFvqHGmMv1ZkqDJrDqKKSykTDX+ehuA==} + engines: {node: '>= 12.0.0'} + cpu: [x64] + os: [win32] + + lightningcss@1.33.0: + resolution: {integrity: sha512-WkUDrojuJs0xkgGf2udWxa3yGBRxPtxUkB79i6aCZLRgc7PM8fZe9TosfPDcvEpQZbuFASnHYmRLBLUbmLOIIA==} + engines: {node: '>= 12.0.0'} + + locate-path@6.0.0: + resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} + engines: {node: '>=10'} + + lodash.merge@4.6.2: + resolution: {integrity: sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==} + + lodash.snakecase@4.1.1: + resolution: {integrity: sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==} + + lodash@4.18.1: + resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==} + + loose-envify@1.4.0: + resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} + hasBin: true + + luxon@3.7.2: + resolution: {integrity: sha512-vtEhXh/gNjI9Yg1u4jX/0YVPMvxzHuGgCm6tC5kZyb08yjGWGnqAjGJvcXbqQR2P3MyMEFnRbpcdFS6PBcLqew==} + engines: {node: '>=12'} + + magic-bytes.js@1.13.1: + resolution: {integrity: sha512-x5sn4UX2k5gCWlcfmoFwG4TPie8+dctESyqOBdhB5p6MsgWXdBKGmt9nXPObj/JI50TTL928lc5Yt1WntMn1bw==} + + magic-string@1.4.5: + resolution: {integrity: sha512-oLLC2+YvQUfAa+vxoufE/yc1icb87M9iXIRqAoR/2EhE/8cb3SF/+Gi0c2By1B+5Vz2e2vQtUvHiu1+63Znh+w==} + + math-intrinsics@1.1.0: + resolution: {integrity: sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==} + engines: {node: '>= 0.4'} + + mdn-data@2.37.2: + resolution: {integrity: sha512-rz9YOBGItdSbe7HcSArUbhiAv4SB/4DKRYg96CSFS2CcIYMbUvBtZlzA1NCbk2AdgbmYwMqwNblLpR441lLeiQ==} + + micromark-core-commonmark@2.0.4: + resolution: {integrity: sha512-wxEeE8v8XVvOrxn1TZj74qYhAtTQsSqufHVS3uNVyT1MupXxhyaHk8/9xDNPh9BmL77QNDgWTkZ3RsYHB2ry7w==} + + micromark-factory-destination@2.0.1: + resolution: {integrity: sha512-Xe6rDdJlkmbFRExpTOmRj9N3MaWmbAgdpSrBQvCFqhezUn4AHqJHbaEnfbVYYiexVSs//tqOdY/DxhjdCiJnIA==} + + micromark-factory-label@2.0.1: + resolution: {integrity: sha512-VFMekyQExqIW7xIChcXn4ok29YE3rnuyveW3wZQWWqF4Nv9Wk5rgJ99KzPvHjkmPXF93FXIbBp6YdW3t71/7Vg==} + + micromark-factory-space@2.1.0: + resolution: {integrity: sha512-fS8hnLIjnjvdQIj39Geug8wWsR0HrYZ43KShKxNfwT7t2LOHo/LbWZEzEaSOjwtjdCsjoE6syHhonEzW0zv0+Q==} + + micromark-factory-title@2.0.1: + resolution: {integrity: sha512-5bZ+3CjhAd9eChYTHsjy6TGxpOFSKgKKJPJxr293jTbfry2KDoWkhBb6TcPVB4NmzaPhMs1Frm9AZH7OD4Cjzw==} + + micromark-factory-whitespace@2.0.1: + resolution: {integrity: sha512-Ob0nuZ3PKt/n0hORHyvoD9uZhr+Za8sFoP+OnMcnWK5lngSzALgQYKMr9RJVOWLqQYuyn6ulqGWSXdwf6F80lQ==} + + micromark-util-character@2.1.1: + resolution: {integrity: sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==} + + micromark-util-chunked@2.0.1: + resolution: {integrity: sha512-QUNFEOPELfmvv+4xiNg2sRYeS/P84pTW0TCgP5zc9FpXetHY0ab7SxKyAQCNCc1eK0459uoLI1y5oO5Vc1dbhA==} + + micromark-util-classify-character@2.0.1: + resolution: {integrity: sha512-K0kHzM6afW/MbeWYWLjoHQv1sgg2Q9EccHEDzSkxiP/EaagNzCm7T/WMKZ3rjMbvIpvBiZgwR3dKMygtA4mG1Q==} + + micromark-util-combine-extensions@2.0.1: + resolution: {integrity: sha512-OnAnH8Ujmy59JcyZw8JSbK9cGpdVY44NKgSM7E9Eh7DiLS2E9RNQf0dONaGDzEG9yjEl5hcqeIsj4hfRkLH/Bg==} + + micromark-util-decode-numeric-character-reference@2.0.2: + resolution: {integrity: sha512-ccUbYk6CwVdkmCQMyr64dXz42EfHGkPQlBj5p7YVGzq8I7CtjXZJrubAYezf7Rp+bjPseiROqe7G6foFd+lEuw==} + + micromark-util-edit-map@1.0.0: + resolution: {integrity: sha512-Pa2ljlsEL6sVwFaYeyrOLSYbQt73JvGbPOYFq+9AElXiSnfI5Q4465RRZ1sHv7lDjDOnGRDDaqPXqClqWK/q1Q==} + + micromark-util-encode@2.0.1: + resolution: {integrity: sha512-c3cVx2y4KqUnwopcO9b/SCdo2O67LwJJ/UyqGfbigahfegL9myoEFoDYZgkT7f36T0bLrM9hZTAaAyH+PCAXjw==} + + micromark-util-html-tag-name@2.0.1: + resolution: {integrity: sha512-2cNEiYDhCWKI+Gs9T0Tiysk136SnR13hhO8yW6BGNyhOC4qYFnwF1nKfD3HFAIXA5c45RrIG1ub11GiXeYd1xA==} + + micromark-util-normalize-identifier@2.0.1: + resolution: {integrity: sha512-sxPqmo70LyARJs0w2UclACPUUEqltCkJ6PhKdMIDuJ3gSf/Q+/GIe3WKl0Ijb/GyH9lOpUkRAO2wp0GVkLvS9Q==} + + micromark-util-resolve-all@2.0.1: + resolution: {integrity: sha512-VdQyxFWFT2/FGJgwQnJYbe1jjQoNTS4RjglmSjTUlpUMa95Htx9NHeYW4rGDJzbjvCsl9eLjMQwGeElsqmzcHg==} + + micromark-util-sanitize-uri@2.0.1: + resolution: {integrity: sha512-9N9IomZ/YuGGZZmQec1MbgxtlgougxTodVwDzzEouPKo3qFWvymFHWcnDi2vzV1ff6kas9ucW+o3yzJK9YB1AQ==} + + micromark-util-subtokenize@2.1.0: + resolution: {integrity: sha512-XQLu552iSctvnEcgXw6+Sx75GflAPNED1qx7eBJ+wydBb2KCbRZe+NwvIEEMM83uml1+2WSXpBAcp9IUCgCYWA==} + + micromark-util-symbol@2.0.1: + resolution: {integrity: sha512-vs5t8Apaud9N28kgCrRUdEed4UJ+wWNvicHLPxCa9ENlYuAY31M0ETy5y1vA33YoNPDFTghEbnh6efaE8h4x0Q==} + + micromark-util-types@2.0.3: + resolution: {integrity: sha512-oxB2Ik03hI0gv+VNn9tnh1t1YEe9MDPptViAEgfdf3YQHsn0pzGTgCdlSCJXcwhqm8phaEuM7zeEu3QQzVBrPg==} + + micromark@4.0.3: + resolution: {integrity: sha512-oGYfQzHSG5dOMovQcJ3fyTmZlWAWpi0XA0sJwJs+i6OT88o1+Jtw/8z0CmdowSLxGhhFK89rQ/oXph/wN02PNw==} + + minimatch@10.2.6: + resolution: {integrity: sha512-vpLQEs+VLCr1nU0BXS07maYoFwlDAH0gngQuuttxIwutDFEMHq2blX+8vpgxDdK3J1PwjCJiep77OitTZ4Ll1A==} + engines: {node: 18 || 20 || >=22} + + minimatch@11.0.8: + resolution: {integrity: sha512-nFQuYSTVrGvysVBps5Ih+0BdnYFN/Cj3C816r6+p7yK+FHrVLGE4O4N9AFwykrlNlvM2HYt+Rad1Uiro6h88Ig==} + engines: {node: 20 || >=22} + + minimatch@3.1.5: + resolution: {integrity: sha512-VgjWUsnnT6n+NUk6eZq77zeFdpW2LWDzP6zFGrCbHXiYNul5Dzqk2HHQ5uFH2DNW5Xbp8+jVzaeNt94ssEEl4w==} + + minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + ms@2.1.3: + resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} + + nanoid@3.3.20: + resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} + engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} + hasBin: true + + napi-postinstall@0.3.8: + resolution: {integrity: sha512-dHbDC5V1g/EI8OLEtL4Iuwbu0fgzmyykxenn2KnlsX9XdhTXL3gWnfbbP+ab+oUcgV6CFpb8QGyQt/ZXA0UXig==} + engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + hasBin: true + + natural-compare@1.4.0: + resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + + node-addon-api@8.9.2: + resolution: {integrity: sha512-VijLXbi3UACN69I0JVXJsX4tjACjNoQDgv2gTF6sx2wWEi8tkSg2eX8p5gSIFi8z2+DL3oHmY6OyKce38SDolg==} + engines: {node: ^18 || ^20 || >= 21} + + node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead + + node-exports-info@1.6.2: + resolution: {integrity: sha512-kXs9Go0cah0qHVV2v389IXQLdLCeE1xfFtjOAF+iobu0OIoG1pje8At2vMHyaPMiPMnG/LWP50twML21eMcAag==} + engines: {node: '>= 0.4'} + + node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + + node-releases@2.0.64: + resolution: {integrity: sha512-zAPCKqMcnqs2nGy6nlkm7JduFseiBJy3EXHGLh+8pFR+TxGCBxxiEN21+UROU5CKwX/f4TlUcYjiM+vs/tsyxw==} + engines: {node: '>=18'} + + non-error@0.1.0: + resolution: {integrity: sha512-TMB1uHiGsHRGv1uYclfhivcnf0/PdFp2pNqRxXjncaAsjYMoisaQJI+SSZCqRq+VliwRTC8tsMQfmrWjDMhkPQ==} + engines: {node: '>=20'} + + object-assign@4.1.1: + resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} + engines: {node: '>=0.10.0'} + + object-inspect@1.13.4: + resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} + engines: {node: '>= 0.4'} + + object-keys@1.1.1: + resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} + engines: {node: '>= 0.4'} + + object.assign@4.1.7: + resolution: {integrity: sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==} + engines: {node: '>= 0.4'} + + object.entries@1.1.9: + resolution: {integrity: sha512-8u/hfXFRBD1O0hPUjioLhoWFHRmt6tKA4/vZPyckBr18l1KE9uHrFaFaUi8MDRTpi4uak2goyPTSNJLXX2k2Hw==} + engines: {node: '>= 0.4'} + + object.fromentries@2.0.8: + resolution: {integrity: sha512-k6E21FzySsSK5a21KRADBd/NGneRegFO5pLHfdQLpRDETUNJueLXs3WCzyQ3tFRDYgbq3KHGXfTbi2bs8WQ6rQ==} + engines: {node: '>= 0.4'} + + object.values@1.2.1: + resolution: {integrity: sha512-gXah6aZrcUxjWg2zR2MwouP2eHlCBzdV4pygudehaKXSGW4v2AsRQUK+lwwXhii6KFZcunEnmSUoYp5CXibxtA==} + engines: {node: '>= 0.4'} + + obug@3.0.0: + resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==} + engines: {node: '>=12.20.0'} + + on-exit-leak-free@2.1.2: + resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==} + engines: {node: '>=14.0.0'} + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + + optionator@0.9.4: + resolution: {integrity: sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==} + engines: {node: '>= 0.8.0'} + + own-keys@1.0.2: + resolution: {integrity: sha512-19YVAg7T+WTrxggPukVq7DjTv6+PJ867TmhCvBsYwmbFCsZd344rq2Ld1p0wo8f8Qrrhgp82c6FJRqdXWtSEhg==} + engines: {node: '>= 0.4'} + + p-limit@3.1.0: + resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} + engines: {node: '>=10'} + + p-locate@5.0.0: + resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} + engines: {node: '>=10'} + + parse5@8.1.1: + resolution: {integrity: sha512-EcR/6WDcU7b2N3vQSxKALCk9lXGtUMQxXio008OEMBE0kavu/7JLfBEeFPzi43nMqVDSbEn3QCK+BMCc9zO//w==} + + path-exists@4.0.0: + resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} + engines: {node: '>=8'} + + path-key@3.1.1: + resolution: {integrity: sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==} + engines: {node: '>=8'} + + path-parse@1.0.7: + resolution: {integrity: sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==} + + pg-boss@12.38.2: + resolution: {integrity: sha512-nvB9hB2cDJGSPUwYjN/Mth+EE3zvxffkp7uKXIiYloMAaxSoEiutmZi9mpSW85hNCcPChf3yicNXdwhIWkv2nA==} + engines: {node: '>=22.12.0'} + hasBin: true + peerDependencies: + '@opentelemetry/api': ^1.9.0 + + pg-cloudflare@1.4.1: + resolution: {integrity: sha512-6PQbsFWZcp9EmJEwy5cGQ2La+AMWpP46lgbb8X+U/XsHIUweYDNCpeuKck5RxL2MdVFi7krbbEi5nX4Zh7JhrQ==} + + pg-connection-string@2.14.1: + resolution: {integrity: sha512-qR3kGNPBLpCNtz0evbKA0Y/MRFXwSSdT+pTJvYp/bXTcReZbvX1kzF0IyTc1QnxqF7AZbOeBhNL8R5mYQZV/MA==} + + pg-int8@1.0.1: + resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} + engines: {node: '>=4.0.0'} + + pg-pool@3.14.0: + resolution: {integrity: sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==} + peerDependencies: + pg: '>=8.0' + + pg-protocol@1.16.1: + resolution: {integrity: sha512-p9VOFMiHB/ZbJATetbg+99PxssTVSQRnyuPSQ67mN1+1KBOjZaZ83ZQzltnxPhJwSsC3nwVjJ10DVJlerbFzLg==} + + pg-types@2.2.0: + resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==} + engines: {node: '>=4'} + + pg@8.23.1: + resolution: {integrity: sha512-aL96AHANtWjPLDOLqnhx+ngp9+UK7ETEU8VJrDCGvsSSi/mGLcWYsS6Herg7lmaBJe4uwrfqsa7gTEFaSizDoQ==} + engines: {node: '>= 16.0.0'} + peerDependencies: + pg-native: '>=3.0.1' + peerDependenciesMeta: + pg-native: + optional: true + + pgpass@1.0.5: + resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} + + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + + picomatch@4.0.7: + resolution: {integrity: sha512-qcJu88Q2IWqJsDD529JKMdwGm/dvInW4HvQnRwiH9JtihJvzGOscDtHE3x1pBKeUOTysQ8kVmLnJ2kJu7yhcGA==} + engines: {node: '>=12'} + + pino-abstract-transport@3.0.0: + resolution: {integrity: sha512-wlfUczU+n7Hy/Ha5j9a/gZNy7We5+cXp8YL+X+PG8S0KXxw7n/JXA3c46Y0zQznIJ83URJiwy7Lh56WLokNuxg==} + + pino-pretty@13.2.0: + resolution: {integrity: sha512-jjghD1ML+Di/WxjJDz6j6Y4FT7hIXOlb8h27AyJ+ohtAXJXH4PS/xkv7si+RCCIW59HMgZsMKTDgzdr0RhuRrg==} + hasBin: true + + pino-std-serializers@7.1.0: + resolution: {integrity: sha512-BndPH67/JxGExRgiX1dX0w1FvZck5Wa4aal9198SrRhZjH3GxKQUKIBnYJTdj2HDN3UQAS06HlfcSbQj2OHmaw==} + + pino@10.4.0: + resolution: {integrity: sha512-bk1ZMTwG/Vymx+zPoa28MhNzucFvXJWp3csrSuxuHPSMeUettaCoQ5Jvg07mtC4JGNpcfTwz41oVCnNgBK9+vA==} + hasBin: true + + pluralize@8.0.0: + resolution: {integrity: sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==} + engines: {node: '>=4'} + + possible-typed-array-names@1.1.0: + resolution: {integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==} + engines: {node: '>= 0.4'} + + postcss@8.5.33: + resolution: {integrity: sha512-RVHEU9/Pp1Fnjr/MpAJsZoADukCKhfIi15OunEYiGktIkYLkPVvC1sioWolGDS7XByMTx9m/IGbro0Js13zhnQ==} + engines: {node: ^10 || ^12 || >=14} + + postgres-array@2.0.0: + resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} + engines: {node: '>=4'} + + postgres-bytea@1.0.1: + resolution: {integrity: sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==} + engines: {node: '>=0.10.0'} + + postgres-date@1.0.7: + resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==} + engines: {node: '>=0.10.0'} + + postgres-interval@1.2.0: + resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} + engines: {node: '>=0.10.0'} + + postgres@3.4.9: + resolution: {integrity: sha512-GD3qdB0x1z9xgFI6cdRD6xu2Sp2WCOEoe3mtnyB5Ee0XrrL5Pe+e4CCnJrRMnL1zYtRDZmQQVbvOttLnKDLnaw==} + engines: {node: '>=12'} + + prelude-ls@1.2.1: + resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} + engines: {node: '>= 0.8.0'} + + prettier@3.10.1: + resolution: {integrity: sha512-70vp3ZUYoPlFbF9uiTdXHUUCGEIp7d4+6p+8DYbkm2jP7x/3i/paXVF6dopSI3zd/CEitrZN1rc4i85xWmmXlg==} + engines: {node: '>=14'} + hasBin: true + + process-warning@5.1.1: + resolution: {integrity: sha512-oCkNVj4OKnKEcocVBcDfiIugN1/cE6rgfT3nCtzeqZPA8+rIxMaQ0xXzIkGP8Gj2qUaP1UR7uhJ1VD8lUCpzCg==} + + prop-types@15.8.1: + resolution: {integrity: sha512-oj87CgZICdulUohogVAR7AjlC0327U4el4L6eAvOqCeudMDVU0NThNaV+b9Df4dXgSP1gXMTnPdhfe/2qDH5cg==} + + pump@3.0.4: + resolution: {integrity: sha512-VS7sjc6KR7e1ukRFhQSY5LM2uBWAUPiOPa/A3mkKmiMwSmRFUITt0xuj+/lesgnCv+dPIEYlkzrcyXgquIHMcA==} + + punycode@2.3.1: + resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} + engines: {node: '>=6'} + + qified@0.10.1: + resolution: {integrity: sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==} + engines: {node: '>=20'} + + qs@6.17.1: + resolution: {integrity: sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==} + engines: {node: '>=0.6'} + + quansync@1.0.0: + resolution: {integrity: sha512-5xZacEEufv3HSTPQuchrvV6soaiACMFnq1H8wkVioctoH3TRha9Sz66lOxRwPK/qZj7HPiSveih9yAyh98gvqA==} + + quick-format-unescaped@4.0.4: + resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} + + quote-js-string@0.1.0: + resolution: {integrity: sha512-Y3NoRtprEEZQD8RfxMCfS0ZTqc4e+i18OrXEXAvpM6TfC/3y+0L5rNbZiSnbBBEkDfFzbpd8o+cE8q3/anjMGA==} + engines: {node: '>=22'} + + react-is@16.13.1: + resolution: {integrity: sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ==} + + real-require@1.0.0: + resolution: {integrity: sha512-P4nbQYQfePJxRSmY+v/KINxVucm4NF3p3s7pJveMTtom52FR4YGltUQLB8idDXwDDWW+eYrWDFbuzUnjoWHF7g==} + + refa@0.12.1: + resolution: {integrity: sha512-J8rn6v4DBb2nnFqkqwy6/NnTYMcgLA+sLr0iIO41qpv0n+ngb7ksag2tMRl0inb1bbO/esUwzW1vbJi7K0sI0g==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + + reflect.getprototypeof@1.0.10: + resolution: {integrity: sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==} + engines: {node: '>= 0.4'} + + regexp-ast-analysis@0.7.1: + resolution: {integrity: sha512-sZuz1dYW/ZsfG17WSAG7eS85r5a0dDsvg+7BiiYR5o6lKCAtUrEwdmRmaGF6rwVj3LcmAeYkOWKEPlbPzN3Y3A==} + engines: {node: ^12.0.0 || ^14.0.0 || >=16.0.0} + + regexp.prototype.flags@1.5.4: + resolution: {integrity: sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==} + engines: {node: '>= 0.4'} + + regjsparser@0.13.4: + resolution: {integrity: sha512-EWV80YgFaVgFrjGCAsV7oybp4GOxbls5RzBg8OB0nKEVXsBJR1JlV8Di1JhCROg3MzTfe1RI8yitIm1eOs68iA==} + hasBin: true + + reserved-identifiers@1.2.0: + resolution: {integrity: sha512-yE7KUfFvaBFzGPs5H3Ops1RevfUEsDc5Iz65rOwWg4lE8HJSYtle77uul3+573457oHvBKuHYDl/xqUkKpEEdw==} + engines: {node: '>=18'} + + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + + resolve@2.0.0-next.7: + resolution: {integrity: sha512-tqt+NBWwyaMgw3zDsnygx4CByWjQEJHOPMdslYhppaQSJUtL/D4JO9CcBBlhPoI8lz9oJIDXkwXfhF4aWqP8xQ==} + engines: {node: '>= 0.4'} + hasBin: true + + rolldown-plugin-dts@0.30.2: + resolution: {integrity: sha512-Q3wRlwawifZeN1llb1BaeZfimmJMF/WHzm7z5ieZ8g2CWHQM0gvVWLYPbgBglsXJqcd405gc+3LS2NzSevbYNQ==} + engines: {node: ^22.18.0 || ^24.11.0 || >=26.0.0} + peerDependencies: + '@volar/typescript': ~2.4.0 + '@vue/language-core': ~3.2.0 || ~3.3.0 + rolldown: ^1.2.0 + tsrs: '*' + typescript: ^5.0.0 || ^6.0.0 || ~7.0.0 || ~7.1.0-0 + vue-tsc: ~3.2.0 || ~3.3.0 + peerDependenciesMeta: + '@volar/typescript': + optional: true + '@vue/language-core': + optional: true + tsrs: + optional: true + typescript: + optional: true + vue-tsc: + optional: true + + rolldown@1.2.19: + resolution: {integrity: sha512-QIiV1J9d0pzN4jeeTH4sjPy0AZ6cAy2cG0ExeoE1+U8Rvj+hR3gYkokx0YbeUNGlZqiQJJ2utcETe0oKXwzsuA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + rolldown@1.3.2: + resolution: {integrity: sha512-EFHqbVkXiYZA6akmYm2bvJhNbEGdUwAResRhYwl/BO8QhB5KxsG+t3RVHJSIOy5jBEb0XCACvrIGnnl6Z8sMGA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + + rrule-temporal@2.2.9: + resolution: {integrity: sha512-5Bc+IxlGKZtOF/JtkM+39VtK9uYvg1NRWGzZCy2QQj9KFZ4mMMa949GMtGv0Ud/bzyk2KuGhwxmVDuq8cnbzuA==} + + safe-array-concat@1.1.4: + resolution: {integrity: sha512-wtZlHyOje6OZTGqAoaDKxFkgRtkF9CnHAVnCHKfuj200wAgL+bSJhdsCD2l0Qx/2ekEXjPWcyKkfGb5CPboslg==} + engines: {node: '>=0.4'} + + safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + + safe-push-apply@1.0.0: + resolution: {integrity: sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==} + engines: {node: '>= 0.4'} + + safe-regex-test@1.1.0: + resolution: {integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==} + engines: {node: '>= 0.4'} + + safe-stable-stringify@2.5.0: + resolution: {integrity: sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==} + engines: {node: '>=10'} + + scslre@0.3.0: + resolution: {integrity: sha512-3A6sD0WYP7+QrjbfNA2FN3FsOaGGFoekCVgTyypy53gPxhbkCIjtO6YWgdrfM+n/8sI8JeXZOIxsHjMTNxQ4nQ==} + engines: {node: ^14.0.0 || >=16.0.0} + + secure-json-parse@4.1.1: + resolution: {integrity: sha512-lnd81MQEZKjhW/Gd2TQqdd4XP6QYNdDW/EP+I7nTrFHP9y2LmaGPIHk9xsnzcOiEr1c39c/e84xFgGviQKBTRw==} + + semver@6.3.2: + resolution: {integrity: sha512-GYrCADwpu6yV5OAvchkQ27Z5wwMxWAEMg5NNWjyHh/5DboFFqbdbvYNIvZouQpxXyeMPoTOh0vdPYKlf0ZswdQ==} + hasBin: true + + semver@7.8.6: + resolution: {integrity: sha512-9lpSSU4Mly3mrtruwLs1eLK6+gzbzqeBFwRNjIjE+9LuDpWdYctrQlQ3ej1Ilgi7gknpsTRnPoLP8DpCHqHIJw==} + engines: {node: '>=10'} + hasBin: true + + serialize-error@13.1.0: + resolution: {integrity: sha512-FT1EL2Pz7lAWA48I6Qb1qHEvGT9ZGz2pb1sYZ9Dhu2t+RmHN6O12WMu7HzFcqFRQaUWEl3Q+++EYBTrZpCoykQ==} + engines: {node: '>=20'} + + set-function-length@1.2.2: + resolution: {integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==} + engines: {node: '>= 0.4'} + + set-function-name@2.0.2: + resolution: {integrity: sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==} + engines: {node: '>= 0.4'} + + set-proto@1.0.0: + resolution: {integrity: sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==} + engines: {node: '>= 0.4'} + + shebang-command@2.0.0: + resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} + engines: {node: '>=8'} + + shebang-regex@3.0.0: + resolution: {integrity: sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==} + engines: {node: '>=8'} + + side-channel-list@1.0.1: + resolution: {integrity: sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==} + engines: {node: '>= 0.4'} + + side-channel-map@1.0.1: + resolution: {integrity: sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==} + engines: {node: '>= 0.4'} + + side-channel-weakmap@1.0.2: + resolution: {integrity: sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==} + engines: {node: '>= 0.4'} + + side-channel@1.1.1: + resolution: {integrity: sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==} + engines: {node: '>= 0.4'} + + sonic-boom@4.2.1: + resolution: {integrity: sha512-w6AxtubXa2wTXAUsZMMWERrsIRAdrK0Sc+FUytWvYAhBJLyuI4llrMIC1DtlNSdI99EI86KZum2MMq3EAZlF9Q==} + + sonic-boom@5.0.2: + resolution: {integrity: sha512-/JEruzo6yhNVhsLblTRchgTQHIt7SsdJP0YyrfWaNKjIOQDfrdZv9gwYraYCAsmKV39/LAdV31FLL5NCDpoL/A==} + + source-map-js@1.2.2: + resolution: {integrity: sha512-KGj/8Y43x35aZVDtt+J4mK1hoLGHULMYfSkODJNQjNDC3oW1PqPoxMwo0pLUsWM/UEGzON/NxeHywEfNXNP3Vw==} + engines: {node: '>=0.10.0'} + + source-map-support@0.5.21: + resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} + + source-map@0.6.1: + resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} + engines: {node: '>=0.10.0'} + + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + + stable-hash-x@0.2.0: + resolution: {integrity: sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==} + engines: {node: '>=12.0.0'} + + std-env@4.3.0: + resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} + + stop-iteration-iterator@1.1.0: + resolution: {integrity: sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==} + engines: {node: '>= 0.4'} + + string.prototype.matchall@4.1.0: + resolution: {integrity: sha512-tHNHTxInrYLCga9O9YGxWA3G9/nnzQw8UGAyqGx3Ar1pSTTzIuM4woFSq4SowkXCjJIwq5sIiQvEfRI9tCH1qQ==} + engines: {node: '>= 0.4'} + + string.prototype.repeat@1.0.0: + resolution: {integrity: sha512-0u/TldDbKD8bFCQ/4f5+mNRrXwZ8hg2w7ZR8wa16e8z9XpePWl3eGEcUD0OXpEH/VJH/2G3gjUtR3ZOiBe2S/w==} + + string.prototype.trim@1.2.11: + resolution: {integrity: sha512-PwvK7BU+CMTJGYQCTZb5RWXIML92lftJLhQz1tBzgKiqGxJaMlBAa48POXaNAC2s4y8jr3EFqrkF9+44neS46w==} + engines: {node: '>= 0.4'} + + string.prototype.trimend@1.0.10: + resolution: {integrity: sha512-2+3aDAOmPTmuFwjDnmJG2ctEkQKVki7vOSqaxkv42Mowj1V6PnvuwFCRrR5lChUux1TBskPjfkeTOhqczDMxTw==} + engines: {node: '>= 0.4'} + + string.prototype.trimstart@1.0.8: + resolution: {integrity: sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==} + engines: {node: '>= 0.4'} + + strip-indent@4.1.1: + resolution: {integrity: sha512-SlyRoSkdh1dYP0PzclLE7r0M9sgbFKKMFXpFRUMNuKhQSbC6VQIGzq3E0qsfvGJaUFJPGv6Ws1NZ/haTAjfbMA==} + engines: {node: '>=12'} + + strip-json-comments@5.1.0: + resolution: {integrity: sha512-ErcwpJBYr8EfX/Br7JauOIGXoRE92w0hVtuS9j92UFgbATxA+WRSIZksSUDzEeItfWB/0QCEprTZT55RSINUHQ==} + engines: {node: '>=22'} + + supports-preserve-symlinks-flag@1.0.0: + resolution: {integrity: sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==} + engines: {node: '>= 0.4'} + + tagged-tag@1.0.0: + resolution: {integrity: sha512-yEFYrVhod+hdNyx7g5Bnkkb0G6si8HJurOoOEgC8B/O0uXLHlaey/65KRv6cuWBNhBgHKAROVpc7QyYqE5gFng==} + engines: {node: '>=20'} + + temporal-spec@1.0.1: + resolution: {integrity: sha512-wxVoanmDeavXie1vu2JaQ3WIc3JZnWAOYFBsJyATaVsXsycKYUflGsyBmrRSnoCpZJpwPyr38VpgSUlQ8CbFxg==} + + thread-stream@4.2.1: + resolution: {integrity: sha512-Stg6edJXC/6/xqGwSXwFokrUhChJ18amEjpKH89WrQQ0oVFDF+pUUcTpiwWhFUrE89Vf16FBOlwhaw+lescxMQ==} + engines: {node: '>=20'} + + tinybench@6.2.3: + resolution: {integrity: sha512-Al01C2JIBnO2CXCAPbpAl6sUiOZHeThGtHYNTa51JRw9PyWOCdr+9Ong05R4qg/Sk3+H645E8ov1h2c58ityNw==} + engines: {node: '>=20.0.0'} + + tinyexec@1.3.1: + resolution: {integrity: sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==} + engines: {node: '>=18'} + + tinyglobby@0.2.17: + resolution: {integrity: sha512-wXR/dYpcqKmfWpEdZjiKJOwCNFndD0DMnrW/cYjVGttEkBfVgcLFHoNrlj47mjOVic9yyNu65alsgF4NQyTa2g==} + engines: {node: '>=12.0.0'} + + tinyps@0.5.2: + resolution: {integrity: sha512-sYhvdbpuo2rGE7u/jPUMiZz4H2LCaOodUtRD9ot4DLNFQbr884g9zozoJnxLI+1r4hXqWkmdHUl8Yig2Rllxxw==} + + tmdb-ts@2.3.0: + resolution: {integrity: sha512-j7V85Gs8+fsSDOYmsChjCLn//ouxrwdWqlUUwKOM518PIcBU8VBS4YN/Lh2KJiLjEICHjYjv2SRvhMWn1Tdk4w==} + engines: {node: '>=20.0.0'} + + ts-api-utils@2.5.0: + resolution: {integrity: sha512-OJ/ibxhPlqrMM0UiNHJ/0CKQkoKF243/AEmplt3qpRgkW8VG7IfOS41h7V8TjITqdByHzrjcS/2si+y4lIh8NA==} + engines: {node: '>=18.12'} + peerDependencies: + typescript: '>=4.8.4' + + ts-mixer@6.0.4: + resolution: {integrity: sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==} + + tsdown@0.23.7: + resolution: {integrity: sha512-w9nmWyEimfqQ7/HpVeKTldAeBvWGXiaWyNP7xaxSrr0GhKxsngEyTWqk1nOruRqvqRSkdpMMkpV2BcoWfLB4Uw==} + engines: {node: ^22.18.0 || ^24.11.0 || >=26.0.0} + hasBin: true + peerDependencies: + '@arethetypeswrong/core': ^0.18.1 + '@tsdown/css': 0.23.7 + '@tsdown/exe': 0.23.7 + '@vitejs/devtools': '*' + publint: ^0.3.8 + tsx: '*' + typescript: ^5.0.0 || ^6.0.0 || ^7.0.0 + unplugin-unused: '>=0.5.0' + unrun: '*' + peerDependenciesMeta: + '@arethetypeswrong/core': + optional: true + '@tsdown/css': + optional: true + '@tsdown/exe': + optional: true + '@vitejs/devtools': + optional: true + publint: + optional: true + tsx: + optional: true + typescript: + optional: true + unplugin-unused: + optional: true + unrun: + optional: true + + tslib@2.9.1: + resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==} + + tsx@4.23.15: + resolution: {integrity: sha512-Yiex1Ovn8z2xPpOWckIiysV1SSyRMY9BkLF++q0yKiDxCqRhosKfMg3janKkiLBwZ5c/YryloKwGZcrEmtwxKw==} + engines: {node: '>=18.0.0'} + hasBin: true + + type-check@0.4.0: + resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} + engines: {node: '>= 0.8.0'} + + type-fest@5.10.0: + resolution: {integrity: sha512-NoSdpq/WEiAg5sjmBkmV/hfxv6HJH4NqPNrqjtSO5CwRmpsDfaf4begxW34KdJykH/l1yHtwBWQkCRdoXO8mPA==} + engines: {node: '>=20'} + + typed-array-buffer@1.0.3: + resolution: {integrity: sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==} + engines: {node: '>= 0.4'} + + typed-array-byte-length@1.0.3: + resolution: {integrity: sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==} + engines: {node: '>= 0.4'} + + typed-array-byte-offset@1.0.5: + resolution: {integrity: sha512-0FHJvLPqZ7KJzp17O13jfsAjsqazgrxBu2zEK95PmUz8lv2+GjRuxUInCr2Rk9Dms3ihN21zJ929ZO43yJ95QQ==} + engines: {node: '>= 0.4'} + + typed-array-length@1.0.8: + resolution: {integrity: sha512-phPGCwqr2+Qo0fwniCE8e4pKnGu/yFb5nD5Y8bf0EEeiI5GklnACYA9GFy/DrAeRrKHXvHn+1SUsOWgJp6RO+g==} + engines: {node: '>= 0.4'} + + typescript-eslint@8.72.2: + resolution: {integrity: sha512-c/+AKMW1KB81r28Sp0AAdcyXj5dzNmAsZFcsrxKbZTKmcBK2xIwBR31dcSYSDu3bKmzXe8GKrSxO+eDQ401Uzg==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + eslint: ^8.57.0 || ^9.0.0 || ^10.0.0 + typescript: '>=4.8.4 <6.1.0' + + typescript@6.0.3: + resolution: {integrity: sha512-y2TvuxSZPDyQakkFRPZHKFm+KKVqIisdg9/CZwm9ftvKXLP8NRWj38/ODjNbr43SsoXqNuAisEf1GdCxqWcdBw==} + engines: {node: '>=14.17'} + hasBin: true + + unbox-primitive@1.1.0: + resolution: {integrity: sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==} + engines: {node: '>= 0.4'} + + unconfig-core@7.5.0: + resolution: {integrity: sha512-Su3FauozOGP44ZmKdHy2oE6LPjk51M/TRRjHv2HNCWiDvfvCoxC2lno6jevMA91MYAdCdwP05QnWdWpSbncX/w==} + + undici-types@7.24.6: + resolution: {integrity: sha512-WRNW+sJgj5OBN4/0JpHFqtqzhpbnV0GuB+OozA9gCL7a993SmU+1JBZCzLNxYsbMfIeDL+lTsphD5jN5N+n0zg==} + + undici@6.29.1: + resolution: {integrity: sha512-EvRlUt/QqAEvXdQeRMYUfwOQsfzpDztykrG2owGEE/rBOBoYv9uF39ZzsNDh4lTFHhTr2XOZjKkYgueD12ZmGA==} + engines: {node: '>=18.17'} + + unrs-resolver@1.13.0: + resolution: {integrity: sha512-mcPQo9Vm6kXd84d/WqMiYBi2CcA57QHBX/ev5PoUEb8b2oQzUvJ6xYsfseQblnCncgnVmCZGWiFwK7KkS5JZJA==} + + update-browserslist-db@1.3.4: + resolution: {integrity: sha512-t8wonIOdQyOjtPd2VktlBu6QjTVTks6v8bSi7kd0r2Vll8TK1JYDZtRRdbmCHOAMphkZgrzK+L+vXK4pyZ8t4A==} + hasBin: true + peerDependencies: + browserslist: '>= 4.21.0' + + uri-js@4.4.1: + resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} + + url-template@2.0.8: + resolution: {integrity: sha512-XdVKMF4SJ0nP/O7XIPB0JwAEuT9lDIYnNsK8yGVe43y0AWoKeJNdv3ZNWh7ksJ6KqQFjOO6ox/VEitLnaVNufw==} + + verkit@0.5.0: + resolution: {integrity: sha512-u4J1hr6Y+C/hit34GwL3eIcUf3wngT8TlYUjK7tk0jxydKLAq3sYvifjdTDA6U3KCKRcQCQDGf/srjxfZF3l7g==} + engines: {node: '>=18.12.0'} + + vite@8.3.8: + resolution: {integrity: sha512-LzOn3h9rG/0vhLdXrV4yJ4QFA9eEoqCl+Yx+kGJd7aB9w6nfNgVHKSYwLPZUHrz4ZGa+t+kXjV9itvcHDLQouA==} + engines: {node: ^20.19.0 || >=22.12.0} + hasBin: true + 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 + + vitest@5.1.0: + resolution: {integrity: sha512-MzmNFnrwa8v8lF1bLxw3UJ4EREwVOVb75VqJZmUDRjJ6EluK/x9th7qTbaeDk41WxE1GxWqmTXcdsfobfH5sOA==} + engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0} + hasBin: true + 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 + + web-streams-polyfill@3.3.3: + resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} + engines: {node: '>= 8'} + + which-boxed-primitive@1.1.1: + resolution: {integrity: sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==} + engines: {node: '>= 0.4'} + + which-builtin-type@1.2.1: + resolution: {integrity: sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==} + engines: {node: '>= 0.4'} + + which-collection@1.0.2: + resolution: {integrity: sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==} + engines: {node: '>= 0.4'} + + which-typed-array@1.1.24: + resolution: {integrity: sha512-wk4Mf4pR5mRP7eYuuTBCIQ9d0ud2Fv2jRLQpfgnRjbOxAFHmjKFValgTpitVKzJJS8ajnYQV2Du1SZ8j6b/EUQ==} + engines: {node: '>= 0.4'} + + which@2.0.2: + resolution: {integrity: sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==} + engines: {node: '>= 8'} + hasBin: true + + why-is-node-running@3.2.1: + resolution: {integrity: sha512-Tb2FUhB4vUsGQlfSquQLYkApkuPAFQXGFzxWKHHumVz2dK+X1RUm/HnID4+TfIGYJ1kTcwOaCk/buYCEJr6YjQ==} + engines: {node: '>=20.11'} + hasBin: true + + word-wrap@1.2.5: + resolution: {integrity: sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==} + engines: {node: '>=0.10.0'} + + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + + ws@8.23.0: + resolution: {integrity: sha512-wCkmX8QMOrKjgO8HW2WyDbTSGeqkocxgDzS9iR79rEAexty6/2qzilx3Ag8Tqf9ykop3irLKle0MtVn5qjVnoQ==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + + xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + + yaml@2.9.1: + resolution: {integrity: sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDsWxv7Y7mcDsT/oOmgW8BpyQQFFBnvZE3j9Y2Sdz1ULFLezL7Eb2yFw==} + engines: {node: '>= 14.6'} + hasBin: true + + yocto-queue@0.1.0: + resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} + engines: {node: '>=10'} + + yuku@0.28.0: + resolution: {integrity: sha512-vzuml0lBwq8gYUujhLZn9AZwgPG1yPF1081ceOkTnEIM9bwgRnFUGAW5x2hTLC+qGI/iqu9PLs5Jko6rUn7YDA==} + engines: {node: '>=16.4.0'} + peerDependencies: + '@yuku-toolchain/wasm': 0.28.0 + peerDependenciesMeta: + '@yuku-toolchain/wasm': + optional: true + + zod@4.6.7: + resolution: {integrity: sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==} + +snapshots: + + '@cacheable/memory@2.2.0': + dependencies: + '@cacheable/utils': 2.5.0 + '@keyv/bigmap': 1.3.1(keyv@5.6.0) + hookified: 1.15.1 + keyv: 5.6.0 + + '@cacheable/utils@2.5.0': + dependencies: + hashery: 1.5.1 + keyv: 5.6.0 + + '@date-fns/tz@1.5.0': {} + + '@discordjs/builders@1.15.0': + dependencies: + '@discordjs/formatters': 0.6.2 + '@discordjs/util': 1.2.0 + '@sapphire/shapeshift': 4.0.0 + discord-api-types: 0.38.59 + fast-deep-equal: 3.1.3 + ts-mixer: 6.0.4 + tslib: 2.9.1 + + '@discordjs/collection@1.5.3': {} + + '@discordjs/collection@2.1.1': {} + + '@discordjs/formatters@0.6.2': + dependencies: + discord-api-types: 0.38.59 + + '@discordjs/rest@2.6.3': + dependencies: + '@discordjs/collection': 2.1.1 + '@discordjs/util': 1.2.0 + '@sapphire/async-queue': 1.5.5 + '@sapphire/snowflake': 3.5.5 + '@vladfrangu/async_event_emitter': 2.4.7 + discord-api-types: 0.38.59 + magic-bytes.js: 1.13.1 + tslib: 2.9.1 + undici: 6.29.1 + + '@discordjs/util@1.2.0': + dependencies: + discord-api-types: 0.38.59 + + '@discordjs/ws@1.2.3': + dependencies: + '@discordjs/collection': 2.1.1 + '@discordjs/rest': 2.6.3 + '@discordjs/util': 1.2.0 + '@sapphire/async-queue': 1.5.5 + '@types/ws': 8.18.2 + '@vladfrangu/async_event_emitter': 2.4.7 + discord-api-types: 0.38.59 + tslib: 2.9.1 + ws: 8.23.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@drizzle-team/brocli@0.10.2': {} + + '@emnapi/core@2.0.0-beta.2': + dependencies: + '@emnapi/wasi-threads': 2.2.0 + tslib: 2.9.1 + optional: true + + '@emnapi/runtime@2.0.0-beta.2': + dependencies: + tslib: 2.9.1 + optional: true + + '@emnapi/wasi-threads@2.2.0': + dependencies: + tslib: 2.9.1 + optional: true + + '@esbuild-kit/core-utils@3.3.2': + dependencies: + esbuild: 0.18.20 + source-map-support: 0.5.21 + + '@esbuild-kit/esm-loader@2.6.5': + dependencies: + '@esbuild-kit/core-utils': 3.3.2 + get-tsconfig: 4.14.3 + + '@esbuild/aix-ppc64@0.25.12': + optional: true + + '@esbuild/aix-ppc64@0.28.2': + optional: true + + '@esbuild/android-arm64@0.18.20': + optional: true + + '@esbuild/android-arm64@0.25.12': + optional: true + + '@esbuild/android-arm64@0.28.2': + optional: true + + '@esbuild/android-arm@0.18.20': + optional: true + + '@esbuild/android-arm@0.25.12': + optional: true + + '@esbuild/android-arm@0.28.2': + optional: true + + '@esbuild/android-x64@0.18.20': + optional: true + + '@esbuild/android-x64@0.25.12': + optional: true + + '@esbuild/android-x64@0.28.2': + optional: true + + '@esbuild/darwin-arm64@0.18.20': + optional: true + + '@esbuild/darwin-arm64@0.25.12': + optional: true + + '@esbuild/darwin-arm64@0.28.2': + optional: true + + '@esbuild/darwin-x64@0.18.20': + optional: true + + '@esbuild/darwin-x64@0.25.12': + optional: true + + '@esbuild/darwin-x64@0.28.2': + optional: true + + '@esbuild/freebsd-arm64@0.18.20': + optional: true + + '@esbuild/freebsd-arm64@0.25.12': + optional: true + + '@esbuild/freebsd-arm64@0.28.2': + optional: true + + '@esbuild/freebsd-x64@0.18.20': + optional: true + + '@esbuild/freebsd-x64@0.25.12': + optional: true + + '@esbuild/freebsd-x64@0.28.2': + optional: true + + '@esbuild/linux-arm64@0.18.20': + optional: true + + '@esbuild/linux-arm64@0.25.12': + optional: true + + '@esbuild/linux-arm64@0.28.2': + optional: true + + '@esbuild/linux-arm@0.18.20': + optional: true + + '@esbuild/linux-arm@0.25.12': + optional: true + + '@esbuild/linux-arm@0.28.2': + optional: true + + '@esbuild/linux-ia32@0.18.20': + optional: true + + '@esbuild/linux-ia32@0.25.12': + optional: true + + '@esbuild/linux-ia32@0.28.2': + optional: true + + '@esbuild/linux-loong64@0.18.20': + optional: true + + '@esbuild/linux-loong64@0.25.12': + optional: true + + '@esbuild/linux-loong64@0.28.2': + optional: true + + '@esbuild/linux-mips64el@0.18.20': + optional: true + + '@esbuild/linux-mips64el@0.25.12': + optional: true + + '@esbuild/linux-mips64el@0.28.2': + optional: true + + '@esbuild/linux-ppc64@0.18.20': + optional: true + + '@esbuild/linux-ppc64@0.25.12': + optional: true + + '@esbuild/linux-ppc64@0.28.2': + optional: true + + '@esbuild/linux-riscv64@0.18.20': + optional: true + + '@esbuild/linux-riscv64@0.25.12': + optional: true + + '@esbuild/linux-riscv64@0.28.2': + optional: true + + '@esbuild/linux-s390x@0.18.20': + optional: true + + '@esbuild/linux-s390x@0.25.12': + optional: true + + '@esbuild/linux-s390x@0.28.2': + optional: true + + '@esbuild/linux-x64@0.18.20': + optional: true + + '@esbuild/linux-x64@0.25.12': + optional: true + + '@esbuild/linux-x64@0.28.2': + optional: true + + '@esbuild/netbsd-arm64@0.25.12': + optional: true + + '@esbuild/netbsd-arm64@0.28.2': + optional: true + + '@esbuild/netbsd-x64@0.18.20': + optional: true + + '@esbuild/netbsd-x64@0.25.12': + optional: true + + '@esbuild/netbsd-x64@0.28.2': + optional: true + + '@esbuild/openbsd-arm64@0.25.12': + optional: true + + '@esbuild/openbsd-arm64@0.28.2': + optional: true + + '@esbuild/openbsd-x64@0.18.20': + optional: true + + '@esbuild/openbsd-x64@0.25.12': + optional: true + + '@esbuild/openbsd-x64@0.28.2': + optional: true + + '@esbuild/openharmony-arm64@0.25.12': + optional: true + + '@esbuild/openharmony-arm64@0.28.2': + optional: true + + '@esbuild/sunos-x64@0.18.20': + optional: true + + '@esbuild/sunos-x64@0.25.12': + optional: true + + '@esbuild/sunos-x64@0.28.2': + optional: true + + '@esbuild/win32-arm64@0.18.20': + optional: true + + '@esbuild/win32-arm64@0.25.12': + optional: true + + '@esbuild/win32-arm64@0.28.2': + optional: true + + '@esbuild/win32-ia32@0.18.20': + optional: true + + '@esbuild/win32-ia32@0.25.12': + optional: true + + '@esbuild/win32-ia32@0.28.2': + optional: true + + '@esbuild/win32-x64@0.18.20': + optional: true + + '@esbuild/win32-x64@0.25.12': + optional: true + + '@esbuild/win32-x64@0.28.2': + optional: true + + '@eslint-community/eslint-utils@4.10.1(eslint@10.15.0(jiti@2.7.0))': + dependencies: + eslint: 10.15.0(jiti@2.7.0) + eslint-visitor-keys: 3.4.3 + + '@eslint-community/regexpp@4.12.3': {} + + '@eslint/config-array@0.23.6': + dependencies: + '@eslint/object-schema': 3.0.5 + debug: 4.4.3 + minimatch: 11.0.8 + transitivePeerDependencies: + - supports-color + + '@eslint/config-helpers@0.7.0': + dependencies: + '@eslint/core': 1.2.1 + + '@eslint/core@1.2.1': + dependencies: + '@types/json-schema': 7.0.15 + + '@eslint/css-tree@4.1.2': + dependencies: + mdn-data: 2.37.2 + source-map-js: 1.2.2 + + '@eslint/js@10.0.1(eslint@10.15.0(jiti@2.7.0))': + optionalDependencies: + eslint: 10.15.0(jiti@2.7.0) + + '@eslint/object-schema@3.0.5': {} + + '@eslint/plugin-kit@0.7.3': + dependencies: + '@eslint/core': 1.2.1 + levn: 0.4.1 + + '@googleapis/calendar@20.2.0': + dependencies: + googleapis-common: 9.3.1 + transitivePeerDependencies: + - supports-color + + '@hono/node-server@2.1.8(hono@4.13.18)': + dependencies: + hono: 4.13.18 + + '@hono/oauth-providers@0.9.1(hono@4.13.18)': + dependencies: + hono: 4.13.18 + + '@humanfs/core@0.19.2': + dependencies: + '@humanfs/types': 0.15.0 + + '@humanfs/node@0.16.8': + dependencies: + '@humanfs/core': 0.19.2 + '@humanfs/types': 0.15.0 + '@humanwhocodes/retry': 0.4.3 + + '@humanfs/types@0.15.0': {} + + '@humanwhocodes/module-importer@1.0.1': {} + + '@humanwhocodes/retry@0.4.3': {} + + '@isaacs/nonrecursive-glob-match@1.1.0': {} + + '@jridgewell/resolve-uri@3.1.3': {} + + '@jridgewell/sourcemap-codec@1.6.0': {} + + '@jridgewell/trace-mapping@0.3.31': + dependencies: + '@jridgewell/resolve-uri': 3.1.3 + '@jridgewell/sourcemap-codec': 1.6.0 + + '@keyv/bigmap@1.3.1(keyv@5.6.0)': + dependencies: + hashery: 1.5.1 + hookified: 1.15.1 + keyv: 5.6.0 + + '@keyv/serialize@1.1.1': {} + + '@napi-rs/wasm-runtime@1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2)': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@tybys/wasm-util': 0.10.4 + optional: true + + '@opentelemetry/api@1.10.0': {} + + '@oxc-project/types@0.156.0': {} + + '@oxc-project/types@0.158.0': {} + + '@pinojs/redact@0.4.0': {} + + '@quansync/fs@1.1.0': + dependencies: + quansync: 1.0.0 + + '@rolldown/binding-android-arm-eabi@1.2.19': + optional: true + + '@rolldown/binding-android-arm-eabi@1.3.2': + optional: true + + '@rolldown/binding-android-arm64@1.2.19': + optional: true + + '@rolldown/binding-android-arm64@1.3.2': + optional: true + + '@rolldown/binding-darwin-arm64@1.2.19': + optional: true + + '@rolldown/binding-darwin-arm64@1.3.2': + optional: true + + '@rolldown/binding-darwin-x64@1.2.19': + optional: true + + '@rolldown/binding-darwin-x64@1.3.2': + optional: true + + '@rolldown/binding-freebsd-x64@1.2.19': + optional: true + + '@rolldown/binding-freebsd-x64@1.3.2': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.2.19': + optional: true + + '@rolldown/binding-linux-arm-gnueabihf@1.3.2': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-gnu@1.3.2': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.2.19': + optional: true + + '@rolldown/binding-linux-arm64-musl@1.3.2': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-ppc64-gnu@1.3.2': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-s390x-gnu@1.3.2': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-gnu@1.3.2': + optional: true + + '@rolldown/binding-linux-x64-musl@1.2.19': + optional: true + + '@rolldown/binding-linux-x64-musl@1.3.2': + optional: true + + '@rolldown/binding-openharmony-arm64@1.2.19': + optional: true + + '@rolldown/binding-openharmony-arm64@1.3.2': + optional: true + + '@rolldown/binding-wasm32-wasi@1.2.19': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) + optional: true + + '@rolldown/binding-wasm32-wasi@1.3.2': + dependencies: + '@emnapi/core': 2.0.0-beta.2 + '@emnapi/runtime': 2.0.0-beta.2 + '@napi-rs/wasm-runtime': 1.2.6(@emnapi/core@2.0.0-beta.2)(@emnapi/runtime@2.0.0-beta.2) + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.2.19': + optional: true + + '@rolldown/binding-win32-arm64-msvc@1.3.2': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.2.19': + optional: true + + '@rolldown/binding-win32-x64-msvc@1.3.2': + optional: true + + '@rolldown/pluginutils@1.1.1': {} + + '@sapphire/async-queue@1.5.5': {} + + '@sapphire/shapeshift@4.0.0': + dependencies: + fast-deep-equal: 3.1.3 + lodash: 4.18.1 + + '@sapphire/snowflake@3.5.5': {} + + '@sonarsource/analyzer-commons-configurations@2.31.0-5284': {} + + '@stylistic/eslint-plugin@6.0.0(eslint@10.15.0(jiti@2.7.0))': + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0(jiti@2.7.0)) + '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/visitor-keys': 8.72.2 + espree: 11.2.0 + picomatch: 4.0.7 + optionalDependencies: + eslint: 10.15.0(jiti@2.7.0) + + '@total-typescript/ts-reset@0.6.1': {} + + '@tybys/wasm-util@0.10.4': + dependencies: + tslib: 2.9.1 + optional: true + + '@types/better-sqlite3@9.6.0': + dependencies: + '@types/node': 24.19.2 + + '@types/chai@5.2.3': + dependencies: + '@types/deep-eql': 4.0.2 + assertion-error: 2.0.1 + + '@types/debug@4.1.13': + dependencies: + '@types/ms': 2.1.0 + + '@types/deep-eql@4.0.2': {} + + '@types/esrecurse@4.3.1': {} + + '@types/estree@1.0.10': {} + + '@types/json-schema@7.0.15': {} + + '@types/ms@2.1.0': {} + + '@types/node@24.19.2': + dependencies: + undici-types: 7.24.6 + + '@types/ws@8.18.2': + dependencies: + '@types/node': 24.19.2 + + '@typescript-eslint/eslint-plugin@8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3)': + dependencies: + '@eslint-community/regexpp': 4.12.3 + '@typescript-eslint/parser': 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + '@typescript-eslint/scope-manager': 8.72.2 + '@typescript-eslint/type-utils': 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + '@typescript-eslint/utils': 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + '@typescript-eslint/visitor-keys': 8.72.2 + eslint: 10.15.0(jiti@2.7.0) + ignore: 7.0.14 + natural-compare: 1.4.0 + ts-api-utils: 2.5.0(typescript@6.0.3) + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/parser@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3)': + dependencies: + '@typescript-eslint/scope-manager': 8.72.2 + '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) + '@typescript-eslint/visitor-keys': 8.72.2 + debug: 4.4.3 + eslint: 10.15.0(jiti@2.7.0) + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/project-service@8.72.2(typescript@6.0.3)': + dependencies: + '@typescript-eslint/tsconfig-utils': 8.72.2(typescript@6.0.3) + '@typescript-eslint/types': 8.72.2 + debug: 4.4.3 + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/scope-manager@8.72.2': + dependencies: + '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/visitor-keys': 8.72.2 + + '@typescript-eslint/tsconfig-utils@8.72.2(typescript@6.0.3)': + dependencies: + typescript: 6.0.3 + + '@typescript-eslint/type-utils@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3)': + dependencies: + '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) + '@typescript-eslint/utils': 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + debug: 4.4.3 + eslint: 10.15.0(jiti@2.7.0) + ts-api-utils: 2.5.0(typescript@6.0.3) + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/types@8.72.2': {} + + '@typescript-eslint/typescript-estree@8.72.2(typescript@6.0.3)': + dependencies: + '@typescript-eslint/project-service': 8.72.2(typescript@6.0.3) + '@typescript-eslint/tsconfig-utils': 8.72.2(typescript@6.0.3) + '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/visitor-keys': 8.72.2 + debug: 4.4.3 + minimatch: 10.2.6 + semver: 7.8.6 + tinyglobby: 0.2.17 + ts-api-utils: 2.5.0(typescript@6.0.3) + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/utils@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3)': + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0(jiti@2.7.0)) + '@typescript-eslint/scope-manager': 8.72.2 + '@typescript-eslint/types': 8.72.2 + '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) + eslint: 10.15.0(jiti@2.7.0) + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + '@typescript-eslint/visitor-keys@8.72.2': + dependencies: + '@typescript-eslint/types': 8.72.2 + eslint-visitor-keys: 5.0.1 + + '@unrs/resolver-binding-android-arm-eabi@1.13.0': + optional: true + + '@unrs/resolver-binding-android-arm64@1.13.0': + optional: true + + '@unrs/resolver-binding-darwin-arm64@1.13.0': + optional: true + + '@unrs/resolver-binding-darwin-x64@1.13.0': + optional: true + + '@unrs/resolver-binding-freebsd-x64@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-arm-gnueabihf@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-arm-musleabihf@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-arm64-gnu@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-arm64-musl@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-loong64-gnu@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-loong64-musl@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-ppc64-gnu@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-riscv64-gnu@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-riscv64-musl@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-s390x-gnu@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-x64-gnu@1.13.0': + optional: true + + '@unrs/resolver-binding-linux-x64-musl@1.13.0': + optional: true + + '@unrs/resolver-binding-openharmony-arm64@1.13.0': + optional: true + + '@unrs/resolver-binding-win32-arm64-msvc@1.13.0': + optional: true + + '@unrs/resolver-binding-win32-ia32-msvc@1.13.0': + optional: true + + '@unrs/resolver-binding-win32-x64-msvc@1.13.0': + optional: true + + '@vitest/mocker@5.1.0(vite@8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1))': + dependencies: + '@jridgewell/trace-mapping': 0.3.31 + '@vitest/spy': 5.1.0 + estree-walker: 3.0.3 + magic-string: 1.4.5 + optionalDependencies: + vite: 8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1) + + '@vitest/spy@5.1.0': {} + + '@vladfrangu/async_event_emitter@2.4.7': {} + + '@yuku-toolchain/darwin-arm64@0.28.0': + optional: true + + '@yuku-toolchain/darwin-x64@0.28.0': + optional: true + + '@yuku-toolchain/linux-arm64@0.28.0': + optional: true + + '@yuku-toolchain/linux-x64@0.28.0': + optional: true + + '@yuku-toolchain/win32-arm64@0.28.0': + optional: true + + '@yuku-toolchain/win32-x64@0.28.0': + optional: true + + acorn-jsx@5.3.2(acorn@8.19.0): + dependencies: + acorn: 8.19.0 + + acorn@8.19.0: {} + + agent-base@7.1.4: {} + + ajv@6.15.0: + dependencies: + fast-deep-equal: 3.1.3 + fast-json-stable-stringify: 2.1.0 + json-schema-traverse: 0.4.1 + uri-js: 4.4.1 + + array-buffer-byte-length@1.0.2: + dependencies: + call-bound: 1.0.4 + is-array-buffer: 3.0.5 + + array-includes@3.2.0: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-object-atoms: 1.1.2 + es-shim-unscopables: 1.1.0 + is-string: 1.1.1 + math-intrinsics: 1.1.0 + + array.prototype.findlast@1.2.5: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + es-shim-unscopables: 1.1.0 + + array.prototype.flat@1.3.3: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-shim-unscopables: 1.1.0 + + array.prototype.flatmap@1.3.3: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-shim-unscopables: 1.1.0 + + array.prototype.tosorted@1.1.4: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-shim-unscopables: 1.1.0 + + arraybuffer.prototype.slice@1.0.4: + dependencies: + array-buffer-byte-length: 1.0.2 + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + is-array-buffer: 3.0.5 + + assertion-error@2.0.1: {} + + async-function@1.0.0: {} + + atomic-sleep@1.0.0: {} + + available-typed-arrays@1.0.7: + dependencies: + possible-typed-array-names: 1.1.0 + + balanced-match@1.0.2: {} + + balanced-match@4.0.4: {} + + base64-js@1.5.1: {} + + baseline-browser-mapping@2.11.37: {} + + better-sqlite3@13.2.0: + dependencies: + node-addon-api: 8.9.2 + + bignumber.js@9.3.1: {} + + brace-expansion@1.1.22: + dependencies: + balanced-match: 1.0.2 + concat-map: 0.0.1 + + brace-expansion@5.0.13: + dependencies: + balanced-match: 4.0.4 + + browserslist@4.29.5: + dependencies: + baseline-browser-mapping: 2.11.37 + caniuse-lite: 1.0.30001826 + electron-to-chromium: 1.5.485 + node-releases: 2.0.64 + update-browserslist-db: 1.3.4(browserslist@4.29.5) + + buffer-equal-constant-time@1.0.1: {} + + buffer-from@1.1.2: {} + + builtin-modules@3.3.0: {} + + builtin-modules@5.5.0: {} + + bytes@3.1.2: {} + + cac@7.1.0: {} + + cacheable@2.5.0: + dependencies: + '@cacheable/memory': 2.2.0 + '@cacheable/utils': 2.5.0 + hookified: 1.15.1 + keyv: 5.6.0 + qified: 0.10.1 + + call-bind-apply-helpers@1.0.2: + dependencies: + es-errors: 1.3.0 + function-bind: 1.1.2 + + call-bind@1.0.9: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + get-intrinsic: 1.3.0 + set-function-length: 1.2.2 + + call-bound@1.0.4: + dependencies: + call-bind-apply-helpers: 1.0.2 + get-intrinsic: 1.3.0 + + caniuse-lite@1.0.30001826: {} + + chai@6.3.0: {} + + change-case@5.4.4: {} + + character-entities@2.0.2: {} + + chrono-node@2.10.3: {} + + ci-info@4.5.0: {} + + cjs-module-lexer@2.3.0: {} + + colorette@2.0.20: {} + + comment-parser@1.4.9: {} + + concat-map@0.0.1: {} + + core-js-compat@3.51.0: + dependencies: + browserslist: 4.29.5 + + cron-parser@5.10.6: + dependencies: + luxon: 3.7.2 + + cross-spawn@7.0.6: + dependencies: + path-key: 3.1.1 + shebang-command: 2.0.0 + which: 2.0.2 + + data-uri-to-buffer@4.0.1: {} + + data-view-buffer@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + data-view-byte-length@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + data-view-byte-offset@1.0.1: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-data-view: 1.0.2 + + date-fns@4.4.0: {} + + dateformat@4.6.3: {} + + debug@4.4.3: + dependencies: + ms: 2.1.3 + + decode-named-character-reference@1.3.0: + dependencies: + character-entities: 2.0.2 + + deep-is@0.1.4: {} + + define-data-property@1.1.4: + dependencies: + es-define-property: 1.0.1 + es-errors: 1.3.0 + gopd: 1.2.0 + + define-properties@1.2.1: + dependencies: + define-data-property: 1.1.4 + has-property-descriptors: 1.0.2 + object-keys: 1.1.1 + + defu@6.1.7: {} + + dequal@2.0.3: {} + + detect-indent@7.0.2: {} + + detect-libc@2.1.2: {} + + devlop@1.1.0: + dependencies: + dequal: 2.0.3 + + discord-api-types@0.38.59: {} + + discord.js@14.28.1: + dependencies: + '@discordjs/builders': 1.15.0 + '@discordjs/collection': 1.5.3 + '@discordjs/formatters': 0.6.2 + '@discordjs/rest': 2.6.3 + '@discordjs/util': 1.2.0 + '@discordjs/ws': 1.2.3 + '@sapphire/snowflake': 3.5.5 + discord-api-types: 0.38.59 + fast-deep-equal: 3.1.3 + lodash.snakecase: 4.1.1 + magic-bytes.js: 1.13.1 + tslib: 2.9.1 + undici: 6.29.1 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + doctrine@2.1.0: + dependencies: + esutils: 2.0.3 + + drizzle-kit@0.31.11: + dependencies: + '@drizzle-team/brocli': 0.10.2 + '@esbuild-kit/esm-loader': 2.6.5 + esbuild: 0.25.12 + tsx: 4.23.15 + + drizzle-orm@0.45.4(@opentelemetry/api@1.10.0)(@types/better-sqlite3@9.6.0)(better-sqlite3@13.2.0)(pg@8.23.1)(postgres@3.4.9): + optionalDependencies: + '@opentelemetry/api': 1.10.0 + '@types/better-sqlite3': 9.6.0 + better-sqlite3: 13.2.0 + pg: 8.23.1 + postgres: 3.4.9 + + dts-resolver@3.0.0: {} + + dunder-proto@1.0.1: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-errors: 1.3.0 + gopd: 1.2.0 + + ecdsa-sig-formatter@1.0.11: + dependencies: + safe-buffer: 5.2.1 + + electron-to-chromium@1.5.485: {} + + empathic@2.1.0: {} + + end-of-stream@1.4.5: + dependencies: + once: 1.4.0 + + entities@8.1.0: {} + + entities@9.0.0: {} + + es-abstract-get@1.0.0: + dependencies: + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + is-callable: 1.2.7 + object-inspect: 1.13.4 + + es-abstract@1.24.2: + dependencies: + array-buffer-byte-length: 1.0.2 + arraybuffer.prototype.slice: 1.0.4 + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + call-bound: 1.0.4 + data-view-buffer: 1.0.2 + data-view-byte-length: 1.0.2 + data-view-byte-offset: 1.0.1 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + es-set-tostringtag: 2.1.0 + es-to-primitive: 1.3.4 + function.prototype.name: 1.2.0 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + get-symbol-description: 1.1.0 + globalthis: 1.0.4 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + has-proto: 1.2.0 + has-symbols: 1.1.0 + hasown: 2.0.4 + internal-slot: 1.1.0 + is-array-buffer: 3.0.5 + is-callable: 1.2.7 + is-data-view: 1.0.2 + is-negative-zero: 2.0.3 + is-regex: 1.2.1 + is-set: 2.0.3 + is-shared-array-buffer: 1.0.4 + is-string: 1.1.1 + is-typed-array: 1.1.15 + is-weakref: 1.1.1 + math-intrinsics: 1.1.0 + object-inspect: 1.13.4 + object-keys: 1.1.1 + object.assign: 4.1.7 + own-keys: 1.0.2 + regexp.prototype.flags: 1.5.4 + safe-array-concat: 1.1.4 + safe-push-apply: 1.0.0 + safe-regex-test: 1.1.0 + set-proto: 1.0.0 + stop-iteration-iterator: 1.1.0 + string.prototype.trim: 1.2.11 + string.prototype.trimend: 1.0.10 + string.prototype.trimstart: 1.0.8 + typed-array-buffer: 1.0.3 + typed-array-byte-length: 1.0.3 + typed-array-byte-offset: 1.0.5 + typed-array-length: 1.0.8 + unbox-primitive: 1.1.0 + which-typed-array: 1.1.24 + + es-define-property@1.0.1: {} + + es-errors@1.3.0: {} + + es-iterator-helpers@1.4.0: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-set-tostringtag: 2.1.0 + function-bind: 1.1.2 + get-intrinsic: 1.3.0 + globalthis: 1.0.4 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + has-proto: 1.2.0 + has-symbols: 1.1.0 + internal-slot: 1.1.0 + iterator.prototype: 1.1.5 + math-intrinsics: 1.1.0 + + es-module-lexer@2.3.2: {} + + es-module-lexer@3.0.4: {} + + es-object-atoms@1.1.2: + dependencies: + es-errors: 1.3.0 + + es-set-tostringtag@2.1.0: + dependencies: + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + has-tostringtag: 1.0.2 + hasown: 2.0.4 + + es-shim-unscopables@1.1.0: + dependencies: + hasown: 2.0.4 + + es-to-primitive@1.3.4: + dependencies: + es-abstract-get: 1.0.0 + es-define-property: 1.0.1 + es-errors: 1.3.0 + is-callable: 1.2.7 + is-date-object: 1.1.0 + is-symbol: 1.1.1 + + esbuild@0.18.20: + optionalDependencies: + '@esbuild/android-arm': 0.18.20 + '@esbuild/android-arm64': 0.18.20 + '@esbuild/android-x64': 0.18.20 + '@esbuild/darwin-arm64': 0.18.20 + '@esbuild/darwin-x64': 0.18.20 + '@esbuild/freebsd-arm64': 0.18.20 + '@esbuild/freebsd-x64': 0.18.20 + '@esbuild/linux-arm': 0.18.20 + '@esbuild/linux-arm64': 0.18.20 + '@esbuild/linux-ia32': 0.18.20 + '@esbuild/linux-loong64': 0.18.20 + '@esbuild/linux-mips64el': 0.18.20 + '@esbuild/linux-ppc64': 0.18.20 + '@esbuild/linux-riscv64': 0.18.20 + '@esbuild/linux-s390x': 0.18.20 + '@esbuild/linux-x64': 0.18.20 + '@esbuild/netbsd-x64': 0.18.20 + '@esbuild/openbsd-x64': 0.18.20 + '@esbuild/sunos-x64': 0.18.20 + '@esbuild/win32-arm64': 0.18.20 + '@esbuild/win32-ia32': 0.18.20 + '@esbuild/win32-x64': 0.18.20 + + esbuild@0.25.12: + optionalDependencies: + '@esbuild/aix-ppc64': 0.25.12 + '@esbuild/android-arm': 0.25.12 + '@esbuild/android-arm64': 0.25.12 + '@esbuild/android-x64': 0.25.12 + '@esbuild/darwin-arm64': 0.25.12 + '@esbuild/darwin-x64': 0.25.12 + '@esbuild/freebsd-arm64': 0.25.12 + '@esbuild/freebsd-x64': 0.25.12 + '@esbuild/linux-arm': 0.25.12 + '@esbuild/linux-arm64': 0.25.12 + '@esbuild/linux-ia32': 0.25.12 + '@esbuild/linux-loong64': 0.25.12 + '@esbuild/linux-mips64el': 0.25.12 + '@esbuild/linux-ppc64': 0.25.12 + '@esbuild/linux-riscv64': 0.25.12 + '@esbuild/linux-s390x': 0.25.12 + '@esbuild/linux-x64': 0.25.12 + '@esbuild/netbsd-arm64': 0.25.12 + '@esbuild/netbsd-x64': 0.25.12 + '@esbuild/openbsd-arm64': 0.25.12 + '@esbuild/openbsd-x64': 0.25.12 + '@esbuild/openharmony-arm64': 0.25.12 + '@esbuild/sunos-x64': 0.25.12 + '@esbuild/win32-arm64': 0.25.12 + '@esbuild/win32-ia32': 0.25.12 + '@esbuild/win32-x64': 0.25.12 + + esbuild@0.28.2: + 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 + + escalade@3.2.0: {} + + escape-string-regexp@4.0.0: {} + + eslint-config-prettier@10.1.8(eslint@10.15.0(jiti@2.7.0)): + dependencies: + eslint: 10.15.0(jiti@2.7.0) + + eslint-import-context@0.1.9(unrs-resolver@1.13.0): + dependencies: + get-tsconfig: 4.14.3 + stable-hash-x: 0.2.0 + optionalDependencies: + unrs-resolver: 1.13.0 + + eslint-import-resolver-typescript@4.4.5(eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.15.0(jiti@2.7.0)))(eslint@10.15.0(jiti@2.7.0)): + dependencies: + debug: 4.4.3 + eslint: 10.15.0(jiti@2.7.0) + eslint-import-context: 0.1.9(unrs-resolver@1.13.0) + get-tsconfig: 4.14.3 + is-bun-module: 2.0.0 + stable-hash-x: 0.2.0 + tinyglobby: 0.2.17 + unrs-resolver: 1.13.0 + optionalDependencies: + eslint-plugin-import-x: 4.18.1(@typescript-eslint/utils@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.15.0(jiti@2.7.0)) + transitivePeerDependencies: + - supports-color + + eslint-plugin-import-x@4.18.1(@typescript-eslint/utils@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.15.0(jiti@2.7.0)): + dependencies: + '@typescript-eslint/types': 8.72.2 + cjs-module-lexer: 2.3.0 + comment-parser: 1.4.9 + debug: 4.4.3 + es-module-lexer: 3.0.4 + eslint: 10.15.0(jiti@2.7.0) + eslint-import-context: 0.1.9(unrs-resolver@1.13.0) + is-glob: 4.0.3 + minimatch: 11.0.8 + semver: 7.8.6 + stable-hash-x: 0.2.0 + unrs-resolver: 1.13.0 + optionalDependencies: + '@typescript-eslint/utils': 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + transitivePeerDependencies: + - supports-color + + eslint-plugin-react@7.37.5(eslint@10.15.0(jiti@2.7.0)): + dependencies: + array-includes: 3.2.0 + array.prototype.findlast: 1.2.5 + array.prototype.flatmap: 1.3.3 + array.prototype.tosorted: 1.1.4 + doctrine: 2.1.0 + es-iterator-helpers: 1.4.0 + eslint: 10.15.0(jiti@2.7.0) + estraverse: 5.3.0 + hasown: 2.0.4 + jsx-ast-utils: 3.3.5 + minimatch: 3.1.5 + object.entries: 1.1.9 + object.fromentries: 2.0.8 + object.values: 1.2.1 + prop-types: 15.8.1 + resolve: 2.0.0-next.7 + semver: 6.3.2 + string.prototype.matchall: 4.1.0 + string.prototype.repeat: 1.0.0 + + eslint-plugin-sonarjs@4.2.2(eslint@10.15.0(jiti@2.7.0)): + dependencies: + '@eslint-community/regexpp': 4.12.3 + '@sonarsource/analyzer-commons-configurations': 2.31.0-5284 + builtin-modules: 3.3.0 + bytes: 3.1.2 + eslint: 10.15.0(jiti@2.7.0) + functional-red-black-tree: 1.0.1 + globals: 17.14.0 + jsx-ast-utils-x: 0.1.0 + lodash.merge: 4.6.2 + minimatch: 10.2.6 + scslre: 0.3.0 + semver: 7.8.6 + ts-api-utils: 2.5.0(typescript@6.0.3) + typescript: 6.0.3 + yaml: 2.9.1 + + eslint-plugin-unicorn@79.0.0(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3): + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0(jiti@2.7.0)) + '@eslint/css-tree': 4.1.2 + browserslist: 4.29.5 + change-case: 5.4.4 + ci-info: 4.5.0 + core-js-compat: 3.51.0 + detect-indent: 7.0.2 + entities: 8.1.0 + eslint: 10.15.0(jiti@2.7.0) + find-up-simple: 1.0.1 + globals: 17.14.0 + identifier-regex: 1.1.0 + indent-string: 5.0.0 + is-builtin-module: 5.0.0 + micromark: 4.0.3 + parse5: 8.1.1 + pluralize: 8.0.0 + quote-js-string: 0.1.0 + regjsparser: 0.13.4 + reserved-identifiers: 1.2.0 + semver: 7.8.6 + strip-indent: 4.1.1 + yaml: 2.9.1 + optionalDependencies: + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + eslint-scope@9.1.2: + dependencies: + '@types/esrecurse': 4.3.1 + '@types/estree': 1.0.10 + esrecurse: 4.3.0 + estraverse: 5.3.0 + + eslint-visitor-keys@3.4.3: {} + + eslint-visitor-keys@5.0.1: {} + + eslint@10.15.0(jiti@2.7.0): + dependencies: + '@eslint-community/eslint-utils': 4.10.1(eslint@10.15.0(jiti@2.7.0)) + '@eslint-community/regexpp': 4.12.3 + '@eslint/config-array': 0.23.6 + '@eslint/config-helpers': 0.7.0 + '@eslint/core': 1.2.1 + '@eslint/plugin-kit': 0.7.3 + '@humanfs/node': 0.16.8 + '@humanwhocodes/module-importer': 1.0.1 + '@humanwhocodes/retry': 0.4.3 + '@types/estree': 1.0.10 + ajv: 6.15.0 + cross-spawn: 7.0.6 + debug: 4.4.3 + escape-string-regexp: 4.0.0 + eslint-scope: 9.1.2 + eslint-visitor-keys: 5.0.1 + espree: 11.2.0 + esquery: 1.7.0 + esutils: 2.0.3 + fast-deep-equal: 3.1.3 + file-entry-cache: 11.1.5 + find-up: 5.0.0 + glob-parent: 6.0.2 + ignore: 5.3.2 + imurmurhash: 0.1.4 + is-glob: 4.0.3 + json-stable-stringify-without-jsonify: 1.0.1 + minimatch: 11.0.8 + natural-compare: 1.4.0 + optionator: 0.9.4 + optionalDependencies: + jiti: 2.7.0 + transitivePeerDependencies: + - supports-color + + espree@11.2.0: + dependencies: + acorn: 8.19.0 + acorn-jsx: 5.3.2(acorn@8.19.0) + eslint-visitor-keys: 5.0.1 + + esquery@1.7.0: + dependencies: + estraverse: 5.3.0 + + esrecurse@4.3.0: + dependencies: + estraverse: 5.3.0 + + estraverse@5.3.0: {} + + estree-walker@3.0.3: + dependencies: + '@types/estree': 1.0.10 + + esutils@2.0.3: {} + + expect-type@1.4.0: {} + + extend@3.0.2: {} + + fast-copy@4.3.1: {} + + fast-deep-equal@3.1.3: {} + + fast-json-stable-stringify@2.1.0: {} + + fast-levenshtein@2.0.6: {} + + fast-safe-stringify@2.1.1: {} + + fdir@6.5.0(picomatch@4.0.7): + optionalDependencies: + picomatch: 4.0.7 + + fetch-blob@3.2.0: + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.3.3 + + file-entry-cache@11.1.5: + dependencies: + flat-cache: 6.1.23 + + find-up-simple@1.0.1: {} + + find-up@5.0.0: + dependencies: + locate-path: 6.0.0 + path-exists: 4.0.0 + + flat-cache@6.1.23: + dependencies: + cacheable: 2.5.0 + flatted: 3.4.4 + hookified: 1.15.1 + + flatted@3.4.4: {} + + for-each@0.3.5: + dependencies: + is-callable: 1.2.7 + + formdata-polyfill@4.0.10: + dependencies: + fetch-blob: 3.2.0 + + fsevents@2.3.3: + optional: true + + function-bind@1.1.2: {} + + function.prototype.name@1.2.0: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + es-define-property: 1.0.1 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + hasown: 2.0.4 + is-callable: 1.2.7 + is-document.all: 1.0.0 + + functional-red-black-tree@1.0.1: {} + + functions-have-names@1.2.3: {} + + gaxios@8.3.3: + dependencies: + extend: 3.0.2 + https-proxy-agent: 7.0.6 + node-fetch: 3.3.2 + transitivePeerDependencies: + - supports-color + + gcp-metadata@9.2.3: + dependencies: + gaxios: 8.3.3 + google-logging-utils: 2.2.0 + json-bigint: 1.0.0 + transitivePeerDependencies: + - supports-color + + generator-function@2.0.1: {} + + get-intrinsic@1.3.0: + dependencies: + call-bind-apply-helpers: 1.0.2 + es-define-property: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + function-bind: 1.1.2 + get-proto: 1.0.1 + gopd: 1.2.0 + has-symbols: 1.1.0 + hasown: 2.0.4 + math-intrinsics: 1.1.0 + + get-proto@1.0.1: + dependencies: + dunder-proto: 1.0.1 + es-object-atoms: 1.1.2 + + get-symbol-description@1.1.0: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + + get-tsconfig@4.14.3: + dependencies: + resolve-pkg-maps: 1.0.0 + + get-tsconfig@5.0.0-beta.6: + dependencies: + resolve-pkg-maps: 1.0.0 + + glob-parent@6.0.2: + dependencies: + is-glob: 4.0.3 + + globals@17.14.0: {} + + globalthis@1.0.4: + dependencies: + define-properties: 1.2.1 + gopd: 1.2.0 + + google-auth-library@11.3.4: + dependencies: + base64-js: 1.5.1 + ecdsa-sig-formatter: 1.0.11 + gaxios: 8.3.3 + gcp-metadata: 9.2.3 + google-logging-utils: 2.2.0 + jws: 4.0.1 + transitivePeerDependencies: + - supports-color + + google-logging-utils@2.2.0: {} + + googleapis-common@9.3.1: + dependencies: + extend: 3.0.2 + gaxios: 8.3.3 + google-auth-library: 11.3.4 + google-logging-utils: 2.2.0 + qs: 6.17.1 + url-template: 2.0.8 + transitivePeerDependencies: + - supports-color + + gopd@1.2.0: {} + + has-bigints@1.1.0: {} + + has-property-descriptors@1.0.2: + dependencies: + es-define-property: 1.0.1 + + has-proto@1.2.0: + dependencies: + dunder-proto: 1.0.1 + + has-symbols@1.1.0: {} + + has-tostringtag@1.0.2: + dependencies: + has-symbols: 1.1.0 + + hashery@1.5.1: + dependencies: + hookified: 1.15.1 + + hasown@2.0.4: + dependencies: + function-bind: 1.1.2 + + help-me@5.0.0: {} + + hono@4.13.18: {} + + hookable@6.1.2: {} + + hookified@1.15.1: {} + + hookified@2.2.0: {} + + https-proxy-agent@7.0.6: + dependencies: + agent-base: 7.1.4 + debug: 4.4.3 + transitivePeerDependencies: + - supports-color + + identifier-regex@1.1.0: + dependencies: + reserved-identifiers: 1.2.0 + + ignore@5.3.2: {} + + ignore@7.0.14: {} + + import-without-cache@0.4.1: {} + + imurmurhash@0.1.4: {} + + indent-string@5.0.0: {} + + internal-slot@1.1.0: + dependencies: + es-errors: 1.3.0 + hasown: 2.0.4 + side-channel: 1.1.1 + + is-array-buffer@3.0.5: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + + is-async-function@2.1.1: + dependencies: + async-function: 1.0.0 + call-bound: 1.0.4 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + + is-bigint@1.1.0: + dependencies: + has-bigints: 1.1.0 + + is-boolean-object@1.2.2: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-builtin-module@5.0.0: + dependencies: + builtin-modules: 5.5.0 + + is-bun-module@2.0.0: + dependencies: + semver: 7.8.6 + + is-callable@1.2.7: {} + + is-core-module@2.18.0: + dependencies: + hasown: 2.0.4 + + is-data-view@1.0.2: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + is-typed-array: 1.1.15 + + is-date-object@1.1.0: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-document.all@1.0.0: + dependencies: + call-bound: 1.0.4 + + is-extglob@2.1.1: {} + + is-finalizationregistry@1.1.1: + dependencies: + call-bound: 1.0.4 + + is-generator-function@1.1.2: + dependencies: + call-bound: 1.0.4 + generator-function: 2.0.1 + get-proto: 1.0.1 + has-tostringtag: 1.0.2 + safe-regex-test: 1.1.0 + + is-glob@4.0.3: + dependencies: + is-extglob: 2.1.1 + + is-map@2.0.3: {} + + is-negative-zero@2.0.3: {} + + is-number-object@1.1.1: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-regex@1.2.1: + dependencies: + call-bound: 1.0.4 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + hasown: 2.0.4 + + is-set@2.0.3: {} + + is-shared-array-buffer@1.0.4: + dependencies: + call-bound: 1.0.4 + + is-string@1.1.1: + dependencies: + call-bound: 1.0.4 + has-tostringtag: 1.0.2 + + is-symbol@1.1.1: + dependencies: + call-bound: 1.0.4 + has-symbols: 1.1.0 + safe-regex-test: 1.1.0 + + is-typed-array@1.1.15: + dependencies: + which-typed-array: 1.1.24 + + is-weakmap@2.0.2: {} + + is-weakref@1.1.1: + dependencies: + call-bound: 1.0.4 + + is-weakset@2.0.4: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + + isarray@2.0.5: {} + + isexe@2.0.0: {} + + iterator.prototype@1.1.5: + dependencies: + define-data-property: 1.1.4 + es-object-atoms: 1.1.2 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + has-symbols: 1.1.0 + set-function-name: 2.0.2 + + jiti@2.7.0: {} + + joycon@3.1.1: {} + + js-tokens@4.0.0: {} + + jsesc@3.1.0: {} + + json-bigint@1.0.0: + dependencies: + bignumber.js: 9.3.1 + + json-schema-traverse@0.4.1: {} + + json-stable-stringify-without-jsonify@1.0.1: {} + + jsx-ast-utils-x@0.1.0: {} + + jsx-ast-utils@3.3.5: + dependencies: + array-includes: 3.2.0 + array.prototype.flat: 1.3.3 + object.assign: 4.1.7 + object.values: 1.2.1 + + jwa@2.0.1: + dependencies: + buffer-equal-constant-time: 1.0.1 + ecdsa-sig-formatter: 1.0.11 + safe-buffer: 5.2.1 + + jws@4.0.1: + dependencies: + jwa: 2.0.1 + safe-buffer: 5.2.1 + + keyv@5.6.0: + dependencies: + '@keyv/serialize': 1.1.1 + + levn@0.4.1: + dependencies: + prelude-ls: 1.2.1 + type-check: 0.4.0 + + lightningcss-android-arm64@1.33.0: + optional: true + + lightningcss-darwin-arm64@1.33.0: + optional: true + + lightningcss-darwin-x64@1.33.0: + optional: true + + lightningcss-freebsd-x64@1.33.0: + optional: true + + lightningcss-linux-arm-gnueabihf@1.33.0: + optional: true + + lightningcss-linux-arm64-gnu@1.33.0: + optional: true + + lightningcss-linux-arm64-musl@1.33.0: + optional: true + + lightningcss-linux-x64-gnu@1.33.0: + optional: true + + lightningcss-linux-x64-musl@1.33.0: + optional: true + + lightningcss-win32-arm64-msvc@1.33.0: + optional: true + + lightningcss-win32-x64-msvc@1.33.0: + optional: true + + lightningcss@1.33.0: + dependencies: + detect-libc: 2.1.2 + 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 + + locate-path@6.0.0: + dependencies: + p-locate: 5.0.0 + + lodash.merge@4.6.2: {} + + lodash.snakecase@4.1.1: {} + + lodash@4.18.1: {} + + loose-envify@1.4.0: + dependencies: + js-tokens: 4.0.0 + + luxon@3.7.2: {} + + magic-bytes.js@1.13.1: {} + + magic-string@1.4.5: + dependencies: + '@jridgewell/sourcemap-codec': 1.6.0 + + math-intrinsics@1.1.0: {} + + mdn-data@2.37.2: {} + + micromark-core-commonmark@2.0.4: + dependencies: + decode-named-character-reference: 1.3.0 + devlop: 1.1.0 + micromark-factory-destination: 2.0.1 + micromark-factory-label: 2.0.1 + micromark-factory-space: 2.1.0 + micromark-factory-title: 2.0.1 + micromark-factory-whitespace: 2.0.1 + micromark-util-character: 2.1.1 + micromark-util-chunked: 2.0.1 + micromark-util-classify-character: 2.0.1 + micromark-util-edit-map: 1.0.0 + micromark-util-html-tag-name: 2.0.1 + micromark-util-normalize-identifier: 2.0.1 + micromark-util-resolve-all: 2.0.1 + micromark-util-subtokenize: 2.1.0 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-destination@2.0.1: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-label@2.0.1: + dependencies: + devlop: 1.1.0 + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-space@2.1.0: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-types: 2.0.3 + + micromark-factory-title@2.0.1: + dependencies: + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-factory-whitespace@2.0.1: + dependencies: + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-character@2.1.1: + dependencies: + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-chunked@2.0.1: + dependencies: + micromark-util-symbol: 2.0.1 + + micromark-util-classify-character@2.0.1: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-combine-extensions@2.0.1: + dependencies: + micromark-util-chunked: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-decode-numeric-character-reference@2.0.2: + dependencies: + micromark-util-symbol: 2.0.1 + + micromark-util-edit-map@1.0.0: + dependencies: + micromark-util-types: 2.0.3 + + micromark-util-encode@2.0.1: {} + + micromark-util-html-tag-name@2.0.1: {} + + micromark-util-normalize-identifier@2.0.1: + dependencies: + micromark-util-symbol: 2.0.1 + + micromark-util-resolve-all@2.0.1: + dependencies: + micromark-util-types: 2.0.3 + + micromark-util-sanitize-uri@2.0.1: + dependencies: + micromark-util-character: 2.1.1 + micromark-util-encode: 2.0.1 + micromark-util-symbol: 2.0.1 + + micromark-util-subtokenize@2.1.0: + dependencies: + devlop: 1.1.0 + micromark-util-chunked: 2.0.1 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + + micromark-util-symbol@2.0.1: {} + + micromark-util-types@2.0.3: {} + + micromark@4.0.3: + dependencies: + '@types/debug': 4.1.13 + debug: 4.4.3 + decode-named-character-reference: 1.3.0 + devlop: 1.1.0 + micromark-core-commonmark: 2.0.4 + micromark-factory-space: 2.1.0 + micromark-util-character: 2.1.1 + micromark-util-chunked: 2.0.1 + micromark-util-combine-extensions: 2.0.1 + micromark-util-decode-numeric-character-reference: 2.0.2 + micromark-util-edit-map: 1.0.0 + micromark-util-encode: 2.0.1 + micromark-util-normalize-identifier: 2.0.1 + micromark-util-resolve-all: 2.0.1 + micromark-util-sanitize-uri: 2.0.1 + micromark-util-subtokenize: 2.1.0 + micromark-util-symbol: 2.0.1 + micromark-util-types: 2.0.3 + transitivePeerDependencies: + - supports-color + + minimatch@10.2.6: + dependencies: + brace-expansion: 5.0.13 + + minimatch@11.0.8: + dependencies: + '@isaacs/nonrecursive-glob-match': 1.1.0 + brace-expansion: 5.0.13 + + minimatch@3.1.5: + dependencies: + brace-expansion: 1.1.22 + + minimist@1.2.8: {} + + ms@2.1.3: {} + + nanoid@3.3.20: {} + + napi-postinstall@0.3.8: {} + + natural-compare@1.4.0: {} + + node-addon-api@8.9.2: {} + + node-domexception@1.0.0: {} + + node-exports-info@1.6.2: + dependencies: + array.prototype.flatmap: 1.3.3 + es-errors: 1.3.0 + object.entries: 1.1.9 + semver: 6.3.2 + + node-fetch@3.3.2: + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + + node-releases@2.0.64: {} + + non-error@0.1.0: {} + + object-assign@4.1.1: {} + + object-inspect@1.13.4: {} + + object-keys@1.1.1: {} + + object.assign@4.1.7: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + has-symbols: 1.1.0 + object-keys: 1.1.1 + + object.entries@1.1.9: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + object.fromentries@2.0.8: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-object-atoms: 1.1.2 + + object.values@1.2.1: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + obug@3.0.0: {} + + on-exit-leak-free@2.1.2: {} + + once@1.4.0: + dependencies: + wrappy: 1.0.2 + + optionator@0.9.4: + dependencies: + deep-is: 0.1.4 + fast-levenshtein: 2.0.6 + levn: 0.4.1 + prelude-ls: 1.2.1 + type-check: 0.4.0 + word-wrap: 1.2.5 + + own-keys@1.0.2: + dependencies: + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + object-keys: 1.1.1 + safe-push-apply: 1.0.0 + + p-limit@3.1.0: + dependencies: + yocto-queue: 0.1.0 + + p-locate@5.0.0: + dependencies: + p-limit: 3.1.0 + + parse5@8.1.1: + dependencies: + entities: 9.0.0 + + path-exists@4.0.0: {} + + path-key@3.1.1: {} + + path-parse@1.0.7: {} + + pg-boss@12.38.2(@opentelemetry/api@1.10.0): + dependencies: + '@opentelemetry/api': 1.10.0 + cron-parser: 5.10.6 + pg: 8.23.1 + rrule-temporal: 2.2.9 + serialize-error: 13.1.0 + transitivePeerDependencies: + - pg-native + + pg-cloudflare@1.4.1: + optional: true + + pg-connection-string@2.14.1: {} + + pg-int8@1.0.1: {} + + pg-pool@3.14.0(pg@8.23.1): + dependencies: + pg: 8.23.1 + + pg-protocol@1.16.1: {} + + pg-types@2.2.0: + dependencies: + pg-int8: 1.0.1 + postgres-array: 2.0.0 + postgres-bytea: 1.0.1 + postgres-date: 1.0.7 + postgres-interval: 1.2.0 + + pg@8.23.1: + dependencies: + pg-connection-string: 2.14.1 + pg-pool: 3.14.0(pg@8.23.1) + pg-protocol: 1.16.1 + pg-types: 2.2.0 + pgpass: 1.0.5 + optionalDependencies: + pg-cloudflare: 1.4.1 + + pgpass@1.0.5: + dependencies: + split2: 4.2.0 + + picocolors@1.1.1: {} + + picomatch@4.0.7: {} + + pino-abstract-transport@3.0.0: + dependencies: + split2: 4.2.0 + + pino-pretty@13.2.0: + dependencies: + colorette: 2.0.20 + dateformat: 4.6.3 + fast-copy: 4.3.1 + fast-safe-stringify: 2.1.1 + help-me: 5.0.0 + joycon: 3.1.1 + minimist: 1.2.8 + on-exit-leak-free: 2.1.2 + pino-abstract-transport: 3.0.0 + pump: 3.0.4 + secure-json-parse: 4.1.1 + sonic-boom: 5.0.2 + strip-json-comments: 5.1.0 + + pino-std-serializers@7.1.0: {} + + pino@10.4.0: + dependencies: + '@pinojs/redact': 0.4.0 + atomic-sleep: 1.0.0 + on-exit-leak-free: 2.1.2 + pino-abstract-transport: 3.0.0 + pino-std-serializers: 7.1.0 + process-warning: 5.1.1 + quick-format-unescaped: 4.0.4 + real-require: 1.0.0 + safe-stable-stringify: 2.5.0 + sonic-boom: 4.2.1 + thread-stream: 4.2.1 + + pluralize@8.0.0: {} + + possible-typed-array-names@1.1.0: {} + + postcss@8.5.33: + dependencies: + nanoid: 3.3.20 + picocolors: 1.1.1 + source-map-js: 1.2.2 + + postgres-array@2.0.0: {} + + postgres-bytea@1.0.1: {} + + postgres-date@1.0.7: {} + + postgres-interval@1.2.0: + dependencies: + xtend: 4.0.2 + + postgres@3.4.9: {} + + prelude-ls@1.2.1: {} + + prettier@3.10.1: {} + + process-warning@5.1.1: {} + + prop-types@15.8.1: + dependencies: + loose-envify: 1.4.0 + object-assign: 4.1.1 + react-is: 16.13.1 + + pump@3.0.4: + dependencies: + end-of-stream: 1.4.5 + once: 1.4.0 + + punycode@2.3.1: {} + + qified@0.10.1: + dependencies: + hookified: 2.2.0 + + qs@6.17.1: + dependencies: + es-define-property: 1.0.1 + side-channel: 1.1.1 + + quansync@1.0.0: {} + + quick-format-unescaped@4.0.4: {} + + quote-js-string@0.1.0: {} + + react-is@16.13.1: {} + + real-require@1.0.0: {} + + refa@0.12.1: + dependencies: + '@eslint-community/regexpp': 4.12.3 + + reflect.getprototypeof@1.0.10: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + get-intrinsic: 1.3.0 + get-proto: 1.0.1 + which-builtin-type: 1.2.1 + + regexp-ast-analysis@0.7.1: + dependencies: + '@eslint-community/regexpp': 4.12.3 + refa: 0.12.1 + + regexp.prototype.flags@1.5.4: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-errors: 1.3.0 + get-proto: 1.0.1 + gopd: 1.2.0 + set-function-name: 2.0.2 + + regjsparser@0.13.4: + dependencies: + jsesc: 3.1.0 + + reserved-identifiers@1.2.0: {} + + resolve-pkg-maps@1.0.0: {} + + resolve@2.0.0-next.7: + dependencies: + es-errors: 1.3.0 + is-core-module: 2.18.0 + node-exports-info: 1.6.2 + object-keys: 1.1.1 + path-parse: 1.0.7 + supports-preserve-symlinks-flag: 1.0.0 + + rolldown-plugin-dts@0.30.2(rolldown@1.3.2)(typescript@6.0.3): + dependencies: + dts-resolver: 3.0.0 + get-tsconfig: 5.0.0-beta.6 + obug: 3.0.0 + rolldown: 1.3.2 + yuku: 0.28.0 + optionalDependencies: + typescript: 6.0.3 + transitivePeerDependencies: + - '@yuku-toolchain/wasm' + - oxc-resolver + + rolldown@1.2.19: + dependencies: + '@oxc-project/types': 0.156.0 + '@rolldown/pluginutils': 1.1.1 + 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 + + rolldown@1.3.2: + dependencies: + '@oxc-project/types': 0.158.0 + '@rolldown/pluginutils': 1.1.1 + optionalDependencies: + '@rolldown/binding-android-arm-eabi': 1.3.2 + '@rolldown/binding-android-arm64': 1.3.2 + '@rolldown/binding-darwin-arm64': 1.3.2 + '@rolldown/binding-darwin-x64': 1.3.2 + '@rolldown/binding-freebsd-x64': 1.3.2 + '@rolldown/binding-linux-arm-gnueabihf': 1.3.2 + '@rolldown/binding-linux-arm64-gnu': 1.3.2 + '@rolldown/binding-linux-arm64-musl': 1.3.2 + '@rolldown/binding-linux-ppc64-gnu': 1.3.2 + '@rolldown/binding-linux-s390x-gnu': 1.3.2 + '@rolldown/binding-linux-x64-gnu': 1.3.2 + '@rolldown/binding-linux-x64-musl': 1.3.2 + '@rolldown/binding-openharmony-arm64': 1.3.2 + '@rolldown/binding-wasm32-wasi': 1.3.2 + '@rolldown/binding-win32-arm64-msvc': 1.3.2 + '@rolldown/binding-win32-x64-msvc': 1.3.2 + + rrule-temporal@2.2.9: + dependencies: + temporal-spec: 1.0.1 + + safe-array-concat@1.1.4: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + get-intrinsic: 1.3.0 + has-symbols: 1.1.0 + isarray: 2.0.5 + + safe-buffer@5.2.1: {} + + safe-push-apply@1.0.0: + dependencies: + es-errors: 1.3.0 + isarray: 2.0.5 + + safe-regex-test@1.1.0: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-regex: 1.2.1 + + safe-stable-stringify@2.5.0: {} + + scslre@0.3.0: + dependencies: + '@eslint-community/regexpp': 4.12.3 + refa: 0.12.1 + regexp-ast-analysis: 0.7.1 + + secure-json-parse@4.1.1: {} + + semver@6.3.2: {} + + semver@7.8.6: {} + + serialize-error@13.1.0: + dependencies: + non-error: 0.1.0 + type-fest: 5.10.0 + + set-function-length@1.2.2: + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + function-bind: 1.1.2 + get-intrinsic: 1.3.0 + gopd: 1.2.0 + has-property-descriptors: 1.0.2 + + set-function-name@2.0.2: + dependencies: + define-data-property: 1.1.4 + es-errors: 1.3.0 + functions-have-names: 1.2.3 + has-property-descriptors: 1.0.2 + + set-proto@1.0.0: + dependencies: + dunder-proto: 1.0.1 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + + shebang-command@2.0.0: + dependencies: + shebang-regex: 3.0.0 + + shebang-regex@3.0.0: {} + + side-channel-list@1.0.1: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + + side-channel-map@1.0.1: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + + side-channel-weakmap@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + side-channel-map: 1.0.1 + + side-channel@1.1.1: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + side-channel-list: 1.0.1 + side-channel-map: 1.0.1 + side-channel-weakmap: 1.0.2 + + sonic-boom@4.2.1: + dependencies: + atomic-sleep: 1.0.0 + + sonic-boom@5.0.2: + dependencies: + atomic-sleep: 1.0.0 + + source-map-js@1.2.2: {} + + source-map-support@0.5.21: + dependencies: + buffer-from: 1.1.2 + source-map: 0.6.1 + + source-map@0.6.1: {} + + split2@4.2.0: {} + + stable-hash-x@0.2.0: {} + + std-env@4.3.0: {} + + stop-iteration-iterator@1.1.0: + dependencies: + es-errors: 1.3.0 + internal-slot: 1.1.0 + + string.prototype.matchall@4.1.0: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-errors: 1.3.0 + es-object-atoms: 1.1.2 + get-intrinsic: 1.3.0 + gopd: 1.2.0 + has-symbols: 1.1.0 + internal-slot: 1.1.0 + regexp.prototype.flags: 1.5.4 + set-function-name: 2.0.2 + side-channel: 1.1.1 + + string.prototype.repeat@1.0.0: + dependencies: + define-properties: 1.2.1 + es-abstract: 1.24.2 + + string.prototype.trim@1.2.11: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-data-property: 1.1.4 + define-properties: 1.2.1 + es-abstract: 1.24.2 + es-object-atoms: 1.1.2 + has-property-descriptors: 1.0.2 + safe-regex-test: 1.1.0 + + string.prototype.trimend@1.0.10: + dependencies: + call-bind: 1.0.9 + call-bound: 1.0.4 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + string.prototype.trimstart@1.0.8: + dependencies: + call-bind: 1.0.9 + define-properties: 1.2.1 + es-object-atoms: 1.1.2 + + strip-indent@4.1.1: {} + + strip-json-comments@5.1.0: {} + + supports-preserve-symlinks-flag@1.0.0: {} + + tagged-tag@1.0.0: {} + + temporal-spec@1.0.1: {} + + thread-stream@4.2.1: + dependencies: + real-require: 1.0.0 + + tinybench@6.2.3: {} + + tinyexec@1.3.1: {} + + tinyglobby@0.2.17: + dependencies: + fdir: 6.5.0(picomatch@4.0.7) + picomatch: 4.0.7 + + tinyps@0.5.2: {} + + tmdb-ts@2.3.0: {} + + ts-api-utils@2.5.0(typescript@6.0.3): + dependencies: + typescript: 6.0.3 + + ts-mixer@6.0.4: {} + + tsdown@0.23.7(tsx@4.23.15)(typescript@6.0.3): + dependencies: + cac: 7.1.0 + defu: 6.1.7 + empathic: 2.1.0 + hookable: 6.1.2 + import-without-cache: 0.4.1 + obug: 3.0.0 + picomatch: 4.0.7 + rolldown: 1.3.2 + rolldown-plugin-dts: 0.30.2(rolldown@1.3.2)(typescript@6.0.3) + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + tinyps: 0.5.2 + unconfig-core: 7.5.0 + verkit: 0.5.0 + optionalDependencies: + tsx: 4.23.15 + typescript: 6.0.3 + transitivePeerDependencies: + - '@volar/typescript' + - '@vue/language-core' + - '@yuku-toolchain/wasm' + - oxc-resolver + - tsrs + - vue-tsc + + tslib@2.9.1: {} + + tsx@4.23.15: + dependencies: + esbuild: 0.28.2 + optionalDependencies: + fsevents: 2.3.3 + + type-check@0.4.0: + dependencies: + prelude-ls: 1.2.1 + + type-fest@5.10.0: + dependencies: + tagged-tag: 1.0.0 + + typed-array-buffer@1.0.3: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + is-typed-array: 1.1.15 + + typed-array-byte-length@1.0.3: + dependencies: + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + has-proto: 1.2.0 + is-typed-array: 1.1.15 + + typed-array-byte-offset@1.0.5: + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + is-typed-array: 1.1.15 + reflect.getprototypeof: 1.0.10 + + typed-array-length@1.0.8: + dependencies: + call-bind: 1.0.9 + for-each: 0.3.5 + gopd: 1.2.0 + is-typed-array: 1.1.15 + possible-typed-array-names: 1.1.0 + reflect.getprototypeof: 1.0.10 + + typescript-eslint@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3): + dependencies: + '@typescript-eslint/eslint-plugin': 8.72.2(@typescript-eslint/parser@8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + '@typescript-eslint/parser': 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + '@typescript-eslint/typescript-estree': 8.72.2(typescript@6.0.3) + '@typescript-eslint/utils': 8.72.2(eslint@10.15.0(jiti@2.7.0))(typescript@6.0.3) + eslint: 10.15.0(jiti@2.7.0) + typescript: 6.0.3 + transitivePeerDependencies: + - supports-color + + typescript@6.0.3: {} + + unbox-primitive@1.1.0: + dependencies: + call-bound: 1.0.4 + has-bigints: 1.1.0 + has-symbols: 1.1.0 + which-boxed-primitive: 1.1.1 + + unconfig-core@7.5.0: + dependencies: + '@quansync/fs': 1.1.0 + quansync: 1.0.0 + + undici-types@7.24.6: {} + + undici@6.29.1: {} + + unrs-resolver@1.13.0: + dependencies: + napi-postinstall: 0.3.8 + optionalDependencies: + '@unrs/resolver-binding-android-arm-eabi': 1.13.0 + '@unrs/resolver-binding-android-arm64': 1.13.0 + '@unrs/resolver-binding-darwin-arm64': 1.13.0 + '@unrs/resolver-binding-darwin-x64': 1.13.0 + '@unrs/resolver-binding-freebsd-x64': 1.13.0 + '@unrs/resolver-binding-linux-arm-gnueabihf': 1.13.0 + '@unrs/resolver-binding-linux-arm-musleabihf': 1.13.0 + '@unrs/resolver-binding-linux-arm64-gnu': 1.13.0 + '@unrs/resolver-binding-linux-arm64-musl': 1.13.0 + '@unrs/resolver-binding-linux-loong64-gnu': 1.13.0 + '@unrs/resolver-binding-linux-loong64-musl': 1.13.0 + '@unrs/resolver-binding-linux-ppc64-gnu': 1.13.0 + '@unrs/resolver-binding-linux-riscv64-gnu': 1.13.0 + '@unrs/resolver-binding-linux-riscv64-musl': 1.13.0 + '@unrs/resolver-binding-linux-s390x-gnu': 1.13.0 + '@unrs/resolver-binding-linux-x64-gnu': 1.13.0 + '@unrs/resolver-binding-linux-x64-musl': 1.13.0 + '@unrs/resolver-binding-openharmony-arm64': 1.13.0 + '@unrs/resolver-binding-win32-arm64-msvc': 1.13.0 + '@unrs/resolver-binding-win32-ia32-msvc': 1.13.0 + '@unrs/resolver-binding-win32-x64-msvc': 1.13.0 + + update-browserslist-db@1.3.4(browserslist@4.29.5): + dependencies: + browserslist: 4.29.5 + escalade: 3.2.0 + picocolors: 1.1.1 + + uri-js@4.4.1: + dependencies: + punycode: 2.3.1 + + url-template@2.0.8: {} + + verkit@0.5.0: {} + + vite@8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1): + dependencies: + lightningcss: 1.33.0 + picomatch: 4.0.7 + postcss: 8.5.33 + rolldown: 1.2.19 + tinyglobby: 0.2.17 + optionalDependencies: + '@types/node': 24.19.2 + esbuild: 0.28.2 + fsevents: 2.3.3 + jiti: 2.7.0 + tsx: 4.23.15 + yaml: 2.9.1 + + vitest@5.1.0(@opentelemetry/api@1.10.0)(@types/node@24.19.2)(vite@8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)): + dependencies: + '@types/chai': 5.2.3 + '@vitest/mocker': 5.1.0(vite@8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1)) + chai: 6.3.0 + es-module-lexer: 2.3.2 + expect-type: 1.4.0 + magic-string: 1.4.5 + obug: 3.0.0 + picomatch: 4.0.7 + std-env: 4.3.0 + tinybench: 6.2.3 + tinyexec: 1.3.1 + tinyglobby: 0.2.17 + vite: 8.3.8(@types/node@24.19.2)(esbuild@0.28.2)(jiti@2.7.0)(tsx@4.23.15)(yaml@2.9.1) + why-is-node-running: 3.2.1 + optionalDependencies: + '@opentelemetry/api': 1.10.0 + '@types/node': 24.19.2 + transitivePeerDependencies: + - msw + + web-streams-polyfill@3.3.3: {} + + which-boxed-primitive@1.1.1: + dependencies: + is-bigint: 1.1.0 + is-boolean-object: 1.2.2 + is-number-object: 1.1.1 + is-string: 1.1.1 + is-symbol: 1.1.1 + + which-builtin-type@1.2.1: + dependencies: + call-bound: 1.0.4 + function.prototype.name: 1.2.0 + has-tostringtag: 1.0.2 + is-async-function: 2.1.1 + is-date-object: 1.1.0 + is-finalizationregistry: 1.1.1 + is-generator-function: 1.1.2 + is-regex: 1.2.1 + is-weakref: 1.1.1 + isarray: 2.0.5 + which-boxed-primitive: 1.1.1 + which-collection: 1.0.2 + which-typed-array: 1.1.24 + + which-collection@1.0.2: + dependencies: + is-map: 2.0.3 + is-set: 2.0.3 + is-weakmap: 2.0.2 + is-weakset: 2.0.4 + + which-typed-array@1.1.24: + dependencies: + available-typed-arrays: 1.0.7 + call-bind: 1.0.9 + call-bound: 1.0.4 + for-each: 0.3.5 + get-proto: 1.0.1 + gopd: 1.2.0 + has-tostringtag: 1.0.2 + + which@2.0.2: + dependencies: + isexe: 2.0.0 + + why-is-node-running@3.2.1: {} + + word-wrap@1.2.5: {} + + wrappy@1.0.2: {} + + ws@8.23.0: {} + + xtend@4.0.2: {} + + yaml@2.9.1: {} + + yocto-queue@0.1.0: {} + + yuku@0.28.0: + optionalDependencies: + '@yuku-toolchain/darwin-arm64': 0.28.0 + '@yuku-toolchain/darwin-x64': 0.28.0 + '@yuku-toolchain/linux-arm64': 0.28.0 + '@yuku-toolchain/linux-x64': 0.28.0 + '@yuku-toolchain/win32-arm64': 0.28.0 + '@yuku-toolchain/win32-x64': 0.28.0 + + zod@4.6.7: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml new file mode 100644 index 0000000..691e5b7 --- /dev/null +++ b/pnpm-workspace.yaml @@ -0,0 +1,3 @@ +allowBuilds: + better-sqlite3: true + esbuild: true diff --git a/scripts/ci/deploy-test.py b/scripts/ci/deploy-test.py new file mode 100644 index 0000000..002792b --- /dev/null +++ b/scripts/ci/deploy-test.py @@ -0,0 +1,163 @@ +"""Health checks must observe the restarted invocation, including rollback.""" +import importlib.util +import unittest +import tempfile +from subprocess import CalledProcessError +from datetime import datetime +from pathlib import Path +from subprocess import CompletedProcess +from unittest.mock import patch + +spec = importlib.util.spec_from_file_location( + 'deploy', Path(__file__).parents[1] / 'deploy' / 'deploy.py' +) +deploy = importlib.util.module_from_spec(spec) +spec.loader.exec_module(deploy) + + +class HealthTests(unittest.TestCase): + def check_states(self, states, ready=True): + journal = CompletedProcess([], 0, stdout='{"msg":"Ready"}' if ready else '') + with patch.object(deploy, 'ready_timeout', len(states)), \ + patch.object(deploy, 'service_state', side_effect=states), \ + patch.object(deploy.time, 'sleep'), \ + patch.object(deploy.subprocess, 'run', return_value=journal) as run: + result = deploy.ready((datetime.now(), 'old')) + return result, run + + def test_slow_shutdown_then_new_ready(self): + result, run = self.check_states([ + {'InvocationID': 'old', 'ActiveState': 'deactivating'}, + {'InvocationID': '', 'ActiveState': 'inactive'}, + {'InvocationID': 'new', 'ActiveState': 'active'}, + ]) + self.assertTrue(result) + self.assertIn('_SYSTEMD_INVOCATION_ID=new', run.call_args.args[0]) + + def test_outgoing_readiness_is_ignored(self): + result, _ = self.check_states([ + {'InvocationID': 'old', 'ActiveState': 'active'}, + ]) + self.assertFalse(result) + + def test_new_invocation_must_be_ready(self): + result, _ = self.check_states([ + {'InvocationID': 'new', 'ActiveState': 'active'}, + ], ready=False) + self.assertFalse(result) + + def test_failed_new_invocation(self): + result, _ = self.check_states([ + {'InvocationID': 'new', 'ActiveState': 'failed'}, + ]) + self.assertFalse(result) + + def test_rollback_checks_health(self): + with patch.object(deploy, 'switch_to') as switch, \ + patch.object(deploy, 'restart', return_value='request'), \ + patch.object(deploy, 'ready', return_value=True) as ready: + deploy.roll_back(Path('/previous')) + switch.assert_called_once_with(Path('/previous')) + ready.assert_called_once_with('request') + + def test_failed_rollback_is_reported(self): + with patch.object(deploy, 'switch_to'), \ + patch.object(deploy, 'restart'), \ + patch.object(deploy, 'ready', return_value=False), \ + patch('builtins.print') as output: + deploy.roll_back(Path('/previous')) + self.assertTrue(any('FAILED' in str(call) for call in output.call_args_list)) + + +class DeploymentTests(unittest.TestCase): + def setUp(self): + self.temp = tempfile.TemporaryDirectory() + self.addCleanup(self.temp.cleanup) + self.root = Path(self.temp.name) + for name, value in { + 'root_dir': self.root, + 'env_file': self.root / '.env', + 'lock_file': self.root / '.deploy.lock', + 'restart_file': self.root / '.restart', + 'repo_dir': self.root / 'repo', + 'releases_dir': self.root / 'releases', + 'current_link': self.root / 'current', + 'logs_dir': self.root / 'logs', + }.items(): + patcher = patch.object(deploy, name, value) + patcher.start() + self.addCleanup(patcher.stop) + self.env = self.root / '.env' + self.env.write_text('A=1\n') + self.releases = self.root / 'releases' + self.previous = self.releases / '0000-previous' + + def build(self, release): + release.mkdir(parents=True) + (release / '.env').symlink_to(self.env) + (release / 'logs').symlink_to(self.root / 'logs') + (release / 'package.json').write_text('{}') + + def seed_previous(self): + self.previous.mkdir(parents=True) + deploy.switch_to(self.previous) + + def run_deploy(self, health=True, build=None): + # Exercise real filesystem switching, restart requests, cleanup and pruning. + # External fetching, package installation and systemd are boundary mocks. + with patch.object(deploy, 'update_code'), \ + patch.object(deploy, 'git', return_value='test-commit'), \ + patch.object(deploy, 'build', side_effect=build or self.build), \ + patch.object(deploy, 'service_state', return_value={}), \ + patch.object(deploy, 'ready', side_effect=health if isinstance(health, list) else None, + return_value=health) as ready: + deploy.main() + return ready + + def test_missing_env_fails_before_build(self): + self.env.unlink() + with self.assertRaises(SystemExit): + self.run_deploy() + self.assertFalse(self.releases.exists()) + + def test_first_deploy_links_and_requests_restart(self): + self.run_deploy() + current = deploy.live() + self.assertTrue((current / 'package.json').is_file()) + self.assertEqual((current / '.env').readlink(), self.env) + self.assertEqual((current / 'logs').readlink(), self.root / 'logs') + self.assertEqual(deploy.restart_file.read_text().strip(), str(current)) + self.assertEqual(len(list(self.releases.iterdir())), 1) + + def test_prunes_to_three_releases(self): + self.releases.mkdir() + for number in range(5): + (self.releases / f'000{number}-old').mkdir() + self.run_deploy() + self.assertEqual(len(list(self.releases.iterdir())), 3) + self.assertTrue(deploy.live().is_dir()) + + def test_failed_startup_rolls_back_and_verifies(self): + self.seed_previous() + with self.assertRaises(SystemExit): + self.run_deploy(health=[False, True]) + self.assertEqual(deploy.live(), self.previous) + self.assertEqual(list(self.releases.iterdir()), [self.previous]) + self.assertEqual(deploy.restart_file.read_text().strip(), str(self.previous)) + + def test_failed_build_preserves_current_without_restart(self): + self.seed_previous() + + def fail(release): + self.build(release) + raise CalledProcessError(1, ['pnpm', 'build']) + + with self.assertRaises(CalledProcessError): + self.run_deploy(build=fail) + self.assertEqual(deploy.live(), self.previous) + self.assertEqual(list(self.releases.iterdir()), [self.previous]) + self.assertFalse(deploy.restart_file.exists()) + + +if __name__ == '__main__': + unittest.main() diff --git a/scripts/deploy/deploy.py b/scripts/deploy/deploy.py new file mode 100755 index 0000000..5ed18ff --- /dev/null +++ b/scripts/deploy/deploy.py @@ -0,0 +1,205 @@ +#!/usr/bin/env -S python3 -u +import os +import shutil +import subprocess +import sys +import time +from datetime import datetime +from fcntl import LOCK_EX, flock +from pathlib import Path + +root_dir = Path(os.environ.get("LAPBOT_ROOT", "/opt/lapbot")) +service = os.environ.get("LAPBOT_SERVICE", "lapbot") +ready_timeout = int(os.environ.get("LAPBOT_READY_TIMEOUT", "90")) +keep_releases = 3 + +env_file = root_dir / ".env" +lock_file = root_dir / ".deploy.lock" +restart_file = root_dir / ".restart" +repo_dir = root_dir / "repo" +releases_dir = root_dir / "releases" +current_link = root_dir / "current" +logs_dir = root_dir / "logs" + + +def main(): + if not root_dir.is_dir(): + sys.exit(f"root: {root_dir} does not exist") + + with lock_file.open("w") as lock: + flock(lock, LOCK_EX) + + if not env_file.is_file(): + sys.exit(f"env: {env_file} is missing\nCheck .env.example") + + update_code() + commit = git("rev-parse", "--short", "HEAD") + release = releases_dir / f"{datetime.now():%Y%m%d-%H%M%S}-{commit}" + previous = live() + + try: + build(release) + except BaseException: + discard(release) + raise + + switch_to(release) + started = restart() + + if not ready(started): + roll_back(previous) + + if live() != release: + discard(release) + + sys.exit(1) + + prune() + + +def run(*command, cwd=None, stdin=None): + subprocess.run(command, cwd=cwd, input=stdin, check=True) + + +def git(*args): + result = subprocess.run( + ["git", "-C", str(repo_dir), *args], check=True, capture_output=True, text=True + ) + + return result.stdout.strip() + + +def remote(): + configured = os.environ.get("LAPBOT_REMOTE") + + if configured: + return configured + + own = subprocess.run( + ["git", "-C", str(Path(__file__).parent), "remote", "get-url", "origin"], + capture_output=True, + text=True, + ).stdout.strip() + + if not own: + sys.exit(f"repo: {repo_dir} is missing and LAPBOT_REMOTE is not set") + + return own + + +def live(): + return Path(os.readlink(current_link)) if current_link.is_symlink() else None + + +def update_code(): + if not (repo_dir / ".git").is_dir(): + run("git", "clone", remote(), str(repo_dir)) + print(f"code: cloned into {repo_dir}") + + git("fetch", "origin", "main") + git("reset", "--hard", "origin/main") + print(f"code: at {git('log', '-1', '--format=%h %s')}") + + +def build(release): + release.mkdir(parents=True) + logs_dir.mkdir(exist_ok=True) + archive = subprocess.run( + ["git", "-C", str(repo_dir), "archive", "HEAD"], check=True, capture_output=True + ).stdout + run("tar", "-x", "-C", str(release), stdin=archive) + (release / ".env").symlink_to(env_file) + (release / "logs").symlink_to(logs_dir) + run("pnpm", "install", "--frozen-lockfile", cwd=release) + run("pnpm", "build", cwd=release) + print(f"build: {release}") + + +def switch_to(release): + staged = root_dir / "current.next" + staged.unlink(missing_ok=True) + staged.symlink_to(release) + staged.replace(current_link) + print(f"release: current_link is {release}") + + +def restart(): + started = (datetime.now(), service_state().get("InvocationID", "")) + restart_file.write_text(f"{live()}\n") + print(f"service: requested a restart of {service}") + + return started + + +def service_state(): + result = subprocess.run( + ["systemctl", "show", service, "--property=InvocationID,ActiveState"], + capture_output=True, text=True, check=True, + ) + return { + key: value + for key, sep, value in (line.partition("=") for line in result.stdout.splitlines()) + if sep + } + + +def ready(started): + requested, previous_invocation = started + journal = ["journalctl", "-u", service, "--since", + f"{requested:%Y-%m-%d %H:%M:%S}", "--no-pager"] + observed_new = False + + for _ in range(ready_timeout): + state = service_state() + invocation = state.get("InvocationID", "") + if invocation and invocation != previous_invocation: + observed_new = True + entries = subprocess.run( + [*journal, f"_SYSTEMD_INVOCATION_ID={invocation}", "-o", "cat"], + capture_output=True, text=True, + ) + if state.get("ActiveState") == "active" and entries.returncode == 0 and '"msg":"Ready"' in entries.stdout: + print(f"health: {service} is ready") + return True + + if observed_new and state.get("ActiveState") in ("failed", "inactive"): + break + time.sleep(1) + + print(f"health: {service} did not become ready", file=sys.stderr) + subprocess.run([*journal, "-n", "50"], stdout=sys.stderr) + return False + + +def roll_back(previous): + if previous is None: + print("rollback: no previous release", file=sys.stderr) + return + + switch_to(previous) + if ready(restart()): + print(f"rollback: verified {previous}", file=sys.stderr) + else: + print(f"rollback: FAILED to restore a healthy {previous}", file=sys.stderr) + + +def discard(release): + shutil.rmtree(release, ignore_errors=True) + print(f"release: discarded {release}", file=sys.stderr) + + +def prune(): + live_release = live() + built = sorted((path for path in releases_dir.iterdir() if path.is_dir()), reverse=True) + + for old in built[keep_releases:]: + if old != live_release: + shutil.rmtree(old) + print(f"prune: removed {old}") + + +if __name__ == "__main__": + try: + main() + except subprocess.CalledProcessError as error: + sys.exit(f"failed: {' '.join(map(str, error.cmd))}") diff --git a/src/app.ts b/src/app.ts new file mode 100644 index 0000000..6ea19ae --- /dev/null +++ b/src/app.ts @@ -0,0 +1,367 @@ +import { createEventSuggestionService } from '~/features/event-suggestions/service'; +import { configureApplicationAdminRole } from '~/discord/interactions/actor'; +import { createPostgresInfrastructure } from '~/integrations/db/infrastructure'; +import type { AppInfrastructure } from '~/infrastructure'; +import { randomBytes } from 'node:crypto'; +import { Events, type Client } from 'discord.js'; +import type { Config } from '~/config/env'; +import { announcementCommands } from '~/discord/commands/announcements'; +import { birthdayCommands } from '~/discord/commands/birthdays'; +import { createClient } from '~/integrations/discord/client'; +import { createGoogleCalendar } from '~/integrations/google/calendar'; +import { eventCommands } from '~/discord/commands/events'; +import { movieCommands } from '~/discord/commands/movies'; +import { pollCommands } from '~/discord/commands/polls'; +import { createInteractionHandler } from '~/discord/interactions/router'; +import { buildRegistry, type Registry } from '~/discord/registry'; +import { registerCommands } from '~/discord/registration'; +import { createDiscordDirectory } from '~/integrations/discord/directory'; +import { createDiscordMessenger } from '~/integrations/discord/messenger'; +import { reminderCommands } from '~/discord/commands/reminders'; +import { roleEvents } from '~/discord/events/roles'; +import { permissionCommands } from '~/discord/commands/permissions'; +import { createAnnouncementService } from '~/features/announcements/service'; +import { + createAuthorizer, + createPermissionService, +} from '~/features/permissions/service'; +import { createBirthdayService } from '~/features/birthdays/service'; +import { createEventService } from '~/features/events/service'; +import { createMovieService } from '~/features/movies/service'; +import { createPollService } from '~/features/polls/service'; +import { createReminderService } from '~/features/reminders/service'; +import { createRoleService, type LegacyPanel } from '~/features/roles/service'; +import type { AppContext, Feature } from '~/discord/contracts'; +import type { Logger } from 'pino'; +import type { LogStore } from '~/integrations/logging/store'; +import { systemClock } from '~/core/helpers/clock'; +import type { Authorizer } from '~/core/ports/authorization'; +import type { Directory } from '~/core/ports/directory'; +import type { Job } from '~/core/ports/scheduler'; +import { webAccess } from '~/core/permission'; +import { createWebApp } from '~/web/app'; +import { startWebServer } from '~/web/server'; +import type { WebServices } from '~/web/context'; +import { createTmdbCatalog } from '~/integrations/tmdb/catalog'; + +function legacyPanel(config: Config): LegacyPanel | undefined { + const channelId = config.ROLE_SELECTION_CHANNEL_ID; + + if (channelId === undefined) { + return undefined; + } + + const roles = [ + { emoji: '1️⃣', roleId: config.TARKVARA_ROLE_ID, label: 'Tarkvara' }, + { emoji: '2️⃣', roleId: config.HELPDESK_ROLE_ID, label: 'Helpdesk' }, + { emoji: '3️⃣', roleId: config.KULTUUR_ROLE_ID, label: 'Kultuur' }, + ].flatMap(({ roleId, ...rest }) => + roleId === undefined ? [] : [{ roleId, ...rest }], + ); + + return { channelId, roles }; +} + +export function compose( + config: Config, + log: Logger, + infrastructure: AppInfrastructure = createPostgresInfrastructure( + config.DATABASE_URL, + log, + ), +) { + configureApplicationAdminRole( + config.JUHATUS_ROLE_ID, + config.DISCORD_GUILD_ID, + ); + const client = createClient(); + const grants = infrastructure.repositories.grants; + const authz = createAuthorizer(grants); + const directory = createDiscordDirectory(client); + const messenger = createDiscordMessenger(client); + const legacy = legacyPanel(config); + const roles = createRoleService({ + panels: infrastructure.repositories.roles, + directory, + messenger, + log: log.child({ service: 'roles' }), + ...(legacy && { legacy }), + }); + const timezone = config.DEFAULT_TIMEZONE; + const scheduler = infrastructure.scheduler; + const reminders = createReminderService({ + reminders: infrastructure.repositories.reminders, + scheduler, + messenger, + directory, + authz, + timezone, + }); + const announcements = createAnnouncementService({ + posts: infrastructure.repositories.announcements, + scheduler, + messenger, + directory, + authz, + log: log.child({ service: 'announcements' }), + clock: systemClock, + timezone, + }); + const eventSuggestions = createEventSuggestionService({ + suggestions: infrastructure.repositories.eventSuggestions, + authz, + directory, + messenger, + }); + const events = createEventService({ + events: infrastructure.repositories.events, + scheduler, + messenger, + ...(config.GOOGLE_CALENDAR_ID !== undefined && + config.GOOGLE_SERVICE_ACCOUNT_KEY !== undefined && { + calendar: createGoogleCalendar( + config.GOOGLE_CALENDAR_ID, + config.GOOGLE_SERVICE_ACCOUNT_KEY, + ), + }), + directory, + authz, + log: log.child({ service: 'events' }), + timezone, + }); + const polls = createPollService({ + polls: infrastructure.repositories.polls, + scheduler, + messenger, + directory, + authz, + log: log.child({ service: 'polls' }), + timezone, + }); + const movies = createMovieService({ + catalog: + config.TMDB_ACCESS_TOKEN === undefined + ? undefined + : createTmdbCatalog(config.TMDB_ACCESS_TOKEN), + movies: infrastructure.repositories.movies, + polls, + events, + authz, + timezone, + }); + const birthdays = createBirthdayService({ + birthdays: infrastructure.repositories.birthdays, + scheduler, + messenger, + directory, + authz, + log: log.child({ service: 'birthdays' }), + timezone, + }); + const jobs: Array> = [ + ...birthdays.jobs, + ...polls.jobs, + ...reminders.jobs, + ...announcements.jobs, + ...events.jobs, + ]; + const permissions = createPermissionService({ + grants, + directory, + authz, + log: log.child({ service: 'permissions' }), + known: () => registry.permissions, + }); + const features: Feature[] = [ + roleEvents(roles), + permissionCommands(permissions), + reminderCommands(reminders), + announcementCommands(announcements), + eventCommands(events, directory, timezone, eventSuggestions), + birthdayCommands(birthdays), + pollCommands(polls, directory), + movieCommands(movies), + { + name: 'web', + permissions: [{ id: webAccess, description: 'Open the web dashboard' }], + }, + ]; + + const registry = buildRegistry(features); + + const runnerJobs = new Map>(); + + for (const job of jobs) { + if (runnerJobs.has(job.type)) { + throw new Error(`Duplicate job type "${job.type}"`); + } + + runnerJobs.set(job.type, job); + } + + return { + infrastructure, + client, + authz, + registry, + directory, + jobs: runnerJobs, + web: { + eventSuggestions, + announcements, + events, + polls, + permissions, + birthdays, + movies, + roles, + }, + }; +} + +export function createRegistry(config: Config, log: Logger): Registry { + return compose(config, log).registry; +} + +async function startWeb( + config: Config, + deps: { + directory: Directory; + authz: Authorizer; + services: WebServices; + log: Logger; + logs: LogStore; + }, +): Promise<() => Promise> { + const port = config.WEB_PORT; + const guildId = config.DISCORD_GUILD_ID; + const clientId = config.DISCORD_APPLICATION_ID; + const clientSecret = config.DISCORD_CLIENT_SECRET; + + if (port === undefined || guildId === undefined) { + return () => Promise.resolve(); + } + + if (clientId === undefined || clientSecret === undefined) { + deps.log.warn( + 'Web UI is off: set DISCORD_APPLICATION_ID and DISCORD_CLIENT_SECRET for Discord sign-in', + ); + + return () => Promise.resolve(); + } + + const app = createWebApp({ + guildId, + authz: deps.authz, + timezone: config.DEFAULT_TIMEZONE, + signIn: { + clientId, + clientSecret, + publicUrl: config.WEB_URL ?? `http://localhost:${port}`, + sessionSecret: config.SESSION_SECRET ?? randomBytes(32).toString('hex'), + }, + directory: deps.directory, + services: deps.services, + log: deps.log, + logs: deps.logs, + }); + + return startWebServer(app, { port, host: config.WEB_HOST, log: deps.log }); +} + +function waitForReady(client: Client, token: string): Promise> { + return new Promise((resolve, reject) => { + client.once(Events.ClientReady, resolve); + client.login(token).catch(reject); + }); +} + +export async function startApp( + config: Config, + log: Logger, + logs: LogStore, +): Promise<() => Promise> { + const { infrastructure, client, authz, registry, directory, jobs, web } = + compose(config, log); + const jobLog = log.child({ component: 'scheduler' }); + + try { + await infrastructure.migrate(); + await infrastructure.start(); + const ready = await waitForReady(client, config.DISCORD_TOKEN); + + await infrastructure.startJobs(jobs.values(), jobLog); + + await registerCommands(registry, { + token: config.DISCORD_TOKEN, + applicationId: ready.application.id, + ...(config.DISCORD_GUILD_ID !== undefined && { + guildId: config.DISCORD_GUILD_ID, + }), + }); + + const ctx: AppContext = { log, authz }; + + for (const feature of registry.features) { + for (const listener of feature.events ?? []) { + listener.attach(client, { + ...ctx, + log: log.child({ feature: feature.name }), + }); + } + } + + const handleInteraction = createInteractionHandler(registry, ctx); + + client.on(Events.InteractionCreate, (interaction) => { + handleInteraction(interaction).catch((error: unknown) => { + log.error({ error }, 'Interaction handler crashed'); + }); + }); + client.on(Events.Error, (error) => { + log.error({ error }, 'Discord client error'); + }); + + await Promise.all( + registry.features.map(async (feature) => { + try { + await feature.start?.(); + } catch (error) { + log.error( + { error, feature: feature.name }, + 'Feature failed to start', + ); + } + }), + ); + + const stopWeb = await startWeb(config, { + directory, + authz, + services: web, + log: log.child({ component: 'web' }), + logs, + }); + + log.info( + { + user: ready.user.tag, + features: registry.features.map((f) => f.name), + }, + 'Ready', + ); + + return async () => { + client.removeAllListeners(Events.InteractionCreate); + await stopWeb(); + await infrastructure.stop(); + await client.destroy(); + await infrastructure.close(); + }; + } catch (error) { + await infrastructure.stop().catch(() => null); + await client.destroy(); + await infrastructure.close(); + throw error; + } +} diff --git a/src/config/env.ts b/src/config/env.ts new file mode 100644 index 0000000..ccbe3bc --- /dev/null +++ b/src/config/env.ts @@ -0,0 +1,91 @@ +import { isZone } from '~/core/helpers/time'; +import { z } from 'zod'; + +const optional = (schema: T) => + z.preprocess( + (value) => (value === '' ? undefined : value), + schema.optional(), + ); + +const snowflake = z.string().regex(/^\d{17,20}$/, 'must be a Discord ID'); + +const serviceAccount = z + .string() + .transform((value, ctx): unknown => { + try { + return JSON.parse(value); + } catch { + ctx.addIssue({ code: 'custom', message: 'must be the JSON key file' }); + + return z.NEVER; + } + }) + .pipe(z.object({ client_email: z.email(), private_key: z.string().min(1) })); + +const envSchema = z.object({ + DISCORD_TOKEN: z.string().min(1), + DISCORD_APPLICATION_ID: optional(snowflake), + DISCORD_GUILD_ID: optional(snowflake), + + DATABASE_URL: z.url(), + + LOG_DATABASE_PATH: z.string().min(1).default('logs/lapbot.sqlite'), + LOG_LEVEL: z + .enum(['fatal', 'error', 'warn', 'info', 'debug', 'trace']) + .default('info'), + DEFAULT_TIMEZONE: z + .string() + .default('Europe/Tallinn') + .refine((zone) => isZone(zone), 'must be an IANA timezone'), + + JUHATUS_ROLE_ID: optional(snowflake), + + ROLE_SELECTION_CHANNEL_ID: optional(snowflake), + TARKVARA_ROLE_ID: optional(snowflake), + HELPDESK_ROLE_ID: optional(snowflake), + KULTUUR_ROLE_ID: optional(snowflake), + + TMDB_ACCESS_TOKEN: optional(z.string().min(1)), + + GOOGLE_CALENDAR_ID: optional(z.string().min(1)), + GOOGLE_SERVICE_ACCOUNT_KEY: optional(serviceAccount), + + WEB_PORT: optional(z.coerce.number().int().min(1).max(65_535)), + WEB_HOST: z.string().default('127.0.0.1'), + WEB_URL: optional(z.url()), + DISCORD_CLIENT_SECRET: optional(z.string().min(1)), + SESSION_SECRET: optional( + z.string().min(32, 'must be at least 32 characters'), + ), +}); + +export type Config = z.infer; + +const checkedSchema = envSchema + .refine( + (env) => env.WEB_PORT === undefined || env.DISCORD_GUILD_ID !== undefined, + { + message: 'DISCORD_GUILD_ID is required when WEB_PORT is set', + path: ['DISCORD_GUILD_ID'], + }, + ) + .refine( + (env) => + (env.GOOGLE_CALENDAR_ID === undefined) === + (env.GOOGLE_SERVICE_ACCOUNT_KEY === undefined), + { + message: + 'GOOGLE_CALENDAR_ID and GOOGLE_SERVICE_ACCOUNT_KEY must be set together', + path: ['GOOGLE_CALENDAR_ID'], + }, + ); + +export function loadConfig(env: NodeJS.ProcessEnv = process.env): Config { + const result = checkedSchema.safeParse(env); + + if (!result.success) { + throw new Error(`Invalid configuration:\n${z.prettifyError(result.error)}`); + } + + return result.data; +} diff --git a/src/core/actor.ts b/src/core/actor.ts new file mode 100644 index 0000000..17ef908 --- /dev/null +++ b/src/core/actor.ts @@ -0,0 +1,8 @@ +export interface Actor { + guildId: string; + userId: string; + roleIds: readonly string[]; + administrator: boolean; + owner: boolean; + highestRolePosition: number; +} diff --git a/src/core/errors.ts b/src/core/errors.ts new file mode 100644 index 0000000..e84923e --- /dev/null +++ b/src/core/errors.ts @@ -0,0 +1,9 @@ +export class UserError extends Error { + override readonly name = 'UserError'; +} + +export class PermanentError extends Error { + override readonly name = 'PermanentError'; +} + +export const ignore = () => null; diff --git a/src/core/helpers/async.ts b/src/core/helpers/async.ts new file mode 100644 index 0000000..1fe61cf --- /dev/null +++ b/src/core/helpers/async.ts @@ -0,0 +1,8 @@ +export async function sequential( + items: Iterable, + run: (item: T) => Promise, +): Promise { + for (const item of items) { + await run(item); + } +} diff --git a/src/core/helpers/authorization.ts b/src/core/helpers/authorization.ts new file mode 100644 index 0000000..66e6433 --- /dev/null +++ b/src/core/helpers/authorization.ts @@ -0,0 +1,15 @@ +import type { Actor } from '~/core/actor'; +import type { Permission } from '~/core/permission'; +import type { Authorizer } from '~/core/ports/authorization'; + +export function guard( + authz: Authorizer, + permission: Permission, + method: (actor: Actor, ...args: Args) => Promise, +): (actor: Actor, ...args: Args) => Promise { + return async (actor, ...args) => { + await authz.require(actor, permission); + + return method(actor, ...args); + }; +} diff --git a/src/core/helpers/clock.ts b/src/core/helpers/clock.ts new file mode 100644 index 0000000..10f584f --- /dev/null +++ b/src/core/helpers/clock.ts @@ -0,0 +1,3 @@ +import type { Clock } from '~/core/ports/clock'; + +export const systemClock: Clock = { now: () => new Date() }; diff --git a/src/core/helpers/jobs.ts b/src/core/helpers/jobs.ts new file mode 100644 index 0000000..2da7f5a --- /dev/null +++ b/src/core/helpers/jobs.ts @@ -0,0 +1,22 @@ +import type { z } from 'zod'; +import { PermanentError } from '~/core/errors'; +import type { Job, JobOutcome } from '~/core/ports/scheduler'; + +export function defineJob(definition: { + type: string; + payload: S; + handle: (payload: z.infer) => Promise; +}): Job> { + return { + type: definition.type, + run: async (raw) => { + const parsed = definition.payload.safeParse(raw); + + if (!parsed.success) { + throw new PermanentError(`Invalid payload: ${parsed.error.message}`); + } + + return (await definition.handle(parsed.data)) ?? null; + }, + }; +} diff --git a/src/core/helpers/permissions.ts b/src/core/helpers/permissions.ts new file mode 100644 index 0000000..00b5be3 --- /dev/null +++ b/src/core/helpers/permissions.ts @@ -0,0 +1,32 @@ +import type { Actor } from '~/core/actor'; +import { UserError } from '~/core/errors'; +import { managePermissions, type Permission } from '~/core/permission'; + +export interface Delegation { + actor: Actor; + rolePosition: number; + permission: Permission; + actorHolds: boolean; +} + +export function checkDelegation(delegation: Delegation): void { + const { actor, rolePosition, permission, actorHolds } = delegation; + + if (actor.administrator) { + return; + } + + if (permission === managePermissions) { + throw new UserError( + 'Only administrators can delegate permission management.', + ); + } + + if (actor.highestRolePosition <= rolePosition) { + throw new UserError('That role is not below your highest role.'); + } + + if (!actorHolds) { + throw new UserError('You can only grant permissions you hold yourself.'); + } +} diff --git a/src/core/helpers/roles.ts b/src/core/helpers/roles.ts new file mode 100644 index 0000000..1dbdc82 --- /dev/null +++ b/src/core/helpers/roles.ts @@ -0,0 +1,36 @@ +import { UserError } from '~/core/errors'; +import type { RoleInfo } from '~/core/ports/directory'; + +export function selfAssignProblem(role: RoleInfo): string | undefined { + if (role.everyone) { + return 'is the @everyone role'; + } + + if (role.managed) { + return 'is managed by an integration'; + } + + if (role.moderator) { + return 'grants moderator permissions'; + } + + if (!role.botCanAssign) { + return 'is above my highest role, or I lack Manage Roles'; + } + + return undefined; +} + +export function requireManageable(role: RoleInfo): void { + if (role.managed || !role.botCanAssign) { + throw new UserError( + `I cannot manage ${role.name}: it is managed or above my highest role.`, + ); + } +} + +export function requireMentionable(role: RoleInfo): void { + if (role.everyone || !role.mentionable) { + throw new UserError('You may not mention that role.'); + } +} diff --git a/src/core/helpers/time.ts b/src/core/helpers/time.ts new file mode 100644 index 0000000..db318ea --- /dev/null +++ b/src/core/helpers/time.ts @@ -0,0 +1,176 @@ +import { en, ParsingComponents } from 'chrono-node'; +import { TZDate, tz, tzOffset } from '@date-fns/tz'; +import { addDays, addMonths, addWeeks, isValid, parse, set } from 'date-fns'; +import { UserError } from '~/core/errors'; + +const steps = { daily: addDays, weekly: addWeeks, monthly: addMonths }; + +export const recurrences = ['daily', 'weekly', 'monthly'] as const; + +export type Recurrence = (typeof recurrences)[number]; + +export interface CalendarDay { + year: number; + month: number; + day: number; +} + +export function isZone(zone: string): boolean { + try { + new Intl.DateTimeFormat('en', { timeZone: zone }); + + return true; + } catch { + return false; + } +} + +export function requireZone(zone: string): string { + if (!isZone(zone)) { + throw new UserError( + `Unknown timezone "${zone}". Use an IANA name like Europe/Tallinn.`, + ); + } + + return zone; +} + +export function parseWhen(input: string, zone: string, now = new Date()): Date { + requireZone(zone); + const text = input.trim(); + const result = + text.length <= 100 + ? en.GB.parse( + text, + { instant: now, timezone: tzOffset(zone, now) }, + { forwardDate: true }, + )[0] + : undefined; + + if (result?.text !== text) { + throw new UserError( + `I could not read "${input}". Try "30m", "2 hours", "18:30", "tomorrow at noon", "Friday at 6pm" or "20/11 18:00".`, + ); + } + + const start = result.start; + + if ( + start instanceof ParsingComponents && + !start.isCertain('timezoneOffset') + ) { + start.assign('timezoneOffset', tzOffset(zone, result.date())); + } + + const date = result.date(); + + if (!isValid(date)) { + throw new UserError('That is not a valid time.'); + } + + return new Date(date); +} + +export function parseFutureWhen( + input: string, + zone: string, + now = new Date(), +): Date { + const date = parseWhen(input, zone, now); + + if (date <= now) { + throw new UserError('That time is in the past.'); + } + + return date; +} + +export function nextOccurrence( + from: Date, + recurrence: Recurrence, + zone: string, +): Date { + return new Date(steps[recurrence](from, 1, { in: tz(zone) })); +} + +export function nextFutureOccurrence( + from: Date, + recurrence: Recurrence, + zone: string, + now = new Date(), +): Date { + let next = nextOccurrence(from, recurrence, zone); + + while (next <= now) { + next = nextOccurrence(next, recurrence, zone); + } + + return next; +} + +export function nextDailyRun( + zone: string, + hour: number, + now = new Date(), +): Date { + const today = set( + now, + { hours: hour, minutes: 0, seconds: 0, milliseconds: 0 }, + { in: tz(zone) }, + ); + const next = today <= now ? addDays(today, 1, { in: tz(zone) }) : today; + + return new Date(next); +} + +export function calendarDay(date: Date, zone: string): CalendarDay { + const local = new TZDate(date, zone); + + return { + year: local.getFullYear(), + month: local.getMonth() + 1, + day: local.getDate(), + }; +} + +export function sameCalendarDay(a: Date, b: Date, zone: string): boolean { + return ( + formatCalendarDay(calendarDay(a, zone)) === + formatCalendarDay(calendarDay(b, zone)) + ); +} + +export function zonedTime(day: CalendarDay, hour: number, zone: string): Date { + return new Date( + new TZDate(day.year, day.month - 1, day.day, hour, 0, 0, zone), + ); +} + +export function discordTime( + date: Date, + style: 'F' | 'R' | 'f' | 'D' | 't' = 'F', +): string { + return ``; +} + +export function addCalendarDays(day: CalendarDay, days: number): CalendarDay { + const date = new Date(Date.UTC(day.year, day.month - 1, day.day + days)); + + return { + year: date.getUTCFullYear(), + month: date.getUTCMonth() + 1, + day: date.getUTCDate(), + }; +} + +export function formatCalendarDay(day: CalendarDay): string { + return [day.year, day.month, day.day] + .map((part) => String(part).padStart(2, '0')) + .join('-'); +} + +export function parseCalendarDay(value: string): CalendarDay | undefined { + const date = parse(value, 'yyyy-MM-dd', new Date(0), { in: tz('UTC') }); + + return isValid(date) ? calendarDay(date, 'UTC') : undefined; +} diff --git a/src/core/helpers/visibility.ts b/src/core/helpers/visibility.ts new file mode 100644 index 0000000..5246989 --- /dev/null +++ b/src/core/helpers/visibility.ts @@ -0,0 +1,18 @@ +import type { Directory } from '~/core/ports/directory'; +import type { Actor } from '~/core/actor'; + +export async function visibleRecords( + directory: Directory, + actor: Actor, + records: readonly T[], +): Promise { + const channels = [...new Set(records.map((record) => record.channelId))]; + const allowed = await Promise.all( + channels.map(async (id) => + (await directory.canView(actor, id)) ? [id] : [], + ), + ); + const visible = new Set(allowed.flat()); + + return records.filter((record) => visible.has(record.channelId)); +} diff --git a/src/core/message.ts b/src/core/message.ts new file mode 100644 index 0000000..eead145 --- /dev/null +++ b/src/core/message.ts @@ -0,0 +1,83 @@ +export interface Mentions { + users?: readonly string[]; + roles?: readonly string[]; + here?: boolean; +} + +export interface EmbedField { + name: string; + value: string; + inline?: boolean; +} + +export interface Embed { + title?: string; + description?: string; + url?: string; + color?: number; + fields?: readonly EmbedField[]; + footer?: string; +} + +export type ButtonStyle = 'primary' | 'secondary' | 'success' | 'danger'; + +export type Control = + | { kind: 'button'; id: string; label: string; style: ButtonStyle } + | { + kind: 'select'; + id: string; + placeholder: string; + min: number; + max: number; + options: ReadonlyArray<{ + label: string; + value: string; + default?: boolean; + }>; + }; + +export interface Message { + content?: string; + embeds?: readonly Embed[]; + mentions?: Mentions; + controls?: ReadonlyArray; + suppressEmbeds?: boolean; +} + +export const maxContentLength = 2000; + +export function splitContent(text: string, limit = maxContentLength): string[] { + const parts: string[] = []; + let rest = text; + + while (rest.length > limit) { + const window = rest.slice(0, limit + 1); + const newline = window.lastIndexOf('\n'); + const space = window.lastIndexOf(' '); + const fallback = space > 0 ? space : limit; + const cut = newline > limit / 2 ? newline : fallback; + + parts.push(rest.slice(0, cut)); + rest = rest.slice(cut).replace(/^[\n ]/, ''); + } + + return [...parts, rest]; +} + +export const userMention = (id: string) => `<@${id}>`; + +export const roleMention = (id: string) => `<@&${id}>`; + +export const channelMention = (id: string) => `<#${id}>`; + +export const hereMention = () => '@here'; + +export const controlId = (prefix: string, ...args: Array) => { + const id = [prefix, ...args].join(':'); + + if (id.length > 100) { + throw new Error(`Control ID exceeds 100 characters: ${id}`); + } + + return id; +}; diff --git a/src/core/permission.ts b/src/core/permission.ts new file mode 100644 index 0000000..425fb0e --- /dev/null +++ b/src/core/permission.ts @@ -0,0 +1,14 @@ +export type Permission = `${string}:${string}`; + +export interface PermissionDefinition { + id: Permission; + description: string; + group?: string; +} + +export const managePermissions: Permission = 'permissions:manage'; + +export const webAccess: Permission = 'web:access'; + +// Internal navigation capability, never assignable through grants. +export const applicationAdmin: Permission = 'application:administrator'; diff --git a/src/core/ports/authorization.ts b/src/core/ports/authorization.ts new file mode 100644 index 0000000..c09abda --- /dev/null +++ b/src/core/ports/authorization.ts @@ -0,0 +1,11 @@ +import type { Actor } from '~/core/actor'; +import type { Permission } from '~/core/permission'; + +export interface Authorizer { + can: (actor: Actor, permission: Permission) => Promise; + require: (actor: Actor, permission: Permission) => Promise; + granted: ( + actor: Actor, + permissions: readonly Permission[], + ) => Promise>; +} diff --git a/src/core/ports/calendar.ts b/src/core/ports/calendar.ts new file mode 100644 index 0000000..46ad625 --- /dev/null +++ b/src/core/ports/calendar.ts @@ -0,0 +1,20 @@ +export interface CalendarEvent { + title: string; + description: string; + location: string; + startsAt: Date; + endsAt: Date; +} + +export interface CalendarEntry { + id: string; + title: string; + startsAt: Date; + allDay: boolean; +} + +export interface Calendar { + upsert: (id: string | null, event: CalendarEvent) => Promise; + remove: (id: string) => Promise; + between: (from: Date, to: Date) => Promise; +} diff --git a/src/core/ports/clock.ts b/src/core/ports/clock.ts new file mode 100644 index 0000000..404daf7 --- /dev/null +++ b/src/core/ports/clock.ts @@ -0,0 +1,3 @@ +export interface Clock { + now: () => Date; +} diff --git a/src/core/ports/directory.ts b/src/core/ports/directory.ts new file mode 100644 index 0000000..7c474f8 --- /dev/null +++ b/src/core/ports/directory.ts @@ -0,0 +1,41 @@ +import type { Actor } from '~/core/actor'; + +export interface ChannelInfo { + id: string; + name: string; + kind: 'text' | 'announcement'; +} + +export interface Directory { + guildOf: (channelId: string) => Promise; + channels: (guildId: string) => Promise; + roles: (guildId: string) => Promise; + role: (guildId: string, roleId: string) => Promise; + member: (guildId: string, userId: string) => Promise; + displayName: (guildId: string, userId: string) => Promise; + canView: (actor: Actor, channelId: string) => Promise; + canPost: (actor: Actor, channelId: string) => Promise; + isPublic: (guildId: string, channelId: string) => Promise; + addRoles: ( + member: { guildId: string; userId: string }, + roleIds: readonly string[], + reason: string, + ) => Promise; + removeRoles: ( + member: { guildId: string; userId: string }, + roleIds: readonly string[], + reason: string, + ) => Promise; +} + +export interface RoleInfo { + id: string; + name: string; + position: number; + everyone: boolean; + managed: boolean; + mentionable: boolean; + moderator: boolean; + administrator: boolean; + botCanAssign: boolean; +} diff --git a/src/core/ports/logger.ts b/src/core/ports/logger.ts new file mode 100644 index 0000000..22ce8e8 --- /dev/null +++ b/src/core/ports/logger.ts @@ -0,0 +1,9 @@ +type Log = (details: object, message: string) => void; + +export interface Logger { + debug: Log; + info: Log; + warn: Log; + error: Log; + child: (bindings: object) => Logger; +} diff --git a/src/core/ports/messenger.ts b/src/core/ports/messenger.ts new file mode 100644 index 0000000..756afb6 --- /dev/null +++ b/src/core/ports/messenger.ts @@ -0,0 +1,26 @@ +import type { Message } from '~/core/message'; + +export interface Sent { + channelId: string; + messageId: string; +} + +export interface Messenger { + send: (channelId: string, message: Message) => Promise; + edit: ( + channelId: string, + messageId: string, + message: Message, + ) => Promise; + remove: (channelId: string, messageId: string) => Promise; + direct: (userId: string, message: Message) => Promise; + exists: (channelId: string, messageId: string) => Promise; + findOwn: (channelId: string, content: string) => Promise; + clearReactionsExcept: ( + channelId: string, + messageId: string, + emojis: readonly string[], + ) => Promise; + ownReactions: (channelId: string, messageId: string) => Promise; + react: (channelId: string, messageId: string, emoji: string) => Promise; +} diff --git a/src/core/ports/movie-catalog.ts b/src/core/ports/movie-catalog.ts new file mode 100644 index 0000000..dfe0757 --- /dev/null +++ b/src/core/ports/movie-catalog.ts @@ -0,0 +1,12 @@ +export interface MovieDetails { + tmdbId: number; + title: string; + year: number | null; + overview: string | null; + posterUrl: string | null; + trailerUrl: string | null; +} + +export interface MovieCatalog { + lookup: (title: string, year: number | null) => Promise; +} diff --git a/src/core/ports/scheduler.ts b/src/core/ports/scheduler.ts new file mode 100644 index 0000000..c555e54 --- /dev/null +++ b/src/core/ports/scheduler.ts @@ -0,0 +1,21 @@ +export type JobOutcome = null | { rescheduleAt: Date }; + +export interface Job

{ + type: string; + run: (raw: unknown) => Promise; + payloadType?: P; +} + +export interface ScheduleOptions { + runAt: Date; + key: string; +} + +export interface Scheduler { + schedule:

( + job: Job

, + payload: P, + options: ScheduleOptions, + ) => Promise; + cancel:

(job: Job

, key: string) => Promise; +} diff --git a/src/core/posts.ts b/src/core/posts.ts new file mode 100644 index 0000000..b3672ec --- /dev/null +++ b/src/core/posts.ts @@ -0,0 +1,19 @@ +import { roleMention, type Message } from './message'; + +export interface Post { + title?: string | null; + content: string; + mentionRoleIds?: readonly string[]; +} + +export function renderPost(post: Post): Message { + const roles = post.mentionRoleIds ?? []; + const pings = roles.map((id) => roleMention(id)).join(' '); + const heading = + post.title === null || post.title === undefined ? '' : `# ${post.title}\n`; + + return { + content: [pings, `${heading}${post.content}`].filter(Boolean).join('\n'), + mentions: { roles }, + }; +} diff --git a/src/discord/commands/announcements.ts b/src/discord/commands/announcements.ts new file mode 100644 index 0000000..86cf8c1 --- /dev/null +++ b/src/discord/commands/announcements.ts @@ -0,0 +1,359 @@ +import { + ChannelType, + InteractionContextType, + LabelBuilder, + ModalBuilder, + RoleSelectMenuBuilder, + SlashCommandBuilder, + TextInputBuilder, + TextInputStyle, +} from 'discord.js'; +import type { Announcement } from '~/features/announcements/model'; +import { + maxAnnouncementLength, + type AnnouncementService, +} from '~/features/announcements/service'; +import { + channelMention, + controlId, + maxContentLength, + splitContent, + type Message, +} from '~/core/message'; +import { discordTime } from '~/core/helpers/time'; +import { UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import { toActor } from '~/discord/interactions/actor'; +import { bySubcommand } from './handlers'; +import type { + AppContext, + ComponentHandler, + Feature, +} from '~/discord/contracts'; +import { render } from '~/discord/render'; +import { respond, respondView } from '~/discord/interactions/responses'; + +function contentModal( + id: string, + title: string, + current?: Announcement, +): ModalBuilder { + const titleInput = new TextInputBuilder() + .setCustomId('title') + .setStyle(TextInputStyle.Short) + .setRequired(false) + .setMaxLength(256); + const contentInput = new TextInputBuilder() + .setCustomId('content') + .setStyle(TextInputStyle.Paragraph) + .setMaxLength(maxAnnouncementLength); + + if (current?.title !== undefined && current.title !== null) { + titleInput.setValue(current.title); + } + + if (current) { + contentInput.setValue(current.content); + } + + return new ModalBuilder() + .setCustomId(id) + .setTitle(title) + .addLabelComponents( + new LabelBuilder().setLabel('Title').setTextInputComponent(titleInput), + new LabelBuilder() + .setLabel('Content') + .setTextInputComponent(contentInput), + ); +} + +const data = new SlashCommandBuilder() + .setName('announce') + .setDescription('Write an announcement') + .setContexts(InteractionContextType.Guild) + .addSubcommand((sub) => + sub + .setName('create') + .setDescription('Write, preview and publish an announcement') + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Where to post it') + .setRequired(true) + .addChannelTypes( + ChannelType.GuildText, + ChannelType.GuildAnnouncement, + ), + ), + ) + .addSubcommand((sub) => + sub + .setName('edit') + .setDescription('Fix the text of an announcement') + .addIntegerOption((o) => + o + .setName('id') + .setDescription('Announcement') + .setRequired(true) + .setAutocomplete(true), + ), + ); + +export function announcementCommands( + announcements: AnnouncementService, +): Feature { + const draftView = async ( + announcement: Announcement, + actor: Actor, + ctx: AppContext, + ): Promise => { + const [first, ...rest] = announcements.view(announcement); + const heading = `-# Preview for ${channelMention(announcement.channelId)}`; + const plural = rest.length === 1 ? '' : 's'; + const more = + rest.length === 0 + ? '' + : `\n-# Continues in ${rest.length} more message${plural}`; + const [body = ''] = splitContent( + first?.content ?? '', + maxContentLength - heading.length - more.length - 1, + ); + const action = (name: string) => + controlId('announcements:act', announcement.id, name); + const [canPublish, canSchedule] = await Promise.all([ + ctx.authz.can(actor, 'announcement:publish'), + ctx.authz.can(actor, 'announcement:schedule'), + ]); + + return { + ...first, + content: `${heading}\n${body}${more}`, + controls: [ + [ + ...(canPublish + ? [ + { + kind: 'button' as const, + id: action('publish'), + label: 'Publish now', + style: 'primary' as const, + }, + ] + : []), + ...(canSchedule + ? [ + { + kind: 'button' as const, + id: action('schedule'), + label: 'Schedule…', + style: 'secondary' as const, + }, + ] + : []), + { + kind: 'button', + id: action('edit'), + label: 'Edit', + style: 'secondary', + }, + { + kind: 'button', + id: action('discard'), + label: 'Discard', + style: 'danger', + }, + ], + ], + }; + }; + + const done = (content: string) => ({ content, embeds: [], components: [] }); + + const create: ComponentHandler = { + prefix: 'announcements:create', + execute: async (interaction, [channelId = ''], ctx) => { + if (!interaction.isModalSubmit()) { + return; + } + + const actor = toActor(interaction.member); + const roles = interaction.fields.getSelectedRoles('mentions'); + const announcement = await announcements.draft(actor, { + channelId, + title: interaction.fields.getTextInputValue('title'), + content: interaction.fields.getTextInputValue('content'), + mentionRoleIds: roles ? [...roles.keys()] : [], + }); + + await respondView(interaction, await draftView(announcement, actor, ctx)); + }, + }; + + const act: ComponentHandler = { + prefix: 'announcements:act', + execute: async (interaction, [rawId, name]) => { + const id = Number(rawId); + + if (!interaction.isButton() || !Number.isSafeInteger(id)) { + throw new UserError('This button is invalid.'); + } + + const actor = toActor(interaction.member); + + if (name === 'publish') { + const published = await announcements.publish(actor, id); + + await interaction.update( + done(`Published in ${channelMention(published.channelId)}.`), + ); + } else if (name === 'schedule') { + await interaction.showModal( + new ModalBuilder() + .setCustomId(controlId('announcements:when', id)) + .setTitle('Schedule announcement') + .addLabelComponents( + new LabelBuilder() + .setLabel('When') + .setDescription('e.g. tomorrow 18:00, fri 9:00, 20/11 18:00') + .setTextInputComponent( + new TextInputBuilder() + .setCustomId('when') + .setStyle(TextInputStyle.Short), + ), + ), + ); + } else if (name === 'edit') { + await interaction.showModal( + contentModal( + controlId('announcements:edit', id), + 'Edit announcement', + await announcements.get(actor, id), + ), + ); + } else if (name === 'discard') { + await announcements.cancel(actor, id); + await interaction.update(done('Discarded.')); + } else { + throw new UserError('This button is invalid.'); + } + }, + }; + + const when: ComponentHandler = { + prefix: 'announcements:when', + execute: async (interaction, [id]) => { + if (!interaction.isModalSubmit() || !interaction.isFromMessage()) { + return; + } + + const scheduled = await announcements.schedule( + toActor(interaction.member), + Number(id), + interaction.fields.getTextInputValue('when'), + ); + + await interaction.update( + done( + `Will be posted in ${channelMention(scheduled.channelId)} ${discordTime(scheduled.scheduledAt ?? new Date())}.`, + ), + ); + }, + }; + + const edit: ComponentHandler = { + prefix: 'announcements:edit', + execute: async (interaction, [id], ctx) => { + if (!interaction.isModalSubmit()) { + return; + } + + const actor = toActor(interaction.member); + const updated = await announcements.edit(actor, Number(id), { + title: interaction.fields.getTextInputValue('title'), + content: interaction.fields.getTextInputValue('content'), + }); + + if (interaction.isFromMessage() && updated.status === 'draft') { + const { content, components } = render( + await draftView(updated, actor, ctx), + ); + + await interaction.update({ content, components }); + + return; + } + + await respond(interaction, 'Announcement updated.'); + }, + }; + + return { + name: 'announcements', + permissions: [ + { id: 'announcement:create', description: 'Write announcements' }, + { + id: 'announcement:publish', + description: 'Publish and edit any announcement', + }, + { id: 'announcement:schedule', description: 'Schedule announcements' }, + ], + components: [create, act, when, edit], + commands: [ + { + data: data.toJSON(), + permissions: { create: 'announcement:create' }, + execute: bySubcommand({ + create: async (interaction) => { + const channel = interaction.options.getChannel('channel', true); + + await interaction.showModal( + contentModal( + controlId('announcements:create', channel.id), + 'New announcement', + ).addLabelComponents( + new LabelBuilder() + .setLabel('Mention roles') + .setRoleSelectMenuComponent( + new RoleSelectMenuBuilder() + .setCustomId('mentions') + .setRequired(false) + .setMaxValues(25), + ), + ), + ); + }, + edit: async (interaction) => { + const announcement = await announcements.get( + toActor(interaction.member), + interaction.options.getInteger('id', true), + ); + + await interaction.showModal( + contentModal( + controlId('announcements:edit', announcement.id), + `Edit announcement #${announcement.id}`, + announcement, + ), + ); + }, + }), + autocomplete: async (interaction) => { + const rows = await announcements.list(toActor(interaction.member)); + + await interaction.respond( + rows + .filter((row) => row.status !== 'cancelled') + .slice(0, 25) + .map((row) => ({ + name: `#${row.id} [${row.status}] ${row.title ?? row.content}`.slice( + 0, + 100, + ), + value: row.id, + })), + ); + }, + }, + ], + }; +} diff --git a/src/discord/commands/birthdays.ts b/src/discord/commands/birthdays.ts new file mode 100644 index 0000000..969ad31 --- /dev/null +++ b/src/discord/commands/birthdays.ts @@ -0,0 +1,297 @@ +import { + ChannelType, + InteractionContextType, + LabelBuilder, + ModalBuilder, + SlashCommandBuilder, + StringSelectMenuBuilder, + TextInputBuilder, + TextInputStyle, +} from 'discord.js'; +import { + describeBirthday, + type BirthdayService, +} from '~/features/birthdays/service'; +import { + birthdayVisibilities, + birthdayVisibilityLabels, +} from '~/features/birthdays/rules'; +import { toActor } from '~/discord/interactions/actor'; +import { bySubcommand } from './handlers'; +import type { ComponentHandler, Feature } from '~/discord/contracts'; +import { respond } from '~/discord/interactions/responses'; + +const months = [ + 'January', + 'February', + 'March', + 'April', + 'May', + 'June', + 'July', + 'August', + 'September', + 'October', + 'November', + 'December', +]; + +const data = new SlashCommandBuilder() + .setName('birthday') + .setDescription('Birthdays') + .setContexts(InteractionContextType.Guild) + .addSubcommand((sub) => + sub + .setName('set') + .setDescription('Save your birthday (no year needed)') + .addIntegerOption((o) => + o + .setName('day') + .setDescription('Day') + .setRequired(true) + .setMinValue(1) + .setMaxValue(31), + ) + .addIntegerOption((o) => + o + .setName('month') + .setDescription('Month') + .setRequired(true) + .setMinValue(1) + .setMaxValue(12), + ) + .addStringOption((o) => + o + .setName('visibility') + .setDescription('Who gets to know (default: announce and list it)') + .addChoices( + birthdayVisibilities.map((v) => ({ + name: birthdayVisibilityLabels[v], + value: v, + })), + ), + ), + ) + .addSubcommand((sub) => + sub.setName('remove').setDescription('Delete your birthday data'), + ) + .addSubcommand((sub) => + sub + .setName('view') + .setDescription('See a birthday') + .addUserOption((o) => + o.setName('member').setDescription('Member (default: you)'), + ), + ) + .addSubcommand((sub) => + sub.setName('upcoming').setDescription('Upcoming public birthdays'), + ) + .addSubcommand((sub) => + sub + .setName('post') + .setDescription('Post a message with an "Add my birthday" button') + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Where to post it (default: here)') + .addChannelTypes(ChannelType.GuildText), + ), + ) + .addSubcommand((sub) => + sub + .setName('settings') + .setDescription('Configure birthday announcements') + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Announcement channel') + .addChannelTypes(ChannelType.GuildText), + ) + .addRoleOption((o) => + o.setName('role').setDescription('Role to give for the day'), + ) + .addIntegerOption((o) => + o + .setName('hour') + .setDescription('Hour to announce (server time)') + .setMinValue(0) + .setMaxValue(23), + ) + .addBooleanOption((o) => + o.setName('disable').setDescription('Turn announcements off'), + ), + ); + +export function birthdayCommands(birthdays: BirthdayService): Feature { + const add: ComponentHandler = { + prefix: 'birthdays:add', + execute: async (interaction) => { + if (!interaction.isButton()) { + return; + } + + const current = await birthdays.view( + toActor(interaction.member), + interaction.user.id, + ); + const day = new TextInputBuilder() + .setCustomId('day') + .setStyle(TextInputStyle.Short) + .setMinLength(1) + .setMaxLength(2) + .setPlaceholder('e.g. 17'); + + if (current) { + day.setValue(String(current.day)); + } + + await interaction.showModal( + new ModalBuilder() + .setCustomId('birthdays:save') + .setTitle('Your birthday') + .addLabelComponents( + new LabelBuilder().setLabel('Month').setStringSelectMenuComponent( + new StringSelectMenuBuilder().setCustomId('month').addOptions( + months.map((name, index) => ({ + label: name, + value: String(index + 1), + default: current?.month === index + 1, + })), + ), + ), + new LabelBuilder().setLabel('Day').setTextInputComponent(day), + new LabelBuilder() + .setLabel('Who gets to know') + .setStringSelectMenuComponent( + new StringSelectMenuBuilder() + .setCustomId('visibility') + .addOptions( + birthdayVisibilities.map((value) => ({ + label: birthdayVisibilityLabels[value], + value, + default: (current?.visibility ?? 'public') === value, + })), + ), + ), + ), + ); + }, + }; + + const save: ComponentHandler = { + prefix: 'birthdays:save', + execute: async (interaction) => { + if (!interaction.isModalSubmit()) { + return; + } + + const [month = ''] = interaction.fields.getStringSelectValues('month'); + const [visibility = 'public'] = + interaction.fields.getStringSelectValues('visibility'); + const saved = await birthdays.set(toActor(interaction.member), { + day: Number(interaction.fields.getTextInputValue('day')), + month: Number(month), + visibility, + }); + + await respond(interaction, `Saved. ${birthdayVisibilityLabels[saved]}.`); + }, + }; + + return { + components: [add, save], + name: 'birthdays', + permissions: [ + { + id: 'birthday:manage', + description: 'Configure birthday announcements', + }, + ], + commands: [ + { + data: data.toJSON(), + execute: bySubcommand({ + set: async (interaction) => { + const day = interaction.options.getInteger('day', true); + const month = interaction.options.getInteger('month', true); + const visibility = await birthdays.set( + toActor(interaction.member), + { + day, + month, + visibility: + interaction.options.getString('visibility') ?? 'public', + }, + ); + const leap = + month === 2 && day === 29 + ? ' In non-leap years it is celebrated on 28 February.' + : ''; + + await respond( + interaction, + `Saved. ${birthdayVisibilityLabels[visibility]}.${leap}`, + ); + }, + remove: async (interaction) => { + const removed = await birthdays.remove(toActor(interaction.member)); + + await respond( + interaction, + removed + ? 'Your birthday data is deleted.' + : 'You had no birthday saved.', + ); + }, + view: async (interaction) => { + const user = + interaction.options.getUser('member') ?? interaction.user; + const birthday = await birthdays.view( + toActor(interaction.member), + user.id, + ); + + await respond( + interaction, + birthday ? describeBirthday(birthday) : 'No birthday to show.', + ); + }, + upcoming: async (interaction) => { + const list = await birthdays.upcoming(interaction.guildId); + + await respond( + interaction, + list.length === 0 + ? 'No public birthdays yet.' + : list.map((birthday) => describeBirthday(birthday)).join('\n'), + ); + }, + post: async (interaction) => { + const channelId = + interaction.options.getChannel('channel')?.id ?? + interaction.channelId; + + await birthdays.postSignup(toActor(interaction.member), channelId); + await respond(interaction, 'Posted.'); + }, + settings: async (interaction) => { + const channel = interaction.options.getChannel('channel'); + const role = interaction.options.getRole('role'); + const hour = interaction.options.getInteger('hour'); + const message = await birthdays.configure( + toActor(interaction.member), + { + ...(channel && { channelId: channel.id }), + ...(role && { roleId: role.id }), + ...(hour !== null && { hour }), + disable: interaction.options.getBoolean('disable') ?? false, + }, + ); + + await respond(interaction, message); + }, + }), + }, + ], + }; +} diff --git a/src/discord/commands/events.ts b/src/discord/commands/events.ts new file mode 100644 index 0000000..0e6f485 --- /dev/null +++ b/src/discord/commands/events.ts @@ -0,0 +1,426 @@ +import type { EventSuggestionService } from '~/features/event-suggestions/service'; +import { visibleRecords } from '~/core/helpers/visibility'; +import { + ChannelType, + InteractionContextType, + SlashCommandBuilder, + type SlashCommandIntegerOption, +} from 'discord.js'; +import { rsvpStatuses, type RsvpStatus } from '~/features/events/model'; +import type { Directory } from '~/core/ports/directory'; +import { reminderChoices, type EventService } from '~/features/events/service'; +import { dayChoice, dayOverview, rsvpLabels } from '~/features/events/message'; +import { channelMention, userMention } from '~/core/message'; +import { discordTime } from '~/core/helpers/time'; +import { UserError } from '~/core/errors'; +import { toActor } from '~/discord/interactions/actor'; +import { bySubcommand, deferred } from './handlers'; +import type { + CommandInteraction, + ComponentHandler, + Feature, +} from '~/discord/contracts'; +import { render } from '~/discord/render'; +import { respond, respondView } from '~/discord/interactions/responses'; + +const idOption = (o: SlashCommandIntegerOption) => + o + .setName('id') + .setDescription('Event') + .setRequired(true) + .setAutocomplete(true); + +const data = new SlashCommandBuilder() + .setName('event') + .setDescription('Organise events') + .setContexts(InteractionContextType.Guild) + .addSubcommand((sub) => + sub + .setName('suggest') + .setDescription('Suggest an event idea') + .addStringOption((o) => + o + .setName('text') + .setDescription('Your idea') + .setRequired(true) + .setMaxLength(1500), + ), + ) + .addSubcommand((sub) => + sub + .setName('calendar') + .setDescription('Also post an event to the club calendar') + .addIntegerOption(idOption), + ) + .addSubcommand((sub) => + sub + .setName('create') + .setDescription('Create and publish an event') + .addStringOption((o) => + o + .setName('title') + .setDescription('Title') + .setRequired(true) + .setMaxLength(200), + ) + .addStringOption((o) => + o + .setName('start') + .setDescription('e.g. fri 18:00, tomorrow 19:00, 20/11 18:00') + .setRequired(true) + .setAutocomplete(true), + ) + .addStringOption((o) => + o + .setName('description') + .setDescription('Description') + .setMaxLength(1500), + ) + .addStringOption((o) => + o.setName('end').setDescription('e.g. 21:00 or 3h after the start'), + ) + .addStringOption((o) => + o.setName('location').setDescription('Place or link').setMaxLength(200), + ) + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Where to post (default: here)') + .addChannelTypes( + ChannelType.GuildText, + ChannelType.GuildAnnouncement, + ), + ) + .addIntegerOption((o) => + o + .setName('capacity') + .setDescription('Maximum attendees') + .setMinValue(1) + .setMaxValue(10_000), + ) + .addRoleOption((o) => + o.setName('mention').setDescription('Role to notify'), + ) + .addStringOption((o) => + o + .setName('reminders') + .setDescription( + 'When to remind people who are going (default 1 hour before)', + ) + .addChoices( + reminderChoices.map(({ label, value }) => ({ name: label, value })), + ), + ) + .addBooleanOption((o) => + o + .setName('calendar') + .setDescription('Also add it to the club Google Calendar'), + ) + .addBooleanOption((o) => + o.setName('icons').setDescription('Show 🗓️ 🕐 📍 icons (default yes)'), + ), + ) + .addSubcommand((sub) => + sub + .setName('edit') + .setDescription('Change an event') + .addIntegerOption(idOption) + .addStringOption((o) => + o.setName('title').setDescription('Title').setMaxLength(200), + ) + .addStringOption((o) => + o.setName('start').setDescription('e.g. fri 18:00 or 20/11 18:00'), + ) + .addStringOption((o) => o.setName('end').setDescription('End time')) + .addStringOption((o) => + o + .setName('description') + .setDescription('Description') + .setMaxLength(1500), + ) + .addStringOption((o) => + o.setName('location').setDescription('Place or link').setMaxLength(200), + ) + .addIntegerOption((o) => + o + .setName('capacity') + .setDescription('Maximum attendees') + .setMinValue(1), + ) + .addBooleanOption((o) => + o.setName('icons').setDescription('Show 🗓️ 🕐 📍 icons'), + ), + ) + .addSubcommand((sub) => + sub + .setName('cancel') + .setDescription('Cancel an event') + .addIntegerOption(idOption), + ) + .addSubcommand((sub) => sub.setName('list').setDescription('Upcoming events')) + .addSubcommand((sub) => + sub + .setName('view') + .setDescription('Show an event') + .addIntegerOption(idOption), + ) + .addSubcommand((sub) => + sub + .setName('attendees') + .setDescription('Who is coming') + .addIntegerOption(idOption), + ); + +function optional(interaction: CommandInteraction, name: string) { + return interaction.options.getString(name) ?? undefined; +} + +export function eventCommands( + events: EventService, + directory: Directory, + timezone: string, + suggestions: EventSuggestionService, +): Feature { + const rsvp: ComponentHandler = { + prefix: 'events:rsvp', + execute: async (interaction, [id, answer]) => { + const status = rsvpStatuses.find((s) => s === answer); + const eventId = Number(id); + + if ( + !interaction.isButton() || + status === undefined || + !Number.isSafeInteger(eventId) + ) { + throw new UserError('This button is invalid.'); + } + + const view = await events.rsvp( + toActor(interaction.member), + eventId, + status, + ); + const { content, embeds, components } = render(view); + + await interaction.update({ content, embeds, components }); + await respond(interaction, `RSVP saved: **${rsvpLabels[status]}**.`); + }, + }; + + return { + name: 'events', + permissions: [ + { + id: 'event:suggestions:manage', + description: 'Review event suggestions', + }, + { id: 'event:create', description: 'Create events' }, + { + id: 'event:calendar:publish', + description: 'Crosspost events to the club calendar', + }, + { id: 'event:manage', description: 'Edit and cancel any event' }, + ], + components: [rsvp], + commands: [ + { + data: data.toJSON(), + permissions: { create: 'event:create' }, + execute: bySubcommand({ + suggest: deferred(async (interaction) => { + const result = await suggestions.suggest( + toActor(interaction.member), + interaction.channelId, + interaction.options.getString('text', true), + ); + + await respond( + interaction, + result.posted + ? 'Your event suggestion was saved and posted.' + : 'Your suggestion was saved, but could not be posted publicly.', + ); + }), + calendar: deferred(async (interaction) => { + const event = await events.crosspost( + toActor(interaction.member), + interaction.options.getInteger('id', true), + ); + + await respond( + interaction, + `Event #${event.id} posted to the calendar.`, + ); + }), + create: deferred(async (interaction) => { + const capacity = interaction.options.getInteger('capacity'); + const icons = interaction.options.getBoolean('icons'); + const mention = interaction.options.getRole('mention'); + const fields = [ + 'description', + 'end', + 'location', + 'reminders', + ] as const; + const extras = Object.fromEntries( + fields.flatMap((name) => { + const value = optional(interaction, name); + + return value === undefined ? [] : [[name, value]]; + }), + ); + const actor = toActor(interaction.member); + const start = interaction.options.getString('start', true); + const day = await events.sameDay(actor, start).catch(() => null); + const event = await events.create(actor, { + ...extras, + title: interaction.options.getString('title', true), + start, + channelId: + interaction.options.getChannel('channel')?.id ?? + interaction.channelId, + calendar: interaction.options.getBoolean('calendar') ?? false, + ...(capacity !== null && { capacity }), + ...(icons !== null && { icons }), + ...(mention && { mentionRoleId: mention.id }), + }); + + await respond( + interaction, + [ + `Created event #${event.id} in ${channelMention(event.channelId)}.`, + ...(day && day.entries.length > 0 + ? [`That day ${dayOverview(day.entries, timezone)}.`] + : []), + ].join('\n'), + ); + }), + edit: deferred(async (interaction) => { + const capacity = interaction.options.getInteger('capacity'); + const icons = interaction.options.getBoolean('icons'); + const fields = [ + 'title', + 'start', + 'end', + 'description', + 'location', + ] as const; + const changes = Object.fromEntries( + fields.flatMap((name) => { + const value = optional(interaction, name); + + return value === undefined ? [] : [[name, value]]; + }), + ); + const event = await events.edit( + toActor(interaction.member), + interaction.options.getInteger('id', true), + { + ...changes, + ...(capacity !== null && { capacity }), + ...(icons !== null && { icons }), + }, + ); + + await respond(interaction, `Event #${event.id} updated.`); + }), + cancel: deferred(async (interaction) => { + const event = await events.cancel( + toActor(interaction.member), + interaction.options.getInteger('id', true), + ); + + await respond(interaction, `Event #${event.id} is cancelled.`); + }), + list: async (interaction) => { + const upcoming = await visibleRecords( + directory, + toActor(interaction.member), + await events.upcoming(interaction.guildId), + ); + + await respond( + interaction, + upcoming.length === 0 + ? 'No upcoming events.' + : upcoming + .map( + (e) => + `#${e.id} **${e.title}** - ${discordTime(e.startsAt, 'f')}`, + ) + .join('\n'), + ); + }, + view: async (interaction) => { + const view = await events.view( + toActor(interaction.member), + interaction.options.getInteger('id', true), + ); + + await respondView(interaction, { ...view, controls: [] }); + }, + attendees: async (interaction) => { + const { attendees } = await events.attendees( + toActor(interaction.member), + interaction.options.getInteger('id', true), + ); + const section = (status: RsvpStatus) => { + const ids = attendees + .filter((a) => a.status === status) + .map((a) => userMention(a.userId)); + + return `**${rsvpLabels[status]} (${ids.length})**\n${ids.join(' ') || '-'}`; + }; + + await respond( + interaction, + rsvpStatuses + .map((status) => section(status)) + .join('\n\n') + .slice(0, 2000), + ); + }, + }), + autocomplete: async (interaction) => { + const focused = interaction.options.getFocused(true); + + if (focused.name === 'start') { + const typed = focused.value.trim(); + const day = + typed === '' + ? null + : await events + .sameDay(toActor(interaction.member), typed) + .catch(() => null); + + await interaction.respond( + day && typed.length <= 100 + ? [ + { + name: dayChoice(day.startsAt, day.entries, timezone), + value: typed, + }, + ] + : [], + ); + + return; + } + + const upcoming = await visibleRecords( + directory, + toActor(interaction.member), + await events.upcoming(interaction.guildId), + ); + + await interaction.respond( + upcoming.map((e) => ({ + name: `#${e.id} ${e.title}`.slice(0, 100), + value: e.id, + })), + ); + }, + }, + ], + }; +} diff --git a/src/discord/commands/handlers.ts b/src/discord/commands/handlers.ts new file mode 100644 index 0000000..8317139 --- /dev/null +++ b/src/discord/commands/handlers.ts @@ -0,0 +1,42 @@ +import { MessageFlags } from 'discord.js'; +import type { + AppContext, + CommandInteraction, + SlashCommand, +} from '~/discord/contracts'; + +type SubcommandHandler = ( + interaction: CommandInteraction, + ctx: AppContext, +) => Promise; + +export function subcommandPath(interaction: CommandInteraction): string { + return [ + interaction.options.getSubcommandGroup(false), + interaction.options.getSubcommand(false), + ] + .filter(Boolean) + .join(' '); +} + +export function bySubcommand( + handlers: Record, +): SlashCommand['execute'] { + return async (interaction, ctx) => { + const path = subcommandPath(interaction); + const handler = handlers[path]; + + if (!handler) { + throw new Error(`No handler for /${interaction.commandName} ${path}`); + } + + await handler(interaction, ctx); + }; +} + +export function deferred(handler: SubcommandHandler): SubcommandHandler { + return async (interaction, ctx) => { + await interaction.deferReply({ flags: MessageFlags.Ephemeral }); + await handler(interaction, ctx); + }; +} diff --git a/src/discord/commands/movies.ts b/src/discord/commands/movies.ts new file mode 100644 index 0000000..0452664 --- /dev/null +++ b/src/discord/commands/movies.ts @@ -0,0 +1,291 @@ +import { + ChannelType, + InteractionContextType, + SlashCommandBuilder, + type SlashCommandIntegerOption, +} from 'discord.js'; +import type { MovieService } from '~/features/movies/service'; +import { discordTime } from '~/core/helpers/time'; +import { userMention } from '~/core/message'; +import { maxPollOptions } from '~/features/polls/rules'; +import { + movieLabel, + movieLinks, + type MovieLink, +} from '~/features/movies/rules'; +import { toActor } from '~/discord/interactions/actor'; +import { bySubcommand, deferred } from './handlers'; +import type { Feature } from '~/discord/contracts'; +import { respond } from '~/discord/interactions/responses'; + +const linkLine = (links: readonly MovieLink[]) => + links.map(({ label, url }) => `[${label}](${url})`).join(' · '); + +const movieOption = (o: SlashCommandIntegerOption) => + o.setName('movie').setDescription('Movie').setAutocomplete(true); + +const data = new SlashCommandBuilder() + .setName('movie') + .setDescription('Movie suggestions and movie nights') + .setContexts(InteractionContextType.Guild) + .addSubcommand((sub) => + sub + .setName('suggest') + .setDescription('Suggest a movie') + .addStringOption((o) => + o + .setName('title') + .setDescription('Title') + .setRequired(true) + .setMaxLength(200), + ) + .addIntegerOption((o) => + o + .setName('year') + .setDescription('Release year') + .setMinValue(1880) + .setMaxValue(2100), + ) + .addStringOption((o) => + o.setName('note').setDescription('Why watch it?').setMaxLength(300), + ) + .addStringOption((o) => + o + .setName('link') + .setDescription('A link, e.g. Letterboxd or a trailer') + .setMaxLength(300), + ), + ) + .addSubcommand((sub) => + sub + .setName('link') + .setDescription('Add a link to a suggestion') + .addIntegerOption((o) => movieOption(o).setRequired(true)) + .addStringOption((o) => + o + .setName('url') + .setDescription('e.g. Letterboxd, IMDb or a trailer') + .setRequired(true) + .setMaxLength(300), + ), + ) + .addSubcommand((sub) => + sub.setName('suggestions').setDescription('Movies waiting to be watched'), + ) + .addSubcommand((sub) => + sub + .setName('remove') + .setDescription('Remove a suggestion') + .addIntegerOption((o) => movieOption(o).setRequired(true)), + ) + .addSubcommand((sub) => + sub + .setName('vote') + .setDescription('Start a poll over the suggestions') + .addIntegerOption((o) => + o + .setName('count') + .setDescription('How many movies (default 10)') + .setMinValue(2) + .setMaxValue(maxPollOptions), + ) + .addStringOption((o) => + o.setName('closes').setDescription('When voting ends (default 2d)'), + ) + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Where to post (default: here)') + .addChannelTypes(ChannelType.GuildText), + ), + ) + .addSubcommand((sub) => + sub + .setName('night') + .setDescription( + 'Schedule a movie night (defaults to the last poll winner)', + ) + .addStringOption((o) => + o + .setName('start') + .setDescription('e.g. fri 19:00 or 20.11 19:00') + .setRequired(true), + ) + .addIntegerOption(movieOption) + .addStringOption((o) => + o.setName('location').setDescription('Where').setMaxLength(200), + ) + .addIntegerOption((o) => + o.setName('capacity').setDescription('Seats').setMinValue(1), + ) + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Where to post (default: here)') + .addChannelTypes(ChannelType.GuildText), + ), + ) + .addSubcommand((sub) => + sub + .setName('watched') + .setDescription('Mark a movie as watched') + .addIntegerOption((o) => movieOption(o).setRequired(true)) + .addStringOption((o) => + o.setName('date').setDescription('When (default: now)'), + ), + ) + .addSubcommand((sub) => + sub.setName('history').setDescription('Movies we have watched'), + ); + +export function movieCommands(movies: MovieService): Feature { + return { + name: 'movies', + permissions: [ + { + id: 'movie:manage', + description: 'Run movie votes and movie nights, remove suggestions', + }, + ], + commands: [ + { + data: data.toJSON(), + execute: bySubcommand({ + suggest: deferred(async (interaction) => { + const link = interaction.options.getString('link'); + const movie = await movies.suggest(toActor(interaction.member), { + title: interaction.options.getString('title', true), + year: interaction.options.getInteger('year'), + note: interaction.options.getString('note'), + links: link === null ? [] : [link], + }); + + await respond( + interaction, + `Added #${movie.id} ${movieLabel(movie)} to the list. ${linkLine(movieLinks(movie))}`, + ); + }), + link: async (interaction) => { + const movie = await movies.addLinks( + toActor(interaction.member), + interaction.options.getInteger('movie', true), + [interaction.options.getString('url', true)], + ); + + await respond( + interaction, + `${movieLabel(movie)}: ${linkLine(movieLinks(movie))}`, + ); + }, + suggestions: async (interaction) => { + const list = await movies.unwatched(interaction.guildId); + + await respond( + interaction, + list.length === 0 + ? 'No suggestions yet. Add one with "/movie suggest".' + : list + .map((m) => + [ + `#${m.id} **${movieLabel(m)}** - ${userMention(m.suggestedBy)}`, + linkLine(movieLinks(m)), + ] + .filter(Boolean) + .join(' · '), + ) + .join('\n') + .slice(0, 2000), + ); + }, + remove: async (interaction) => { + const movie = await movies.remove( + toActor(interaction.member), + interaction.options.getInteger('movie', true), + ); + + await respond(interaction, `Removed ${movieLabel(movie)}.`); + }, + vote: deferred(async (interaction) => { + const count = interaction.options.getInteger('count'); + const closes = interaction.options.getString('closes'); + const poll = await movies.vote(toActor(interaction.member), { + channelId: + interaction.options.getChannel('channel')?.id ?? + interaction.channelId, + ...(count !== null && { count }), + ...(closes !== null && { closes }), + }); + + await respond( + interaction, + `Movie poll #${poll.id} closes ${discordTime(poll.closesAt ?? new Date(), 'R')}.`, + ); + }), + night: deferred(async (interaction) => { + const movieId = interaction.options.getInteger('movie'); + const location = interaction.options.getString('location'); + const capacity = interaction.options.getInteger('capacity'); + const { movie, event } = await movies.night( + toActor(interaction.member), + { + start: interaction.options.getString('start', true), + channelId: + interaction.options.getChannel('channel')?.id ?? + interaction.channelId, + ...(movieId !== null && { movieId }), + ...(location !== null && { location }), + ...(capacity !== null && { capacity }), + }, + ); + + await respond( + interaction, + `Movie night for ${movieLabel(movie)} is event #${event.id}.`, + ); + }), + watched: async (interaction) => { + const date = interaction.options.getString('date'); + const movie = await movies.watched( + toActor(interaction.member), + interaction.options.getInteger('movie', true), + ...(date === null ? [] : [date]), + ); + + await respond( + interaction, + `Marked ${movieLabel(movie)} as watched.`, + ); + }, + history: async (interaction) => { + const history = await movies.history(interaction.guildId); + + await respond( + interaction, + history.length === 0 + ? 'No movies watched yet.' + : history + .map( + (h) => + `${h.watchedAt ? discordTime(h.watchedAt, 'D') : ''} ${movieLabel(h)}`, + ) + .join('\n'), + ); + }, + }), + autocomplete: async (interaction) => { + const query = interaction.options.getFocused().toLowerCase(); + const list = await movies.unwatched(interaction.guildId); + + await interaction.respond( + list + .filter((m) => m.title.toLowerCase().includes(query)) + .map((m) => ({ + name: `#${m.id} ${movieLabel(m)}`.slice(0, 100), + value: m.id, + })), + ); + }, + }, + ], + }; +} diff --git a/src/discord/commands/permissions.ts b/src/discord/commands/permissions.ts new file mode 100644 index 0000000..ce5a15e --- /dev/null +++ b/src/discord/commands/permissions.ts @@ -0,0 +1,136 @@ +import { UserError } from '~/core/errors'; +import { + InteractionContextType, + SlashCommandBuilder, + type SlashCommandStringOption, +} from 'discord.js'; +import type { PermissionService } from '~/features/permissions/service'; +import { managePermissions } from '~/core/permission'; +import { roleMention, userMention } from '~/core/message'; +import { toActor } from '~/discord/interactions/actor'; +import { bySubcommand, deferred } from './handlers'; +import type { Feature } from '~/discord/contracts'; +import { respond } from '~/discord/interactions/responses'; + +const permissionOption = (o: SlashCommandStringOption) => + o + .setName('permission') + .setDescription('Permission') + .setRequired(true) + .setAutocomplete(true); + +const data = new SlashCommandBuilder() + .setName('permissions') + .setDescription('Manage which roles may use restricted bot actions') + .setContexts(InteractionContextType.Guild) + .addSubcommand((sub) => + sub + .setName('grant') + .setDescription('Grant a permission to a role') + .addStringOption(permissionOption) + .addRoleOption((o) => o.setName('role').setDescription('Role')) + .addUserOption((o) => + o.setName('user').setDescription('Member (choose a role or member)'), + ), + ) + .addSubcommand((sub) => + sub + .setName('revoke') + .setDescription('Revoke a permission from a role') + .addStringOption(permissionOption) + .addRoleOption((o) => o.setName('role').setDescription('Role')) + .addUserOption((o) => + o.setName('user').setDescription('Member (choose a role or member)'), + ), + ) + .addSubcommand((sub) => + sub + .setName('list') + .setDescription('List granted permissions') + .addRoleOption((o) => o.setName('role').setDescription('Only this role')), + ); + +export function permissionCommands(permissions: PermissionService): Feature { + const change = (action: 'grant' | 'revoke') => + deferred(async (interaction) => { + const role = interaction.options.getRole('role'); + const user = interaction.options.getUser('user'); + const targetId = role?.id ?? user?.id; + + if (targetId === undefined || (role !== null && user !== null)) { + throw new UserError('Choose exactly one role or member.'); + } + + const permission = interaction.options.getString('permission', true); + const changed = await permissions[action]( + toActor(interaction.member), + targetId, + permission, + user ? 'user' : 'role', + ); + const verb = action === 'grant' ? 'Granted' : 'Revoked'; + const mention = user ? userMention(targetId) : roleMention(targetId); + + await respond( + interaction, + changed + ? `${verb} "${permission}" for ${mention}.` + : 'Nothing changed.', + ); + }); + + return { + name: 'permissions', + permissions: [ + { + id: managePermissions, + description: 'Grant and revoke bot permissions', + }, + ], + commands: [ + { + data: data.toJSON(), + execute: bySubcommand({ + grant: change('grant'), + revoke: change('revoke'), + list: async (interaction) => { + const role = interaction.options.getRole('role'); + const grants = await permissions.list( + toActor(interaction.member), + ...(role ? [role.id] : []), + ); + const lines = grants.map( + (g) => + `${g.subjectType === 'user' ? userMention(g.roleId) : roleMention(g.roleId)} - "${g.permission}"`, + ); + + await respond( + interaction, + lines.length === 0 + ? 'No permissions granted. Administrators hold every permission.' + : lines.join('\n').slice(0, 2000), + ); + }, + }), + autocomplete: async (interaction) => { + const query = interaction.options.getFocused().toLowerCase(); + + await interaction.respond( + permissions + .catalogue() + .filter( + (p) => + p.id.includes(query) || + p.description.toLowerCase().includes(query), + ) + .slice(0, 25) + .map((p) => ({ + name: `${p.id} - ${p.description}`.slice(0, 100), + value: p.id, + })), + ); + }, + }, + ], + }; +} diff --git a/src/discord/commands/polls.ts b/src/discord/commands/polls.ts new file mode 100644 index 0000000..9a86cd8 --- /dev/null +++ b/src/discord/commands/polls.ts @@ -0,0 +1,266 @@ +import type { Directory } from '~/core/ports/directory'; +import { visibleRecords } from '~/core/helpers/visibility'; +import { + ChannelType, + InteractionContextType, + SlashCommandBuilder, + type SlashCommandIntegerOption, +} from 'discord.js'; +import { describeOutcome } from '~/features/polls/message'; +import type { PollService } from '~/features/polls/service'; +import { channelMention, userMention } from '~/core/message'; +import { UserError } from '~/core/errors'; +import { toActor } from '~/discord/interactions/actor'; +import { bySubcommand, deferred } from './handlers'; +import type { ComponentHandler, Feature } from '~/discord/contracts'; +import { render } from '~/discord/render'; +import { respond } from '~/discord/interactions/responses'; + +const idOption = (o: SlashCommandIntegerOption) => + o + .setName('id') + .setDescription('Poll') + .setRequired(true) + .setAutocomplete(true); + +const data = new SlashCommandBuilder() + .setName('poll') + .setDescription('Polls') + .setContexts(InteractionContextType.Guild) + .addSubcommand((sub) => + sub + .setName('create') + .setDescription('Start a poll') + .addStringOption((o) => + o + .setName('question') + .setDescription('Question') + .setRequired(true) + .setMaxLength(256), + ) + .addStringOption((o) => + o + .setName('options') + .setDescription('Options separated by | e.g. "Pizza | Sushi | Tacos"') + .setRequired(true), + ) + .addBooleanOption((o) => + o.setName('multiple').setDescription('Allow several choices'), + ) + .addBooleanOption((o) => + o.setName('anonymous').setDescription('Hide who voted for what'), + ) + .addStringOption((o) => + o + .setName('results') + .setDescription('When results are visible') + .addChoices( + { name: 'live', value: 'live' }, + { name: 'after closing', value: 'closed' }, + ), + ) + .addStringOption((o) => + o.setName('closes').setDescription('e.g. 2h, 1d, fri 18:00'), + ) + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Where to post (default: here)') + .addChannelTypes(ChannelType.GuildText), + ), + ) + .addSubcommand((sub) => sub.setName('list').setDescription('Open polls')) + .addSubcommand((sub) => + sub + .setName('results') + .setDescription('Show results') + .addIntegerOption(idOption), + ) + .addSubcommand((sub) => + sub + .setName('close') + .setDescription('Close a poll now') + .addIntegerOption(idOption), + ) + .addSubcommand((sub) => + sub + .setName('cancel') + .setDescription('Cancel a poll') + .addIntegerOption(idOption), + ); + +function parseId(value: string | undefined): number { + const id = Number(value); + + if (!Number.isSafeInteger(id)) { + throw new UserError('This poll control is invalid.'); + } + + return id; +} + +export function pollCommands( + polls: PollService, + directory: Directory, +): Feature { + const answer = async ( + interaction: Parameters[0], + outcome: Awaited>, + ) => { + if (interaction.isModalSubmit()) { + return; + } + + const { content, embeds, components } = render(outcome.view); + + await interaction.update({ content, embeds, components }); + await respond( + interaction, + outcome.chosen.length === 0 + ? 'Your vote is cleared.' + : `Your vote: **${outcome.chosen.join(', ')}**`, + ); + }; + + const vote: ComponentHandler = { + prefix: 'polls:vote', + execute: async (interaction, [id]) => { + if (!interaction.isStringSelectMenu()) { + return; + } + + await answer( + interaction, + await polls.vote( + toActor(interaction.member), + parseId(id), + interaction.values.map(Number), + ), + ); + }, + }; + + const clear: ComponentHandler = { + prefix: 'polls:clear', + execute: async (interaction, [id]) => { + await answer( + interaction, + await polls.clear(toActor(interaction.member), parseId(id)), + ); + }, + }; + + return { + name: 'polls', + permissions: [ + { id: 'poll:create', description: 'Start polls' }, + { + id: 'poll:manage', + description: 'Close and cancel any poll, see voters', + }, + ], + components: [vote, clear], + commands: [ + { + data: data.toJSON(), + permissions: { create: 'poll:create' }, + execute: bySubcommand({ + create: deferred(async (interaction) => { + const closes = interaction.options.getString('closes'); + const poll = await polls.create(toActor(interaction.member), { + question: interaction.options.getString('question', true), + options: interaction.options + .getString('options', true) + .split('|'), + channelId: + interaction.options.getChannel('channel')?.id ?? + interaction.channelId, + multiple: interaction.options.getBoolean('multiple') ?? false, + anonymous: interaction.options.getBoolean('anonymous') ?? false, + showResults: + interaction.options.getString('results') === 'closed' + ? 'closed' + : 'live', + ...(closes !== null && { closes }), + }); + + await respond( + interaction, + `Poll #${poll.id} is up in ${channelMention(poll.channelId)}.`, + ); + }), + list: async (interaction) => { + const open = await visibleRecords( + directory, + toActor(interaction.member), + await polls.open(interaction.guildId), + ); + + await respond( + interaction, + open.length === 0 + ? 'No open polls.' + : open + .map( + (p) => + `#${p.id} ${p.question} - ${channelMention(p.channelId)}`, + ) + .join('\n'), + ); + }, + results: async (interaction) => { + const { poll, results, voters } = await polls.summary( + toActor(interaction.member), + interaction.options.getInteger('id', true), + ); + const lines = results.options.map((option) => { + const names = + voters?.get(option.id)?.map((id) => userMention(id)) ?? []; + + return [`**${option.label}** - ${option.votes}`, ...names].join( + ' ', + ); + }); + const winner = + results.winners.length === 0 + ? 'No votes yet.' + : describeOutcome(results, 'Leading'); + + await respond( + interaction, + [`# ${poll.question}`, ...lines, winner] + .join('\n') + .slice(0, 2000), + ); + }, + close: deferred(async (interaction) => { + const id = interaction.options.getInteger('id', true); + + await polls.close(toActor(interaction.member), id); + await respond(interaction, `Poll #${id} is closed.`); + }), + cancel: deferred(async (interaction) => { + const id = interaction.options.getInteger('id', true); + + await polls.cancel(toActor(interaction.member), id); + await respond(interaction, `Poll #${id} is cancelled.`); + }), + }), + autocomplete: async (interaction) => { + const open = await visibleRecords( + directory, + toActor(interaction.member), + await polls.open(interaction.guildId), + ); + + await interaction.respond( + open.map((p) => ({ + name: `#${p.id} ${p.question}`.slice(0, 100), + value: p.id, + })), + ); + }, + }, + ], + }; +} diff --git a/src/discord/commands/reminders.ts b/src/discord/commands/reminders.ts new file mode 100644 index 0000000..aabcfc8 --- /dev/null +++ b/src/discord/commands/reminders.ts @@ -0,0 +1,191 @@ +import { + ApplicationCommandType, + ChannelType, + ContextMenuCommandBuilder, + InteractionContextType, + SlashCommandBuilder, + type SlashCommandIntegerOption, +} from 'discord.js'; +import type { Reminder } from '~/features/reminders/model'; +import type { ReminderService } from '~/features/reminders/service'; +import { channelMention } from '~/core/message'; +import { discordTime, recurrences } from '~/core/helpers/time'; +import { toActor } from '~/discord/interactions/actor'; +import { bySubcommand } from './handlers'; +import type { Feature } from '~/discord/contracts'; +import { respond } from '~/discord/interactions/responses'; + +export function describeReminder(reminder: Reminder): string { + const where = + reminder.channelId === null ? 'DM' : channelMention(reminder.channelId); + const repeat = reminder.recurrence === null ? '' : `, ${reminder.recurrence}`; + + return `#${reminder.id} ${discordTime(reminder.runAt, 'f')} (${where}${repeat}) - ${reminder.message.slice(0, 80)}`; +} + +const remindme = new SlashCommandBuilder() + .setName('remindme') + .setDescription('Set a reminder') + .setContexts(InteractionContextType.Guild) + .addStringOption((o) => + o + .setName('message') + .setDescription('What to remind about') + .setRequired(true) + .setMaxLength(1000), + ) + .addStringOption((o) => + o + .setName('when') + .setDescription( + 'Default tomorrow. e.g. 30m, 2h, tomorrow 9:00, fri 18:00', + ), + ) + .addChannelOption((o) => + o + .setName('channel') + .setDescription('Post in a channel instead of DM') + .addChannelTypes(ChannelType.GuildText), + ) + .addStringOption((o) => + o + .setName('repeat') + .setDescription('Repeat the reminder') + .addChoices(recurrences.map((r) => ({ name: r, value: r }))), + ); + +const idOption = (o: SlashCommandIntegerOption) => + o + .setName('id') + .setDescription('Reminder') + .setRequired(true) + .setAutocomplete(true); + +const manage = new SlashCommandBuilder() + .setName('reminders') + .setDescription('Manage your reminders') + .setContexts(InteractionContextType.Guild) + .addSubcommand((sub) => + sub.setName('list').setDescription('List your active reminders'), + ) + .addSubcommand((sub) => + sub + .setName('edit') + .setDescription('Change a reminder') + .addIntegerOption(idOption) + .addStringOption((o) => + o.setName('when').setDescription('e.g. 2h, tomorrow 9:00'), + ) + .addStringOption((o) => + o.setName('message').setDescription('New message').setMaxLength(1000), + ), + ) + .addSubcommand((sub) => + sub + .setName('cancel') + .setDescription('Cancel a reminder') + .addIntegerOption(idOption), + ); + +export function reminderCommands(reminders: ReminderService): Feature { + return { + name: 'reminders', + permissions: [ + { id: 'reminder:channel', description: 'Post reminders in channels' }, + ], + messageCommands: [ + { + data: new ContextMenuCommandBuilder() + .setName('Remind me tomorrow') + .setType(ApplicationCommandType.Message) + .setContexts(InteractionContextType.Guild) + .toJSON(), + execute: async (interaction) => { + const target = interaction.targetMessage; + const excerpt = target.content.slice(0, 200); + const reminder = await reminders.create(toActor(interaction.member), { + message: [excerpt, target.url].filter(Boolean).join('\n'), + }); + + await respond( + interaction, + `I will DM you about ${target.url} ${discordTime(reminder.runAt, 'R')}.`, + ); + }, + }, + ], + commands: [ + { + data: remindme.toJSON(), + execute: async (interaction) => { + const channel = interaction.options.getChannel('channel', false, [ + ChannelType.GuildText, + ]); + const repeat = interaction.options.getString('repeat'); + const when = interaction.options.getString('when'); + const reminder = await reminders.create(toActor(interaction.member), { + ...(when !== null && { when }), + message: interaction.options.getString('message', true), + ...(channel && { channelId: channel.id }), + ...(repeat !== null && { repeat }), + }); + const note = channel + ? '' + : ' Make sure you allow DMs from server members.'; + + await respond( + interaction, + `Reminder set: ${describeReminder(reminder)}.${note}`, + ); + }, + }, + { + data: manage.toJSON(), + execute: bySubcommand({ + list: async (interaction) => { + const active = await reminders.list(toActor(interaction.member)); + + await respond( + interaction, + active.length === 0 + ? 'You have no active reminders.' + : active + .map((reminder) => describeReminder(reminder)) + .join('\n'), + ); + }, + edit: async (interaction) => { + const when = interaction.options.getString('when'); + const message = interaction.options.getString('message'); + const updated = await reminders.edit( + toActor(interaction.member), + interaction.options.getInteger('id', true), + { + ...(when !== null && { when }), + ...(message !== null && { message }), + }, + ); + + await respond(interaction, `Updated: ${describeReminder(updated)}`); + }, + cancel: async (interaction) => { + const id = interaction.options.getInteger('id', true); + + await reminders.cancel(toActor(interaction.member), id); + await respond(interaction, `Cancelled reminder #${id}.`); + }, + }), + autocomplete: async (interaction) => { + const active = await reminders.list(toActor(interaction.member)); + + await interaction.respond( + active.map((r) => ({ + name: `#${r.id} ${r.message}`.slice(0, 100), + value: r.id, + })), + ); + }, + }, + ], + }; +} diff --git a/src/discord/contracts.ts b/src/discord/contracts.ts new file mode 100644 index 0000000..1e7ceea --- /dev/null +++ b/src/discord/contracts.ts @@ -0,0 +1,76 @@ +import type { + AnySelectMenuInteraction, + AutocompleteInteraction, + ButtonInteraction, + ChatInputCommandInteraction, + Client, + ClientEvents, + MessageContextMenuCommandInteraction, + ModalSubmitInteraction, + RESTPostAPIChatInputApplicationCommandsJSONBody, + RESTPostAPIContextMenuApplicationCommandsJSONBody, +} from 'discord.js'; +import type { Logger } from '~/core/ports/logger'; +import type { Authorizer } from '~/core/ports/authorization'; +import type { Permission, PermissionDefinition } from '~/core/permission'; + +export interface AppContext { + log: Logger; + authz: Authorizer; +} + +export type CommandInteraction = ChatInputCommandInteraction<'cached'>; + +export interface SlashCommand { + data: RESTPostAPIChatInputApplicationCommandsJSONBody; + permissions?: Partial>; + execute: (interaction: CommandInteraction, ctx: AppContext) => Promise; + autocomplete?: ( + interaction: AutocompleteInteraction<'cached'>, + ctx: AppContext, + ) => Promise; +} + +export type MessageCommandInteraction = + MessageContextMenuCommandInteraction<'cached'>; + +export interface MessageCommand { + data: RESTPostAPIContextMenuApplicationCommandsJSONBody; + execute: ( + interaction: MessageCommandInteraction, + ctx: AppContext, + ) => Promise; +} + +export type ComponentInteraction = + | ButtonInteraction<'cached'> + | AnySelectMenuInteraction<'cached'> + | ModalSubmitInteraction<'cached'>; + +export type Repliable = + CommandInteraction | ComponentInteraction | MessageCommandInteraction; + +export interface ComponentHandler { + prefix: string; + permission?: Permission; + execute: ( + interaction: ComponentInteraction, + args: readonly string[], + ctx: AppContext, + ) => Promise; +} + +export interface EventListener { + event: keyof ClientEvents; + attach: (client: Client, ctx: AppContext) => void; +} + +export interface Feature { + name: string; + permissions?: readonly PermissionDefinition[]; + commands?: readonly SlashCommand[]; + messageCommands?: readonly MessageCommand[]; + components?: readonly ComponentHandler[]; + events?: readonly EventListener[]; + start?: () => Promise; +} diff --git a/src/discord/events/listener.ts b/src/discord/events/listener.ts new file mode 100644 index 0000000..4e0df11 --- /dev/null +++ b/src/discord/events/listener.ts @@ -0,0 +1,18 @@ +import type { ClientEvents } from 'discord.js'; +import type { AppContext, EventListener } from '~/discord/contracts'; + +export function createEventListener( + event: K, + handle: (ctx: AppContext, ...args: ClientEvents[K]) => Promise, +): EventListener { + return { + event, + attach: (client, ctx) => { + client.on(event, (...args) => { + handle(ctx, ...args).catch((error: unknown) => { + ctx.log.error({ error, event }, 'Event listener failed'); + }); + }); + }, + }; +} diff --git a/src/discord/events/roles.ts b/src/discord/events/roles.ts new file mode 100644 index 0000000..4b41c8b --- /dev/null +++ b/src/discord/events/roles.ts @@ -0,0 +1,59 @@ +import { + Events, + type MessageReaction, + type PartialMessageReaction, + type PartialUser, + type User, +} from 'discord.js'; +import type { RoleService } from '~/features/roles/service'; +import { createEventListener } from './listener'; +import type { Feature } from '~/discord/contracts'; + +function reactionOf( + reaction: MessageReaction | PartialMessageReaction, + user: User | PartialUser, +) { + const { message } = reaction; + const emoji = reaction.emoji.name; + + if (user.bot || message.guildId === null || emoji === null) { + return null; + } + + return { + guildId: message.guildId, + channelId: message.channelId, + messageId: message.id, + emoji, + userId: user.id, + }; +} + +export function roleEvents(roles: RoleService): Feature { + const added = createEventListener( + Events.MessageReactionAdd, + async (_ctx, reaction, user) => { + const key = reactionOf(reaction, user); + + if (key) { + await roles.reacted(key, true); + } + }, + ); + const removed = createEventListener( + Events.MessageReactionRemove, + async (_ctx, reaction, user) => { + const key = reactionOf(reaction, user); + + if (key) { + await roles.reacted(key, false); + } + }, + ); + + return { + name: 'roles', + events: [added, removed], + start: () => roles.syncLegacyPanel(), + }; +} diff --git a/src/discord/interactions/actor.ts b/src/discord/interactions/actor.ts new file mode 100644 index 0000000..201a87b --- /dev/null +++ b/src/discord/interactions/actor.ts @@ -0,0 +1,59 @@ +import { PermissionFlagsBits, type GuildMember, type Role } from 'discord.js'; +import type { Actor } from '~/core/actor'; +import type { RoleInfo } from '~/core/ports/directory'; + +const moderatorPermissions = [ + PermissionFlagsBits.Administrator, + PermissionFlagsBits.ManageGuild, + PermissionFlagsBits.ManageRoles, + PermissionFlagsBits.ManageChannels, + PermissionFlagsBits.ManageMessages, + PermissionFlagsBits.ManageWebhooks, + PermissionFlagsBits.BanMembers, + PermissionFlagsBits.KickMembers, + PermissionFlagsBits.ModerateMembers, +]; + +let applicationAdminRole: + { roleId: string; guildId: string | undefined } | undefined; + +export function configureApplicationAdminRole( + roleId?: string, + guildId?: string, +): void { + applicationAdminRole = roleId === undefined ? undefined : { roleId, guildId }; +} + +export function toActor(member: GuildMember): Actor { + return { + guildId: member.guild.id, + userId: member.id, + roleIds: [...member.roles.cache.keys()], + administrator: + member.permissions.has(PermissionFlagsBits.Administrator) || + (applicationAdminRole !== undefined && + (applicationAdminRole.guildId === undefined || + applicationAdminRole.guildId === member.guild.id) && + member.roles.cache.has(applicationAdminRole.roleId)), + owner: member.id === member.guild.ownerId, + highestRolePosition: member.roles.highest.position, + }; +} + +export function toRoleInfo(role: Role): RoleInfo { + return { + id: role.id, + name: role.name, + position: role.position, + everyone: role.id === role.guild.id, + managed: role.managed, + mentionable: role.mentionable, + moderator: + moderatorPermissions.some((flag) => role.permissions.has(flag)) || + (role.id === applicationAdminRole?.roleId && + (applicationAdminRole.guildId === undefined || + role.guild.id === applicationAdminRole.guildId)), + administrator: role.permissions.has(PermissionFlagsBits.Administrator), + botCanAssign: role.editable, + }; +} diff --git a/src/discord/interactions/responses.ts b/src/discord/interactions/responses.ts new file mode 100644 index 0000000..42cc280 --- /dev/null +++ b/src/discord/interactions/responses.ts @@ -0,0 +1,43 @@ +import { MessageFlags, type BaseMessageOptions } from 'discord.js'; +import type { Repliable } from '~/discord/contracts'; +import type { Message as DomainMessage } from '~/core/message'; +import { render } from '~/discord/render'; + +export async function respond( + interaction: Repliable, + content: string | Pick, +): Promise { + const message = { + ...(typeof content === 'string' ? { content } : content), + allowedMentions: { parse: [] }, + }; + + if (interaction.replied) { + await interaction.followUp({ ...message, flags: MessageFlags.Ephemeral }); + } else if (interaction.deferred) { + await interaction.editReply(message); + } else { + await interaction.reply({ ...message, flags: MessageFlags.Ephemeral }); + } +} + +export async function respondView( + interaction: Repliable, + view: DomainMessage, +): Promise { + const { content, embeds, components } = render(view); + const message = { + content, + embeds, + components, + allowedMentions: { parse: [] }, + }; + + if (interaction.replied) { + await interaction.followUp({ ...message, flags: MessageFlags.Ephemeral }); + } else if (interaction.deferred) { + await interaction.editReply(message); + } else { + await interaction.reply({ ...message, flags: MessageFlags.Ephemeral }); + } +} diff --git a/src/discord/interactions/router.ts b/src/discord/interactions/router.ts new file mode 100644 index 0000000..139b267 --- /dev/null +++ b/src/discord/interactions/router.ts @@ -0,0 +1,190 @@ +import { subcommandPath } from '~/discord/commands/handlers'; +import { respond } from './responses'; +import { randomUUID } from 'node:crypto'; +import { + MessageFlags, + type AutocompleteInteraction, + type Interaction, +} from 'discord.js'; +import { ignore, UserError } from '~/core/errors'; +import type { + AppContext, + CommandInteraction, + ComponentInteraction, + MessageCommandInteraction, + Repliable, +} from '~/discord/contracts'; +import { toActor } from './actor'; +import { parseCustomId, type Registry } from '~/discord/registry'; + +async function runCommand( + registry: Registry, + interaction: CommandInteraction, + ctx: AppContext, +): Promise { + const command = registry.commands.get(interaction.commandName); + + if (!command) { + throw new UserError('This command is no longer available.'); + } + + const permissions = command.permissions ?? {}; + const required = permissions['*'] ?? permissions[subcommandPath(interaction)]; + + if (required !== undefined) { + await ctx.authz.require(toActor(interaction.member), required); + } + + await command.execute(interaction, ctx); +} + +async function runMessageCommand( + registry: Registry, + interaction: MessageCommandInteraction, + ctx: AppContext, +): Promise { + const command = registry.messageCommands.get(interaction.commandName); + + if (!command) { + throw new UserError('This command is no longer available.'); + } + + await command.execute(interaction, ctx); +} + +async function runComponent( + registry: Registry, + interaction: ComponentInteraction, + ctx: AppContext, +): Promise { + const parsed = parseCustomId(interaction.customId); + const handler = parsed && registry.components.get(parsed.prefix); + + if (!parsed || !handler) { + throw new UserError('This control is no longer active.'); + } + + if (handler.permission !== undefined) { + await ctx.authz.require(toActor(interaction.member), handler.permission); + } + + await handler.execute(interaction, parsed.args, ctx); +} + +async function runAutocomplete( + registry: Registry, + interaction: AutocompleteInteraction<'cached'>, + ctx: AppContext, +): Promise { + const command = registry.commands.get(interaction.commandName); + + try { + await command?.autocomplete?.(interaction, ctx); + } catch (error) { + ctx.log.warn( + { error, command: interaction.commandName }, + 'Autocomplete failed', + ); + } + + if (!interaction.responded) { + await interaction.respond([]).catch(ignore); + } +} + +function describe(interaction: Repliable): Record { + return { + guildId: interaction.guildId, + userId: interaction.user.id, + ...(interaction.isChatInputCommand() && { + command: + `${interaction.commandName} ${subcommandPath(interaction)}`.trim(), + }), + ...(interaction.isMessageContextMenuCommand() && { + command: interaction.commandName, + }), + ...((interaction.isMessageComponent() || interaction.isModalSubmit()) && { + customId: interaction.customId, + }), + }; +} + +function dispatch( + registry: Registry, + interaction: Repliable, + ctx: AppContext, +): Promise { + if (interaction.isChatInputCommand()) { + return runCommand(registry, interaction, ctx); + } + + if (interaction.isMessageContextMenuCommand()) { + return runMessageCommand(registry, interaction, ctx); + } + + return runComponent(registry, interaction, ctx); +} + +export function createInteractionHandler( + registry: Registry, + ctx: AppContext, +): (interaction: Interaction) => Promise { + return async (interaction) => { + if (!interaction.inCachedGuild()) { + if (interaction.isRepliable()) { + await interaction + .reply({ + content: + interaction.guildId === null + ? 'Please use me inside the server.' + : 'I am not a member of this server yet. Ask an admin to invite me with the "bot" scope.', + flags: MessageFlags.Ephemeral, + }) + .catch(ignore); + } + + return; + } + + if (interaction.isAutocomplete()) { + await runAutocomplete(registry, interaction, ctx); + + return; + } + + if ( + !interaction.isChatInputCommand() && + !interaction.isMessageContextMenuCommand() && + !interaction.isMessageComponent() && + !interaction.isModalSubmit() + ) { + return; + } + + try { + await dispatch(registry, interaction, ctx); + } catch (error) { + let message: string; + + if (error instanceof UserError) { + message = error.message; + ctx.log.debug( + { ...describe(interaction), reason: error.message }, + 'Interaction rejected', + ); + } else { + const ref = randomUUID().slice(0, 8); + + ctx.log.error( + { error, ref, ...describe(interaction) }, + 'Interaction failed', + ); + message = `Something went wrong. Reference: \`${ref}\``; + } + + await respond(interaction, message).catch((replyError: unknown) => { + ctx.log.warn({ replyError }, 'Could not report interaction error'); + }); + } + }; +} diff --git a/src/discord/registration.ts b/src/discord/registration.ts new file mode 100644 index 0000000..3b1a4bb --- /dev/null +++ b/src/discord/registration.ts @@ -0,0 +1,25 @@ +import { REST, Routes } from 'discord.js'; +import type { Registry } from './registry'; + +export async function registerCommands( + registry: Registry, + options: { + token: string; + applicationId: string; + guildId?: string; + }, +): Promise { + const body = [ + ...[...registry.commands.values()].map((command) => command.data), + ...[...registry.messageCommands.values()].map((command) => command.data), + ]; + const rest = new REST().setToken(options.token); + const route = + options.guildId === undefined + ? Routes.applicationCommands(options.applicationId) + : Routes.applicationGuildCommands(options.applicationId, options.guildId); + + await rest.put(route, { body }); + + return body.length; +} diff --git a/src/discord/registry.ts b/src/discord/registry.ts new file mode 100644 index 0000000..b9c74a7 --- /dev/null +++ b/src/discord/registry.ts @@ -0,0 +1,79 @@ +import type { + ComponentHandler, + Feature, + MessageCommand, + SlashCommand, +} from './contracts'; +import type { Permission, PermissionDefinition } from '~/core/permission'; + +export interface Registry { + features: readonly Feature[]; + commands: ReadonlyMap; + messageCommands: ReadonlyMap; + components: ReadonlyMap; + permissions: ReadonlyMap; +} + +const componentPrefix = /^[a-z][a-z-]*:[a-z][a-z-]*$/; + +function addUnique( + map: Map, + key: string, + value: V, + what: string, +): void { + if (map.has(key)) { + throw new Error(`Duplicate ${what} "${key}"`); + } + + map.set(key, value); +} + +export function buildRegistry(features: readonly Feature[]): Registry { + const names = new Map(); + const commands = new Map(); + const messageCommands = new Map(); + const components = new Map(); + const permissions = new Map(); + + for (const feature of features) { + addUnique(names, feature.name, feature, 'feature'); + for (const command of feature.commands ?? []) { + addUnique(commands, command.data.name, command, 'command'); + } + + for (const command of feature.messageCommands ?? []) { + addUnique(messageCommands, command.data.name, command, 'message command'); + } + + for (const component of feature.components ?? []) { + if (!componentPrefix.test(component.prefix)) { + throw new Error(`Invalid component prefix "${component.prefix}"`); + } + + addUnique(components, component.prefix, component, 'component prefix'); + } + + for (const permission of feature.permissions ?? []) { + if (permissions.has(permission.id)) { + throw new Error(`Duplicate permission "${permission.id}"`); + } + + permissions.set(permission.id, { ...permission, group: feature.name }); + } + } + + return { features, commands, messageCommands, components, permissions }; +} + +export function parseCustomId( + id: string, +): { prefix: string; args: string[] } | undefined { + const [feature, action, ...args] = id.split(':'); + + if (feature === undefined || action === undefined) { + return undefined; + } + + return { prefix: `${feature}:${action}`, args }; +} diff --git a/src/discord/render.ts b/src/discord/render.ts new file mode 100644 index 0000000..72f732d --- /dev/null +++ b/src/discord/render.ts @@ -0,0 +1,98 @@ +import { + ActionRowBuilder, + ButtonBuilder, + ButtonStyle, + EmbedBuilder, + MessageFlags, + StringSelectMenuBuilder, + type MessageActionRowComponentBuilder, + type MessageMentionOptions, +} from 'discord.js'; +import type { Control, Embed, Mentions, Message } from '~/core/message'; + +const buttonStyles = { + primary: ButtonStyle.Primary, + secondary: ButtonStyle.Secondary, + success: ButtonStyle.Success, + danger: ButtonStyle.Danger, +}; + +export function allowedMentions( + mentions: Mentions = {}, +): MessageMentionOptions { + return { + parse: (mentions.here ?? false) ? ['everyone'] : [], + users: [...(mentions.users ?? [])], + roles: [...(mentions.roles ?? [])], + }; +} + +function embed(source: Embed): EmbedBuilder { + const built = new EmbedBuilder(); + + if (source.title !== undefined) { + built.setTitle(source.title.slice(0, 256)); + } + + if (source.description !== undefined && source.description !== '') { + built.setDescription(source.description.slice(0, 4096)); + } + + if (source.url !== undefined) { + built.setURL(source.url); + } + + if (source.color !== undefined) { + built.setColor(source.color); + } + + if (source.footer !== undefined) { + built.setFooter({ text: source.footer }); + } + + return built.addFields( + (source.fields ?? []).map((field) => ({ + name: field.name, + value: field.value.slice(0, 1024), + inline: field.inline ?? false, + })), + ); +} + +function control(source: Control): MessageActionRowComponentBuilder { + if (source.kind === 'button') { + return new ButtonBuilder() + .setCustomId(source.id) + .setLabel(source.label) + .setStyle(buttonStyles[source.style]); + } + + return new StringSelectMenuBuilder() + .setCustomId(source.id) + .setPlaceholder(source.placeholder) + .setMinValues(source.min) + .setMaxValues(source.max) + .addOptions( + source.options.map((option) => ({ + label: option.label.slice(0, 100), + value: option.value, + default: option.default ?? false, + })), + ); +} + +export function render(message: Message) { + return { + content: message.content ?? '', + embeds: (message.embeds ?? []).map((source) => embed(source)), + components: (message.controls ?? []).map((row) => + new ActionRowBuilder().addComponents( + row.map((source) => control(source)), + ), + ), + allowedMentions: allowedMentions(message.mentions), + ...(message.suppressEmbeds === true && { + flags: MessageFlags.SuppressEmbeds as const, + }), + }; +} diff --git a/src/features/announcements/message.ts b/src/features/announcements/message.ts new file mode 100644 index 0000000..8d4acd8 --- /dev/null +++ b/src/features/announcements/message.ts @@ -0,0 +1,11 @@ +import { splitContent, type Message } from '~/core/message'; +import { renderPost, type Post } from '~/core/posts'; + +export function announcementView(post: Post): Message[] { + const { content = '', mentions = {} } = renderPost(post); + + return splitContent(content).map((part, index) => ({ + content: part, + mentions: index === 0 ? mentions : {}, + })); +} diff --git a/src/features/announcements/model.ts b/src/features/announcements/model.ts new file mode 100644 index 0000000..2fdd55f --- /dev/null +++ b/src/features/announcements/model.ts @@ -0,0 +1,39 @@ +import type { Post } from '~/core/posts'; + +export type AnnouncementStatus = + 'draft' | 'scheduled' | 'published' | 'cancelled'; + +export interface Announcement extends Post { + id: number; + guildId: string; + authorId: string; + channelId: string; + title: string | null; + mentionRoleIds: string[]; + status: AnnouncementStatus; + scheduledAt: Date | null; + publishedAt: Date | null; + messageIds: string[]; + failure: string | null; + createdAt: Date; +} + +export type NewAnnouncement = Pick< + Announcement, + 'guildId' | 'authorId' | 'channelId' | 'title' | 'content' | 'mentionRoleIds' +>; + +export type AnnouncementChanges = Partial< + Omit +>; + +export interface AnnouncementRepository { + insert: (post: NewAnnouncement) => Promise; + find: (id: number) => Promise; + list: (guildId: string, limit?: number) => Promise; + update: ( + id: number, + changes: AnnouncementChanges, + onlyIf?: readonly AnnouncementStatus[], + ) => Promise; +} diff --git a/src/features/announcements/service.ts b/src/features/announcements/service.ts new file mode 100644 index 0000000..47e0311 --- /dev/null +++ b/src/features/announcements/service.ts @@ -0,0 +1,405 @@ +import { announcementView } from './message'; +import { z } from 'zod'; +import { channelMention } from '~/core/message'; +import { parseFutureWhen } from '~/core/helpers/time'; +import { ignore, PermanentError, UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import { requireMentionable } from '~/core/helpers/roles'; +import type { AnnouncementRepository, AnnouncementStatus } from './model'; +import { type Authorizer } from '~/core/ports/authorization'; +import { guard } from '~/core/helpers/authorization'; +import type { Clock } from '~/core/ports/clock'; +import type { Directory } from '~/core/ports/directory'; +import type { Logger } from '~/core/ports/logger'; +import type { Messenger, Sent } from '~/core/ports/messenger'; +import { type Scheduler } from '~/core/ports/scheduler'; +import { defineJob } from '~/core/helpers/jobs'; +import { sequential } from '~/core/helpers/async'; +import { visibleRecords } from '~/core/helpers/visibility'; + +const jobKey = (id: number) => `announcement:${id}`; +const maxLatenessMs = 60 * 60 * 1000; +const open: AnnouncementStatus[] = ['draft', 'scheduled']; + +export const maxAnnouncementLength = 4000; + +export interface AnnouncementDraft { + channelId: string; + title?: string; + content: string; + mentionRoleIds?: readonly string[]; +} + +export interface AnnouncementDeps { + posts: AnnouncementRepository; + scheduler: Scheduler; + messenger: Messenger; + directory: Directory; + authz: Authorizer; + log: Logger; + clock: Clock; + timezone: string; +} + +export function createAnnouncementService(deps: AnnouncementDeps) { + const { posts, scheduler, messenger, directory, authz, log, clock } = deps; + + const requireReadable = async (actor: Actor, id: number) => { + const post = await posts.find(id); + + if ( + post?.guildId !== actor.guildId || + !(await directory.canView(actor, post.channelId)) || + (post.status !== 'published' && + post.authorId !== actor.userId && + !(await authz.can(actor, 'announcement:publish'))) + ) { + throw new UserError(`Announcement #${id} does not exist.`); + } + + return post; + }; + + const requireEditable = async (actor: Actor, id: number) => { + const post = await requireReadable(actor, id); + + if (post.authorId !== actor.userId) { + await authz.require(actor, 'announcement:publish'); + } + + return post; + }; + + const checkTargets = async ( + actor: Actor, + draft: Pick, + ) => { + if (!(await directory.canPost(actor, draft.channelId))) { + throw new UserError( + `You cannot post in ${channelMention(draft.channelId)} yourself.`, + ); + } + + const roles = await Promise.all( + (draft.mentionRoleIds ?? []).map((id) => + directory.role(actor.guildId, id), + ), + ); + + for (const role of roles) { + if (!role) { + throw new UserError('One of the mentioned roles no longer exists.'); + } + + requireMentionable(role); + } + }; + + const publish = async (id: number, from: readonly AnnouncementStatus[]) => { + const claimed = await posts.update( + id, + { + status: 'published', + publishedAt: clock.now(), + failure: null, + }, + from, + ); + + if (!claimed) { + throw new UserError( + `Announcement #${id} is already published or cancelled.`, + ); + } + + const sent: Sent[] = []; + + try { + await sequential(announcementView(claimed), async (message) => { + sent.push(await messenger.send(claimed.channelId, message)); + }); + } catch (error) { + await Promise.all( + sent.map(({ messageId }) => + messenger.remove(claimed.channelId, messageId).catch(ignore), + ), + ); + + const permanent = + error instanceof PermanentError || error instanceof UserError; + + await posts.update(id, { + status: permanent ? 'draft' : (from[0] ?? 'draft'), + publishedAt: null, + failure: error instanceof Error ? error.message : String(error), + }); + + throw error; + } + + const messageIds = sent.map(({ messageId }) => messageId); + + await posts.update(id, { messageIds }); + log.info({ announcementId: id, messageIds }, 'Announcement published'); + + return { ...claimed, messageIds }; + }; + + const publishJob = defineJob({ + type: 'announcements.publish', + payload: z.object({ + announcementId: z.number().int(), + scheduledBy: z.string().min(1).optional(), + }), + handle: async ({ announcementId, scheduledBy }) => { + const post = await posts.find(announcementId); + + if (post?.status !== 'scheduled') { + return null; + } + + const due = post.scheduledAt ?? post.createdAt; + + const now = clock.now(); + + if (due > now) { + return { rescheduleAt: due }; + } + + if (now.getTime() - due.getTime() > maxLatenessMs) { + await posts.update( + announcementId, + { + status: 'draft', + failure: 'Not posted: the bot was offline at the scheduled time.', + }, + ['scheduled'], + ); + log.warn({ announcementId }, 'Skipped stale scheduled announcement'); + + return null; + } + + const author = await directory.member(post.guildId, post.authorId); + + try { + if (!author) { + throw new UserError('The author is no longer a server member.'); + } + + await authz.require(author, 'announcement:create'); + const publisher = + scheduledBy === undefined || scheduledBy === post.authorId + ? author + : await directory.member(post.guildId, scheduledBy); + + if (!publisher) { + throw new UserError('The scheduler is no longer a server member.'); + } + + await authz.require(publisher, 'announcement:schedule'); + await checkTargets(author, post); + if (publisher.userId !== post.authorId) { + await authz.require(publisher, 'announcement:publish'); + await checkTargets(publisher, post); + } + } catch (error) { + if (!(error instanceof UserError)) { + throw error; + } + + await posts.update( + announcementId, + { + status: 'draft', + failure: `Not posted: ${error.message}`, + }, + ['scheduled'], + ); + log.warn( + { announcementId, reason: error.message }, + 'Scheduled announcement authorization revoked', + ); + + return null; + } + + await publish(announcementId, ['scheduled']); + + return null; + }, + }); + + const validate = (draft: AnnouncementDraft) => { + if ( + draft.content.trim() === '' || + draft.content.length > maxAnnouncementLength + ) { + throw new UserError(`Write 1-${maxAnnouncementLength} characters.`); + } + }; + + return { + jobs: [publishJob], + view: announcementView, + list: async (actor: Actor) => { + const [records, publisher] = await Promise.all([ + posts.list(actor.guildId), + authz.can(actor, 'announcement:publish'), + ]); + const accessible = records.filter( + (record) => + record.status === 'published' || + record.authorId === actor.userId || + publisher, + ); + + return visibleRecords(directory, actor, accessible); + }, + get: requireReadable, + draft: guard( + authz, + 'announcement:create', + async (actor, draft: AnnouncementDraft) => { + validate(draft); + await checkTargets(actor, draft); + + const title = draft.title?.trim() ?? ''; + const post = { + title: title === '' ? null : title, + content: draft.content, + mentionRoleIds: [...(draft.mentionRoleIds ?? [])], + }; + + announcementView(post); + + return await posts.insert({ + ...post, + guildId: actor.guildId, + authorId: actor.userId, + channelId: draft.channelId, + }); + }, + ), + edit: async ( + actor: Actor, + id: number, + changes: { title?: string; content: string }, + ) => { + await authz.require(actor, 'announcement:create'); + const post = await requireEditable(actor, id); + + validate({ channelId: post.channelId, content: changes.content }); + + const title = changes.title?.trim() ?? ''; + const updated = { + ...post, + title: title === '' ? null : title, + content: changes.content, + }; + + const parts = announcementView(updated).map((message) => ({ + ...message, + mentions: {}, + })); + + if (post.status !== 'published' || post.messageIds.length === 0) { + await posts.update(id, { + title: updated.title, + content: updated.content, + }); + + return updated; + } + + const messageIds: string[] = []; + + await sequential(parts.entries(), async ([index, part]) => { + const existing = post.messageIds[index]; + + if (existing === undefined) { + const sent = await messenger.send(post.channelId, part); + + messageIds.push(sent.messageId); + } else { + await messenger.edit(post.channelId, existing, part); + messageIds.push(existing); + } + }); + await Promise.all( + post.messageIds + .slice(parts.length) + .map((messageId) => messenger.remove(post.channelId, messageId)), + ); + await posts.update(id, { + title: updated.title, + content: updated.content, + messageIds, + }); + + return { ...updated, messageIds }; + }, + publish: guard(authz, 'announcement:publish', async (actor, id: number) => { + const post = await requireReadable(actor, id); + + await checkTargets(actor, post); + await scheduler.cancel(publishJob, jobKey(id)); + + return publish(id, open); + }), + schedule: guard( + authz, + 'announcement:schedule', + async (actor, id: number, when: string) => { + const post = await requireReadable(actor, id); + const runAt = parseFutureWhen(when, deps.timezone, clock.now()); + + await checkTargets(actor, post); + + const scheduled = await posts.update( + id, + { + status: 'scheduled', + scheduledAt: runAt, + failure: null, + }, + open, + ); + + if (!scheduled) { + throw new UserError( + `Announcement #${id} is already published or cancelled.`, + ); + } + + await scheduler.schedule( + publishJob, + { announcementId: id, scheduledBy: actor.userId }, + { runAt, key: jobKey(id) }, + ); + + return scheduled; + }, + ), + cancel: async (actor: Actor, id: number) => { + const post = await requireEditable(actor, id); + const cancelled = await posts.update( + id, + { + status: 'cancelled', + }, + open, + ); + + if (!cancelled) { + throw new UserError(`Announcement #${id} is already ${post.status}.`); + } + + await scheduler.cancel(publishJob, jobKey(id)); + + return cancelled; + }, + }; +} + +export type AnnouncementService = ReturnType; diff --git a/src/features/birthdays/form.ts b/src/features/birthdays/form.ts new file mode 100644 index 0000000..b22bf76 --- /dev/null +++ b/src/features/birthdays/form.ts @@ -0,0 +1,35 @@ +import { z } from 'zod'; +import { birthdayVisibilities, validateBirthday } from './rules'; +import { UserError } from '~/core/errors'; + +export const birthdayForm = z.object({ + day: z.number().int().min(1).max(31).meta({ label: 'Day', kind: 'integer' }), + month: z + .number() + .int() + .min(1) + .max(12) + .meta({ label: 'Month', kind: 'integer' }), + visibility: z + .enum(birthdayVisibilities) + .meta({ label: 'Visibility', kind: 'choice' }), +}); + +export function parseBirthdaySubmission(input: { + day: number; + month: number; + visibility?: string; +}): z.infer { + const visibility = + birthdayVisibilities.find((value) => value === input.visibility) ?? + 'public'; + const result = birthdayForm.safeParse({ ...input, visibility }); + + if (!result.success) { + throw new UserError('That is not a valid date.'); + } + + validateBirthday(result.data.month, result.data.day); + + return result.data; +} diff --git a/src/features/birthdays/model.ts b/src/features/birthdays/model.ts new file mode 100644 index 0000000..4b1e6c3 --- /dev/null +++ b/src/features/birthdays/model.ts @@ -0,0 +1,33 @@ +import type { BirthdayVisibility } from './rules'; +import type { CalendarDay } from '~/core/helpers/time'; + +export interface Birthday { + guildId: string; + userId: string; + month: number; + day: number; + visibility: BirthdayVisibility; + lastAnnouncedYear: number | null; +} + +export interface BirthdaySettings { + guildId: string; + channelId: string; + hour: number; +} + +export interface BirthdayRepository { + set: (birthday: Omit) => Promise; + remove: (guildId: string, userId: string) => Promise; + find: (guildId: string, userId: string) => Promise; + upcoming: ( + guildId: string, + today: CalendarDay, + limit?: number, + ) => Promise; + claim: (guildId: string, today: CalendarDay) => Promise; + release: (guildId: string, userIds: string[], year: number) => Promise; + settings: (guildId: string) => Promise; + saveSettings: (settings: BirthdaySettings) => Promise; + deleteSettings: (guildId: string) => Promise; +} diff --git a/src/features/birthdays/rules.ts b/src/features/birthdays/rules.ts new file mode 100644 index 0000000..1e547c8 --- /dev/null +++ b/src/features/birthdays/rules.ts @@ -0,0 +1,37 @@ +import { isLeapYear } from 'date-fns'; +import { UserError } from '~/core/errors'; +import type { CalendarDay } from '~/core/helpers/time'; + +export const birthdayVisibilities = ['public', 'announce', 'private'] as const; + +export type BirthdayVisibility = (typeof birthdayVisibilities)[number]; + +export const birthdayVisibilityLabels: Record = { + public: 'Announce it and show it in upcoming birthdays', + announce: 'Announce it, but keep the date unlisted', + private: 'Keep it private: no announcement', +}; + +export function validateBirthday(month: number, day: number): void { + const date = new Date(2024, month - 1, day); + + if (date.getMonth() !== month - 1 || date.getDate() !== day) { + throw new UserError('That is not a valid date.'); + } +} + +export function celebratedOn( + date: CalendarDay, +): Array<{ month: number; day: number }> { + const dates = [{ month: date.month, day: date.day }]; + + if ( + date.month === 2 && + date.day === 28 && + !isLeapYear(new Date(date.year, 0, 1)) + ) { + dates.push({ month: 2, day: 29 }); + } + + return dates; +} diff --git a/src/features/birthdays/service.ts b/src/features/birthdays/service.ts new file mode 100644 index 0000000..7320b6e --- /dev/null +++ b/src/features/birthdays/service.ts @@ -0,0 +1,215 @@ +import { format } from 'date-fns'; +import { z } from 'zod'; +import { parseBirthdaySubmission } from './form'; +import { calendarDay, nextDailyRun } from '~/core/helpers/time'; +import { + channelMention, + hereMention, + userMention, + type Message, +} from '~/core/message'; +import { PermanentError, UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import { type Authorizer } from '~/core/ports/authorization'; +import { guard } from '~/core/helpers/authorization'; +import type { Directory } from '~/core/ports/directory'; +import type { Logger } from '~/core/ports/logger'; +import type { Messenger } from '~/core/ports/messenger'; +import { type Scheduler } from '~/core/ports/scheduler'; +import { defineJob } from '~/core/helpers/jobs'; +import type { Birthday, BirthdaySettings, BirthdayRepository } from './model'; + +const dailyKey = (guildId: string) => `birthdays:${guildId}`; +const validHour = z.number().int().min(0).max(23); + +export interface BirthdayConfiguration { + channelId?: string; + hour?: number; + disable?: boolean; +} + +export function describeBirthday(birthday: Birthday): string { + const date = format( + new Date(2024, birthday.month - 1, birthday.day), + 'd MMMM', + ); + + return `${userMention(birthday.userId)} - ${date}`; +} + +export const birthdaySignup: Message = { + content: '# 🎂 Sünnipäevad\nLisa oma sünnipäeva kuupäev!', + controls: [ + [ + { + kind: 'button', + id: 'birthdays:add', + label: 'Lisa oma sünnipäev', + style: 'primary', + }, + ], + ], +}; + +interface Deps { + birthdays: BirthdayRepository; + scheduler: Scheduler; + messenger: Messenger; + directory: Directory; + authz: Authorizer; + log: Logger; + timezone: string; +} + +export function createBirthdayService(deps: Deps) { + const { birthdays, scheduler, messenger, directory, authz, log, timezone } = + deps; + + const announce = async ( + settings: BirthdaySettings, + userIds: string[], + year: number, + ) => { + try { + await messenger.send(settings.channelId, { + content: `${hereMention()} 🎉 Palju õnne sünnipäevaks, ${userIds.map((id) => userMention(id)).join(', ')}!`, + mentions: { users: userIds, here: true }, + }); + } catch (error) { + if (!(error instanceof PermanentError)) { + await birthdays.release(settings.guildId, userIds, year); + + throw error; + } + + log.error( + { error, guildId: settings.guildId }, + 'Birthday channel is unusable; skipping today', + ); + } + }; + + const dailyJob = defineJob({ + type: 'birthdays.daily', + payload: z.object({ guildId: z.string() }), + handle: async ({ guildId }) => { + const settings = await birthdays.settings(guildId); + + if (!settings) { + return null; + } + + const today = calendarDay(new Date(), timezone); + const userIds = await birthdays.claim(guildId, today); + + if (userIds.length > 0) { + await announce(settings, userIds, today.year); + } + + return { rescheduleAt: nextDailyRun(timezone, settings.hour) }; + }, + }); + + const resolveSettings = async ( + actor: Actor, + change: BirthdayConfiguration, + ) => { + const current = await birthdays.settings(actor.guildId); + const channelId = change.channelId ?? current?.channelId; + + if (channelId === undefined) { + throw new UserError('Choose an announcement channel.'); + } + + if (!(await directory.canPost(actor, channelId))) { + throw new UserError('You cannot post in that birthday channel yourself.'); + } + + const hour = change.hour ?? current?.hour ?? 9; + + if (!validHour.safeParse(hour).success) { + throw new UserError('Choose an announcement time from 00:00 to 23:00.'); + } + + return { + guildId: actor.guildId, + channelId, + hour, + }; + }; + + return { + jobs: [dailyJob], + set: async ( + actor: Actor, + birthday: { day: number; month: number; visibility?: string }, + ) => { + const parsed = parseBirthdaySubmission(birthday); + + await birthdays.set({ + guildId: actor.guildId, + userId: actor.userId, + ...parsed, + }); + + return parsed.visibility; + }, + remove: (actor: Actor) => birthdays.remove(actor.guildId, actor.userId), + view: async (actor: Actor, userId: string) => { + const birthday = await birthdays.find(actor.guildId, userId); + + return birthday && + (userId === actor.userId || birthday.visibility === 'public') + ? birthday + : undefined; + }, + settings: (guildId: string) => birthdays.settings(guildId), + postSignup: guard( + authz, + 'birthday:manage', + async (actor, channelId: string) => { + if (!(await directory.canPost(actor, channelId))) { + throw new UserError( + `You cannot post in ${channelMention(channelId)} yourself.`, + ); + } + + await messenger.send(channelId, birthdaySignup); + }, + ), + upcoming: async (guildId: string) => + birthdays.upcoming(guildId, calendarDay(new Date(), timezone)), + configure: guard( + authz, + 'birthday:manage', + async (actor, change: BirthdayConfiguration) => { + if (change.disable === true) { + await birthdays.deleteSettings(actor.guildId); + await scheduler.cancel(dailyJob, dailyKey(actor.guildId)); + + return 'Birthday announcements are off.'; + } + + const settings = await resolveSettings(actor, change); + + await birthdays.saveSettings(settings); + await scheduler.schedule( + dailyJob, + { guildId: actor.guildId }, + { + runAt: nextDailyRun(timezone, settings.hour), + key: dailyKey(actor.guildId), + }, + ); + log.info( + { guildId: actor.guildId, actorId: actor.userId, settings }, + 'Birthday settings changed', + ); + + return `Birthdays are announced in ${channelMention(settings.channelId)} at ${settings.hour}:00 (${timezone}).`; + }, + ), + }; +} + +export type BirthdayService = ReturnType; diff --git a/src/features/event-suggestions/model.ts b/src/features/event-suggestions/model.ts new file mode 100644 index 0000000..949bfd1 --- /dev/null +++ b/src/features/event-suggestions/model.ts @@ -0,0 +1,26 @@ +export type SuggestionStatus = 'new' | 'reviewed' | 'dismissed'; +export interface EventSuggestion { + id: number; + guildId: string; + authorId: string; + text: string; + channelId: string; + messageId: string | null; + status: SuggestionStatus; + createdAt: Date; +} +export interface EventSuggestionRepository { + insert: ( + input: Pick, + ) => Promise; + list: ( + guildId: string, + offset: number, + limit: number, + ) => Promise; + update: ( + guildId: string, + id: number, + changes: Partial>, + ) => Promise; +} diff --git a/src/features/event-suggestions/service.ts b/src/features/event-suggestions/service.ts new file mode 100644 index 0000000..4f19334 --- /dev/null +++ b/src/features/event-suggestions/service.ts @@ -0,0 +1,76 @@ +import type { Actor } from '~/core/actor'; +import type { Authorizer } from '~/core/ports/authorization'; +import type { Directory } from '~/core/ports/directory'; +import type { Messenger } from '~/core/ports/messenger'; +import { UserError } from '~/core/errors'; +import type { EventSuggestionRepository, SuggestionStatus } from './model'; + +export function createEventSuggestionService(deps: { + suggestions: EventSuggestionRepository; + authz: Authorizer; + directory: Directory; + messenger: Messenger; +}) { + const { suggestions, authz, directory, messenger } = deps; + + return { + suggest: async (actor: Actor, channelId: string, input: string) => { + const text = input.trim(); + + if (text.length === 0 || text.length > 1500) { + throw new UserError('Give an idea of 1–1500 characters.'); + } + + if (!(await directory.canView(actor, channelId))) { + throw new UserError('You cannot access that channel.'); + } + + if (!(await directory.canPost(actor, channelId))) { + throw new UserError('You cannot post in that channel.'); + } + + const suggestion = await suggestions.insert({ + guildId: actor.guildId, + authorId: actor.userId, + channelId, + text, + }); + let sent; + + try { + sent = await messenger.send(channelId, { + content: `Event suggestion from <@${actor.userId}>:\n${text}`, + }); + } catch { + return { suggestion, posted: false }; + } + + return { + suggestion: await suggestions.update(actor.guildId, suggestion.id, { + messageId: sent.messageId, + }), + posted: true, + }; + }, + list: async (actor: Actor, page = 0) => { + await authz.require(actor, 'event:suggestions:manage'); + if (!Number.isSafeInteger(page) || page < 0) { + throw new UserError('Invalid page.'); + } + + return suggestions.list(actor.guildId, page * 25, 25); + }, + review: async (actor: Actor, id: number, status: SuggestionStatus) => { + await authz.require(actor, 'event:suggestions:manage'); + if (!['new', 'reviewed', 'dismissed'].includes(status)) { + throw new UserError('Invalid status.'); + } + + return suggestions.update(actor.guildId, id, { status }); + }, + }; +} + +export type EventSuggestionService = ReturnType< + typeof createEventSuggestionService +>; diff --git a/src/features/events/calendar.ts b/src/features/events/calendar.ts new file mode 100644 index 0000000..39fd1ad --- /dev/null +++ b/src/features/events/calendar.ts @@ -0,0 +1,18 @@ +import type { CalendarEvent } from '~/core/ports/calendar'; +import type { Event } from './model'; + +type EventDetails = Pick< + Event, + 'title' | 'description' | 'location' | 'startsAt' | 'endsAt' +>; + +export function eventCalendarEntry(event: EventDetails): CalendarEvent { + return { + title: event.title, + description: event.description ?? '', + location: event.location ?? 'See the event post', + startsAt: event.startsAt, + endsAt: + event.endsAt ?? new Date(event.startsAt.getTime() + 2 * 60 * 60 * 1000), + }; +} diff --git a/src/features/events/message.ts b/src/features/events/message.ts new file mode 100644 index 0000000..91923f9 --- /dev/null +++ b/src/features/events/message.ts @@ -0,0 +1,129 @@ +import { + controlId, + maxContentLength, + userMention, + type Message, +} from '~/core/message'; +import { tz } from '@date-fns/tz'; +import { format } from 'date-fns'; +import type { CalendarEntry } from '~/core/ports/calendar'; +import { discordTime, sameCalendarDay } from '~/core/helpers/time'; +import { + rsvpStatuses, + type Event, + type RsvpCounts, + type RsvpStatus, +} from './model'; + +export const rsvpLabels: Record = { + going: 'Going', + maybe: 'Maybe', + not_going: 'Not going', +}; + +export function eventView(event: Event, counts: RsvpCounts): Message { + const cancelled = event.status === 'cancelled'; + const icon = (emoji: string) => (event.icons ? `${emoji} ` : ''); + const endStyle = + event.endsAt !== null && + sameCalendarDay(event.startsAt, event.endsAt, event.timezone) + ? 't' + : 'f'; + const end = + event.endsAt === null ? '' : ` - ${discordTime(event.endsAt, endStyle)}`; + const going = + event.capacity === null + ? String(counts.going) + : `${counts.going} / ${event.capacity}`; + const prefix = cancelled ? '[Cancelled] ' : ''; + const lines = [ + `# ${prefix}${event.title}`, + ...(event.description === null ? [] : [event.description, '']), + `${icon('🗓️')}${discordTime(event.startsAt, 'D')} (${discordTime(event.startsAt, 'R')})`, + `${icon('🕐')}${discordTime(event.startsAt, 't')}${end}`, + ...(event.location === null ? [] : [`${icon('📍')}${event.location}`]), + '', + `**Going:** ${going} · **Maybe:** ${counts.maybe}`, + `-# Event #${event.id} · organized by ${userMention(event.organizerId)}`, + ]; + + return { + content: lines.join('\n'), + controls: cancelled + ? [] + : [ + rsvpStatuses.map((status) => ({ + kind: 'button' as const, + id: controlId('events:rsvp', event.id, status), + label: rsvpLabels[status], + style: + status === 'going' + ? ('success' as const) + : ('secondary' as const), + })), + ], + }; +} + +export function reminderText( + event: Event, + minutes: number, + going: readonly string[], +) { + const link = + event.messageId === null + ? '' + : ` https://discord.com/channels/${event.guildId}/${event.channelId}/${event.messageId}`; + const head = `⏰ **${event.title}** starts ${discordTime(event.startsAt, 'R')} (${minutes} min reminder).${link}`; + const pinged: string[] = []; + let length = head.length + 1; + + for (const id of going) { + const mention = `${userMention(id)} `; + + if (length + mention.length > maxContentLength) { + break; + } + + pinged.push(id); + length += mention.length; + } + + return { + content: [head, pinged.map((id) => userMention(id)).join(' ')] + .filter(Boolean) + .join('\n'), + pinged, + }; +} + +export type DayEntry = Omit; + +export function dayOverview( + entries: readonly DayEntry[], + timezone: string, +): string { + if (entries.length === 0) { + return 'nothing else that day'; + } + + return `also: ${entries.map((entry) => entryLabel(entry, timezone)).join(', ')}`; +} + +export function entryLabel(entry: DayEntry, timezone: string): string { + const time = entry.allDay + ? 'all day' + : format(entry.startsAt, 'HH:mm', { in: tz(timezone) }); + + return `${entry.title} ${time}`; +} + +export function dayChoice( + startsAt: Date, + entries: readonly DayEntry[], + timezone: string, +): string { + const when = format(startsAt, 'EEE d MMM HH:mm', { in: tz(timezone) }); + + return `${when} · ${dayOverview(entries, timezone)}`.slice(0, 100); +} diff --git a/src/features/events/model.ts b/src/features/events/model.ts new file mode 100644 index 0000000..9f2dfbc --- /dev/null +++ b/src/features/events/model.ts @@ -0,0 +1,51 @@ +export const rsvpStatuses = ['going', 'maybe', 'not_going'] as const; + +export type RsvpStatus = (typeof rsvpStatuses)[number]; + +export type RsvpCounts = Record; + +export interface Event { + id: number; + guildId: string; + title: string; + description: string | null; + startsAt: Date; + endsAt: Date | null; + timezone: string; + location: string | null; + organizerId: string; + channelId: string; + messageId: string | null; + capacity: number | null; + mentionRoleId: string | null; + reminderMinutes: number[]; + icons: boolean; + calendarEventId: string | null; + status: 'scheduled' | 'cancelled'; + createdAt: Date; +} + +export type NewEvent = Omit< + Event, + 'id' | 'messageId' | 'calendarEventId' | 'status' | 'createdAt' +>; + +export interface EventRepository { + insert: (event: NewEvent) => Promise; + find: (id: number) => Promise; + upcoming: (guildId: string, limit?: number) => Promise; + between: (guildId: string, from: Date, to: Date) => Promise; + update: ( + id: number, + changes: Partial>, + ) => Promise; + setRsvp: ( + eventId: number, + userId: string, + status: RsvpStatus, + ) => Promise; + counts: (eventId: number) => Promise; + attendees: ( + eventId: number, + ) => Promise>; +} diff --git a/src/features/events/service.ts b/src/features/events/service.ts new file mode 100644 index 0000000..c664c0a --- /dev/null +++ b/src/features/events/service.ts @@ -0,0 +1,551 @@ +import { eventCalendarEntry } from './calendar'; +import { eventView, reminderText, type DayEntry } from './message'; +import { z } from 'zod'; +import { channelMention, maxContentLength, roleMention } from '~/core/message'; +import { + addCalendarDays, + calendarDay, + parseFutureWhen, + parseWhen, + zonedTime, +} from '~/core/helpers/time'; +import { visibleRecords } from '~/core/helpers/visibility'; +import { UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import { requireMentionable } from '~/core/helpers/roles'; +import type { Authorizer } from '~/core/ports/authorization'; +import type { Calendar } from '~/core/ports/calendar'; +import type { Directory } from '~/core/ports/directory'; +import type { Logger } from '~/core/ports/logger'; +import type { Messenger } from '~/core/ports/messenger'; +import { type Scheduler } from '~/core/ports/scheduler'; +import { defineJob } from '~/core/helpers/jobs'; +import type { Event, NewEvent, RsvpStatus, EventRepository } from './model'; + +const maxReminders = 3; +const reminderKey = (id: number, minutes: number) => + `event:${id}:remind:${minutes}`; + +export interface EventRequest { + title: string; + start: string; + end?: string; + description?: string; + location?: string; + channelId: string; + capacity?: number; + mentionRoleId?: string; + reminders?: string; + calendar?: boolean; + icons?: boolean; +} + +export interface EventChanges extends Partial< + Pick +> { + end?: string | null; + description?: string | null; + location?: string | null; + capacity?: number | null; +} + +const maxTitleLength = 200; +const maxDescriptionLength = 1500; + +function requireText(title: string, description?: string | null) { + if (title.trim() === '' || title.length > maxTitleLength) { + throw new UserError(`Give a title of 1-${maxTitleLength} characters.`); + } + + if ((description?.length ?? 0) > maxDescriptionLength) { + throw new UserError( + `Keep the description under ${maxDescriptionLength} characters.`, + ); + } +} + +function requireCapacity(capacity?: number | null) { + if ( + capacity !== undefined && + capacity !== null && + (!Number.isInteger(capacity) || capacity < 1) + ) { + throw new UserError('Capacity must be a whole number of at least 1.'); + } +} + +function requirePublishable(input: NewEvent, mention = false) { + const view = eventView( + { + ...input, + id: 2_147_483_647, + messageId: null, + calendarEventId: null, + status: 'cancelled', + createdAt: new Date(), + }, + { going: 2_147_483_647, maybe: 2_147_483_647, not_going: 0 }, + ); + const prefix = + mention && input.mentionRoleId !== null + ? `${roleMention(input.mentionRoleId)}\n` + : ''; + + if (prefix.length + (view.content?.length ?? 0) > maxContentLength) { + throw new UserError( + `Keep the complete event message under ${maxContentLength} characters. Shorten the title, description or location.`, + ); + } +} + +export const reminderChoices = [ + { label: '1 hour before', value: '60' }, + { label: '15 minutes before', value: '15' }, + { label: '1 day before', value: '1440' }, + { label: '1 day and 1 hour before', value: '1440,60' }, + { label: 'No reminders', value: 'none' }, +] as const; + +export function parseReminderMinutes(value: string | undefined): number[] { + if (value === undefined) { + return [60]; + } + + if (value.trim() === '' || value === 'none') { + return []; + } + + const minutes = value.split(',').map((part) => Number(part.trim())); + + if ( + minutes.length > maxReminders || + minutes.some((m) => !Number.isInteger(m) || m < 1 || m > 10_080) + ) { + throw new UserError( + `Reminders are up to ${maxReminders} comma-separated minute values, e.g. "60,15".`, + ); + } + + return [...new Set(minutes)]; +} + +interface Deps { + events: EventRepository; + scheduler: Scheduler; + messenger: Messenger; + calendar?: Calendar; + directory: Directory; + authz: Authorizer; + log: Logger; + timezone: string; +} + +export function createEventService(deps: Deps) { + const { events, scheduler, messenger, calendar, directory, authz, log } = + deps; + + const remindJob = defineJob({ + type: 'events.remind', + payload: z.object({ eventId: z.number().int(), minutes: z.number().int() }), + handle: async ({ eventId, minutes }) => { + const event = await events.find(eventId); + + if ( + event?.status !== 'scheduled' || + event.startsAt.getTime() <= Date.now() + ) { + return; + } + + const attendees = await events.attendees(eventId); + const going = attendees + .filter((a) => a.status === 'going') + .map((a) => a.userId); + const { content, pinged } = reminderText(event, minutes, going); + + await messenger.send(event.channelId, { + content, + mentions: { users: pinged }, + }); + }, + }); + + const refresh = async (event: Event) => { + if (event.messageId === null) { + return; + } + + const edited = await messenger.edit( + event.channelId, + event.messageId, + eventView(event, await events.counts(event.id)), + ); + + if (!edited) { + log.warn({ eventId: event.id }, 'Event message or channel was deleted'); + } + }; + + const scheduleReminders = async ( + event: Event, + previous: readonly number[] = [], + ) => { + await Promise.all( + previous.map((minutes) => + scheduler.cancel(remindJob, reminderKey(event.id, minutes)), + ), + ); + + if (event.status !== 'scheduled') { + return; + } + + const upcoming = event.reminderMinutes + .map((minutes) => ({ + minutes, + runAt: new Date(event.startsAt.getTime() - minutes * 60_000), + })) + .filter(({ runAt }) => runAt.getTime() > Date.now()); + + await Promise.all( + upcoming.map(({ minutes, runAt }) => + scheduler.schedule( + remindJob, + { eventId: event.id, minutes }, + { runAt, key: reminderKey(event.id, minutes) }, + ), + ), + ); + }; + + const syncCalendar = async (event: Event): Promise => { + if (calendar === undefined) { + return event.calendarEventId; + } + + try { + if (event.status === 'cancelled') { + if (event.calendarEventId !== null) { + await calendar.remove(event.calendarEventId); + } + + return null; + } + + return await calendar.upsert( + event.calendarEventId, + eventCalendarEntry(event), + ); + } catch (error) { + log.warn({ error, eventId: event.id }, 'Could not sync Google Calendar'); + + throw new UserError( + event.status === 'cancelled' + ? `Calendar removal failed. The Discord event is cancelled; retry /event cancel id:${event.id}.` + : 'Calendar synchronization failed. The Discord event is saved; retry calendar posting.', + ); + } + }; + + const requireCalendarChannel = async (actor: Actor, channelId: string) => { + if (calendar === undefined) { + throw new UserError('The club Google Calendar is not set up.'); + } + + if (!(await directory.isPublic(actor.guildId, channelId))) { + throw new UserError( + 'Only events in channels everyone can see can go to the club calendar.', + ); + } + }; + + const publish = async (input: NewEvent, synced = false) => { + requirePublishable(input, true); + + let event = await events.insert(input); + const view = eventView(event, { going: 0, maybe: 0, not_going: 0 }); + const sent = await messenger.send( + event.channelId, + event.mentionRoleId === null + ? view + : { + ...view, + content: `${roleMention(event.mentionRoleId)}\n${view.content ?? ''}`, + mentions: { roles: [event.mentionRoleId] }, + }, + ); + + event = await events.update(event.id, { messageId: sent.messageId }); + await scheduleReminders(event); + if (synced) { + event = await events.update(event.id, { + calendarEventId: await syncCalendar(event), + }); + } + + return event; + }; + + const requireEvent = async (actor: Actor, id: number) => { + const event = await events.find(id); + + if ( + event?.guildId !== actor.guildId || + !(await directory.canView(actor, event.channelId)) + ) { + throw new UserError(`Event #${id} does not exist.`); + } + + return event; + }; + + const requireManageable = async (actor: Actor, id: number) => { + const event = await requireEvent(actor, id); + + if (event.organizerId !== actor.userId) { + await authz.require(actor, 'event:manage'); + } + + return event; + }; + + const requirePostable = async (actor: Actor, channelId: string) => { + if (!(await directory.canPost(actor, channelId))) { + throw new UserError( + `You cannot post in ${channelMention(channelId)} yourself.`, + ); + } + }; + + return { + jobs: [remindJob], + calendarEnabled: calendar !== undefined, + crosspost: async (actor: Actor, id: number) => { + await authz.require(actor, 'event:calendar:publish'); + const event = await requireEvent(actor, id); + + if (event.status !== 'scheduled') { + throw new UserError('Cancelled events cannot be crossposted.'); + } + + await requireCalendarChannel(actor, event.channelId); + if (calendar === undefined) { + throw new UserError('The club Google Calendar is not set up.'); + } + + const calendarEventId = await syncCalendar(event); + + return events.update(id, { calendarEventId }); + }, + get: requireEvent, + view: async (actor: Actor, id: number) => { + const event = await requireEvent(actor, id); + + return eventView(event, await events.counts(event.id)); + }, + upcoming: (guildId: string) => events.upcoming(guildId), + sameDay: async (actor: Actor, start: string) => { + const { timezone } = deps; + const startsAt = parseFutureWhen(start, timezone); + const day = calendarDay(startsAt, timezone); + const from = zonedTime(day, 0, timezone); + const to = zonedTime(addCalendarDays(day, 1), 0, timezone); + const local = await visibleRecords( + directory, + actor, + await events.between(actor.guildId, from, to), + ); + const linked = new Set(local.map((event) => event.calendarEventId)); + const external = + calendar === undefined + ? [] + : await calendar.between(from, to).catch((error: unknown) => { + log.warn({ error }, 'Could not read Google Calendar'); + + return []; + }); + const entries: DayEntry[] = [ + ...local.map((event) => ({ + title: event.title, + startsAt: event.startsAt, + allDay: false, + })), + ...external.filter((entry) => !linked.has(entry.id)), + ]; + + return { + startsAt, + entries: entries.toSorted( + (a, b) => a.startsAt.getTime() - b.startsAt.getTime(), + ), + }; + }, + attendees: async (actor: Actor, id: number) => { + const event = await requireEvent(actor, id); + + return { event, attendees: await events.attendees(event.id) }; + }, + publish: async (actor: Actor, input: NewEvent) => { + await requirePostable(actor, input.channelId); + + return publish(input); + }, + create: async (actor: Actor, request: EventRequest) => { + await authz.require(actor, 'event:create'); + await requirePostable(actor, request.channelId); + + if (request.calendar === true) { + await authz.require(actor, 'event:calendar:publish'); + await requireCalendarChannel(actor, request.channelId); + } + + if (request.mentionRoleId !== undefined) { + const role = await directory.role(actor.guildId, request.mentionRoleId); + + if (!role) { + throw new UserError('That role no longer exists.'); + } + + requireMentionable(role); + } + + const { timezone } = deps; + const startsAt = parseFutureWhen(request.start, timezone); + const endsAt = + request.end === undefined + ? null + : parseWhen(request.end, timezone, startsAt); + + if (endsAt && endsAt <= startsAt) { + throw new UserError('The end must be after the start.'); + } + + requireText(request.title, request.description); + requireCapacity(request.capacity); + + const event = await publish( + { + guildId: actor.guildId, + title: request.title, + description: request.description ?? null, + startsAt, + endsAt, + timezone, + location: request.location ?? null, + organizerId: actor.userId, + channelId: request.channelId, + capacity: request.capacity ?? null, + mentionRoleId: request.mentionRoleId ?? null, + reminderMinutes: parseReminderMinutes(request.reminders), + icons: request.icons ?? true, + }, + request.calendar ?? false, + ); + + log.info({ eventId: event.id, actorId: actor.userId }, 'Event created'); + + return event; + }, + edit: async (actor: Actor, id: number, changes: EventChanges) => { + const event = await requireManageable(actor, id); + + if (event.status !== 'scheduled') { + throw new UserError('Cancelled events cannot be edited.'); + } + + if (needsCalendarPermission(event, changes)) { + await authz.require(actor, 'event:calendar:publish'); + } + + const startsAt = + changes.start === undefined + ? event.startsAt + : parseFutureWhen(changes.start, event.timezone); + let endsAt = event.endsAt; + + if (changes.end !== undefined) { + endsAt = + changes.end === null + ? null + : parseWhen(changes.end, event.timezone, startsAt); + } + + if (endsAt && endsAt <= startsAt) { + throw new UserError('The end must be after the start.'); + } + + requireText(changes.title ?? event.title, changes.description); + requireCapacity(changes.capacity); + + const updates = { + title: changes.title ?? event.title, + description: + changes.description === undefined + ? event.description + : changes.description, + location: + changes.location === undefined ? event.location : changes.location, + capacity: + changes.capacity === undefined ? event.capacity : changes.capacity, + icons: changes.icons ?? event.icons, + startsAt, + endsAt, + }; + + requirePublishable({ ...event, ...updates }); + + let updated = await events.update(event.id, updates); + + await refresh(updated); + await scheduleReminders(updated, event.reminderMinutes); + + if (updated.calendarEventId !== null) { + updated = await events.update(event.id, { + calendarEventId: await syncCalendar(updated), + }); + } + + log.info({ eventId: event.id, actorId: actor.userId }, 'Event edited'); + + return updated; + }, + cancel: async (actor: Actor, id: number) => { + const event = await requireManageable(actor, id); + + if (event.status === 'cancelled' && event.calendarEventId === null) { + throw new UserError('That event is already cancelled.'); + } + + const cancelled = await events.update(event.id, { status: 'cancelled' }); + const [, , calendarEventId] = await Promise.all([ + refresh(cancelled), + scheduleReminders(cancelled, event.reminderMinutes), + syncCalendar(cancelled), + ]); + + log.info({ eventId: event.id, actorId: actor.userId }, 'Event cancelled'); + + return calendarEventId === cancelled.calendarEventId + ? cancelled + : await events.update(event.id, { calendarEventId }); + }, + rsvp: async (actor: Actor, id: number, status: RsvpStatus) => { + const event = await requireEvent(actor, id); + + await events.setRsvp(event.id, actor.userId, status); + + return eventView(event, await events.counts(event.id)); + }, + }; +} + +export type EventService = ReturnType; + +function needsCalendarPermission(event: Event, changes: EventChanges): boolean { + return ( + event.calendarEventId !== null && + ['title', 'description', 'start', 'end', 'location'].some( + (key) => key in changes, + ) + ); +} diff --git a/src/features/movies/model.ts b/src/features/movies/model.ts new file mode 100644 index 0000000..c52f064 --- /dev/null +++ b/src/features/movies/model.ts @@ -0,0 +1,59 @@ +export interface MovieSuggestion { + id: number; + guildId: string; + title: string; + normalizedTitle: string; + year: number | null; + note: string | null; + suggestedBy: string; + tmdbId: number | null; + overview: string | null; + posterUrl: string | null; + trailerUrl: string | null; + links: string[]; + createdAt: Date; + removedAt: Date | null; +} + +export type NewSuggestion = Pick< + MovieSuggestion, + | 'guildId' + | 'title' + | 'year' + | 'note' + | 'suggestedBy' + | 'tmdbId' + | 'overview' + | 'posterUrl' + | 'trailerUrl' + | 'links' +>; + +export interface Screening { + guildId: string; + suggestionId: number; + eventId?: number | null; + pollId?: number | null; + scheduledFor?: Date | null; +} + +export interface WatchedMovie { + title: string; + year: number | null; + watchedAt: Date | null; +} + +export interface MovieRepository { + suggest: (suggestion: NewSuggestion) => Promise; + find: (guildId: string, id: number) => Promise; + unwatched: (guildId: string, limit?: number) => Promise; + remove: (id: number) => Promise; + setLinks: (id: number, links: readonly string[]) => Promise; + recordScreening: (screening: Screening) => Promise; + markWatched: ( + guildId: string, + suggestionId: number, + at: Date, + ) => Promise; + history: (guildId: string, limit?: number) => Promise; +} diff --git a/src/features/movies/rules.ts b/src/features/movies/rules.ts new file mode 100644 index 0000000..e09a289 --- /dev/null +++ b/src/features/movies/rules.ts @@ -0,0 +1,59 @@ +import { UserError } from '~/core/errors'; + +export function normalizeTitle(title: string): string { + return title + .normalize('NFKD') + .toLowerCase() + .replaceAll(/[^\p{L}\p{N}]+/gu, ' ') + .trim(); +} + +export const movieLabel = (movie: { title: string; year: number | null }) => + movie.year === null ? movie.title : `${movie.title} (${movie.year})`; + +export const maxMovieLinks = 5; + +export const tmdbPage = (id: number) => + `https://www.themoviedb.org/movie/${id}`; + +export function validateLinks(links: readonly string[]): string[] { + const trimmed = links + .map((link) => link.trim()) + .filter((link) => link !== ''); + + if (trimmed.length > maxMovieLinks) { + throw new UserError(`Add at most ${maxMovieLinks} links.`); + } + + for (const link of trimmed) { + if (!URL.canParse(link) || !/^https?:$/.test(new URL(link).protocol)) { + throw new UserError(`"${link.slice(0, 80)}" is not a web link.`); + } + } + + return [...new Set(trimmed)]; +} + +export interface MovieLink { + label: string; + url: string; +} + +export function movieLinks(movie: { + trailerUrl: string | null; + tmdbId: number | null; + links: readonly string[]; +}): MovieLink[] { + return [ + ...(movie.trailerUrl === null + ? [] + : [{ label: 'Trailer', url: movie.trailerUrl }]), + ...(movie.tmdbId === null + ? [] + : [{ label: 'TMDB', url: tmdbPage(movie.tmdbId) }]), + ...movie.links.map((url) => ({ + label: new URL(url).hostname.replace(/^www\./, ''), + url, + })), + ]; +} diff --git a/src/features/movies/service.ts b/src/features/movies/service.ts new file mode 100644 index 0000000..a7c7615 --- /dev/null +++ b/src/features/movies/service.ts @@ -0,0 +1,215 @@ +import { maxOptionLength } from '~/features/polls/rules'; +import { movieLabel, movieLinks, validateLinks } from './rules'; +import { parseFutureWhen, parseWhen } from '~/core/helpers/time'; +import { UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import { type Authorizer } from '~/core/ports/authorization'; +import { guard } from '~/core/helpers/authorization'; +import type { MovieCatalog, MovieDetails } from '~/core/ports/movie-catalog'; +import type { MovieRepository } from './model'; +import type { EventService } from '~/features/events/service'; +import type { PollService } from '~/features/polls/service'; + +const pollSource = 'movies'; + +export interface MovieNight { + start: string; + movieId?: number; + location?: string; + capacity?: number; + channelId: string; +} + +export interface MovieSuggestionRequest { + title: string; + year: number | null; + note: string | null; + links?: readonly string[]; +} + +interface Deps { + movies: MovieRepository; + catalog: MovieCatalog | undefined; + polls: PollService; + events: EventService; + authz: Authorizer; + timezone: string; +} + +export function createMovieService(deps: Deps) { + const { movies, polls, events, authz, timezone, catalog } = deps; + + const lookup = async ( + title: string, + year: number | null, + ): Promise => + catalog ? await catalog.lookup(title, year).catch(() => null) : null; + + const requireOwned = async (actor: Actor, id: number) => { + const movie = await movies.find(actor.guildId, id); + + if (movie.suggestedBy !== actor.userId) { + await authz.require(actor, 'movie:manage'); + } + + return movie; + }; + + const pick = async (actor: Actor, movieId: number | undefined) => { + if (movieId !== undefined) { + return { movie: await movies.find(actor.guildId, movieId), pollId: null }; + } + + const poll = await polls.latestBySource(actor.guildId, pollSource); + + if (poll?.status !== 'closed') { + throw new UserError('Pick a movie, or close a "/movie vote" poll first.'); + } + + const { winners, tie } = await polls.results(poll); + const [winner] = winners; + + if (winner === undefined) { + throw new UserError('The last movie poll had no votes. Pick a movie.'); + } + + if (tie) { + const tied = winners.map((w) => `#${w.ref ?? '?'} ${w.label}`).join(', '); + + throw new UserError( + `The last poll is a tie between ${tied}. Pick one with the "movie" option.`, + ); + } + + return { + movie: await movies.find(actor.guildId, Number(winner.ref)), + pollId: poll.id, + }; + }; + + return { + pick, + suggest: async (actor: Actor, request: MovieSuggestionRequest) => { + const links = validateLinks(request.links ?? []); + const details = await lookup(request.title, request.year); + + return movies.suggest({ + guildId: actor.guildId, + suggestedBy: actor.userId, + title: details?.title ?? request.title, + year: details?.year ?? request.year, + note: request.note, + tmdbId: details?.tmdbId ?? null, + overview: details?.overview ?? null, + posterUrl: details?.posterUrl ?? null, + trailerUrl: details?.trailerUrl ?? null, + links, + }); + }, + addLinks: async (actor: Actor, id: number, links: readonly string[]) => { + const movie = await requireOwned(actor, id); + const merged = validateLinks([...movie.links, ...links]); + + await movies.setLinks(movie.id, merged); + + return { ...movie, links: merged }; + }, + unwatched: (guildId: string, limit?: number) => + movies.unwatched(guildId, limit), + history: (guildId: string) => movies.history(guildId), + remove: async (actor: Actor, id: number) => { + const movie = await requireOwned(actor, id); + + await movies.remove(movie.id); + + return movie; + }, + vote: guard( + authz, + 'movie:manage', + async ( + actor, + request: { count?: number; closes?: string; channelId: string }, + ) => { + const candidates = await movies.unwatched( + actor.guildId, + request.count ?? 10, + ); + + if (candidates.length < 2) { + throw new UserError( + 'At least two unwatched suggestions are needed for a vote.', + ); + } + + const closesAt = parseFutureWhen(request.closes ?? '2d', timezone); + + return polls.publish(actor, { + guildId: actor.guildId, + channelId: request.channelId, + creatorId: actor.userId, + question: '🎬 What should we watch next?', + options: candidates.map((m) => ({ + label: movieLabel(m).slice(0, maxOptionLength), + ref: String(m.id), + url: movieLinks(m)[0]?.url ?? null, + })), + closesAt, + source: pollSource, + }); + }, + ), + night: guard(authz, 'movie:manage', async (actor, night: MovieNight) => { + const { movie, pollId } = await pick(actor, night.movieId); + const startsAt = parseFutureWhen(night.start, timezone); + const event = await events.publish(actor, { + guildId: actor.guildId, + title: `🎬 Movie night: ${movieLabel(movie)}`.slice(0, 200), + description: + [ + movie.note, + movie.overview?.slice(0, 900), + movieLinks(movie) + .map(({ label, url }) => `[${label}](${url})`) + .join(' · '), + ] + .filter(Boolean) + .join('\n\n') || null, + startsAt, + endsAt: null, + timezone, + location: night.location ?? null, + organizerId: actor.userId, + channelId: night.channelId, + capacity: night.capacity ?? null, + mentionRoleId: null, + reminderMinutes: [60], + icons: true, + }); + + await movies.recordScreening({ + guildId: actor.guildId, + suggestionId: movie.id, + eventId: event.id, + pollId, + scheduledFor: startsAt, + }); + + return { movie, event }; + }), + watched: guard( + authz, + 'movie:manage', + async (actor, id: number, date?: string) => { + const movie = await movies.find(actor.guildId, id); + const at = date === undefined ? new Date() : parseWhen(date, timezone); + + await movies.markWatched(actor.guildId, movie.id, at); + + return movie; + }, + ), + }; +} + +export type MovieService = ReturnType; diff --git a/src/features/permissions/model.ts b/src/features/permissions/model.ts new file mode 100644 index 0000000..d25358c --- /dev/null +++ b/src/features/permissions/model.ts @@ -0,0 +1,45 @@ +import type { Permission } from '~/core/permission'; + +export type GrantSubject = 'role' | 'user'; + +export interface Grant { + subjectType?: GrantSubject; + roleId: string; + permission: string; +} + +export interface GrantChange { + subjectType?: GrantSubject; + guildId: string; + roleId: string; + permission: Permission; +} + +export interface GrantRepository { + holds: ( + guildId: string, + roleIds: readonly string[], + permission: Permission, + userId?: string, + ) => Promise; + held: ( + guildId: string, + roleIds: readonly string[], + userId?: string, + ) => Promise; + grant: (change: GrantChange & { grantedBy: string }) => Promise; + revoke: (change: GrantChange) => Promise; + apply: (input: { + guildId: string; + roleId: string; + subjectType?: GrantSubject; + grantedBy: string; + grant: readonly Permission[]; + revoke: readonly Permission[]; + }) => Promise; + list: ( + guildId: string, + roleId?: string, + subjectType?: GrantSubject, + ) => Promise; +} diff --git a/src/features/permissions/service.ts b/src/features/permissions/service.ts new file mode 100644 index 0000000..1c4518b --- /dev/null +++ b/src/features/permissions/service.ts @@ -0,0 +1,200 @@ +import { checkDelegation } from '~/core/helpers/permissions'; +import { + applicationAdmin, + managePermissions, + type Permission, + type PermissionDefinition, +} from '~/core/permission'; +import { UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import { type Authorizer } from '~/core/ports/authorization'; +import { guard } from '~/core/helpers/authorization'; +import type { Directory } from '~/core/ports/directory'; +import type { Logger } from '~/core/ports/logger'; +import type { GrantRepository, GrantSubject } from './model'; + +export function createAuthorizer(grants: GrantRepository): Authorizer { + const can = async (actor: Actor, permission: Permission) => + actor.administrator || + (permission !== applicationAdmin && + (await grants.holds( + actor.guildId, + actor.roleIds, + permission, + actor.userId, + ))); + + return { + can, + require: async (actor, permission) => { + if (!(await can(actor, permission))) { + throw new UserError( + `You need the "${permission}" permission for this.`, + ); + } + }, + granted: async (actor, permissions) => { + if (actor.administrator) { + return new Set(permissions); + } + + const held = new Set( + await grants.held(actor.guildId, actor.roleIds, actor.userId), + ); + + return new Set( + permissions.filter( + (permission) => + permission !== applicationAdmin && held.has(permission), + ), + ); + }, + }; +} + +interface Deps { + grants: GrantRepository; + directory: Directory; + authz: Authorizer; + log: Logger; + known: () => ReadonlyMap; +} + +export function createPermissionService(deps: Deps) { + const { grants, directory, authz, log, known } = deps; + + const definition = (value: string): PermissionDefinition => { + if (value === applicationAdmin) { + throw new UserError( + 'Application administrator access cannot be granted as a bot permission.', + ); + } + + const found = [...known().values()].find((p) => p.id === value); + + if (!found) { + throw new UserError(`Unknown permission "${value}".`); + } + + return found; + }; + + const change = (action: 'grant' | 'revoke') => + guard( + authz, + managePermissions, + async ( + actor, + roleId: string, + value: string, + subjectType: GrantSubject = 'role', + ) => { + const { id: permission } = definition(value); + const role = + subjectType === 'user' + ? await directory + .member(actor.guildId, roleId) + .then( + (member) => + member && { position: member.highestRolePosition }, + ) + : await directory.role(actor.guildId, roleId); + + if (!role) { + throw new UserError('That member or role does not exist.'); + } + + checkDelegation({ + actor, + rolePosition: role.position, + permission, + actorHolds: await authz.can(actor, permission), + }); + + const input = { + guildId: actor.guildId, + roleId, + permission, + subjectType, + }; + const changed = + action === 'grant' + ? await grants.grant({ ...input, grantedBy: actor.userId }) + : await grants.revoke(input); + + log.info( + { ...input, actorId: actor.userId, action, changed }, + 'Permission change', + ); + + return changed; + }, + ); + + const grant = change('grant'); + const revoke = change('revoke'); + + return { + catalogue: () => [...known().values()], + grant, + revoke, + list: guard( + authz, + managePermissions, + (actor, roleId?: string, subjectType?: GrantSubject) => + grants.list(actor.guildId, roleId, subjectType), + ), + setRole: guard( + authz, + managePermissions, + async (actor, roleId: string, wanted: readonly string[]) => { + const target = new Set(wanted.map((value) => definition(value).id)); + const granted = await grants.list(actor.guildId, roleId, 'role'); + const current = new Set(granted.map((g) => g.permission)); + const toGrant = [...target].filter((p) => !current.has(p)); + const toRevoke = [...known().keys()].filter( + (p) => current.has(p) && !target.has(p), + ); + + const role = await directory.role(actor.guildId, roleId); + + if (!role) { + throw new UserError('That role does not exist.'); + } + + await Promise.all( + [...toGrant, ...toRevoke].map(async (permission) => { + checkDelegation({ + actor, + rolePosition: role.position, + permission, + actorHolds: await authz.can(actor, permission), + }); + }), + ); + + await grants.apply({ + guildId: actor.guildId, + roleId, + grantedBy: actor.userId, + grant: toGrant, + revoke: toRevoke, + }); + log.info( + { + guildId: actor.guildId, + roleId, + actorId: actor.userId, + granted: toGrant, + revoked: toRevoke, + }, + 'Permission replacement', + ); + + return { granted: toGrant.length, revoked: toRevoke.length }; + }, + ), + }; +} + +export type PermissionService = ReturnType; diff --git a/src/features/polls/form.ts b/src/features/polls/form.ts new file mode 100644 index 0000000..7cc5419 --- /dev/null +++ b/src/features/polls/form.ts @@ -0,0 +1,42 @@ +import { z } from 'zod'; +import { UserError } from '~/core/errors'; + +interface Option { + id: number; + label: string; +} + +export function pollResponseForm( + options: readonly Option[], + multiple: boolean, +) { + const allowed = new Set(options.map(({ id }) => id)); + const choices = z.array(z.custom((value) => allowed.has(value))); + + return z.object({ + choices: (multiple ? choices : choices.max(1)).meta({ + label: 'Choices', + kind: 'choice', + }), + }); +} + +export function validatePollResponse( + options: readonly Option[], + multiple: boolean, + optionIds: readonly number[], +): number[] { + const result = pollResponseForm(options, multiple).safeParse({ + choices: [...new Set(optionIds)], + }); + + if (!result.success) { + throw new UserError( + result.error.issues.some(({ code }) => code === 'too_big') + ? 'This poll allows only one choice.' + : 'That option is not part of this poll.', + ); + } + + return result.data.choices; +} diff --git a/src/features/polls/message.ts b/src/features/polls/message.ts new file mode 100644 index 0000000..b35d2f4 --- /dev/null +++ b/src/features/polls/message.ts @@ -0,0 +1,130 @@ +import { controlId, maxContentLength, type Message } from '~/core/message'; +import { discordTime } from '~/core/helpers/time'; +import { UserError } from '~/core/errors'; +import { isPollOpen } from './rules'; +import type { NewPoll, Poll, PollResults, PollWithOptions } from './model'; + +function bar(votes: number, total: number): string { + const filled = + total <= 0 + ? 0 + : Math.max(0, Math.min(10, Math.round((votes / total) * 10))); + + return '▰'.repeat(filled) + '▱'.repeat(10 - filled); +} + +export function describeOutcome(results: PollResults, leader: string): string { + const label = results.tie ? 'Tie' : leader; + + return `**${label}:** ${results.winners.map((w) => w.label).join(', ')}`; +} + +function statusLine(poll: Poll, open: boolean): string { + if (open) { + return poll.closesAt === null + ? 'Open' + : `Closes ${discordTime(poll.closesAt, 'R')}`; + } + + return poll.status === 'cancelled' ? 'Cancelled' : 'Closed'; +} + +export function renderPoll( + poll: PollWithOptions, + results: PollResults, + now: Date, +): Message { + const open = isPollOpen(poll, now); + const showCounts = poll.showResults === 'live' || !open; + const lines = results.options.map((option, index) => { + const heading = `**${index + 1}. ${option.label}**`; + + return showCounts + ? `${heading}\n${bar(option.votes, results.voters)} ${option.votes}` + : heading; + }); + const outcome = + !open && results.winners.length > 0 + ? [describeOutcome(results, 'Winner')] + : []; + const footer = [ + `Poll #${poll.id}`, + poll.multiple ? 'multiple choice' : 'single choice', + poll.anonymous ? 'anonymous' : 'votes visible to organizers', + `${results.voters} voter${results.voters === 1 ? '' : 's'}`, + statusLine(poll, open), + ].join(' · '); + + return { + content: [ + `# ${poll.question}`, + lines.join('\n\n'), + ...outcome, + `-# ${footer}`, + ].join('\n\n'), + controls: open + ? [ + [ + { + kind: 'select', + id: controlId('polls:vote', poll.id), + placeholder: poll.multiple ? 'Choose one or more' : 'Choose one', + min: 1, + max: poll.multiple ? poll.options.length : 1, + options: poll.options.map((option) => ({ + label: `${option.position + 1}. ${option.label}`, + value: String(option.id), + })), + }, + ], + [ + { + kind: 'button', + id: controlId('polls:clear', poll.id), + label: 'Clear my vote', + style: 'secondary', + }, + ], + ] + : [], + }; +} + +export function pollDetails( + input: Pick, +): Message[] { + if ( + !input.options.some( + (option) => option.url !== undefined && option.url !== null, + ) + ) { + return []; + } + + const heading = `## ${input.question} · options`; + const pages: string[] = []; + let page = heading; + + for (const [index, option] of input.options.entries()) { + const label = `${index + 1}. ${option.label}`; + const line = + option.url !== undefined && option.url !== null + ? `[${label}](<${option.url}>)` + : label; + + if (heading.length + line.length + 1 > maxContentLength) { + throw new UserError('An option link is too long to post on Discord.'); + } + + if (page.length + line.length + 1 > maxContentLength) { + pages.push(page); + page = heading; + } + + page += `\n${line}`; + } + + pages.push(page); + + return pages.map((content) => ({ content, suppressEmbeds: true })); +} diff --git a/src/features/polls/model.ts b/src/features/polls/model.ts new file mode 100644 index 0000000..fe25dd6 --- /dev/null +++ b/src/features/polls/model.ts @@ -0,0 +1,73 @@ +import type { Tally } from './rules'; + +export type PollStatus = 'open' | 'closed' | 'cancelled'; + +export interface Poll { + id: number; + guildId: string; + channelId: string; + messageId: string | null; + creatorId: string; + question: string; + multiple: boolean; + anonymous: boolean; + showResults: 'live' | 'closed'; + closesAt: Date | null; + status: PollStatus; + source: string | null; + createdAt: Date; +} + +export interface PollOption { + id: number; + pollId: number; + position: number; + label: string; + ref: string | null; + url: string | null; +} + +export interface PollWithOptions extends Poll { + options: PollOption[]; +} + +export type PollResults = Tally; + +export interface NewPoll + extends + Pick, + Partial< + Pick< + Poll, + 'multiple' | 'anonymous' | 'showResults' | 'closesAt' | 'source' + > + > { + options: ReadonlyArray<{ + label: string; + ref?: string | null; + url?: string | null; + }>; +} + +export interface PollRepository { + insert: (poll: NewPoll) => Promise; + find: (id: number) => Promise; + vote: ( + pollId: number, + userId: string, + optionIds: readonly number[], + ) => Promise; + results: (poll: PollWithOptions) => Promise; + choices: (pollId: number, userId: string) => Promise; + voters: (pollId: number) => Promise>; + finish: ( + id: number, + status: 'closed' | 'cancelled', + ) => Promise; + setMessage: (id: number, messageId: string) => Promise; + open: (guildId: string) => Promise; + latestBySource: ( + guildId: string, + source: string, + ) => Promise; +} diff --git a/src/features/polls/rules.ts b/src/features/polls/rules.ts new file mode 100644 index 0000000..576de54 --- /dev/null +++ b/src/features/polls/rules.ts @@ -0,0 +1,59 @@ +import { UserError } from '~/core/errors'; + +export const maxPollOptions = 10; + +export const maxOptionLength = 55; + +export interface Tally { + options: Array; + voters: number; + winners: Array; + tie: boolean; +} + +export function isPollOpen( + poll: { status: string; closesAt: Date | null }, + now = new Date(), +): boolean { + return ( + poll.status === 'open' && (poll.closesAt === null || poll.closesAt > now) + ); +} + +export function tally( + options: readonly O[], + votes: ReadonlyMap, + voters: number, +): Tally { + const counted = options.map((option) => ({ + ...option, + votes: votes.get(option.id) ?? 0, + })); + const top = Math.max(0, ...counted.map((option) => option.votes)); + const winners = + top === 0 ? [] : counted.filter((option) => option.votes === top); + + return { options: counted, voters, winners, tie: winners.length > 1 }; +} + +export function validatePollOptions(labels: readonly string[]): string[] { + const trimmed = labels.map((label) => label.trim()); + + if (trimmed.length < 2 || trimmed.length > maxPollOptions) { + throw new UserError( + `A poll needs between 2 and ${maxPollOptions} options.`, + ); + } + + if (trimmed.some((label) => label === '' || label.length > maxOptionLength)) { + throw new UserError(`Options must be 1-${maxOptionLength} characters.`); + } + + if ( + new Set(trimmed.map((label) => label.toLowerCase())).size !== trimmed.length + ) { + throw new UserError('Options must be distinct.'); + } + + return trimmed; +} diff --git a/src/features/polls/service.ts b/src/features/polls/service.ts new file mode 100644 index 0000000..0e03649 --- /dev/null +++ b/src/features/polls/service.ts @@ -0,0 +1,230 @@ +import { renderPoll, pollDetails } from './message'; +import { z } from 'zod'; +import { channelMention, type Message } from '~/core/message'; +import { parseFutureWhen } from '~/core/helpers/time'; +import { UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import { isPollOpen } from './rules'; +import type { Authorizer } from '~/core/ports/authorization'; +import type { Directory } from '~/core/ports/directory'; +import type { Logger } from '~/core/ports/logger'; +import type { Messenger } from '~/core/ports/messenger'; +import { type Scheduler } from '~/core/ports/scheduler'; +import { defineJob } from '~/core/helpers/jobs'; +import { sequential } from '~/core/helpers/async'; +import type { + NewPoll, + Poll, + PollResults, + PollWithOptions, + PollRepository, +} from './model'; + +const closeKey = (id: number) => `poll:${id}:close`; + +export interface PollRequest { + question: string; + options: readonly string[]; + channelId: string; + multiple?: boolean; + anonymous?: boolean; + showResults?: 'live' | 'closed'; + closes?: string; +} + +interface Deps { + polls: PollRepository; + scheduler: Scheduler; + messenger: Messenger; + directory: Directory; + authz: Authorizer; + log: Logger; + timezone: string; +} + +export function createPollService(deps: Deps) { + const { polls, scheduler, messenger, directory, authz, log } = deps; + + const refresh = async (id: number) => { + const poll = await polls.find(id); + + if (poll?.messageId === undefined || poll.messageId === null) { + return; + } + + if ( + !(await messenger.edit( + poll.channelId, + poll.messageId, + pollView(poll, await polls.results(poll)), + )) + ) { + log.warn({ pollId: id }, 'Poll message or channel was deleted'); + } + }; + + const closeJob = defineJob({ + type: 'polls.close', + payload: z.object({ pollId: z.number().int() }), + handle: async ({ pollId }) => { + if (await polls.finish(pollId, 'closed')) { + await refresh(pollId); + } + }, + }); + + const publish = async (actor: Actor, input: NewPoll) => { + if (!(await directory.canPost(actor, input.channelId))) { + throw new UserError( + `You cannot post in ${channelMention(input.channelId)} yourself.`, + ); + } + + if (input.question.trim() === '' || input.question.length > 256) { + throw new UserError('Poll questions must be 1-256 characters.'); + } + + const details = pollDetails(input); + const poll = await polls.insert(input); + + await sequential(details, (message) => + messenger.send(poll.channelId, message), + ); + + const sent = await messenger.send( + poll.channelId, + pollView(poll, await polls.results(poll)), + ); + + await polls.setMessage(poll.id, sent.messageId); + + if (poll.closesAt !== null) { + await scheduler.schedule( + closeJob, + { pollId: poll.id }, + { runAt: poll.closesAt, key: closeKey(poll.id) }, + ); + } + + return { ...poll, messageId: sent.messageId }; + }; + + const requirePoll = async (actor: Actor, id: number) => { + const poll = await polls.find(id); + + if ( + poll?.guildId !== actor.guildId || + !(await directory.canView(actor, poll.channelId)) + ) { + throw new UserError(`Poll #${id} does not exist.`); + } + + return poll; + }; + + const isManager = async (actor: Actor, poll: Poll) => + poll.creatorId === actor.userId || (await authz.can(actor, 'poll:manage')); + + const requireManager = async (actor: Actor, id: number) => { + const poll = await requirePoll(actor, id); + + if (poll.creatorId !== actor.userId) { + await authz.require(actor, 'poll:manage'); + } + + return poll; + }; + + const vote = async ( + actor: Actor, + id: number, + optionIds: readonly number[], + ) => { + await requirePoll(actor, id); + await polls.vote(id, actor.userId, optionIds); + + const poll = await requirePoll(actor, id); + const chosen = poll.options + .filter((o) => optionIds.includes(o.id)) + .map((o) => o.label); + + return { view: pollView(poll, await polls.results(poll)), chosen }; + }; + + return { + jobs: [closeJob], + publish, + results: (poll: PollWithOptions) => polls.results(poll), + latestBySource: (guildId: string, source: string) => + polls.latestBySource(guildId, source), + open: (guildId: string) => polls.open(guildId), + create: async (actor: Actor, request: PollRequest) => { + await authz.require(actor, 'poll:create'); + + return publish(actor, { + guildId: actor.guildId, + channelId: request.channelId, + creatorId: actor.userId, + question: request.question, + options: request.options.map((label) => ({ label })), + multiple: request.multiple ?? false, + anonymous: request.anonymous ?? false, + showResults: request.showResults ?? 'live', + closesAt: + request.closes === undefined + ? null + : parseFutureWhen(request.closes, deps.timezone), + }); + }, + vote, + clear: async (actor: Actor, id: number) => { + const current = await polls.choices(id, actor.userId); + + if (current.length === 0) { + throw new UserError('You have not voted.'); + } + + return vote(actor, id, []); + }, + summary: async (actor: Actor, id: number) => { + const poll = await requirePoll(actor, id); + const manager = await isManager(actor, poll); + + if (poll.showResults === 'closed' && isPollOpen(poll) && !manager) { + throw new UserError('Results are shown when the poll closes.'); + } + + const results = await polls.results(poll); + const voters = + !poll.anonymous && manager ? await polls.voters(poll.id) : undefined; + + return { poll, results, voters }; + }, + close: async (actor: Actor, id: number) => { + await requireManager(actor, id); + + if (!(await polls.finish(id, 'closed'))) { + throw new UserError('That poll is not open.'); + } + + await scheduler.cancel(closeJob, closeKey(id)); + await refresh(id); + }, + cancel: async (actor: Actor, id: number) => { + await requireManager(actor, id); + + if (!(await polls.finish(id, 'cancelled'))) { + throw new UserError('That poll is not open.'); + } + + await scheduler.cancel(closeJob, closeKey(id)); + await refresh(id); + }, + }; +} + +export type PollService = ReturnType; + +export function pollView(poll: PollWithOptions, results: PollResults): Message { + return renderPoll(poll, results, new Date()); +} diff --git a/src/features/reminders/model.ts b/src/features/reminders/model.ts new file mode 100644 index 0000000..f62ebb1 --- /dev/null +++ b/src/features/reminders/model.ts @@ -0,0 +1,28 @@ +import type { Recurrence } from '~/core/helpers/time'; + +export type ReminderStatus = 'active' | 'done' | 'cancelled' | 'failed'; + +export interface Reminder { + id: number; + guildId: string; + userId: string; + channelId: string | null; + message: string; + runAt: Date; + recurrence: Recurrence | null; + timezone: string; + status: ReminderStatus; +} + +export type NewReminder = Omit; + +export type ReminderChanges = Partial< + Pick & { failure: string } +>; + +export interface ReminderRepository { + insert: (reminder: NewReminder) => Promise; + find: (id: number) => Promise; + active: (guildId: string, userId: string) => Promise; + update: (id: number, changes: ReminderChanges) => Promise; +} diff --git a/src/features/reminders/service.ts b/src/features/reminders/service.ts new file mode 100644 index 0000000..b83bdc5 --- /dev/null +++ b/src/features/reminders/service.ts @@ -0,0 +1,188 @@ +import { z } from 'zod'; +import { channelMention, userMention } from '~/core/message'; +import { + nextFutureOccurrence, + parseFutureWhen, + recurrences, + type Recurrence, +} from '~/core/helpers/time'; +import { PermanentError, UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import type { Authorizer } from '~/core/ports/authorization'; +import type { Directory } from '~/core/ports/directory'; +import type { Messenger } from '~/core/ports/messenger'; +import { type Scheduler } from '~/core/ports/scheduler'; +import { defineJob } from '~/core/helpers/jobs'; +import type { NewReminder, Reminder, ReminderRepository } from './model'; + +const jobKey = (id: number) => `reminder:${id}`; + +export interface ReminderRequest { + when?: string; + message: string; + channelId?: string; + repeat?: string; +} + +interface Deps { + reminders: ReminderRepository; + scheduler: Scheduler; + messenger: Messenger; + directory: Directory; + authz: Authorizer; + timezone: string; +} + +export function createReminderService(deps: Deps) { + const { reminders, scheduler, messenger, directory, authz, timezone } = deps; + + const deliver = async (reminder: Reminder) => { + const text = `⏰ **Reminder:** ${reminder.message}`; + + if (reminder.channelId === null) { + await messenger.direct(reminder.userId, { content: text }); + + return; + } + + await messenger.send(reminder.channelId, { + content: `${userMention(reminder.userId)} ${text}`, + mentions: { users: [reminder.userId] }, + }); + }; + + const deliverJob = defineJob({ + type: 'reminders.deliver', + payload: z.object({ reminderId: z.number().int() }), + handle: async ({ reminderId }) => { + const reminder = await reminders.find(reminderId); + + if (reminder?.status !== 'active') { + return null; + } + + try { + await deliver(reminder); + } catch (error) { + if (error instanceof PermanentError) { + await reminders.update(reminder.id, { + status: 'failed', + failure: error.message, + }); + } + + throw error; + } + + if (reminder.recurrence === null) { + await reminders.update(reminder.id, { status: 'done' }); + + return null; + } + + const next = nextFutureOccurrence( + reminder.runAt, + reminder.recurrence, + reminder.timezone, + ); + + await reminders.update(reminder.id, { runAt: next }); + + return { rescheduleAt: next }; + }, + }); + + const queue = (reminder: Reminder) => + scheduler.schedule( + deliverJob, + { reminderId: reminder.id }, + { runAt: reminder.runAt, key: jobKey(reminder.id) }, + ); + + const schedule = async (input: NewReminder) => { + const reminder = await reminders.insert(input); + + await queue(reminder); + + return reminder; + }; + + const own = async (actor: Actor, id: number) => { + const reminder = await reminders.find(id); + + if ( + reminder?.guildId !== actor.guildId || + reminder.userId !== actor.userId || + reminder.status !== 'active' + ) { + throw new UserError(`You have no active reminder #${id}.`); + } + + return reminder; + }; + + return { + jobs: [deliverJob], + schedule, + create: async (actor: Actor, request: ReminderRequest) => { + if (request.channelId !== undefined) { + await authz.require(actor, 'reminder:channel'); + + if (!(await directory.canPost(actor, request.channelId))) { + throw new UserError( + `You cannot post in ${channelMention(request.channelId)} yourself.`, + ); + } + } + + const recurrence: Recurrence | null = + recurrences.find((r) => r === request.repeat) ?? null; + + return schedule({ + guildId: actor.guildId, + userId: actor.userId, + channelId: request.channelId ?? null, + message: request.message, + runAt: parseFutureWhen(request.when ?? '1d', timezone), + recurrence, + timezone, + }); + }, + list: (actor: Actor) => reminders.active(actor.guildId, actor.userId), + edit: async ( + actor: Actor, + id: number, + changes: { when?: string; message?: string }, + ) => { + const reminder = await own(actor, id); + + if (changes.when === undefined && changes.message === undefined) { + throw new UserError('Give a new time or message.'); + } + + const updated = { + ...reminder, + message: changes.message ?? reminder.message, + runAt: + changes.when === undefined + ? reminder.runAt + : parseFutureWhen(changes.when, reminder.timezone), + }; + + await reminders.update(id, { + message: updated.message, + runAt: updated.runAt, + }); + await queue(updated); + + return updated; + }, + cancel: async (actor: Actor, id: number) => { + await own(actor, id); + await reminders.update(id, { status: 'cancelled' }); + await scheduler.cancel(deliverJob, jobKey(id)); + }, + }; +} + +export type ReminderService = ReturnType; diff --git a/src/features/roles/model.ts b/src/features/roles/model.ts new file mode 100644 index 0000000..a339620 --- /dev/null +++ b/src/features/roles/model.ts @@ -0,0 +1,40 @@ +export type PanelKind = 'reaction' | 'select'; + +export interface PanelRole { + roleId: string; + label: string; + emoji: string | null; +} + +export interface NewPanel { + guildId: string; + channelId: string; + kind: PanelKind; + title: string; + createdBy: string; +} + +export interface ReactionKey { + guildId: string; + channelId: string; + messageId: string; + emoji: string; +} + +export interface RolePanel extends NewPanel { + id: number; + messageId: string | null; + roles: PanelRole[]; +} + +export interface RolePanelRepository { + list: (guildId: string) => Promise; + reactionRole: (key: ReactionKey) => Promise; + create: (panel: NewPanel) => Promise; + reactionPanel: ( + guildId: string, + channelId: string, + ) => Promise<{ id: number; messageId: string | null } | undefined>; + setMessage: (id: number, messageId: string | null) => Promise; + replaceRoles: (id: number, roles: readonly PanelRole[]) => Promise; +} diff --git a/src/features/roles/service.ts b/src/features/roles/service.ts new file mode 100644 index 0000000..83721b2 --- /dev/null +++ b/src/features/roles/service.ts @@ -0,0 +1,337 @@ +import { selfAssignProblem } from '~/core/helpers/roles'; +import { UserError } from '~/core/errors'; +import type { Actor } from '~/core/actor'; +import type { Directory } from '~/core/ports/directory'; +import type { Logger } from '~/core/ports/logger'; +import type { Messenger } from '~/core/ports/messenger'; +import type { RolePanelRepository, PanelRole, RolePanel } from './model'; +import { sequential } from '~/core/helpers/async'; + +export const legacyMessage = + 'Valige endale rolli:\n1 - Tarkvara\n2 - Helpdesk\n3 - Kultuur'; + +export interface LegacyPanel { + channelId: string; + roles: ReadonlyArray<{ emoji: string; roleId: string; label: string }>; +} + +export interface Reaction { + guildId: string; + channelId: string; + messageId: string; + emoji: string; + userId: string; +} + +interface Deps { + panels: RolePanelRepository; + directory: Directory; + messenger: Messenger; + log: Logger; + legacy?: LegacyPanel; +} +interface Choice { + roleId: string; + emoji: string; +} + +function panelContent(entries: readonly PanelRole[]) { + return [ + 'Valige endale rolli:', + ...entries.map((entry) => `${entry.emoji ?? ''} - ${entry.label}`), + '', + 'React to get a role. Remove your reaction to leave it.', + ].join('\n'); +} + +export function createRoleService(deps: Deps) { + const { panels, directory, messenger, log, legacy } = deps; + + const postLegacy = async (channelId: string, content = legacyMessage) => { + log.info({ channelId }, 'Posting role selection message'); + + const sent = await messenger.send(channelId, { content }); + + return sent.messageId; + }; + + const storedRoles = async (guildId: string, panelId: number) => { + const saved = await panels.list(guildId); + + return saved.find((stored) => stored.id === panelId)?.roles ?? []; + }; + + const syncLegacyPanel = async () => { + if (!legacy) { + return; + } + + const guildId = await directory.guildOf(legacy.channelId); + + if (guildId === undefined) { + log.error( + { channelId: legacy.channelId }, + 'ROLE_SELECTION_CHANNEL_ID is not a server text channel', + ); + + return; + } + + const roles = await Promise.all( + legacy.roles.map(async (entry) => ({ + entry, + role: await directory.role(guildId, entry.roleId), + })), + ); + + for (const { entry, role } of roles) { + const problem = role ? selfAssignProblem(role) : 'does not exist'; + + if (problem !== undefined) { + log.error({ ...entry, problem }, 'Legacy panel role is not assignable'); + } + } + + const existing = await panels.reactionPanel(guildId, legacy.channelId); + const panel = existing ?? { + id: await panels.create({ + guildId, + channelId: legacy.channelId, + kind: 'reaction', + title: 'Role selection', + createdBy: 'bot', + }), + messageId: null, + }; + + if (!existing) { + await panels.replaceRoles(panel.id, legacy.roles); + } + + const entries = existing + ? await storedRoles(guildId, panel.id) + : legacy.roles; + const content = existing ? panelContent(entries) : legacyMessage; + + const stored = + panel.messageId !== null && + (await messenger.exists(legacy.channelId, panel.messageId)) + ? panel.messageId + : undefined; + const located = + stored ?? (await messenger.findOwn(legacy.channelId, content)); + const messageId = located ?? (await postLegacy(legacy.channelId, content)); + + if (messageId !== panel.messageId) { + await panels.setMessage(panel.id, messageId); + } + + const present = new Set( + await messenger.ownReactions(legacy.channelId, messageId), + ); + const missing = entries.filter( + ({ emoji }) => emoji !== null && !present.has(emoji), + ); + + await sequential(missing, ({ emoji }) => + messenger.react(legacy.channelId, messageId, emoji ?? ''), + ); + }; + + const reacted = async (reaction: Reaction, added: boolean) => { + const roleId = await panels.reactionRole(reaction); + + if (roleId === undefined) { + return; + } + + const role = await directory.role(reaction.guildId, roleId); + const problem = role ? selfAssignProblem(role) : 'does not exist'; + + if (problem !== undefined) { + log.warn({ roleId, problem }, 'Skipping reaction role change'); + + return; + } + + const member = { guildId: reaction.guildId, userId: reaction.userId }; + + await (added + ? directory.addRoles(member, [roleId], 'Role selection reaction') + : directory.removeRoles( + member, + [roleId], + 'Role selection reaction removed', + )); + log.info( + { ...member, roleId, added }, + added ? 'Assigned role' : 'Removed role', + ); + }; + + const requireAdmin = (actor: Actor) => { + if (!actor.administrator) { + throw new UserError( + 'Only server administrators can manage role selection.', + ); + } + }; + + const list = async (actor: Actor) => { + requireAdmin(actor); + + return panels.list(actor.guildId); + }; + + const validateChoices = async ( + guildId: string, + choices: readonly Choice[], + ) => { + if ( + choices.length > 20 || + new Set(choices.map((c) => c.emoji)).size !== choices.length || + new Set(choices.map((c) => c.roleId)).size !== choices.length + ) { + throw new UserError( + 'Use at most 20 choices, each with a different role and emoji.', + ); + } + + return Promise.all( + choices.map(async (choice): Promise => { + const segments = [ + ...new Intl.Segmenter(undefined, { granularity: 'grapheme' }).segment( + choice.emoji, + ), + ]; + + if ( + segments.length !== 1 || + !/[\p{Extended_Pictographic}\p{Regional_Indicator}\u20e3]/u.test( + choice.emoji, + ) + ) { + throw new UserError( + 'Use one standard emoji for each role, such as 🎉 or 1️⃣.', + ); + } + + const role = await directory.role(guildId, choice.roleId); + const problem = role ? selfAssignProblem(role) : 'does not exist'; + + if (!role || problem !== undefined) { + throw new UserError(`That role ${problem ?? 'is unavailable'}.`); + } + + return { ...choice, label: role.name }; + }), + ); + }; + + const publishPanel = async ( + actor: Actor, + channelId: string, + entries: PanelRole[], + existing: RolePanel | undefined, + ) => { + for (const entry of entries) { + if ( + existing?.roles.some( + (old) => old.emoji === entry.emoji && old.roleId !== entry.roleId, + ) === true + ) { + throw new UserError( + 'Use a new emoji when changing the role assigned to a reaction.', + ); + } + } + + const content = panelContent(entries); + + if (content.length > 2000) { + throw new UserError('The panel is too long. Choose fewer roles.'); + } + + const id = + existing?.id ?? + (await panels.create({ + guildId: actor.guildId, + channelId, + kind: 'reaction', + title: 'Role selection', + createdBy: actor.userId, + })); + let messageId = existing?.messageId ?? null; + + if (messageId !== null) { + await messenger.clearReactionsExcept( + channelId, + messageId, + entries.map((entry) => entry.emoji ?? ''), + ); + } + + if ( + messageId === null || + !(await messenger.edit(channelId, messageId, { content })) + ) { + const sent = await messenger.send(channelId, { content }); + + messageId = sent.messageId; + await panels.setMessage(id, messageId); + } + + await panels.replaceRoles(id, entries); + const present = new Set(await messenger.ownReactions(channelId, messageId)); + const missing = entries.filter( + (entry) => entry.emoji !== null && !present.has(entry.emoji), + ); + const target = messageId; + + await sequential(missing, (entry) => + messenger.react(channelId, target, entry.emoji ?? ''), + ); + }; + + const saving = new Set(); + const save = async ( + actor: Actor, + channelId: string, + choices: readonly Choice[], + ) => { + requireAdmin(actor); + if ( + (await directory.guildOf(channelId)) !== actor.guildId || + !(await directory.canView(actor, channelId)) || + !(await directory.canPost(actor, channelId)) + ) { + throw new UserError( + 'Choose a server channel where you and the bot can post.', + ); + } + + const entries = await validateChoices(actor.guildId, choices); + + if (saving.has(channelId)) { + throw new UserError('This panel is being saved. Please try again.'); + } + + saving.add(channelId); + try { + const stored = await panels.list(actor.guildId); + const existing = stored.find((p) => p.channelId === channelId); + + await publishPanel(actor, channelId, entries, existing); + log.info( + { guildId: actor.guildId, channelId, actorId: actor.userId }, + 'Role selection saved', + ); + } finally { + saving.delete(channelId); + } + }; + + return { syncLegacyPanel, reacted, list, save }; +} + +export type RoleService = ReturnType; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..52c7b57 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,51 @@ +import { startApp } from './app'; +import { loadConfig } from '~/config/env'; +import { createLogger } from '~/integrations/logging/logger'; +import { createLogStore } from '~/integrations/logging/store'; + +let config: ReturnType; + +try { + config = loadConfig(); +} catch (error) { + console.error(error instanceof Error ? error.message : error); + process.exit(1); +} + +const logs = createLogStore(config.LOG_DATABASE_PATH); +const log = createLogger(config.LOG_LEVEL, logs); + +process.on('unhandledRejection', (reason) => { + log.error({ reason }, 'Unhandled promise rejection'); +}); + +try { + const stop = await startApp(config, log, logs); + let stopping = false; + const shutdown = (signal: NodeJS.Signals) => { + if (stopping) { + return; + } + + stopping = true; + log.info({ signal }, 'Shutting down'); + stop().then( + () => { + logs.close(); + process.exit(0); + }, + (error: unknown) => { + log.error({ error }, 'Shutdown failed'); + logs.close(); + process.exit(1); + }, + ); + }; + + process.once('SIGINT', shutdown); + process.once('SIGTERM', shutdown); +} catch (error) { + log.fatal({ error }, 'Startup failed'); + logs.close(); + process.exitCode = 1; +} diff --git a/src/infrastructure.ts b/src/infrastructure.ts new file mode 100644 index 0000000..400b5ac --- /dev/null +++ b/src/infrastructure.ts @@ -0,0 +1,31 @@ +import type { EventSuggestionRepository } from '~/features/event-suggestions/model'; +import type { Job, Scheduler } from '~/core/ports/scheduler'; +import type { Logger } from '~/core/ports/logger'; +import type { AnnouncementRepository } from '~/features/announcements/model'; +import type { EventRepository } from '~/features/events/model'; +import type { BirthdayRepository } from '~/features/birthdays/model'; +import type { GrantRepository } from '~/features/permissions/model'; +import type { MovieRepository } from '~/features/movies/model'; +import type { PollRepository } from '~/features/polls/model'; +import type { ReminderRepository } from '~/features/reminders/model'; +import type { RolePanelRepository } from '~/features/roles/model'; + +export interface AppInfrastructure { + repositories: { + announcements: AnnouncementRepository; + events: EventRepository; + eventSuggestions: EventSuggestionRepository; + birthdays: BirthdayRepository; + grants: GrantRepository; + movies: MovieRepository; + polls: PollRepository; + reminders: ReminderRepository; + roles: RolePanelRepository; + }; + scheduler: Scheduler; + migrate: () => Promise; + start: () => Promise; + startJobs: (jobs: Iterable>, log: Logger) => Promise; + stop: () => Promise; + close: () => Promise; +} diff --git a/src/integrations/db/announcements/repository.ts b/src/integrations/db/announcements/repository.ts new file mode 100644 index 0000000..2f0b6c9 --- /dev/null +++ b/src/integrations/db/announcements/repository.ts @@ -0,0 +1,42 @@ +import { and, desc, eq, inArray } from 'drizzle-orm'; +import type { AnnouncementRepository } from '~/features/announcements/model'; +import type { Db } from '../client'; +import { posts } from './table'; + +export function createAnnouncementRepository(db: Db): AnnouncementRepository { + return { + insert: async (input) => { + const [row] = await db.insert(posts).values(input).returning(); + + if (!row) { + throw new Error('Insert returned no row'); + } + + return row; + }, + find: async (id) => { + const [row] = await db.select().from(posts).where(eq(posts.id, id)); + + return row; + }, + list: async (guildId, limit = 50) => { + return await db + .select() + .from(posts) + .where(eq(posts.guildId, guildId)) + .orderBy(desc(posts.id)) + .limit(limit); + }, + update: async (id, changes, onlyIf) => { + const [row] = await db + .update(posts) + .set(changes) + .where( + and(eq(posts.id, id), onlyIf && inArray(posts.status, [...onlyIf])), + ) + .returning(); + + return row; + }, + }; +} diff --git a/src/integrations/db/announcements/table.ts b/src/integrations/db/announcements/table.ts new file mode 100644 index 0000000..bbe67b9 --- /dev/null +++ b/src/integrations/db/announcements/table.ts @@ -0,0 +1,39 @@ +import { + index, + pgEnum, + pgTable, + serial, + text, + timestamp, +} from 'drizzle-orm/pg-core'; + +export const postStatus = pgEnum('announcement_status', [ + 'draft', + 'scheduled', + 'published', + 'cancelled', +]); + +export const posts = pgTable( + 'announcements', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + authorId: text('author_id').notNull(), + channelId: text('channel_id').notNull(), + title: text('title'), + content: text('content').notNull(), + mentionRoleIds: text('mention_role_ids').array().notNull().default([]), + status: postStatus('status').notNull().default('draft'), + scheduledAt: timestamp('scheduled_at', { withTimezone: true }), + publishedAt: timestamp('published_at', { withTimezone: true }), + messageIds: text('message_ids').array().notNull().default([]), + failure: text('failure'), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [index('announcements_guild_idx').on(table.guildId, table.status)], +); + +export type AnnouncementRow = typeof posts.$inferSelect; diff --git a/src/integrations/db/birthdays/repository.ts b/src/integrations/db/birthdays/repository.ts new file mode 100644 index 0000000..eacd367 --- /dev/null +++ b/src/integrations/db/birthdays/repository.ts @@ -0,0 +1,126 @@ +import { and, eq, inArray, isNull, lt, ne, or } from 'drizzle-orm'; +import type { BirthdayRepository } from '~/features/birthdays/model'; +import type { Db } from '../client'; +import { celebratedOn, validateBirthday } from '~/features/birthdays/rules'; +import { birthdays, birthdaySettings } from './table'; + +export function createBirthdayRepository(db: Db): BirthdayRepository { + return { + set: async (input) => { + validateBirthday(input.month, input.day); + await db + .insert(birthdays) + .values(input) + .onConflictDoUpdate({ + target: [birthdays.guildId, birthdays.userId], + set: { + month: input.month, + day: input.day, + visibility: input.visibility, + }, + }); + }, + remove: async (guildId, userId) => { + const rows = await db + .delete(birthdays) + .where( + and(eq(birthdays.guildId, guildId), eq(birthdays.userId, userId)), + ) + .returning({ userId: birthdays.userId }); + + return rows.length > 0; + }, + find: async (guildId, userId) => { + const [row] = await db + .select() + .from(birthdays) + .where( + and(eq(birthdays.guildId, guildId), eq(birthdays.userId, userId)), + ); + + return row; + }, + upcoming: async (guildId, today, limit = 10) => { + const rows = await db + .select() + .from(birthdays) + .where( + and( + eq(birthdays.guildId, guildId), + eq(birthdays.visibility, 'public'), + ), + ) + .limit(2000); + const key = (b: { month: number; day: number }) => b.month * 100 + b.day; + const start = key(today); + + return rows + .toSorted((a, b) => { + const ka = (key(a) - start + 1300) % 1300; + const kb = (key(b) - start + 1300) % 1300; + + return ka - kb; + }) + .slice(0, limit); + }, + claim: async (guildId, today) => { + const dates = celebratedOn(today); + const rows = await db + .update(birthdays) + .set({ lastAnnouncedYear: today.year }) + .where( + and( + eq(birthdays.guildId, guildId), + ne(birthdays.visibility, 'private'), + or( + ...dates.map((d) => + and(eq(birthdays.month, d.month), eq(birthdays.day, d.day)), + ), + ), + or( + isNull(birthdays.lastAnnouncedYear), + lt(birthdays.lastAnnouncedYear, today.year), + ), + ), + ) + .returning({ userId: birthdays.userId }); + + return rows.map((row) => row.userId); + }, + release: async (guildId, userIds, year) => { + if (userIds.length === 0) { + return; + } + + await db + .update(birthdays) + .set({ lastAnnouncedYear: year - 1 }) + .where( + and( + eq(birthdays.guildId, guildId), + inArray(birthdays.userId, userIds), + eq(birthdays.lastAnnouncedYear, year), + ), + ); + }, + settings: async (guildId) => { + const [row] = await db + .select() + .from(birthdaySettings) + .where(eq(birthdaySettings.guildId, guildId)); + + return row; + }, + saveSettings: async (settings) => { + await db.insert(birthdaySettings).values(settings).onConflictDoUpdate({ + target: birthdaySettings.guildId, + set: settings, + }); + }, + deleteSettings: async (guildId) => { + await db + .delete(birthdaySettings) + .where(eq(birthdaySettings.guildId, guildId)); + }, + }; +} diff --git a/src/integrations/db/birthdays/table.ts b/src/integrations/db/birthdays/table.ts new file mode 100644 index 0000000..2a1d6c4 --- /dev/null +++ b/src/integrations/db/birthdays/table.ts @@ -0,0 +1,40 @@ +import { + index, + integer, + pgEnum, + pgTable, + primaryKey, + smallint, + text, +} from 'drizzle-orm/pg-core'; + +export const birthdayVisibility = pgEnum('birthday_visibility', [ + 'public', + 'announce', + 'private', +]); + +export const birthdays = pgTable( + 'birthdays', + { + guildId: text('guild_id').notNull(), + userId: text('user_id').notNull(), + month: smallint('month').notNull(), + day: smallint('day').notNull(), + visibility: birthdayVisibility('visibility').notNull().default('public'), + lastAnnouncedYear: integer('last_announced_year'), + }, + (table) => [ + primaryKey({ columns: [table.guildId, table.userId] }), + index('birthdays_date_idx').on(table.guildId, table.month, table.day), + ], +); + +export const birthdaySettings = pgTable('birthday_settings', { + guildId: text('guild_id').primaryKey(), + channelId: text('channel_id').notNull(), + hour: smallint('hour').notNull().default(9), +}); + +export type Birthday = typeof birthdays.$inferSelect; +export type BirthdayVisibility = Birthday['visibility']; diff --git a/src/integrations/db/client.ts b/src/integrations/db/client.ts new file mode 100644 index 0000000..956a679 --- /dev/null +++ b/src/integrations/db/client.ts @@ -0,0 +1,29 @@ +import { resolve } from 'node:path'; +import { drizzle, type PostgresJsDatabase } from 'drizzle-orm/postgres-js'; +import { migrate } from 'drizzle-orm/postgres-js/migrator'; +import postgres from 'postgres'; +import { ignore } from '~/core/errors'; + +export type Db = PostgresJsDatabase; + +export type Tx = Parameters[0]>[0]; + +export interface Database { + db: Db; + close: () => Promise; +} + +const migrationsFolder = resolve('drizzle'); + +export function connectDatabase(url: string): Database { + const sql = postgres(url, { max: 10, onnotice: ignore }); + + return { + db: drizzle(sql), + close: () => sql.end({ timeout: 5 }), + }; +} + +export async function runMigrations(db: Db): Promise { + await migrate(db, { migrationsFolder }); +} diff --git a/src/integrations/db/event-suggestions/repository.ts b/src/integrations/db/event-suggestions/repository.ts new file mode 100644 index 0000000..176ae08 --- /dev/null +++ b/src/integrations/db/event-suggestions/repository.ts @@ -0,0 +1,46 @@ +import { and, desc, eq } from 'drizzle-orm'; +import type { Db } from '../client'; +import type { EventSuggestionRepository } from '~/features/event-suggestions/model'; +import { UserError } from '~/core/errors'; +import { eventSuggestions } from './table'; +export function createEventSuggestionRepository( + db: Db, +): EventSuggestionRepository { + return { + insert: async (input) => { + const [row] = await db.insert(eventSuggestions).values(input).returning(); + + if (!row) { + throw new Error('Insert returned no suggestion'); + } + + return row; + }, + list: async (guildId, offset, limit) => + db + .select() + .from(eventSuggestions) + .where(eq(eventSuggestions.guildId, guildId)) + .orderBy(desc(eventSuggestions.id)) + .offset(offset) + .limit(limit), + update: async (guildId, id, changes) => { + const [row] = await db + .update(eventSuggestions) + .set(changes) + .where( + and( + eq(eventSuggestions.guildId, guildId), + eq(eventSuggestions.id, id), + ), + ) + .returning(); + + if (!row) { + throw new UserError('Suggestion not found.'); + } + + return row; + }, + }; +} diff --git a/src/integrations/db/event-suggestions/table.ts b/src/integrations/db/event-suggestions/table.ts new file mode 100644 index 0000000..46ad996 --- /dev/null +++ b/src/integrations/db/event-suggestions/table.ts @@ -0,0 +1,32 @@ +import { sql } from 'drizzle-orm'; +import { + check, + index, + pgTable, + serial, + text, + timestamp, +} from 'drizzle-orm/pg-core'; +import type { SuggestionStatus } from '~/features/event-suggestions/model'; +export const eventSuggestions = pgTable( + 'event_suggestions', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + authorId: text('author_id').notNull(), + text: text('text').notNull(), + channelId: text('channel_id').notNull(), + messageId: text('message_id'), + status: text('status').$type().notNull().default('new'), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + index('event_suggestions_guild_id_id').on(table.guildId, table.id), + check( + 'event_suggestions_status', + sql`${table.status} IN ('new', 'reviewed', 'dismissed')`, + ), + ], +); diff --git a/src/integrations/db/events/repository.ts b/src/integrations/db/events/repository.ts new file mode 100644 index 0000000..0eedd10 --- /dev/null +++ b/src/integrations/db/events/repository.ts @@ -0,0 +1,135 @@ +import { and, asc, count, eq, gte, lt, ne } from 'drizzle-orm'; +import type { EventRepository, RsvpCounts } from '~/features/events/model'; +import type { Db } from '../client'; +import { UserError } from '~/core/errors'; +import { eventRsvps, events } from './table'; + +export function createEventRepository(db: Db): EventRepository { + return { + insert: async (input) => { + if (input.endsAt && input.endsAt <= input.startsAt) { + throw new UserError('The end must be after the start.'); + } + + const [row] = await db.insert(events).values(input).returning(); + + if (!row) { + throw new Error('Insert returned no row'); + } + + return row; + }, + find: async (id) => { + const [row] = await db.select().from(events).where(eq(events.id, id)); + + return row; + }, + upcoming: async (guildId, limit = 25) => { + return await db + .select() + .from(events) + .where( + and( + eq(events.guildId, guildId), + eq(events.status, 'scheduled'), + gte(events.startsAt, new Date()), + ), + ) + .orderBy(asc(events.startsAt)) + .limit(limit); + }, + between: async (guildId, from, to) => { + return await db + .select() + .from(events) + .where( + and( + eq(events.guildId, guildId), + eq(events.status, 'scheduled'), + gte(events.startsAt, from), + lt(events.startsAt, to), + ), + ) + .orderBy(asc(events.startsAt)); + }, + update: async (id, changes) => { + const [row] = await db + .update(events) + .set(changes) + .where(eq(events.id, id)) + .returning(); + + if (!row) { + throw new UserError(`Event #${id} does not exist.`); + } + + return row; + }, + setRsvp: async (eventId, userId, status) => { + await db.transaction(async (tx) => { + const [event] = await tx + .select({ + status: events.status, + capacity: events.capacity, + startsAt: events.startsAt, + }) + .from(events) + .where(eq(events.id, eventId)) + .for('update'); + + if (event?.status !== 'scheduled') { + throw new UserError('This event is no longer open for RSVPs.'); + } + + if (status === 'going' && event.capacity !== null) { + const [others] = await tx + .select({ total: count() }) + .from(eventRsvps) + .where( + and( + eq(eventRsvps.eventId, eventId), + eq(eventRsvps.status, 'going'), + ne(eventRsvps.userId, userId), + ), + ); + + if ((others?.total ?? 0) >= event.capacity) { + throw new UserError( + 'This event is full. You can still answer "Maybe".', + ); + } + } + + await tx + .insert(eventRsvps) + .values({ eventId, userId, status }) + .onConflictDoUpdate({ + target: [eventRsvps.eventId, eventRsvps.userId], + set: { status, updatedAt: new Date() }, + }); + }); + }, + counts: async (eventId) => { + const rows = await db + .select({ status: eventRsvps.status, total: count() }) + .from(eventRsvps) + .where(eq(eventRsvps.eventId, eventId)) + .groupBy(eventRsvps.status); + const counts: RsvpCounts = { going: 0, maybe: 0, not_going: 0 }; + + for (const row of rows) { + counts[row.status] = row.total; + } + + return counts; + }, + attendees: async (eventId) => { + return await db + .select({ userId: eventRsvps.userId, status: eventRsvps.status }) + .from(eventRsvps) + .where(eq(eventRsvps.eventId, eventId)) + .orderBy(asc(eventRsvps.updatedAt)) + .limit(1000); + }, + }; +} diff --git a/src/integrations/db/events/table.ts b/src/integrations/db/events/table.ts new file mode 100644 index 0000000..42766c4 --- /dev/null +++ b/src/integrations/db/events/table.ts @@ -0,0 +1,68 @@ +import { + boolean, + index, + integer, + pgEnum, + pgTable, + primaryKey, + serial, + text, + timestamp, +} from 'drizzle-orm/pg-core'; + +export const eventStatus = pgEnum('event_status', ['scheduled', 'cancelled']); +export const rsvpStatus = pgEnum('rsvp_status', [ + 'going', + 'maybe', + 'not_going', +]); + +export const events = pgTable( + 'events', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + title: text('title').notNull(), + description: text('description'), + startsAt: timestamp('starts_at', { withTimezone: true }).notNull(), + endsAt: timestamp('ends_at', { withTimezone: true }), + timezone: text('timezone').notNull(), + location: text('location'), + organizerId: text('organizer_id').notNull(), + channelId: text('channel_id').notNull(), + messageId: text('message_id'), + capacity: integer('capacity'), + mentionRoleId: text('mention_role_id'), + reminderMinutes: integer('reminder_minutes').array().notNull().default([]), + icons: boolean('icons').notNull().default(true), + calendarEventId: text('calendar_event_id'), + status: eventStatus('status').notNull().default('scheduled'), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + index('events_guild_start_idx').on(table.guildId, table.startsAt), + ], +); + +export const eventRsvps = pgTable( + 'event_rsvps', + { + eventId: integer('event_id') + .notNull() + .references(() => events.id, { onDelete: 'cascade' }), + userId: text('user_id').notNull(), + status: rsvpStatus('status').notNull(), + updatedAt: timestamp('updated_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + primaryKey({ columns: [table.eventId, table.userId] }), + index('event_rsvps_status_idx').on(table.eventId, table.status), + ], +); + +export type Event = typeof events.$inferSelect; +export type RsvpStatus = (typeof rsvpStatus.enumValues)[number]; diff --git a/src/integrations/db/infrastructure.ts b/src/integrations/db/infrastructure.ts new file mode 100644 index 0000000..f818578 --- /dev/null +++ b/src/integrations/db/infrastructure.ts @@ -0,0 +1,47 @@ +import { createEventSuggestionRepository } from './event-suggestions/repository'; +import { PgBoss } from 'pg-boss'; +import { createJobQueue, startJobs } from '~/integrations/scheduler/boss'; +import { connectDatabase, runMigrations } from '~/integrations/db/client'; +import { createAnnouncementRepository } from '~/integrations/db/announcements/repository'; +import { createEventRepository } from '~/integrations/db/events/repository'; +import { createBirthdayRepository } from '~/integrations/db/birthdays/repository'; +import { createGrantRepository } from '~/integrations/db/permissions/repository'; +import { createMovieRepository } from '~/integrations/db/movies/repository'; +import { createPollRepository } from '~/integrations/db/polls/repository'; +import { createReminderRepository } from '~/integrations/db/reminders/repository'; +import { createRolePanelRepository } from '~/integrations/db/roles/repository'; +import type { AppInfrastructure } from '~/infrastructure'; +import type { Logger } from '~/core/ports/logger'; +export function createPostgresInfrastructure( + url: string, + log: Logger, +): AppInfrastructure { + const database = connectDatabase(url); + const boss = new PgBoss({ connectionString: url }); + + boss.on('error', (error) => log.error({ error }, 'Job queue error')); + + return { + repositories: { + announcements: createAnnouncementRepository(database.db), + events: createEventRepository(database.db), + eventSuggestions: createEventSuggestionRepository(database.db), + birthdays: createBirthdayRepository(database.db), + grants: createGrantRepository(database.db), + movies: createMovieRepository(database.db), + polls: createPollRepository(database.db), + reminders: createReminderRepository(database.db), + roles: createRolePanelRepository(database.db), + }, + scheduler: createJobQueue(boss), + migrate: () => runMigrations(database.db), + start: async () => { + await boss.start(); + }, + startJobs: (jobs, logger) => startJobs(boss, jobs, logger), + stop: async () => { + await boss.stop(); + }, + close: () => database.close(), + }; +} diff --git a/src/integrations/db/movies/repository.ts b/src/integrations/db/movies/repository.ts new file mode 100644 index 0000000..8feb335 --- /dev/null +++ b/src/integrations/db/movies/repository.ts @@ -0,0 +1,181 @@ +import { and, asc, desc, eq, isNotNull, isNull, notExists } from 'drizzle-orm'; +import type { MovieRepository } from '~/features/movies/model'; +import type { Db } from '../client'; +import { normalizeTitle } from '~/features/movies/rules'; +import { UserError } from '~/core/errors'; +import { movieScreenings, movieSuggestions } from './table'; + +const watched = (db: Db) => + db + .select({ id: movieScreenings.id }) + .from(movieScreenings) + .where( + and( + eq(movieScreenings.suggestionId, movieSuggestions.id), + isNotNull(movieScreenings.watchedAt), + ), + ); + +async function findActive(db: Db, guildId: string, normalizedTitle: string) { + const [row] = await db + .select() + .from(movieSuggestions) + .where( + and( + eq(movieSuggestions.guildId, guildId), + eq(movieSuggestions.normalizedTitle, normalizedTitle), + isNull(movieSuggestions.removedAt), + ), + ); + + return row; +} + +export async function lastWatched( + db: Db, + suggestionId: number, +): Promise { + const [row] = await db + .select({ watchedAt: movieScreenings.watchedAt }) + .from(movieScreenings) + .where( + and( + eq(movieScreenings.suggestionId, suggestionId), + isNotNull(movieScreenings.watchedAt), + ), + ) + .orderBy(desc(movieScreenings.watchedAt)) + .limit(1); + + return row?.watchedAt ?? undefined; +} + +export function createMovieRepository(db: Db): MovieRepository { + return { + suggest: async (input) => { + const normalizedTitle = normalizeTitle(input.title); + + if (normalizedTitle === '') { + throw new UserError('Give a movie title.'); + } + + const [row] = await db + .insert(movieSuggestions) + .values({ ...input, title: input.title.trim(), normalizedTitle }) + .onConflictDoNothing() + .returning(); + + if (!row) { + const existing = await findActive(db, input.guildId, normalizedTitle); + const when = existing && (await lastWatched(db, existing.id)); + + throw new UserError( + when + ? `That movie was already watched (${when.toISOString().slice(0, 10)}).` + : 'That movie is already suggested.', + ); + } + + return row; + }, + find: async (guildId, id) => { + const [row] = await db + .select() + .from(movieSuggestions) + .where( + and( + eq(movieSuggestions.id, id), + eq(movieSuggestions.guildId, guildId), + isNull(movieSuggestions.removedAt), + ), + ); + + if (!row) { + throw new UserError(`Movie #${id} is not on the list.`); + } + + return row; + }, + unwatched: async (guildId, limit = 25) => { + return await db + .select() + .from(movieSuggestions) + .where( + and( + eq(movieSuggestions.guildId, guildId), + isNull(movieSuggestions.removedAt), + notExists(watched(db)), + ), + ) + .orderBy(asc(movieSuggestions.createdAt)) + .limit(limit); + }, + remove: async (id) => { + await db + .update(movieSuggestions) + .set({ removedAt: new Date() }) + .where(eq(movieSuggestions.id, id)); + }, + setLinks: async (id, links) => { + await db + .update(movieSuggestions) + .set({ links: [...links] }) + .where(eq(movieSuggestions.id, id)); + }, + recordScreening: async (input) => { + const [row] = await db + .insert(movieScreenings) + .values(input) + .returning({ id: movieScreenings.id }); + + if (!row) { + throw new Error('Insert returned no row'); + } + + return row.id; + }, + markWatched: async (guildId, suggestionId, watchedAt) => { + const [pending] = await db + .select({ id: movieScreenings.id }) + .from(movieScreenings) + .where( + and( + eq(movieScreenings.suggestionId, suggestionId), + isNull(movieScreenings.watchedAt), + ), + ) + .orderBy(desc(movieScreenings.createdAt)) + .limit(1); + + await (pending + ? db + .update(movieScreenings) + .set({ watchedAt }) + .where(eq(movieScreenings.id, pending.id)) + : db + .insert(movieScreenings) + .values({ guildId, suggestionId, watchedAt })); + }, + history: async (guildId, limit = 25) => { + return await db + .select({ + title: movieSuggestions.title, + year: movieSuggestions.year, + watchedAt: movieScreenings.watchedAt, + }) + .from(movieScreenings) + .innerJoin( + movieSuggestions, + eq(movieSuggestions.id, movieScreenings.suggestionId), + ) + .where( + and( + eq(movieScreenings.guildId, guildId), + isNotNull(movieScreenings.watchedAt), + ), + ) + .orderBy(desc(movieScreenings.watchedAt)) + .limit(limit); + }, + }; +} diff --git a/src/integrations/db/movies/table.ts b/src/integrations/db/movies/table.ts new file mode 100644 index 0000000..eb6cf71 --- /dev/null +++ b/src/integrations/db/movies/table.ts @@ -0,0 +1,61 @@ +import { isNull } from 'drizzle-orm'; +import { + index, + integer, + pgTable, + serial, + smallint, + text, + timestamp, + uniqueIndex, +} from 'drizzle-orm/pg-core'; + +export const movieSuggestions = pgTable( + 'movie_suggestions', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + title: text('title').notNull(), + normalizedTitle: text('normalized_title').notNull(), + year: smallint('year'), + note: text('note'), + suggestedBy: text('suggested_by').notNull(), + tmdbId: integer('tmdb_id'), + overview: text('overview'), + posterUrl: text('poster_url'), + trailerUrl: text('trailer_url'), + links: text('links').array().notNull().default([]), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + removedAt: timestamp('removed_at', { withTimezone: true }), + }, + (table) => [ + uniqueIndex('movie_suggestions_unique_idx') + .on(table.guildId, table.normalizedTitle) + .where(isNull(table.removedAt)), + ], +); + +export const movieScreenings = pgTable( + 'movie_screenings', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + suggestionId: integer('suggestion_id') + .notNull() + .references(() => movieSuggestions.id), + eventId: integer('event_id'), + pollId: integer('poll_id'), + scheduledFor: timestamp('scheduled_for', { withTimezone: true }), + watchedAt: timestamp('watched_at', { withTimezone: true }), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + index('movie_screenings_guild_idx').on(table.guildId, table.watchedAt), + ], +); + +export type MovieSuggestion = typeof movieSuggestions.$inferSelect; diff --git a/src/integrations/db/permissions/repository.ts b/src/integrations/db/permissions/repository.ts new file mode 100644 index 0000000..ff1c33e --- /dev/null +++ b/src/integrations/db/permissions/repository.ts @@ -0,0 +1,196 @@ +import type { + GrantRepository, + GrantSubject, +} from '~/features/permissions/model'; +import { and, eq, inArray, or } from 'drizzle-orm'; +import type { Db } from '../client'; +import { rolePermissions } from './table'; + +export async function hasGrant( + db: Db, + guildId: string, + roleIds: readonly string[], + request: { permission: string; userId?: string }, +): Promise { + const { permission, userId } = request; + + if (roleIds.length === 0 && userId === undefined) { + return false; + } + + const rows = await db + .select({ roleId: rolePermissions.roleId }) + .from(rolePermissions) + .where( + and( + eq(rolePermissions.guildId, guildId), + eq(rolePermissions.permission, permission), + or( + and( + eq(rolePermissions.subjectType, 'role'), + inArray(rolePermissions.roleId, [...roleIds]), + ), + userId === undefined + ? undefined + : and( + eq(rolePermissions.subjectType, 'user'), + eq(rolePermissions.roleId, userId), + ), + ), + ), + ) + .limit(1); + + return rows.length > 0; +} + +export async function heldPermissions( + db: Db, + guildId: string, + roleIds: readonly string[], + userId?: string, +): Promise { + if (roleIds.length === 0 && userId === undefined) { + return []; + } + + const rows = await db + .selectDistinct({ permission: rolePermissions.permission }) + .from(rolePermissions) + .where( + and( + eq(rolePermissions.guildId, guildId), + or( + and( + eq(rolePermissions.subjectType, 'role'), + inArray(rolePermissions.roleId, [...roleIds]), + ), + userId === undefined + ? undefined + : and( + eq(rolePermissions.subjectType, 'user'), + eq(rolePermissions.roleId, userId), + ), + ), + ), + ); + + return rows.map((row) => row.permission); +} + +export async function grant( + db: Db, + input: { + guildId: string; + roleId: string; + subjectType?: GrantSubject; + permission: string; + grantedBy: string; + }, +): Promise { + const rows = await db + .insert(rolePermissions) + .values(input) + .onConflictDoNothing() + .returning({ roleId: rolePermissions.roleId }); + + return rows.length > 0; +} + +export async function revoke( + db: Db, + input: { + guildId: string; + roleId: string; + permission: string; + subjectType?: GrantSubject; + }, +): Promise { + const rows = await db + .delete(rolePermissions) + .where( + and( + eq(rolePermissions.guildId, input.guildId), + eq(rolePermissions.roleId, input.roleId), + eq(rolePermissions.subjectType, input.subjectType ?? 'role'), + eq(rolePermissions.permission, input.permission), + ), + ) + .returning({ roleId: rolePermissions.roleId }); + + return rows.length > 0; +} + +export async function listGrants( + db: Db, + guildId: string, + roleId?: string, + subjectType?: GrantSubject, +): Promise< + Array<{ roleId: string; permission: string; subjectType: GrantSubject }> +> { + return await db + .select({ + roleId: rolePermissions.roleId, + subjectType: rolePermissions.subjectType, + permission: rolePermissions.permission, + }) + .from(rolePermissions) + .where( + and( + eq(rolePermissions.guildId, guildId), + roleId === undefined ? undefined : eq(rolePermissions.roleId, roleId), + subjectType === undefined + ? undefined + : eq(rolePermissions.subjectType, subjectType), + ), + ) + .orderBy(rolePermissions.roleId, rolePermissions.permission) + .limit(500); +} + +export function createGrantRepository(db: Db): GrantRepository { + return { + holds: (guildId, roleIds, permission, userId) => + hasGrant(db, guildId, roleIds, { + permission, + ...(userId !== undefined && { userId }), + }), + held: (guildId, roleIds, userId) => + heldPermissions(db, guildId, roleIds, userId), + grant: (change) => grant(db, change), + revoke: (change) => revoke(db, change), + apply: (input) => + db.transaction(async (tx) => { + if (input.revoke.length > 0) { + await tx + .delete(rolePermissions) + .where( + and( + eq(rolePermissions.guildId, input.guildId), + eq(rolePermissions.roleId, input.roleId), + eq(rolePermissions.subjectType, input.subjectType ?? 'role'), + inArray(rolePermissions.permission, [...input.revoke]), + ), + ); + } + + if (input.grant.length > 0) { + await tx + .insert(rolePermissions) + .values( + input.grant.map((permission) => ({ + guildId: input.guildId, + roleId: input.roleId, + subjectType: input.subjectType ?? 'role', + grantedBy: input.grantedBy, + permission, + })), + ) + .onConflictDoNothing(); + } + }), + list: (guildId, roleId, subjectType) => + listGrants(db, guildId, roleId, subjectType), + }; +} diff --git a/src/integrations/db/permissions/table.ts b/src/integrations/db/permissions/table.ts new file mode 100644 index 0000000..311b09c --- /dev/null +++ b/src/integrations/db/permissions/table.ts @@ -0,0 +1,39 @@ +import { sql } from 'drizzle-orm'; +import { + check, + pgTable, + primaryKey, + text, + timestamp, +} from 'drizzle-orm/pg-core'; + +export const rolePermissions = pgTable( + 'role_permissions', + { + guildId: text('guild_id').notNull(), + roleId: text('role_id').notNull(), + subjectType: text('subject_type') + .$type<'role' | 'user'>() + .notNull() + .default('role'), + permission: text('permission').notNull(), + grantedBy: text('granted_by').notNull(), + grantedAt: timestamp('granted_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + check( + 'role_permissions_subject_type_check', + sql`${table.subjectType} IN ('role', 'user')`, + ), + primaryKey({ + columns: [ + table.guildId, + table.roleId, + table.subjectType, + table.permission, + ], + }), + ], +); diff --git a/src/integrations/db/polls/repository.ts b/src/integrations/db/polls/repository.ts new file mode 100644 index 0000000..8ca3d64 --- /dev/null +++ b/src/integrations/db/polls/repository.ts @@ -0,0 +1,195 @@ +import { and, asc, count, countDistinct, desc, eq } from 'drizzle-orm'; +import type { PollWithOptions, PollRepository } from '~/features/polls/model'; +import type { Db } from '../client'; +import { isPollOpen, tally, validatePollOptions } from '~/features/polls/rules'; +import { validatePollResponse } from '~/features/polls/form'; +import { UserError } from '~/core/errors'; +import { pollOptions, polls, pollVotes } from './table'; + +export async function getPoll( + db: Db, + id: number, +): Promise { + const [poll] = await db.select().from(polls).where(eq(polls.id, id)); + + if (!poll) { + return undefined; + } + + const options = await db + .select() + .from(pollOptions) + .where(eq(pollOptions.pollId, id)) + .orderBy(asc(pollOptions.position)); + + return { ...poll, options }; +} + +export function createPollRepository(db: Db): PollRepository { + return { + insert: async (input) => { + const labels = validatePollOptions( + input.options.map((option) => option.label), + ); + + return await db.transaction(async (tx) => { + const { options, ...values } = input; + const [poll] = await tx.insert(polls).values(values).returning(); + + if (!poll) { + throw new Error('Insert returned no row'); + } + + const inserted = await tx + .insert(pollOptions) + .values( + options.map((option, position) => ({ + pollId: poll.id, + position, + label: labels[position] ?? '', + ref: option.ref ?? null, + url: option.url ?? null, + })), + ) + .returning(); + + return { + ...poll, + options: inserted.toSorted((a, b) => a.position - b.position), + }; + }); + }, + find: (id) => getPoll(db, id), + vote: async (pollId, userId, optionIds) => { + await db.transaction(async (tx) => { + const [poll] = await tx + .select() + .from(polls) + .where(eq(polls.id, pollId)) + .for('update'); + + if (!poll || !isPollOpen(poll)) { + throw new UserError('This poll is closed.'); + } + + const options = await tx + .select({ id: pollOptions.id, label: pollOptions.label }) + .from(pollOptions) + .where(eq(pollOptions.pollId, pollId)); + const unique = validatePollResponse(options, poll.multiple, optionIds); + + await tx + .delete(pollVotes) + .where( + and(eq(pollVotes.pollId, pollId), eq(pollVotes.userId, userId)), + ); + if (unique.length > 0) { + await tx + .insert(pollVotes) + .values(unique.map((optionId) => ({ pollId, optionId, userId }))); + } + }); + }, + results: async (poll) => { + const totals = db + .select({ voters: countDistinct(pollVotes.userId).as('voters') }) + .from(pollVotes) + .where(eq(pollVotes.pollId, poll.id)) + .as('totals'); + const counts = await db + .select({ + optionId: pollVotes.optionId, + votes: count(), + voters: totals.voters, + }) + .from(pollVotes) + .crossJoin(totals) + .where(eq(pollVotes.pollId, poll.id)) + .groupBy(pollVotes.optionId, totals.voters); + + return tally( + poll.options, + new Map(counts.map((row) => [row.optionId, row.votes])), + counts[0]?.voters ?? 0, + ); + }, + choices: async (pollId, userId) => { + const rows = await db + .select({ optionId: pollVotes.optionId }) + .from(pollVotes) + .where(and(eq(pollVotes.pollId, pollId), eq(pollVotes.userId, userId))); + + return rows.map((row) => row.optionId); + }, + voters: async (pollId) => { + const rows = await db + .select({ optionId: pollVotes.optionId, userId: pollVotes.userId }) + .from(pollVotes) + .where(eq(pollVotes.pollId, pollId)) + .orderBy(asc(pollVotes.createdAt)) + .limit(5000); + const voters = new Map(); + + for (const row of rows) { + voters.set(row.optionId, [ + ...(voters.get(row.optionId) ?? []), + row.userId, + ]); + } + + return voters; + }, + finish: async (id, status) => { + return await db.transaction(async (tx) => { + const [poll] = await tx + .select() + .from(polls) + .where(and(eq(polls.id, id), eq(polls.status, 'open'))) + .for('update'); + + if (!poll) { + return poll; + } + + const [row] = await tx + .update(polls) + .set({ + status, + ...(status === 'closed' && { + closesAt: new Date( + Math.min( + poll.closesAt?.getTime() ?? Number.POSITIVE_INFINITY, + Date.now(), + ), + ), + }), + }) + .where(eq(polls.id, id)) + .returning(); + + return row; + }); + }, + setMessage: async (id, messageId) => { + await db.update(polls).set({ messageId }).where(eq(polls.id, id)); + }, + open: async (guildId) => { + return await db + .select() + .from(polls) + .where(and(eq(polls.guildId, guildId), eq(polls.status, 'open'))) + .orderBy(desc(polls.id)) + .limit(25); + }, + latestBySource: async (guildId, source) => { + const [row] = await db + .select({ id: polls.id }) + .from(polls) + .where(and(eq(polls.guildId, guildId), eq(polls.source, source))) + .orderBy(desc(polls.createdAt), desc(polls.id)) + .limit(1); + + return row ? getPoll(db, row.id) : undefined; + }, + }; +} diff --git a/src/integrations/db/polls/table.ts b/src/integrations/db/polls/table.ts new file mode 100644 index 0000000..5efefdc --- /dev/null +++ b/src/integrations/db/polls/table.ts @@ -0,0 +1,87 @@ +import { + boolean, + index, + integer, + pgEnum, + pgTable, + primaryKey, + serial, + text, + timestamp, + unique, +} from 'drizzle-orm/pg-core'; + +export const pollStatus = pgEnum('poll_status', [ + 'open', + 'closed', + 'cancelled', +]); +export const pollResultVisibility = pgEnum('poll_result_visibility', [ + 'live', + 'closed', +]); + +export const polls = pgTable( + 'polls', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + channelId: text('channel_id').notNull(), + messageId: text('message_id'), + creatorId: text('creator_id').notNull(), + question: text('question').notNull(), + multiple: boolean('multiple').notNull().default(false), + anonymous: boolean('anonymous').notNull().default(false), + showResults: pollResultVisibility('show_results').notNull().default('live'), + closesAt: timestamp('closes_at', { withTimezone: true }), + status: pollStatus('status').notNull().default('open'), + source: text('source'), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + index('polls_guild_status_idx').on(table.guildId, table.status), + index('polls_source_idx').on(table.guildId, table.source, table.createdAt), + ], +); + +export const pollOptions = pgTable( + 'poll_options', + { + id: serial('id').primaryKey(), + pollId: integer('poll_id') + .notNull() + .references(() => polls.id, { onDelete: 'cascade' }), + position: integer('position').notNull(), + label: text('label').notNull(), + ref: text('ref'), + url: text('url'), + }, + (table) => [ + unique('poll_options_position_unique').on(table.pollId, table.position), + ], +); + +export const pollVotes = pgTable( + 'poll_votes', + { + pollId: integer('poll_id') + .notNull() + .references(() => polls.id, { onDelete: 'cascade' }), + optionId: integer('option_id') + .notNull() + .references(() => pollOptions.id, { onDelete: 'cascade' }), + userId: text('user_id').notNull(), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + primaryKey({ columns: [table.pollId, table.userId, table.optionId] }), + index('poll_votes_option_idx').on(table.optionId), + ], +); + +export type Poll = typeof polls.$inferSelect; +export type PollOption = typeof pollOptions.$inferSelect; diff --git a/src/integrations/db/reminders/repository.ts b/src/integrations/db/reminders/repository.ts new file mode 100644 index 0000000..99c472d --- /dev/null +++ b/src/integrations/db/reminders/repository.ts @@ -0,0 +1,72 @@ +import { and, asc, count, eq } from 'drizzle-orm'; +import type { Db } from '../client'; +import { UserError } from '~/core/errors'; +import type { ReminderRepository } from '~/features/reminders/model'; +import { reminders } from './table'; + +export const maxActivePerUser = 25; +export const maxMessageLength = 1000; + +export function createReminderRepository(db: Db): ReminderRepository { + return { + insert: async (input) => { + if (input.message.length > maxMessageLength) { + throw new UserError( + `Reminders can be at most ${maxMessageLength} characters.`, + ); + } + + return await db.transaction(async (tx) => { + const [active] = await tx + .select({ total: count() }) + .from(reminders) + .where( + and( + eq(reminders.guildId, input.guildId), + eq(reminders.userId, input.userId), + eq(reminders.status, 'active'), + ), + ); + + if ((active?.total ?? 0) >= maxActivePerUser) { + throw new UserError( + `You can have at most ${maxActivePerUser} active reminders.`, + ); + } + + const [row] = await tx.insert(reminders).values(input).returning(); + + if (!row) { + throw new Error('Insert returned no row'); + } + + return row; + }); + }, + find: async (id) => { + const [row] = await db + .select() + .from(reminders) + .where(eq(reminders.id, id)); + + return row; + }, + active: async (guildId, userId) => { + return await db + .select() + .from(reminders) + .where( + and( + eq(reminders.guildId, guildId), + eq(reminders.userId, userId), + eq(reminders.status, 'active'), + ), + ) + .orderBy(asc(reminders.runAt)) + .limit(maxActivePerUser); + }, + update: async (id, changes) => { + await db.update(reminders).set(changes).where(eq(reminders.id, id)); + }, + }; +} diff --git a/src/integrations/db/reminders/table.ts b/src/integrations/db/reminders/table.ts new file mode 100644 index 0000000..d7a3c0f --- /dev/null +++ b/src/integrations/db/reminders/table.ts @@ -0,0 +1,44 @@ +import { + index, + pgEnum, + pgTable, + serial, + text, + timestamp, +} from 'drizzle-orm/pg-core'; + +export const reminderRecurrence = pgEnum('reminder_recurrence', [ + 'daily', + 'weekly', + 'monthly', +]); +export const reminderStatus = pgEnum('reminder_status', [ + 'active', + 'done', + 'cancelled', + 'failed', +]); + +export const reminders = pgTable( + 'reminders', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + userId: text('user_id').notNull(), + channelId: text('channel_id'), + message: text('message').notNull(), + runAt: timestamp('run_at', { withTimezone: true }).notNull(), + recurrence: reminderRecurrence('recurrence'), + timezone: text('timezone').notNull(), + status: reminderStatus('status').notNull().default('active'), + failure: text('failure'), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + index('reminders_user_idx').on(table.guildId, table.userId, table.status), + ], +); + +export type Reminder = typeof reminders.$inferSelect; diff --git a/src/integrations/db/roles/repository.ts b/src/integrations/db/roles/repository.ts new file mode 100644 index 0000000..08a0603 --- /dev/null +++ b/src/integrations/db/roles/repository.ts @@ -0,0 +1,97 @@ +import { and, asc, eq } from 'drizzle-orm'; +import type { RolePanelRepository } from '~/features/roles/model'; +import type { Db } from '../client'; +import { rolePanelRoles, rolePanels } from './table'; + +export function createRolePanelRepository(db: Db): RolePanelRepository { + return { + list: async (guildId) => { + const panels = await db + .select() + .from(rolePanels) + .where( + and(eq(rolePanels.guildId, guildId), eq(rolePanels.kind, 'reaction')), + ) + .orderBy(asc(rolePanels.id)); + + return Promise.all( + panels.map(async (panel) => ({ + ...panel, + roles: await db + .select({ + roleId: rolePanelRoles.roleId, + label: rolePanelRoles.label, + emoji: rolePanelRoles.emoji, + }) + .from(rolePanelRoles) + .where(eq(rolePanelRoles.panelId, panel.id)) + .orderBy(asc(rolePanelRoles.position)), + })), + ); + }, + reactionRole: async (reaction) => { + const [row] = await db + .select({ roleId: rolePanelRoles.roleId }) + .from(rolePanels) + .innerJoin(rolePanelRoles, eq(rolePanelRoles.panelId, rolePanels.id)) + .where( + and( + eq(rolePanels.messageId, reaction.messageId), + eq(rolePanels.guildId, reaction.guildId), + eq(rolePanels.channelId, reaction.channelId), + eq(rolePanels.kind, 'reaction'), + eq(rolePanelRoles.emoji, reaction.emoji), + ), + ) + .limit(1); + + return row?.roleId; + }, + create: async (input) => { + const [row] = await db + .insert(rolePanels) + .values(input) + .returning({ id: rolePanels.id }); + + if (!row) { + throw new Error('Insert returned no row'); + } + + return row.id; + }, + reactionPanel: async (guildId, channelId) => { + const [panel] = await db + .select() + .from(rolePanels) + .where( + and( + eq(rolePanels.guildId, guildId), + eq(rolePanels.channelId, channelId), + eq(rolePanels.kind, 'reaction'), + ), + ); + + return panel; + }, + setMessage: async (panelId, messageId) => { + await db + .update(rolePanels) + .set({ messageId }) + .where(eq(rolePanels.id, panelId)); + }, + replaceRoles: async (panelId, roles) => { + await db.transaction(async (tx) => { + await tx + .delete(rolePanelRoles) + .where(eq(rolePanelRoles.panelId, panelId)); + if (roles.length > 0) { + await tx + .insert(rolePanelRoles) + .values( + roles.map((role, position) => ({ ...role, panelId, position })), + ); + } + }); + }, + }; +} diff --git a/src/integrations/db/roles/table.ts b/src/integrations/db/roles/table.ts new file mode 100644 index 0000000..b16f6f3 --- /dev/null +++ b/src/integrations/db/roles/table.ts @@ -0,0 +1,50 @@ +import { + index, + integer, + pgEnum, + pgTable, + primaryKey, + serial, + text, + timestamp, + uniqueIndex, +} from 'drizzle-orm/pg-core'; +import { eq } from 'drizzle-orm'; + +export const rolePanelKind = pgEnum('role_panel_kind', ['reaction', 'select']); + +export const rolePanels = pgTable( + 'role_panels', + { + id: serial('id').primaryKey(), + guildId: text('guild_id').notNull(), + channelId: text('channel_id').notNull(), + messageId: text('message_id').unique(), + kind: rolePanelKind('kind').notNull(), + title: text('title').notNull(), + createdBy: text('created_by').notNull(), + createdAt: timestamp('created_at', { withTimezone: true }) + .notNull() + .defaultNow(), + }, + (table) => [ + index('role_panels_guild_idx').on(table.guildId), + uniqueIndex('role_panels_reaction_channel_idx') + .on(table.guildId, table.channelId) + .where(eq(table.kind, 'reaction').inlineParams()), + ], +); + +export const rolePanelRoles = pgTable( + 'role_panel_roles', + { + panelId: integer('panel_id') + .notNull() + .references(() => rolePanels.id, { onDelete: 'cascade' }), + roleId: text('role_id').notNull(), + label: text('label').notNull(), + emoji: text('emoji'), + position: integer('position').notNull(), + }, + (table) => [primaryKey({ columns: [table.panelId, table.roleId] })], +); diff --git a/src/integrations/discord/client.ts b/src/integrations/discord/client.ts new file mode 100644 index 0000000..484d51a --- /dev/null +++ b/src/integrations/discord/client.ts @@ -0,0 +1,17 @@ +import { Client, GatewayIntentBits, Partials } from 'discord.js'; + +export function createClient(): Client { + return new Client({ + intents: [ + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessageReactions, + ], + partials: [ + Partials.Message, + Partials.Channel, + Partials.Reaction, + Partials.User, + ], + allowedMentions: { parse: [] }, + }); +} diff --git a/src/integrations/discord/directory.ts b/src/integrations/discord/directory.ts new file mode 100644 index 0000000..3a06e77 --- /dev/null +++ b/src/integrations/discord/directory.ts @@ -0,0 +1,135 @@ +import { + ChannelType, + PermissionFlagsBits, + type Client, + type Guild, +} from 'discord.js'; +import type { Directory } from '~/core/ports/directory'; +import { toActor, toRoleInfo } from '~/discord/interactions/actor'; +import { isPermanentDiscordError, permanent } from './errors'; + +function absentOrThrow(error: unknown): null { + if (isPermanentDiscordError(error)) { + return null; + } + + throw error; +} + +export function createDiscordDirectory(client: Client): Directory { + const guild = (id: string): Promise => + permanent(() => client.guilds.fetch(id)); + + return { + guildOf: async (channelId) => { + const channel = await client.channels + .fetch(channelId) + .catch(absentOrThrow); + + return channel && !channel.isDMBased() ? channel.guildId : undefined; + }, + channels: async (guildId) => { + const found = await guild(guildId); + const all = await found.channels.fetch(); + + return all + .filter( + (channel) => + channel?.type === ChannelType.GuildText || + channel?.type === ChannelType.GuildAnnouncement, + ) + .map((channel) => ({ + id: channel.id, + name: channel.name, + kind: + channel.type === ChannelType.GuildAnnouncement + ? ('announcement' as const) + : ('text' as const), + })); + }, + roles: async (guildId) => { + const found = await guild(guildId); + const roles = await found.roles.fetch(); + + return roles + .sort((a, b) => b.position - a.position) + .map((role) => toRoleInfo(role)); + }, + role: async (guildId, roleId) => { + const found = await guild(guildId); + const role = await found.roles.fetch(roleId).catch(absentOrThrow); + + return role ? toRoleInfo(role) : undefined; + }, + member: async (guildId, userId) => { + const found = await guild(guildId); + const member = await found.members + .fetch({ user: userId, force: true }) + .catch(absentOrThrow); + + return member ? toActor(member) : undefined; + }, + displayName: async (guildId, userId) => { + const found = await guild(guildId); + const member = await found.members.fetch(userId).catch(absentOrThrow); + + return member?.displayName; + }, + canView: async (actor, channelId) => { + const found = await guild(actor.guildId); + const [channel, member] = await Promise.all([ + found.channels.fetch(channelId).catch(absentOrThrow), + found.members.fetch(actor.userId).catch(absentOrThrow), + ]); + + return ( + !!channel && + !!member && + channel.permissionsFor(member).has(PermissionFlagsBits.ViewChannel) + ); + }, + canPost: async (actor, channelId) => { + const found = await guild(actor.guildId); + const [channel, member] = await Promise.all([ + found.channels.fetch(channelId).catch(absentOrThrow), + found.members.fetch(actor.userId).catch(absentOrThrow), + ]); + + if (!channel || !member) { + return false; + } + + return channel + .permissionsFor(member) + .has([ + PermissionFlagsBits.ViewChannel, + PermissionFlagsBits.SendMessages, + ]); + }, + isPublic: async (guildId, channelId) => { + const found = await guild(guildId); + const channel = await found.channels + .fetch(channelId) + .catch(absentOrThrow); + + return ( + !!channel && + channel + .permissionsFor(found.roles.everyone) + .has(PermissionFlagsBits.ViewChannel) + ); + }, + addRoles: async ({ guildId, userId }, roleIds, reason) => { + const found = await guild(guildId); + const member = await permanent(() => found.members.fetch(userId)); + + await permanent(() => member.roles.add([...roleIds], reason)); + }, + removeRoles: async ({ guildId, userId }, roleIds, reason) => { + const found = await guild(guildId); + const member = await permanent(() => found.members.fetch(userId)); + + await permanent(() => member.roles.remove([...roleIds], reason)); + }, + }; +} diff --git a/src/integrations/discord/errors.ts b/src/integrations/discord/errors.ts new file mode 100644 index 0000000..523adff --- /dev/null +++ b/src/integrations/discord/errors.ts @@ -0,0 +1,40 @@ +import { PermanentError } from '~/core/errors'; +import { DiscordAPIError, RESTJSONErrorCodes } from 'discord.js'; + +const permanentCodes = new Set([ + RESTJSONErrorCodes.UnknownChannel, + RESTJSONErrorCodes.UnknownGuild, + RESTJSONErrorCodes.UnknownMember, + RESTJSONErrorCodes.UnknownMessage, + RESTJSONErrorCodes.UnknownRole, + RESTJSONErrorCodes.UnknownUser, + RESTJSONErrorCodes.MissingAccess, + RESTJSONErrorCodes.MissingPermissions, + RESTJSONErrorCodes.CannotSendMessagesToThisUser, +]); + +export function isPermanentDiscordError(error: unknown): boolean { + return error instanceof DiscordAPIError && permanentCodes.has(error.code); +} + +export function isUnknownObject(error: unknown): boolean { + const source = error instanceof PermanentError ? error.cause : error; + + return ( + source instanceof DiscordAPIError && + (source.code === RESTJSONErrorCodes.UnknownMessage || + source.code === RESTJSONErrorCodes.UnknownChannel) + ); +} + +export async function permanent(action: () => Promise): Promise { + try { + return await action(); + } catch (error) { + if (isPermanentDiscordError(error) && error instanceof Error) { + throw new PermanentError(error.message, { cause: error }); + } + + throw error; + } +} diff --git a/src/integrations/discord/messenger.ts b/src/integrations/discord/messenger.ts new file mode 100644 index 0000000..04fccf5 --- /dev/null +++ b/src/integrations/discord/messenger.ts @@ -0,0 +1,115 @@ +import { + PermissionFlagsBits, + type Client, + type GuildTextBasedChannel, +} from 'discord.js'; +import { PermanentError, UserError } from '~/core/errors'; +import type { Messenger } from '~/core/ports/messenger'; +import { permanent, isUnknownObject } from './errors'; +import { render } from '~/discord/render'; + +async function orFalse(action: () => Promise): Promise { + try { + await action(); + + return true; + } catch (error) { + if (isUnknownObject(error)) { + return false; + } + + throw error; + } +} + +export function createDiscordMessenger(client: Client): Messenger { + const textChannel = async (id: string): Promise => { + const channel = await permanent(() => client.channels.fetch(id)); + + if (channel?.isTextBased() !== true || channel.isDMBased()) { + throw new PermanentError(`Channel ${id} is not a server text channel`); + } + + return channel; + }; + + return { + send: async (channelId, message) => { + const channel = await textChannel(channelId); + const sent = await permanent(() => channel.send(render(message))); + + return { channelId, messageId: sent.id }; + }, + edit: (channelId, messageId, message) => + orFalse(async () => { + const channel = await textChannel(channelId); + + await channel.messages.edit(messageId, render(message)); + }), + remove: (channelId, messageId) => + orFalse(async () => { + const channel = await textChannel(channelId); + + await channel.messages.delete(messageId); + }), + direct: async (userId, message) => { + const user = await permanent(() => client.users.fetch(userId)); + + await permanent(() => user.send(render(message))); + }, + exists: (channelId, messageId) => + orFalse(async () => { + const channel = await textChannel(channelId); + + await channel.messages.fetch(messageId); + }), + findOwn: async (channelId, content) => { + const channel = await textChannel(channelId); + const recent = await channel.messages.fetch({ limit: 50 }); + + return recent.find( + (message) => + message.author.id === client.user?.id && message.content === content, + )?.id; + }, + clearReactionsExcept: async (channelId, messageId, emojis) => { + await orFalse(async () => { + const channel = await textChannel(channelId); + const message = await channel.messages.fetch(messageId); + const obsolete = [...message.reactions.cache.values()].filter( + (reaction) => !emojis.includes(reaction.emoji.name ?? ''), + ); + + if (obsolete.length === 0) { + return; + } + + const bot = await channel.guild.members.fetchMe(); + + if ( + !channel.permissionsFor(bot).has(PermissionFlagsBits.ManageMessages) + ) { + throw new UserError( + 'Give the bot Manage Messages in this channel to remove old panel reactions, then save again.', + ); + } + + await Promise.all(obsolete.map((reaction) => reaction.remove())); + }); + }, + ownReactions: async (channelId, messageId) => { + const channel = await textChannel(channelId); + const message = await channel.messages.fetch(messageId); + + return message.reactions.cache + .filter((reaction) => reaction.me) + .map((reaction) => reaction.emoji.name ?? ''); + }, + react: async (channelId, messageId, emoji) => { + const channel = await textChannel(channelId); + const message = await channel.messages.fetch(messageId); + + await message.react(emoji); + }, + }; +} diff --git a/src/integrations/google/calendar.ts b/src/integrations/google/calendar.ts new file mode 100644 index 0000000..02cc94d --- /dev/null +++ b/src/integrations/google/calendar.ts @@ -0,0 +1,90 @@ +import { auth, calendar } from '@googleapis/calendar'; +import type { Calendar, CalendarEvent } from '~/core/ports/calendar'; + +export interface ServiceAccount { + client_email: string; + private_key: string; +} + +const body = (event: CalendarEvent) => ({ + summary: event.title, + description: event.description, + location: event.location, + start: { dateTime: event.startsAt.toISOString() }, + end: { dateTime: event.endsAt.toISOString() }, +}); + +export function createGoogleCalendar( + calendarId: string, + credentials: ServiceAccount, +): Calendar { + const api = calendar({ + version: 'v3', + auth: new auth.GoogleAuth({ + credentials, + scopes: ['https://www.googleapis.com/auth/calendar.events'], + }), + }); + + return { + upsert: async (id, event) => { + if (id !== null) { + await api.events.patch({ + calendarId, + eventId: id, + requestBody: body(event), + }); + + return id; + } + + const { data } = await api.events.insert({ + calendarId, + requestBody: body(event), + }); + + if (data.id === null || data.id === undefined) { + throw new Error('Google Calendar returned no event ID'); + } + + return data.id; + }, + remove: async (id) => { + await api.events.delete( + { calendarId, eventId: id }, + { + validateStatus: (status) => + (status >= 200 && status < 300) || status === 410, + }, + ); + }, + between: async (from, to) => { + const { data } = await api.events.list({ + calendarId, + timeMin: from.toISOString(), + timeMax: to.toISOString(), + singleEvents: true, + orderBy: 'startTime', + maxResults: 50, + }); + + return (data.items ?? []).flatMap((item) => { + const dateTime = item.start?.dateTime ?? undefined; + const start = dateTime ?? item.start?.date ?? undefined; + + if (item.id === null || item.id === undefined || start === undefined) { + return []; + } + + return [ + { + id: item.id, + title: item.summary ?? 'Untitled', + startsAt: new Date(start), + allDay: dateTime === undefined, + }, + ]; + }); + }, + }; +} diff --git a/src/integrations/logging/logger.ts b/src/integrations/logging/logger.ts new file mode 100644 index 0000000..1925065 --- /dev/null +++ b/src/integrations/logging/logger.ts @@ -0,0 +1,47 @@ +import { pino, stdSerializers, type Logger } from 'pino'; +import type { LogStore } from './store'; + +export function createLogger( + level: string, + logs: Pick, +): Logger { + const pretty = process.stdout.isTTY && process.env.NODE_ENV !== 'production'; + + return pino({ + level, + serializers: { + error: stdSerializers.err, + replyError: stdSerializers.err, + reason: stdSerializers.err, + }, + hooks: { + streamWrite: (line) => { + try { + logs.write(line); + } catch (error) { + process.stderr.write( + `Failed to save log entry: ${error instanceof Error ? error.message : String(error)}\n`, + ); + } + + return line; + }, + }, + redact: { + paths: [ + 'token', + 'apiKey', + 'api_key', + 'password', + 'headers', + '*.token', + '*.apiKey', + '*.api_key', + '*.password', + '*.headers', + ], + censor: '[redacted]', + }, + ...(pretty && { transport: { target: 'pino-pretty' } }), + }); +} diff --git a/src/integrations/logging/store.ts b/src/integrations/logging/store.ts new file mode 100644 index 0000000..319ec46 --- /dev/null +++ b/src/integrations/logging/store.ts @@ -0,0 +1,89 @@ +import { chmodSync, mkdirSync } from 'node:fs'; +import { dirname, resolve } from 'node:path'; +import Database from 'better-sqlite3'; +import { and, count, desc, gte, like, or } from 'drizzle-orm'; +import { drizzle } from 'drizzle-orm/better-sqlite3'; +import { migrate } from 'drizzle-orm/better-sqlite3/migrator'; +import { logs } from './table'; +import { z } from 'zod'; + +export const logPageSize = 100; + +const record = z + .object({ + time: z.number(), + level: z.number(), + msg: z.string().default(''), + }) + .catchall(z.unknown()); + +export type LogEntry = typeof logs.$inferSelect; + +export function createLogStore(path: string) { + if (path !== ':memory:') { + mkdirSync(dirname(path), { recursive: true, mode: 0o700 }); + } + + const database = new Database(path); + + if (path !== ':memory:') { + chmodSync(path, 0o600); + } + + database.pragma('journal_mode = WAL'); + database.pragma('synchronous = FULL'); + const db = drizzle(database); + + migrate(db, { migrationsFolder: resolve('drizzle/logs') }); + + return { + write: (line: string): void => { + const { time, level, msg, ...details } = record.parse(JSON.parse(line)); + const source = details.service ?? details.component ?? details.feature; + + db.insert(logs) + .values({ + time, + level, + message: msg, + source: typeof source === 'string' ? source : 'app', + details: JSON.stringify(details, null, 2), + }) + .run(); + }, + page: (input: { level: number; query: string; page?: number }) => { + const query = input.query.toLowerCase(); + const where = and( + gte(logs.level, input.level), + query === '' + ? undefined + : or( + like(logs.message, `%${query}%`), + like(logs.source, `%${query}%`), + like(logs.details, `%${query}%`), + ), + ); + const total = + db.select({ value: count() }).from(logs).where(where).get()?.value ?? 0; + const pages = Math.max(1, Math.ceil(total / logPageSize)); + const page = Math.min(Math.max(1, input.page ?? 1), pages); + const entries = db + .select() + .from(logs) + .where(where) + .orderBy(desc(logs.id)) + .limit(logPageSize) + .offset((page - 1) * logPageSize) + .all(); + + return { entries, total, page, pages, hasMore: page < pages }; + }, + close: () => { + if (database.open) { + database.close(); + } + }, + }; +} + +export type LogStore = ReturnType; diff --git a/src/integrations/logging/table.ts b/src/integrations/logging/table.ts new file mode 100644 index 0000000..0987a8f --- /dev/null +++ b/src/integrations/logging/table.ts @@ -0,0 +1,10 @@ +import { integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'; + +export const logs = sqliteTable('logs', { + id: integer('id').primaryKey(), + time: integer('time').notNull(), + level: integer('level').notNull(), + message: text('message').notNull(), + source: text('source').notNull(), + details: text('details').notNull(), +}); diff --git a/src/integrations/scheduler/boss.ts b/src/integrations/scheduler/boss.ts new file mode 100644 index 0000000..d1e2a3b --- /dev/null +++ b/src/integrations/scheduler/boss.ts @@ -0,0 +1,92 @@ +import type { JobWithMetadata, PgBoss } from 'pg-boss'; +import type { Job, Scheduler } from '~/core/ports/scheduler'; +import type { Logger } from '~/core/ports/logger'; +import { PermanentError } from '~/core/errors'; +import { sequential } from '~/core/helpers/async'; + +const queueOptions = { + policy: 'short', + retryLimit: 4, + retryDelay: 30, + retryBackoff: true, + retryDelayMax: 3600, +} as const; + +export function createJobQueue(boss: PgBoss): Scheduler { + return { + schedule: async (job, payload, { runAt, key }) => { + await boss.upsert(job.type, payload, { + singletonKey: key, + startAfter: runAt, + }); + }, + cancel: async (job, key) => { + const queued = await boss.findJobs(job.type, { key, queued: true }); + + if (queued.length > 0) { + await boss.cancel( + job.type, + queued.map((found) => found.id), + ); + } + }, + }; +} + +export async function startJobs( + boss: PgBoss, + jobs: Iterable>, + log: Logger, +): Promise { + await sequential(jobs, async (job) => { + if (!(await boss.getQueue(job.type))) { + await boss.createQueue(job.type, queueOptions); + } + + await boss.work( + job.type, + { includeMetadata: true, perJobResults: true }, + (batch: JobWithMetadata[]) => + Promise.all( + batch.map(async (found) => { + try { + const outcome = await job.run(found.data); + + if (outcome && found.singletonKey !== null) { + await boss.upsert(job.type, found.data, { + singletonKey: found.singletonKey, + startAfter: outcome.rescheduleAt, + }); + } + + return { id: found.id, status: 'completed' as const }; + } catch (error) { + const permanent = error instanceof PermanentError; + + log.error( + { + error, + jobId: found.id, + jobType: job.type, + attempt: found.retryCount + 1, + permanent, + }, + 'Job failed', + ); + + return { + id: found.id, + status: permanent + ? ('deadletter' as const) + : ('failed' as const), + output: { + message: + error instanceof Error ? error.message : String(error), + }, + }; + } + }), + ), + ); + }); +} diff --git a/src/integrations/tmdb/catalog.ts b/src/integrations/tmdb/catalog.ts new file mode 100644 index 0000000..b928ea6 --- /dev/null +++ b/src/integrations/tmdb/catalog.ts @@ -0,0 +1,41 @@ +import { TMDB } from 'tmdb-ts'; +import type { MovieCatalog } from '~/core/ports/movie-catalog'; + +const posterBase = 'https://image.tmdb.org/t/p/w342'; + +export function createTmdbCatalog(accessToken: string): MovieCatalog { + const tmdb = new TMDB(accessToken); + + return { + lookup: async (title, year) => { + const { results } = await tmdb.search.movies({ + query: title, + ...(year !== null && { year }), + }); + const [movie] = results; + + if (!movie) { + return null; + } + + const { results: videos } = await tmdb.movies.videos(movie.id); + const youtube = videos.filter((video) => video.site === 'YouTube'); + const trailer = + youtube.find((video) => video.type === 'Trailer') ?? youtube[0]; + const released = Number.parseInt(movie.release_date.slice(0, 4), 10); + + return { + tmdbId: movie.id, + title: movie.title, + year: Number.isNaN(released) ? null : released, + overview: movie.overview === '' ? null : movie.overview, + posterUrl: movie.poster_path + ? `${posterBase}${movie.poster_path}` + : null, + trailerUrl: trailer + ? `https://www.youtube.com/watch?v=${trailer.key}` + : null, + }; + }, + }; +} diff --git a/src/reset.d.ts b/src/reset.d.ts new file mode 100644 index 0000000..12bd3ed --- /dev/null +++ b/src/reset.d.ts @@ -0,0 +1 @@ +import '@total-typescript/ts-reset'; diff --git a/src/web/app.tsx b/src/web/app.tsx new file mode 100644 index 0000000..98df4f3 --- /dev/null +++ b/src/web/app.tsx @@ -0,0 +1,243 @@ +import { applicationAdmin, webAccess } from '~/core/permission'; +import { eventSuggestionRoutes } from '~/web/pages/post/event-suggestions/routes'; +import { visibleRecords } from '~/core/helpers/visibility'; +import { randomUUID } from 'node:crypto'; +import { serveStatic } from '@hono/node-server/serve-static'; +import { Hono } from 'hono'; +import { bodyLimit } from 'hono/body-limit'; +import { csrf } from 'hono/csrf'; +import { HTTPException } from 'hono/http-exception'; +import { secureHeaders } from 'hono/secure-headers'; +import { UserError } from '~/core/errors'; +import { signedInUser, signInPages } from './auth'; +import { birthdayRoutes } from '~/web/pages/forms/birthdays/routes'; +import { back, serverOf, type Env, type Server, type WebDeps } from './context'; +import { eventRoutes } from '~/web/pages/post/events/routes'; +import { movieRoutes } from '~/web/pages/forms/movies/routes'; +import { logRoutes } from '~/web/pages/settings/logs/routes'; +import { StatusPage } from './components/status-page'; +import { overviewRoutes } from './pages/overview/routes'; +import { containsPath, sections, visibleLinks } from './navigation'; +import { permissionRoutes } from '~/web/pages/settings/permissions/routes'; +import { roleRoutes } from '~/web/pages/roles/routes'; +import { pollRoutes } from '~/web/pages/post/polls/routes'; +import { announcementRoutes } from '~/web/pages/post/announcements/routes'; + +function returnPath(referer: string | undefined, path: string): string { + const parts = path.split('/').filter(Boolean); + const depth = ['post', 'forms', 'settings'].includes(parts[0] ?? '') ? 2 : 1; + const section = `/${parts.slice(0, depth).join('/')}`; + const from = referer === undefined ? null : URL.parse(referer); + + if (from === null || !containsPath(section, from.pathname)) { + return section; + } + + from.searchParams.delete('notice'); + from.searchParams.delete('error'); + + return `${from.pathname}${from.search}`; +} + +export function createWebApp(deps: WebDeps) { + const { guildId, signIn, directory, authz, services, log } = deps; + const app = new Hono(); + const fetchMetadata = () => + Promise.all([directory.channels(guildId), directory.roles(guildId)]); + let metadata: ReturnType | undefined; + let expiresAt = 0; + const getMetadata = () => { + if (metadata === undefined || Date.now() >= expiresAt) { + expiresAt = Number.POSITIVE_INFINITY; + metadata = fetchMetadata().then((value) => { + expiresAt = Date.now() + 30_000; + + return value; + }); + void metadata.catch(() => { + metadata = undefined; + }); + } + + return metadata; + }; + + app.use( + secureHeaders({ + contentSecurityPolicy: { + defaultSrc: ["'none'"], + styleSrc: ["'self'", 'https://cdn.jsdelivr.net'], + imgSrc: ["'self'", 'https://image.tmdb.org'], + formAction: ["'self'"], + frameAncestors: ["'none'"], + }, + referrerPolicy: 'same-origin', + }), + ); + app.use(serveStatic({ root: 'src/web/public' })); + app.use( + bodyLimit({ + maxSize: 64 * 1024, + onError: (c) => + c.html( + , + 413, + ), + }), + ); + app.use(csrf()); + app.route('/', signInPages(signIn)); + app.use(async (c, next) => { + const userId = await signedInUser(c, signIn); + + if (userId === undefined) { + return c.redirect('/login', 303); + } + + const actor = await directory.member(guildId, userId); + + if (!actor) { + return c.html( + , + 403, + ); + } + + const can = await authz.granted(actor, [ + applicationAdmin, + webAccess, + ...services.permissions.catalogue().map(({ id }) => id), + ]); + + if ( + c.req.path === '/' && + !can.has(webAccess) && + can.has('event:suggestions:manage') + ) { + return c.redirect('/post/event-suggestions', 303); + } + + if ( + !can.has(webAccess) && + !( + can.has('event:suggestions:manage') && + (c.req.path === '/post/event-suggestions' || + c.req.path.startsWith('/post/event-suggestions/')) + ) + ) { + return c.html( + , + 403, + ); + } + + c.set('actor', actor); + c.set('can', can); + let server: Promise | undefined; + + c.set( + 'server', + () => + (server ??= getMetadata().then(async ([channels, roles]) => { + const visible = await visibleRecords( + directory, + actor, + channels.map((channel) => ({ ...channel, channelId: channel.id })), + ); + + return serverOf(visible, roles); + })), + ); + + return next(); + }); + + for (const section of sections.filter(({ pages }) => pages !== undefined)) { + app.get(section.href, (c) => { + const allowed = visibleLinks([section], c.var.can)[0]; + const first = visibleLinks(allowed?.pages ?? [], c.var.can)[0]; + + if (first === undefined) { + return c.html( + , + 403, + ); + } + + return c.redirect(`${first.href}${new URL(c.req.url).search}`, 303); + }); + } + + app.route('/', overviewRoutes(deps)); + app.route('/post/announcements', announcementRoutes(deps)); + app.route('/post/event-suggestions', eventSuggestionRoutes(deps)); + app.route('/post/events', eventRoutes(deps)); + app.route('/post/polls', pollRoutes(deps)); + app.route('/forms/birthdays', birthdayRoutes(deps)); + app.route('/forms/movies', movieRoutes(deps)); + app.route('/roles', roleRoutes(deps)); + app.route('/settings/permissions', permissionRoutes(deps)); + app.route('/settings/logs', logRoutes(deps.timezone, deps.logs)); + + app.notFound((c) => + c.html(, 404), + ); + + app.onError((error, c) => { + if (error instanceof UserError && c.req.method === 'GET') { + return c.html( + , + 403, + ); + } + + if (error instanceof UserError) { + return back(c, returnPath(c.req.header('referer'), c.req.path), { + error: error.message, + }); + } + + if (error instanceof HTTPException && c.req.path === '/login') { + return c.html( + , + error.status, + ); + } + + if (error instanceof HTTPException && error.status === 403) { + return c.html( + , + 403, + ); + } + + const ref = randomUUID().slice(0, 8); + + log.error({ error, ref, path: c.req.path }, 'Web request failed'); + + return c.html( + , + 500, + ); + }); + + return app; +} + +export type WebApp = ReturnType; diff --git a/src/web/auth.ts b/src/web/auth.ts new file mode 100644 index 0000000..d3acf3c --- /dev/null +++ b/src/web/auth.ts @@ -0,0 +1,94 @@ +import { discordAuth, type DiscordUser } from '@hono/oauth-providers/discord'; +import { Hono, type Context } from 'hono'; +import { deleteCookie, getSignedCookie, setSignedCookie } from 'hono/cookie'; +import type { Env } from './context'; + +export interface SignIn { + clientId: string; + clientSecret: string; + publicUrl: string; + sessionSecret: string; +} + +interface SignInEnv { + Variables: Env['Variables'] & { 'user-discord'?: DiscordUser }; +} + +const sessionCookie = 'session'; +const sessionSeconds = 7 * 86_400; + +export async function signedInUser( + c: Context, + signIn: SignIn, +): Promise { + const value = await getSignedCookie(c, signIn.sessionSecret, sessionCookie); + + if (typeof value !== 'string') { + return undefined; + } + + try { + const session: unknown = JSON.parse(value); + + if ( + session !== null && + typeof session === 'object' && + 'userId' in session && + typeof session.userId === 'string' && + 'expiresAt' in session && + typeof session.expiresAt === 'number' && + Number.isFinite(session.expiresAt) && + session.expiresAt > Date.now() + ) { + return session.userId; + } + } catch { + return undefined; + } + + return undefined; +} + +export function signInPages(signIn: SignIn) { + return new Hono() + .use( + '/login', + discordAuth({ + scope: ['identify'], + client_id: signIn.clientId, + client_secret: signIn.clientSecret, + redirect_uri: new URL('/login', signIn.publicUrl).href, + }), + ) + .get('/login', async (c) => { + const user = c.get('user-discord'); + + if (!user) { + return c.redirect('/login', 303); + } + + await setSignedCookie( + c, + sessionCookie, + JSON.stringify({ + userId: user.id, + expiresAt: Date.now() + sessionSeconds * 1000, + }), + signIn.sessionSecret, + { + httpOnly: true, + sameSite: 'Lax', + secure: signIn.publicUrl.startsWith('https://'), + path: '/', + maxAge: sessionSeconds, + }, + ); + + return c.redirect('/', 303); + }) + .post('/logout', (c) => { + deleteCookie(c, sessionCookie, { path: '/' }); + + return c.redirect('/', 303); + }); +} diff --git a/src/web/components/actions.tsx b/src/web/components/actions.tsx new file mode 100644 index 0000000..5ec6f48 --- /dev/null +++ b/src/web/components/actions.tsx @@ -0,0 +1,18 @@ +import type { Child } from 'hono/jsx'; + +export function ActionButton({ + action, + label, +}: Readonly<{ action: string; label: string }>) { + return ( +

+ +
+ ); +} + +export function FormActions({ children }: Readonly<{ children: Child }>) { + return
{children}
; +} diff --git a/src/web/components/choices.tsx b/src/web/components/choices.tsx new file mode 100644 index 0000000..b388d95 --- /dev/null +++ b/src/web/components/choices.tsx @@ -0,0 +1,68 @@ +import type { Child } from 'hono/jsx'; + +export function Checkbox({ + name, + label, + checked = false, + value = '1', +}: Readonly<{ + name: string; + label: Child; + checked?: boolean; + value?: string; +}>) { + return ( + + ); +} + +export interface Choice { + name: string; + value: string; + label: string; +} + +export function MultiSelect({ + label, + placeholder, + choices, + selected, +}: Readonly<{ + label: string; + placeholder: string; + choices: readonly Choice[]; + selected: ReadonlySet; +}>) { + const picked = choices.filter(({ value }) => selected.has(value)); + + return ( +
+ {label} + +
+ ); +} diff --git a/src/web/components/controls.tsx b/src/web/components/controls.tsx new file mode 100644 index 0000000..e35772b --- /dev/null +++ b/src/web/components/controls.tsx @@ -0,0 +1,68 @@ +import { createElement, type Child, type JSX } from 'hono/jsx'; +import { Field } from './field'; + +interface Presentation { + name: string; + id?: string; + label: Child; + help?: string; + error?: string; + 'aria-invalid'?: boolean | 'true' | 'false' | 'grammar' | 'spelling'; +} +type ControlTag = 'input' | 'textarea' | 'select'; + +function describedBy( + id: string, + help: string | undefined, + error: string | undefined, + existing: unknown, +) { + return ( + [ + existing, + help === undefined ? undefined : `${id}-help`, + error === undefined ? undefined : `${id}-error`, + ] + .filter( + (value): value is string => + typeof value === 'string' && value.length > 0, + ) + .join(' ') || undefined + ); +} + +function control(tag: Tag) { + return function Control({ + label, + help, + error, + id, + ...props + }: Readonly) { + const controlId = id ?? props.name; + + return ( + + {createElement( + tag, + { + ...props, + id: controlId, + 'aria-describedby': describedBy( + controlId, + help, + error, + props['aria-describedby'], + ), + 'aria-invalid': error === undefined ? props['aria-invalid'] : true, + }, + props.children, + )} + + ); + }; +} + +export const Input = control('input'); +export const Textarea = control('textarea'); +export const Select = control('select'); diff --git a/src/web/components/field.tsx b/src/web/components/field.tsx new file mode 100644 index 0000000..affe046 --- /dev/null +++ b/src/web/components/field.tsx @@ -0,0 +1,30 @@ +import type { Child } from 'hono/jsx'; + +export interface FieldProps { + id: string; + label: Child; + help: string | undefined; + error: string | undefined; + children: Child; +} + +export function Field({ + id, + label, + help, + error, + children, +}: Readonly) { + return ( + + ); +} diff --git a/src/web/components/preview.tsx b/src/web/components/preview.tsx new file mode 100644 index 0000000..96a4c4b --- /dev/null +++ b/src/web/components/preview.tsx @@ -0,0 +1,64 @@ +import type { Message } from '~/core/message'; +import type { Server } from '~/web/context'; + +const token = /(<@&\d+>|<@\d+>|<#\d+>|\*\*[^*]+\*\*)/; + +function withOffsets(parts: readonly string[], separator = 0) { + let offset = 0; + + return parts.map((part) => { + const start = offset; + + offset += part.length + separator; + + return { part, start }; + }); +} + +function Piece({ part, server }: Readonly<{ part: string; server: Server }>) { + const role = /^<@&(\d+)>$/.exec(part)?.[1]; + const channel = /^<#(\d+)>$/.exec(part)?.[1]; + + if (role !== undefined) { + return @{server.roleName(role)}; + } + + if (/^<@\d+>$/.test(part)) { + return @user; + } + + if (channel !== undefined) { + return #{server.channelName(channel)}; + } + + if (part.startsWith('**') && part.endsWith('**')) { + return {part.slice(2, -2)}; + } + + return {part}; +} + +function Line({ text, server }: Readonly<{ text: string; server: Server }>) { + const heading = text.startsWith('# '); + const body = heading ? text.slice(2) : text; + const pieces = withOffsets( + body.split(token).filter((part) => part !== ''), + ).map(({ part, start }) => ); + + return heading ?
{pieces}
:
{pieces}
; +} + +export function MessagePreview({ + message, + server, +}: Readonly<{ message: Message; server: Server }>) { + const lines = withOffsets((message.content ?? '').split('\n'), 1); + + return ( +
+ {lines.map(({ part, start }) => ( + + ))} +
+ ); +} diff --git a/src/web/components/selectors.tsx b/src/web/components/selectors.tsx new file mode 100644 index 0000000..2a9d517 --- /dev/null +++ b/src/web/components/selectors.tsx @@ -0,0 +1,32 @@ +import type { Server } from '~/web/context'; +import { Select } from '~/web/components/controls'; + +export function ChannelOptions({ + server, + selected, +}: Readonly<{ server: Server; selected?: string }>) { + return ( + <> + {server.channels.map(({ id, name }) => ( + + ))} + + ); +} + +export function ChannelSelect({ + server, + name = 'channelId', + selected, +}: Readonly<{ server: Server; name?: string; selected?: string }>) { + return ( + + ); +} diff --git a/src/web/components/status-page.tsx b/src/web/components/status-page.tsx new file mode 100644 index 0000000..7e2a378 --- /dev/null +++ b/src/web/components/status-page.tsx @@ -0,0 +1,19 @@ +import type { Permission } from '~/core/permission'; +import { Layout } from '~/web/layout'; + +interface Props { + title: string; + text: string; + can?: ReadonlySet; +} + +export function StatusPage({ title, text, can }: Readonly) { + return ( + +

{text}

+

+ Back to the overview +

+
+ ); +} diff --git a/src/web/context.ts b/src/web/context.ts new file mode 100644 index 0000000..c557c03 --- /dev/null +++ b/src/web/context.ts @@ -0,0 +1,130 @@ +import type { EventSuggestionService } from '~/features/event-suggestions/service'; +import type { LogStore } from '~/integrations/logging/store'; +import { tz } from '@date-fns/tz'; +import { format } from 'date-fns'; +import type { Context } from 'hono'; +import type { Authorizer } from '~/core/ports/authorization'; +import type { ChannelInfo, Directory, RoleInfo } from '~/core/ports/directory'; +import type { Logger } from '~/core/ports/logger'; +import type { AnnouncementService } from '~/features/announcements/service'; +import type { BirthdayService } from '~/features/birthdays/service'; +import type { MovieService } from '~/features/movies/service'; +import type { EventService } from '~/features/events/service'; +import type { PermissionService } from '~/features/permissions/service'; +import type { PollService } from '~/features/polls/service'; +import type { RoleService } from '~/features/roles/service'; +import type { Actor } from '~/core/actor'; +import type { Permission } from '~/core/permission'; +import type { SignIn } from './auth'; + +export interface WebServices { + eventSuggestions: EventSuggestionService; + roles: RoleService; + announcements: AnnouncementService; + events: EventService; + polls: PollService; + permissions: PermissionService; + birthdays: BirthdayService; + movies: MovieService; +} + +export interface WebDeps { + guildId: string; + timezone: string; + signIn: SignIn; + directory: Directory; + authz: Authorizer; + services: WebServices; + log: Logger; + logs: LogStore; +} + +export interface Server { + channels: ChannelInfo[]; + roles: RoleInfo[]; + roleName: (id: string) => string; + channelName: (id: string) => string; +} + +export function serverOf(channels: ChannelInfo[], roles: RoleInfo[]): Server { + const roleNames = new Map( + roles.map((role) => [role.id, role.name]), + ); + const channelNames = new Map( + channels.map((channel) => [channel.id, channel.name]), + ); + + return { + channels, + roles, + roleName: (id: string): string => roleNames.get(id) ?? 'unknown role', + channelName: (id: string): string => `#${channelNames.get(id) ?? id}`, + }; +} + +export interface Env { + Variables: { + actor: Actor; + server: () => Promise; + can: ReadonlySet; + }; +} + +export const allows = (c: Context, permission: Permission) => + c.var.can.has(permission); + +export const owns = ( + c: Context, + ownerId: string, + permission: Permission, +) => c.var.actor.userId === ownerId || allows(c, permission); + +export interface Flash { + notice?: string; + error?: string; +} + +export type Form = FormData; + +export const field = (form: Form, name: string) => { + const value = form.get(name); + const text = typeof value === 'string' ? value.trim() : ''; + + return text === '' ? undefined : text; +}; + +export const checked = (form: Form, name: string) => form.get(name) === '1'; + +export const flashOf = (c: Context): Flash => { + const notice = c.req.query('notice'); + const error = c.req.query('error'); + + return { + ...(notice !== undefined && { notice }), + ...(error !== undefined && { error }), + }; +}; + +export const withFlash = (path: string, flash: Flash) => { + const query = new URLSearchParams(Object.entries(flash)).toString(); + + const separator = path.includes('?') ? '&' : '?'; + + return query === '' ? path : `${path}${separator}${query}`; +}; + +export const back = (c: Context, path: string, flash: Flash) => + c.redirect(withFlash(path, flash), 303); + +export const inputTime = (timezone: string) => (date: Date | null) => + date === null ? '' : format(date, 'yyyy-MM-dd HH:mm', { in: tz(timezone) }); + +export const formatter = (timezone: string) => { + const display = new Intl.DateTimeFormat('en-GB', { + dateStyle: 'medium', + timeStyle: 'short', + timeZone: timezone, + }); + + return (date: Date | null) => (date === null ? '' : display.format(date)); +}; diff --git a/src/web/layout.tsx b/src/web/layout.tsx new file mode 100644 index 0000000..9f73770 --- /dev/null +++ b/src/web/layout.tsx @@ -0,0 +1,111 @@ +import type { Child } from 'hono/jsx'; +import { type Permission } from '~/core/permission'; +import type { Flash } from './context'; +import { containsPath, sections, visibleLinks } from './navigation'; + +const pico = + 'https://cdn.jsdelivr.net/npm/@picocss/pico@2.1.1/css/pico.min.css'; + +export function Layout({ + title, + path, + can, + flash = {}, + actions, + children, +}: Readonly<{ + title: string; + path: string; + can?: ReadonlySet; + flash?: Flash; + actions?: Child; + children?: Child; +}>) { + const visible = visibleLinks(sections, can); + const section = visible.find(({ href }) => containsPath(href, path)); + const pages = visibleLinks(section?.pages ?? [], can); + const heading = pages.map(({ label }) => label).includes(title) + ? section?.label + : title; + + return ( + + + + + {`${title} · LAPbot`} + + + + +
+ +
+
+ {pages.length === 0 ? null : ( + + )} +
+

{heading}

+ {actions} +
+ {flash.notice === undefined ? null : ( +

+ {flash.notice} +

+ )} + {flash.error === undefined ? null : ( + + )} + {children} +
+ + + ); +} diff --git a/src/web/navigation.ts b/src/web/navigation.ts new file mode 100644 index 0000000..8d4dbad --- /dev/null +++ b/src/web/navigation.ts @@ -0,0 +1,74 @@ +import { + applicationAdmin, + managePermissions, + type Permission, +} from '~/core/permission'; + +interface PageLink { + href: string; + label: string; + permission?: Permission; +} + +export interface Section extends PageLink { + pages?: readonly PageLink[]; +} + +export const sections: readonly Section[] = [ + { href: '/', label: 'Overview' }, + { + href: '/post', + label: 'Post', + pages: [ + { + href: '/post/announcements', + label: 'Announcements', + permission: 'announcement:create', + }, + { href: '/post/events', label: 'Events' }, + { + href: '/post/event-suggestions', + label: 'Event suggestions', + permission: 'event:suggestions:manage', + }, + { href: '/post/polls', label: 'Polls' }, + ], + }, + { + href: '/forms', + label: 'Forms', + pages: [ + { href: '/forms/birthdays', label: 'Birthdays' }, + { href: '/forms/movies', label: 'Movies' }, + ], + }, + { href: '/roles', label: 'Roles', permission: applicationAdmin }, + { + href: '/settings', + label: 'Settings', + permission: managePermissions, + pages: [ + { + href: '/settings/permissions', + label: 'Permissions', + permission: managePermissions, + }, + { href: '/settings/logs', label: 'Logs', permission: applicationAdmin }, + ], + }, +]; + +export function visibleLinks( + links: readonly T[], + can: ReadonlySet | undefined, +): readonly T[] { + return can === undefined + ? [] + : links.filter( + ({ permission }) => permission === undefined || can.has(permission), + ); +} + +export function containsPath(href: string, path: string): boolean { + return path === href || (href !== '/' && path.startsWith(`${href}/`)); +} diff --git a/src/web/pages/forms/birthdays/form.tsx b/src/web/pages/forms/birthdays/form.tsx new file mode 100644 index 0000000..e9ef900 --- /dev/null +++ b/src/web/pages/forms/birthdays/form.tsx @@ -0,0 +1,46 @@ +import type { BirthdaySettings } from '~/features/birthdays/model'; +import { FormActions } from '~/web/components/actions'; +import { Select } from '~/web/components/controls'; +import { ChannelSelect } from '~/web/components/selectors'; +import type { Server } from '~/web/context'; + +interface Props { + settings: BirthdaySettings | undefined; + server: Server; +} +export function BirthdaySettingsForm({ settings, server }: Readonly) { + const selectedHour = settings?.hour ?? 9; + + return ( +
+ +
+ +
+ + + {settings === undefined ? null : ( + + )} + + + ); +} diff --git a/src/web/pages/forms/birthdays/index.tsx b/src/web/pages/forms/birthdays/index.tsx new file mode 100644 index 0000000..38a81e7 --- /dev/null +++ b/src/web/pages/forms/birthdays/index.tsx @@ -0,0 +1,43 @@ +import type { Permission } from '~/core/permission'; +import type { Birthday, BirthdaySettings } from '~/features/birthdays/model'; +import type { Flash, Server } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { BirthdaySettingsForm } from './form'; +import { BirthdaySignup } from './signup'; +import { UpcomingBirthdays } from './upcoming'; + +interface Props { + settings: BirthdaySettings | undefined; + upcoming: Birthday[]; + names: string[]; + server: Server; + can: ReadonlySet; + flash: Flash; +} + +export function BirthdayPage({ + settings, + upcoming, + names, + server, + can, + flash, +}: Readonly) { + return ( + +

+ {settings === undefined + ? 'Birthday announcements are off.' + : `Announced in ${server.channelName(settings.channelId)} at ${settings.hour}:00.`}{' '} + Members add their own birthday with /birthday set. +

+ {can.has('birthday:manage') ? ( + <> + + + + ) : null} + +
+ ); +} diff --git a/src/web/pages/forms/birthdays/routes.tsx b/src/web/pages/forms/birthdays/routes.tsx new file mode 100644 index 0000000..8802b1f --- /dev/null +++ b/src/web/pages/forms/birthdays/routes.tsx @@ -0,0 +1,57 @@ +import { Hono } from 'hono'; +import { back, field, flashOf, type Env, type WebDeps } from '~/web/context'; +import { BirthdayPage } from './index'; + +export function birthdayRoutes({ guildId, services, directory }: WebDeps) { + return new Hono() + .get('/', async (c) => { + const [server, settings, upcoming] = await Promise.all([ + c.var.server(), + services.birthdays.settings(guildId), + services.birthdays.upcoming(guildId), + ]); + const names = await Promise.all( + upcoming.map( + async ({ userId }) => + (await directory.displayName(guildId, userId)) ?? 'Former member', + ), + ); + + return c.html( + , + ); + }) + .post('/', async (c) => { + const form = await c.req.formData(); + const hour = field(form, 'hour'); + const channelId = field(form, 'channelId'); + const message = await services.birthdays.configure( + c.var.actor, + form.get('action') === 'disable' + ? { disable: true } + : { + ...(channelId !== undefined && { channelId }), + ...(hour !== undefined && { hour: Number(hour) }), + }, + ); + + return back(c, '/forms/birthdays', { notice: message }); + }) + .post('/signup', async (c) => { + const form = await c.req.formData(); + + await services.birthdays.postSignup( + c.var.actor, + field(form, 'channelId') ?? '', + ); + + return back(c, '/forms/birthdays', { notice: 'Sign-up message posted.' }); + }); +} diff --git a/src/web/pages/forms/birthdays/signup.tsx b/src/web/pages/forms/birthdays/signup.tsx new file mode 100644 index 0000000..737c2d8 --- /dev/null +++ b/src/web/pages/forms/birthdays/signup.tsx @@ -0,0 +1,28 @@ +import { ChannelOptions } from '~/web/components/selectors'; +import type { Server } from '~/web/context'; + +interface Props { + server: Server; +} +export function BirthdaySignup({ server }: Readonly) { + return ( + <> +

Sign-up message

+

+ Post a message with an Add my birthday button. It keeps working + after restarts, so one post is enough. +

+
+ +
+ + +
+
+ + ); +} diff --git a/src/web/pages/forms/birthdays/upcoming.tsx b/src/web/pages/forms/birthdays/upcoming.tsx new file mode 100644 index 0000000..1cf3976 --- /dev/null +++ b/src/web/pages/forms/birthdays/upcoming.tsx @@ -0,0 +1,37 @@ +import type { Birthday } from '~/features/birthdays/model'; + +const dayMonth = new Intl.DateTimeFormat('en-GB', { + day: 'numeric', + month: 'long', + timeZone: 'UTC', +}); + +interface Props { + upcoming: Birthday[]; + names: string[]; +} +export function UpcomingBirthdays({ upcoming, names }: Readonly) { + return ( + <> +

Coming up

+ {upcoming.length === 0 ? ( +

No public birthdays saved yet.

+ ) : ( + + + {upcoming.map((birthday, index) => ( + + + + + ))} + +
{names[index]} + {dayMonth.format( + new Date(Date.UTC(2024, birthday.month - 1, birthday.day)), + )} +
+ )} + + ); +} diff --git a/src/web/pages/forms/movies/card.tsx b/src/web/pages/forms/movies/card.tsx new file mode 100644 index 0000000..28ce705 --- /dev/null +++ b/src/web/pages/forms/movies/card.tsx @@ -0,0 +1,60 @@ +import type { MovieSuggestion } from '~/features/movies/model'; +import { movieLabel, movieLinks } from '~/features/movies/rules'; +import { ActionButton } from '~/web/components/actions'; + +export function MovieCard({ + movie, + suggestedBy, + editable, +}: Readonly<{ + movie: MovieSuggestion; + suggestedBy: string; + editable: boolean; +}>) { + return ( +
+ {movie.posterUrl === null ? ( +
+ ) : ( + + )} +
+

{movieLabel(movie)}

+ Suggested by {suggestedBy} + {movie.note === null ? null :

{movie.note}

} + {movie.overview === null ? null : ( +

{movie.overview}

+ )} +

+ {movieLinks(movie).map(({ label, url }) => ( + + {label} + + ))} +

+ {editable ? ( + <> +
+
+ + +
+
+ + + ) : null} +
+
+ ); +} diff --git a/src/web/pages/forms/movies/create.tsx b/src/web/pages/forms/movies/create.tsx new file mode 100644 index 0000000..372cf54 --- /dev/null +++ b/src/web/pages/forms/movies/create.tsx @@ -0,0 +1,22 @@ +import type { Permission } from '~/core/permission'; +import type { Flash } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { MovieForm } from './form'; + +interface Props { + can: ReadonlySet; + flash: Flash; +} + +export function NewMoviePage({ can, flash }: Readonly) { + return ( + + + + ); +} diff --git a/src/web/pages/forms/movies/form.tsx b/src/web/pages/forms/movies/form.tsx new file mode 100644 index 0000000..0330788 --- /dev/null +++ b/src/web/pages/forms/movies/form.tsx @@ -0,0 +1,20 @@ +import { Input, Textarea } from '~/web/components/controls'; + +export function MovieForm() { + return ( +
+
+ + +
+ + + + + {preview} + + {actions + .filter(([, , , needs]) => needs === undefined || can.has(needs)) + .map(([value, label, variant]) => ( + + ))} + + + ); +} diff --git a/src/web/pages/post/announcements/index.tsx b/src/web/pages/post/announcements/index.tsx new file mode 100644 index 0000000..ef01cae --- /dev/null +++ b/src/web/pages/post/announcements/index.tsx @@ -0,0 +1,43 @@ +import type { Permission } from '~/core/permission'; +import type { Announcement } from '~/features/announcements/model'; +import type { Flash, Server } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { Recent } from './list'; + +const title = 'Announcements'; + +interface Props { + list: Announcement[]; + server: Server; + date: (value: Date | null) => string; + can: ReadonlySet; + userId: string; + flash: Flash; +} + +export function AnnouncementPage({ + list, + server, + date, + can, + userId, + flash, +}: Readonly) { + return ( + New PSA} + > + + + ); +} diff --git a/src/web/pages/post/announcements/list.tsx b/src/web/pages/post/announcements/list.tsx new file mode 100644 index 0000000..5d27b95 --- /dev/null +++ b/src/web/pages/post/announcements/list.tsx @@ -0,0 +1,72 @@ +import type { Permission } from '~/core/permission'; +import type { Announcement } from '~/features/announcements/model'; +import { ActionButton } from '~/web/components/actions'; +import { type Server } from '~/web/context'; + +export function Recent({ + list, + server, + date, + can, + userId, +}: Readonly<{ + list: Announcement[]; + server: Server; + date: (value: Date | null) => string; + can: ReadonlySet; + userId: string; +}>) { + const publisher = can.has('announcement:publish'); + + return ( + + + + + + + + + + + + {list.map((a) => ( + + + + + + + + + ))} + +
#StatusChannelTitleWhen +
{a.id} + {a.status} + {a.failure === null ? null : ( + <> +
+ {a.failure} + + )} +
{server.channelName(a.channelId)}{a.title ?? a.content.slice(0, 60)}{date(a.publishedAt ?? a.scheduledAt)} + {a.status === 'draft' || a.status === 'scheduled' ? ( + <> + {publisher ? ( + + ) : null} + {publisher || a.authorId === userId ? ( + + ) : null} + + ) : null} +
+ ); +} diff --git a/src/web/pages/post/announcements/mentions.tsx b/src/web/pages/post/announcements/mentions.tsx new file mode 100644 index 0000000..4eecd43 --- /dev/null +++ b/src/web/pages/post/announcements/mentions.tsx @@ -0,0 +1,24 @@ +import { MultiSelect } from '~/web/components/choices'; +import { type Server } from '~/web/context'; +import type { Draft } from './submission'; + +export function MentionPicker({ + server, + draft, +}: Readonly<{ server: Server; draft: Draft | undefined }>) { + const roles = server.roles.filter((role) => !role.everyone && !role.managed); + const selected = new Set(draft?.mentionRoleIds ?? []); + + return ( + ({ + name: 'role', + value: id, + label: `@${name}`, + }))} + /> + ); +} diff --git a/src/web/pages/post/announcements/preview.tsx b/src/web/pages/post/announcements/preview.tsx new file mode 100644 index 0000000..0b77fd6 --- /dev/null +++ b/src/web/pages/post/announcements/preview.tsx @@ -0,0 +1,43 @@ +import type { Message } from '~/core/message'; +import type { Permission } from '~/core/permission'; +import { MessagePreview } from '~/web/components/preview'; +import { type Server } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { Composer } from './form'; +import type { Draft } from './submission'; + +interface Props { + server: Server; + can: ReadonlySet; + draft: Draft; + view: readonly Message[]; +} + +export function AnnouncementPreviewPage({ + server, + can, + draft, + view, +}: Readonly) { + return ( + + +

Preview

+ {view.map((message) => ( + + ))} + + } + /> +
+ ); +} diff --git a/src/web/pages/post/announcements/routes.tsx b/src/web/pages/post/announcements/routes.tsx new file mode 100644 index 0000000..969dadc --- /dev/null +++ b/src/web/pages/post/announcements/routes.tsx @@ -0,0 +1,117 @@ +import { Hono } from 'hono'; +import { UserError } from '~/core/errors'; +import { + allows, + back, + field, + flashOf, + formatter, + type Env, + type WebDeps, +} from '~/web/context'; +import { NewAnnouncementPage } from './create'; +import { AnnouncementPage } from './index'; +import { AnnouncementPreviewPage } from './preview'; +import { draftOf } from './submission'; + +export function announcementRoutes({ services, timezone }: WebDeps) { + const date = formatter(timezone); + + return new Hono() + .use(async (c, next) => { + if (!allows(c, 'announcement:create')) { + throw new UserError('You need the "announcement:create" permission.'); + } + + await next(); + }) + .get('/', async (c) => { + const list = await services.announcements.list(c.var.actor); + + return c.html( + , + ); + }) + .get('/new', async (c) => + c.html( + , + ), + ) + .post('/', async (c) => { + const form = await c.req.formData(); + const action = form.get('action'); + const draft = draftOf(form); + const { actor } = c.var; + + if (action === 'preview') { + const view = services.announcements.view({ + ...draft, + title: draft.title === '' ? null : draft.title, + }); + + return c.html( + , + ); + } + + const created = await services.announcements.draft(actor, draft); + + if (action === 'publish') { + await services.announcements.publish(actor, created.id); + + return back(c, '/post/announcements', { + notice: `PSA #${created.id} published.`, + }); + } + + if (action === 'schedule') { + const scheduled = await services.announcements.schedule( + actor, + created.id, + field(form, 'when') ?? '', + ); + + return back(c, '/post/announcements', { + notice: `PSA #${created.id} scheduled for ${date(scheduled.scheduledAt)}.`, + }); + } + + return back(c, '/post/announcements', { + notice: `Draft #${created.id} saved.`, + }); + }) + .post(String.raw`/:id{\d+}/publish`, async (c) => { + const id = Number(c.req.param('id')); + + await services.announcements.publish(c.var.actor, id); + + return back(c, '/post/announcements', { + notice: `PSA #${id} published.`, + }); + }) + .post(String.raw`/:id{\d+}/cancel`, async (c) => { + const id = Number(c.req.param('id')); + + await services.announcements.cancel(c.var.actor, id); + + return back(c, '/post/announcements', { + notice: `PSA #${id} cancelled.`, + }); + }); +} diff --git a/src/web/pages/post/announcements/submission.ts b/src/web/pages/post/announcements/submission.ts new file mode 100644 index 0000000..2618b9f --- /dev/null +++ b/src/web/pages/post/announcements/submission.ts @@ -0,0 +1,15 @@ +import { field, type Form } from '~/web/context'; + +export function draftOf(form: Form) { + const content = form.get('content'); + + return { + when: field(form, 'when') ?? '', + channelId: field(form, 'channelId') ?? '', + title: field(form, 'title') ?? '', + content: typeof content === 'string' ? content : '', + mentionRoleIds: form.getAll('role').map(String), + }; +} + +export type Draft = ReturnType; diff --git a/src/web/pages/post/event-suggestions/routes.tsx b/src/web/pages/post/event-suggestions/routes.tsx new file mode 100644 index 0000000..438b092 --- /dev/null +++ b/src/web/pages/post/event-suggestions/routes.tsx @@ -0,0 +1,76 @@ +import { Hono } from 'hono'; +import { UserError } from '~/core/errors'; +import { + back, + field, + flashOf, + formatter, + type Env, + type WebDeps, +} from '~/web/context'; +import { Layout } from '~/web/layout'; + +export function eventSuggestionRoutes({ services, timezone }: WebDeps) { + return new Hono() + .get('/', async (c) => { + const page = Number(c.req.query('page') ?? 0); + const list = await services.eventSuggestions.list(c.var.actor, page); + + return c.html( + + {list.length === 0 &&

No suggestions on this page.

} + {list.map((idea) => ( +
+

Suggestion #{idea.id}

+

{idea.text}

+

+ By {idea.authorId} · {formatter(timezone)(idea.createdAt)} ·{' '} + {idea.status} +

+ {idea.messageId !== null && ( +

+ + View message + +

+ )} +
+ + +
+
+ ))} + {page > 0 && Previous} + {list.length === 25 && Next} +
, + ); + }) + .post(String.raw`/:id{\d+}`, async (c) => { + const status = field(await c.req.formData(), 'status'); + + if (status !== 'new' && status !== 'reviewed' && status !== 'dismissed') { + throw new UserError('Invalid status.'); + } + + await services.eventSuggestions.review( + c.var.actor, + Number(c.req.param('id')), + status, + ); + + return back(c, '/post/event-suggestions', { + notice: 'Suggestion updated.', + }); + }); +} diff --git a/src/web/pages/post/events/create.tsx b/src/web/pages/post/events/create.tsx new file mode 100644 index 0000000..71a1c0f --- /dev/null +++ b/src/web/pages/post/events/create.tsx @@ -0,0 +1,92 @@ +import type { Permission } from '~/core/permission'; +import { reminderChoices } from '~/features/events/service'; +import { Checkbox } from '~/web/components/choices'; +import { Input, Select } from '~/web/components/controls'; +import { ChannelSelect } from '~/web/components/selectors'; +import type { Flash, Server } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { EventFields } from './fields'; + +export type DayCheck = + | { start: string; heading: string; entries: string[] } + | { start: string; error: string }; + +interface Props { + time: (value: Date | null) => string; + server: Server; + can: ReadonlySet; + flash: Flash; + calendar: boolean; + day?: DayCheck; +} + +function DayResult({ day }: Readonly<{ day: DayCheck }>) { + if ('error' in day) { + return

{day.error}

; + } + + return ( +
+ {day.heading} + {day.entries.length === 0 ? ( +

Nothing else that day.

+ ) : ( +
    + {day.entries.map((entry) => ( +
  • {entry}
  • + ))} +
+ )} +
+ ); +} + +export function NewEventPage({ + time, + server, + can, + flash, + calendar, + day, +}: Readonly) { + return ( + +
+ + +
+ {day && } +
+ +
+ + +
+
+ {calendar && ( + + )} + +
+ + +
+ ); +} diff --git a/src/web/pages/post/events/edit.tsx b/src/web/pages/post/events/edit.tsx new file mode 100644 index 0000000..f5d3b11 --- /dev/null +++ b/src/web/pages/post/events/edit.tsx @@ -0,0 +1,45 @@ +import type { Permission } from '~/core/permission'; +import type { Event } from '~/features/events/model'; +import { Checkbox } from '~/web/components/choices'; +import type { Flash } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { EventFields } from './fields'; + +interface Props { + event: Event; + time: (value: Date | null) => string; + can: ReadonlySet; + flash: Flash; +} + +export function EditEventPage({ event, time, can, flash }: Readonly) { + return ( + +
+ +
+ +
+ + + {can.has('event:calendar:publish') && ( +
+ +
+ )} +
+ ); +} diff --git a/src/web/pages/post/events/fields.tsx b/src/web/pages/post/events/fields.tsx new file mode 100644 index 0000000..bcce4fe --- /dev/null +++ b/src/web/pages/post/events/fields.tsx @@ -0,0 +1,62 @@ +import type { Event } from '~/features/events/model'; +import { Input, Textarea } from '~/web/components/controls'; + +export function EventFields({ + event, + time, + start, +}: Readonly<{ + event?: Event; + time: (date: Date | null) => string; + start?: string; +}>) { + return ( + <> + +
+ + +
+ +
+ + +
+ + ); +} diff --git a/src/web/pages/post/events/index.tsx b/src/web/pages/post/events/index.tsx new file mode 100644 index 0000000..f7020df --- /dev/null +++ b/src/web/pages/post/events/index.tsx @@ -0,0 +1,44 @@ +import type { Permission } from '~/core/permission'; +import type { Event } from '~/features/events/model'; +import type { Flash, Server } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { EventList } from './list'; + +interface Props { + upcoming: Event[]; + date: (value: Date | null) => string; + server: Server; + can: ReadonlySet; + flash: Flash; + canManage: (ownerId: string) => boolean; +} + +export function EventPage({ + upcoming, + date, + server, + can, + flash, + canManage, +}: Readonly) { + return ( + New event + ) : null + } + > + + + ); +} diff --git a/src/web/pages/post/events/list.tsx b/src/web/pages/post/events/list.tsx new file mode 100644 index 0000000..cb5e56e --- /dev/null +++ b/src/web/pages/post/events/list.tsx @@ -0,0 +1,53 @@ +import type { Event } from '~/features/events/model'; +import { ActionButton } from '~/web/components/actions'; +import type { Server } from '~/web/context'; + +interface Props { + upcoming: Event[]; + date: (value: Date | null) => string; + server: Server; + canManage: (ownerId: string) => boolean; +} +export function EventList({ + upcoming, + date, + server, + canManage, +}: Readonly) { + return ( + + + + + + + + + + + {upcoming.map((e) => ( + + + + + + + + ))} + +
#TitleStartsChannel +
{e.id}{e.title}{date(e.startsAt)}{server.channelName(e.channelId)} + {canManage(e.organizerId) ? ( + <> + + Edit + {' '} + + + ) : null} +
+ ); +} diff --git a/src/web/pages/post/events/routes.tsx b/src/web/pages/post/events/routes.tsx new file mode 100644 index 0000000..709e243 --- /dev/null +++ b/src/web/pages/post/events/routes.tsx @@ -0,0 +1,148 @@ +import { Hono } from 'hono'; +import { UserError } from '~/core/errors'; +import { visibleRecords } from '~/core/helpers/visibility'; +import { + allows, + back, + checked, + field, + flashOf, + formatter, + inputTime, + owns, + type Env, + type WebDeps, +} from '~/web/context'; +import { NewEventPage } from './create'; +import { EditEventPage } from './edit'; +import { EventPage } from './index'; +import { changesOf, fieldsOf } from './submission'; +import { entryLabel } from '~/features/events/message'; + +export function eventRoutes({ + guildId, + services, + timezone, + directory, +}: WebDeps) { + const date = formatter(timezone); + const time = inputTime(timezone); + + return new Hono() + .get('/', async (c) => { + const upcoming = await visibleRecords( + directory, + c.var.actor, + await services.events.upcoming(guildId), + ); + + return c.html( + owns(c, ownerId, 'event:manage')} + />, + ); + }) + .get('/new', async (c) => { + if (!allows(c, 'event:create')) { + throw new UserError('You need the "event:create" permission.'); + } + + const start = c.req.query('day')?.trim() ?? ''; + const day = + start === '' + ? undefined + : await services.events.sameDay(c.var.actor, start).then( + ({ startsAt, entries }) => ({ + start, + heading: date(startsAt), + entries: entries.map((entry) => entryLabel(entry, timezone)), + }), + (error: unknown) => { + if (error instanceof UserError) { + return { start, error: error.message }; + } + + throw error; + }, + ); + + return c.html( + , + ); + }) + .post('/', async (c) => { + const form = await c.req.formData(); + const reminders = field(form, 'reminders'); + const event = await services.events.create(c.var.actor, { + title: '', + start: '', + ...fieldsOf(form), + channelId: field(form, 'channelId') ?? '', + calendar: checked(form, 'calendar'), + ...(reminders !== undefined && { reminders }), + }); + + return back(c, '/post/events', { notice: `Event #${event.id} created.` }); + }) + .get(String.raw`/:id{\d+}`, async (c) => { + const event = await services.events.get( + c.var.actor, + Number(c.req.param('id')), + ); + + if (!owns(c, event.organizerId, 'event:manage')) { + throw new UserError('Only the organizer can edit this event.'); + } + + return c.html( + , + ); + }) + .post(String.raw`/:id{\d+}`, async (c) => { + const id = Number(c.req.param('id')); + + await services.events.edit( + c.var.actor, + id, + changesOf(await c.req.formData()), + ); + + return back(c, '/post/events', { notice: `Event #${id} updated.` }); + }) + .post(String.raw`/:id{\d+}/calendar`, async (c) => { + const id = Number(c.req.param('id')); + + await services.events.crosspost(c.var.actor, id); + + return back(c, '/post/events', { + notice: `Event #${id} posted to the calendar.`, + }); + }) + .post(String.raw`/:id{\d+}/cancel`, async (c) => { + const id = Number(c.req.param('id')); + + await services.events.cancel(c.var.actor, id); + + return back(c, '/post/events', { notice: `Event #${id} cancelled.` }); + }); +} diff --git a/src/web/pages/post/events/submission.ts b/src/web/pages/post/events/submission.ts new file mode 100644 index 0000000..a2452ce --- /dev/null +++ b/src/web/pages/post/events/submission.ts @@ -0,0 +1,41 @@ +import { checked, field, type Form } from '~/web/context'; + +export const textFields = [ + 'title', + 'start', + 'end', + 'description', + 'location', +] as const; + +export function fieldsOf(form: Form) { + const capacity = field(form, 'capacity'); + + return { + ...Object.fromEntries( + textFields.flatMap((name) => { + const value = field(form, name); + + return value === undefined ? [] : [[name, value]]; + }), + ), + icons: checked(form, 'icons'), + ...(capacity !== undefined && { capacity: Number(capacity) }), + }; +} + +export function changesOf(form: Form) { + const capacity = field(form, 'capacity'); + + return { + ...fieldsOf(form), + ...(form.has('description') && { + description: field(form, 'description') ?? null, + }), + ...(form.has('location') && { location: field(form, 'location') ?? null }), + ...(form.has('end') && { end: field(form, 'end') ?? null }), + ...(form.has('capacity') && { + capacity: capacity === undefined ? null : Number(capacity), + }), + }; +} diff --git a/src/web/pages/post/polls/create.tsx b/src/web/pages/post/polls/create.tsx new file mode 100644 index 0000000..5c1b628 --- /dev/null +++ b/src/web/pages/post/polls/create.tsx @@ -0,0 +1,18 @@ +import type { Permission } from '~/core/permission'; +import type { Flash, Server } from '~/web/context'; +import { Layout } from '~/web/layout'; +import { PollForm } from './form'; + +interface Props { + server: Server; + can: ReadonlySet; + flash: Flash; +} + +export function NewPollPage({ server, can, flash }: Readonly) { + return ( + + + + ); +} diff --git a/src/web/pages/post/polls/form.tsx b/src/web/pages/post/polls/form.tsx new file mode 100644 index 0000000..2c2d9c4 --- /dev/null +++ b/src/web/pages/post/polls/form.tsx @@ -0,0 +1,38 @@ +import { Checkbox } from '~/web/components/choices'; +import { Input, Select, Textarea } from '~/web/components/controls'; +import { ChannelSelect } from '~/web/components/selectors'; +import type { Server } from '~/web/context'; + +interface Props { + server: Server; +} +export function PollForm({ server }: Readonly) { + return ( +
+ +