Unified · Split
| @@ -1,63 +1,6 @@ | ||
| 1 | −# dependencies (bun install) | |
| 2 | −node_modules | |
| 3 | −executor/bun.lock | |
| 4 | − | |
| 5 | −# output | |
| 6 | −out | |
| 7 | −dist | |
| 8 | −*.tgz | |
| 9 | − | |
| 10 | −# code coverage | |
| 11 | −coverage | |
| 12 | −*.lcov | |
| 13 | − | |
| 14 | −# logs | |
| 15 | −logs | |
| 16 | −*.log | |
| 17 | −report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | |
| 18 | − | |
| 19 | −# dotenv environment variable files | |
| 20 | −.env | |
| 21 | −.env.production | |
| 22 | −.env.development.local | |
| 23 | −.env.test.local | |
| 24 | −.env.production.local | |
| 25 | −.env.local | |
| 26 | − | |
| 27 | −# caches | |
| 28 | −.eslintcache | |
| 29 | −.cache | |
| 30 | −*.tsbuildinfo | |
| 31 | 1 | .reference/ |
| 32 | − | |
| 33 | −# IntelliJ based IDEs | |
| 34 | −.idea | |
| 35 | − | |
| 36 | −# Finder (MacOS) folder config | |
| 37 | −.DS_Store | |
| 38 | − | |
| 39 | −# Convex local backend state | |
| 40 | −convex_local_backend.sqlite3 | |
| 41 | −convex_local_storage/ | |
| 42 | − | |
| 43 | −# Local OpenAPI sources service state | |
| 44 | −sources/data/*.sqlite | |
| 45 | −sources/data/*.sqlite-shm | |
| 46 | −sources/data/*.sqlite-wal | |
| 47 | − | |
| 48 | −# Composio toolkit scrape outputs | |
| 49 | −sources/composio-scrape/data/ | |
| 50 | − | |
| 51 | −# Cloudflare Workers local state | |
| 52 | −.wrangler/ | |
| 53 | −.dev.vars | |
| 54 | − | |
| 55 | −# Generated push env file | |
| 56 | −executor/.env.executor-push | |
| 57 | − | |
| 58 | −# Dev runner PID file | |
| 59 | −.dev.pids | |
| 60 | −*.har | |
| 61 | 2 | .vercel |
| 62 | 3 | .env*.local |
| 63 | −.chat-links.json | |
| 4 | +.next/ | |
| 5 | +.turbo/ | |
| 6 | +.executor-v2/ | |
| @@ -1,32 +1,4 @@ | ||
| 1 | 1 | { |
| 2 | − "search.useIgnoreFiles": true, | |
| 3 | − "search.useGlobalIgnoreFiles": true, | |
| 4 | − "search.useParentIgnoreFiles": true, | |
| 5 | − "search.exclude": { | |
| 6 | − "**/node_modules": true, | |
| 7 | − "**/dist": true, | |
| 8 | − "**/.next": true, | |
| 9 | − "**/out": true, | |
| 10 | − "**/coverage": true, | |
| 11 | − "**/.cache": true, | |
| 12 | − "**/.DS_Store": true, | |
| 13 | − "**/.idea": true, | |
| 14 | − "**/.wrangler": true, | |
| 15 | − "**/.turbo": true, | |
| 16 | − "**/.dev.pids": true, | |
| 17 | − "**/.vercel": true, | |
| 18 | − "**/coverage": true, | |
| 19 | − "**/*.env*": true, | |
| 20 | − "**/*.log": true, | |
| 21 | − "**/*.lcov": true, | |
| 22 | − "**/*.tgz": true, | |
| 23 | − "**/*.har": true, | |
| 24 | − "**/*.tsbuildinfo": true, | |
| 25 | − "**/convex_local_storage": true, | |
| 26 | − "**/convex_local_backend.sqlite3": true, | |
| 27 | − "**/sources/data/*.sqlite": true, | |
| 28 | − "**/sources/data/*.sqlite-shm": true, | |
| 29 | − "**/sources/data/*.sqlite-wal": true, | |
| 30 | − "**/.reference/**": true | |
| 31 | − } | |
| 2 | + "typescript.tsdk": "./node_modules/typescript/lib", | |
| 3 | + "typescript.enablePromptUseWorkspaceTsdk": true | |
| 32 | 4 | } |
| @@ -1,167 +1,4 @@ | ||
| 1 | −## AGENTS.md - Monorepo Agent Guide | |
| 2 | − | |
| 3 | −This file is for coding agents working in `/home/rhys/assistant`. | |
| 4 | −It captures project architecture, commands, and code conventions observed in-repo. | |
| 5 | − | |
| 6 | −## Rule Sources Checked | |
| 7 | − | |
| 8 | −- Checked for Cursor rules: `.cursor/rules/**` and `.cursorrules` (none found). | |
| 9 | −- Checked for Copilot rules: `.github/copilot-instructions.md` (none found). | |
| 10 | −- If any of these files are added later, treat them as highest-priority supplements. | |
| 11 | − | |
| 12 | −## Monorepo Layout | |
| 13 | − | |
| 14 | −- `executor/`: primary execution platform (Convex backend, runtimes, Next.js web app, release tooling). | |
| 15 | −- `assistant/`: assistant server + Discord bot + shared core loop + `reacord` package. | |
| 16 | −- `sources/`: Bun service that syncs API catalog data into SQLite. | |
| 17 | −- `dev.ts`: root multi-service dev orchestrator. | |
| 18 | −- `.env.example`: canonical environment template for all projects. | |
| 19 | − | |
| 20 | −## Runtime and Package Manager | |
| 21 | − | |
| 22 | −Default to Bun across this repository. | |
| 23 | − | |
| 24 | −- Use `bun install` for dependencies. | |
| 25 | −- Use `bun run <script>` for scripts. | |
| 26 | −- Use `bun test` for tests. | |
| 27 | −- Use `bunx <tool>` for one-off CLIs. | |
| 28 | −- Bun auto-loads `.env`; avoid adding `dotenv` unless there is a hard requirement. | |
| 29 | − | |
| 30 | −## Build, Lint, Test, Typecheck Commands | |
| 31 | − | |
| 32 | −Run from repo root unless noted. | |
| 33 | − | |
| 34 | −### Main quality commands | |
| 35 | − | |
| 36 | −- `bun run test` - runs executor fast suite + assistant tests. | |
| 37 | −- `bun run typecheck` - runs executor + assistant TypeScript checks. | |
| 38 | −- `bun run knip` - dead-code/unused-export scan. | |
| 39 | − | |
| 40 | −### Package-specific quality commands | |
| 41 | − | |
| 42 | −- `bun run test:executor` - executor fast/normal tests (`bun run --cwd executor test`). | |
| 43 | −- `bun run test:executor:integration` - executor integration tests (`bun run --cwd executor test:integration`). | |
| 44 | −- `bun run test:executor:e2e` - executor e2e tests (`bun run --cwd executor test:e2e`). | |
| 45 | −- `bun run test:executor:all` - all executor tests (`bun run --cwd executor test:all`). | |
| 46 | −- `bun run test:assistant` - assistant tests (`assistant/packages/core/src`). | |
| 47 | −- `bun run typecheck:executor` - `tsc --noEmit -p executor/tsconfig.json`. | |
| 48 | −- `bun run typecheck:assistant` - checks server + bot tsconfig files. | |
| 49 | −- `bun run --cwd executor/apps/web lint` - ESLint for Next.js web app. | |
| 50 | − | |
| 51 | −- `bun run --cwd executor build:binary` - host-native binary build. | |
| 52 | −- `bun run --cwd executor/apps/web build` - Next.js production build. | |
| 53 | − | |
| 54 | −### Dev commands | |
| 55 | − | |
| 56 | −- `bun run dev` - starts sources, convex dev, sandbox worker, web, assistant, optional bot. | |
| 57 | −- `bun run kill:all` - stop processes started by `dev.ts`. | |
| 58 | −- `bun run dev:executor:web` / `bun run dev:assistant` / `bun run dev:bot` - focused dev loops. | |
| 59 | − | |
| 60 | −### Run a single test file (important) | |
| 61 | − | |
| 62 | −- `bun test executor/packages/core/src/tool-discovery.test.ts` | |
| 63 | −- `bun test executor/packages/convex/access-controls.test.ts` | |
| 64 | −- `bun test assistant/packages/core/src/agent.test.ts` | |
| 65 | − | |
| 66 | −### Run a single test by name | |
| 67 | − | |
| 68 | −- `bun test executor/packages/core/src/tool-discovery.test.ts --test-name-pattern "discover returns aliases"` | |
| 69 | −- `bun test --test-name-pattern "workspace admin can upsert access policies"` | |
| 70 | − | |
| 71 | −## High-Level Architecture | |
| 72 | − | |
| 73 | −### Executor (core platform) | |
| 74 | − | |
| 75 | −- Convex functions in `executor/packages/convex/**` own tasks, authz, approvals, billing, and persistence. | |
| 76 | −- MCP HTTP surface is defined in `executor/packages/convex/http.ts` (`/mcp`, `/mcp/anonymous`, OAuth metadata routes). | |
| 77 | −- Runtime/tool engine logic lives in `executor/packages/core/src/**`. | |
| 78 | −- Sandbox host for Cloudflare worker runtime is `executor/packages/runner-sandbox-host`. | |
| 79 | −- Operator UI is Next.js in `executor/apps/web` and loads a client-side React Router app shell. | |
| 80 | − | |
| 81 | −### Assistant | |
| 82 | − | |
| 83 | −- `assistant/packages/server`: Elysia API that resolves user context and invokes core agent. | |
| 84 | −- `assistant/packages/core`: model + MCP tool loop. | |
| 85 | −- `assistant/packages/bot`: Discord integration and link flows. | |
| 86 | −- `assistant/packages/reacord`: Effect-based Discord React reconciler package. | |
| 87 | − | |
| 88 | −- `sources/`: Bun HTTP sync service + SQLite catalog ingester. | |
| 89 | − | |
| 90 | −## How To Write Code Here | |
| 91 | − | |
| 92 | −### TypeScript and typing | |
| 93 | − | |
| 94 | −- Project is strict TS (`strict: true` broadly enabled); keep new code fully typed. | |
| 95 | −- Prefer explicit interfaces/types for public function boundaries. | |
| 96 | −- Use `type`-only imports where possible (`import type { ... }`). | |
| 97 | −- Use existing shared types (`executor/packages/core/src/types.ts`) before inventing duplicates. | |
| 98 | −- In Convex code, validate inputs with `v.*` validators and preserve arg schemas. | |
| 99 | − | |
| 100 | −### Imports and module boundaries | |
| 101 | − | |
| 102 | −- Keep imports grouped: external packages first, workspace/internal modules second. | |
| 103 | −- Web app uses `@/` aliases inside `executor/apps/web`. | |
| 104 | −- Avoid deep cross-package reach-ins unless already established by the package. | |
| 105 | −- Do not edit generated Convex files under `executor/packages/convex/_generated/**`. | |
| 106 | − | |
| 107 | −### Naming and file conventions | |
| 108 | − | |
| 109 | −- Prefer `camelCase` for variables/functions and `PascalCase` for React components/types. | |
| 110 | −- Match local file naming conventions: | |
| 111 | − - Web UI files are mostly `kebab-case.ts(x)`. | |
| 112 | − - Some executor/convex internals use `snake_case.ts`. | |
| 113 | −- Keep existing API/event string names unchanged unless migration is intentional. | |
| 114 | − | |
| 115 | −### Formatting and style | |
| 116 | − | |
| 117 | −- No single formatter is enforced across all packages; preserve local style per file. | |
| 118 | −- Many backend files use semicolons; many shadcn-style UI primitives omit semicolons. | |
| 119 | −- Do not perform broad reformat-only edits. | |
| 120 | −- Follow existing section-divider comment style when useful (the `// --------` blocks). | |
| 121 | − | |
| 122 | −### Error handling | |
| 123 | − | |
| 124 | −- Fail fast on invalid inputs with clear `Error` messages. | |
| 125 | −- Wrap external/network calls and include status/context in thrown errors. | |
| 126 | −- For recoverable UI/API flows, return structured errors instead of swallowing failures. | |
| 127 | −- In Convex auth/access paths, use existing access helpers (`workspaceMutation`, `workspaceQuery`, etc.). | |
| 128 | −- Preserve best-effort behavior where already intended (e.g., scheduler prewarm calls in `try/catch`). | |
| 129 | − | |
| 130 | −### Framework-specific patterns | |
| 131 | − | |
| 132 | −- Prefer Bun-native APIs for new runtime services (`Bun.serve`, `Bun.file`, `bun:sqlite`) unless package context requires Node APIs. | |
| 133 | −- In Next routes and async boundaries, use existing `Result.try` / `Result.tryPromise` patterns where present. | |
| 134 | −- For Convex functions, keep public APIs in top-level files (`workspace.ts`, `organizations.ts`) and DB access in `database/**`. | |
| 135 | −- In React, reuse existing UI primitives and helpers (`cn`, shadcn components, shared hooks). | |
| 136 | − | |
| 137 | −## Testing Guidelines | |
| 138 | − | |
| 139 | −- Use `bun:test` (`import { test, expect } from "bun:test"`). | |
| 140 | −- Keep tests close to code with `.test.ts` / `.e2e.test.ts` naming. | |
| 141 | −- Keep scheduler behavior test-safe by default; do not require `DISABLE_CONVEX_SCHEDULER=1` to run the normal fast suite. | |
| 142 | −- When changing Convex auth/access logic, add/adjust permission tests in `executor/packages/convex/access-controls.test.ts`. | |
| 143 | −- When changing tool discovery/typing behavior, update tests in `executor/packages/core/src/*.test.ts`. | |
| 144 | − | |
| 145 | −## User Preferences (Observed) | |
| 146 | − | |
| 147 | −- Preserve local/cloud parity: prefer the same architecture and runtime behavior in both environments. | |
| 148 | −- Reduce complexity by enforcing write-time invariants over read-time repair (`ensure*` backfills should be minimal and clearly scoped). | |
| 149 | −- For greenfield iterations, prefer clearing/resetting the DB over adding one-off migrations. | |
| 150 | −- Keep default feedback loops fast: split tests into fast, integration, and e2e buckets and make fast the default. | |
| 151 | −- Favor practical simplification over theoretical abstractions when refactoring data models and auth flows. | |
| 152 | − | |
| 153 | −## Generated/Build Artifacts | |
| 154 | − | |
| 155 | −- Do not manually edit generated/build outputs such as: | |
| 156 | − - `executor/packages/convex/_generated/**` | |
| 157 | − - `.next/**` | |
| 158 | − - `dist/**` (unless task is explicitly about release artifacts) | |
| 159 | − | |
| 160 | −## Environment and Secrets | |
| 161 | − | |
| 162 | −- Use `.env.example` as the source-of-truth variable list. | |
| 163 | −- Never hardcode secrets/tokens in code or tests. | |
| 164 | −- Redact secrets in logs and API responses (follow existing credential redaction patterns). | |
| 1 | +# v2 Agent Notes | |
| 165 | 2 | |
| 166 | 3 | <!-- effect-solutions:start --> |
| 167 | 4 | |
| @@ -177,10 +14,4 @@ Topics: quick-start, project-setup, tsconfig, basics, services-and-layers, data- · 9 unmodified lines | ||
| 177 | 14 | |
| 178 | 15 | Never guess at Effect patterns - check the guide first. |
| 179 | 16 | |
| 180 | −- Prefer Effect-native helpers/combinators over manual branching when possible (e.g. `Result.match`, `Result.isSuccess`, `Effect.catchTag`, `ParseResult` formatters). | |
| 181 | −- Avoid ad-hoc `_tag` checks and `instanceof Error` fallbacks in business logic when a typed/tagged Effect error path exists. | |
| 182 | −- Keep error/result mapping centralized in atoms/services/handlers rather than spread through UI components. | |
| 183 | − | |
| 184 | 17 | <!-- effect-solutions:end --> |
| 185 | − | |
| 186 | −Unless I explicitly state otherwise, the request relates to this codebase. i.e "add the deepwiki MCP to the default sources" means look through the codebase for how thats relevant, not update opencode config | |
File renamed without changes.
| @@ -1,114 +1,9 @@ | ||
| 1 | −# Assistant + Executor Monorepo | |
| 1 | +# Executor v2 Scaffold | |
| 2 | 2 | |
| 3 | −This repository contains two related projects in one Bun workspace: | |
| 3 | +This directory is a fresh monorepo scaffold for the Executor v2 architecture. | |
| 4 | 4 | |
| 5 | −- `executor/`: task execution platform (Convex backend, MCP endpoints, approvals, tool discovery, web app, binary CLI installer). | |
| 6 | −- `assistant/`: assistant-side services and Discord bot integrations that call into executor. | |
| 5 | +## Included | |
| 7 | 6 | |
| 8 | −Most active platform work is in `executor/`, but root scripts are set up to run both sides together. | |
| 9 | − | |
| 10 | −## Monorepo Structure | |
| 11 | − | |
| 12 | −The root `package.json` wires workspaces for: | |
| 13 | − | |
| 14 | −- `executor/apps/*` | |
| 15 | −- `executor/packages/*` | |
| 16 | −- `assistant` | |
| 17 | −- `assistant/packages/*` | |
| 18 | − | |
| 19 | −High-level layout: | |
| 20 | − | |
| 21 | −```text | |
| 22 | −. | |
| 23 | −|- assistant/ # assistant monorepo (core, server, bot, reacord) | |
| 24 | −|- executor/ # executor platform and binary install tooling | |
| 25 | −|- dev.ts # root orchestrator: starts all main dev services | |
| 26 | −|- kill-all.ts # cleanup for dev.ts processes | |
| 27 | −|- .env.example # canonical env template for the whole repo | |
| 28 | −`- package.json # root scripts + workspace graph | |
| 29 | −``` | |
| 30 | − | |
| 31 | −## Prerequisites | |
| 32 | − | |
| 33 | −- Bun (required) | |
| 34 | −- Convex account/project (for source dev against a Convex deployment) | |
| 35 | −- Optional: Discord bot token, WorkOS and Stripe credentials | |
| 36 | − | |
| 37 | −## Quick Start | |
| 38 | − | |
| 39 | −1. Install dependencies from the repository root: | |
| 40 | − | |
| 41 | −```bash | |
| 42 | −bun install | |
| 43 | −``` | |
| 44 | − | |
| 45 | −2. Create local env file: | |
| 46 | − | |
| 47 | −```bash | |
| 48 | −cp .env.example .env | |
| 49 | −``` | |
| 50 | − | |
| 51 | −3. Set required values in `.env`: | |
| 52 | − | |
| 53 | −- `CONVEX_DEPLOYMENT` | |
| 54 | −- `CONVEX_URL` | |
| 55 | − | |
| 56 | −4. Start the full stack: | |
| 57 | − | |
| 58 | −```bash | |
| 59 | −bun run dev | |
| 60 | −``` | |
| 61 | − | |
| 62 | −`bun run dev` starts, in parallel: | |
| 63 | − | |
| 64 | −- Convex dev watcher for `executor/` | |
| 65 | −- Executor web app (`http://localhost:4312`) | |
| 66 | −- Executor MCP endpoint (`<CONVEX_SITE_URL>/mcp`) | |
| 67 | −- Assistant server (`http://localhost:3002`) | |
| 68 | −- Discord bot (only if `DISCORD_BOT_TOKEN` is set) | |
| 69 | − | |
| 70 | −PIDs are tracked in `.dev.pids`. To stop all processes: | |
| 71 | − | |
| 72 | −```bash | |
| 73 | −bun run kill:all | |
| 74 | −``` | |
| 75 | − | |
| 76 | −## Common Root Commands | |
| 77 | − | |
| 78 | −```bash | |
| 79 | −# Development | |
| 80 | −bun run dev | |
| 81 | −bun run kill:all | |
| 82 | − | |
| 83 | −# Quality | |
| 84 | −bun run test | |
| 85 | −bun run typecheck | |
| 86 | − | |
| 87 | −# Executor utilities | |
| 88 | −bun run db:clear:executor | |
| 89 | −bun run convex:codegen | |
| 90 | −``` | |
| 91 | − | |
| 92 | −## Environment Model | |
| 93 | − | |
| 94 | −This repo uses a single root `.env` as the source of truth. | |
| 95 | − | |
| 96 | −- `assistant` and `executor` scripts read from root env-aware wrappers. | |
| 97 | −- `executor/apps/web` is a TanStack Start app; canonical vars are consumed by the app and injected at runtime. | |
| 98 | −- Client-facing values use `VITE_*` names where needed. | |
| 99 | −- See `.env.example` for optional WorkOS, Stripe, tool-source API keys, and port overrides. | |
| 100 | − | |
| 101 | −## Project Notes | |
| 102 | − | |
| 103 | −- The assistant side lives in `assistant/` (server, bot, shared core). | |
| 104 | −- The execution/control plane lives in `executor/`. | |
| 105 | −- If you are focused on executor internals, start with `executor/README.md`. | |
| 106 | − | |
| 107 | −## Testing and Type Safety | |
| 108 | − | |
| 109 | −From root: | |
| 110 | − | |
| 111 | −- `bun run test` runs executor and assistant tests. | |
| 112 | −- `bun run typecheck` runs TypeScript checks for executor and assistant packages. | |
| 113 | − | |
| 114 | −You can also run package-local checks directly from each subproject. | |
| 7 | +- Workspace root `package.json` and `tsconfig.json` | |
| 8 | +- App and package folders with `src/`, `package.json`, `tsconfig.json`, and `README.md` | |
| 9 | +- No implementation files yet | |
File renamed without changes.
File renamed without changes.
File renamed without changes.
| @@ -0,0 +1 @@ | ||
| 1 | +../convex/bin/main.js | |
| @@ -0,0 +1 @@ | ||
| 1 | +../typescript/bin/tsc | |
| @@ -0,0 +1 @@ | ||
| 1 | +../typescript/bin/tsserver | |
| @@ -0,0 +1 @@ | ||
| 1 | +../vitest/vitest.mjs | |
| @@ -0,0 +1 @@ | ||
| 1 | +../yaml/bin.mjs | |
| @@ -0,0 +1 @@ | ||
| 1 | +{"version":"3.2.4","results":[[":api/parse-openapi.fidelity.test.ts",{"duration":15450.162534,"failed":false}]]} | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@effect+vitest@0.27.0+745106daec5afff3/node_modules/@effect/vitest | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@types+node@20.19.33/node_modules/@types/node | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/convex@1.32.0+b1ab299f0a400331/node_modules/convex | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/effect@3.19.19/node_modules/effect | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/typescript@5.9.3/node_modules/typescript | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/vitest@3.2.4+dddfa60a3fc73abb/node_modules/vitest | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/yaml@2.8.2/node_modules/yaml | |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
| @@ -0,0 +1 @@ | ||
| 1 | +../convex/bin/main.js | |
| @@ -0,0 +1 @@ | ||
| 1 | +../vitest/vitest.mjs | |
| @@ -0,0 +1 @@ | ||
| 1 | +{"version":"3.2.4","results":[[":convex/executor.test.ts",{"duration":746.3599650000001,"failed":false}],[":convex/sources.test.ts",{"duration":235.0589490000002,"failed":false}]]} | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@convex-dev+workflow@0.3.4+e4a957bbb87593a0/node_modules/@convex-dev/workflow | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@effect+vitest@0.27.0+745106daec5afff3/node_modules/@effect/vitest | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/confect | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/control-plane | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/domain | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/engine | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/management-api | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/mcp-gateway | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/state-convex | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/state-contracts | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/rpc | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/runtime-cloudflare-worker-loader | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/runtime-local-inproc | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/schema | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/sdk | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/state-convex | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@workos-inc+node@8.7.0/node_modules/@workos-inc/node | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/convex@1.32.0+b1ab299f0a400331/node_modules/convex | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../packages/convex-test | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/effect@3.19.19/node_modules/effect | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/jose@6.1.3/node_modules/jose | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/vitest@3.2.4+dddfa60a3fc73abb/node_modules/vitest | |
| @@ -10,6 +10,7 @@ · 9 unmodified lines | ||
| 10 | 10 | }, |
| 11 | 11 | "dependencies": { |
| 12 | 12 | "@convex-dev/workflow": "^0.3.4", |
| 13 | + "@modelcontextprotocol/sdk": "^1.27.1", | |
| 13 | 14 | "@executor-v2/confect": "workspace:*", |
| 14 | 15 | "@executor-v2/domain": "workspace:*", |
| 15 | 16 | "@executor-v2/engine": "workspace:*", |
| @@ -20,7 +21,8 @@ · 4 unmodified lines | ||
| 20 | 21 | "@executor-v2/schema": "workspace:*", |
| 21 | 22 | "@executor-v2/sdk": "workspace:*", |
| 22 | 23 | "convex": "catalog:", |
| 23 | − "effect": "catalog:" | |
| 24 | + "effect": "catalog:", | |
| 25 | + "jose": "^6.1.0" | |
| 24 | 26 | }, |
| 25 | 27 | "devDependencies": { |
| 26 | 28 | "@effect/vitest": "catalog:", |
File renamed without changes.
File renamed without changes.
File renamed without changes.
| @@ -0,0 +1 @@ | ||
| 1 | +../vitest/vitest.mjs | |
| @@ -0,0 +1 @@ | ||
| 1 | +{"version":"3.2.4","results":[[":src/tool-call-handler.test.ts",{"duration":65.40639299999975,"failed":false}],[":src/execute.e2e.test.ts",{"duration":1312.0678289999998,"failed":false}],[":src/sources-handler.test.ts",{"duration":90.26854400000002,"failed":false}],[":src/persistent-approval-policy.test.ts",{"duration":66.12446200000022,"failed":false}],[":src/storage-service.test.ts",{"duration":96.20161000000007,"failed":false}]]} | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@effect+platform-bun@0.86.0+e085871485f58d8a/node_modules/@effect/platform-bun | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@effect+vitest@0.27.0+745106daec5afff3/node_modules/@effect/vitest | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/control-plane | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/domain | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/engine | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/management-api | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/mcp-gateway | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/state-local-file | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/state-contracts | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/rpc | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/runtime-cloudflare-worker-loader | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/runtime-deno-subprocess | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/runtime-local-inproc | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/schema | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/sdk | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../packages/source-manager | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../../node_modules/.bun/@modelcontextprotocol+sdk@1.27.1/node_modules/@modelcontextprotocol/sdk | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/effect@3.19.19/node_modules/effect | |
| @@ -0,0 +1 @@ | ||
| 1 | +../../../node_modules/.bun/vitest@3.2.4+dddfa60a3fc73abb/node_modules/vitest | |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
| @@ -0,0 +1 @@ | ||
| 1 | +../next/dist/bin/next | |
| @@ -0,0 +1 @@ | ||
| 1 | +../tldts/bin/cli.js | |
| @@ -0,0 +1 @@ | ||
| 1 | +../vite/bin/vite.js | |
| @@ -0,0 +1 @@ | ||
| 1 | +../vitest/vitest.mjs | |
| @@ -0,0 +1,294 @@ | ||
| 1 | +import { | |
| 2 | + require_scheduler | |
| 3 | +} from "./chunk-VISJ3ZMH.js"; | |
| 4 | +import { | |
| 5 | + require_react | |
| 6 | +} from "./chunk-4IK2VPRV.js"; | |
| 7 | +import { | |
| 8 | + AtomHttpApi_exports, | |
| 9 | + AtomRef_exports, | |
| 10 | + AtomRpc_exports, | |
| 11 | + Atom_exports, | |
| 12 | + Hydration_exports, | |
| 13 | + Registry_exports, | |
| 14 | + Result_exports, | |
| 15 | + getResult, | |
| 16 | + getServerValue, | |
| 17 | + make, | |
| 18 | + map | |
| 19 | +} from "./chunk-LVLGAPNT.js"; | |
| 20 | +import "./chunk-4SMLXLLX.js"; | |
| 21 | +import "./chunk-ZXM2CMI2.js"; | |
| 22 | +import "./chunk-ZQSAFZCP.js"; | |
| 23 | +import "./chunk-5O7CUVLV.js"; | |
| 24 | +import "./chunk-SF36ZBUI.js"; | |
| 25 | +import "./chunk-6MBN5S2E.js"; | |
| 26 | +import "./chunk-HVF2XBK2.js"; | |
| 27 | +import "./chunk-3LT46UFL.js"; | |
| 28 | +import { | |
| 29 | + Effect_exports | |
| 30 | +} from "./chunk-LXSJW2UJ.js"; | |
| 31 | +import { | |
| 32 | + isSuccess2 as isSuccess, | |
| 33 | + squash | |
| 34 | +} from "./chunk-UYCMDTGT.js"; | |
| 35 | +import "./chunk-B5FOTKVA.js"; | |
| 36 | +import "./chunk-7GS5HKXM.js"; | |
| 37 | +import "./chunk-JDLTRRA5.js"; | |
| 38 | +import "./chunk-RG46YT3R.js"; | |
| 39 | +import "./chunk-5XJTUU64.js"; | |
| 40 | +import { | |
| 41 | + globalValue | |
| 42 | +} from "./chunk-SPGJQP32.js"; | |
| 43 | +import "./chunk-LX4DLJUA.js"; | |
| 44 | +import { | |
| 45 | + __export, | |
| 46 | + __toESM | |
| 47 | +} from "./chunk-G3PMV62Z.js"; | |
| 48 | + | |
| 49 | +// ../../node_modules/.bun/@effect-atom+atom-react@0.4.6+5d30bd2b706d99e1/node_modules/@effect-atom/atom-react/dist/esm/ScopedAtom.js | |
| 50 | +var ScopedAtom_exports = {}; | |
| 51 | +__export(ScopedAtom_exports, { | |
| 52 | + TypeId: () => TypeId, | |
| 53 | + make: () => make2 | |
| 54 | +}); | |
| 55 | +var React = __toESM(require_react(), 1); | |
| 56 | +var TypeId = "~@effect-atom/atom-react/ScopedAtom"; | |
| 57 | +var make2 = (f) => { | |
| 58 | + const Context = React.createContext(void 0); | |
| 59 | + const use = () => { | |
| 60 | + const atom = React.useContext(Context); | |
| 61 | + if (atom === void 0) { | |
| 62 | + throw new Error("ScopedAtom used outside of its Provider"); | |
| 63 | + } | |
| 64 | + return atom; | |
| 65 | + }; | |
| 66 | + const Provider = ({ | |
| 67 | + children, | |
| 68 | + value | |
| 69 | + }) => { | |
| 70 | + const atom = React.useRef(null); | |
| 71 | + if (atom.current === null) { | |
| 72 | + atom.current = f(value); | |
| 73 | + } | |
| 74 | + return React.createElement(Context.Provider, { | |
| 75 | + value: atom.current | |
| 76 | + }, children); | |
| 77 | + }; | |
| 78 | + return { | |
| 79 | + [TypeId]: TypeId, | |
| 80 | + use, | |
| 81 | + Provider, | |
| 82 | + Context | |
| 83 | + }; | |
| 84 | +}; | |
| 85 | + | |
| 86 | +// ../../node_modules/.bun/@effect-atom+atom-react@0.4.6+5d30bd2b706d99e1/node_modules/@effect-atom/atom-react/dist/esm/Hooks.js | |
| 87 | +var React3 = __toESM(require_react(), 1); | |
| 88 | + | |
| 89 | +// ../../node_modules/.bun/@effect-atom+atom-react@0.4.6+5d30bd2b706d99e1/node_modules/@effect-atom/atom-react/dist/esm/RegistryContext.js | |
| 90 | +var React2 = __toESM(require_react(), 1); | |
| 91 | +var Scheduler = __toESM(require_scheduler(), 1); | |
| 92 | +function scheduleTask(f) { | |
| 93 | + Scheduler.unstable_scheduleCallback(Scheduler.unstable_LowPriority, f); | |
| 94 | +} | |
| 95 | +var RegistryContext = React2.createContext(make({ | |
| 96 | + scheduleTask, | |
| 97 | + defaultIdleTTL: 400 | |
| 98 | +})); | |
| 99 | +var RegistryProvider = (options) => { | |
| 100 | + const ref = React2.useRef(null); | |
| 101 | + if (ref.current === null) { | |
| 102 | + ref.current = { | |
| 103 | + registry: make({ | |
| 104 | + scheduleTask: options.scheduleTask ?? scheduleTask, | |
| 105 | + initialValues: options.initialValues, | |
| 106 | + timeoutResolution: options.timeoutResolution, | |
| 107 | + defaultIdleTTL: options.defaultIdleTTL | |
| 108 | + }) | |
| 109 | + }; | |
| 110 | + } | |
| 111 | + React2.useEffect(() => { | |
| 112 | + if (ref.current?.timeout !== void 0) { | |
| 113 | + clearTimeout(ref.current.timeout); | |
| 114 | + } | |
| 115 | + return () => { | |
| 116 | + ref.current.timeout = setTimeout(() => { | |
| 117 | + ref.current?.registry.dispose(); | |
| 118 | + ref.current = null; | |
| 119 | + }, 500); | |
| 120 | + }; | |
| 121 | + }, [ref]); | |
| 122 | + return React2.createElement(RegistryContext.Provider, { | |
| 123 | + value: ref.current.registry | |
| 124 | + }, options?.children); | |
| 125 | +}; | |
| 126 | + | |
| 127 | +// ../../node_modules/.bun/@effect-atom+atom-react@0.4.6+5d30bd2b706d99e1/node_modules/@effect-atom/atom-react/dist/esm/Hooks.js | |
| 128 | +var storeRegistry = globalValue("@effect-atom/atom-react/storeRegistry", () => /* @__PURE__ */ new WeakMap()); | |
| 129 | +function makeStore(registry, atom) { | |
| 130 | + let stores = storeRegistry.get(registry); | |
| 131 | + if (stores === void 0) { | |
| 132 | + stores = /* @__PURE__ */ new WeakMap(); | |
| 133 | + storeRegistry.set(registry, stores); | |
| 134 | + } | |
| 135 | + const store = stores.get(atom); | |
| 136 | + if (store !== void 0) { | |
| 137 | + return store; | |
| 138 | + } | |
| 139 | + const newStore = { | |
| 140 | + subscribe(f) { | |
| 141 | + return registry.subscribe(atom, f); | |
| 142 | + }, | |
| 143 | + snapshot() { | |
| 144 | + return registry.get(atom); | |
| 145 | + }, | |
| 146 | + getServerSnapshot() { | |
| 147 | + return getServerValue(atom, registry); | |
| 148 | + } | |
| 149 | + }; | |
| 150 | + stores.set(atom, newStore); | |
| 151 | + return newStore; | |
| 152 | +} | |
| 153 | +function useStore(registry, atom) { | |
| 154 | + const store = makeStore(registry, atom); | |
| 155 | + return React3.useSyncExternalStore(store.subscribe, store.snapshot, store.getServerSnapshot); | |
| 156 | +} | |
| 157 | +var initialValuesSet = globalValue("@effect-atom/atom-react/initialValuesSet", () => /* @__PURE__ */ new WeakMap()); | |
| 158 | +var useAtomInitialValues = (initialValues) => { | |
| 159 | + const registry = React3.useContext(RegistryContext); | |
| 160 | + let set = initialValuesSet.get(registry); | |
| 161 | + if (set === void 0) { | |
| 162 | + set = /* @__PURE__ */ new WeakSet(); | |
| 163 | + initialValuesSet.set(registry, set); | |
| 164 | + } | |
| 165 | + for (const [atom, value] of initialValues) { | |
| 166 | + if (!set.has(atom)) { | |
| 167 | + set.add(atom); | |
| 168 | + registry.ensureNode(atom).setValue(value); | |
| 169 | + } | |
| 170 | + } | |
| 171 | +}; | |
| 172 | +var useAtomValue = (atom, f) => { | |
| 173 | + const registry = React3.useContext(RegistryContext); | |
| 174 | + if (f) { | |
| 175 | + const atomB = React3.useMemo(() => map(atom, f), [atom, f]); | |
| 176 | + return useStore(registry, atomB); | |
| 177 | + } | |
| 178 | + return useStore(registry, atom); | |
| 179 | +}; | |
| 180 | +function mountAtom(registry, atom) { | |
| 181 | + React3.useEffect(() => registry.mount(atom), [atom, registry]); | |
| 182 | +} | |
| 183 | +function setAtom(registry, atom, options) { | |
| 184 | + if (options?.mode === "promise" || options?.mode === "promiseExit") { | |
| 185 | + return React3.useCallback((value) => { | |
| 186 | + registry.set(atom, value); | |
| 187 | + const promise = Effect_exports.runPromiseExit(getResult(registry, atom, { | |
| 188 | + suspendOnWaiting: true | |
| 189 | + })); | |
| 190 | + return options.mode === "promise" ? promise.then(flattenExit) : promise; | |
| 191 | + }, [registry, atom, options.mode]); | |
| 192 | + } | |
| 193 | + return React3.useCallback((value) => { | |
| 194 | + registry.set(atom, typeof value === "function" ? value(registry.get(atom)) : value); | |
| 195 | + }, [registry, atom]); | |
| 196 | +} | |
| 197 | +var flattenExit = (exit) => { | |
| 198 | + if (isSuccess(exit)) return exit.value; | |
| 199 | + throw squash(exit.cause); | |
| 200 | +}; | |
| 201 | +var useAtomMount = (atom) => { | |
| 202 | + const registry = React3.useContext(RegistryContext); | |
| 203 | + mountAtom(registry, atom); | |
| 204 | +}; | |
| 205 | +var useAtomSet = (atom, options) => { | |
| 206 | + const registry = React3.useContext(RegistryContext); | |
| 207 | + mountAtom(registry, atom); | |
| 208 | + return setAtom(registry, atom, options); | |
| 209 | +}; | |
| 210 | +var useAtomRefresh = (atom) => { | |
| 211 | + const registry = React3.useContext(RegistryContext); | |
| 212 | + mountAtom(registry, atom); | |
| 213 | + return React3.useCallback(() => { | |
| 214 | + registry.refresh(atom); | |
| 215 | + }, [registry, atom]); | |
| 216 | +}; | |
| 217 | +var useAtom = (atom, options) => { | |
| 218 | + const registry = React3.useContext(RegistryContext); | |
| 219 | + return [useStore(registry, atom), setAtom(registry, atom, options)]; | |
| 220 | +}; | |
| 221 | +var atomPromiseMap = globalValue("@effect-atom/atom-react/atomPromiseMap", () => ({ | |
| 222 | + suspendOnWaiting: /* @__PURE__ */ new Map(), | |
| 223 | + default: /* @__PURE__ */ new Map() | |
| 224 | +})); | |
| 225 | +function atomToPromise(registry, atom, suspendOnWaiting) { | |
| 226 | + const map2 = suspendOnWaiting ? atomPromiseMap.suspendOnWaiting : atomPromiseMap.default; | |
| 227 | + let promise = map2.get(atom); | |
| 228 | + if (promise !== void 0) { | |
| 229 | + return promise; | |
| 230 | + } | |
| 231 | + promise = new Promise((resolve) => { | |
| 232 | + const dispose = registry.subscribe(atom, (result) => { | |
| 233 | + if (result._tag === "Initial" || suspendOnWaiting && result.waiting) { | |
| 234 | + return; | |
| 235 | + } | |
| 236 | + setTimeout(dispose, 1e3); | |
| 237 | + resolve(); | |
| 238 | + map2.delete(atom); | |
| 239 | + }); | |
| 240 | + }); | |
| 241 | + map2.set(atom, promise); | |
| 242 | + return promise; | |
| 243 | +} | |
| 244 | +function atomResultOrSuspend(registry, atom, suspendOnWaiting) { | |
| 245 | + const value = useStore(registry, atom); | |
| 246 | + if (value._tag === "Initial" || suspendOnWaiting && value.waiting) { | |
| 247 | + throw atomToPromise(registry, atom, suspendOnWaiting); | |
| 248 | + } | |
| 249 | + return value; | |
| 250 | +} | |
| 251 | +var useAtomSuspense = (atom, options) => { | |
| 252 | + const registry = React3.useContext(RegistryContext); | |
| 253 | + const result = atomResultOrSuspend(registry, atom, options?.suspendOnWaiting ?? false); | |
| 254 | + if (result._tag === "Failure" && !options?.includeFailure) { | |
| 255 | + throw squash(result.cause); | |
| 256 | + } | |
| 257 | + return result; | |
| 258 | +}; | |
| 259 | +var useAtomSubscribe = (atom, f, options) => { | |
| 260 | + const registry = React3.useContext(RegistryContext); | |
| 261 | + React3.useEffect(() => registry.subscribe(atom, f, options), [registry, atom, f, options?.immediate]); | |
| 262 | +}; | |
| 263 | +var useAtomRef = (ref) => { | |
| 264 | + const [, setValue] = React3.useState(ref.value); | |
| 265 | + React3.useEffect(() => ref.subscribe(setValue), [ref]); | |
| 266 | + return ref.value; | |
| 267 | +}; | |
| 268 | +var useAtomRefProp = (ref, prop) => React3.useMemo(() => ref.prop(prop), [ref, prop]); | |
| 269 | +var useAtomRefPropValue = (ref, prop) => useAtomRef(useAtomRefProp(ref, prop)); | |
| 270 | +export { | |
| 271 | + Atom_exports as Atom, | |
| 272 | + AtomHttpApi_exports as AtomHttpApi, | |
| 273 | + AtomRef_exports as AtomRef, | |
| 274 | + AtomRpc_exports as AtomRpc, | |
| 275 | + Hydration_exports as Hydration, | |
| 276 | + Registry_exports as Registry, | |
| 277 | + RegistryContext, | |
| 278 | + RegistryProvider, | |
| 279 | + Result_exports as Result, | |
| 280 | + ScopedAtom_exports as ScopedAtom, | |
| 281 | + scheduleTask, | |
| 282 | + useAtom, | |
| 283 | + useAtomInitialValues, | |
| 284 | + useAtomMount, | |
| 285 | + useAtomRef, | |
| 286 | + useAtomRefProp, | |
| 287 | + useAtomRefPropValue, | |
| 288 | + useAtomRefresh, | |
| 289 | + useAtomSet, | |
| 290 | + useAtomSubscribe, | |
| 291 | + useAtomSuspense, | |
| 292 | + useAtomValue | |
| 293 | +}; | |
| 294 | +//# sourceMappingURL=@effect-atom_atom-react.js.map | |
| @@ -0,0 +1,7 @@ | ||
| 1 | +{ | |
| 2 | + "version": 3, | |
| 3 | + "sources": ["../../../../../node_modules/.bun/@effect-atom+atom-react@0.4.6+5d30bd2b706d99e1/node_modules/@effect-atom/atom-react/src/ScopedAtom.ts", "../../../../../node_modules/.bun/@effect-atom+atom-react@0.4.6+5d30bd2b706d99e1/node_modules/@effect-atom/atom-react/src/Hooks.ts", "../../../../../node_modules/.bun/@effect-atom+atom-react@0.4.6+5d30bd2b706d99e1/node_modules/@effect-atom/atom-react/src/RegistryContext.ts"], | |
| 4 | + "sourcesContent": ["/**\n * @since 1.0.0\n */\n\"use client\"\nimport type * as Atom from \"@effect-atom/atom/Atom\"\nimport * as React from \"react\"\n\n/**\n * @since 1.0.0\n * @category Type IDs\n */\nexport type TypeId = \"~@effect-atom/atom-react/ScopedAtom\"\n\n/**\n * @since 1.0.0\n * @category Type IDs\n */\nexport const TypeId: TypeId = \"~@effect-atom/atom-react/ScopedAtom\"\n\n/**\n * @since 1.0.0\n * @category models\n */\nexport interface ScopedAtom<A extends Atom.Atom<any>, Input = never> {\n readonly [TypeId]: TypeId\n use(): A\n Provider: Input extends never ? React.FC<{ readonly children?: React.ReactNode | undefined }>\n : React.FC<{ readonly children?: React.ReactNode | undefined; readonly value: Input }>\n Context: React.Context<A>\n}\n\n/**\n * @since 1.0.0\n * @category constructors\n */\nexport const make = <A extends Atom.Atom<any>, Input = never>(\n f: (() => A) | ((input: Input) => A)\n): ScopedAtom<A, Input> => {\n const Context = React.createContext<A>(undefined as unknown as A)\n\n const use = (): A => {\n const atom = React.useContext(Context)\n if (atom === undefined) {\n throw new Error(\"ScopedAtom used outside of its Provider\")\n }\n return atom\n }\n\n const Provider: React.FC<{ readonly children?: React.ReactNode | undefined; readonly value: Input }> = ({\n children,\n value\n }) => {\n const atom = React.useRef<A | null>(null)\n if (atom.current === null) {\n atom.current = f(value)\n }\n return React.createElement(Context.Provider, { value: atom.current }, children)\n }\n\n return {\n [TypeId]: TypeId,\n use,\n Provider: Provider as any,\n Context\n }\n}\n", "/**\n * @since 1.0.0\n */\n\"use client\"\n\nimport * as Atom from \"@effect-atom/atom/Atom\"\nimport type * as AtomRef from \"@effect-atom/atom/AtomRef\"\nimport * as Registry from \"@effect-atom/atom/Registry\"\nimport type * as Result from \"@effect-atom/atom/Result\"\nimport { Effect } from \"effect\"\nimport * as Cause from \"effect/Cause\"\nimport * as Exit from \"effect/Exit\"\nimport { globalValue } from \"effect/GlobalValue\"\nimport * as React from \"react\"\nimport { RegistryContext } from \"./RegistryContext.js\"\n\ninterface AtomStore<A> {\n readonly subscribe: (f: () => void) => () => void\n readonly snapshot: () => A\n readonly getServerSnapshot: () => A\n}\n\nconst storeRegistry = globalValue(\n \"@effect-atom/atom-react/storeRegistry\",\n () => new WeakMap<Registry.Registry, WeakMap<Atom.Atom<any>, AtomStore<any>>>()\n)\n\nfunction makeStore<A>(registry: Registry.Registry, atom: Atom.Atom<A>): AtomStore<A> {\n let stores = storeRegistry.get(registry)\n if (stores === undefined) {\n stores = new WeakMap()\n storeRegistry.set(registry, stores)\n }\n const store = stores.get(atom)\n if (store !== undefined) {\n return store\n }\n const newStore: AtomStore<A> = {\n subscribe(f) {\n return registry.subscribe(atom, f)\n },\n snapshot() {\n return registry.get(atom)\n },\n getServerSnapshot() {\n return Atom.getServerValue(atom, registry)\n }\n }\n stores.set(atom, newStore)\n return newStore\n}\n\nfunction useStore<A>(registry: Registry.Registry, atom: Atom.Atom<A>): A {\n const store = makeStore(registry, atom)\n\n return React.useSyncExternalStore(store.subscribe, store.snapshot, store.getServerSnapshot)\n}\n\nconst initialValuesSet = globalValue(\n \"@effect-atom/atom-react/initialValuesSet\",\n () => new WeakMap<Registry.Registry, WeakSet<Atom.Atom<any>>>()\n)\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomInitialValues = (initialValues: Iterable<readonly [Atom.Atom<any>, any]>): void => {\n const registry = React.useContext(RegistryContext)\n let set = initialValuesSet.get(registry)\n if (set === undefined) {\n set = new WeakSet()\n initialValuesSet.set(registry, set)\n }\n for (const [atom, value] of initialValues) {\n if (!set.has(atom)) {\n set.add(atom)\n ;(registry as any).ensureNode(atom).setValue(value)\n }\n }\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomValue: {\n <A>(atom: Atom.Atom<A>): A\n <A, B>(atom: Atom.Atom<A>, f: (_: A) => B): B\n} = <A>(atom: Atom.Atom<A>, f?: (_: A) => A): A => {\n const registry = React.useContext(RegistryContext)\n if (f) {\n const atomB = React.useMemo(() => Atom.map(atom, f), [atom, f])\n return useStore(registry, atomB)\n }\n return useStore(registry, atom)\n}\n\nfunction mountAtom<A>(registry: Registry.Registry, atom: Atom.Atom<A>): void {\n React.useEffect(() => registry.mount(atom), [atom, registry])\n}\n\nfunction setAtom<R, W, Mode extends \"value\" | \"promise\" | \"promiseExit\" = never>(\n registry: Registry.Registry,\n atom: Atom.Writable<R, W>,\n options?: {\n readonly mode?: ([R] extends [Result.Result<any, any>] ? Mode : \"value\") | undefined\n }\n): \"promise\" extends Mode ? (\n (value: W) => Promise<Result.Result.Success<R>>\n ) :\n \"promiseExit\" extends Mode ? (\n (value: W) => Promise<Exit.Exit<Result.Result.Success<R>, Result.Result.Failure<R>>>\n ) :\n ((value: W | ((value: R) => W)) => void)\n{\n if (options?.mode === \"promise\" || options?.mode === \"promiseExit\") {\n return React.useCallback((value: W) => {\n registry.set(atom, value)\n const promise = Effect.runPromiseExit(\n Registry.getResult(registry, atom as Atom.Atom<Result.Result<any, any>>, { suspendOnWaiting: true })\n )\n return options!.mode === \"promise\" ? promise.then(flattenExit) : promise\n }, [registry, atom, options.mode]) as any\n }\n return React.useCallback((value: W | ((value: R) => W)) => {\n registry.set(atom, typeof value === \"function\" ? (value as any)(registry.get(atom)) : value)\n }, [registry, atom]) as any\n}\n\nconst flattenExit = <A, E>(exit: Exit.Exit<A, E>): A => {\n if (Exit.isSuccess(exit)) return exit.value\n throw Cause.squash(exit.cause)\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomMount = <A>(atom: Atom.Atom<A>): void => {\n const registry = React.useContext(RegistryContext)\n mountAtom(registry, atom)\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomSet = <\n R,\n W,\n Mode extends \"value\" | \"promise\" | \"promiseExit\" = never\n>(\n atom: Atom.Writable<R, W>,\n options?: {\n readonly mode?: ([R] extends [Result.Result<any, any>] ? Mode : \"value\") | undefined\n }\n): \"promise\" extends Mode ? (\n (value: W) => Promise<Result.Result.Success<R>>\n ) :\n \"promiseExit\" extends Mode ? (\n (value: W) => Promise<Exit.Exit<Result.Result.Success<R>, Result.Result.Failure<R>>>\n ) :\n ((value: W | ((value: R) => W)) => void) =>\n{\n const registry = React.useContext(RegistryContext)\n mountAtom(registry, atom)\n return setAtom(registry, atom, options)\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomRefresh = <A>(atom: Atom.Atom<A>): () => void => {\n const registry = React.useContext(RegistryContext)\n mountAtom(registry, atom)\n return React.useCallback(() => {\n registry.refresh(atom)\n }, [registry, atom])\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtom = <R, W, const Mode extends \"value\" | \"promise\" | \"promiseExit\" = never>(\n atom: Atom.Writable<R, W>,\n options?: {\n readonly mode?: ([R] extends [Result.Result<any, any>] ? Mode : \"value\") | undefined\n }\n): readonly [\n value: R,\n write: \"promise\" extends Mode ? (\n (value: W) => Promise<Result.Result.Success<R>>\n ) :\n \"promiseExit\" extends Mode ? (\n (value: W) => Promise<Exit.Exit<Result.Result.Success<R>, Result.Result.Failure<R>>>\n ) :\n ((value: W | ((value: R) => W)) => void)\n] => {\n const registry = React.useContext(RegistryContext)\n return [\n useStore(registry, atom),\n setAtom(registry, atom, options)\n ] as const\n}\n\nconst atomPromiseMap = globalValue(\n \"@effect-atom/atom-react/atomPromiseMap\",\n () => ({\n suspendOnWaiting: new Map<Atom.Atom<any>, Promise<void>>(),\n default: new Map<Atom.Atom<any>, Promise<void>>()\n })\n)\n\nfunction atomToPromise<A, E>(\n registry: Registry.Registry,\n atom: Atom.Atom<Result.Result<A, E>>,\n suspendOnWaiting: boolean\n) {\n const map = suspendOnWaiting ? atomPromiseMap.suspendOnWaiting : atomPromiseMap.default\n let promise = map.get(atom)\n if (promise !== undefined) {\n return promise\n }\n promise = new Promise<void>((resolve) => {\n const dispose = registry.subscribe(atom, (result) => {\n if (result._tag === \"Initial\" || (suspendOnWaiting && result.waiting)) {\n return\n }\n setTimeout(dispose, 1000)\n resolve()\n map.delete(atom)\n })\n })\n map.set(atom, promise)\n return promise\n}\n\nfunction atomResultOrSuspend<A, E>(\n registry: Registry.Registry,\n atom: Atom.Atom<Result.Result<A, E>>,\n suspendOnWaiting: boolean\n) {\n const value = useStore(registry, atom)\n if (value._tag === \"Initial\" || (suspendOnWaiting && value.waiting)) {\n throw atomToPromise(registry, atom, suspendOnWaiting)\n }\n return value\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomSuspense = <A, E, const IncludeFailure extends boolean = false>(\n atom: Atom.Atom<Result.Result<A, E>>,\n options?: {\n readonly suspendOnWaiting?: boolean | undefined\n readonly includeFailure?: IncludeFailure | undefined\n }\n): Result.Success<A, E> | (IncludeFailure extends true ? Result.Failure<A, E> : never) => {\n const registry = React.useContext(RegistryContext)\n const result = atomResultOrSuspend(registry, atom, options?.suspendOnWaiting ?? false)\n if (result._tag === \"Failure\" && !options?.includeFailure) {\n throw Cause.squash(result.cause)\n }\n return result as any\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomSubscribe = <A>(\n atom: Atom.Atom<A>,\n f: (_: A) => void,\n options?: { readonly immediate?: boolean }\n): void => {\n const registry = React.useContext(RegistryContext)\n React.useEffect(\n () => registry.subscribe(atom, f, options),\n [registry, atom, f, options?.immediate]\n )\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomRef = <A>(ref: AtomRef.ReadonlyRef<A>): A => {\n const [, setValue] = React.useState(ref.value)\n React.useEffect(() => ref.subscribe(setValue), [ref])\n return ref.value\n}\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomRefProp = <A, K extends keyof A>(ref: AtomRef.AtomRef<A>, prop: K): AtomRef.AtomRef<A[K]> =>\n React.useMemo(() => ref.prop(prop), [ref, prop])\n\n/**\n * @since 1.0.0\n * @category hooks\n */\nexport const useAtomRefPropValue = <A, K extends keyof A>(ref: AtomRef.AtomRef<A>, prop: K): A[K] =>\n useAtomRef(useAtomRefProp(ref, prop))\n", "/**\n * @since 1.0.0\n */\n\"use client\"\nimport type * as Atom from \"@effect-atom/atom/Atom\"\nimport * as Registry from \"@effect-atom/atom/Registry\"\nimport * as React from \"react\"\nimport * as Scheduler from \"scheduler\"\n\n/**\n * @since 1.0.0\n * @category context\n */\nexport function scheduleTask(f: () => void): void {\n Scheduler.unstable_scheduleCallback(Scheduler.unstable_LowPriority, f)\n}\n\n/**\n * @since 1.0.0\n * @category context\n */\nexport const RegistryContext = React.createContext<Registry.Registry>(Registry.make({\n scheduleTask,\n defaultIdleTTL: 400\n}))\n\n/**\n * @since 1.0.0\n * @category context\n */\nexport const RegistryProvider = (options: {\n readonly children?: React.ReactNode | undefined\n readonly initialValues?: Iterable<readonly [Atom.Atom<any>, any]> | undefined\n readonly scheduleTask?: ((f: () => void) => void) | undefined\n readonly timeoutResolution?: number | undefined\n readonly defaultIdleTTL?: number | undefined\n}) => {\n const ref = React.useRef<{\n readonly registry: Registry.Registry\n timeout?: number | undefined\n }>(null)\n if (ref.current === null) {\n ref.current = {\n registry: Registry.make({\n scheduleTask: options.scheduleTask ?? scheduleTask,\n initialValues: options.initialValues,\n timeoutResolution: options.timeoutResolution,\n defaultIdleTTL: options.defaultIdleTTL\n })\n }\n }\n React.useEffect(() => {\n if (ref.current?.timeout !== undefined) {\n clearTimeout(ref.current.timeout)\n }\n return () => {\n ref.current!.timeout = setTimeout(() => {\n ref.current?.registry.dispose()\n ref.current = null\n }, 500)\n }\n }, [ref])\n return React.createElement(RegistryContext.Provider, { value: ref.current.registry }, options?.children)\n}\n"], | |
| 5 | + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;cAAAA;;AAKA,YAAuB;AAYhB,IAAMC,SAAiB;AAkBvB,IAAMD,QACXE,OACwB;AACxB,QAAMC,UAAgBC,oBAAiBC,MAAyB;AAEhE,QAAMC,MAAMA,MAAQ;AAClB,UAAMC,OAAaC,iBAAWL,OAAO;AACrC,QAAII,SAASF,QAAW;AACtB,YAAM,IAAII,MAAM,yCAAyC;IAC3D;AACA,WAAOF;EACT;AAEA,QAAMG,WAAiGA,CAAC;IACtGC;IACAC;EAAK,MACF;AACH,UAAML,OAAaM,aAAiB,IAAI;AACxC,QAAIN,KAAKO,YAAY,MAAM;AACzBP,WAAKO,UAAUZ,EAAEU,KAAK;IACxB;AACA,WAAaG,oBAAcZ,QAAQO,UAAU;MAAEE,OAAOL,KAAKO;IAAO,GAAIH,QAAQ;EAChF;AAEA,SAAO;IACL,CAACV,MAAM,GAAGA;IACVK;IACAI;IACAP;;AAEJ;;;ACpDA,IAAAa,SAAuB;;;ACPvB,IAAAC,SAAuB;AACvB,gBAA2B;AAMrB,SAAUC,aAAaC,GAAa;AACxCC,EAAUC,oCAAoCC,gCAAsBH,CAAC;AACvE;AAMO,IAAMI,kBAAwBC,qBAA0CC,KAAK;EAClFP;EACAQ,gBAAgB;CACjB,CAAC;AAMK,IAAMC,mBAAoBC,aAM5B;AACH,QAAMC,MAAYC,cAGf,IAAI;AACP,MAAID,IAAIE,YAAY,MAAM;AACxBF,QAAIE,UAAU;MACZC,UAAmBP,KAAK;QACtBP,cAAcU,QAAQV,gBAAgBA;QACtCe,eAAeL,QAAQK;QACvBC,mBAAmBN,QAAQM;QAC3BR,gBAAgBE,QAAQF;OACzB;;EAEL;AACAT,EAAMkB,iBAAU,MAAK;AACnB,QAAIN,IAAIE,SAASK,YAAYC,QAAW;AACtCC,mBAAaT,IAAIE,QAAQK,OAAO;IAClC;AACA,WAAO,MAAK;AACVP,UAAIE,QAASK,UAAUG,WAAW,MAAK;AACrCV,YAAIE,SAASC,SAASQ,QAAO;AAC7BX,YAAIE,UAAU;MAChB,GAAG,GAAG;IACR;EACF,GAAG,CAACF,GAAG,CAAC;AACR,SAAaY,qBAAclB,gBAAgBmB,UAAU;IAAEC,OAAOd,IAAIE,QAAQC;EAAQ,GAAIJ,SAASgB,QAAQ;AACzG;;;ADzCA,IAAMC,gBAAgBC,YACpB,yCACA,MAAM,oBAAIC,QAAO,CAA8D;AAGjF,SAASC,UAAaC,UAA6BC,MAAkB;AACnE,MAAIC,SAASN,cAAcO,IAAIH,QAAQ;AACvC,MAAIE,WAAWE,QAAW;AACxBF,aAAS,oBAAIJ,QAAO;AACpBF,kBAAcS,IAAIL,UAAUE,MAAM;EACpC;AACA,QAAMI,QAAQJ,OAAOC,IAAIF,IAAI;AAC7B,MAAIK,UAAUF,QAAW;AACvB,WAAOE;EACT;AACA,QAAMC,WAAyB;IAC7BC,UAAUC,GAAC;AACT,aAAOT,SAASQ,UAAUP,MAAMQ,CAAC;IACnC;IACAC,WAAQ;AACN,aAAOV,SAASG,IAAIF,IAAI;IAC1B;IACAU,oBAAiB;AACf,aAAYC,eAAeX,MAAMD,QAAQ;IAC3C;;AAEFE,SAAOG,IAAIJ,MAAMM,QAAQ;AACzB,SAAOA;AACT;AAEA,SAASM,SAAYb,UAA6BC,MAAkB;AAClE,QAAMK,QAAQP,UAAUC,UAAUC,IAAI;AAEtC,SAAaa,4BAAqBR,MAAME,WAAWF,MAAMI,UAAUJ,MAAMK,iBAAiB;AAC5F;AAEA,IAAMI,mBAAmBlB,YACvB,4CACA,MAAM,oBAAIC,QAAO,CAA8C;AAO1D,IAAMkB,uBAAwBC,mBAAiE;AACpG,QAAMjB,WAAiBkB,kBAAWC,eAAe;AACjD,MAAId,MAAMU,iBAAiBZ,IAAIH,QAAQ;AACvC,MAAIK,QAAQD,QAAW;AACrBC,UAAM,oBAAIe,QAAO;AACjBL,qBAAiBV,IAAIL,UAAUK,GAAG;EACpC;AACA,aAAW,CAACJ,MAAMoB,KAAK,KAAKJ,eAAe;AACzC,QAAI,CAACZ,IAAIiB,IAAIrB,IAAI,GAAG;AAClBI,UAAIkB,IAAItB,IAAI;AACVD,eAAiBwB,WAAWvB,IAAI,EAAEwB,SAASJ,KAAK;IACpD;EACF;AACF;AAMO,IAAMK,eAGTA,CAAIzB,MAAoBQ,MAAsB;AAChD,QAAMT,WAAiBkB,kBAAWC,eAAe;AACjD,MAAIV,GAAG;AACL,UAAMkB,QAAcC,eAAQ,MAAWC,IAAI5B,MAAMQ,CAAC,GAAG,CAACR,MAAMQ,CAAC,CAAC;AAC9D,WAAOI,SAASb,UAAU2B,KAAK;EACjC;AACA,SAAOd,SAASb,UAAUC,IAAI;AAChC;AAEA,SAAS6B,UAAa9B,UAA6BC,MAAkB;AACnE8B,EAAMC,iBAAU,MAAMhC,SAASiC,MAAMhC,IAAI,GAAG,CAACA,MAAMD,QAAQ,CAAC;AAC9D;AAEA,SAASkC,QACPlC,UACAC,MACAkC,SAEC;AASD,MAAIA,SAASC,SAAS,aAAaD,SAASC,SAAS,eAAe;AAClE,WAAaC,mBAAahB,WAAY;AACpCrB,eAASK,IAAIJ,MAAMoB,KAAK;AACxB,YAAMiB,UAAUC,eAAOC,eACZC,UAAUzC,UAAUC,MAA4C;QAAEyC,kBAAkB;MAAI,CAAE,CAAC;AAEtG,aAAOP,QAASC,SAAS,YAAYE,QAAQK,KAAKC,WAAW,IAAIN;IACnE,GAAG,CAACtC,UAAUC,MAAMkC,QAAQC,IAAI,CAAC;EACnC;AACA,SAAaC,mBAAahB,WAAgC;AACxDrB,aAASK,IAAIJ,MAAM,OAAOoB,UAAU,aAAcA,MAAcrB,SAASG,IAAIF,IAAI,CAAC,IAAIoB,KAAK;EAC7F,GAAG,CAACrB,UAAUC,IAAI,CAAC;AACrB;AAEA,IAAM2C,cAAqBC,UAA4B;AACrD,MAASC,UAAUD,IAAI,EAAG,QAAOA,KAAKxB;AACtC,QAAY0B,OAAOF,KAAKG,KAAK;AAC/B;AAMO,IAAMC,eAAmBhD,UAA4B;AAC1D,QAAMD,WAAiBkB,kBAAWC,eAAe;AACjDW,YAAU9B,UAAUC,IAAI;AAC1B;AAMO,IAAMiD,aAAaA,CAKxBjD,MACAkC,YAS2C;AAE3C,QAAMnC,WAAiBkB,kBAAWC,eAAe;AACjDW,YAAU9B,UAAUC,IAAI;AACxB,SAAOiC,QAAQlC,UAAUC,MAAMkC,OAAO;AACxC;AAMO,IAAMgB,iBAAqBlD,UAAkC;AAClE,QAAMD,WAAiBkB,kBAAWC,eAAe;AACjDW,YAAU9B,UAAUC,IAAI;AACxB,SAAaoC,mBAAY,MAAK;AAC5BrC,aAASoD,QAAQnD,IAAI;EACvB,GAAG,CAACD,UAAUC,IAAI,CAAC;AACrB;AAMO,IAAMoD,UAAUA,CACrBpD,MACAkC,YAYE;AACF,QAAMnC,WAAiBkB,kBAAWC,eAAe;AACjD,SAAO,CACLN,SAASb,UAAUC,IAAI,GACvBiC,QAAQlC,UAAUC,MAAMkC,OAAO,CAAC;AAEpC;AAEA,IAAMmB,iBAAiBzD,YACrB,0CACA,OAAO;EACL6C,kBAAkB,oBAAIa,IAAG;EACzBC,SAAS,oBAAID,IAAG;EAChB;AAGJ,SAASE,cACPzD,UACAC,MACAyC,kBAAyB;AAEzB,QAAMb,OAAMa,mBAAmBY,eAAeZ,mBAAmBY,eAAeE;AAChF,MAAIlB,UAAUT,KAAI1B,IAAIF,IAAI;AAC1B,MAAIqC,YAAYlC,QAAW;AACzB,WAAOkC;EACT;AACAA,YAAU,IAAIoB,QAAeC,aAAW;AACtC,UAAMC,UAAU5D,SAASQ,UAAUP,MAAO4D,YAAU;AAClD,UAAIA,OAAOC,SAAS,aAAcpB,oBAAoBmB,OAAOE,SAAU;AACrE;MACF;AACAC,iBAAWJ,SAAS,GAAI;AACxBD,cAAO;AACP9B,MAAAA,KAAIoC,OAAOhE,IAAI;IACjB,CAAC;EACH,CAAC;AACD4B,EAAAA,KAAIxB,IAAIJ,MAAMqC,OAAO;AACrB,SAAOA;AACT;AAEA,SAAS4B,oBACPlE,UACAC,MACAyC,kBAAyB;AAEzB,QAAMrB,QAAQR,SAASb,UAAUC,IAAI;AACrC,MAAIoB,MAAMyC,SAAS,aAAcpB,oBAAoBrB,MAAM0C,SAAU;AACnE,UAAMN,cAAczD,UAAUC,MAAMyC,gBAAgB;EACtD;AACA,SAAOrB;AACT;AAMO,IAAM8C,kBAAkBA,CAC7BlE,MACAkC,YAIuF;AACvF,QAAMnC,WAAiBkB,kBAAWC,eAAe;AACjD,QAAM0C,SAASK,oBAAoBlE,UAAUC,MAAMkC,SAASO,oBAAoB,KAAK;AACrF,MAAImB,OAAOC,SAAS,aAAa,CAAC3B,SAASiC,gBAAgB;AACzD,UAAYrB,OAAOc,OAAOb,KAAK;EACjC;AACA,SAAOa;AACT;AAMO,IAAMQ,mBAAmBA,CAC9BpE,MACAQ,GACA0B,YACQ;AACR,QAAMnC,WAAiBkB,kBAAWC,eAAe;AACjDY,EAAMC,iBACJ,MAAMhC,SAASQ,UAAUP,MAAMQ,GAAG0B,OAAO,GACzC,CAACnC,UAAUC,MAAMQ,GAAG0B,SAASmC,SAAS,CAAC;AAE3C;AAMO,IAAMC,aAAiBC,SAAkC;AAC9D,QAAM,CAAA,EAAG/C,QAAQ,IAAUgD,gBAASD,IAAInD,KAAK;AAC7CU,EAAMC,iBAAU,MAAMwC,IAAIhE,UAAUiB,QAAQ,GAAG,CAAC+C,GAAG,CAAC;AACpD,SAAOA,IAAInD;AACb;AAMO,IAAMqD,iBAAiBA,CAAuBF,KAAyBG,SACtE/C,eAAQ,MAAM4C,IAAIG,KAAKA,IAAI,GAAG,CAACH,KAAKG,IAAI,CAAC;AAM1C,IAAMC,sBAAsBA,CAAuBJ,KAAyBG,SACjFJ,WAAWG,eAAeF,KAAKG,IAAI,CAAC;", | |
| 6 | + "names": ["make", "TypeId", "f", "Context", "createContext", "undefined", "use", "atom", "useContext", "Error", "Provider", "children", "value", "useRef", "current", "createElement", "React", "React", "scheduleTask", "f", "Scheduler", "unstable_scheduleCallback", "unstable_LowPriority", "RegistryContext", "createContext", "make", "defaultIdleTTL", "RegistryProvider", "options", "ref", "useRef", "current", "registry", "initialValues", "timeoutResolution", "useEffect", "timeout", "undefined", "clearTimeout", "setTimeout", "dispose", "createElement", "Provider", "value", "children", "storeRegistry", "globalValue", "WeakMap", "makeStore", "registry", "atom", "stores", "get", "undefined", "set", "store", "newStore", "subscribe", "f", "snapshot", "getServerSnapshot", "getServerValue", "useStore", "useSyncExternalStore", "initialValuesSet", "useAtomInitialValues", "initialValues", "useContext", "RegistryContext", "WeakSet", "value", "has", "add", "ensureNode", "setValue", "useAtomValue", "atomB", "useMemo", "map", "mountAtom", "React", "useEffect", "mount", "setAtom", "options", "mode", "useCallback", "promise", "Effect", "runPromiseExit", "getResult", "suspendOnWaiting", "then", "flattenExit", "exit", "isSuccess", "squash", "cause", "useAtomMount", "useAtomSet", "useAtomRefresh", "refresh", "useAtom", "atomPromiseMap", "Map", "default", "atomToPromise", "Promise", "resolve", "dispose", "result", "_tag", "waiting", "setTimeout", "delete", "atomResultOrSuspend", "useAtomSuspense", "includeFailure", "useAtomSubscribe", "immediate", "useAtomRef", "ref", "useState", "useAtomRefProp", "prop", "useAtomRefPropValue"] | |
| 7 | +} | |
| @@ -0,0 +1,34 @@ | ||
| 1 | +import { | |
| 2 | + AtomHttpApi_exports, | |
| 3 | + AtomRef_exports, | |
| 4 | + AtomRpc_exports, | |
| 5 | + Atom_exports, | |
| 6 | + Hydration_exports, | |
| 7 | + Registry_exports, | |
| 8 | + Result_exports | |
| 9 | +} from "./chunk-LVLGAPNT.js"; | |
| 10 | +import "./chunk-4SMLXLLX.js"; | |
| 11 | +import "./chunk-ZQSAFZCP.js"; | |
| 12 | +import "./chunk-SF36ZBUI.js"; | |
| 13 | +import "./chunk-6MBN5S2E.js"; | |
| 14 | +import "./chunk-HVF2XBK2.js"; | |
| 15 | +import "./chunk-3LT46UFL.js"; | |
| 16 | +import "./chunk-LXSJW2UJ.js"; | |
| 17 | +import "./chunk-UYCMDTGT.js"; | |
| 18 | +import "./chunk-B5FOTKVA.js"; | |
| 19 | +import "./chunk-7GS5HKXM.js"; | |
| 20 | +import "./chunk-JDLTRRA5.js"; | |
| 21 | +import "./chunk-RG46YT3R.js"; | |
| 22 | +import "./chunk-5XJTUU64.js"; | |
| 23 | +import "./chunk-SPGJQP32.js"; | |
| 24 | +import "./chunk-LX4DLJUA.js"; | |
| 25 | +import "./chunk-G3PMV62Z.js"; | |
| 26 | +export { | |
| 27 | + Atom_exports as Atom, | |
| 28 | + AtomHttpApi_exports as AtomHttpApi, | |
| 29 | + AtomRef_exports as AtomRef, | |
| 30 | + AtomRpc_exports as AtomRpc, | |
| 31 | + Hydration_exports as Hydration, | |
| 32 | + Registry_exports as Registry, | |
| 33 | + Result_exports as Result | |
| 34 | +}; | |
| @@ -0,0 +1,7 @@ | ||
| 1 | +{ | |
| 2 | + "version": 3, | |
| 3 | + "sources": [], | |
| 4 | + "sourcesContent": [], | |
| 5 | + "mappings": "", | |
| 6 | + "names": [] | |
| 7 | +} | |
| @@ -0,0 +1,6731 @@ | ||
| 1 | +import { | |
| 2 | + AdditionalSchemas, | |
| 3 | + Api, | |
| 4 | + Collector, | |
| 5 | + Cookies_exports, | |
| 6 | + Error_exports, | |
| 7 | + FileSystem, | |
| 8 | + FileSystem_exports, | |
| 9 | + Headers_exports, | |
| 10 | + HttpApiClient_exports, | |
| 11 | + HttpApiDecodeError, | |
| 12 | + HttpApiError_exports, | |
| 13 | + HttpApiSchema_exports, | |
| 14 | + HttpApi_exports, | |
| 15 | + HttpBody_exports, | |
| 16 | + HttpClient, | |
| 17 | + HttpClientError_exports, | |
| 18 | + HttpClientRequest_exports, | |
| 19 | + HttpClientResponse_exports, | |
| 20 | + HttpClient_exports, | |
| 21 | + HttpIncomingMessage_exports, | |
| 22 | + HttpMethod_exports, | |
| 23 | + HttpTraceContext_exports, | |
| 24 | + KeyValueStore_exports, | |
| 25 | + MaxBodySize, | |
| 26 | + NoContent, | |
| 27 | + Packr, | |
| 28 | + Path, | |
| 29 | + Path_exports, | |
| 30 | + RequestError, | |
| 31 | + Size, | |
| 32 | + Socket_exports, | |
| 33 | + Transferable_exports, | |
| 34 | + TypeId, | |
| 35 | + TypeIdError, | |
| 36 | + UnionUnify, | |
| 37 | + Unpackr, | |
| 38 | + UrlParams_exports, | |
| 39 | + WorkerError, | |
| 40 | + WorkerError_exports, | |
| 41 | + Worker_exports, | |
| 42 | + annotations, | |
| 43 | + currentRedactedNames, | |
| 44 | + decode as decode2, | |
| 45 | + deunionize, | |
| 46 | + empty as empty8, | |
| 47 | + empty2 as empty9, | |
| 48 | + empty3 as empty10, | |
| 49 | + encode as encode2, | |
| 50 | + formData, | |
| 51 | + fromHeaders, | |
| 52 | + fromInput, | |
| 53 | + fromInput2, | |
| 54 | + fromSetCookie, | |
| 55 | + fromWeb, | |
| 56 | + getEmptyDecodeable, | |
| 57 | + getEncoding, | |
| 58 | + getMultipart, | |
| 59 | + getMultipartStream, | |
| 60 | + getParam, | |
| 61 | + getStatusErrorAST, | |
| 62 | + getStatusSuccessAST, | |
| 63 | + hasBody, | |
| 64 | + inspect, | |
| 65 | + isEmpty as isEmpty2, | |
| 66 | + isHttpApi, | |
| 67 | + isPlatformError, | |
| 68 | + isVoid, | |
| 69 | + isWorkerError, | |
| 70 | + json, | |
| 71 | + jsonSchema, | |
| 72 | + layer, | |
| 73 | + layerMergedContext, | |
| 74 | + layerNoop, | |
| 75 | + make as make8, | |
| 76 | + mapRequest, | |
| 77 | + merge as merge2, | |
| 78 | + merge2 as merge3, | |
| 79 | + parseHeader, | |
| 80 | + prependUrl, | |
| 81 | + raw, | |
| 82 | + redact as redact2, | |
| 83 | + reflect, | |
| 84 | + remove as remove2, | |
| 85 | + remove2 as remove3, | |
| 86 | + schemaBodyJson, | |
| 87 | + schemaBodyUrlParams, | |
| 88 | + schemaHeaders, | |
| 89 | + schemaJson, | |
| 90 | + set as set2, | |
| 91 | + set2 as set3, | |
| 92 | + setAll, | |
| 93 | + setAll2, | |
| 94 | + stream, | |
| 95 | + stream2, | |
| 96 | + text, | |
| 97 | + toChannelWith, | |
| 98 | + toRecord, | |
| 99 | + toSetCookieHeaders, | |
| 100 | + toString, | |
| 101 | + uint8Array, | |
| 102 | + unsafeFromRecord, | |
| 103 | + unsafeJson, | |
| 104 | + unsafeMakeCollector, | |
| 105 | + unsafeSet, | |
| 106 | + unsafeSetAll, | |
| 107 | + withMaxBodySize | |
| 108 | +} from "./chunk-4SMLXLLX.js"; | |
| 109 | +import { | |
| 110 | + ConfigProvider, | |
| 111 | + batched, | |
| 112 | + currentServices, | |
| 113 | + defaultLogger, | |
| 114 | + empty as empty11, | |
| 115 | + fromAST, | |
| 116 | + fromFlat, | |
| 117 | + fromMap, | |
| 118 | + isLogger, | |
| 119 | + makeFlat, | |
| 120 | + orElse as orElse2, | |
| 121 | + prettyLoggerDefault, | |
| 122 | + unify | |
| 123 | +} from "./chunk-5O7CUVLV.js"; | |
| 124 | +import { | |
| 125 | + acquireUseRelease, | |
| 126 | + embedInput, | |
| 127 | + failCause as failCause3, | |
| 128 | + flatMap as flatMap4, | |
| 129 | + foldLeftChunks, | |
| 130 | + isChannel, | |
| 131 | + make as make5, | |
| 132 | + mapOut, | |
| 133 | + mapOutEffect, | |
| 134 | + nominal, | |
| 135 | + pipeTo, | |
| 136 | + readWithCause, | |
| 137 | + run as run2, | |
| 138 | + splitLines as splitLines2, | |
| 139 | + succeed as succeed5, | |
| 140 | + suspend, | |
| 141 | + sync as sync3, | |
| 142 | + unwrap, | |
| 143 | + void_ as void_2, | |
| 144 | + write, | |
| 145 | + zipRight as zipRight2 | |
| 146 | +} from "./chunk-SF36ZBUI.js"; | |
| 147 | +import { | |
| 148 | + Array$, | |
| 149 | + ChunkFromSelf, | |
| 150 | + Defect, | |
| 151 | + Forbidden, | |
| 152 | + Literal, | |
| 153 | + MissingData, | |
| 154 | + Never, | |
| 155 | + SourceUnavailable, | |
| 156 | + String$, | |
| 157 | + Struct, | |
| 158 | + TaggedError as TaggedError2, | |
| 159 | + Type, | |
| 160 | + Uint8ArrayFromSelf, | |
| 161 | + Union2 as Union, | |
| 162 | + _try, | |
| 163 | + declare, | |
| 164 | + decode, | |
| 165 | + decodeBase64String, | |
| 166 | + decodeUnknown, | |
| 167 | + encode, | |
| 168 | + encodeUnknown, | |
| 169 | + fail as fail5, | |
| 170 | + is, | |
| 171 | + isParseError, | |
| 172 | + itemsCount, | |
| 173 | + make2 as make6, | |
| 174 | + make3 as make7, | |
| 175 | + parseJson, | |
| 176 | + serializeFailure, | |
| 177 | + serializeSuccess, | |
| 178 | + succeed as succeed4, | |
| 179 | + transform, | |
| 180 | + transformOrFail, | |
| 181 | + value2 as value | |
| 182 | +} from "./chunk-6MBN5S2E.js"; | |
| 183 | +import { | |
| 184 | + StreamTypeId, | |
| 185 | + currentContext, | |
| 186 | + currentLoggers, | |
| 187 | + defaultRuntime, | |
| 188 | + defaultRuntimeFlags, | |
| 189 | + encodeText, | |
| 190 | + ensuring4 as ensuring2, | |
| 191 | + fail5 as fail4, | |
| 192 | + flatMap4 as flatMap3, | |
| 193 | + fromChannel3 as fromChannel, | |
| 194 | + fromChunk, | |
| 195 | + fromIterable as fromIterable5, | |
| 196 | + fromReadableStream, | |
| 197 | + get as get2, | |
| 198 | + make as make4, | |
| 199 | + map5 as map6, | |
| 200 | + mapChunks, | |
| 201 | + mapError4 as mapError2, | |
| 202 | + pipeThroughChannel, | |
| 203 | + provideContext4 as provideContext, | |
| 204 | + provideSomeContext2 as provideSomeContext, | |
| 205 | + run2 as run, | |
| 206 | + runCollect2 as runCollect, | |
| 207 | + runForEach, | |
| 208 | + runForEachChunk, | |
| 209 | + runFork as runFork2, | |
| 210 | + set, | |
| 211 | + splitLines2 as splitLines, | |
| 212 | + succeed4 as succeed3, | |
| 213 | + toReadableStreamEffect, | |
| 214 | + toReadableStreamRuntime, | |
| 215 | + unsafeMake as unsafeMake3, | |
| 216 | + unwrapScoped4 as unwrapScoped2, | |
| 217 | + update | |
| 218 | +} from "./chunk-HVF2XBK2.js"; | |
| 219 | +import { | |
| 220 | + CurrentMemoMap, | |
| 221 | + buildWithMemoMap, | |
| 222 | + buildWithScope, | |
| 223 | + effect, | |
| 224 | + effectDiscard, | |
| 225 | + empty as empty7, | |
| 226 | + fiberRefLocallyScopedWith, | |
| 227 | + isLayer, | |
| 228 | + locally as locally2, | |
| 229 | + locallyScoped, | |
| 230 | + mergeAll, | |
| 231 | + provide as provide2, | |
| 232 | + provideMerge, | |
| 233 | + scopedContext, | |
| 234 | + scopedDiscard, | |
| 235 | + setConfigProvider, | |
| 236 | + succeed as succeed2, | |
| 237 | + succeedContext, | |
| 238 | + sync as sync2, | |
| 239 | + toRuntime, | |
| 240 | + toRuntimeWithMemoMap, | |
| 241 | + unwrapEffect, | |
| 242 | + unwrapScoped | |
| 243 | +} from "./chunk-3LT46UFL.js"; | |
| 244 | +import { | |
| 245 | + Do, | |
| 246 | + _void, | |
| 247 | + all, | |
| 248 | + andThen2 as andThen, | |
| 249 | + annotateLogs, | |
| 250 | + as2 as as, | |
| 251 | + async, | |
| 252 | + bind, | |
| 253 | + bindTo, | |
| 254 | + cached, | |
| 255 | + catchAll, | |
| 256 | + catchAllCause, | |
| 257 | + catchIf, | |
| 258 | + catchTag, | |
| 259 | + catchTags, | |
| 260 | + context, | |
| 261 | + contextWith, | |
| 262 | + die as die2, | |
| 263 | + ensuring2 as ensuring, | |
| 264 | + exit, | |
| 265 | + fail as fail3, | |
| 266 | + failCause as failCause2, | |
| 267 | + flatMap as flatMap2, | |
| 268 | + fnUntraced, | |
| 269 | + forEach as forEach2, | |
| 270 | + forkScoped, | |
| 271 | + gen, | |
| 272 | + ignore, | |
| 273 | + interruptible, | |
| 274 | + isEffect, | |
| 275 | + locally, | |
| 276 | + locallyWith, | |
| 277 | + log2 as log, | |
| 278 | + logDebug, | |
| 279 | + logError, | |
| 280 | + map2 as map5, | |
| 281 | + mapError, | |
| 282 | + mapInputContext2 as mapInputContext, | |
| 283 | + match2 as match3, | |
| 284 | + matchCauseEffect, | |
| 285 | + matchEffect, | |
| 286 | + onExit, | |
| 287 | + orDie, | |
| 288 | + orElseSucceed, | |
| 289 | + provide, | |
| 290 | + provideService2 as provideService, | |
| 291 | + provideServiceEffect, | |
| 292 | + runFork, | |
| 293 | + runPromise, | |
| 294 | + runSync, | |
| 295 | + runtime as runtime2, | |
| 296 | + scope, | |
| 297 | + scoped, | |
| 298 | + scopedWith, | |
| 299 | + succeed2 as succeed, | |
| 300 | + sync2 as sync, | |
| 301 | + tap, | |
| 302 | + tapErrorCause, | |
| 303 | + tryMap, | |
| 304 | + tryPromise, | |
| 305 | + try_ as try_2, | |
| 306 | + uninterruptible, | |
| 307 | + uninterruptibleMask, | |
| 308 | + updateService, | |
| 309 | + useSpan, | |
| 310 | + withFiberRuntime, | |
| 311 | + withLogSpan, | |
| 312 | + withParentSpan, | |
| 313 | + zipRight2 as zipRight | |
| 314 | +} from "./chunk-LXSJW2UJ.js"; | |
| 315 | +import { | |
| 316 | + Class as Class2, | |
| 317 | + IllegalArgumentException, | |
| 318 | + ParentSpan, | |
| 319 | + Scope, | |
| 320 | + StructuralClass, | |
| 321 | + _await2 as _await, | |
| 322 | + close, | |
| 323 | + die2 as die, | |
| 324 | + empty6, | |
| 325 | + extend, | |
| 326 | + fail, | |
| 327 | + fail3 as fail2, | |
| 328 | + failCause, | |
| 329 | + failureOrCause, | |
| 330 | + getCurrentFiber, | |
| 331 | + getOrDefault, | |
| 332 | + interrupt3 as interrupt, | |
| 333 | + isEmptyType, | |
| 334 | + isFailure2 as isFailure, | |
| 335 | + isInterruptType, | |
| 336 | + isInterruptedOnly, | |
| 337 | + isNoSuchElementException, | |
| 338 | + make11 as make2, | |
| 339 | + make13 as make3, | |
| 340 | + reduce3 as reduce2, | |
| 341 | + sequential3 as sequential, | |
| 342 | + squash, | |
| 343 | + stripSomeDefects, | |
| 344 | + unsafeMake3 as unsafeMake2, | |
| 345 | + updateAs, | |
| 346 | + void_ | |
| 347 | +} from "./chunk-UYCMDTGT.js"; | |
| 348 | +import { | |
| 349 | + TaggedError | |
| 350 | +} from "./chunk-B5FOTKVA.js"; | |
| 351 | +import { | |
| 352 | + add as add2, | |
| 353 | + empty2 as empty5, | |
| 354 | + fromIterable as fromIterable3, | |
| 355 | + fromIterable2 as fromIterable4, | |
| 356 | + has, | |
| 357 | + none2, | |
| 358 | + remove, | |
| 359 | + runtime, | |
| 360 | + union2 as union | |
| 361 | +} from "./chunk-7GS5HKXM.js"; | |
| 362 | +import { | |
| 363 | + append2 as append, | |
| 364 | + appendAll2 as appendAll, | |
| 365 | + empty2 as empty, | |
| 366 | + empty3 as empty2, | |
| 367 | + empty4 as empty3, | |
| 368 | + filter3 as filter2, | |
| 369 | + flatMap2 as flatMap, | |
| 370 | + forEach, | |
| 371 | + fromIterable, | |
| 372 | + fromIterable2, | |
| 373 | + isEmpty, | |
| 374 | + isEmptyRecord, | |
| 375 | + left, | |
| 376 | + make3 as make, | |
| 377 | + map, | |
| 378 | + map3, | |
| 379 | + map5 as map4, | |
| 380 | + match, | |
| 381 | + of, | |
| 382 | + of2, | |
| 383 | + reduce3 as reduce, | |
| 384 | + reverse, | |
| 385 | + right, | |
| 386 | + some as some2, | |
| 387 | + toArray, | |
| 388 | + toReadonlyArray, | |
| 389 | + try_, | |
| 390 | + unsafeFromArray | |
| 391 | +} from "./chunk-JDLTRRA5.js"; | |
| 392 | +import { | |
| 393 | + GenericTag, | |
| 394 | + Reference, | |
| 395 | + Tag, | |
| 396 | + add, | |
| 397 | + empty as empty4, | |
| 398 | + get, | |
| 399 | + getOption, | |
| 400 | + getOrElse as getOrElse2, | |
| 401 | + isContext, | |
| 402 | + merge, | |
| 403 | + unsafeGet, | |
| 404 | + unsafeMake | |
| 405 | +} from "./chunk-RG46YT3R.js"; | |
| 406 | +import { | |
| 407 | + filter, | |
| 408 | + flatMapNullable, | |
| 409 | + getOrElse, | |
| 410 | + getOrThrow, | |
| 411 | + getOrUndefined, | |
| 412 | + isNone, | |
| 413 | + isOption, | |
| 414 | + isSome, | |
| 415 | + map as map2, | |
| 416 | + match as match2, | |
| 417 | + none, | |
| 418 | + orElse, | |
| 419 | + some | |
| 420 | +} from "./chunk-5XJTUU64.js"; | |
| 421 | +import { | |
| 422 | + BaseProto, | |
| 423 | + Class, | |
| 424 | + NodeInspectSymbol, | |
| 425 | + format, | |
| 426 | + globalValue, | |
| 427 | + hasProperty, | |
| 428 | + isTagged, | |
| 429 | + pipeArguments, | |
| 430 | + redact, | |
| 431 | + toJSON | |
| 432 | +} from "./chunk-SPGJQP32.js"; | |
| 433 | +import { | |
| 434 | + compose, | |
| 435 | + constFalse, | |
| 436 | + constant, | |
| 437 | + dual, | |
| 438 | + identity, | |
| 439 | + pipe | |
| 440 | +} from "./chunk-LX4DLJUA.js"; | |
| 441 | +import { | |
| 442 | + __export | |
| 443 | +} from "./chunk-G3PMV62Z.js"; | |
| 444 | + | |
| 445 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/ChannelSchema.js | |
| 446 | +var ChannelSchema_exports = {}; | |
| 447 | +__export(ChannelSchema_exports, { | |
| 448 | + decode: () => decode3, | |
| 449 | + decodeUnknown: () => decodeUnknown2, | |
| 450 | + duplex: () => duplex, | |
| 451 | + duplexUnknown: () => duplexUnknown, | |
| 452 | + encode: () => encode3, | |
| 453 | + encodeUnknown: () => encodeUnknown2 | |
| 454 | +}); | |
| 455 | +var encode3 = (schema2) => () => { | |
| 456 | + const encode4 = encode(ChunkFromSelf(schema2)); | |
| 457 | + const loop = readWithCause({ | |
| 458 | + onInput: (input) => zipRight2(flatMap4(encode4(input), write), loop), | |
| 459 | + onFailure: (cause) => failCause3(cause), | |
| 460 | + onDone: succeed5 | |
| 461 | + }); | |
| 462 | + return loop; | |
| 463 | +}; | |
| 464 | +var encodeUnknown2 = encode3; | |
| 465 | +var decode3 = (schema2) => () => { | |
| 466 | + const decode4 = decode(ChunkFromSelf(schema2)); | |
| 467 | + const loop = readWithCause({ | |
| 468 | + onInput(chunk) { | |
| 469 | + return decode4(chunk).pipe(flatMap4(write), zipRight2(loop)); | |
| 470 | + }, | |
| 471 | + onFailure(cause) { | |
| 472 | + return failCause3(cause); | |
| 473 | + }, | |
| 474 | + onDone(done) { | |
| 475 | + return succeed5(done); | |
| 476 | + } | |
| 477 | + }); | |
| 478 | + return loop; | |
| 479 | +}; | |
| 480 | +var decodeUnknown2 = decode3; | |
| 481 | +var duplex = dual(2, (self, options4) => { | |
| 482 | + const decode4 = decode(ChunkFromSelf(options4.outputSchema)); | |
| 483 | + return pipe(encode3(options4.inputSchema)(), pipeTo(self), mapOutEffect(decode4)); | |
| 484 | +}); | |
| 485 | +var duplexUnknown = duplex; | |
| 486 | + | |
| 487 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Command.js | |
| 488 | +var Command_exports = {}; | |
| 489 | +__export(Command_exports, { | |
| 490 | + CommandTypeId: () => CommandTypeId2, | |
| 491 | + env: () => env2, | |
| 492 | + exitCode: () => exitCode2, | |
| 493 | + feed: () => feed2, | |
| 494 | + flatten: () => flatten2, | |
| 495 | + isCommand: () => isCommand2, | |
| 496 | + lines: () => lines2, | |
| 497 | + make: () => make10, | |
| 498 | + pipeTo: () => pipeTo3, | |
| 499 | + runInShell: () => runInShell2, | |
| 500 | + start: () => start2, | |
| 501 | + stderr: () => stderr2, | |
| 502 | + stdin: () => stdin2, | |
| 503 | + stdout: () => stdout2, | |
| 504 | + stream: () => stream4, | |
| 505 | + streamLines: () => streamLines2, | |
| 506 | + string: () => string2, | |
| 507 | + workingDirectory: () => workingDirectory2 | |
| 508 | +}); | |
| 509 | + | |
| 510 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/commandExecutor.js | |
| 511 | +var TypeId2 = Symbol.for("@effect/platform/CommandExecutor"); | |
| 512 | +var ProcessTypeId = Symbol.for("@effect/platform/Process"); | |
| 513 | +var ExitCode = nominal(); | |
| 514 | +var ProcessId = nominal(); | |
| 515 | +var CommandExecutor = GenericTag("@effect/platform/CommandExecutor"); | |
| 516 | +var makeExecutor = (start3) => { | |
| 517 | + const stream8 = (command) => unwrapScoped2(map5(start3(command), (process) => process.stdout)); | |
| 518 | + const streamLines3 = (command, encoding) => { | |
| 519 | + const decoder = new TextDecoder(encoding); | |
| 520 | + return splitLines(mapChunks(stream8(command), map4((bytes) => decoder.decode(bytes)))); | |
| 521 | + }; | |
| 522 | + return { | |
| 523 | + [TypeId2]: TypeId2, | |
| 524 | + start: start3, | |
| 525 | + exitCode: (command) => scoped(flatMap2(start3(command), (process) => process.exitCode)), | |
| 526 | + stream: stream8, | |
| 527 | + string: (command, encoding = "utf-8") => { | |
| 528 | + const decoder = new TextDecoder(encoding); | |
| 529 | + return pipe(start3(command), flatMap2((process) => run(process.stdout, collectUint8Array)), map5((bytes) => decoder.decode(bytes)), scoped); | |
| 530 | + }, | |
| 531 | + lines: (command, encoding = "utf-8") => { | |
| 532 | + return pipe(streamLines3(command, encoding), runCollect, map5(toArray)); | |
| 533 | + }, | |
| 534 | + streamLines: streamLines3 | |
| 535 | + }; | |
| 536 | +}; | |
| 537 | +var collectUint8Array = foldLeftChunks(new Uint8Array(), (bytes, chunk) => reduce(chunk, bytes, (acc, curr) => { | |
| 538 | + const newArray = new Uint8Array(acc.length + curr.length); | |
| 539 | + newArray.set(acc); | |
| 540 | + newArray.set(curr, acc.length); | |
| 541 | + return newArray; | |
| 542 | +})); | |
| 543 | + | |
| 544 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/command.js | |
| 545 | +var CommandTypeId = Symbol.for("@effect/platform/Command"); | |
| 546 | +var isCommand = (u) => typeof u === "object" && u != null && CommandTypeId in u; | |
| 547 | +var env = dual(2, (self, environment) => { | |
| 548 | + switch (self._tag) { | |
| 549 | + case "StandardCommand": { | |
| 550 | + return makeStandard({ | |
| 551 | + ...self, | |
| 552 | + env: union(self.env, fromIterable4(Object.entries(environment).filter(([v]) => v !== void 0))) | |
| 553 | + }); | |
| 554 | + } | |
| 555 | + case "PipedCommand": { | |
| 556 | + return pipeTo2(env(self.left, environment), env(self.right, environment)); | |
| 557 | + } | |
| 558 | + } | |
| 559 | +}); | |
| 560 | +var exitCode = (self) => flatMap2(CommandExecutor, (executor) => executor.exitCode(self)); | |
| 561 | +var feed = dual(2, (self, input) => stdin(self, fromChunk(of2(new TextEncoder().encode(input))))); | |
| 562 | +var flatten = (self) => Array.from(flattenLoop(self)); | |
| 563 | +var flattenLoop = (self) => { | |
| 564 | + switch (self._tag) { | |
| 565 | + case "StandardCommand": { | |
| 566 | + return of2(self); | |
| 567 | + } | |
| 568 | + case "PipedCommand": { | |
| 569 | + return appendAll(flattenLoop(self.left), flattenLoop(self.right)); | |
| 570 | + } | |
| 571 | + } | |
| 572 | +}; | |
| 573 | +var runInShell = dual(2, (self, shell) => { | |
| 574 | + switch (self._tag) { | |
| 575 | + case "StandardCommand": { | |
| 576 | + return makeStandard({ | |
| 577 | + ...self, | |
| 578 | + shell | |
| 579 | + }); | |
| 580 | + } | |
| 581 | + case "PipedCommand": { | |
| 582 | + return pipeTo2(runInShell(self.left, shell), runInShell(self.right, shell)); | |
| 583 | + } | |
| 584 | + } | |
| 585 | +}); | |
| 586 | +var lines = (command, encoding = "utf-8") => flatMap2(CommandExecutor, (executor) => executor.lines(command, encoding)); | |
| 587 | +var Proto = { | |
| 588 | + [CommandTypeId]: CommandTypeId, | |
| 589 | + pipe() { | |
| 590 | + return pipeArguments(this, arguments); | |
| 591 | + }, | |
| 592 | + ...BaseProto | |
| 593 | +}; | |
| 594 | +var StandardProto = { | |
| 595 | + ...Proto, | |
| 596 | + _tag: "StandardCommand", | |
| 597 | + toJSON() { | |
| 598 | + return { | |
| 599 | + _id: "@effect/platform/Command", | |
| 600 | + _tag: this._tag, | |
| 601 | + command: this.command, | |
| 602 | + args: this.args, | |
| 603 | + env: Object.fromEntries(this.env), | |
| 604 | + cwd: this.cwd.toJSON(), | |
| 605 | + shell: this.shell, | |
| 606 | + gid: this.gid.toJSON(), | |
| 607 | + uid: this.uid.toJSON() | |
| 608 | + }; | |
| 609 | + } | |
| 610 | +}; | |
| 611 | +var makeStandard = (options4) => Object.assign(Object.create(StandardProto), options4); | |
| 612 | +var PipedProto = { | |
| 613 | + ...Proto, | |
| 614 | + _tag: "PipedCommand", | |
| 615 | + toJSON() { | |
| 616 | + return { | |
| 617 | + _id: "@effect/platform/Command", | |
| 618 | + _tag: this._tag, | |
| 619 | + left: this.left.toJSON(), | |
| 620 | + right: this.right.toJSON() | |
| 621 | + }; | |
| 622 | + } | |
| 623 | +}; | |
| 624 | +var makePiped = (options4) => Object.assign(Object.create(PipedProto), options4); | |
| 625 | +var make9 = (command, ...args) => makeStandard({ | |
| 626 | + command, | |
| 627 | + args, | |
| 628 | + env: empty5(), | |
| 629 | + cwd: none(), | |
| 630 | + shell: false, | |
| 631 | + stdin: "pipe", | |
| 632 | + stdout: "pipe", | |
| 633 | + stderr: "pipe", | |
| 634 | + gid: none(), | |
| 635 | + uid: none() | |
| 636 | +}); | |
| 637 | +var pipeTo2 = dual(2, (self, into) => makePiped({ | |
| 638 | + left: self, | |
| 639 | + right: into | |
| 640 | +})); | |
| 641 | +var stderr = dual(2, (self, output) => { | |
| 642 | + switch (self._tag) { | |
| 643 | + case "StandardCommand": { | |
| 644 | + return makeStandard({ | |
| 645 | + ...self, | |
| 646 | + stderr: output | |
| 647 | + }); | |
| 648 | + } | |
| 649 | + // For piped commands it only makes sense to provide `stderr` for the | |
| 650 | + // right-most command as the rest will be piped in. | |
| 651 | + case "PipedCommand": { | |
| 652 | + return makePiped({ | |
| 653 | + ...self, | |
| 654 | + right: stderr(self.right, output) | |
| 655 | + }); | |
| 656 | + } | |
| 657 | + } | |
| 658 | +}); | |
| 659 | +var stdin = dual(2, (self, input) => { | |
| 660 | + switch (self._tag) { | |
| 661 | + case "StandardCommand": { | |
| 662 | + return makeStandard({ | |
| 663 | + ...self, | |
| 664 | + stdin: input | |
| 665 | + }); | |
| 666 | + } | |
| 667 | + // For piped commands it only makes sense to provide `stdin` for the | |
| 668 | + // left-most command as the rest will be piped in. | |
| 669 | + case "PipedCommand": { | |
| 670 | + return makePiped({ | |
| 671 | + ...self, | |
| 672 | + left: stdin(self.left, input) | |
| 673 | + }); | |
| 674 | + } | |
| 675 | + } | |
| 676 | +}); | |
| 677 | +var stdout = dual(2, (self, output) => { | |
| 678 | + switch (self._tag) { | |
| 679 | + case "StandardCommand": { | |
| 680 | + return makeStandard({ | |
| 681 | + ...self, | |
| 682 | + stdout: output | |
| 683 | + }); | |
| 684 | + } | |
| 685 | + // For piped commands it only makes sense to provide `stderr` for the | |
| 686 | + // right-most command as the rest will be piped in. | |
| 687 | + case "PipedCommand": { | |
| 688 | + return makePiped({ | |
| 689 | + ...self, | |
| 690 | + right: stdout(self.right, output) | |
| 691 | + }); | |
| 692 | + } | |
| 693 | + } | |
| 694 | +}); | |
| 695 | +var start = (command) => flatMap2(CommandExecutor, (executor) => executor.start(command)); | |
| 696 | +var stream3 = (command) => flatMap3(CommandExecutor, (executor) => executor.stream(command)); | |
| 697 | +var streamLines = (command, encoding) => flatMap3(CommandExecutor, (executor) => executor.streamLines(command, encoding)); | |
| 698 | +var string = dual((args) => isCommand(args[0]), (command, encoding) => flatMap2(CommandExecutor, (executor) => executor.string(command, encoding))); | |
| 699 | +var workingDirectory = dual(2, (self, cwd) => { | |
| 700 | + switch (self._tag) { | |
| 701 | + case "StandardCommand": { | |
| 702 | + return makeStandard({ | |
| 703 | + ...self, | |
| 704 | + cwd: some(cwd) | |
| 705 | + }); | |
| 706 | + } | |
| 707 | + case "PipedCommand": { | |
| 708 | + return pipeTo2(workingDirectory(self.left, cwd), workingDirectory(self.right, cwd)); | |
| 709 | + } | |
| 710 | + } | |
| 711 | +}); | |
| 712 | + | |
| 713 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Command.js | |
| 714 | +var CommandTypeId2 = CommandTypeId; | |
| 715 | +var isCommand2 = isCommand; | |
| 716 | +var env2 = env; | |
| 717 | +var exitCode2 = exitCode; | |
| 718 | +var feed2 = feed; | |
| 719 | +var flatten2 = flatten; | |
| 720 | +var lines2 = lines; | |
| 721 | +var make10 = make9; | |
| 722 | +var pipeTo3 = pipeTo2; | |
| 723 | +var runInShell2 = runInShell; | |
| 724 | +var start2 = start; | |
| 725 | +var stream4 = stream3; | |
| 726 | +var streamLines2 = streamLines; | |
| 727 | +var string2 = string; | |
| 728 | +var stderr2 = stderr; | |
| 729 | +var stdin2 = stdin; | |
| 730 | +var stdout2 = stdout; | |
| 731 | +var workingDirectory2 = workingDirectory; | |
| 732 | + | |
| 733 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/CommandExecutor.js | |
| 734 | +var CommandExecutor_exports = {}; | |
| 735 | +__export(CommandExecutor_exports, { | |
| 736 | + CommandExecutor: () => CommandExecutor2, | |
| 737 | + ExitCode: () => ExitCode2, | |
| 738 | + ProcessId: () => ProcessId2, | |
| 739 | + ProcessTypeId: () => ProcessTypeId2, | |
| 740 | + TypeId: () => TypeId3, | |
| 741 | + makeExecutor: () => makeExecutor2 | |
| 742 | +}); | |
| 743 | +var TypeId3 = TypeId2; | |
| 744 | +var CommandExecutor2 = CommandExecutor; | |
| 745 | +var ProcessTypeId2 = ProcessTypeId; | |
| 746 | +var ExitCode2 = ExitCode; | |
| 747 | +var ProcessId2 = ProcessId; | |
| 748 | +var makeExecutor2 = makeExecutor; | |
| 749 | + | |
| 750 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Effectify.js | |
| 751 | +var Effectify_exports = {}; | |
| 752 | +__export(Effectify_exports, { | |
| 753 | + effectify: () => effectify2 | |
| 754 | +}); | |
| 755 | + | |
| 756 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/effectify.js | |
| 757 | +var effectify = (fn, onError, onSyncError) => (...args) => async((resume) => { | |
| 758 | + try { | |
| 759 | + fn(...args, (err, result) => { | |
| 760 | + if (err) { | |
| 761 | + resume(fail3(onError ? onError(err, args) : err)); | |
| 762 | + } else { | |
| 763 | + resume(succeed(result)); | |
| 764 | + } | |
| 765 | + }); | |
| 766 | + } catch (err) { | |
| 767 | + resume(onSyncError ? fail3(onSyncError(err, args)) : die2(err)); | |
| 768 | + } | |
| 769 | +}); | |
| 770 | + | |
| 771 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Effectify.js | |
| 772 | +var effectify2 = effectify; | |
| 773 | + | |
| 774 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Etag.js | |
| 775 | +var Etag_exports = {}; | |
| 776 | +__export(Etag_exports, { | |
| 777 | + Generator: () => Generator, | |
| 778 | + GeneratorTypeId: () => GeneratorTypeId2, | |
| 779 | + layer: () => layer3, | |
| 780 | + layerWeak: () => layerWeak2, | |
| 781 | + toString: () => toString3 | |
| 782 | +}); | |
| 783 | + | |
| 784 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/etag.js | |
| 785 | +var GeneratorTypeId = Symbol.for("@effect/platform/Etag/Generator"); | |
| 786 | +var tag = GenericTag("@effect/platform/Etag/Generator"); | |
| 787 | +var toString2 = (self) => { | |
| 788 | + switch (self._tag) { | |
| 789 | + case "Weak": | |
| 790 | + return `W/"${self.value}"`; | |
| 791 | + case "Strong": | |
| 792 | + return `"${self.value}"`; | |
| 793 | + } | |
| 794 | +}; | |
| 795 | +var fromFileInfo = (info) => { | |
| 796 | + const mtime = info.mtime._tag === "Some" ? info.mtime.value.getTime().toString(16) : "0"; | |
| 797 | + return `${info.size.toString(16)}-${mtime}`; | |
| 798 | +}; | |
| 799 | +var fromFileWeb = (file3) => { | |
| 800 | + return `${file3.size.toString(16)}-${file3.lastModified.toString(16)}`; | |
| 801 | +}; | |
| 802 | +var layer2 = succeed2(tag, tag.of({ | |
| 803 | + [GeneratorTypeId]: GeneratorTypeId, | |
| 804 | + fromFileInfo(info) { | |
| 805 | + return sync(() => ({ | |
| 806 | + _tag: "Strong", | |
| 807 | + value: fromFileInfo(info) | |
| 808 | + })); | |
| 809 | + }, | |
| 810 | + fromFileWeb(file3) { | |
| 811 | + return sync(() => ({ | |
| 812 | + _tag: "Strong", | |
| 813 | + value: fromFileWeb(file3) | |
| 814 | + })); | |
| 815 | + } | |
| 816 | +})); | |
| 817 | +var layerWeak = succeed2(tag, tag.of({ | |
| 818 | + [GeneratorTypeId]: GeneratorTypeId, | |
| 819 | + fromFileInfo(info) { | |
| 820 | + return sync(() => ({ | |
| 821 | + _tag: "Weak", | |
| 822 | + value: fromFileInfo(info) | |
| 823 | + })); | |
| 824 | + }, | |
| 825 | + fromFileWeb(file3) { | |
| 826 | + return sync(() => ({ | |
| 827 | + _tag: "Weak", | |
| 828 | + value: fromFileWeb(file3) | |
| 829 | + })); | |
| 830 | + } | |
| 831 | +})); | |
| 832 | + | |
| 833 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Etag.js | |
| 834 | +var toString3 = toString2; | |
| 835 | +var GeneratorTypeId2 = GeneratorTypeId; | |
| 836 | +var Generator = tag; | |
| 837 | +var layer3 = layer2; | |
| 838 | +var layerWeak2 = layerWeak; | |
| 839 | + | |
| 840 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/FetchHttpClient.js | |
| 841 | +var FetchHttpClient_exports = {}; | |
| 842 | +__export(FetchHttpClient_exports, { | |
| 843 | + Fetch: () => Fetch, | |
| 844 | + RequestInit: () => RequestInit, | |
| 845 | + layer: () => layer5 | |
| 846 | +}); | |
| 847 | + | |
| 848 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/fetchHttpClient.js | |
| 849 | +var fetchTagKey = "@effect/platform/FetchHttpClient/Fetch"; | |
| 850 | +var requestInitTagKey = "@effect/platform/FetchHttpClient/FetchOptions"; | |
| 851 | +var fetch = make8((request, url, signal, fiber) => { | |
| 852 | + const context2 = fiber.getFiberRef(currentContext); | |
| 853 | + const fetch2 = context2.unsafeMap.get(fetchTagKey) ?? globalThis.fetch; | |
| 854 | + const options4 = context2.unsafeMap.get(requestInitTagKey) ?? {}; | |
| 855 | + const headers = options4.headers ? merge3(fromInput2(options4.headers), request.headers) : request.headers; | |
| 856 | + const send = (body) => map5(tryPromise({ | |
| 857 | + try: () => fetch2(url, { | |
| 858 | + ...options4, | |
| 859 | + method: request.method, | |
| 860 | + headers, | |
| 861 | + body, | |
| 862 | + duplex: request.body._tag === "Stream" ? "half" : void 0, | |
| 863 | + signal | |
| 864 | + }), | |
| 865 | + catch: (cause) => new RequestError({ | |
| 866 | + request, | |
| 867 | + reason: "Transport", | |
| 868 | + cause | |
| 869 | + }) | |
| 870 | + }), (response) => fromWeb(request, response)); | |
| 871 | + switch (request.body._tag) { | |
| 872 | + case "Raw": | |
| 873 | + case "Uint8Array": | |
| 874 | + return send(request.body.body); | |
| 875 | + case "FormData": | |
| 876 | + return send(request.body.formData); | |
| 877 | + case "Stream": | |
| 878 | + return flatMap2(toReadableStreamEffect(request.body.stream), send); | |
| 879 | + } | |
| 880 | + return send(void 0); | |
| 881 | +}); | |
| 882 | +var layer4 = layerMergedContext(succeed(fetch)); | |
| 883 | + | |
| 884 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/FetchHttpClient.js | |
| 885 | +var Fetch = class extends Tag(fetchTagKey)() { | |
| 886 | +}; | |
| 887 | +var RequestInit = class extends Tag(requestInitTagKey)() { | |
| 888 | +}; | |
| 889 | +var layer5 = layer4; | |
| 890 | + | |
| 891 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpApiBuilder.js | |
| 892 | +var HttpApiBuilder_exports = {}; | |
| 893 | +__export(HttpApiBuilder_exports, { | |
| 894 | + HandlersTypeId: () => HandlersTypeId, | |
| 895 | + Middleware: () => Middleware, | |
| 896 | + Router: () => Router, | |
| 897 | + api: () => api, | |
| 898 | + buildMiddleware: () => buildMiddleware, | |
| 899 | + group: () => group, | |
| 900 | + handler: () => handler, | |
| 901 | + httpApp: () => httpApp, | |
| 902 | + middleware: () => middleware, | |
| 903 | + middlewareCors: () => middlewareCors, | |
| 904 | + middlewareOpenApi: () => middlewareOpenApi, | |
| 905 | + normalizeUrlParams: () => normalizeUrlParams, | |
| 906 | + securityDecode: () => securityDecode, | |
| 907 | + securitySetCookie: () => securitySetCookie, | |
| 908 | + serve: () => serve3, | |
| 909 | + toWebHandler: () => toWebHandler2 | |
| 910 | +}); | |
| 911 | + | |
| 912 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpApiMiddleware.js | |
| 913 | +var HttpApiMiddleware_exports = {}; | |
| 914 | +__export(HttpApiMiddleware_exports, { | |
| 915 | + SecurityTypeId: () => SecurityTypeId, | |
| 916 | + Tag: () => Tag2, | |
| 917 | + TypeId: () => TypeId4, | |
| 918 | + isSecurity: () => isSecurity | |
| 919 | +}); | |
| 920 | +var TypeId4 = Symbol.for("@effect/platform/HttpApiMiddleware"); | |
| 921 | +var SecurityTypeId = Symbol.for("@effect/platform/HttpApiMiddleware/Security"); | |
| 922 | +var isSecurity = (u) => hasProperty(u, SecurityTypeId); | |
| 923 | +var Tag2 = () => (id, options4) => { | |
| 924 | + const Err = globalThis.Error; | |
| 925 | + const limit = Err.stackTraceLimit; | |
| 926 | + Err.stackTraceLimit = 2; | |
| 927 | + const creationError = new Err(); | |
| 928 | + Err.stackTraceLimit = limit; | |
| 929 | + function TagClass() { | |
| 930 | + } | |
| 931 | + const TagClass_ = TagClass; | |
| 932 | + Object.setPrototypeOf(TagClass, Object.getPrototypeOf(GenericTag(id))); | |
| 933 | + TagClass.key = id; | |
| 934 | + Object.defineProperty(TagClass, "stack", { | |
| 935 | + get() { | |
| 936 | + return creationError.stack; | |
| 937 | + } | |
| 938 | + }); | |
| 939 | + TagClass_[TypeId4] = TypeId4; | |
| 940 | + TagClass_.failure = options4?.optional === true || options4?.failure === void 0 ? Never : options4.failure; | |
| 941 | + if (options4?.provides) { | |
| 942 | + TagClass_.provides = options4.provides; | |
| 943 | + } | |
| 944 | + TagClass_.optional = options4?.optional ?? false; | |
| 945 | + if (options4?.security) { | |
| 946 | + if (Object.keys(options4.security).length === 0) { | |
| 947 | + throw new Error("HttpApiMiddleware.Tag: security object must not be empty"); | |
| 948 | + } | |
| 949 | + TagClass_[SecurityTypeId] = SecurityTypeId; | |
| 950 | + TagClass_.security = options4.security; | |
| 951 | + } | |
| 952 | + return TagClass; | |
| 953 | +}; | |
| 954 | + | |
| 955 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpApp.js | |
| 956 | +var HttpApp_exports = {}; | |
| 957 | +__export(HttpApp_exports, { | |
| 958 | + appendPreResponseHandler: () => appendPreResponseHandler2, | |
| 959 | + currentPreResponseHandlers: () => currentPreResponseHandlers2, | |
| 960 | + ejectDefaultScopeClose: () => ejectDefaultScopeClose, | |
| 961 | + fromWebHandler: () => fromWebHandler, | |
| 962 | + toHandled: () => toHandled, | |
| 963 | + toWebHandler: () => toWebHandler, | |
| 964 | + toWebHandlerLayer: () => toWebHandlerLayer, | |
| 965 | + toWebHandlerLayerWith: () => toWebHandlerLayerWith, | |
| 966 | + toWebHandlerRuntime: () => toWebHandlerRuntime, | |
| 967 | + unsafeEjectStreamScope: () => unsafeEjectStreamScope, | |
| 968 | + withPreResponseHandler: () => withPreResponseHandler2 | |
| 969 | +}); | |
| 970 | + | |
| 971 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerError.js | |
| 972 | +var HttpServerError_exports = {}; | |
| 973 | +__export(HttpServerError_exports, { | |
| 974 | + RequestError: () => RequestError2, | |
| 975 | + ResponseError: () => ResponseError, | |
| 976 | + RouteNotFound: () => RouteNotFound, | |
| 977 | + ServeError: () => ServeError, | |
| 978 | + TypeId: () => TypeId8, | |
| 979 | + causeResponse: () => causeResponse2, | |
| 980 | + causeResponseStripped: () => causeResponseStripped2, | |
| 981 | + clientAbortFiberId: () => clientAbortFiberId2, | |
| 982 | + exitResponse: () => exitResponse2, | |
| 983 | + isServerError: () => isServerError2 | |
| 984 | +}); | |
| 985 | + | |
| 986 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerRespondable.js | |
| 987 | +var HttpServerRespondable_exports = {}; | |
| 988 | +__export(HttpServerRespondable_exports, { | |
| 989 | + isRespondable: () => isRespondable, | |
| 990 | + symbol: () => symbol, | |
| 991 | + toResponse: () => toResponse, | |
| 992 | + toResponseOrElse: () => toResponseOrElse, | |
| 993 | + toResponseOrElseDefect: () => toResponseOrElseDefect | |
| 994 | +}); | |
| 995 | + | |
| 996 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerResponse.js | |
| 997 | +var HttpServerResponse_exports = {}; | |
| 998 | +__export(HttpServerResponse_exports, { | |
| 999 | + TypeId: () => TypeId6, | |
| 1000 | + empty: () => empty13, | |
| 1001 | + expireCookie: () => expireCookie2, | |
| 1002 | + file: () => file2, | |
| 1003 | + fileWeb: () => fileWeb2, | |
| 1004 | + formData: () => formData3, | |
| 1005 | + fromWeb: () => fromWeb2, | |
| 1006 | + html: () => html2, | |
| 1007 | + htmlStream: () => htmlStream2, | |
| 1008 | + isServerResponse: () => isServerResponse2, | |
| 1009 | + json: () => json3, | |
| 1010 | + mergeCookies: () => mergeCookies2, | |
| 1011 | + raw: () => raw3, | |
| 1012 | + redirect: () => redirect2, | |
| 1013 | + removeCookie: () => removeCookie2, | |
| 1014 | + replaceCookies: () => replaceCookies2, | |
| 1015 | + schemaJson: () => schemaJson3, | |
| 1016 | + setBody: () => setBody2, | |
| 1017 | + setCookie: () => setCookie2, | |
| 1018 | + setCookies: () => setCookies2, | |
| 1019 | + setHeader: () => setHeader2, | |
| 1020 | + setHeaders: () => setHeaders2, | |
| 1021 | + setStatus: () => setStatus2, | |
| 1022 | + stream: () => stream7, | |
| 1023 | + text: () => text3, | |
| 1024 | + toWeb: () => toWeb2, | |
| 1025 | + uint8Array: () => uint8Array3, | |
| 1026 | + unsafeJson: () => unsafeJson3, | |
| 1027 | + unsafeSetCookie: () => unsafeSetCookie2, | |
| 1028 | + unsafeSetCookies: () => unsafeSetCookies2, | |
| 1029 | + updateCookies: () => updateCookies2, | |
| 1030 | + urlParams: () => urlParams2 | |
| 1031 | +}); | |
| 1032 | + | |
| 1033 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Template.js | |
| 1034 | +var Template_exports = {}; | |
| 1035 | +__export(Template_exports, { | |
| 1036 | + make: () => make11, | |
| 1037 | + stream: () => stream5 | |
| 1038 | +}); | |
| 1039 | +function make11(strings, ...args) { | |
| 1040 | + const argsLength = args.length; | |
| 1041 | + const values = new Array(argsLength); | |
| 1042 | + const effects = []; | |
| 1043 | + for (let i = 0; i < argsLength; i++) { | |
| 1044 | + const arg = args[i]; | |
| 1045 | + if (isOption(arg)) { | |
| 1046 | + values[i] = arg._tag === "Some" ? primitiveToString(arg.value) : ""; | |
| 1047 | + } else if (isSuccess(arg)) { | |
| 1048 | + values[i] = primitiveToString(arg.effect_instruction_i0); | |
| 1049 | + } else if (isEffect(arg)) { | |
| 1050 | + effects.push([i, arg]); | |
| 1051 | + } else { | |
| 1052 | + values[i] = primitiveToString(arg); | |
| 1053 | + } | |
| 1054 | + } | |
| 1055 | + if (effects.length === 0) { | |
| 1056 | + return succeed(consolidate(strings, values)); | |
| 1057 | + } | |
| 1058 | + return map5(forEach2(effects, ([index, effect2]) => tap(effect2, (value2) => { | |
| 1059 | + values[index] = primitiveToString(value2); | |
| 1060 | + }), { | |
| 1061 | + concurrency: "inherit", | |
| 1062 | + discard: true | |
| 1063 | + }), (_) => consolidate(strings, values)); | |
| 1064 | +} | |
| 1065 | +function stream5(strings, ...args) { | |
| 1066 | + const chunks = []; | |
| 1067 | + let buffer = ""; | |
| 1068 | + for (let i = 0, len = args.length; i < len; i++) { | |
| 1069 | + buffer += strings[i]; | |
| 1070 | + const arg = args[i]; | |
| 1071 | + if (isOption(arg)) { | |
| 1072 | + buffer += arg._tag === "Some" ? primitiveToString(arg.value) : ""; | |
| 1073 | + } else if (isSuccess(arg)) { | |
| 1074 | + buffer += primitiveToString(arg.effect_instruction_i0); | |
| 1075 | + } else if (hasProperty(arg, StreamTypeId)) { | |
| 1076 | + if (buffer.length > 0) { | |
| 1077 | + chunks.push(buffer); | |
| 1078 | + buffer = ""; | |
| 1079 | + } | |
| 1080 | + if (isEffect(arg)) { | |
| 1081 | + chunks.push(map5(arg, primitiveToString)); | |
| 1082 | + } else { | |
| 1083 | + chunks.push(map6(arg, primitiveToString)); | |
| 1084 | + } | |
| 1085 | + } else { | |
| 1086 | + buffer += primitiveToString(arg); | |
| 1087 | + } | |
| 1088 | + } | |
| 1089 | + buffer += strings[strings.length - 1]; | |
| 1090 | + if (buffer.length > 0) { | |
| 1091 | + chunks.push(buffer); | |
| 1092 | + buffer = ""; | |
| 1093 | + } | |
| 1094 | + return flatMap3(fromIterable5(chunks), (chunk) => typeof chunk === "string" ? succeed3(chunk) : chunk, { | |
| 1095 | + concurrency: "unbounded" | |
| 1096 | + }); | |
| 1097 | +} | |
| 1098 | +function primitiveToString(value2) { | |
| 1099 | + if (Array.isArray(value2)) { | |
| 1100 | + return value2.map(primitiveToString).join(""); | |
| 1101 | + } | |
| 1102 | + switch (typeof value2) { | |
| 1103 | + case "string": { | |
| 1104 | + return value2; | |
| 1105 | + } | |
| 1106 | + case "number": | |
| 1107 | + case "bigint": { | |
| 1108 | + return value2.toString(); | |
| 1109 | + } | |
| 1110 | + case "boolean": { | |
| 1111 | + return value2 ? "true" : "false"; | |
| 1112 | + } | |
| 1113 | + default: { | |
| 1114 | + return ""; | |
| 1115 | + } | |
| 1116 | + } | |
| 1117 | +} | |
| 1118 | +function consolidate(strings, values) { | |
| 1119 | + let out = ""; | |
| 1120 | + for (let i = 0, len = values.length; i < len; i++) { | |
| 1121 | + out += strings[i]; | |
| 1122 | + out += values[i]; | |
| 1123 | + } | |
| 1124 | + return out + strings[strings.length - 1]; | |
| 1125 | +} | |
| 1126 | +function isSuccess(u) { | |
| 1127 | + return isEffect(u) && u._op === "Success"; | |
| 1128 | +} | |
| 1129 | + | |
| 1130 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpServerResponse.js | |
| 1131 | +var TypeId5 = Symbol.for("@effect/platform/HttpServerResponse"); | |
| 1132 | +var respondableSymbol = Symbol.for("@effect/platform/HttpServerRespondable"); | |
| 1133 | +var ServerResponseImpl = class extends StructuralClass { | |
| 1134 | + status; | |
| 1135 | + statusText; | |
| 1136 | + cookies; | |
| 1137 | + body; | |
| 1138 | + [TypeId5]; | |
| 1139 | + headers; | |
| 1140 | + constructor(status, statusText, headers, cookies, body) { | |
| 1141 | + super(); | |
| 1142 | + this.status = status; | |
| 1143 | + this.statusText = statusText; | |
| 1144 | + this.cookies = cookies; | |
| 1145 | + this.body = body; | |
| 1146 | + this[TypeId5] = TypeId5; | |
| 1147 | + if (body.contentType || body.contentLength) { | |
| 1148 | + const newHeaders = { | |
| 1149 | + ...headers | |
| 1150 | + }; | |
| 1151 | + if (body.contentType) { | |
| 1152 | + newHeaders["content-type"] = body.contentType; | |
| 1153 | + } | |
| 1154 | + if (body.contentLength) { | |
| 1155 | + newHeaders["content-length"] = body.contentLength.toString(); | |
| 1156 | + } | |
| 1157 | + this.headers = newHeaders; | |
| 1158 | + } else { | |
| 1159 | + this.headers = headers; | |
| 1160 | + } | |
| 1161 | + } | |
| 1162 | + commit() { | |
| 1163 | + return succeed(this); | |
| 1164 | + } | |
| 1165 | + [respondableSymbol]() { | |
| 1166 | + return succeed(this); | |
| 1167 | + } | |
| 1168 | + [NodeInspectSymbol]() { | |
| 1169 | + return this.toJSON(); | |
| 1170 | + } | |
| 1171 | + toString() { | |
| 1172 | + return format(this); | |
| 1173 | + } | |
| 1174 | + toJSON() { | |
| 1175 | + return { | |
| 1176 | + _id: "@effect/platform/HttpServerResponse", | |
| 1177 | + status: this.status, | |
| 1178 | + statusText: this.statusText, | |
| 1179 | + headers: redact(this.headers), | |
| 1180 | + cookies: this.cookies.toJSON(), | |
| 1181 | + body: this.body.toJSON() | |
| 1182 | + }; | |
| 1183 | + } | |
| 1184 | +}; | |
| 1185 | +var isServerResponse = (u) => typeof u === "object" && u !== null && TypeId5 in u; | |
| 1186 | +var empty12 = (options4) => new ServerResponseImpl(options4?.status ?? 204, options4?.statusText, options4?.headers ? fromInput2(options4.headers) : empty10, options4?.cookies ?? empty9, empty8); | |
| 1187 | +var redirect = (location, options4) => { | |
| 1188 | + const headers = unsafeFromRecord({ | |
| 1189 | + location: location.toString() | |
| 1190 | + }); | |
| 1191 | + return new ServerResponseImpl(options4?.status ?? 302, options4?.statusText, options4?.headers ? merge3(headers, fromInput2(options4.headers)) : headers, options4?.cookies ?? empty9, empty8); | |
| 1192 | +}; | |
| 1193 | +var uint8Array2 = (body, options4) => { | |
| 1194 | + const headers = options4?.headers ? fromInput2(options4.headers) : empty10; | |
| 1195 | + return new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, headers, options4?.cookies ?? empty9, uint8Array(body, getContentType(options4, headers))); | |
| 1196 | +}; | |
| 1197 | +var text2 = (body, options4) => { | |
| 1198 | + const headers = options4?.headers ? fromInput2(options4.headers) : empty10; | |
| 1199 | + return new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, headers, options4?.cookies ?? empty9, text(body, getContentType(options4, headers))); | |
| 1200 | +}; | |
| 1201 | +var html = (strings, ...args) => { | |
| 1202 | + if (typeof strings === "string") { | |
| 1203 | + return text2(strings, { | |
| 1204 | + contentType: "text/html" | |
| 1205 | + }); | |
| 1206 | + } | |
| 1207 | + return map5(make11(strings, ...args), (_) => text2(_, { | |
| 1208 | + contentType: "text/html" | |
| 1209 | + })); | |
| 1210 | +}; | |
| 1211 | +var htmlStream = (strings, ...args) => map5(context(), (context2) => stream6(provideContext(encodeText(stream5(strings, ...args)), context2), { | |
| 1212 | + contentType: "text/html" | |
| 1213 | +})); | |
| 1214 | +var json2 = (body, options4) => map5(json(body), (body2) => new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, options4?.headers ? fromInput2(options4.headers) : empty10, options4?.cookies ?? empty9, body2)); | |
| 1215 | +var unsafeJson2 = (body, options4) => new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, options4?.headers ? fromInput2(options4.headers) : empty10, options4?.cookies ?? empty9, unsafeJson(body)); | |
| 1216 | +var schemaJson2 = (schema2, options4) => { | |
| 1217 | + const encode4 = jsonSchema(schema2, options4); | |
| 1218 | + return (body, options5) => map5(encode4(body), (body2) => new ServerResponseImpl(options5?.status ?? 200, options5?.statusText, options5?.headers ? fromInput2(options5.headers) : empty10, options5?.cookies ?? empty9, body2)); | |
| 1219 | +}; | |
| 1220 | +var httpPlatform = GenericTag("@effect/platform/HttpPlatform"); | |
| 1221 | +var file = (path, options4) => flatMap2(httpPlatform, (platform) => platform.fileResponse(path, options4)); | |
| 1222 | +var fileWeb = (file3, options4) => flatMap2(httpPlatform, (platform) => platform.fileWebResponse(file3, options4)); | |
| 1223 | +var urlParams = (body, options4) => new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, options4?.headers ? fromInput2(options4.headers) : empty10, options4?.cookies ?? empty9, text(toString(fromInput(body)), "application/x-www-form-urlencoded")); | |
| 1224 | +var raw2 = (body, options4) => new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, options4?.headers ? fromInput2(options4.headers) : empty10, options4?.cookies ?? empty9, raw(body, { | |
| 1225 | + contentType: options4?.contentType, | |
| 1226 | + contentLength: options4?.contentLength | |
| 1227 | +})); | |
| 1228 | +var formData2 = (body, options4) => new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, options4?.headers ? fromInput2(options4.headers) : empty10, options4?.cookies ?? empty9, formData(body)); | |
| 1229 | +var stream6 = (body, options4) => { | |
| 1230 | + const headers = options4?.headers ? fromInput2(options4.headers) : empty10; | |
| 1231 | + return new ServerResponseImpl(options4?.status ?? 200, options4?.statusText, headers, options4?.cookies ?? empty9, stream(body, getContentType(options4, headers), options4?.contentLength)); | |
| 1232 | +}; | |
| 1233 | +var getContentType = (options4, headers) => { | |
| 1234 | + if (options4?.contentType) { | |
| 1235 | + return options4.contentType; | |
| 1236 | + } else if (options4?.headers) { | |
| 1237 | + return headers["content-type"]; | |
| 1238 | + } else { | |
| 1239 | + return; | |
| 1240 | + } | |
| 1241 | +}; | |
| 1242 | +var setHeader = dual(3, (self, key, value2) => new ServerResponseImpl(self.status, self.statusText, set3(self.headers, key, value2), self.cookies, self.body)); | |
| 1243 | +var replaceCookies = dual(2, (self, cookies) => new ServerResponseImpl(self.status, self.statusText, self.headers, cookies, self.body)); | |
| 1244 | +var setCookie = dual((args) => isServerResponse(args[0]), (self, name, value2, options4) => map5(set2(self.cookies, name, value2, options4), (cookies) => new ServerResponseImpl(self.status, self.statusText, self.headers, cookies, self.body))); | |
| 1245 | +var unsafeSetCookie = dual((args) => isServerResponse(args[0]), (self, name, value2, options4) => new ServerResponseImpl(self.status, self.statusText, self.headers, unsafeSet(self.cookies, name, value2, options4), self.body)); | |
| 1246 | +var updateCookies = dual(2, (self, f) => new ServerResponseImpl(self.status, self.statusText, self.headers, f(self.cookies), self.body)); | |
| 1247 | +var setCookies = dual(2, (self, cookies) => map5(setAll(self.cookies, cookies), (cookies2) => new ServerResponseImpl(self.status, self.statusText, self.headers, cookies2, self.body))); | |
| 1248 | +var mergeCookies = dual(2, (self, cookies) => new ServerResponseImpl(self.status, self.statusText, self.headers, merge2(self.cookies, cookies), self.body)); | |
| 1249 | +var unsafeSetCookies = dual(2, (self, cookies) => new ServerResponseImpl(self.status, self.statusText, self.headers, unsafeSetAll(self.cookies, cookies), self.body)); | |
| 1250 | +var removeCookie = dual(2, (self, name) => new ServerResponseImpl(self.status, self.statusText, self.headers, remove2(self.cookies, name), self.body)); | |
| 1251 | +var expireCookie = dual(3, (self, name, options4) => new ServerResponseImpl(self.status, self.statusText, self.headers, unsafeSet(self.cookies, name, "", { | |
| 1252 | + ...options4 ?? {}, | |
| 1253 | + maxAge: 0 | |
| 1254 | +}), self.body)); | |
| 1255 | +var setHeaders = dual(2, (self, input) => new ServerResponseImpl(self.status, self.statusText, setAll2(self.headers, input), self.cookies, self.body)); | |
| 1256 | +var setStatus = dual((args) => isServerResponse(args[0]), (self, status, statusText) => new ServerResponseImpl(status, statusText, self.headers, self.cookies, self.body)); | |
| 1257 | +var setBody = dual(2, (self, body) => { | |
| 1258 | + let headers = self.headers; | |
| 1259 | + if (body._tag === "Empty") { | |
| 1260 | + headers = remove3(remove3(headers, "Content-Type"), "Content-length"); | |
| 1261 | + } | |
| 1262 | + return new ServerResponseImpl(self.status, self.statusText, headers, self.cookies, body); | |
| 1263 | +}); | |
| 1264 | +var toWeb = (response, options4) => { | |
| 1265 | + const headers = new globalThis.Headers(response.headers); | |
| 1266 | + if (!isEmpty2(response.cookies)) { | |
| 1267 | + const toAdd = toSetCookieHeaders(response.cookies); | |
| 1268 | + for (const header of toAdd) { | |
| 1269 | + headers.append("set-cookie", header); | |
| 1270 | + } | |
| 1271 | + } | |
| 1272 | + if (options4?.withoutBody) { | |
| 1273 | + return new Response(void 0, { | |
| 1274 | + status: response.status, | |
| 1275 | + statusText: response.statusText, | |
| 1276 | + headers | |
| 1277 | + }); | |
| 1278 | + } | |
| 1279 | + const body = response.body; | |
| 1280 | + switch (body._tag) { | |
| 1281 | + case "Empty": { | |
| 1282 | + return new Response(void 0, { | |
| 1283 | + status: response.status, | |
| 1284 | + statusText: response.statusText, | |
| 1285 | + headers | |
| 1286 | + }); | |
| 1287 | + } | |
| 1288 | + case "Uint8Array": | |
| 1289 | + case "Raw": { | |
| 1290 | + if (body.body instanceof Response) { | |
| 1291 | + for (const [key, value2] of headers) { | |
| 1292 | + body.body.headers.set(key, value2); | |
| 1293 | + } | |
| 1294 | + return body.body; | |
| 1295 | + } | |
| 1296 | + return new Response(body.body, { | |
| 1297 | + status: response.status, | |
| 1298 | + statusText: response.statusText, | |
| 1299 | + headers | |
| 1300 | + }); | |
| 1301 | + } | |
| 1302 | + case "FormData": { | |
| 1303 | + return new Response(body.formData, { | |
| 1304 | + status: response.status, | |
| 1305 | + statusText: response.statusText, | |
| 1306 | + headers | |
| 1307 | + }); | |
| 1308 | + } | |
| 1309 | + case "Stream": { | |
| 1310 | + return new Response(toReadableStreamRuntime(body.stream, options4?.runtime ?? defaultRuntime), { | |
| 1311 | + status: response.status, | |
| 1312 | + statusText: response.statusText, | |
| 1313 | + headers | |
| 1314 | + }); | |
| 1315 | + } | |
| 1316 | + } | |
| 1317 | +}; | |
| 1318 | + | |
| 1319 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerResponse.js | |
| 1320 | +var TypeId6 = Symbol.for("@effect/platform/HttpServerResponse"); | |
| 1321 | +var isServerResponse2 = isServerResponse; | |
| 1322 | +var empty13 = empty12; | |
| 1323 | +var redirect2 = redirect; | |
| 1324 | +var uint8Array3 = uint8Array2; | |
| 1325 | +var text3 = text2; | |
| 1326 | +var html2 = html; | |
| 1327 | +var htmlStream2 = htmlStream; | |
| 1328 | +var json3 = json2; | |
| 1329 | +var schemaJson3 = schemaJson2; | |
| 1330 | +var unsafeJson3 = unsafeJson2; | |
| 1331 | +var urlParams2 = urlParams; | |
| 1332 | +var raw3 = raw2; | |
| 1333 | +var formData3 = formData2; | |
| 1334 | +var stream7 = stream6; | |
| 1335 | +var file2 = file; | |
| 1336 | +var fileWeb2 = fileWeb; | |
| 1337 | +var setHeader2 = setHeader; | |
| 1338 | +var setHeaders2 = setHeaders; | |
| 1339 | +var removeCookie2 = removeCookie; | |
| 1340 | +var expireCookie2 = expireCookie; | |
| 1341 | +var replaceCookies2 = replaceCookies; | |
| 1342 | +var setCookie2 = setCookie; | |
| 1343 | +var unsafeSetCookie2 = unsafeSetCookie; | |
| 1344 | +var updateCookies2 = updateCookies; | |
| 1345 | +var mergeCookies2 = mergeCookies; | |
| 1346 | +var setCookies2 = setCookies; | |
| 1347 | +var unsafeSetCookies2 = unsafeSetCookies; | |
| 1348 | +var setBody2 = setBody; | |
| 1349 | +var setStatus2 = setStatus; | |
| 1350 | +var toWeb2 = toWeb; | |
| 1351 | +var fromWeb2 = (response) => { | |
| 1352 | + const headers = new globalThis.Headers(response.headers); | |
| 1353 | + const setCookieHeaders = headers.getSetCookie(); | |
| 1354 | + headers.delete("set-cookie"); | |
| 1355 | + let self = empty13({ | |
| 1356 | + status: response.status, | |
| 1357 | + statusText: response.statusText, | |
| 1358 | + headers, | |
| 1359 | + cookies: fromSetCookie(setCookieHeaders) | |
| 1360 | + }); | |
| 1361 | + if (response.body) { | |
| 1362 | + self = setBody2(self, stream2(fromReadableStream({ | |
| 1363 | + evaluate: () => response.body, | |
| 1364 | + onError: (e) => e | |
| 1365 | + }))); | |
| 1366 | + } | |
| 1367 | + return self; | |
| 1368 | +}; | |
| 1369 | + | |
| 1370 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerRespondable.js | |
| 1371 | +var symbol = Symbol.for("@effect/platform/HttpServerRespondable"); | |
| 1372 | +var isRespondable = (u) => hasProperty(u, symbol); | |
| 1373 | +var badRequest = empty13({ | |
| 1374 | + status: 400 | |
| 1375 | +}); | |
| 1376 | +var notFound = empty13({ | |
| 1377 | + status: 404 | |
| 1378 | +}); | |
| 1379 | +var toResponse = (self) => { | |
| 1380 | + if (isServerResponse2(self)) { | |
| 1381 | + return succeed(self); | |
| 1382 | + } | |
| 1383 | + return orDie(self[symbol]()); | |
| 1384 | +}; | |
| 1385 | +var toResponseOrElse = (u, orElse3) => { | |
| 1386 | + if (isServerResponse2(u)) { | |
| 1387 | + return succeed(u); | |
| 1388 | + } else if (isRespondable(u)) { | |
| 1389 | + return catchAllCause(u[symbol](), () => succeed(orElse3)); | |
| 1390 | + } else if (isParseError(u)) { | |
| 1391 | + return succeed(badRequest); | |
| 1392 | + } else if (isNoSuchElementException(u)) { | |
| 1393 | + return succeed(notFound); | |
| 1394 | + } | |
| 1395 | + return succeed(orElse3); | |
| 1396 | +}; | |
| 1397 | +var toResponseOrElseDefect = (u, orElse3) => { | |
| 1398 | + if (isServerResponse2(u)) { | |
| 1399 | + return succeed(u); | |
| 1400 | + } else if (isRespondable(u)) { | |
| 1401 | + return catchAllCause(u[symbol](), () => succeed(orElse3)); | |
| 1402 | + } | |
| 1403 | + return succeed(orElse3); | |
| 1404 | +}; | |
| 1405 | + | |
| 1406 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpServerError.js | |
| 1407 | +var TypeId7 = Symbol.for("@effect/platform/HttpServerError"); | |
| 1408 | +var isServerError = (u) => hasProperty(u, TypeId7); | |
| 1409 | +var clientAbortFiberId = globalValue("@effect/platform/HttpServerError/clientAbortFiberId", () => runtime(-499, 0)); | |
| 1410 | +var causeResponse = (cause) => { | |
| 1411 | + const [effect2, stripped] = reduce2(cause, [succeed(internalServerError), empty6], (acc, cause2) => { | |
| 1412 | + const withoutInterrupt = isInterruptType(acc[1]) ? empty6 : acc[1]; | |
| 1413 | + switch (cause2._tag) { | |
| 1414 | + case "Fail": { | |
| 1415 | + return some([toResponseOrElse(cause2.error, internalServerError), combineCauses(withoutInterrupt, cause2)]); | |
| 1416 | + } | |
| 1417 | + case "Die": { | |
| 1418 | + const isResponse = isServerResponse(cause2.defect); | |
| 1419 | + return some([toResponseOrElseDefect(cause2.defect, internalServerError), isResponse ? withoutInterrupt : combineCauses(withoutInterrupt, cause2)]); | |
| 1420 | + } | |
| 1421 | + case "Interrupt": { | |
| 1422 | + if (acc[1]._tag !== "Empty") { | |
| 1423 | + return none(); | |
| 1424 | + } | |
| 1425 | + const response = cause2.fiberId === clientAbortFiberId ? clientAbortError : serverAbortError; | |
| 1426 | + return some([succeed(response), cause2]); | |
| 1427 | + } | |
| 1428 | + default: { | |
| 1429 | + return none(); | |
| 1430 | + } | |
| 1431 | + } | |
| 1432 | + }); | |
| 1433 | + return map5(effect2, (response) => { | |
| 1434 | + if (isEmptyType(stripped)) { | |
| 1435 | + return [response, empty6]; | |
| 1436 | + } | |
| 1437 | + return [response, sequential(stripped, die(response))]; | |
| 1438 | + }); | |
| 1439 | +}; | |
| 1440 | +var combineCauses = (left2, right2) => { | |
| 1441 | + if (isEmptyType(left2)) { | |
| 1442 | + return right2; | |
| 1443 | + } else if (isEmptyType(right2)) { | |
| 1444 | + return left2; | |
| 1445 | + } | |
| 1446 | + return sequential(left2, right2); | |
| 1447 | +}; | |
| 1448 | +var causeResponseStripped = (cause) => { | |
| 1449 | + let response; | |
| 1450 | + const stripped = stripSomeDefects(cause, (defect) => { | |
| 1451 | + if (isServerResponse(defect)) { | |
| 1452 | + response = defect; | |
| 1453 | + return some(empty6); | |
| 1454 | + } | |
| 1455 | + return none(); | |
| 1456 | + }); | |
| 1457 | + return [response ?? internalServerError, stripped]; | |
| 1458 | +}; | |
| 1459 | +var internalServerError = empty12({ | |
| 1460 | + status: 500 | |
| 1461 | +}); | |
| 1462 | +var clientAbortError = empty12({ | |
| 1463 | + status: 499 | |
| 1464 | +}); | |
| 1465 | +var serverAbortError = empty12({ | |
| 1466 | + status: 503 | |
| 1467 | +}); | |
| 1468 | +var exitResponse = (exit2) => { | |
| 1469 | + if (exit2._tag === "Success") { | |
| 1470 | + return exit2.value; | |
| 1471 | + } | |
| 1472 | + return causeResponseStripped(exit2.cause)[0]; | |
| 1473 | +}; | |
| 1474 | + | |
| 1475 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerError.js | |
| 1476 | +var TypeId8 = TypeId7; | |
| 1477 | +var RequestError2 = class extends TypeIdError(TypeId8, "RequestError") { | |
| 1478 | + /** | |
| 1479 | + * @since 1.0.0 | |
| 1480 | + */ | |
| 1481 | + [symbol]() { | |
| 1482 | + return empty13({ | |
| 1483 | + status: 400 | |
| 1484 | + }); | |
| 1485 | + } | |
| 1486 | + get methodAndUrl() { | |
| 1487 | + return `${this.request.method} ${this.request.url}`; | |
| 1488 | + } | |
| 1489 | + get message() { | |
| 1490 | + return this.description ? `${this.reason}: ${this.description} (${this.methodAndUrl})` : `${this.reason} error (${this.methodAndUrl})`; | |
| 1491 | + } | |
| 1492 | +}; | |
| 1493 | +var isServerError2 = isServerError; | |
| 1494 | +var RouteNotFound = class extends TypeIdError(TypeId8, "RouteNotFound") { | |
| 1495 | + constructor(options4) { | |
| 1496 | + super(options4); | |
| 1497 | + this.stack = `${this.name}: ${this.message}`; | |
| 1498 | + } | |
| 1499 | + /** | |
| 1500 | + * @since 1.0.0 | |
| 1501 | + */ | |
| 1502 | + [symbol]() { | |
| 1503 | + return empty13({ | |
| 1504 | + status: 404 | |
| 1505 | + }); | |
| 1506 | + } | |
| 1507 | + get message() { | |
| 1508 | + return `${this.request.method} ${this.request.url} not found`; | |
| 1509 | + } | |
| 1510 | +}; | |
| 1511 | +var ResponseError = class extends TypeIdError(TypeId8, "ResponseError") { | |
| 1512 | + /** | |
| 1513 | + * @since 1.0.0 | |
| 1514 | + */ | |
| 1515 | + [symbol]() { | |
| 1516 | + return empty13({ | |
| 1517 | + status: 500 | |
| 1518 | + }); | |
| 1519 | + } | |
| 1520 | + get methodAndUrl() { | |
| 1521 | + return `${this.request.method} ${this.request.url}`; | |
| 1522 | + } | |
| 1523 | + get message() { | |
| 1524 | + const info = `${this.response.status} ${this.methodAndUrl}`; | |
| 1525 | + return this.description ? `${this.description} (${info})` : `${this.reason} error (${info})`; | |
| 1526 | + } | |
| 1527 | +}; | |
| 1528 | +var ServeError = class extends TypeIdError(TypeId8, "ServeError") { | |
| 1529 | +}; | |
| 1530 | +var clientAbortFiberId2 = clientAbortFiberId; | |
| 1531 | +var causeResponse2 = causeResponse; | |
| 1532 | +var causeResponseStripped2 = causeResponseStripped; | |
| 1533 | +var exitResponse2 = exitResponse; | |
| 1534 | + | |
| 1535 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerRequest.js | |
| 1536 | +var HttpServerRequest_exports = {}; | |
| 1537 | +__export(HttpServerRequest_exports, { | |
| 1538 | + HttpServerRequest: () => HttpServerRequest, | |
| 1539 | + MaxBodySize: () => MaxBodySize, | |
| 1540 | + ParsedSearchParams: () => ParsedSearchParams, | |
| 1541 | + TypeId: () => TypeId11, | |
| 1542 | + fromWeb: () => fromWeb4, | |
| 1543 | + persistedMultipart: () => persistedMultipart, | |
| 1544 | + schemaBodyForm: () => schemaBodyForm2, | |
| 1545 | + schemaBodyFormJson: () => schemaBodyFormJson2, | |
| 1546 | + schemaBodyJson: () => schemaBodyJson3, | |
| 1547 | + schemaBodyMultipart: () => schemaBodyMultipart2, | |
| 1548 | + schemaBodyUrlParams: () => schemaBodyUrlParams3, | |
| 1549 | + schemaCookies: () => schemaCookies2, | |
| 1550 | + schemaHeaders: () => schemaHeaders3, | |
| 1551 | + schemaSearchParams: () => schemaSearchParams2, | |
| 1552 | + searchParamsFromURL: () => searchParamsFromURL2, | |
| 1553 | + toURL: () => toURL2, | |
| 1554 | + toWeb: () => toWeb3, | |
| 1555 | + toWebEither: () => toWebEither, | |
| 1556 | + upgrade: () => upgrade2, | |
| 1557 | + upgradeChannel: () => upgradeChannel2, | |
| 1558 | + withMaxBodySize: () => withMaxBodySize | |
| 1559 | +}); | |
| 1560 | + | |
| 1561 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Multipart.js | |
| 1562 | +var Multipart_exports = {}; | |
| 1563 | +__export(Multipart_exports, { | |
| 1564 | + ErrorTypeId: () => ErrorTypeId, | |
| 1565 | + FieldMimeTypes: () => FieldMimeTypes, | |
| 1566 | + FileSchema: () => FileSchema, | |
| 1567 | + FilesSchema: () => FilesSchema, | |
| 1568 | + MaxFieldSize: () => MaxFieldSize, | |
| 1569 | + MaxFileSize: () => MaxFileSize, | |
| 1570 | + MaxParts: () => MaxParts, | |
| 1571 | + MultipartError: () => MultipartError, | |
| 1572 | + SingleFileSchema: () => SingleFileSchema, | |
| 1573 | + TypeId: () => TypeId9, | |
| 1574 | + collectUint8Array: () => collectUint8Array2, | |
| 1575 | + isField: () => isField, | |
| 1576 | + isFile: () => isFile, | |
| 1577 | + isPart: () => isPart, | |
| 1578 | + isPersistedFile: () => isPersistedFile, | |
| 1579 | + makeChannel: () => makeChannel, | |
| 1580 | + makeConfig: () => makeConfig, | |
| 1581 | + schemaJson: () => schemaJson4, | |
| 1582 | + schemaPersisted: () => schemaPersisted, | |
| 1583 | + toPersisted: () => toPersisted, | |
| 1584 | + withFieldMimeTypes: () => withFieldMimeTypes, | |
| 1585 | + withLimits: () => withLimits, | |
| 1586 | + withLimitsStream: () => withLimitsStream, | |
| 1587 | + withMaxFieldSize: () => withMaxFieldSize, | |
| 1588 | + withMaxFileSize: () => withMaxFileSize, | |
| 1589 | + withMaxParts: () => withMaxParts | |
| 1590 | +}); | |
| 1591 | + | |
| 1592 | +// ../../node_modules/.bun/multipasta@0.2.7/node_modules/multipasta/dist/esm/internal/contentType.js | |
| 1593 | +var paramRE = /; *([!#$%&'*+.^\w`|~-]+)=("(?:[\v\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\v\u0020-\u00ff])*"|[!#$%&'*+.^\w`|~-]+) */gu; | |
| 1594 | +var quotedPairRE = /\\([\v\u0020-\u00ff])/gu; | |
| 1595 | +var mediaTypeRE = /^[!#$%&'*+.^\w|~-]+\/[!#$%&'*+.^\w|~-]+$/u; | |
| 1596 | +var mediaTypeRENoSlash = /^[!#$%&'*+.^\w|~-]+$/u; | |
| 1597 | +var defaultContentType = { | |
| 1598 | + value: "", | |
| 1599 | + parameters: /* @__PURE__ */ Object.create(null) | |
| 1600 | +}; | |
| 1601 | +function parse(header, withoutSlash = false) { | |
| 1602 | + if (typeof header !== "string") { | |
| 1603 | + return defaultContentType; | |
| 1604 | + } | |
| 1605 | + let index = header.indexOf(";"); | |
| 1606 | + const type = index !== -1 ? header.slice(0, index).trim() : header.trim(); | |
| 1607 | + const mediaRE = withoutSlash ? mediaTypeRENoSlash : mediaTypeRE; | |
| 1608 | + if (mediaRE.test(type) === false) { | |
| 1609 | + return defaultContentType; | |
| 1610 | + } | |
| 1611 | + const result = { | |
| 1612 | + value: type.toLowerCase(), | |
| 1613 | + parameters: /* @__PURE__ */ Object.create(null) | |
| 1614 | + }; | |
| 1615 | + if (index === -1) { | |
| 1616 | + return result; | |
| 1617 | + } | |
| 1618 | + let key; | |
| 1619 | + let match4; | |
| 1620 | + let value2; | |
| 1621 | + paramRE.lastIndex = index; | |
| 1622 | + while (match4 = paramRE.exec(header)) { | |
| 1623 | + if (match4.index !== index) { | |
| 1624 | + return defaultContentType; | |
| 1625 | + } | |
| 1626 | + index += match4[0].length; | |
| 1627 | + key = match4[1].toLowerCase(); | |
| 1628 | + value2 = match4[2]; | |
| 1629 | + if (value2[0] === '"') { | |
| 1630 | + value2 = value2.slice(1, value2.length - 1); | |
| 1631 | + !withoutSlash && quotedPairRE.test(value2) && (value2 = value2.replace(quotedPairRE, "$1")); | |
| 1632 | + } | |
| 1633 | + result.parameters[key] = value2; | |
| 1634 | + } | |
| 1635 | + if (index !== header.length) { | |
| 1636 | + return defaultContentType; | |
| 1637 | + } | |
| 1638 | + return result; | |
| 1639 | +} | |
| 1640 | + | |
| 1641 | +// ../../node_modules/.bun/multipasta@0.2.7/node_modules/multipasta/dist/esm/internal/headers.js | |
| 1642 | +var constMaxPairs = 100; | |
| 1643 | +var constMaxSize = 16 * 1024; | |
| 1644 | +var State; | |
| 1645 | +(function(State3) { | |
| 1646 | + State3[State3["key"] = 0] = "key"; | |
| 1647 | + State3[State3["whitespace"] = 1] = "whitespace"; | |
| 1648 | + State3[State3["value"] = 2] = "value"; | |
| 1649 | +})(State || (State = {})); | |
| 1650 | +var constContinue = { | |
| 1651 | + _tag: "Continue" | |
| 1652 | +}; | |
| 1653 | +var constNameChars = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1]; | |
| 1654 | +var constValueChars = [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]; | |
| 1655 | +function make12() { | |
| 1656 | + const decoder = new TextDecoder(); | |
| 1657 | + const state = { | |
| 1658 | + state: State.key, | |
| 1659 | + headers: /* @__PURE__ */ Object.create(null), | |
| 1660 | + key: "", | |
| 1661 | + value: void 0, | |
| 1662 | + crlf: 0, | |
| 1663 | + previousChunk: void 0, | |
| 1664 | + pairs: 0, | |
| 1665 | + size: 0 | |
| 1666 | + }; | |
| 1667 | + function reset(value2) { | |
| 1668 | + state.state = State.key; | |
| 1669 | + state.headers = /* @__PURE__ */ Object.create(null); | |
| 1670 | + state.key = ""; | |
| 1671 | + state.value = void 0; | |
| 1672 | + state.crlf = 0; | |
| 1673 | + state.previousChunk = void 0; | |
| 1674 | + state.pairs = 0; | |
| 1675 | + state.size = 0; | |
| 1676 | + return value2; | |
| 1677 | + } | |
| 1678 | + function concatUint8Array(a, b) { | |
| 1679 | + const newUint8Array = new Uint8Array(a.length + b.length); | |
| 1680 | + newUint8Array.set(a); | |
| 1681 | + newUint8Array.set(b, a.length); | |
| 1682 | + return newUint8Array; | |
| 1683 | + } | |
| 1684 | + function error(reason) { | |
| 1685 | + return reset({ | |
| 1686 | + _tag: "Failure", | |
| 1687 | + reason, | |
| 1688 | + headers: state.headers | |
| 1689 | + }); | |
| 1690 | + } | |
| 1691 | + return function write2(chunk, start3) { | |
| 1692 | + let endOffset = 0; | |
| 1693 | + let previousCursor; | |
| 1694 | + if (state.previousChunk !== void 0) { | |
| 1695 | + endOffset = state.previousChunk.length; | |
| 1696 | + previousCursor = endOffset; | |
| 1697 | + const newChunk = new Uint8Array(chunk.length + endOffset); | |
| 1698 | + newChunk.set(state.previousChunk); | |
| 1699 | + newChunk.set(chunk, endOffset); | |
| 1700 | + state.previousChunk = void 0; | |
| 1701 | + chunk = newChunk; | |
| 1702 | + } | |
| 1703 | + const end = chunk.length; | |
| 1704 | + outer: while (start3 < end) { | |
| 1705 | + if (state.state === State.key) { | |
| 1706 | + let i = start3; | |
| 1707 | + for (; i < end; i++) { | |
| 1708 | + if (state.size++ > constMaxSize) { | |
| 1709 | + return error("HeaderTooLarge"); | |
| 1710 | + } | |
| 1711 | + if (chunk[i] === 58) { | |
| 1712 | + state.key += decoder.decode(chunk.subarray(start3, i)).toLowerCase(); | |
| 1713 | + if (state.key.length === 0) { | |
| 1714 | + return error("InvalidHeaderName"); | |
| 1715 | + } | |
| 1716 | + if (chunk[i + 1] === 32 && chunk[i + 2] !== 32 && chunk[i + 2] !== 9) { | |
| 1717 | + start3 = i + 2; | |
| 1718 | + state.state = State.value; | |
| 1719 | + state.size++; | |
| 1720 | + } else if (chunk[i + 1] !== 32 && chunk[i + 1] !== 9) { | |
| 1721 | + start3 = i + 1; | |
| 1722 | + state.state = State.value; | |
| 1723 | + } else { | |
| 1724 | + start3 = i + 1; | |
| 1725 | + state.state = State.whitespace; | |
| 1726 | + } | |
| 1727 | + break; | |
| 1728 | + } else if (constNameChars[chunk[i]] !== 1) { | |
| 1729 | + return error("InvalidHeaderName"); | |
| 1730 | + } | |
| 1731 | + } | |
| 1732 | + if (i === end) { | |
| 1733 | + state.key += decoder.decode(chunk.subarray(start3, end)).toLowerCase(); | |
| 1734 | + return constContinue; | |
| 1735 | + } | |
| 1736 | + } | |
| 1737 | + if (state.state === State.whitespace) { | |
| 1738 | + for (; start3 < end; start3++) { | |
| 1739 | + if (state.size++ > constMaxSize) { | |
| 1740 | + return error("HeaderTooLarge"); | |
| 1741 | + } | |
| 1742 | + if (chunk[start3] !== 32 && chunk[start3] !== 9) { | |
| 1743 | + state.state = State.value; | |
| 1744 | + break; | |
| 1745 | + } | |
| 1746 | + } | |
| 1747 | + if (start3 === end) { | |
| 1748 | + return constContinue; | |
| 1749 | + } | |
| 1750 | + } | |
| 1751 | + if (state.state === State.value) { | |
| 1752 | + let i = start3; | |
| 1753 | + if (previousCursor !== void 0) { | |
| 1754 | + i = previousCursor; | |
| 1755 | + previousCursor = void 0; | |
| 1756 | + } | |
| 1757 | + for (; i < end; i++) { | |
| 1758 | + if (state.size++ > constMaxSize) { | |
| 1759 | + return error("HeaderTooLarge"); | |
| 1760 | + } | |
| 1761 | + if (chunk[i] === 13 || state.crlf > 0) { | |
| 1762 | + let byte = chunk[i]; | |
| 1763 | + if (byte === 13 && state.crlf === 0) { | |
| 1764 | + state.crlf = 1; | |
| 1765 | + i++; | |
| 1766 | + state.size++; | |
| 1767 | + byte = chunk[i]; | |
| 1768 | + } | |
| 1769 | + if (byte === 10 && state.crlf === 1) { | |
| 1770 | + state.crlf = 2; | |
| 1771 | + i++; | |
| 1772 | + state.size++; | |
| 1773 | + byte = chunk[i]; | |
| 1774 | + } | |
| 1775 | + if (byte === 13 && state.crlf === 2) { | |
| 1776 | + state.crlf = 3; | |
| 1777 | + i++; | |
| 1778 | + state.size++; | |
| 1779 | + byte = chunk[i]; | |
| 1780 | + } | |
| 1781 | + if (byte === 10 && state.crlf === 3) { | |
| 1782 | + state.crlf = 4; | |
| 1783 | + i++; | |
| 1784 | + state.size++; | |
| 1785 | + } | |
| 1786 | + if (state.crlf < 4 && i >= end) { | |
| 1787 | + state.previousChunk = chunk.subarray(start3); | |
| 1788 | + return constContinue; | |
| 1789 | + } else if (state.crlf >= 2) { | |
| 1790 | + state.value = state.value === void 0 ? chunk.subarray(start3, i - state.crlf) : concatUint8Array(state.value, chunk.subarray(start3, i - state.crlf)); | |
| 1791 | + const value2 = decoder.decode(state.value); | |
| 1792 | + if (state.headers[state.key] === void 0) { | |
| 1793 | + state.headers[state.key] = value2; | |
| 1794 | + } else if (typeof state.headers[state.key] === "string") { | |
| 1795 | + state.headers[state.key] = [state.headers[state.key], value2]; | |
| 1796 | + } else { | |
| 1797 | + ; | |
| 1798 | + state.headers[state.key].push(value2); | |
| 1799 | + } | |
| 1800 | + start3 = i; | |
| 1801 | + state.size--; | |
| 1802 | + if (state.crlf !== 4 && state.pairs === constMaxPairs) { | |
| 1803 | + return error("TooManyHeaders"); | |
| 1804 | + } else if (state.crlf === 3) { | |
| 1805 | + return error("InvalidHeaderValue"); | |
| 1806 | + } else if (state.crlf === 4) { | |
| 1807 | + return reset({ | |
| 1808 | + _tag: "Headers", | |
| 1809 | + headers: state.headers, | |
| 1810 | + endPosition: start3 - endOffset | |
| 1811 | + }); | |
| 1812 | + } | |
| 1813 | + state.pairs++; | |
| 1814 | + state.key = ""; | |
| 1815 | + state.value = void 0; | |
| 1816 | + state.crlf = 0; | |
| 1817 | + state.state = State.key; | |
| 1818 | + continue outer; | |
| 1819 | + } | |
| 1820 | + } else if (constValueChars[chunk[i]] !== 1) { | |
| 1821 | + return error("InvalidHeaderValue"); | |
| 1822 | + } | |
| 1823 | + } | |
| 1824 | + if (i === end) { | |
| 1825 | + state.value = state.value === void 0 ? chunk.subarray(start3, end) : concatUint8Array(state.value, chunk.subarray(start3, end)); | |
| 1826 | + return constContinue; | |
| 1827 | + } | |
| 1828 | + } | |
| 1829 | + } | |
| 1830 | + if (start3 > end) { | |
| 1831 | + state.size += end - start3; | |
| 1832 | + } | |
| 1833 | + return constContinue; | |
| 1834 | + }; | |
| 1835 | +} | |
| 1836 | + | |
| 1837 | +// ../../node_modules/.bun/multipasta@0.2.7/node_modules/multipasta/dist/esm/internal/search.js | |
| 1838 | +function makeState(needle_) { | |
| 1839 | + const needle = new TextEncoder().encode(needle_); | |
| 1840 | + const needleLength = needle.length; | |
| 1841 | + const indexes = {}; | |
| 1842 | + for (let i = 0; i < needleLength; i++) { | |
| 1843 | + const b = needle[i]; | |
| 1844 | + if (indexes[b] === void 0) indexes[b] = []; | |
| 1845 | + indexes[b].push(i); | |
| 1846 | + } | |
| 1847 | + return { | |
| 1848 | + needle, | |
| 1849 | + needleLength, | |
| 1850 | + indexes, | |
| 1851 | + firstByte: needle[0], | |
| 1852 | + previousChunk: void 0, | |
| 1853 | + previousChunkLength: 0, | |
| 1854 | + matchIndex: 0 | |
| 1855 | + }; | |
| 1856 | +} | |
| 1857 | +function make13(needle, callback, seed) { | |
| 1858 | + const state = makeState(needle); | |
| 1859 | + if (seed !== void 0) { | |
| 1860 | + state.previousChunk = seed; | |
| 1861 | + state.previousChunkLength = seed.length; | |
| 1862 | + } | |
| 1863 | + function makeIndexOf() { | |
| 1864 | + if ("Buffer" in globalThis && !("Bun" in globalThis || "Deno" in globalThis)) { | |
| 1865 | + return function(chunk, needle2, fromIndex) { | |
| 1866 | + return Buffer.prototype.indexOf.call(chunk, needle2, fromIndex); | |
| 1867 | + }; | |
| 1868 | + } | |
| 1869 | + const skipTable = new Uint8Array(256).fill(state.needle.length); | |
| 1870 | + for (let i = 0, lastIndex = state.needle.length - 1; i < lastIndex; ++i) { | |
| 1871 | + skipTable[state.needle[i]] = lastIndex - i; | |
| 1872 | + } | |
| 1873 | + return function(chunk, needle2, fromIndex) { | |
| 1874 | + const lengthTotal = chunk.length; | |
| 1875 | + let i = fromIndex + state.needleLength - 1; | |
| 1876 | + while (i < lengthTotal) { | |
| 1877 | + for (let j = state.needleLength - 1, k = i; j >= 0 && chunk[k] === needle2[j]; j--, k--) { | |
| 1878 | + if (j === 0) return k; | |
| 1879 | + } | |
| 1880 | + i += skipTable[chunk[i]]; | |
| 1881 | + } | |
| 1882 | + return -1; | |
| 1883 | + }; | |
| 1884 | + } | |
| 1885 | + const indexOf = makeIndexOf(); | |
| 1886 | + function write2(chunk) { | |
| 1887 | + let chunkLength = chunk.length; | |
| 1888 | + if (state.previousChunk !== void 0) { | |
| 1889 | + const newChunk = new Uint8Array(state.previousChunkLength + chunkLength); | |
| 1890 | + newChunk.set(state.previousChunk); | |
| 1891 | + newChunk.set(chunk, state.previousChunkLength); | |
| 1892 | + chunk = newChunk; | |
| 1893 | + chunkLength = state.previousChunkLength + chunkLength; | |
| 1894 | + state.previousChunk = void 0; | |
| 1895 | + } | |
| 1896 | + if (chunkLength < state.needleLength) { | |
| 1897 | + state.previousChunk = chunk; | |
| 1898 | + state.previousChunkLength = chunkLength; | |
| 1899 | + return; | |
| 1900 | + } | |
| 1901 | + let pos = 0; | |
| 1902 | + while (pos < chunkLength) { | |
| 1903 | + const match4 = indexOf(chunk, state.needle, pos); | |
| 1904 | + if (match4 > -1) { | |
| 1905 | + if (match4 > pos) { | |
| 1906 | + callback(state.matchIndex, chunk.subarray(pos, match4)); | |
| 1907 | + } | |
| 1908 | + state.matchIndex += 1; | |
| 1909 | + pos = match4 + state.needleLength; | |
| 1910 | + continue; | |
| 1911 | + } else if (chunk[chunkLength - 1] in state.indexes) { | |
| 1912 | + const indexes = state.indexes[chunk[chunkLength - 1]]; | |
| 1913 | + let earliestIndex = -1; | |
| 1914 | + for (let i = 0, len = indexes.length; i < len; i++) { | |
| 1915 | + const index = indexes[i]; | |
| 1916 | + if (chunk[chunkLength - 1 - index] === state.firstByte && i > earliestIndex) { | |
| 1917 | + earliestIndex = index; | |
| 1918 | + } | |
| 1919 | + } | |
| 1920 | + if (earliestIndex === -1) { | |
| 1921 | + if (pos === 0) { | |
| 1922 | + callback(state.matchIndex, chunk); | |
| 1923 | + } else { | |
| 1924 | + callback(state.matchIndex, chunk.subarray(pos)); | |
| 1925 | + } | |
| 1926 | + } else { | |
| 1927 | + if (chunkLength - 1 - earliestIndex > pos) { | |
| 1928 | + callback(state.matchIndex, chunk.subarray(pos, chunkLength - 1 - earliestIndex)); | |
| 1929 | + } | |
| 1930 | + state.previousChunk = chunk.subarray(chunkLength - 1 - earliestIndex); | |
| 1931 | + state.previousChunkLength = earliestIndex + 1; | |
| 1932 | + } | |
| 1933 | + } else if (pos === 0) { | |
| 1934 | + callback(state.matchIndex, chunk); | |
| 1935 | + } else { | |
| 1936 | + callback(state.matchIndex, chunk.subarray(pos)); | |
| 1937 | + } | |
| 1938 | + break; | |
| 1939 | + } | |
| 1940 | + } | |
| 1941 | + function end() { | |
| 1942 | + if (state.previousChunk !== void 0 && state.previousChunk !== seed) { | |
| 1943 | + callback(state.matchIndex, state.previousChunk); | |
| 1944 | + } | |
| 1945 | + state.previousChunk = seed; | |
| 1946 | + state.previousChunkLength = seed?.length ?? 0; | |
| 1947 | + state.matchIndex = 0; | |
| 1948 | + } | |
| 1949 | + return { | |
| 1950 | + write: write2, | |
| 1951 | + end | |
| 1952 | + }; | |
| 1953 | +} | |
| 1954 | + | |
| 1955 | +// ../../node_modules/.bun/multipasta@0.2.7/node_modules/multipasta/dist/esm/internal/multipart.js | |
| 1956 | +var State2; | |
| 1957 | +(function(State3) { | |
| 1958 | + State3[State3["headers"] = 0] = "headers"; | |
| 1959 | + State3[State3["body"] = 1] = "body"; | |
| 1960 | +})(State2 || (State2 = {})); | |
| 1961 | +var errInvalidDisposition = { | |
| 1962 | + _tag: "InvalidDisposition" | |
| 1963 | +}; | |
| 1964 | +var errEndNotReached = { | |
| 1965 | + _tag: "EndNotReached" | |
| 1966 | +}; | |
| 1967 | +var errMaxParts = { | |
| 1968 | + _tag: "ReachedLimit", | |
| 1969 | + limit: "MaxParts" | |
| 1970 | +}; | |
| 1971 | +var errMaxTotalSize = { | |
| 1972 | + _tag: "ReachedLimit", | |
| 1973 | + limit: "MaxTotalSize" | |
| 1974 | +}; | |
| 1975 | +var errMaxPartSize = { | |
| 1976 | + _tag: "ReachedLimit", | |
| 1977 | + limit: "MaxPartSize" | |
| 1978 | +}; | |
| 1979 | +var errMaxFieldSize = { | |
| 1980 | + _tag: "ReachedLimit", | |
| 1981 | + limit: "MaxFieldSize" | |
| 1982 | +}; | |
| 1983 | +var constCR = new TextEncoder().encode("\r\n"); | |
| 1984 | +function defaultIsFile(info) { | |
| 1985 | + return info.filename !== void 0 || info.contentType === "application/octet-stream"; | |
| 1986 | +} | |
| 1987 | +function parseBoundary(headers) { | |
| 1988 | + const contentType = parse(headers["content-type"]); | |
| 1989 | + return contentType.parameters.boundary; | |
| 1990 | +} | |
| 1991 | +function noopOnChunk(_chunk) { | |
| 1992 | +} | |
| 1993 | +function make14({ | |
| 1994 | + headers, | |
| 1995 | + onFile: onPart, | |
| 1996 | + onField, | |
| 1997 | + onError, | |
| 1998 | + onDone, | |
| 1999 | + isFile: isFile2 = defaultIsFile, | |
| 2000 | + maxParts = Infinity, | |
| 2001 | + maxTotalSize = Infinity, | |
| 2002 | + maxPartSize = Infinity, | |
| 2003 | + maxFieldSize = 1024 * 1024 | |
| 2004 | +}) { | |
| 2005 | + const boundary = parseBoundary(headers); | |
| 2006 | + if (boundary === void 0) { | |
| 2007 | + onError({ | |
| 2008 | + _tag: "InvalidBoundary" | |
| 2009 | + }); | |
| 2010 | + return { | |
| 2011 | + write: noopOnChunk, | |
| 2012 | + end() { | |
| 2013 | + } | |
| 2014 | + }; | |
| 2015 | + } | |
| 2016 | + const state = { | |
| 2017 | + state: State2.headers, | |
| 2018 | + index: 0, | |
| 2019 | + parts: 0, | |
| 2020 | + onChunk: noopOnChunk, | |
| 2021 | + info: void 0, | |
| 2022 | + headerSkip: 0, | |
| 2023 | + partSize: 0, | |
| 2024 | + totalSize: 0, | |
| 2025 | + isFile: false, | |
| 2026 | + fieldChunks: [], | |
| 2027 | + fieldSize: 0 | |
| 2028 | + }; | |
| 2029 | + function skipBody() { | |
| 2030 | + state.state = State2.body; | |
| 2031 | + state.isFile = true; | |
| 2032 | + state.onChunk = noopOnChunk; | |
| 2033 | + } | |
| 2034 | + const headerParser = make12(); | |
| 2035 | + const split = make13(`\r | |
| 2036 | +--${boundary}`, function(index, chunk) { | |
| 2037 | + if (index === 0) { | |
| 2038 | + skipBody(); | |
| 2039 | + return; | |
| 2040 | + } else if (index !== state.index) { | |
| 2041 | + if (state.index > 0) { | |
| 2042 | + if (state.isFile) { | |
| 2043 | + state.onChunk(null); | |
| 2044 | + state.partSize = 0; | |
| 2045 | + } else { | |
| 2046 | + if (state.fieldChunks.length === 1) { | |
| 2047 | + onField(state.info, state.fieldChunks[0]); | |
| 2048 | + } else { | |
| 2049 | + const buf = new Uint8Array(state.fieldSize); | |
| 2050 | + let offset = 0; | |
| 2051 | + for (let i = 0; i < state.fieldChunks.length; i++) { | |
| 2052 | + const chunk2 = state.fieldChunks[i]; | |
| 2053 | + buf.set(chunk2, offset); | |
| 2054 | + offset += chunk2.length; | |
| 2055 | + } | |
| 2056 | + onField(state.info, buf); | |
| 2057 | + } | |
| 2058 | + state.fieldSize = 0; | |
| 2059 | + state.fieldChunks = []; | |
| 2060 | + } | |
| 2061 | + } | |
| 2062 | + state.state = State2.headers; | |
| 2063 | + state.index = index; | |
| 2064 | + state.headerSkip = 2; | |
| 2065 | + if (chunk[0] === 45 && chunk[1] === 45) { | |
| 2066 | + return onDone(); | |
| 2067 | + } | |
| 2068 | + state.parts++; | |
| 2069 | + if (state.parts > maxParts) { | |
| 2070 | + onError(errMaxParts); | |
| 2071 | + } | |
| 2072 | + } | |
| 2073 | + if ((state.partSize += chunk.length) > maxPartSize) { | |
| 2074 | + onError(errMaxPartSize); | |
| 2075 | + } | |
| 2076 | + if (state.state === State2.headers) { | |
| 2077 | + const result = headerParser(chunk, state.headerSkip); | |
| 2078 | + state.headerSkip = 0; | |
| 2079 | + if (result._tag === "Continue") { | |
| 2080 | + return; | |
| 2081 | + } else if (result._tag === "Failure") { | |
| 2082 | + skipBody(); | |
| 2083 | + return onError({ | |
| 2084 | + _tag: "BadHeaders", | |
| 2085 | + error: result | |
| 2086 | + }); | |
| 2087 | + } | |
| 2088 | + const contentType = parse(result.headers["content-type"]); | |
| 2089 | + const contentDisposition = parse(result.headers["content-disposition"], true); | |
| 2090 | + if ("form-data" === contentDisposition.value && !("name" in contentDisposition.parameters)) { | |
| 2091 | + skipBody(); | |
| 2092 | + return onError(errInvalidDisposition); | |
| 2093 | + } | |
| 2094 | + let encodedFilename; | |
| 2095 | + if ("filename*" in contentDisposition.parameters) { | |
| 2096 | + const parts = contentDisposition.parameters["filename*"].split("''"); | |
| 2097 | + if (parts.length === 2) { | |
| 2098 | + encodedFilename = decodeURIComponent(parts[1]); | |
| 2099 | + } | |
| 2100 | + } | |
| 2101 | + state.info = { | |
| 2102 | + name: contentDisposition.parameters.name ?? "", | |
| 2103 | + filename: encodedFilename ?? contentDisposition.parameters.filename, | |
| 2104 | + contentType: contentType.value === "" ? contentDisposition.parameters.filename !== void 0 ? "application/octet-stream" : "text/plain" : contentType.value, | |
| 2105 | + contentTypeParameters: contentType.parameters, | |
| 2106 | + contentDisposition: contentDisposition.value, | |
| 2107 | + contentDispositionParameters: contentDisposition.parameters, | |
| 2108 | + headers: result.headers | |
| 2109 | + }; | |
| 2110 | + state.state = State2.body; | |
| 2111 | + state.isFile = isFile2(state.info); | |
| 2112 | + if (state.isFile) { | |
| 2113 | + state.onChunk = onPart(state.info); | |
| 2114 | + } | |
| 2115 | + if (result.endPosition < chunk.length) { | |
| 2116 | + if (state.isFile) { | |
| 2117 | + state.onChunk(chunk.subarray(result.endPosition)); | |
| 2118 | + } else { | |
| 2119 | + const buf = chunk.subarray(result.endPosition); | |
| 2120 | + if ((state.fieldSize += buf.length) > maxFieldSize) { | |
| 2121 | + onError(errMaxFieldSize); | |
| 2122 | + } | |
| 2123 | + state.fieldChunks.push(buf); | |
| 2124 | + } | |
| 2125 | + } | |
| 2126 | + } else if (state.isFile) { | |
| 2127 | + state.onChunk(chunk); | |
| 2128 | + } else { | |
| 2129 | + if ((state.fieldSize += chunk.length) > maxFieldSize) { | |
| 2130 | + onError(errMaxFieldSize); | |
| 2131 | + } | |
| 2132 | + state.fieldChunks.push(chunk); | |
| 2133 | + } | |
| 2134 | + }, constCR); | |
| 2135 | + return { | |
| 2136 | + write(chunk) { | |
| 2137 | + if ((state.totalSize += chunk.length) > maxTotalSize) { | |
| 2138 | + return onError(errMaxTotalSize); | |
| 2139 | + } | |
| 2140 | + return split.write(chunk); | |
| 2141 | + }, | |
| 2142 | + end() { | |
| 2143 | + split.end(); | |
| 2144 | + if (state.state === State2.body) { | |
| 2145 | + onError(errEndNotReached); | |
| 2146 | + } | |
| 2147 | + state.state = State2.headers; | |
| 2148 | + state.index = 0; | |
| 2149 | + state.parts = 0; | |
| 2150 | + state.onChunk = noopOnChunk; | |
| 2151 | + state.info = void 0; | |
| 2152 | + state.totalSize = 0; | |
| 2153 | + state.partSize = 0; | |
| 2154 | + state.fieldChunks = []; | |
| 2155 | + state.fieldSize = 0; | |
| 2156 | + } | |
| 2157 | + }; | |
| 2158 | +} | |
| 2159 | +var utf8Decoder = new TextDecoder("utf-8"); | |
| 2160 | +function getDecoder(charset) { | |
| 2161 | + if (charset === "utf-8" || charset === "utf8" || charset === "") { | |
| 2162 | + return utf8Decoder; | |
| 2163 | + } | |
| 2164 | + try { | |
| 2165 | + return new TextDecoder(charset); | |
| 2166 | + } catch (error) { | |
| 2167 | + return utf8Decoder; | |
| 2168 | + } | |
| 2169 | +} | |
| 2170 | +function decodeField(info, value2) { | |
| 2171 | + return getDecoder(info.contentTypeParameters.charset ?? "utf-8").decode(value2); | |
| 2172 | +} | |
| 2173 | + | |
| 2174 | +// ../../node_modules/.bun/multipasta@0.2.7/node_modules/multipasta/dist/esm/index.js | |
| 2175 | +var make15 = make14; | |
| 2176 | +var defaultIsFile2 = defaultIsFile; | |
| 2177 | +var decodeField2 = decodeField; | |
| 2178 | + | |
| 2179 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/Multipart.js | |
| 2180 | +var TypeId9 = Symbol.for("@effect/platform/Multipart"); | |
| 2181 | +var isPart = (u) => hasProperty(u, TypeId9); | |
| 2182 | +var isField = (u) => isPart(u) && u._tag === "Field"; | |
| 2183 | +var isFile = (u) => isPart(u) && u._tag === "File"; | |
| 2184 | +var isPersistedFile = (u) => hasProperty(u, TypeId9) && isTagged(u, "PersistedFile"); | |
| 2185 | +var ErrorTypeId = Symbol.for("@effect/platform/Multipart/MultipartError"); | |
| 2186 | +var MultipartError = class extends TaggedError2()("MultipartError", { | |
| 2187 | + reason: Literal("FileTooLarge", "FieldTooLarge", "BodyTooLarge", "TooManyParts", "InternalError", "Parse"), | |
| 2188 | + cause: Defect | |
| 2189 | +}) { | |
| 2190 | + /** | |
| 2191 | + * @since 1.0.0 | |
| 2192 | + */ | |
| 2193 | + [ErrorTypeId] = ErrorTypeId; | |
| 2194 | + /** | |
| 2195 | + * @since 1.0.0 | |
| 2196 | + */ | |
| 2197 | + get message() { | |
| 2198 | + return this.reason; | |
| 2199 | + } | |
| 2200 | +}; | |
| 2201 | +var FileSchema = declare(isPersistedFile, { | |
| 2202 | + identifier: "PersistedFile", | |
| 2203 | + jsonSchema: { | |
| 2204 | + type: "string", | |
| 2205 | + format: "binary" | |
| 2206 | + } | |
| 2207 | +}); | |
| 2208 | +var FilesSchema = Array$(FileSchema); | |
| 2209 | +var SingleFileSchema = transform(FilesSchema.pipe(itemsCount(1)), FileSchema, { | |
| 2210 | + strict: true, | |
| 2211 | + decode: ([file3]) => file3, | |
| 2212 | + encode: (file3) => [file3] | |
| 2213 | +}); | |
| 2214 | +var schemaPersisted = (schema2, options4) => decodeUnknown(schema2, options4); | |
| 2215 | +var schemaJson4 = (schema2, options4) => { | |
| 2216 | + const fromJson = parseJson(schema2); | |
| 2217 | + return dual(2, (persisted, field) => map5(decodeUnknown(Struct({ | |
| 2218 | + [field]: fromJson | |
| 2219 | + }), options4)(persisted), (_) => _[field])); | |
| 2220 | +}; | |
| 2221 | +var makeConfig = (headers) => withFiberRuntime((fiber) => { | |
| 2222 | + const mimeTypes = get(fiber.currentContext, FieldMimeTypes); | |
| 2223 | + return succeed({ | |
| 2224 | + headers, | |
| 2225 | + maxParts: getOrUndefined(get(fiber.currentContext, MaxParts)), | |
| 2226 | + maxFieldSize: Number(get(fiber.currentContext, MaxFieldSize)), | |
| 2227 | + maxPartSize: get(fiber.currentContext, MaxFileSize).pipe(map2(Number), getOrUndefined), | |
| 2228 | + maxTotalSize: get(fiber.currentContext, MaxBodySize).pipe(map2(Number), getOrUndefined), | |
| 2229 | + isFile: mimeTypes.length === 0 ? void 0 : (info) => !some2(mimeTypes, (_) => info.contentType.includes(_)) && defaultIsFile2(info) | |
| 2230 | + }); | |
| 2231 | +}); | |
| 2232 | +var makeChannel = (headers, bufferSize = 16) => acquireUseRelease(all([makeConfig(headers), make5(bufferSize)]), ([config, mailbox]) => { | |
| 2233 | + let partsBuffer = []; | |
| 2234 | + let exit2 = none(); | |
| 2235 | + const input = { | |
| 2236 | + awaitRead: () => _void, | |
| 2237 | + emit(element) { | |
| 2238 | + return mailbox.offer(element); | |
| 2239 | + }, | |
| 2240 | + error(cause) { | |
| 2241 | + exit2 = some(failCause(cause)); | |
| 2242 | + return mailbox.end; | |
| 2243 | + }, | |
| 2244 | + done(_value) { | |
| 2245 | + return mailbox.end; | |
| 2246 | + } | |
| 2247 | + }; | |
| 2248 | + const parser = make15({ | |
| 2249 | + ...config, | |
| 2250 | + onField(info, value2) { | |
| 2251 | + partsBuffer.push(new FieldImpl(info.name, info.contentType, decodeField2(info, value2))); | |
| 2252 | + }, | |
| 2253 | + onFile(info) { | |
| 2254 | + let chunks = []; | |
| 2255 | + let finished = false; | |
| 2256 | + const take = suspend(() => { | |
| 2257 | + if (chunks.length === 0) { | |
| 2258 | + return finished ? void_2 : zipRight2(pump, take); | |
| 2259 | + } | |
| 2260 | + const chunk = unsafeFromArray(chunks); | |
| 2261 | + chunks = []; | |
| 2262 | + return finished ? write(chunk) : zipRight2(write(chunk), zipRight2(pump, take)); | |
| 2263 | + }); | |
| 2264 | + partsBuffer.push(new FileImpl(info, take)); | |
| 2265 | + return function(chunk) { | |
| 2266 | + if (chunk === null) { | |
| 2267 | + finished = true; | |
| 2268 | + } else { | |
| 2269 | + chunks.push(chunk); | |
| 2270 | + } | |
| 2271 | + }; | |
| 2272 | + }, | |
| 2273 | + onError(error_) { | |
| 2274 | + exit2 = some(fail(convertError(error_))); | |
| 2275 | + }, | |
| 2276 | + onDone() { | |
| 2277 | + exit2 = some(void_); | |
| 2278 | + } | |
| 2279 | + }); | |
| 2280 | + const pump = flatMap4(mailbox.takeAll, ([chunks, done]) => sync3(() => { | |
| 2281 | + forEach(chunks, forEach(parser.write)); | |
| 2282 | + if (done) { | |
| 2283 | + parser.end(); | |
| 2284 | + } | |
| 2285 | + })); | |
| 2286 | + const partsChannel = flatMap4(pump, () => { | |
| 2287 | + if (partsBuffer.length === 0) { | |
| 2288 | + return exit2._tag === "None" ? partsChannel : writeExit(exit2.value); | |
| 2289 | + } | |
| 2290 | + const chunk = unsafeFromArray(partsBuffer); | |
| 2291 | + partsBuffer = []; | |
| 2292 | + return zipRight2(write(chunk), exit2._tag === "None" ? partsChannel : writeExit(exit2.value)); | |
| 2293 | + }); | |
| 2294 | + return embedInput(partsChannel, input); | |
| 2295 | +}, ([, mailbox]) => mailbox.shutdown); | |
| 2296 | +var writeExit = (self) => self._tag === "Success" ? void_2 : failCause3(self.cause); | |
| 2297 | +function convertError(cause) { | |
| 2298 | + switch (cause._tag) { | |
| 2299 | + case "ReachedLimit": { | |
| 2300 | + switch (cause.limit) { | |
| 2301 | + case "MaxParts": { | |
| 2302 | + return new MultipartError({ | |
| 2303 | + reason: "TooManyParts", | |
| 2304 | + cause | |
| 2305 | + }); | |
| 2306 | + } | |
| 2307 | + case "MaxFieldSize": { | |
| 2308 | + return new MultipartError({ | |
| 2309 | + reason: "FieldTooLarge", | |
| 2310 | + cause | |
| 2311 | + }); | |
| 2312 | + } | |
| 2313 | + case "MaxPartSize": { | |
| 2314 | + return new MultipartError({ | |
| 2315 | + reason: "FileTooLarge", | |
| 2316 | + cause | |
| 2317 | + }); | |
| 2318 | + } | |
| 2319 | + case "MaxTotalSize": { | |
| 2320 | + return new MultipartError({ | |
| 2321 | + reason: "BodyTooLarge", | |
| 2322 | + cause | |
| 2323 | + }); | |
| 2324 | + } | |
| 2325 | + } | |
| 2326 | + } | |
| 2327 | + default: { | |
| 2328 | + return new MultipartError({ | |
| 2329 | + reason: "Parse", | |
| 2330 | + cause | |
| 2331 | + }); | |
| 2332 | + } | |
| 2333 | + } | |
| 2334 | +} | |
| 2335 | +var PartBase = class extends Class { | |
| 2336 | + [TypeId9]; | |
| 2337 | + constructor() { | |
| 2338 | + super(); | |
| 2339 | + this[TypeId9] = TypeId9; | |
| 2340 | + } | |
| 2341 | +}; | |
| 2342 | +var FieldImpl = class extends PartBase { | |
| 2343 | + key; | |
| 2344 | + contentType; | |
| 2345 | + value; | |
| 2346 | + _tag = "Field"; | |
| 2347 | + constructor(key, contentType, value2) { | |
| 2348 | + super(); | |
| 2349 | + this.key = key; | |
| 2350 | + this.contentType = contentType; | |
| 2351 | + this.value = value2; | |
| 2352 | + } | |
| 2353 | + toJSON() { | |
| 2354 | + return { | |
| 2355 | + _id: "@effect/platform/Multipart/Part", | |
| 2356 | + _tag: "Field", | |
| 2357 | + key: this.key, | |
| 2358 | + contentType: this.contentType, | |
| 2359 | + value: this.value | |
| 2360 | + }; | |
| 2361 | + } | |
| 2362 | +}; | |
| 2363 | +var FileImpl = class extends PartBase { | |
| 2364 | + _tag = "File"; | |
| 2365 | + key; | |
| 2366 | + name; | |
| 2367 | + contentType; | |
| 2368 | + content; | |
| 2369 | + contentEffect; | |
| 2370 | + constructor(info, channel) { | |
| 2371 | + super(); | |
| 2372 | + this.key = info.name; | |
| 2373 | + this.name = info.filename ?? info.name; | |
| 2374 | + this.contentType = info.contentType; | |
| 2375 | + this.content = fromChannel(channel); | |
| 2376 | + this.contentEffect = channel.pipe(pipeTo(collectUint8Array2), run2, mapError((cause) => new MultipartError({ | |
| 2377 | + reason: "InternalError", | |
| 2378 | + cause | |
| 2379 | + }))); | |
| 2380 | + } | |
| 2381 | + toJSON() { | |
| 2382 | + return { | |
| 2383 | + _id: "@effect/platform/Multipart/Part", | |
| 2384 | + _tag: "File", | |
| 2385 | + key: this.key, | |
| 2386 | + name: this.name, | |
| 2387 | + contentType: this.contentType | |
| 2388 | + }; | |
| 2389 | + } | |
| 2390 | +}; | |
| 2391 | +var defaultWriteFile = (path, file3) => flatMap2(FileSystem, (fs) => mapError(run(file3.content, fs.sink(path)), (cause) => new MultipartError({ | |
| 2392 | + reason: "InternalError", | |
| 2393 | + cause | |
| 2394 | +}))); | |
| 2395 | +var collectUint8Array2 = suspend(() => { | |
| 2396 | + let accumulator = new Uint8Array(0); | |
| 2397 | + const loop = readWithCause({ | |
| 2398 | + onInput(chunk) { | |
| 2399 | + for (const element of chunk) { | |
| 2400 | + const newAccumulator = new Uint8Array(accumulator.length + element.length); | |
| 2401 | + newAccumulator.set(accumulator, 0); | |
| 2402 | + newAccumulator.set(element, accumulator.length); | |
| 2403 | + accumulator = newAccumulator; | |
| 2404 | + } | |
| 2405 | + return loop; | |
| 2406 | + }, | |
| 2407 | + onFailure: (cause) => failCause3(cause), | |
| 2408 | + onDone: () => succeed5(accumulator) | |
| 2409 | + }); | |
| 2410 | + return loop; | |
| 2411 | +}); | |
| 2412 | +var toPersisted = (stream8, writeFile = defaultWriteFile) => gen(function* () { | |
| 2413 | + const fs = yield* FileSystem; | |
| 2414 | + const path_ = yield* Path; | |
| 2415 | + const dir = yield* fs.makeTempDirectoryScoped(); | |
| 2416 | + const persisted = /* @__PURE__ */ Object.create(null); | |
| 2417 | + yield* runForEach(stream8, (part) => { | |
| 2418 | + if (part._tag === "Field") { | |
| 2419 | + if (!(part.key in persisted)) { | |
| 2420 | + persisted[part.key] = part.value; | |
| 2421 | + } else if (typeof persisted[part.key] === "string") { | |
| 2422 | + persisted[part.key] = [persisted[part.key], part.value]; | |
| 2423 | + } else { | |
| 2424 | + ; | |
| 2425 | + persisted[part.key].push(part.value); | |
| 2426 | + } | |
| 2427 | + return _void; | |
| 2428 | + } else if (part.name === "") { | |
| 2429 | + return _void; | |
| 2430 | + } | |
| 2431 | + const file3 = part; | |
| 2432 | + const path = path_.join(dir, path_.basename(file3.name).slice(-128)); | |
| 2433 | + const filePart = new PersistedFileImpl(file3.key, file3.name, file3.contentType, path); | |
| 2434 | + if (Array.isArray(persisted[part.key])) { | |
| 2435 | + ; | |
| 2436 | + persisted[part.key].push(filePart); | |
| 2437 | + } else { | |
| 2438 | + persisted[part.key] = [filePart]; | |
| 2439 | + } | |
| 2440 | + return writeFile(path, file3); | |
| 2441 | + }); | |
| 2442 | + return persisted; | |
| 2443 | +}).pipe(catchTags({ | |
| 2444 | + SystemError: (cause) => fail3(new MultipartError({ | |
| 2445 | + reason: "InternalError", | |
| 2446 | + cause | |
| 2447 | + })), | |
| 2448 | + BadArgument: (cause) => fail3(new MultipartError({ | |
| 2449 | + reason: "InternalError", | |
| 2450 | + cause | |
| 2451 | + })) | |
| 2452 | +})); | |
| 2453 | +var PersistedFileImpl = class extends PartBase { | |
| 2454 | + key; | |
| 2455 | + name; | |
| 2456 | + contentType; | |
| 2457 | + path; | |
| 2458 | + _tag = "PersistedFile"; | |
| 2459 | + constructor(key, name, contentType, path) { | |
| 2460 | + super(); | |
| 2461 | + this.key = key; | |
| 2462 | + this.name = name; | |
| 2463 | + this.contentType = contentType; | |
| 2464 | + this.path = path; | |
| 2465 | + } | |
| 2466 | + toJSON() { | |
| 2467 | + return { | |
| 2468 | + _id: "@effect/platform/Multipart/Part", | |
| 2469 | + _tag: "PersistedFile", | |
| 2470 | + key: this.key, | |
| 2471 | + name: this.name, | |
| 2472 | + contentType: this.contentType, | |
| 2473 | + path: this.path | |
| 2474 | + }; | |
| 2475 | + } | |
| 2476 | +}; | |
| 2477 | +var withLimits = dual(2, (effect2, options4) => provide(effect2, withLimitsContext(options4))); | |
| 2478 | +var withLimitsContext = (options4) => { | |
| 2479 | + const contextMap = /* @__PURE__ */ new Map(); | |
| 2480 | + if (options4.maxParts !== void 0) { | |
| 2481 | + contextMap.set(MaxParts.key, options4.maxParts); | |
| 2482 | + } | |
| 2483 | + if (options4.maxFieldSize !== void 0) { | |
| 2484 | + contextMap.set(MaxFieldSize.key, Size(options4.maxFieldSize)); | |
| 2485 | + } | |
| 2486 | + if (options4.maxFileSize !== void 0) { | |
| 2487 | + contextMap.set(MaxFileSize.key, map2(options4.maxFileSize, Size)); | |
| 2488 | + } | |
| 2489 | + if (options4.maxTotalSize !== void 0) { | |
| 2490 | + contextMap.set(MaxBodySize.key, map2(options4.maxTotalSize, Size)); | |
| 2491 | + } | |
| 2492 | + if (options4.fieldMimeTypes !== void 0) { | |
| 2493 | + contextMap.set(FieldMimeTypes.key, fromIterable2(options4.fieldMimeTypes)); | |
| 2494 | + } | |
| 2495 | + return unsafeMake(contextMap); | |
| 2496 | +}; | |
| 2497 | +var withLimitsStream = dual(2, (stream8, options4) => provideSomeContext(stream8, withLimitsContext(options4))); | |
| 2498 | +var MaxParts = class extends Reference()("@effect/platform/Multipart/MaxParts", { | |
| 2499 | + defaultValue: none | |
| 2500 | +}) { | |
| 2501 | +}; | |
| 2502 | +var withMaxParts = dual(2, (effect2, count) => provideService(effect2, MaxParts, count)); | |
| 2503 | +var MaxFieldSize = class extends Reference()("@effect/platform/Multipart/MaxFieldSize", { | |
| 2504 | + defaultValue: constant(Size(10 * 1024 * 1024)) | |
| 2505 | +}) { | |
| 2506 | +}; | |
| 2507 | +var withMaxFieldSize = dual(2, (effect2, size) => provideService(effect2, MaxFieldSize, Size(size))); | |
| 2508 | +var MaxFileSize = class extends Reference()("@effect/platform/Multipart/MaxFileSize", { | |
| 2509 | + defaultValue: none | |
| 2510 | +}) { | |
| 2511 | +}; | |
| 2512 | +var withMaxFileSize = dual(2, (effect2, size) => provideService(effect2, MaxFileSize, map2(size, Size))); | |
| 2513 | +var FieldMimeTypes = class extends Reference()("@effect/platform/Multipart/FieldMimeTypes", { | |
| 2514 | + defaultValue: constant(make("application/json")) | |
| 2515 | +}) { | |
| 2516 | +}; | |
| 2517 | +var withFieldMimeTypes = dual(2, (effect2, mimeTypes) => provideService(effect2, FieldMimeTypes, fromIterable2(mimeTypes))); | |
| 2518 | + | |
| 2519 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpServerRequest.js | |
| 2520 | +var TypeId10 = Symbol.for("@effect/platform/HttpServerRequest"); | |
| 2521 | +var serverRequestTag = GenericTag("@effect/platform/HttpServerRequest"); | |
| 2522 | +var parsedSearchParamsTag = GenericTag("@effect/platform/HttpServerRequest/ParsedSearchParams"); | |
| 2523 | +var upgrade = flatMap2(serverRequestTag, (request) => request.upgrade); | |
| 2524 | +var upgradeChannel = () => unwrap(map5(upgrade, toChannelWith())); | |
| 2525 | +var multipartPersisted = flatMap2(serverRequestTag, (request) => request.multipart); | |
| 2526 | +var searchParamsFromURL = (url) => { | |
| 2527 | + const out = {}; | |
| 2528 | + for (const [key, value2] of url.searchParams.entries()) { | |
| 2529 | + const entry = out[key]; | |
| 2530 | + if (entry !== void 0) { | |
| 2531 | + if (Array.isArray(entry)) { | |
| 2532 | + entry.push(value2); | |
| 2533 | + } else { | |
| 2534 | + out[key] = [entry, value2]; | |
| 2535 | + } | |
| 2536 | + } else { | |
| 2537 | + out[key] = value2; | |
| 2538 | + } | |
| 2539 | + } | |
| 2540 | + return out; | |
| 2541 | +}; | |
| 2542 | +var schemaCookies = (schema2, options4) => { | |
| 2543 | + const parse3 = decodeUnknown(schema2, options4); | |
| 2544 | + return flatMap2(serverRequestTag, (req) => parse3(req.cookies)); | |
| 2545 | +}; | |
| 2546 | +var schemaHeaders2 = (schema2, options4) => { | |
| 2547 | + const parse3 = schemaHeaders(schema2, options4); | |
| 2548 | + return flatMap2(serverRequestTag, parse3); | |
| 2549 | +}; | |
| 2550 | +var schemaSearchParams = (schema2, options4) => { | |
| 2551 | + const parse3 = decodeUnknown(schema2, options4); | |
| 2552 | + return flatMap2(parsedSearchParamsTag, parse3); | |
| 2553 | +}; | |
| 2554 | +var schemaBodyJson2 = (schema2, options4) => { | |
| 2555 | + const parse3 = schemaBodyJson(schema2, options4); | |
| 2556 | + return flatMap2(serverRequestTag, parse3); | |
| 2557 | +}; | |
| 2558 | +var isMultipart = (request) => request.headers["content-type"]?.toLowerCase().includes("multipart/form-data"); | |
| 2559 | +var schemaBodyForm = (schema2, options4) => { | |
| 2560 | + const parseMultipart = schemaPersisted(schema2, options4); | |
| 2561 | + const parseUrlParams = schemaBodyUrlParams(schema2, options4); | |
| 2562 | + return flatMap2(serverRequestTag, (request) => { | |
| 2563 | + if (isMultipart(request)) { | |
| 2564 | + return flatMap2(request.multipart, parseMultipart); | |
| 2565 | + } | |
| 2566 | + return parseUrlParams(request); | |
| 2567 | + }); | |
| 2568 | +}; | |
| 2569 | +var schemaBodyUrlParams2 = (schema2, options4) => { | |
| 2570 | + const parse3 = schemaBodyUrlParams(schema2, options4); | |
| 2571 | + return flatMap2(serverRequestTag, parse3); | |
| 2572 | +}; | |
| 2573 | +var schemaBodyMultipart = (schema2, options4) => { | |
| 2574 | + const parse3 = schemaPersisted(schema2, options4); | |
| 2575 | + return flatMap2(multipartPersisted, parse3); | |
| 2576 | +}; | |
| 2577 | +var schemaBodyFormJson = (schema2, options4) => { | |
| 2578 | + const parseMultipart = schemaJson4(schema2, options4); | |
| 2579 | + const parseUrlParams = schemaJson(schema2, options4); | |
| 2580 | + return (field) => flatMap2(serverRequestTag, (request) => { | |
| 2581 | + if (isMultipart(request)) { | |
| 2582 | + return flatMap2(mapError(request.multipart, (cause) => new RequestError2({ | |
| 2583 | + request, | |
| 2584 | + reason: "Decode", | |
| 2585 | + cause | |
| 2586 | + })), parseMultipart(field)); | |
| 2587 | + } | |
| 2588 | + return flatMap2(request.urlParamsBody, parseUrlParams(field)); | |
| 2589 | + }); | |
| 2590 | +}; | |
| 2591 | +var fromWeb3 = (request) => new ServerRequestImpl(request, removeHost(request.url)); | |
| 2592 | +var removeHost = (url) => { | |
| 2593 | + if (url[0] === "/") { | |
| 2594 | + return url; | |
| 2595 | + } | |
| 2596 | + const index = url.indexOf("/", url.indexOf("//") + 2); | |
| 2597 | + return index === -1 ? "/" : url.slice(index); | |
| 2598 | +}; | |
| 2599 | +var ServerRequestImpl = class _ServerRequestImpl extends Class { | |
| 2600 | + source; | |
| 2601 | + url; | |
| 2602 | + headersOverride; | |
| 2603 | + remoteAddressOverride; | |
| 2604 | + [TypeId10]; | |
| 2605 | + [TypeId]; | |
| 2606 | + constructor(source, url, headersOverride, remoteAddressOverride) { | |
| 2607 | + super(); | |
| 2608 | + this.source = source; | |
| 2609 | + this.url = url; | |
| 2610 | + this.headersOverride = headersOverride; | |
| 2611 | + this.remoteAddressOverride = remoteAddressOverride; | |
| 2612 | + this[TypeId10] = TypeId10; | |
| 2613 | + this[TypeId] = TypeId; | |
| 2614 | + } | |
| 2615 | + toJSON() { | |
| 2616 | + return inspect(this, { | |
| 2617 | + _id: "@effect/platform/HttpServerRequest", | |
| 2618 | + method: this.method, | |
| 2619 | + url: this.originalUrl | |
| 2620 | + }); | |
| 2621 | + } | |
| 2622 | + modify(options4) { | |
| 2623 | + return new _ServerRequestImpl(this.source, options4.url ?? this.url, options4.headers ?? this.headersOverride, options4.remoteAddress ?? this.remoteAddressOverride); | |
| 2624 | + } | |
| 2625 | + get method() { | |
| 2626 | + return this.source.method.toUpperCase(); | |
| 2627 | + } | |
| 2628 | + get originalUrl() { | |
| 2629 | + return this.source.url; | |
| 2630 | + } | |
| 2631 | + get remoteAddress() { | |
| 2632 | + return this.remoteAddressOverride ? some(this.remoteAddressOverride) : none(); | |
| 2633 | + } | |
| 2634 | + get headers() { | |
| 2635 | + this.headersOverride ??= fromInput2(this.source.headers); | |
| 2636 | + return this.headersOverride; | |
| 2637 | + } | |
| 2638 | + cachedCookies; | |
| 2639 | + get cookies() { | |
| 2640 | + if (this.cachedCookies) { | |
| 2641 | + return this.cachedCookies; | |
| 2642 | + } | |
| 2643 | + return this.cachedCookies = parseHeader(this.headers.cookie ?? ""); | |
| 2644 | + } | |
| 2645 | + get stream() { | |
| 2646 | + return this.source.body ? fromReadableStream(() => this.source.body, (cause) => new RequestError2({ | |
| 2647 | + request: this, | |
| 2648 | + reason: "Decode", | |
| 2649 | + cause | |
| 2650 | + })) : fail4(new RequestError2({ | |
| 2651 | + request: this, | |
| 2652 | + reason: "Decode", | |
| 2653 | + description: "can not create stream from empty body" | |
| 2654 | + })); | |
| 2655 | + } | |
| 2656 | + textEffect; | |
| 2657 | + get text() { | |
| 2658 | + if (this.textEffect) { | |
| 2659 | + return this.textEffect; | |
| 2660 | + } | |
| 2661 | + this.textEffect = runSync(cached(tryPromise({ | |
| 2662 | + try: () => this.source.text(), | |
| 2663 | + catch: (cause) => new RequestError2({ | |
| 2664 | + request: this, | |
| 2665 | + reason: "Decode", | |
| 2666 | + cause | |
| 2667 | + }) | |
| 2668 | + }))); | |
| 2669 | + return this.textEffect; | |
| 2670 | + } | |
| 2671 | + get json() { | |
| 2672 | + return tryMap(this.text, { | |
| 2673 | + try: (_) => JSON.parse(_), | |
| 2674 | + catch: (cause) => new RequestError2({ | |
| 2675 | + request: this, | |
| 2676 | + reason: "Decode", | |
| 2677 | + cause | |
| 2678 | + }) | |
| 2679 | + }); | |
| 2680 | + } | |
| 2681 | + get urlParamsBody() { | |
| 2682 | + return flatMap2(this.text, (_) => try_2({ | |
| 2683 | + try: () => fromInput(new URLSearchParams(_)), | |
| 2684 | + catch: (cause) => new RequestError2({ | |
| 2685 | + request: this, | |
| 2686 | + reason: "Decode", | |
| 2687 | + cause | |
| 2688 | + }) | |
| 2689 | + })); | |
| 2690 | + } | |
| 2691 | + multipartEffect; | |
| 2692 | + get multipart() { | |
| 2693 | + if (this.multipartEffect) { | |
| 2694 | + return this.multipartEffect; | |
| 2695 | + } | |
| 2696 | + this.multipartEffect = runSync(cached(toPersisted(this.multipartStream))); | |
| 2697 | + return this.multipartEffect; | |
| 2698 | + } | |
| 2699 | + get multipartStream() { | |
| 2700 | + return pipeThroughChannel(mapError2(this.stream, (cause) => new MultipartError({ | |
| 2701 | + reason: "InternalError", | |
| 2702 | + cause | |
| 2703 | + })), makeChannel(this.headers)); | |
| 2704 | + } | |
| 2705 | + arrayBufferEffect; | |
| 2706 | + get arrayBuffer() { | |
| 2707 | + if (this.arrayBufferEffect) { | |
| 2708 | + return this.arrayBufferEffect; | |
| 2709 | + } | |
| 2710 | + this.arrayBufferEffect = runSync(cached(tryPromise({ | |
| 2711 | + try: () => this.source.arrayBuffer(), | |
| 2712 | + catch: (cause) => new RequestError2({ | |
| 2713 | + request: this, | |
| 2714 | + reason: "Decode", | |
| 2715 | + cause | |
| 2716 | + }) | |
| 2717 | + }))); | |
| 2718 | + return this.arrayBufferEffect; | |
| 2719 | + } | |
| 2720 | + get upgrade() { | |
| 2721 | + return fail3(new RequestError2({ | |
| 2722 | + request: this, | |
| 2723 | + reason: "Decode", | |
| 2724 | + description: "Not an upgradeable ServerRequest" | |
| 2725 | + })); | |
| 2726 | + } | |
| 2727 | +}; | |
| 2728 | +var toURL = (self) => { | |
| 2729 | + const host = self.headers.host ?? "localhost"; | |
| 2730 | + const protocol = self.headers["x-forwarded-proto"] === "https" ? "https" : "http"; | |
| 2731 | + try { | |
| 2732 | + return some(new URL(self.url, `${protocol}://${host}`)); | |
| 2733 | + } catch { | |
| 2734 | + return none(); | |
| 2735 | + } | |
| 2736 | +}; | |
| 2737 | + | |
| 2738 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServerRequest.js | |
| 2739 | +var TypeId11 = TypeId10; | |
| 2740 | +var HttpServerRequest = serverRequestTag; | |
| 2741 | +var ParsedSearchParams = parsedSearchParamsTag; | |
| 2742 | +var searchParamsFromURL2 = searchParamsFromURL; | |
| 2743 | +var persistedMultipart = multipartPersisted; | |
| 2744 | +var upgrade2 = upgrade; | |
| 2745 | +var upgradeChannel2 = upgradeChannel; | |
| 2746 | +var schemaCookies2 = schemaCookies; | |
| 2747 | +var schemaHeaders3 = schemaHeaders2; | |
| 2748 | +var schemaSearchParams2 = schemaSearchParams; | |
| 2749 | +var schemaBodyJson3 = schemaBodyJson2; | |
| 2750 | +var schemaBodyForm2 = schemaBodyForm; | |
| 2751 | +var schemaBodyUrlParams3 = schemaBodyUrlParams2; | |
| 2752 | +var schemaBodyMultipart2 = schemaBodyMultipart; | |
| 2753 | +var schemaBodyFormJson2 = schemaBodyFormJson; | |
| 2754 | +var fromWeb4 = fromWeb3; | |
| 2755 | +var toWebEither = (self, options4) => { | |
| 2756 | + if (self.source instanceof Request) { | |
| 2757 | + return right(self.source); | |
| 2758 | + } | |
| 2759 | + const ourl = toURL2(self); | |
| 2760 | + if (isNone(ourl)) { | |
| 2761 | + return left(new RequestError2({ | |
| 2762 | + request: self, | |
| 2763 | + reason: "Decode", | |
| 2764 | + description: "Invalid URL" | |
| 2765 | + })); | |
| 2766 | + } | |
| 2767 | + const requestInit = { | |
| 2768 | + method: self.method, | |
| 2769 | + headers: self.headers, | |
| 2770 | + signal: options4?.signal | |
| 2771 | + }; | |
| 2772 | + if (hasBody(self.method)) { | |
| 2773 | + requestInit.body = toReadableStreamRuntime(self.stream, options4?.runtime ?? defaultRuntime); | |
| 2774 | + requestInit.duplex = "half"; | |
| 2775 | + } | |
| 2776 | + return right(new Request(ourl.value, requestInit)); | |
| 2777 | +}; | |
| 2778 | +var toWeb3 = (self, options4) => flatMap2(runtime2(), (runtime3) => toWebEither(self, { | |
| 2779 | + signal: options4?.signal, | |
| 2780 | + runtime: runtime3 | |
| 2781 | +})); | |
| 2782 | +var toURL2 = toURL; | |
| 2783 | + | |
| 2784 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpApp.js | |
| 2785 | +var currentPreResponseHandlers = globalValue(Symbol.for("@effect/platform/HttpApp/preResponseHandlers"), () => unsafeMake3(none())); | |
| 2786 | +var appendPreResponseHandler = (handler2) => update(currentPreResponseHandlers, match2({ | |
| 2787 | + onNone: () => some(handler2), | |
| 2788 | + onSome: (prev) => some((request, response) => flatMap2(prev(request, response), (response2) => handler2(request, response2))) | |
| 2789 | +})); | |
| 2790 | +var withPreResponseHandler = dual(2, (self, handler2) => locallyWith(self, currentPreResponseHandlers, match2({ | |
| 2791 | + onNone: () => some(handler2), | |
| 2792 | + onSome: (prev) => some((request, response) => flatMap2(prev(request, response), (response2) => handler2(request, response2))) | |
| 2793 | +}))); | |
| 2794 | + | |
| 2795 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpMiddleware.js | |
| 2796 | +var make16 = (middleware3) => middleware3; | |
| 2797 | +var loggerDisabled = globalValue(Symbol.for("@effect/platform/HttpMiddleware/loggerDisabled"), () => unsafeMake3(false)); | |
| 2798 | +var withLoggerDisabled = (self) => zipRight(set(loggerDisabled, true), self); | |
| 2799 | +var currentTracerDisabledWhen = globalValue(Symbol.for("@effect/platform/HttpMiddleware/tracerDisabledWhen"), () => unsafeMake3(constFalse)); | |
| 2800 | +var withTracerDisabledWhen = dual(2, (self, pred) => locally2(self, currentTracerDisabledWhen, pred)); | |
| 2801 | +var withTracerDisabledWhenEffect = dual(2, (self, pred) => locally(self, currentTracerDisabledWhen, pred)); | |
| 2802 | +var withTracerDisabledForUrls = dual(2, (self, urls) => locally2(self, currentTracerDisabledWhen, (req) => urls.includes(req.url))); | |
| 2803 | +var SpanNameGenerator = Reference()("@effect/platform/HttpMiddleware/SpanNameGenerator", { | |
| 2804 | + defaultValue: () => (request) => `http.server ${request.method}` | |
| 2805 | +}); | |
| 2806 | +var withSpanNameGenerator = dual(2, (self, f) => provide2(self, succeed2(SpanNameGenerator, f))); | |
| 2807 | +var logger = make16((httpApp2) => { | |
| 2808 | + let counter = 0; | |
| 2809 | + return withFiberRuntime((fiber) => { | |
| 2810 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 2811 | + return withLogSpan(flatMap2(exit(httpApp2), (exit2) => { | |
| 2812 | + if (fiber.getFiberRef(loggerDisabled)) { | |
| 2813 | + return exit2; | |
| 2814 | + } else if (exit2._tag === "Failure") { | |
| 2815 | + const [response, cause] = causeResponseStripped2(exit2.cause); | |
| 2816 | + return zipRight(annotateLogs(log(cause._tag === "Some" ? cause.value : "Sent HTTP Response"), { | |
| 2817 | + "http.method": request.method, | |
| 2818 | + "http.url": request.url, | |
| 2819 | + "http.status": response.status | |
| 2820 | + }), exit2); | |
| 2821 | + } | |
| 2822 | + return zipRight(annotateLogs(log("Sent HTTP response"), { | |
| 2823 | + "http.method": request.method, | |
| 2824 | + "http.url": request.url, | |
| 2825 | + "http.status": exit2.value.status | |
| 2826 | + }), exit2); | |
| 2827 | + }), `http.span.${++counter}`); | |
| 2828 | + }); | |
| 2829 | +}); | |
| 2830 | +var tracer = make16((httpApp2) => withFiberRuntime((fiber) => { | |
| 2831 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 2832 | + const disabled = fiber.getFiberRef(currentTracerDisabledWhen)(request); | |
| 2833 | + if (disabled) { | |
| 2834 | + return httpApp2; | |
| 2835 | + } | |
| 2836 | + const url = getOrUndefined(toURL2(request)); | |
| 2837 | + if (url !== void 0 && (url.username !== "" || url.password !== "")) { | |
| 2838 | + url.username = "REDACTED"; | |
| 2839 | + url.password = "REDACTED"; | |
| 2840 | + } | |
| 2841 | + const redactedHeaderNames = fiber.getFiberRef(currentRedactedNames); | |
| 2842 | + const redactedHeaders = redact2(request.headers, redactedHeaderNames); | |
| 2843 | + const nameGenerator = get(fiber.currentContext, SpanNameGenerator); | |
| 2844 | + return useSpan(nameGenerator(request), { | |
| 2845 | + parent: getOrUndefined(fromHeaders(request.headers)), | |
| 2846 | + kind: "server", | |
| 2847 | + captureStackTrace: false | |
| 2848 | + }, (span) => { | |
| 2849 | + span.attribute("http.request.method", request.method); | |
| 2850 | + if (url !== void 0) { | |
| 2851 | + span.attribute("url.full", url.toString()); | |
| 2852 | + span.attribute("url.path", url.pathname); | |
| 2853 | + const query = url.search.slice(1); | |
| 2854 | + if (query !== "") { | |
| 2855 | + span.attribute("url.query", url.search.slice(1)); | |
| 2856 | + } | |
| 2857 | + span.attribute("url.scheme", url.protocol.slice(0, -1)); | |
| 2858 | + } | |
| 2859 | + if (request.headers["user-agent"] !== void 0) { | |
| 2860 | + span.attribute("user_agent.original", request.headers["user-agent"]); | |
| 2861 | + } | |
| 2862 | + for (const name in redactedHeaders) { | |
| 2863 | + span.attribute(`http.request.header.${name}`, String(redactedHeaders[name])); | |
| 2864 | + } | |
| 2865 | + if (request.remoteAddress._tag === "Some") { | |
| 2866 | + span.attribute("client.address", request.remoteAddress.value); | |
| 2867 | + } | |
| 2868 | + return flatMap2(exit(withParentSpan(httpApp2, span)), (exit2) => { | |
| 2869 | + const response = exitResponse2(exit2); | |
| 2870 | + span.attribute("http.response.status_code", response.status); | |
| 2871 | + const redactedHeaders2 = redact2(response.headers, redactedHeaderNames); | |
| 2872 | + for (const name in redactedHeaders2) { | |
| 2873 | + span.attribute(`http.response.header.${name}`, String(redactedHeaders2[name])); | |
| 2874 | + } | |
| 2875 | + return exit2; | |
| 2876 | + }); | |
| 2877 | + }); | |
| 2878 | +})); | |
| 2879 | +var xForwardedHeaders = make16((httpApp2) => updateService(httpApp2, HttpServerRequest, (request) => { | |
| 2880 | + const host = request.headers["x-forwarded-host"]; | |
| 2881 | + const remoteAddress = request.headers["x-forwarded-for"]?.split(",")[0].trim(); | |
| 2882 | + return request.modify({ | |
| 2883 | + headers: host !== void 0 ? set3(request.headers, "host", host) : void 0, | |
| 2884 | + remoteAddress | |
| 2885 | + }); | |
| 2886 | +})); | |
| 2887 | +var searchParamsParser = (httpApp2) => withFiberRuntime((fiber) => { | |
| 2888 | + const context2 = fiber.currentContext; | |
| 2889 | + const request = unsafeGet(context2, HttpServerRequest); | |
| 2890 | + const params3 = searchParamsFromURL2(new URL(request.originalUrl)); | |
| 2891 | + return locally(httpApp2, currentContext, add(context2, ParsedSearchParams, params3)); | |
| 2892 | +}); | |
| 2893 | +var cors = (options4) => { | |
| 2894 | + const opts = { | |
| 2895 | + allowedOrigins: [], | |
| 2896 | + allowedMethods: ["GET", "HEAD", "PUT", "PATCH", "POST", "DELETE"], | |
| 2897 | + allowedHeaders: [], | |
| 2898 | + exposedHeaders: [], | |
| 2899 | + credentials: false, | |
| 2900 | + ...options4 | |
| 2901 | + }; | |
| 2902 | + const isAllowedOrigin = typeof opts.allowedOrigins === "function" ? opts.allowedOrigins : (origin) => opts.allowedOrigins.includes(origin); | |
| 2903 | + const allowOrigin = typeof opts.allowedOrigins === "function" || opts.allowedOrigins.length > 1 ? (originHeader) => { | |
| 2904 | + if (isAllowedOrigin(originHeader)) { | |
| 2905 | + return { | |
| 2906 | + "access-control-allow-origin": originHeader, | |
| 2907 | + vary: "Origin" | |
| 2908 | + }; | |
| 2909 | + } | |
| 2910 | + return void 0; | |
| 2911 | + } : opts.allowedOrigins.length === 1 ? constant({ | |
| 2912 | + "access-control-allow-origin": opts.allowedOrigins[0], | |
| 2913 | + vary: "Origin" | |
| 2914 | + }) : constant({ | |
| 2915 | + "access-control-allow-origin": "*" | |
| 2916 | + }); | |
| 2917 | + const allowMethods = opts.allowedMethods.length > 0 ? { | |
| 2918 | + "access-control-allow-methods": opts.allowedMethods.join(", ") | |
| 2919 | + } : void 0; | |
| 2920 | + const allowCredentials = opts.credentials ? { | |
| 2921 | + "access-control-allow-credentials": "true" | |
| 2922 | + } : void 0; | |
| 2923 | + const allowHeaders = (accessControlRequestHeaders) => { | |
| 2924 | + if (opts.allowedHeaders.length === 0 && accessControlRequestHeaders) { | |
| 2925 | + return { | |
| 2926 | + vary: "Access-Control-Request-Headers", | |
| 2927 | + "access-control-allow-headers": accessControlRequestHeaders | |
| 2928 | + }; | |
| 2929 | + } | |
| 2930 | + if (opts.allowedHeaders) { | |
| 2931 | + return { | |
| 2932 | + "access-control-allow-headers": opts.allowedHeaders.join(",") | |
| 2933 | + }; | |
| 2934 | + } | |
| 2935 | + return void 0; | |
| 2936 | + }; | |
| 2937 | + const exposeHeaders = opts.exposedHeaders.length > 0 ? { | |
| 2938 | + "access-control-expose-headers": opts.exposedHeaders.join(",") | |
| 2939 | + } : void 0; | |
| 2940 | + const maxAge = opts.maxAge ? { | |
| 2941 | + "access-control-max-age": opts.maxAge.toString() | |
| 2942 | + } : void 0; | |
| 2943 | + const headersFromRequest = (request) => { | |
| 2944 | + const origin = request.headers["origin"]; | |
| 2945 | + return unsafeFromRecord({ | |
| 2946 | + ...allowOrigin(origin), | |
| 2947 | + ...allowCredentials, | |
| 2948 | + ...exposeHeaders | |
| 2949 | + }); | |
| 2950 | + }; | |
| 2951 | + const headersFromRequestOptions = (request) => { | |
| 2952 | + const origin = request.headers["origin"]; | |
| 2953 | + const accessControlRequestHeaders = request.headers["access-control-request-headers"]; | |
| 2954 | + return unsafeFromRecord({ | |
| 2955 | + ...allowOrigin(origin), | |
| 2956 | + ...allowCredentials, | |
| 2957 | + ...exposeHeaders, | |
| 2958 | + ...allowMethods, | |
| 2959 | + ...allowHeaders(accessControlRequestHeaders), | |
| 2960 | + ...maxAge | |
| 2961 | + }); | |
| 2962 | + }; | |
| 2963 | + const preResponseHandler = (request, response) => succeed(setHeaders2(response, headersFromRequest(request))); | |
| 2964 | + return (httpApp2) => withFiberRuntime((fiber) => { | |
| 2965 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 2966 | + if (request.method === "OPTIONS") { | |
| 2967 | + return succeed(empty13({ | |
| 2968 | + status: 204, | |
| 2969 | + headers: headersFromRequestOptions(request) | |
| 2970 | + })); | |
| 2971 | + } | |
| 2972 | + return zipRight(appendPreResponseHandler(preResponseHandler), httpApp2); | |
| 2973 | + }); | |
| 2974 | +}; | |
| 2975 | + | |
| 2976 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpApp.js | |
| 2977 | +var handledSymbol = Symbol.for("@effect/platform/HttpApp/handled"); | |
| 2978 | +var toHandled = (self, handleResponse, middleware3) => { | |
| 2979 | + const responded = withFiberRuntime((fiber) => flatMap2(self, (response) => { | |
| 2980 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 2981 | + const handler2 = fiber.getFiberRef(currentPreResponseHandlers2); | |
| 2982 | + if (handler2._tag === "None") { | |
| 2983 | + ; | |
| 2984 | + request[handledSymbol] = true; | |
| 2985 | + return as(handleResponse(request, response), response); | |
| 2986 | + } | |
| 2987 | + return tap(handler2.value(request, response), (response2) => { | |
| 2988 | + ; | |
| 2989 | + request[handledSymbol] = true; | |
| 2990 | + return handleResponse(request, response2); | |
| 2991 | + }); | |
| 2992 | + })); | |
| 2993 | + const withErrorHandling = catchAllCause(responded, (cause) => withFiberRuntime((fiber) => flatMap2(causeResponse2(cause), ([response, cause2]) => { | |
| 2994 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 2995 | + const handler2 = fiber.getFiberRef(currentPreResponseHandlers2); | |
| 2996 | + if (handler2._tag === "None") { | |
| 2997 | + ; | |
| 2998 | + request[handledSymbol] = true; | |
| 2999 | + return zipRight(handleResponse(request, response), isEmptyType(cause2) ? succeed(response) : failCause2(cause2)); | |
| 3000 | + } | |
| 3001 | + return zipRight(tap(handler2.value(request, response), (response2) => { | |
| 3002 | + ; | |
| 3003 | + request[handledSymbol] = true; | |
| 3004 | + return handleResponse(request, response2); | |
| 3005 | + }), isEmptyType(cause2) ? succeed(response) : failCause2(cause2)); | |
| 3006 | + }))); | |
| 3007 | + const withMiddleware = unify(middleware3 === void 0 ? tracer(withErrorHandling) : matchCauseEffect(tracer(middleware3(withErrorHandling)), { | |
| 3008 | + onFailure: (cause) => withFiberRuntime((fiber) => { | |
| 3009 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 3010 | + if (handledSymbol in request) { | |
| 3011 | + return _void; | |
| 3012 | + } | |
| 3013 | + return matchCauseEffect(causeResponse2(cause), { | |
| 3014 | + onFailure: (_cause) => handleResponse(request, empty13({ | |
| 3015 | + status: 500 | |
| 3016 | + })), | |
| 3017 | + onSuccess: ([response]) => handleResponse(request, response) | |
| 3018 | + }); | |
| 3019 | + }), | |
| 3020 | + onSuccess: (response) => withFiberRuntime((fiber) => { | |
| 3021 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 3022 | + return handledSymbol in request ? _void : handleResponse(request, response); | |
| 3023 | + }) | |
| 3024 | + })); | |
| 3025 | + return uninterruptible(scoped2(withMiddleware)); | |
| 3026 | +}; | |
| 3027 | +var ejectDefaultScopeClose = (scope2) => { | |
| 3028 | + ejectedScopes.add(scope2); | |
| 3029 | +}; | |
| 3030 | +var unsafeEjectStreamScope = (response) => { | |
| 3031 | + if (response.body._tag !== "Stream") { | |
| 3032 | + return response; | |
| 3033 | + } | |
| 3034 | + const fiber = getOrThrow(getCurrentFiber()); | |
| 3035 | + const scope2 = unsafeGet(fiber.currentContext, Scope); | |
| 3036 | + ejectDefaultScopeClose(scope2); | |
| 3037 | + return setBody2(response, stream2(ensuring2(response.body.stream, close(scope2, void_)), response.body.contentType, response.body.contentLength)); | |
| 3038 | +}; | |
| 3039 | +var ejectedScopes = globalValue("@effect/platform/HttpApp/ejectedScopes", () => /* @__PURE__ */ new WeakSet()); | |
| 3040 | +var scoped2 = (effect2) => flatMap2(make2(), (scope2) => onExit(extend(effect2, scope2), (exit2) => { | |
| 3041 | + if (ejectedScopes.has(scope2)) { | |
| 3042 | + return _void; | |
| 3043 | + } | |
| 3044 | + return close(scope2, exit2); | |
| 3045 | +})); | |
| 3046 | +var currentPreResponseHandlers2 = currentPreResponseHandlers; | |
| 3047 | +var appendPreResponseHandler2 = appendPreResponseHandler; | |
| 3048 | +var withPreResponseHandler2 = withPreResponseHandler; | |
| 3049 | +var toWebHandlerRuntime = (runtime3) => { | |
| 3050 | + const httpRuntime = make4(runtime3); | |
| 3051 | + const run3 = runFork2(httpRuntime); | |
| 3052 | + return (self, middleware3) => { | |
| 3053 | + const resolveSymbol = Symbol.for("@effect/platform/HttpApp/resolve"); | |
| 3054 | + const httpApp2 = toHandled(self, (request, response) => { | |
| 3055 | + response = unsafeEjectStreamScope(response); | |
| 3056 | + request[resolveSymbol](toWeb2(response, { | |
| 3057 | + withoutBody: request.method === "HEAD", | |
| 3058 | + runtime: runtime3 | |
| 3059 | + })); | |
| 3060 | + return _void; | |
| 3061 | + }, middleware3); | |
| 3062 | + return (request, context2) => new Promise((resolve) => { | |
| 3063 | + const contextMap = new Map(runtime3.context.unsafeMap); | |
| 3064 | + if (isContext(context2)) { | |
| 3065 | + for (const [key, value2] of context2.unsafeMap) { | |
| 3066 | + contextMap.set(key, value2); | |
| 3067 | + } | |
| 3068 | + } | |
| 3069 | + const httpServerRequest = fromWeb4(request); | |
| 3070 | + contextMap.set(HttpServerRequest.key, httpServerRequest); | |
| 3071 | + httpServerRequest[resolveSymbol] = resolve; | |
| 3072 | + httpRuntime.context = unsafeMake(contextMap); | |
| 3073 | + const fiber = run3(httpApp2); | |
| 3074 | + request.signal?.addEventListener("abort", () => { | |
| 3075 | + fiber.unsafeInterruptAsFork(clientAbortFiberId2); | |
| 3076 | + }, { | |
| 3077 | + once: true | |
| 3078 | + }); | |
| 3079 | + }); | |
| 3080 | + }; | |
| 3081 | +}; | |
| 3082 | +var toWebHandler = toWebHandlerRuntime(defaultRuntime); | |
| 3083 | +var toWebHandlerLayerWith = (layer13, options4) => { | |
| 3084 | + const scope2 = runSync(make2()); | |
| 3085 | + const dispose = () => runPromise(close(scope2, void_)); | |
| 3086 | + let handlerCache; | |
| 3087 | + let handlerPromise; | |
| 3088 | + function handler2(request, context2) { | |
| 3089 | + if (handlerCache) { | |
| 3090 | + return handlerCache(request, context2); | |
| 3091 | + } | |
| 3092 | + handlerPromise ??= gen(function* () { | |
| 3093 | + const runtime3 = yield* options4.memoMap ? toRuntimeWithMemoMap(layer13, options4.memoMap) : toRuntime(layer13); | |
| 3094 | + return handlerCache = toWebHandlerRuntime(runtime3)(yield* options4.toHandler(runtime3), options4.middleware); | |
| 3095 | + }).pipe(extend(scope2), runPromise); | |
| 3096 | + return handlerPromise.then((f) => f(request, context2)); | |
| 3097 | + } | |
| 3098 | + return { | |
| 3099 | + dispose, | |
| 3100 | + handler: handler2 | |
| 3101 | + }; | |
| 3102 | +}; | |
| 3103 | +var toWebHandlerLayer = (self, layer13, options4) => toWebHandlerLayerWith(layer13, { | |
| 3104 | + ...options4, | |
| 3105 | + toHandler: () => succeed(self) | |
| 3106 | +}); | |
| 3107 | +var fromWebHandler = (handler2) => async((resume, signal) => { | |
| 3108 | + const fiber = getOrThrow(getCurrentFiber()); | |
| 3109 | + const request = unsafeGet(fiber.currentContext, HttpServerRequest); | |
| 3110 | + const requestResult = toWebEither(request, { | |
| 3111 | + signal, | |
| 3112 | + runtime: make4({ | |
| 3113 | + context: fiber.currentContext, | |
| 3114 | + fiberRefs: fiber.getFiberRefs(), | |
| 3115 | + runtimeFlags: defaultRuntimeFlags | |
| 3116 | + }) | |
| 3117 | + }); | |
| 3118 | + if (requestResult._tag === "Left") { | |
| 3119 | + return resume(fail3(requestResult.left)); | |
| 3120 | + } | |
| 3121 | + handler2(requestResult.right).then((response) => resume(succeed(fromWeb2(response))), (cause) => resume(fail3(new RequestError2({ | |
| 3122 | + cause, | |
| 3123 | + request, | |
| 3124 | + reason: "Transport", | |
| 3125 | + description: "HttpApp.fromWebHandler: Error in handler" | |
| 3126 | + })))); | |
| 3127 | +}); | |
| 3128 | + | |
| 3129 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpMiddleware.js | |
| 3130 | +var HttpMiddleware_exports = {}; | |
| 3131 | +__export(HttpMiddleware_exports, { | |
| 3132 | + SpanNameGenerator: () => SpanNameGenerator2, | |
| 3133 | + cors: () => cors2, | |
| 3134 | + currentTracerDisabledWhen: () => currentTracerDisabledWhen2, | |
| 3135 | + logger: () => logger2, | |
| 3136 | + loggerDisabled: () => loggerDisabled2, | |
| 3137 | + make: () => make17, | |
| 3138 | + searchParamsParser: () => searchParamsParser2, | |
| 3139 | + withLoggerDisabled: () => withLoggerDisabled2, | |
| 3140 | + withSpanNameGenerator: () => withSpanNameGenerator2, | |
| 3141 | + withTracerDisabledForUrls: () => withTracerDisabledForUrls2, | |
| 3142 | + withTracerDisabledWhen: () => withTracerDisabledWhen2, | |
| 3143 | + withTracerDisabledWhenEffect: () => withTracerDisabledWhenEffect2, | |
| 3144 | + xForwardedHeaders: () => xForwardedHeaders2 | |
| 3145 | +}); | |
| 3146 | +var make17 = make16; | |
| 3147 | +var logger2 = logger; | |
| 3148 | +var loggerDisabled2 = loggerDisabled; | |
| 3149 | +var withLoggerDisabled2 = withLoggerDisabled; | |
| 3150 | +var currentTracerDisabledWhen2 = currentTracerDisabledWhen; | |
| 3151 | +var withTracerDisabledWhen2 = withTracerDisabledWhen; | |
| 3152 | +var withTracerDisabledWhenEffect2 = withTracerDisabledWhenEffect; | |
| 3153 | +var withTracerDisabledForUrls2 = withTracerDisabledForUrls; | |
| 3154 | +var xForwardedHeaders2 = xForwardedHeaders; | |
| 3155 | +var searchParamsParser2 = searchParamsParser; | |
| 3156 | +var cors2 = cors; | |
| 3157 | +var SpanNameGenerator2 = SpanNameGenerator; | |
| 3158 | +var withSpanNameGenerator2 = withSpanNameGenerator; | |
| 3159 | + | |
| 3160 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpRouter.js | |
| 3161 | +var HttpRouter_exports = {}; | |
| 3162 | +__export(HttpRouter_exports, { | |
| 3163 | + Default: () => Default, | |
| 3164 | + RouteContext: () => RouteContext2, | |
| 3165 | + RouteContextTypeId: () => RouteContextTypeId2, | |
| 3166 | + RouteTypeId: () => RouteTypeId2, | |
| 3167 | + Tag: () => Tag4, | |
| 3168 | + TypeId: () => TypeId16, | |
| 3169 | + all: () => all3, | |
| 3170 | + append: () => append3, | |
| 3171 | + catchAll: () => catchAll3, | |
| 3172 | + catchAllCause: () => catchAllCause3, | |
| 3173 | + catchTag: () => catchTag3, | |
| 3174 | + catchTags: () => catchTags3, | |
| 3175 | + concat: () => concat2, | |
| 3176 | + concatAll: () => concatAll2, | |
| 3177 | + currentRouterConfig: () => currentRouterConfig2, | |
| 3178 | + del: () => del2, | |
| 3179 | + empty: () => empty15, | |
| 3180 | + fromIterable: () => fromIterable7, | |
| 3181 | + get: () => get4, | |
| 3182 | + head: () => head2, | |
| 3183 | + makeRoute: () => makeRoute2, | |
| 3184 | + mount: () => mount2, | |
| 3185 | + mountApp: () => mountApp2, | |
| 3186 | + options: () => options2, | |
| 3187 | + params: () => params2, | |
| 3188 | + patch: () => patch2, | |
| 3189 | + post: () => post2, | |
| 3190 | + prefixAll: () => prefixAll2, | |
| 3191 | + prefixPath: () => prefixPath2, | |
| 3192 | + provideService: () => provideService3, | |
| 3193 | + provideServiceEffect: () => provideServiceEffect3, | |
| 3194 | + put: () => put2, | |
| 3195 | + route: () => route2, | |
| 3196 | + schemaJson: () => schemaJson6, | |
| 3197 | + schemaNoBody: () => schemaNoBody2, | |
| 3198 | + schemaParams: () => schemaParams2, | |
| 3199 | + schemaPathParams: () => schemaPathParams2, | |
| 3200 | + setRouterConfig: () => setRouterConfig2, | |
| 3201 | + toHttpApp: () => toHttpApp2, | |
| 3202 | + transform: () => transform3, | |
| 3203 | + use: () => use2, | |
| 3204 | + withRouterConfig: () => withRouterConfig2 | |
| 3205 | +}); | |
| 3206 | + | |
| 3207 | +// ../../node_modules/.bun/find-my-way-ts@0.1.6/node_modules/find-my-way-ts/dist/esm/index.js | |
| 3208 | +var esm_exports2 = {}; | |
| 3209 | +__export(esm_exports2, { | |
| 3210 | + make: () => make19 | |
| 3211 | +}); | |
| 3212 | + | |
| 3213 | +// ../../node_modules/.bun/find-my-way-ts@0.1.6/node_modules/find-my-way-ts/dist/esm/QueryString.js | |
| 3214 | +var plusRegex = /\+/g; | |
| 3215 | +var Empty = function() { | |
| 3216 | +}; | |
| 3217 | +Empty.prototype = /* @__PURE__ */ Object.create(null); | |
| 3218 | +function parse2(input) { | |
| 3219 | + const result = new Empty(); | |
| 3220 | + if (typeof input !== "string") { | |
| 3221 | + return result; | |
| 3222 | + } | |
| 3223 | + const inputLength = input.length; | |
| 3224 | + let key = ""; | |
| 3225 | + let value2 = ""; | |
| 3226 | + let startingIndex = -1; | |
| 3227 | + let equalityIndex = -1; | |
| 3228 | + let shouldDecodeKey = false; | |
| 3229 | + let shouldDecodeValue = false; | |
| 3230 | + let keyHasPlus = false; | |
| 3231 | + let valueHasPlus = false; | |
| 3232 | + let hasBothKeyValuePair = false; | |
| 3233 | + let c = 0; | |
| 3234 | + for (let i = 0; i < inputLength + 1; i++) { | |
| 3235 | + c = i !== inputLength ? input.charCodeAt(i) : 38; | |
| 3236 | + if (c === 38) { | |
| 3237 | + hasBothKeyValuePair = equalityIndex > startingIndex; | |
| 3238 | + if (!hasBothKeyValuePair) { | |
| 3239 | + equalityIndex = i; | |
| 3240 | + } | |
| 3241 | + key = input.slice(startingIndex + 1, equalityIndex); | |
| 3242 | + if (hasBothKeyValuePair || key.length > 0) { | |
| 3243 | + if (keyHasPlus) { | |
| 3244 | + key = key.replace(plusRegex, " "); | |
| 3245 | + } | |
| 3246 | + if (shouldDecodeKey) { | |
| 3247 | + try { | |
| 3248 | + key = decodeURIComponent(key) || key; | |
| 3249 | + } catch { | |
| 3250 | + } | |
| 3251 | + } | |
| 3252 | + if (hasBothKeyValuePair) { | |
| 3253 | + value2 = input.slice(equalityIndex + 1, i); | |
| 3254 | + if (valueHasPlus) { | |
| 3255 | + value2 = value2.replace(plusRegex, " "); | |
| 3256 | + } | |
| 3257 | + if (shouldDecodeValue) { | |
| 3258 | + try { | |
| 3259 | + value2 = decodeURIComponent(value2) || value2; | |
| 3260 | + } catch { | |
| 3261 | + } | |
| 3262 | + } | |
| 3263 | + } | |
| 3264 | + const currentValue = result[key]; | |
| 3265 | + if (currentValue === void 0) { | |
| 3266 | + result[key] = value2; | |
| 3267 | + } else { | |
| 3268 | + if (currentValue.pop) { | |
| 3269 | + currentValue.push(value2); | |
| 3270 | + } else { | |
| 3271 | + result[key] = [currentValue, value2]; | |
| 3272 | + } | |
| 3273 | + } | |
| 3274 | + } | |
| 3275 | + value2 = ""; | |
| 3276 | + startingIndex = i; | |
| 3277 | + equalityIndex = i; | |
| 3278 | + shouldDecodeKey = false; | |
| 3279 | + shouldDecodeValue = false; | |
| 3280 | + keyHasPlus = false; | |
| 3281 | + valueHasPlus = false; | |
| 3282 | + } else if (c === 61) { | |
| 3283 | + if (equalityIndex <= startingIndex) { | |
| 3284 | + equalityIndex = i; | |
| 3285 | + } else { | |
| 3286 | + shouldDecodeValue = true; | |
| 3287 | + } | |
| 3288 | + } else if (c === 43) { | |
| 3289 | + if (equalityIndex > startingIndex) { | |
| 3290 | + valueHasPlus = true; | |
| 3291 | + } else { | |
| 3292 | + keyHasPlus = true; | |
| 3293 | + } | |
| 3294 | + } else if (c === 37) { | |
| 3295 | + if (equalityIndex > startingIndex) { | |
| 3296 | + shouldDecodeValue = true; | |
| 3297 | + } else { | |
| 3298 | + shouldDecodeKey = true; | |
| 3299 | + } | |
| 3300 | + } | |
| 3301 | + } | |
| 3302 | + return result; | |
| 3303 | +} | |
| 3304 | +var hexTable = Array.from({ | |
| 3305 | + length: 256 | |
| 3306 | +}, (_, i) => "%" + ((i < 16 ? "0" : "") + i.toString(16)).toUpperCase()); | |
| 3307 | +var noEscape = new Int8Array([ | |
| 3308 | + 0, | |
| 3309 | + 0, | |
| 3310 | + 0, | |
| 3311 | + 0, | |
| 3312 | + 0, | |
| 3313 | + 0, | |
| 3314 | + 0, | |
| 3315 | + 0, | |
| 3316 | + 0, | |
| 3317 | + 0, | |
| 3318 | + 0, | |
| 3319 | + 0, | |
| 3320 | + 0, | |
| 3321 | + 0, | |
| 3322 | + 0, | |
| 3323 | + 0, | |
| 3324 | + // 0 - 15 | |
| 3325 | + 0, | |
| 3326 | + 0, | |
| 3327 | + 0, | |
| 3328 | + 0, | |
| 3329 | + 0, | |
| 3330 | + 0, | |
| 3331 | + 0, | |
| 3332 | + 0, | |
| 3333 | + 0, | |
| 3334 | + 0, | |
| 3335 | + 0, | |
| 3336 | + 0, | |
| 3337 | + 0, | |
| 3338 | + 0, | |
| 3339 | + 0, | |
| 3340 | + 0, | |
| 3341 | + // 16 - 31 | |
| 3342 | + 0, | |
| 3343 | + 1, | |
| 3344 | + 0, | |
| 3345 | + 0, | |
| 3346 | + 0, | |
| 3347 | + 0, | |
| 3348 | + 0, | |
| 3349 | + 1, | |
| 3350 | + 1, | |
| 3351 | + 1, | |
| 3352 | + 1, | |
| 3353 | + 0, | |
| 3354 | + 0, | |
| 3355 | + 1, | |
| 3356 | + 1, | |
| 3357 | + 0, | |
| 3358 | + // 32 - 47 | |
| 3359 | + 1, | |
| 3360 | + 1, | |
| 3361 | + 1, | |
| 3362 | + 1, | |
| 3363 | + 1, | |
| 3364 | + 1, | |
| 3365 | + 1, | |
| 3366 | + 1, | |
| 3367 | + 1, | |
| 3368 | + 1, | |
| 3369 | + 0, | |
| 3370 | + 0, | |
| 3371 | + 0, | |
| 3372 | + 0, | |
| 3373 | + 0, | |
| 3374 | + 0, | |
| 3375 | + // 48 - 63 | |
| 3376 | + 0, | |
| 3377 | + 1, | |
| 3378 | + 1, | |
| 3379 | + 1, | |
| 3380 | + 1, | |
| 3381 | + 1, | |
| 3382 | + 1, | |
| 3383 | + 1, | |
| 3384 | + 1, | |
| 3385 | + 1, | |
| 3386 | + 1, | |
| 3387 | + 1, | |
| 3388 | + 1, | |
| 3389 | + 1, | |
| 3390 | + 1, | |
| 3391 | + 1, | |
| 3392 | + // 64 - 79 | |
| 3393 | + 1, | |
| 3394 | + 1, | |
| 3395 | + 1, | |
| 3396 | + 1, | |
| 3397 | + 1, | |
| 3398 | + 1, | |
| 3399 | + 1, | |
| 3400 | + 1, | |
| 3401 | + 1, | |
| 3402 | + 1, | |
| 3403 | + 1, | |
| 3404 | + 0, | |
| 3405 | + 0, | |
| 3406 | + 0, | |
| 3407 | + 0, | |
| 3408 | + 1, | |
| 3409 | + // 80 - 95 | |
| 3410 | + 0, | |
| 3411 | + 1, | |
| 3412 | + 1, | |
| 3413 | + 1, | |
| 3414 | + 1, | |
| 3415 | + 1, | |
| 3416 | + 1, | |
| 3417 | + 1, | |
| 3418 | + 1, | |
| 3419 | + 1, | |
| 3420 | + 1, | |
| 3421 | + 1, | |
| 3422 | + 1, | |
| 3423 | + 1, | |
| 3424 | + 1, | |
| 3425 | + 1, | |
| 3426 | + // 96 - 111 | |
| 3427 | + 1, | |
| 3428 | + 1, | |
| 3429 | + 1, | |
| 3430 | + 1, | |
| 3431 | + 1, | |
| 3432 | + 1, | |
| 3433 | + 1, | |
| 3434 | + 1, | |
| 3435 | + 1, | |
| 3436 | + 1, | |
| 3437 | + 1, | |
| 3438 | + 0, | |
| 3439 | + 0, | |
| 3440 | + 0, | |
| 3441 | + 1, | |
| 3442 | + 0 | |
| 3443 | + // 112 - 127 | |
| 3444 | +]); | |
| 3445 | + | |
| 3446 | +// ../../node_modules/.bun/find-my-way-ts@0.1.6/node_modules/find-my-way-ts/dist/esm/internal/router.js | |
| 3447 | +var FULL_PATH_REGEXP = /^https?:\/\/.*?\//; | |
| 3448 | +var OPTIONAL_PARAM_REGEXP = /(\/:[^/()]*?)\?(\/?)/; | |
| 3449 | +var make18 = (options4 = {}) => new RouterImpl(options4); | |
| 3450 | +var RouterImpl = class { | |
| 3451 | + constructor(options4 = {}) { | |
| 3452 | + this.options = { | |
| 3453 | + ignoreTrailingSlash: true, | |
| 3454 | + ignoreDuplicateSlashes: true, | |
| 3455 | + caseSensitive: false, | |
| 3456 | + maxParamLength: 100, | |
| 3457 | + ...options4 | |
| 3458 | + }; | |
| 3459 | + } | |
| 3460 | + options; | |
| 3461 | + routes = []; | |
| 3462 | + trees = {}; | |
| 3463 | + on(method, path, handler2) { | |
| 3464 | + const optionalParamMatch = path.match(OPTIONAL_PARAM_REGEXP); | |
| 3465 | + if (optionalParamMatch && optionalParamMatch.index !== void 0) { | |
| 3466 | + assert(path.length === optionalParamMatch.index + optionalParamMatch[0].length, "Optional Parameter needs to be the last parameter of the path"); | |
| 3467 | + const pathFull = path.replace(OPTIONAL_PARAM_REGEXP, "$1$2"); | |
| 3468 | + const pathOptional = path.replace(OPTIONAL_PARAM_REGEXP, "$2"); | |
| 3469 | + this.on(method, pathFull, handler2); | |
| 3470 | + this.on(method, pathOptional, handler2); | |
| 3471 | + return; | |
| 3472 | + } | |
| 3473 | + if (this.options.ignoreDuplicateSlashes) { | |
| 3474 | + path = removeDuplicateSlashes(path); | |
| 3475 | + } | |
| 3476 | + if (this.options.ignoreTrailingSlash) { | |
| 3477 | + path = trimLastSlash(path); | |
| 3478 | + } | |
| 3479 | + const methods = typeof method === "string" ? [method] : method; | |
| 3480 | + for (const method2 of methods) { | |
| 3481 | + this._on(method2, path, handler2); | |
| 3482 | + } | |
| 3483 | + } | |
| 3484 | + all(path, handler2) { | |
| 3485 | + this.on(httpMethods, path, handler2); | |
| 3486 | + } | |
| 3487 | + _on(method, path, handler2) { | |
| 3488 | + if (this.trees[method] === void 0) { | |
| 3489 | + this.trees[method] = new StaticNode("/"); | |
| 3490 | + } | |
| 3491 | + let pattern = path; | |
| 3492 | + if (pattern === "*" && this.trees[method].prefix.length !== 0) { | |
| 3493 | + const currentRoot = this.trees[method]; | |
| 3494 | + this.trees[method] = new StaticNode(""); | |
| 3495 | + this.trees[method].staticChildren["/"] = currentRoot; | |
| 3496 | + } | |
| 3497 | + let parentNodePathIndex = this.trees[method].prefix.length; | |
| 3498 | + let currentNode = this.trees[method]; | |
| 3499 | + const params3 = []; | |
| 3500 | + for (let i = 0; i <= pattern.length; i++) { | |
| 3501 | + if (pattern.charCodeAt(i) === 58 && pattern.charCodeAt(i + 1) === 58) { | |
| 3502 | + i++; | |
| 3503 | + continue; | |
| 3504 | + } | |
| 3505 | + const isParametricNode = pattern.charCodeAt(i) === 58 && pattern.charCodeAt(i + 1) !== 58; | |
| 3506 | + const isWildcardNode = pattern.charCodeAt(i) === 42; | |
| 3507 | + if (isParametricNode || isWildcardNode || i === pattern.length && i !== parentNodePathIndex) { | |
| 3508 | + let staticNodePath = pattern.slice(parentNodePathIndex, i); | |
| 3509 | + if (!this.options.caseSensitive) { | |
| 3510 | + staticNodePath = staticNodePath.toLowerCase(); | |
| 3511 | + } | |
| 3512 | + staticNodePath = staticNodePath.split("::").join(":"); | |
| 3513 | + staticNodePath = staticNodePath.split("%").join("%25"); | |
| 3514 | + currentNode = currentNode.createStaticChild(staticNodePath); | |
| 3515 | + } | |
| 3516 | + if (isParametricNode) { | |
| 3517 | + let isRegexNode = false; | |
| 3518 | + const regexps = []; | |
| 3519 | + let lastParamStartIndex = i + 1; | |
| 3520 | + for (let j = lastParamStartIndex; ; j++) { | |
| 3521 | + const charCode = pattern.charCodeAt(j); | |
| 3522 | + const isRegexParam = charCode === 40; | |
| 3523 | + const isStaticPart = charCode === 45 || charCode === 46; | |
| 3524 | + const isEndOfNode = charCode === 47 || j === pattern.length; | |
| 3525 | + if (isRegexParam || isStaticPart || isEndOfNode) { | |
| 3526 | + const paramName = pattern.slice(lastParamStartIndex, j); | |
| 3527 | + params3.push(paramName); | |
| 3528 | + isRegexNode = isRegexNode || isRegexParam || isStaticPart; | |
| 3529 | + if (isRegexParam) { | |
| 3530 | + const endOfRegexIndex = getClosingParenthensePosition(pattern, j); | |
| 3531 | + const regexString = pattern.slice(j, endOfRegexIndex + 1); | |
| 3532 | + regexps.push(trimRegExpStartAndEnd(regexString)); | |
| 3533 | + j = endOfRegexIndex + 1; | |
| 3534 | + } else { | |
| 3535 | + regexps.push("(.*?)"); | |
| 3536 | + } | |
| 3537 | + const staticPartStartIndex = j; | |
| 3538 | + for (; j < pattern.length; j++) { | |
| 3539 | + const charCode2 = pattern.charCodeAt(j); | |
| 3540 | + if (charCode2 === 47) break; | |
| 3541 | + if (charCode2 === 58) { | |
| 3542 | + const nextCharCode = pattern.charCodeAt(j + 1); | |
| 3543 | + if (nextCharCode === 58) j++; | |
| 3544 | + else break; | |
| 3545 | + } | |
| 3546 | + } | |
| 3547 | + let staticPart = pattern.slice(staticPartStartIndex, j); | |
| 3548 | + if (staticPart) { | |
| 3549 | + staticPart = staticPart.split("::").join(":"); | |
| 3550 | + staticPart = staticPart.split("%").join("%25"); | |
| 3551 | + regexps.push(escapeRegExp(staticPart)); | |
| 3552 | + } | |
| 3553 | + lastParamStartIndex = j + 1; | |
| 3554 | + if (isEndOfNode || pattern.charCodeAt(j) === 47 || j === pattern.length) { | |
| 3555 | + const nodePattern = isRegexNode ? "()" + staticPart : staticPart; | |
| 3556 | + const nodePath = pattern.slice(i, j); | |
| 3557 | + pattern = pattern.slice(0, i + 1) + nodePattern + pattern.slice(j); | |
| 3558 | + i += nodePattern.length; | |
| 3559 | + const regex = isRegexNode ? new RegExp("^" + regexps.join("") + "$") : void 0; | |
| 3560 | + currentNode = currentNode.createParametricChild(regex, staticPart, nodePath); | |
| 3561 | + parentNodePathIndex = i + 1; | |
| 3562 | + break; | |
| 3563 | + } | |
| 3564 | + } | |
| 3565 | + } | |
| 3566 | + } else if (isWildcardNode) { | |
| 3567 | + params3.push("*"); | |
| 3568 | + currentNode = currentNode.createWildcardChild(); | |
| 3569 | + parentNodePathIndex = i + 1; | |
| 3570 | + if (i !== pattern.length - 1) { | |
| 3571 | + throw new Error("Wildcard must be the last character in the route"); | |
| 3572 | + } | |
| 3573 | + } | |
| 3574 | + } | |
| 3575 | + if (!this.options.caseSensitive) { | |
| 3576 | + pattern = pattern.toLowerCase(); | |
| 3577 | + } | |
| 3578 | + if (pattern === "*") { | |
| 3579 | + pattern = "/*"; | |
| 3580 | + } | |
| 3581 | + for (const existRoute of this.routes) { | |
| 3582 | + if (existRoute.method === method && existRoute.pattern === pattern) { | |
| 3583 | + throw new Error(`Method '${method}' already declared for route '${pattern}'`); | |
| 3584 | + } | |
| 3585 | + } | |
| 3586 | + const route4 = { | |
| 3587 | + method, | |
| 3588 | + path, | |
| 3589 | + pattern, | |
| 3590 | + params: params3, | |
| 3591 | + handler: handler2 | |
| 3592 | + }; | |
| 3593 | + this.routes.push(route4); | |
| 3594 | + currentNode.addRoute(route4); | |
| 3595 | + } | |
| 3596 | + has(method, path) { | |
| 3597 | + const node = this.trees[method]; | |
| 3598 | + if (node === void 0) { | |
| 3599 | + return false; | |
| 3600 | + } | |
| 3601 | + const staticNode = node.getStaticChild(path); | |
| 3602 | + if (staticNode === void 0) { | |
| 3603 | + return false; | |
| 3604 | + } | |
| 3605 | + return staticNode.isLeafNode; | |
| 3606 | + } | |
| 3607 | + find(method, path) { | |
| 3608 | + let currentNode = this.trees[method]; | |
| 3609 | + if (currentNode === void 0) return void 0; | |
| 3610 | + if (path.charCodeAt(0) !== 47) { | |
| 3611 | + path = path.replace(FULL_PATH_REGEXP, "/"); | |
| 3612 | + } | |
| 3613 | + if (this.options.ignoreDuplicateSlashes) { | |
| 3614 | + path = removeDuplicateSlashes(path); | |
| 3615 | + } | |
| 3616 | + let sanitizedUrl; | |
| 3617 | + let querystring; | |
| 3618 | + let shouldDecodeParam; | |
| 3619 | + try { | |
| 3620 | + sanitizedUrl = safeDecodeURI(path); | |
| 3621 | + path = sanitizedUrl.path; | |
| 3622 | + querystring = sanitizedUrl.querystring; | |
| 3623 | + shouldDecodeParam = sanitizedUrl.shouldDecodeParam; | |
| 3624 | + } catch (error) { | |
| 3625 | + return void 0; | |
| 3626 | + } | |
| 3627 | + if (this.options.ignoreTrailingSlash) { | |
| 3628 | + path = trimLastSlash(path); | |
| 3629 | + } | |
| 3630 | + const originPath = path; | |
| 3631 | + if (this.options.caseSensitive === false) { | |
| 3632 | + path = path.toLowerCase(); | |
| 3633 | + } | |
| 3634 | + const maxParamLength = this.options.maxParamLength; | |
| 3635 | + let pathIndex = currentNode.prefix.length; | |
| 3636 | + const params3 = []; | |
| 3637 | + const pathLen = path.length; | |
| 3638 | + const brothersNodesStack = []; | |
| 3639 | + while (true) { | |
| 3640 | + if (pathIndex === pathLen && currentNode.isLeafNode) { | |
| 3641 | + const handle = currentNode.handlerStorage?.find(); | |
| 3642 | + if (handle !== void 0) { | |
| 3643 | + return { | |
| 3644 | + handler: handle.handler, | |
| 3645 | + params: handle.createParams(params3), | |
| 3646 | + searchParams: parse2(querystring) | |
| 3647 | + }; | |
| 3648 | + } | |
| 3649 | + } | |
| 3650 | + let node = currentNode.getNextNode(path, pathIndex, brothersNodesStack, params3.length); | |
| 3651 | + if (node === void 0) { | |
| 3652 | + if (brothersNodesStack.length === 0) { | |
| 3653 | + return void 0; | |
| 3654 | + } | |
| 3655 | + const brotherNodeState = brothersNodesStack.pop(); | |
| 3656 | + pathIndex = brotherNodeState.brotherPathIndex; | |
| 3657 | + params3.splice(brotherNodeState.paramsCount); | |
| 3658 | + node = brotherNodeState.brotherNode; | |
| 3659 | + } | |
| 3660 | + currentNode = node; | |
| 3661 | + if (currentNode._tag === "StaticNode") { | |
| 3662 | + pathIndex += currentNode.prefix.length; | |
| 3663 | + continue; | |
| 3664 | + } | |
| 3665 | + if (currentNode._tag === "WildcardNode") { | |
| 3666 | + let param = originPath.slice(pathIndex); | |
| 3667 | + if (shouldDecodeParam) { | |
| 3668 | + param = safeDecodeURIComponent(param); | |
| 3669 | + } | |
| 3670 | + params3.push(param); | |
| 3671 | + pathIndex = pathLen; | |
| 3672 | + continue; | |
| 3673 | + } | |
| 3674 | + if (currentNode._tag === "ParametricNode") { | |
| 3675 | + let paramEndIndex = originPath.indexOf("/", pathIndex); | |
| 3676 | + if (paramEndIndex === -1) { | |
| 3677 | + paramEndIndex = pathLen; | |
| 3678 | + } | |
| 3679 | + let param = originPath.slice(pathIndex, paramEndIndex); | |
| 3680 | + if (shouldDecodeParam) { | |
| 3681 | + param = safeDecodeURIComponent(param); | |
| 3682 | + } | |
| 3683 | + if (currentNode.regex !== void 0) { | |
| 3684 | + const matchedParameters = currentNode.regex.exec(param); | |
| 3685 | + if (matchedParameters === null) continue; | |
| 3686 | + for (let i = 1; i < matchedParameters.length; i++) { | |
| 3687 | + const matchedParam = matchedParameters[i]; | |
| 3688 | + if (matchedParam.length > maxParamLength) { | |
| 3689 | + return void 0; | |
| 3690 | + } | |
| 3691 | + params3.push(matchedParam); | |
| 3692 | + } | |
| 3693 | + } else { | |
| 3694 | + if (param.length > maxParamLength) { | |
| 3695 | + return void 0; | |
| 3696 | + } | |
| 3697 | + params3.push(param); | |
| 3698 | + } | |
| 3699 | + pathIndex = paramEndIndex; | |
| 3700 | + } | |
| 3701 | + } | |
| 3702 | + } | |
| 3703 | +}; | |
| 3704 | +var HandlerStorage = class { | |
| 3705 | + handlers = []; | |
| 3706 | + unconstrainedHandler; | |
| 3707 | + find() { | |
| 3708 | + return this.unconstrainedHandler; | |
| 3709 | + } | |
| 3710 | + add(route4) { | |
| 3711 | + const handler2 = { | |
| 3712 | + params: route4.params, | |
| 3713 | + handler: route4.handler, | |
| 3714 | + createParams: compileCreateParams(route4.params) | |
| 3715 | + }; | |
| 3716 | + this.handlers.push(handler2); | |
| 3717 | + this.unconstrainedHandler = this.handlers[0]; | |
| 3718 | + } | |
| 3719 | +}; | |
| 3720 | +var NodeBase = class { | |
| 3721 | + isLeafNode = false; | |
| 3722 | + routes; | |
| 3723 | + handlerStorage; | |
| 3724 | + addRoute(route4) { | |
| 3725 | + if (this.routes === void 0) { | |
| 3726 | + this.routes = [route4]; | |
| 3727 | + } else { | |
| 3728 | + this.routes.push(route4); | |
| 3729 | + } | |
| 3730 | + if (this.handlerStorage === void 0) { | |
| 3731 | + this.handlerStorage = new HandlerStorage(); | |
| 3732 | + } | |
| 3733 | + this.isLeafNode = true; | |
| 3734 | + this.handlerStorage.add(route4); | |
| 3735 | + } | |
| 3736 | +}; | |
| 3737 | +var ParentNode = class extends NodeBase { | |
| 3738 | + staticChildren = {}; | |
| 3739 | + findStaticMatchingChild(path, pathIndex) { | |
| 3740 | + const staticChild = this.staticChildren[path.charAt(pathIndex)]; | |
| 3741 | + if (staticChild === void 0 || !staticChild.matchPrefix(path, pathIndex)) { | |
| 3742 | + return void 0; | |
| 3743 | + } | |
| 3744 | + return staticChild; | |
| 3745 | + } | |
| 3746 | + getStaticChild(path, pathIndex = 0) { | |
| 3747 | + if (path.length === pathIndex) { | |
| 3748 | + return this; | |
| 3749 | + } | |
| 3750 | + const staticChild = this.findStaticMatchingChild(path, pathIndex); | |
| 3751 | + if (staticChild === void 0) { | |
| 3752 | + return void 0; | |
| 3753 | + } | |
| 3754 | + return staticChild.getStaticChild(path, pathIndex + staticChild.prefix.length); | |
| 3755 | + } | |
| 3756 | + createStaticChild(path) { | |
| 3757 | + if (path.length === 0) { | |
| 3758 | + return this; | |
| 3759 | + } | |
| 3760 | + let staticChild = this.staticChildren[path.charAt(0)]; | |
| 3761 | + if (staticChild) { | |
| 3762 | + let i = 1; | |
| 3763 | + for (; i < staticChild.prefix.length; i++) { | |
| 3764 | + if (path.charCodeAt(i) !== staticChild.prefix.charCodeAt(i)) { | |
| 3765 | + staticChild = staticChild.split(this, i); | |
| 3766 | + break; | |
| 3767 | + } | |
| 3768 | + } | |
| 3769 | + return staticChild.createStaticChild(path.slice(i)); | |
| 3770 | + } | |
| 3771 | + const label = path.charAt(0); | |
| 3772 | + this.staticChildren[label] = new StaticNode(path); | |
| 3773 | + return this.staticChildren[label]; | |
| 3774 | + } | |
| 3775 | +}; | |
| 3776 | +var StaticNode = class _StaticNode extends ParentNode { | |
| 3777 | + _tag = "StaticNode"; | |
| 3778 | + constructor(prefix) { | |
| 3779 | + super(); | |
| 3780 | + this.setPrefix(prefix); | |
| 3781 | + } | |
| 3782 | + prefix; | |
| 3783 | + matchPrefix; | |
| 3784 | + parametricChildren = []; | |
| 3785 | + wildcardChild; | |
| 3786 | + setPrefix(prefix) { | |
| 3787 | + this.prefix = prefix; | |
| 3788 | + if (prefix.length === 1) { | |
| 3789 | + this.matchPrefix = (_path, _pathIndex) => true; | |
| 3790 | + } else { | |
| 3791 | + const len = prefix.length; | |
| 3792 | + this.matchPrefix = function(path, pathIndex) { | |
| 3793 | + for (let i = 1; i < len; i++) { | |
| 3794 | + if (path.charCodeAt(pathIndex + i) !== this.prefix.charCodeAt(i)) { | |
| 3795 | + return false; | |
| 3796 | + } | |
| 3797 | + } | |
| 3798 | + return true; | |
| 3799 | + }; | |
| 3800 | + } | |
| 3801 | + } | |
| 3802 | + getParametricChild(regex) { | |
| 3803 | + if (regex === void 0) { | |
| 3804 | + return this.parametricChildren.find((child) => child.isRegex === false); | |
| 3805 | + } | |
| 3806 | + const source = regex.source; | |
| 3807 | + return this.parametricChildren.find((child) => { | |
| 3808 | + if (child.regex === void 0) { | |
| 3809 | + return false; | |
| 3810 | + } | |
| 3811 | + return child.regex.source === source; | |
| 3812 | + }); | |
| 3813 | + } | |
| 3814 | + createParametricChild(regex, staticSuffix, nodePath) { | |
| 3815 | + let child = this.getParametricChild(regex); | |
| 3816 | + if (child !== void 0) { | |
| 3817 | + child.nodePaths.add(nodePath); | |
| 3818 | + return child; | |
| 3819 | + } | |
| 3820 | + child = new ParametricNode(regex, staticSuffix, nodePath); | |
| 3821 | + this.parametricChildren.push(child); | |
| 3822 | + this.parametricChildren.sort((child1, child2) => { | |
| 3823 | + if (!child1.isRegex) return 1; | |
| 3824 | + if (!child2.isRegex) return -1; | |
| 3825 | + if (child1.staticSuffix === void 0) return 1; | |
| 3826 | + if (child2.staticSuffix === void 0) return -1; | |
| 3827 | + if (child2.staticSuffix.endsWith(child1.staticSuffix)) return 1; | |
| 3828 | + if (child1.staticSuffix.endsWith(child2.staticSuffix)) return -1; | |
| 3829 | + return 0; | |
| 3830 | + }); | |
| 3831 | + return child; | |
| 3832 | + } | |
| 3833 | + createWildcardChild() { | |
| 3834 | + if (this.wildcardChild === void 0) { | |
| 3835 | + this.wildcardChild = new WildcardNode(); | |
| 3836 | + } | |
| 3837 | + return this.wildcardChild; | |
| 3838 | + } | |
| 3839 | + split(parentNode, length) { | |
| 3840 | + const parentPrefix = this.prefix.slice(0, length); | |
| 3841 | + const childPrefix = this.prefix.slice(length); | |
| 3842 | + this.setPrefix(childPrefix); | |
| 3843 | + const staticNode = new _StaticNode(parentPrefix); | |
| 3844 | + staticNode.staticChildren[childPrefix.charAt(0)] = this; | |
| 3845 | + parentNode.staticChildren[parentPrefix.charAt(0)] = staticNode; | |
| 3846 | + return staticNode; | |
| 3847 | + } | |
| 3848 | + getNextNode(path, pathIndex, nodeStack, paramsCount) { | |
| 3849 | + let node = this.findStaticMatchingChild(path, pathIndex); | |
| 3850 | + let parametricBrotherNodeIndex = 0; | |
| 3851 | + if (node === void 0) { | |
| 3852 | + if (this.parametricChildren.length === 0) { | |
| 3853 | + return this.wildcardChild; | |
| 3854 | + } | |
| 3855 | + node = this.parametricChildren[0]; | |
| 3856 | + parametricBrotherNodeIndex = 1; | |
| 3857 | + } | |
| 3858 | + if (this.wildcardChild !== void 0) { | |
| 3859 | + nodeStack.push({ | |
| 3860 | + paramsCount, | |
| 3861 | + brotherPathIndex: pathIndex, | |
| 3862 | + brotherNode: this.wildcardChild | |
| 3863 | + }); | |
| 3864 | + } | |
| 3865 | + for (let i = this.parametricChildren.length - 1; i >= parametricBrotherNodeIndex; i--) { | |
| 3866 | + nodeStack.push({ | |
| 3867 | + paramsCount, | |
| 3868 | + brotherPathIndex: pathIndex, | |
| 3869 | + brotherNode: this.parametricChildren[i] | |
| 3870 | + }); | |
| 3871 | + } | |
| 3872 | + return node; | |
| 3873 | + } | |
| 3874 | +}; | |
| 3875 | +var ParametricNode = class extends ParentNode { | |
| 3876 | + regex; | |
| 3877 | + staticSuffix; | |
| 3878 | + _tag = "ParametricNode"; | |
| 3879 | + constructor(regex, staticSuffix, nodePath) { | |
| 3880 | + super(); | |
| 3881 | + this.regex = regex; | |
| 3882 | + this.staticSuffix = staticSuffix; | |
| 3883 | + this.isRegex = !!regex; | |
| 3884 | + this.nodePaths = /* @__PURE__ */ new Set([nodePath]); | |
| 3885 | + } | |
| 3886 | + isRegex; | |
| 3887 | + nodePaths; | |
| 3888 | + getNextNode(path, pathIndex) { | |
| 3889 | + return this.findStaticMatchingChild(path, pathIndex); | |
| 3890 | + } | |
| 3891 | +}; | |
| 3892 | +var WildcardNode = class extends NodeBase { | |
| 3893 | + _tag = "WildcardNode"; | |
| 3894 | + getNextNode(_path, _pathIndex, _nodeStack, _paramsCount) { | |
| 3895 | + return void 0; | |
| 3896 | + } | |
| 3897 | +}; | |
| 3898 | +var assert = (condition, message) => { | |
| 3899 | + if (!condition) { | |
| 3900 | + throw new Error(message); | |
| 3901 | + } | |
| 3902 | +}; | |
| 3903 | +function removeDuplicateSlashes(path) { | |
| 3904 | + return path.replace(/\/\/+/g, "/"); | |
| 3905 | +} | |
| 3906 | +function trimLastSlash(path) { | |
| 3907 | + if (path.length > 1 && path.charCodeAt(path.length - 1) === 47) { | |
| 3908 | + return path.slice(0, -1); | |
| 3909 | + } | |
| 3910 | + return path; | |
| 3911 | +} | |
| 3912 | +function compileCreateParams(params3) { | |
| 3913 | + const len = params3.length; | |
| 3914 | + return function(paramsArray) { | |
| 3915 | + const paramsObject = {}; | |
| 3916 | + for (let i = 0; i < len; i++) { | |
| 3917 | + paramsObject[params3[i]] = paramsArray[i]; | |
| 3918 | + } | |
| 3919 | + return paramsObject; | |
| 3920 | + }; | |
| 3921 | +} | |
| 3922 | +function getClosingParenthensePosition(path, idx) { | |
| 3923 | + let parentheses = 1; | |
| 3924 | + while (idx < path.length) { | |
| 3925 | + idx++; | |
| 3926 | + if (path[idx] === "\\") { | |
| 3927 | + idx++; | |
| 3928 | + continue; | |
| 3929 | + } | |
| 3930 | + if (path[idx] === ")") { | |
| 3931 | + parentheses--; | |
| 3932 | + } else if (path[idx] === "(") { | |
| 3933 | + parentheses++; | |
| 3934 | + } | |
| 3935 | + if (!parentheses) return idx; | |
| 3936 | + } | |
| 3937 | + throw new TypeError('Invalid regexp expression in "' + path + '"'); | |
| 3938 | +} | |
| 3939 | +function trimRegExpStartAndEnd(regexString) { | |
| 3940 | + if (regexString.charCodeAt(1) === 94) { | |
| 3941 | + regexString = regexString.slice(0, 1) + regexString.slice(2); | |
| 3942 | + } | |
| 3943 | + if (regexString.charCodeAt(regexString.length - 2) === 36) { | |
| 3944 | + regexString = regexString.slice(0, regexString.length - 2) + regexString.slice(regexString.length - 1); | |
| 3945 | + } | |
| 3946 | + return regexString; | |
| 3947 | +} | |
| 3948 | +function escapeRegExp(string3) { | |
| 3949 | + return string3.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); | |
| 3950 | +} | |
| 3951 | +function decodeComponentChar(highCharCode, lowCharCode) { | |
| 3952 | + if (highCharCode === 50) { | |
| 3953 | + if (lowCharCode === 53) return "%"; | |
| 3954 | + if (lowCharCode === 51) return "#"; | |
| 3955 | + if (lowCharCode === 52) return "$"; | |
| 3956 | + if (lowCharCode === 54) return "&"; | |
| 3957 | + if (lowCharCode === 66) return "+"; | |
| 3958 | + if (lowCharCode === 98) return "+"; | |
| 3959 | + if (lowCharCode === 67) return ","; | |
| 3960 | + if (lowCharCode === 99) return ","; | |
| 3961 | + if (lowCharCode === 70) return "/"; | |
| 3962 | + if (lowCharCode === 102) return "/"; | |
| 3963 | + return void 0; | |
| 3964 | + } | |
| 3965 | + if (highCharCode === 51) { | |
| 3966 | + if (lowCharCode === 65) return ":"; | |
| 3967 | + if (lowCharCode === 97) return ":"; | |
| 3968 | + if (lowCharCode === 66) return ";"; | |
| 3969 | + if (lowCharCode === 98) return ";"; | |
| 3970 | + if (lowCharCode === 68) return "="; | |
| 3971 | + if (lowCharCode === 100) return "="; | |
| 3972 | + if (lowCharCode === 70) return "?"; | |
| 3973 | + if (lowCharCode === 102) return "?"; | |
| 3974 | + return void 0; | |
| 3975 | + } | |
| 3976 | + if (highCharCode === 52 && lowCharCode === 48) { | |
| 3977 | + return "@"; | |
| 3978 | + } | |
| 3979 | + return void 0; | |
| 3980 | +} | |
| 3981 | +function safeDecodeURI(path) { | |
| 3982 | + let shouldDecode = false; | |
| 3983 | + let shouldDecodeParam = false; | |
| 3984 | + let querystring = ""; | |
| 3985 | + for (let i = 1; i < path.length; i++) { | |
| 3986 | + const charCode = path.charCodeAt(i); | |
| 3987 | + if (charCode === 37) { | |
| 3988 | + const highCharCode = path.charCodeAt(i + 1); | |
| 3989 | + const lowCharCode = path.charCodeAt(i + 2); | |
| 3990 | + if (decodeComponentChar(highCharCode, lowCharCode) === void 0) { | |
| 3991 | + shouldDecode = true; | |
| 3992 | + } else { | |
| 3993 | + shouldDecodeParam = true; | |
| 3994 | + if (highCharCode === 50 && lowCharCode === 53) { | |
| 3995 | + shouldDecode = true; | |
| 3996 | + path = path.slice(0, i + 1) + "25" + path.slice(i + 1); | |
| 3997 | + i += 2; | |
| 3998 | + } | |
| 3999 | + i += 2; | |
| 4000 | + } | |
| 4001 | + } else if (charCode === 63 || charCode === 59 || charCode === 35) { | |
| 4002 | + querystring = path.slice(i + 1); | |
| 4003 | + path = path.slice(0, i); | |
| 4004 | + break; | |
| 4005 | + } | |
| 4006 | + } | |
| 4007 | + const decodedPath = shouldDecode ? decodeURI(path) : path; | |
| 4008 | + return { | |
| 4009 | + path: decodedPath, | |
| 4010 | + querystring, | |
| 4011 | + shouldDecodeParam | |
| 4012 | + }; | |
| 4013 | +} | |
| 4014 | +function safeDecodeURIComponent(uriComponent) { | |
| 4015 | + const startIndex = uriComponent.indexOf("%"); | |
| 4016 | + if (startIndex === -1) return uriComponent; | |
| 4017 | + let decoded = ""; | |
| 4018 | + let lastIndex = startIndex; | |
| 4019 | + for (let i = startIndex; i < uriComponent.length; i++) { | |
| 4020 | + if (uriComponent.charCodeAt(i) === 37) { | |
| 4021 | + const highCharCode = uriComponent.charCodeAt(i + 1); | |
| 4022 | + const lowCharCode = uriComponent.charCodeAt(i + 2); | |
| 4023 | + const decodedChar = decodeComponentChar(highCharCode, lowCharCode); | |
| 4024 | + decoded += uriComponent.slice(lastIndex, i) + decodedChar; | |
| 4025 | + lastIndex = i + 3; | |
| 4026 | + } | |
| 4027 | + } | |
| 4028 | + return uriComponent.slice(0, startIndex) + decoded + uriComponent.slice(lastIndex); | |
| 4029 | +} | |
| 4030 | +var httpMethods = ["ACL", "BIND", "CHECKOUT", "CONNECT", "COPY", "DELETE", "GET", "HEAD", "LINK", "LOCK", "M-SEARCH", "MERGE", "MKACTIVITY", "MKCALENDAR", "MKCOL", "MOVE", "NOTIFY", "OPTIONS", "PATCH", "POST", "PROPFIND", "PROPPATCH", "PURGE", "PUT", "REBIND", "REPORT", "SEARCH", "SOURCE", "SUBSCRIBE", "TRACE", "UNBIND", "UNLINK", "UNLOCK", "UNSUBSCRIBE"]; | |
| 4031 | + | |
| 4032 | +// ../../node_modules/.bun/find-my-way-ts@0.1.6/node_modules/find-my-way-ts/dist/esm/index.js | |
| 4033 | +var make19 = make18; | |
| 4034 | + | |
| 4035 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServer.js | |
| 4036 | +var HttpServer_exports = {}; | |
| 4037 | +__export(HttpServer_exports, { | |
| 4038 | + HttpServer: () => HttpServer, | |
| 4039 | + TypeId: () => TypeId14, | |
| 4040 | + addressFormattedWith: () => addressFormattedWith2, | |
| 4041 | + addressWith: () => addressWith2, | |
| 4042 | + formatAddress: () => formatAddress2, | |
| 4043 | + layerContext: () => layerContext2, | |
| 4044 | + layerTestClient: () => layerTestClient2, | |
| 4045 | + logAddress: () => logAddress2, | |
| 4046 | + make: () => make22, | |
| 4047 | + serve: () => serve2, | |
| 4048 | + serveEffect: () => serveEffect2, | |
| 4049 | + withLogAddress: () => withLogAddress2 | |
| 4050 | +}); | |
| 4051 | + | |
| 4052 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpPlatform.js | |
| 4053 | +var TypeId12 = Symbol.for("@effect/platform/HttpPlatform"); | |
| 4054 | +var tag2 = GenericTag("@effect/platform/HttpPlatform"); | |
| 4055 | +var make20 = (impl) => gen(function* () { | |
| 4056 | + const fs = yield* FileSystem; | |
| 4057 | + const etagGen = yield* Generator; | |
| 4058 | + return tag2.of({ | |
| 4059 | + [TypeId12]: TypeId12, | |
| 4060 | + fileResponse(path, options4) { | |
| 4061 | + return pipe(bindTo(fs.stat(path), "info"), bind("etag", ({ | |
| 4062 | + info | |
| 4063 | + }) => etagGen.fromFileInfo(info)), map5(({ | |
| 4064 | + etag, | |
| 4065 | + info | |
| 4066 | + }) => { | |
| 4067 | + const start3 = Number(options4?.offset ?? 0); | |
| 4068 | + const end = options4?.bytesToRead !== void 0 ? start3 + Number(options4.bytesToRead) : void 0; | |
| 4069 | + const headers = set3(options4?.headers ? fromInput2(options4.headers) : empty10, "etag", toString3(etag)); | |
| 4070 | + if (info.mtime._tag === "Some") { | |
| 4071 | + ; | |
| 4072 | + headers["last-modified"] = info.mtime.value.toUTCString(); | |
| 4073 | + } | |
| 4074 | + const contentLength = end !== void 0 ? end - start3 : Number(info.size) - start3; | |
| 4075 | + return impl.fileResponse(path, options4?.status ?? 200, options4?.statusText, headers, start3, end, contentLength); | |
| 4076 | + })); | |
| 4077 | + }, | |
| 4078 | + fileWebResponse(file3, options4) { | |
| 4079 | + return map5(etagGen.fromFileWeb(file3), (etag) => { | |
| 4080 | + const headers = merge3(options4?.headers ? fromInput2(options4.headers) : empty10, unsafeFromRecord({ | |
| 4081 | + etag: toString3(etag), | |
| 4082 | + "last-modified": new Date(file3.lastModified).toUTCString() | |
| 4083 | + })); | |
| 4084 | + return impl.fileWebResponse(file3, options4?.status ?? 200, options4?.statusText, headers, options4); | |
| 4085 | + }); | |
| 4086 | + } | |
| 4087 | + }); | |
| 4088 | +}); | |
| 4089 | +var layer6 = effect(tag2, flatMap2(FileSystem, (fs) => make20({ | |
| 4090 | + fileResponse(path, status, statusText, headers, start3, end, contentLength) { | |
| 4091 | + return stream6(fs.stream(path, { | |
| 4092 | + offset: start3, | |
| 4093 | + bytesToRead: end !== void 0 ? end - start3 : void 0 | |
| 4094 | + }), { | |
| 4095 | + contentLength, | |
| 4096 | + headers, | |
| 4097 | + status, | |
| 4098 | + statusText | |
| 4099 | + }); | |
| 4100 | + }, | |
| 4101 | + fileWebResponse(file3, status, statusText, headers, _options) { | |
| 4102 | + return stream6(fromReadableStream(() => file3.stream(), identity), { | |
| 4103 | + headers, | |
| 4104 | + status, | |
| 4105 | + statusText | |
| 4106 | + }); | |
| 4107 | + } | |
| 4108 | +}))).pipe(provide2(layerWeak2)); | |
| 4109 | + | |
| 4110 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpServer.js | |
| 4111 | +var TypeId13 = Symbol.for("@effect/platform/HttpServer"); | |
| 4112 | +var serverTag = GenericTag("@effect/platform/HttpServer"); | |
| 4113 | +var serverProto = { | |
| 4114 | + [TypeId13]: TypeId13 | |
| 4115 | +}; | |
| 4116 | +var make21 = (options4) => Object.assign(Object.create(serverProto), options4); | |
| 4117 | +var serve = dual((args) => isEffect(args[0]), (httpApp2, middleware3) => scopedDiscard(flatMap2(serverTag, (server) => server.serve(httpApp2, middleware3)))); | |
| 4118 | +var serveEffect = dual((args) => isEffect(args[0]), (httpApp2, middleware3) => flatMap2(serverTag, (server) => server.serve(httpApp2, middleware3))); | |
| 4119 | +var formatAddress = (address) => { | |
| 4120 | + switch (address._tag) { | |
| 4121 | + case "UnixAddress": | |
| 4122 | + return `unix://${address.path}`; | |
| 4123 | + case "TcpAddress": | |
| 4124 | + return `http://${address.hostname}:${address.port}`; | |
| 4125 | + } | |
| 4126 | +}; | |
| 4127 | +var addressWith = (effect2) => flatMap2(serverTag, (server) => effect2(server.address)); | |
| 4128 | +var addressFormattedWith = (effect2) => flatMap2(serverTag, (server) => effect2(formatAddress(server.address))); | |
| 4129 | +var logAddress = addressFormattedWith((_) => log(`Listening on ${_}`)); | |
| 4130 | +var withLogAddress = (layer13) => effectDiscard(logAddress).pipe(provideMerge(layer13)); | |
| 4131 | +var makeTestClient = addressWith((address) => flatMap2(HttpClient, (client) => { | |
| 4132 | + if (address._tag === "UnixAddress") { | |
| 4133 | + return die2(new Error("HttpServer.layerTestClient: UnixAddress not supported")); | |
| 4134 | + } | |
| 4135 | + const host = address.hostname === "0.0.0.0" ? "127.0.0.1" : address.hostname; | |
| 4136 | + const url = `http://${host}:${address.port}`; | |
| 4137 | + return succeed(mapRequest(client, prependUrl(url))); | |
| 4138 | +})); | |
| 4139 | +var layerTestClient = effect(HttpClient, makeTestClient); | |
| 4140 | +var layerContext = mergeAll(layer6, layer, layerWeak).pipe(provideMerge(layerNoop({}))); | |
| 4141 | + | |
| 4142 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpServer.js | |
| 4143 | +var TypeId14 = TypeId13; | |
| 4144 | +var HttpServer = serverTag; | |
| 4145 | +var make22 = make21; | |
| 4146 | +var serve2 = serve; | |
| 4147 | +var serveEffect2 = serveEffect; | |
| 4148 | +var formatAddress2 = formatAddress; | |
| 4149 | +var addressWith2 = addressWith; | |
| 4150 | +var addressFormattedWith2 = addressFormattedWith; | |
| 4151 | +var logAddress2 = logAddress; | |
| 4152 | +var withLogAddress2 = withLogAddress; | |
| 4153 | +var layerTestClient2 = layerTestClient; | |
| 4154 | +var layerContext2 = layerContext; | |
| 4155 | + | |
| 4156 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/internal/httpRouter.js | |
| 4157 | +var TypeId15 = Symbol.for("@effect/platform/HttpRouter"); | |
| 4158 | +var RouteTypeId = Symbol.for("@effect/platform/HttpRouter/Route"); | |
| 4159 | +var RouteContextTypeId = Symbol.for("@effect/platform/HttpRouter/RouteContext"); | |
| 4160 | +var RouteContext = GenericTag("@effect/platform/HttpRouter/RouteContext"); | |
| 4161 | +var isRouter = (u) => hasProperty(u, TypeId15); | |
| 4162 | +var params = map5(RouteContext, (_) => _.params); | |
| 4163 | +var schemaJson5 = (schema2, options4) => { | |
| 4164 | + const parse3 = decodeUnknown(schema2, options4); | |
| 4165 | + return flatMap2(context(), (context2) => { | |
| 4166 | + const request = get(context2, HttpServerRequest); | |
| 4167 | + const searchParams = get(context2, ParsedSearchParams); | |
| 4168 | + const routeContext = get(context2, RouteContext); | |
| 4169 | + return flatMap2(request.json, (body) => parse3({ | |
| 4170 | + method: request.method, | |
| 4171 | + url: request.url, | |
| 4172 | + headers: request.headers, | |
| 4173 | + cookies: request.cookies, | |
| 4174 | + pathParams: routeContext.params, | |
| 4175 | + searchParams, | |
| 4176 | + body | |
| 4177 | + })); | |
| 4178 | + }); | |
| 4179 | +}; | |
| 4180 | +var schemaNoBody = (schema2, options4) => { | |
| 4181 | + const parse3 = decodeUnknown(schema2, options4); | |
| 4182 | + return flatMap2(context(), (context2) => { | |
| 4183 | + const request = get(context2, HttpServerRequest); | |
| 4184 | + const searchParams = get(context2, ParsedSearchParams); | |
| 4185 | + const routeContext = get(context2, RouteContext); | |
| 4186 | + return parse3({ | |
| 4187 | + method: request.method, | |
| 4188 | + url: request.url, | |
| 4189 | + headers: request.headers, | |
| 4190 | + cookies: request.cookies, | |
| 4191 | + pathParams: routeContext.params, | |
| 4192 | + searchParams | |
| 4193 | + }); | |
| 4194 | + }); | |
| 4195 | +}; | |
| 4196 | +var schemaParams = (schema2, options4) => { | |
| 4197 | + const parse3 = decodeUnknown(schema2, options4); | |
| 4198 | + return flatMap2(context(), (context2) => { | |
| 4199 | + const searchParams = get(context2, ParsedSearchParams); | |
| 4200 | + const routeContext = get(context2, RouteContext); | |
| 4201 | + return parse3({ | |
| 4202 | + ...searchParams, | |
| 4203 | + ...routeContext.params | |
| 4204 | + }); | |
| 4205 | + }); | |
| 4206 | +}; | |
| 4207 | +var schemaPathParams = (schema2, options4) => { | |
| 4208 | + const parse3 = decodeUnknown(schema2, options4); | |
| 4209 | + return flatMap2(RouteContext, (_) => parse3(_.params)); | |
| 4210 | +}; | |
| 4211 | +var currentRouterConfig = globalValue("@effect/platform/HttpRouter/currentRouterConfig", () => unsafeMake3({})); | |
| 4212 | +var withRouterConfig = dual(2, (effect2, config) => locally(effect2, currentRouterConfig, config)); | |
| 4213 | +var setRouterConfig = (config) => locallyScoped(currentRouterConfig, config); | |
| 4214 | +var RouterImpl2 = class extends StructuralClass { | |
| 4215 | + routes; | |
| 4216 | + mounts; | |
| 4217 | + [TypeId15]; | |
| 4218 | + constructor(routes, mounts) { | |
| 4219 | + super(); | |
| 4220 | + this.routes = routes; | |
| 4221 | + this.mounts = mounts; | |
| 4222 | + this[TypeId15] = TypeId15; | |
| 4223 | + this.httpApp = toHttpApp(this).pipe(flatMap2((app) => this.httpApp = app)); | |
| 4224 | + } | |
| 4225 | + httpApp; | |
| 4226 | + commit() { | |
| 4227 | + return this.httpApp; | |
| 4228 | + } | |
| 4229 | + toJSON() { | |
| 4230 | + return { | |
| 4231 | + _id: "Router", | |
| 4232 | + routes: this.routes.toJSON(), | |
| 4233 | + mounts: this.mounts.toJSON() | |
| 4234 | + }; | |
| 4235 | + } | |
| 4236 | + toString() { | |
| 4237 | + return format(this); | |
| 4238 | + } | |
| 4239 | + [NodeInspectSymbol]() { | |
| 4240 | + return this.toJSON(); | |
| 4241 | + } | |
| 4242 | +}; | |
| 4243 | +var toHttpApp = (self) => map5(get2(currentRouterConfig), (config) => { | |
| 4244 | + const router = make19(config); | |
| 4245 | + const mounts = toReadonlyArray(self.mounts).map(([path, app, options4]) => [path, new RouteContextImpl(new RouteImpl("*", options4?.includePrefix ? `${path}/*` : "/*", app, options4?.includePrefix ? none() : some(path), false), {}), options4]); | |
| 4246 | + const mountsLen = mounts.length; | |
| 4247 | + forEach(self.routes, (route4) => { | |
| 4248 | + if (route4.method === "*") { | |
| 4249 | + router.all(route4.path, route4); | |
| 4250 | + } else { | |
| 4251 | + router.on(route4.method, route4.path, route4); | |
| 4252 | + } | |
| 4253 | + }); | |
| 4254 | + return withFiberRuntime((fiber) => { | |
| 4255 | + const context2 = unsafeMake(new Map(fiber.getFiberRef(currentContext).unsafeMap)); | |
| 4256 | + const request = unsafeGet(context2, HttpServerRequest); | |
| 4257 | + if (mountsLen > 0) { | |
| 4258 | + const searchIndex = request.url.indexOf("?"); | |
| 4259 | + const pathname = searchIndex === -1 ? request.url : request.url.slice(0, searchIndex); | |
| 4260 | + for (let i = 0; i < mountsLen; i++) { | |
| 4261 | + const [path, routeContext, options4] = mounts[i]; | |
| 4262 | + if (pathname === path || pathname.startsWith(path + "/")) { | |
| 4263 | + context2.unsafeMap.set(RouteContext.key, routeContext); | |
| 4264 | + if (options4?.includePrefix !== true) { | |
| 4265 | + context2.unsafeMap.set(HttpServerRequest.key, sliceRequestUrl(request, path)); | |
| 4266 | + } | |
| 4267 | + return locally(flatMap2(routeContext.route.handler, toResponse), currentContext, context2); | |
| 4268 | + } | |
| 4269 | + } | |
| 4270 | + } | |
| 4271 | + let result = router.find(request.method, request.url); | |
| 4272 | + if (result === void 0 && request.method === "HEAD") { | |
| 4273 | + result = router.find("GET", request.url); | |
| 4274 | + } | |
| 4275 | + if (result === void 0) { | |
| 4276 | + return fail3(new RouteNotFound({ | |
| 4277 | + request | |
| 4278 | + })); | |
| 4279 | + } | |
| 4280 | + const route4 = result.handler; | |
| 4281 | + if (route4.prefix._tag === "Some") { | |
| 4282 | + context2.unsafeMap.set(HttpServerRequest.key, sliceRequestUrl(request, route4.prefix.value)); | |
| 4283 | + } | |
| 4284 | + context2.unsafeMap.set(ParsedSearchParams.key, result.searchParams); | |
| 4285 | + context2.unsafeMap.set(RouteContext.key, new RouteContextImpl(route4, result.params)); | |
| 4286 | + const span = getOption(context2, ParentSpan); | |
| 4287 | + if (span._tag === "Some" && span.value._tag === "Span") { | |
| 4288 | + span.value.attribute("http.route", route4.path); | |
| 4289 | + } | |
| 4290 | + const handlerResponse = flatMap2(route4.handler, toResponse); | |
| 4291 | + return locally(route4.uninterruptible ? handlerResponse : interruptible(handlerResponse), currentContext, context2); | |
| 4292 | + }); | |
| 4293 | +}); | |
| 4294 | +function sliceRequestUrl(request, prefix) { | |
| 4295 | + const prefexLen = prefix.length; | |
| 4296 | + return request.modify({ | |
| 4297 | + url: request.url.length <= prefexLen ? "/" : request.url.slice(prefexLen) | |
| 4298 | + }); | |
| 4299 | +} | |
| 4300 | +var RouteImpl = class extends Class { | |
| 4301 | + method; | |
| 4302 | + path; | |
| 4303 | + handler; | |
| 4304 | + prefix; | |
| 4305 | + uninterruptible; | |
| 4306 | + [RouteTypeId]; | |
| 4307 | + constructor(method, path, handler2, prefix = none(), uninterruptible2 = false) { | |
| 4308 | + super(); | |
| 4309 | + this.method = method; | |
| 4310 | + this.path = path; | |
| 4311 | + this.handler = handler2; | |
| 4312 | + this.prefix = prefix; | |
| 4313 | + this.uninterruptible = uninterruptible2; | |
| 4314 | + this[RouteTypeId] = RouteTypeId; | |
| 4315 | + } | |
| 4316 | + toJSON() { | |
| 4317 | + return { | |
| 4318 | + _id: "@effect/platform/HttpRouter/Route", | |
| 4319 | + method: this.method, | |
| 4320 | + path: this.path, | |
| 4321 | + prefix: this.prefix.toJSON() | |
| 4322 | + }; | |
| 4323 | + } | |
| 4324 | +}; | |
| 4325 | +var RouteContextImpl = class { | |
| 4326 | + route; | |
| 4327 | + params; | |
| 4328 | + [RouteContextTypeId]; | |
| 4329 | + constructor(route4, params3) { | |
| 4330 | + this.route = route4; | |
| 4331 | + this.params = params3; | |
| 4332 | + this[RouteContextTypeId] = RouteContextTypeId; | |
| 4333 | + } | |
| 4334 | +}; | |
| 4335 | +var empty14 = new RouterImpl2(empty3(), empty3()); | |
| 4336 | +var fromIterable6 = (routes) => new RouterImpl2(fromIterable2(routes), empty3()); | |
| 4337 | +var makeRoute = (method, path, handler2, options4) => new RouteImpl(method, path, handler2, options4?.prefix ? some(options4.prefix) : none(), options4?.uninterruptible ?? false); | |
| 4338 | +var append2 = dual(2, (self, route4) => new RouterImpl2(append(self.routes, route4), self.mounts)); | |
| 4339 | +var concat = dual(2, (self, that) => concatAll(self, that)); | |
| 4340 | +var concatAll = (...routers) => new RouterImpl2(routers.reduce((cur, acc) => appendAll(cur, acc.routes), empty3()), routers.reduce((cur, acc) => appendAll(cur, acc.mounts), empty3())); | |
| 4341 | +var removeTrailingSlash = (path) => path.endsWith("/") ? path.slice(0, -1) : path; | |
| 4342 | +var prefixPath = dual(2, (self, prefix) => { | |
| 4343 | + prefix = removeTrailingSlash(prefix); | |
| 4344 | + return self === "/" ? prefix : prefix + self; | |
| 4345 | +}); | |
| 4346 | +var prefixAll = dual(2, (self, prefix) => { | |
| 4347 | + prefix = removeTrailingSlash(prefix); | |
| 4348 | + return new RouterImpl2(map4(self.routes, (route4) => new RouteImpl(route4.method, route4.path === "/" ? prefix : prefix + route4.path, route4.handler, orElse(map2(route4.prefix, (_) => prefix + _), () => some(prefix)), route4.uninterruptible)), map4(self.mounts, ([path, app]) => [path === "/" ? prefix : prefix + path, app])); | |
| 4349 | +}); | |
| 4350 | +var mount = dual(3, (self, path, that) => concat(self, prefixAll(that, path))); | |
| 4351 | +var mountApp = dual((args) => hasProperty(args[0], TypeId15), (self, path, that, options4) => new RouterImpl2(self.routes, append(self.mounts, [removeTrailingSlash(path), that, options4]))); | |
| 4352 | +var route = (method) => dual((args) => isRouter(args[0]), (self, path, handler2, options4) => new RouterImpl2(append(self.routes, new RouteImpl(method, path, handler2, none(), options4?.uninterruptible ?? false)), self.mounts)); | |
| 4353 | +var all2 = route("*"); | |
| 4354 | +var get3 = route("GET"); | |
| 4355 | +var post = route("POST"); | |
| 4356 | +var put = route("PUT"); | |
| 4357 | +var patch = route("PATCH"); | |
| 4358 | +var del = route("DELETE"); | |
| 4359 | +var head = route("HEAD"); | |
| 4360 | +var options = route("OPTIONS"); | |
| 4361 | +var use = dual(2, (self, f) => new RouterImpl2(map4(self.routes, (route4) => new RouteImpl(route4.method, route4.path, f(flatMap2(route4.handler, toResponse)), route4.prefix, route4.uninterruptible)), map4(self.mounts, ([path, app]) => [path, f(app)]))); | |
| 4362 | +var transform2 = dual(2, (self, f) => new RouterImpl2(map4(self.routes, (route4) => new RouteImpl(route4.method, route4.path, f(route4.handler), route4.prefix, route4.uninterruptible)), map4(self.mounts, ([path, app]) => [path, flatMap2(f(app), toResponse)]))); | |
| 4363 | +var catchAll2 = dual(2, (self, f) => transform2(self, catchAll(f))); | |
| 4364 | +var catchAllCause2 = dual(2, (self, f) => transform2(self, catchAllCause(f))); | |
| 4365 | +var catchTag2 = dual(3, (self, k, f) => transform2(self, catchTag(k, f))); | |
| 4366 | +var catchTags2 = dual(2, (self, cases) => use(self, catchTags(cases))); | |
| 4367 | +var provideService2 = dual(3, (self, tag4, service) => use(self, provideService(tag4, service))); | |
| 4368 | +var provideServiceEffect2 = dual(3, (self, tag4, effect2) => use(self, provideServiceEffect(tag4, effect2))); | |
| 4369 | +var makeService = () => { | |
| 4370 | + let router = empty14; | |
| 4371 | + return { | |
| 4372 | + addRoute(route4) { | |
| 4373 | + return sync(() => { | |
| 4374 | + router = append2(router, route4); | |
| 4375 | + }); | |
| 4376 | + }, | |
| 4377 | + all(path, handler2, options4) { | |
| 4378 | + return sync(() => { | |
| 4379 | + router = all2(router, path, handler2, options4); | |
| 4380 | + }); | |
| 4381 | + }, | |
| 4382 | + get(path, handler2, options4) { | |
| 4383 | + return sync(() => { | |
| 4384 | + router = get3(router, path, handler2, options4); | |
| 4385 | + }); | |
| 4386 | + }, | |
| 4387 | + post(path, handler2, options4) { | |
| 4388 | + return sync(() => { | |
| 4389 | + router = post(router, path, handler2, options4); | |
| 4390 | + }); | |
| 4391 | + }, | |
| 4392 | + put(path, handler2, options4) { | |
| 4393 | + return sync(() => { | |
| 4394 | + router = put(router, path, handler2, options4); | |
| 4395 | + }); | |
| 4396 | + }, | |
| 4397 | + patch(path, handler2, options4) { | |
| 4398 | + return sync(() => { | |
| 4399 | + router = patch(router, path, handler2, options4); | |
| 4400 | + }); | |
| 4401 | + }, | |
| 4402 | + del(path, handler2, options4) { | |
| 4403 | + return sync(() => { | |
| 4404 | + router = del(router, path, handler2, options4); | |
| 4405 | + }); | |
| 4406 | + }, | |
| 4407 | + head(path, handler2, options4) { | |
| 4408 | + return sync(() => { | |
| 4409 | + router = head(router, path, handler2, options4); | |
| 4410 | + }); | |
| 4411 | + }, | |
| 4412 | + options(path, handler2, opts) { | |
| 4413 | + return sync(() => { | |
| 4414 | + router = options(router, path, handler2, opts); | |
| 4415 | + }); | |
| 4416 | + }, | |
| 4417 | + router: sync(() => router), | |
| 4418 | + mount(path, that) { | |
| 4419 | + return sync(() => { | |
| 4420 | + router = mount(router, path, that); | |
| 4421 | + }); | |
| 4422 | + }, | |
| 4423 | + mountApp(path, app, options4) { | |
| 4424 | + return sync(() => { | |
| 4425 | + router = mountApp(router, path, app, options4); | |
| 4426 | + }); | |
| 4427 | + }, | |
| 4428 | + concat(that) { | |
| 4429 | + return sync(() => { | |
| 4430 | + router = concat(router, that); | |
| 4431 | + }); | |
| 4432 | + } | |
| 4433 | + }; | |
| 4434 | +}; | |
| 4435 | +var Tag3 = (id) => () => { | |
| 4436 | + const Err = globalThis.Error; | |
| 4437 | + const limit = Err.stackTraceLimit; | |
| 4438 | + Err.stackTraceLimit = 2; | |
| 4439 | + const creationError = new Err(); | |
| 4440 | + Err.stackTraceLimit = limit; | |
| 4441 | + function TagClass() { | |
| 4442 | + } | |
| 4443 | + const TagClass_ = TagClass; | |
| 4444 | + Object.setPrototypeOf(TagClass, Object.getPrototypeOf(GenericTag(id))); | |
| 4445 | + TagClass.key = id; | |
| 4446 | + Object.defineProperty(TagClass, "stack", { | |
| 4447 | + get() { | |
| 4448 | + return creationError.stack; | |
| 4449 | + } | |
| 4450 | + }); | |
| 4451 | + TagClass_.Live = sync2(TagClass_, makeService); | |
| 4452 | + TagClass_.router = flatMap2(TagClass_, (_) => _.router); | |
| 4453 | + TagClass_.use = (f) => TagClass_.pipe(flatMap2(f), scopedDiscard, provide2(TagClass_.Live)); | |
| 4454 | + TagClass_.unwrap = (f) => TagClass_.pipe(flatMap2((_) => _.router), map5(f), unwrapEffect, provide2(TagClass_.Live)); | |
| 4455 | + TagClass_.serve = (middleware3) => TagClass_.unwrap(serve2(middleware3)); | |
| 4456 | + return TagClass; | |
| 4457 | +}; | |
| 4458 | + | |
| 4459 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpRouter.js | |
| 4460 | +var TypeId16 = TypeId15; | |
| 4461 | +var RouteTypeId2 = RouteTypeId; | |
| 4462 | +var RouteContextTypeId2 = RouteContextTypeId; | |
| 4463 | +var RouteContext2 = RouteContext; | |
| 4464 | +var params2 = params; | |
| 4465 | +var schemaJson6 = schemaJson5; | |
| 4466 | +var schemaNoBody2 = schemaNoBody; | |
| 4467 | +var schemaParams2 = schemaParams; | |
| 4468 | +var schemaPathParams2 = schemaPathParams; | |
| 4469 | +var currentRouterConfig2 = currentRouterConfig; | |
| 4470 | +var withRouterConfig2 = withRouterConfig; | |
| 4471 | +var setRouterConfig2 = setRouterConfig; | |
| 4472 | +var empty15 = empty14; | |
| 4473 | +var fromIterable7 = fromIterable6; | |
| 4474 | +var makeRoute2 = makeRoute; | |
| 4475 | +var prefixPath2 = prefixPath; | |
| 4476 | +var prefixAll2 = prefixAll; | |
| 4477 | +var append3 = append2; | |
| 4478 | +var concat2 = concat; | |
| 4479 | +var concatAll2 = concatAll; | |
| 4480 | +var mount2 = mount; | |
| 4481 | +var mountApp2 = mountApp; | |
| 4482 | +var route2 = route; | |
| 4483 | +var all3 = all2; | |
| 4484 | +var get4 = get3; | |
| 4485 | +var post2 = post; | |
| 4486 | +var patch2 = patch; | |
| 4487 | +var put2 = put; | |
| 4488 | +var del2 = del; | |
| 4489 | +var head2 = head; | |
| 4490 | +var options2 = options; | |
| 4491 | +var use2 = use; | |
| 4492 | +var transform3 = transform2; | |
| 4493 | +var catchAll3 = catchAll2; | |
| 4494 | +var catchAllCause3 = catchAllCause2; | |
| 4495 | +var catchTag3 = catchTag2; | |
| 4496 | +var catchTags3 = catchTags2; | |
| 4497 | +var provideService3 = provideService2; | |
| 4498 | +var provideServiceEffect3 = provideServiceEffect2; | |
| 4499 | +var Tag4 = Tag3; | |
| 4500 | +var Default = class extends Tag4("@effect/platform/HttpRouter/Default")() { | |
| 4501 | +}; | |
| 4502 | +var toHttpApp2 = toHttpApp; | |
| 4503 | + | |
| 4504 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/OpenApi.js | |
| 4505 | +var OpenApi_exports = {}; | |
| 4506 | +__export(OpenApi_exports, { | |
| 4507 | + Deprecated: () => Deprecated, | |
| 4508 | + Description: () => Description, | |
| 4509 | + Exclude: () => Exclude, | |
| 4510 | + ExternalDocs: () => ExternalDocs, | |
| 4511 | + Format: () => Format, | |
| 4512 | + Identifier: () => Identifier, | |
| 4513 | + License: () => License, | |
| 4514 | + Override: () => Override, | |
| 4515 | + Servers: () => Servers, | |
| 4516 | + Summary: () => Summary, | |
| 4517 | + Title: () => Title, | |
| 4518 | + Transform: () => Transform, | |
| 4519 | + Version: () => Version, | |
| 4520 | + annotations: () => annotations2, | |
| 4521 | + fromApi: () => fromApi | |
| 4522 | +}); | |
| 4523 | + | |
| 4524 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/OpenApiJsonSchema.js | |
| 4525 | +var OpenApiJsonSchema_exports = {}; | |
| 4526 | +__export(OpenApiJsonSchema_exports, { | |
| 4527 | + fromAST: () => fromAST2, | |
| 4528 | + make: () => make23, | |
| 4529 | + makeWithDefs: () => makeWithDefs | |
| 4530 | +}); | |
| 4531 | +var make23 = (schema2) => { | |
| 4532 | + const defs = {}; | |
| 4533 | + const out = makeWithDefs(schema2, { | |
| 4534 | + defs | |
| 4535 | + }); | |
| 4536 | + if (!isEmptyRecord(defs)) { | |
| 4537 | + out.$defs = defs; | |
| 4538 | + } | |
| 4539 | + return out; | |
| 4540 | +}; | |
| 4541 | +var makeWithDefs = (schema2, options4) => fromAST2(schema2.ast, options4); | |
| 4542 | +var fromAST2 = (ast, options4) => { | |
| 4543 | + const jsonSchema2 = fromAST(ast, { | |
| 4544 | + definitions: options4.defs, | |
| 4545 | + definitionPath: options4.defsPath ?? "#/components/schemas/", | |
| 4546 | + target: "openApi3.1", | |
| 4547 | + topLevelReferenceStrategy: options4.topLevelReferenceStrategy, | |
| 4548 | + additionalPropertiesStrategy: options4.additionalPropertiesStrategy | |
| 4549 | + }); | |
| 4550 | + return jsonSchema2; | |
| 4551 | +}; | |
| 4552 | + | |
| 4553 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/OpenApi.js | |
| 4554 | +var Identifier = class extends Tag("@effect/platform/OpenApi/Identifier")() { | |
| 4555 | +}; | |
| 4556 | +var Title = class extends Tag("@effect/platform/OpenApi/Title")() { | |
| 4557 | +}; | |
| 4558 | +var Version = class extends Tag("@effect/platform/OpenApi/Version")() { | |
| 4559 | +}; | |
| 4560 | +var Description = class extends Tag("@effect/platform/OpenApi/Description")() { | |
| 4561 | +}; | |
| 4562 | +var License = class extends Tag("@effect/platform/OpenApi/License")() { | |
| 4563 | +}; | |
| 4564 | +var ExternalDocs = class extends Tag("@effect/platform/OpenApi/ExternalDocs")() { | |
| 4565 | +}; | |
| 4566 | +var Servers = class extends Tag("@effect/platform/OpenApi/Servers")() { | |
| 4567 | +}; | |
| 4568 | +var Format = class extends Tag("@effect/platform/OpenApi/Format")() { | |
| 4569 | +}; | |
| 4570 | +var Summary = class extends Tag("@effect/platform/OpenApi/Summary")() { | |
| 4571 | +}; | |
| 4572 | +var Deprecated = class extends Tag("@effect/platform/OpenApi/Deprecated")() { | |
| 4573 | +}; | |
| 4574 | +var Override = class extends Tag("@effect/platform/OpenApi/Override")() { | |
| 4575 | +}; | |
| 4576 | +var Exclude = class extends Reference()("@effect/platform/OpenApi/Exclude", { | |
| 4577 | + defaultValue: constFalse | |
| 4578 | +}) { | |
| 4579 | +}; | |
| 4580 | +var Transform = class extends Tag("@effect/platform/OpenApi/Transform")() { | |
| 4581 | +}; | |
| 4582 | +var contextPartial = (tags) => { | |
| 4583 | + const entries = Object.entries(tags); | |
| 4584 | + return (options4) => { | |
| 4585 | + let context2 = empty4(); | |
| 4586 | + for (const [key, tag4] of entries) { | |
| 4587 | + if (options4[key] !== void 0) { | |
| 4588 | + context2 = add(context2, tag4, options4[key]); | |
| 4589 | + } | |
| 4590 | + } | |
| 4591 | + return context2; | |
| 4592 | + }; | |
| 4593 | +}; | |
| 4594 | +var annotations2 = contextPartial({ | |
| 4595 | + identifier: Identifier, | |
| 4596 | + title: Title, | |
| 4597 | + version: Version, | |
| 4598 | + description: Description, | |
| 4599 | + license: License, | |
| 4600 | + summary: Summary, | |
| 4601 | + deprecated: Deprecated, | |
| 4602 | + externalDocs: ExternalDocs, | |
| 4603 | + servers: Servers, | |
| 4604 | + format: Format, | |
| 4605 | + override: Override, | |
| 4606 | + exclude: Exclude, | |
| 4607 | + transform: Transform | |
| 4608 | +}); | |
| 4609 | +var apiCache = globalValue("@effect/platform/OpenApi/apiCache", () => /* @__PURE__ */ new WeakMap()); | |
| 4610 | +function processAnnotation(ctx, tag4, f) { | |
| 4611 | + const o = getOption(ctx, tag4); | |
| 4612 | + if (isSome(o)) { | |
| 4613 | + f(o.value); | |
| 4614 | + } | |
| 4615 | +} | |
| 4616 | +var fromApi = (api2, options4) => { | |
| 4617 | + const cached2 = apiCache.get(api2); | |
| 4618 | + if (cached2 !== void 0) { | |
| 4619 | + return cached2; | |
| 4620 | + } | |
| 4621 | + const jsonSchemaDefs = {}; | |
| 4622 | + let spec = { | |
| 4623 | + openapi: "3.1.0", | |
| 4624 | + info: { | |
| 4625 | + title: getOrElse2(api2.annotations, Title, () => "Api"), | |
| 4626 | + version: getOrElse2(api2.annotations, Version, () => "0.0.1") | |
| 4627 | + }, | |
| 4628 | + paths: {}, | |
| 4629 | + components: { | |
| 4630 | + schemas: jsonSchemaDefs, | |
| 4631 | + securitySchemes: {} | |
| 4632 | + }, | |
| 4633 | + security: [], | |
| 4634 | + tags: [] | |
| 4635 | + }; | |
| 4636 | + function processAST(ast) { | |
| 4637 | + return fromAST2(ast, { | |
| 4638 | + defs: jsonSchemaDefs, | |
| 4639 | + additionalPropertiesStrategy: options4?.additionalPropertiesStrategy | |
| 4640 | + }); | |
| 4641 | + } | |
| 4642 | + function processHttpApiSecurity(name, security) { | |
| 4643 | + if (spec.components.securitySchemes[name] !== void 0) { | |
| 4644 | + return; | |
| 4645 | + } | |
| 4646 | + spec.components.securitySchemes[name] = makeSecurityScheme(security); | |
| 4647 | + } | |
| 4648 | + processAnnotation(api2.annotations, AdditionalSchemas, (componentSchemas) => { | |
| 4649 | + componentSchemas.forEach((componentSchema) => processAST(componentSchema.ast)); | |
| 4650 | + }); | |
| 4651 | + processAnnotation(api2.annotations, Description, (description) => { | |
| 4652 | + spec.info.description = description; | |
| 4653 | + }); | |
| 4654 | + processAnnotation(api2.annotations, License, (license) => { | |
| 4655 | + spec.info.license = license; | |
| 4656 | + }); | |
| 4657 | + processAnnotation(api2.annotations, Summary, (summary) => { | |
| 4658 | + spec.info.summary = summary; | |
| 4659 | + }); | |
| 4660 | + processAnnotation(api2.annotations, Servers, (servers) => { | |
| 4661 | + spec.servers = [...servers]; | |
| 4662 | + }); | |
| 4663 | + api2.middlewares.forEach((middleware3) => { | |
| 4664 | + if (!isSecurity(middleware3)) { | |
| 4665 | + return; | |
| 4666 | + } | |
| 4667 | + for (const [name, security] of Object.entries(middleware3.security)) { | |
| 4668 | + processHttpApiSecurity(name, security); | |
| 4669 | + spec.security.push({ | |
| 4670 | + [name]: [] | |
| 4671 | + }); | |
| 4672 | + } | |
| 4673 | + }); | |
| 4674 | + reflect(api2, { | |
| 4675 | + onGroup({ | |
| 4676 | + group: group2 | |
| 4677 | + }) { | |
| 4678 | + if (get(group2.annotations, Exclude)) { | |
| 4679 | + return; | |
| 4680 | + } | |
| 4681 | + let tag4 = { | |
| 4682 | + name: getOrElse2(group2.annotations, Title, () => group2.identifier) | |
| 4683 | + }; | |
| 4684 | + processAnnotation(group2.annotations, Description, (description) => { | |
| 4685 | + tag4.description = description; | |
| 4686 | + }); | |
| 4687 | + processAnnotation(group2.annotations, ExternalDocs, (externalDocs) => { | |
| 4688 | + tag4.externalDocs = externalDocs; | |
| 4689 | + }); | |
| 4690 | + processAnnotation(group2.annotations, Override, (override) => { | |
| 4691 | + Object.assign(tag4, override); | |
| 4692 | + }); | |
| 4693 | + processAnnotation(group2.annotations, Transform, (transformFn) => { | |
| 4694 | + tag4 = transformFn(tag4); | |
| 4695 | + }); | |
| 4696 | + spec.tags.push(tag4); | |
| 4697 | + }, | |
| 4698 | + onEndpoint({ | |
| 4699 | + endpoint, | |
| 4700 | + errors, | |
| 4701 | + group: group2, | |
| 4702 | + mergedAnnotations, | |
| 4703 | + middleware: middleware3, | |
| 4704 | + payloads, | |
| 4705 | + successes | |
| 4706 | + }) { | |
| 4707 | + if (get(mergedAnnotations, Exclude)) { | |
| 4708 | + return; | |
| 4709 | + } | |
| 4710 | + let op = { | |
| 4711 | + tags: [getOrElse2(group2.annotations, Title, () => group2.identifier)], | |
| 4712 | + operationId: getOrElse2(endpoint.annotations, Identifier, () => group2.topLevel ? endpoint.name : `${group2.identifier}.${endpoint.name}`), | |
| 4713 | + parameters: [], | |
| 4714 | + security: [], | |
| 4715 | + responses: {} | |
| 4716 | + }; | |
| 4717 | + function processResponseMap(map7, defaultDescription) { | |
| 4718 | + for (const [status, { | |
| 4719 | + ast, | |
| 4720 | + description | |
| 4721 | + }] of map7) { | |
| 4722 | + if (op.responses[status]) continue; | |
| 4723 | + op.responses[status] = { | |
| 4724 | + description: getOrElse(description, defaultDescription) | |
| 4725 | + }; | |
| 4726 | + ast.pipe(filter((ast2) => !getEmptyDecodeable(ast2)), map2((ast2) => { | |
| 4727 | + const encoding = getEncoding(ast2); | |
| 4728 | + op.responses[status].content = { | |
| 4729 | + [encoding.contentType]: { | |
| 4730 | + schema: processAST(ast2) | |
| 4731 | + } | |
| 4732 | + }; | |
| 4733 | + })); | |
| 4734 | + } | |
| 4735 | + } | |
| 4736 | + function processParameters(schema2, i) { | |
| 4737 | + if (isSome(schema2)) { | |
| 4738 | + const jsonSchema2 = processAST(schema2.value.ast); | |
| 4739 | + if ("properties" in jsonSchema2) { | |
| 4740 | + Object.entries(jsonSchema2.properties).forEach(([name, psJsonSchema]) => { | |
| 4741 | + op.parameters.push({ | |
| 4742 | + name, | |
| 4743 | + in: i, | |
| 4744 | + schema: psJsonSchema, | |
| 4745 | + required: jsonSchema2.required.includes(name), | |
| 4746 | + ...psJsonSchema.description !== void 0 ? { | |
| 4747 | + description: psJsonSchema.description | |
| 4748 | + } : void 0 | |
| 4749 | + }); | |
| 4750 | + }); | |
| 4751 | + } | |
| 4752 | + } | |
| 4753 | + } | |
| 4754 | + processAnnotation(endpoint.annotations, Description, (description) => { | |
| 4755 | + op.description = description; | |
| 4756 | + }); | |
| 4757 | + processAnnotation(endpoint.annotations, Summary, (summary) => { | |
| 4758 | + op.summary = summary; | |
| 4759 | + }); | |
| 4760 | + processAnnotation(endpoint.annotations, Deprecated, (deprecated) => { | |
| 4761 | + op.deprecated = deprecated; | |
| 4762 | + }); | |
| 4763 | + processAnnotation(endpoint.annotations, ExternalDocs, (externalDocs) => { | |
| 4764 | + op.externalDocs = externalDocs; | |
| 4765 | + }); | |
| 4766 | + middleware3.forEach((middleware4) => { | |
| 4767 | + if (!isSecurity(middleware4)) { | |
| 4768 | + return; | |
| 4769 | + } | |
| 4770 | + for (const [name, security] of Object.entries(middleware4.security)) { | |
| 4771 | + processHttpApiSecurity(name, security); | |
| 4772 | + op.security.push({ | |
| 4773 | + [name]: [] | |
| 4774 | + }); | |
| 4775 | + } | |
| 4776 | + }); | |
| 4777 | + const hasBody2 = hasBody(endpoint.method); | |
| 4778 | + if (hasBody2 && payloads.size > 0) { | |
| 4779 | + const content = {}; | |
| 4780 | + payloads.forEach(({ | |
| 4781 | + ast | |
| 4782 | + }, contentType) => { | |
| 4783 | + content[contentType] = { | |
| 4784 | + schema: processAST(ast) | |
| 4785 | + }; | |
| 4786 | + }); | |
| 4787 | + op.requestBody = { | |
| 4788 | + content, | |
| 4789 | + required: true | |
| 4790 | + }; | |
| 4791 | + } | |
| 4792 | + processParameters(endpoint.pathSchema, "path"); | |
| 4793 | + if (!hasBody2) { | |
| 4794 | + processParameters(endpoint.payloadSchema, "query"); | |
| 4795 | + } | |
| 4796 | + processParameters(endpoint.headersSchema, "header"); | |
| 4797 | + processParameters(endpoint.urlParamsSchema, "query"); | |
| 4798 | + processResponseMap(successes, () => "Success"); | |
| 4799 | + processResponseMap(errors, () => "Error"); | |
| 4800 | + const path = endpoint.path.replace(/:(\w+)\??/g, "{$1}"); | |
| 4801 | + const method = endpoint.method.toLowerCase(); | |
| 4802 | + if (!spec.paths[path]) { | |
| 4803 | + spec.paths[path] = {}; | |
| 4804 | + } | |
| 4805 | + processAnnotation(endpoint.annotations, Override, (override) => { | |
| 4806 | + Object.assign(op, override); | |
| 4807 | + }); | |
| 4808 | + processAnnotation(endpoint.annotations, Transform, (transformFn) => { | |
| 4809 | + op = transformFn(op); | |
| 4810 | + }); | |
| 4811 | + spec.paths[path][method] = op; | |
| 4812 | + } | |
| 4813 | + }); | |
| 4814 | + processAnnotation(api2.annotations, Override, (override) => { | |
| 4815 | + Object.assign(spec, override); | |
| 4816 | + }); | |
| 4817 | + processAnnotation(api2.annotations, Transform, (transformFn) => { | |
| 4818 | + spec = transformFn(spec); | |
| 4819 | + }); | |
| 4820 | + apiCache.set(api2, spec); | |
| 4821 | + return spec; | |
| 4822 | +}; | |
| 4823 | +var makeSecurityScheme = (security) => { | |
| 4824 | + const meta = {}; | |
| 4825 | + processAnnotation(security.annotations, Description, (description) => { | |
| 4826 | + meta.description = description; | |
| 4827 | + }); | |
| 4828 | + switch (security._tag) { | |
| 4829 | + case "Basic": { | |
| 4830 | + return { | |
| 4831 | + ...meta, | |
| 4832 | + type: "http", | |
| 4833 | + scheme: "basic" | |
| 4834 | + }; | |
| 4835 | + } | |
| 4836 | + case "Bearer": { | |
| 4837 | + const format2 = getOption(security.annotations, Format).pipe(map2((format3) => ({ | |
| 4838 | + bearerFormat: format3 | |
| 4839 | + })), getOrUndefined); | |
| 4840 | + return { | |
| 4841 | + ...meta, | |
| 4842 | + type: "http", | |
| 4843 | + scheme: "bearer", | |
| 4844 | + ...format2 | |
| 4845 | + }; | |
| 4846 | + } | |
| 4847 | + case "ApiKey": { | |
| 4848 | + return { | |
| 4849 | + ...meta, | |
| 4850 | + type: "apiKey", | |
| 4851 | + name: security.key, | |
| 4852 | + in: security.in | |
| 4853 | + }; | |
| 4854 | + } | |
| 4855 | + } | |
| 4856 | +}; | |
| 4857 | + | |
| 4858 | +// ../../node_modules/.bun/@effect+platform@0.93.8+a91c478e54a5dd97/node_modules/@effect/platform/dist/esm/HttpApiBuilder.js | |
| 4859 | +var Router = class extends Tag4("@effect/platform/HttpApiBuilder/Router")() { | |
| 4860 | +}; | |
| 4861 | +var api = (api2) => effect(Api, map5(context(), (context2) => ({ | |
| 4862 | + api: api2, | |
| 4863 | + context: context2 | |
| 4864 | +}))); | |
| 4865 | +var serve3 = (middleware3) => httpApp.pipe(map5((app) => serve2(app, middleware3)), unwrapEffect, provide2([Router.Live, Middleware.layer])); | |
| 4866 | +var httpApp = gen(function* () { | |
| 4867 | + const { | |
| 4868 | + api: api2, | |
| 4869 | + context: context2 | |
| 4870 | + } = yield* Api; | |
| 4871 | + const middleware3 = makeMiddlewareMap(api2.middlewares, context2); | |
| 4872 | + const router = applyMiddleware(middleware3, yield* toHttpApp2(yield* Router.router)); | |
| 4873 | + const apiMiddlewareService = yield* Middleware; | |
| 4874 | + const apiMiddleware = yield* apiMiddlewareService.retrieve; | |
| 4875 | + const errorSchema = makeErrorSchema(api2); | |
| 4876 | + const encodeError = encodeUnknown(errorSchema); | |
| 4877 | + return router.pipe(apiMiddleware, catchAllCause((cause) => matchEffect(provide(encodeError(squash(cause)), context2), { | |
| 4878 | + onFailure: () => failCause2(cause), | |
| 4879 | + onSuccess: succeed | |
| 4880 | + }))); | |
| 4881 | +}); | |
| 4882 | +var buildMiddleware = fnUntraced(function* (api2) { | |
| 4883 | + const context2 = yield* context(); | |
| 4884 | + const middlewareMap = makeMiddlewareMap(api2.middlewares, context2); | |
| 4885 | + const errorSchema = makeErrorSchema(api2); | |
| 4886 | + const encodeError = encodeUnknown(errorSchema); | |
| 4887 | + return (effect2) => catchAllCause(applyMiddleware(middlewareMap, effect2), (cause) => matchEffect(provide(encodeError(squash(cause)), context2), { | |
| 4888 | + onFailure: () => failCause2(cause), | |
| 4889 | + onSuccess: succeed | |
| 4890 | + })); | |
| 4891 | +}); | |
| 4892 | +var toWebHandler2 = (layer13, options4) => { | |
| 4893 | + const layerMerged = mergeAll(layer13, Router.Live, Middleware.layer); | |
| 4894 | + return toWebHandlerLayerWith(layerMerged, { | |
| 4895 | + memoMap: options4?.memoMap, | |
| 4896 | + middleware: options4?.middleware, | |
| 4897 | + toHandler: (r) => provide(httpApp, r) | |
| 4898 | + }); | |
| 4899 | +}; | |
| 4900 | +var HandlersTypeId = Symbol.for("@effect/platform/HttpApiBuilder/Handlers"); | |
| 4901 | +var HandlersProto = { | |
| 4902 | + [HandlersTypeId]: { | |
| 4903 | + _Endpoints: identity | |
| 4904 | + }, | |
| 4905 | + pipe() { | |
| 4906 | + return pipeArguments(this, arguments); | |
| 4907 | + }, | |
| 4908 | + handle(name, handler2, options4) { | |
| 4909 | + const endpoint = this.group.endpoints[name]; | |
| 4910 | + return makeHandlers({ | |
| 4911 | + group: this.group, | |
| 4912 | + handlers: append(this.handlers, { | |
| 4913 | + endpoint, | |
| 4914 | + handler: handler2, | |
| 4915 | + withFullRequest: false, | |
| 4916 | + uninterruptible: options4?.uninterruptible ?? false | |
| 4917 | + }) | |
| 4918 | + }); | |
| 4919 | + }, | |
| 4920 | + handleRaw(name, handler2, options4) { | |
| 4921 | + const endpoint = this.group.endpoints[name]; | |
| 4922 | + return makeHandlers({ | |
| 4923 | + group: this.group, | |
| 4924 | + handlers: append(this.handlers, { | |
| 4925 | + endpoint, | |
| 4926 | + handler: handler2, | |
| 4927 | + withFullRequest: true, | |
| 4928 | + uninterruptible: options4?.uninterruptible ?? false | |
| 4929 | + }) | |
| 4930 | + }); | |
| 4931 | + } | |
| 4932 | +}; | |
| 4933 | +var makeHandlers = (options4) => { | |
| 4934 | + const self = Object.create(HandlersProto); | |
| 4935 | + self.group = options4.group; | |
| 4936 | + self.handlers = options4.handlers; | |
| 4937 | + return self; | |
| 4938 | +}; | |
| 4939 | +var group = (api2, groupName, build) => Router.use((router) => gen(function* () { | |
| 4940 | + const context2 = yield* context(); | |
| 4941 | + const group2 = api2.groups[groupName]; | |
| 4942 | + const result = build(makeHandlers({ | |
| 4943 | + group: group2, | |
| 4944 | + handlers: empty3() | |
| 4945 | + })); | |
| 4946 | + const handlers = isEffect(result) ? yield* result : result; | |
| 4947 | + const groupMiddleware = makeMiddlewareMap(group2.middlewares, context2); | |
| 4948 | + const routes = []; | |
| 4949 | + for (const item of handlers.handlers) { | |
| 4950 | + const middleware3 = makeMiddlewareMap(item.endpoint.middlewares, context2, groupMiddleware); | |
| 4951 | + routes.push(handlerToRoute(item.endpoint, middleware3, function(request) { | |
| 4952 | + return mapInputContext(item.handler(request), (input) => merge(context2, input)); | |
| 4953 | + }, item.withFullRequest, item.uninterruptible)); | |
| 4954 | + } | |
| 4955 | + yield* router.concat(fromIterable7(routes)); | |
| 4956 | +})); | |
| 4957 | +var handler = (_api, _groupName, _name, f) => f; | |
| 4958 | +var requestPayload = (request, urlParams4, multipartLimits) => { | |
| 4959 | + if (!hasBody(request.method)) { | |
| 4960 | + return succeed(urlParams4); | |
| 4961 | + } | |
| 4962 | + const contentType = request.headers["content-type"] ? request.headers["content-type"].toLowerCase().trim() : "application/json"; | |
| 4963 | + if (contentType.includes("application/json")) { | |
| 4964 | + return orDie(request.json); | |
| 4965 | + } else if (contentType.includes("multipart/form-data")) { | |
| 4966 | + return orDie(match2(multipartLimits, { | |
| 4967 | + onNone: () => request.multipart, | |
| 4968 | + onSome: (limits) => withLimits(request.multipart, limits) | |
| 4969 | + })); | |
| 4970 | + } else if (contentType.includes("x-www-form-urlencoded")) { | |
| 4971 | + return map5(orDie(request.urlParamsBody), toRecord); | |
| 4972 | + } else if (contentType.startsWith("text/")) { | |
| 4973 | + return orDie(request.text); | |
| 4974 | + } | |
| 4975 | + return map5(orDie(request.arrayBuffer), (buffer) => new Uint8Array(buffer)); | |
| 4976 | +}; | |
| 4977 | +var makeMiddlewareMap = (middleware3, context2, initial) => { | |
| 4978 | + const map7 = new Map(initial); | |
| 4979 | + middleware3.forEach((tag4) => { | |
| 4980 | + map7.set(tag4.key, { | |
| 4981 | + tag: tag4, | |
| 4982 | + effect: unsafeGet(context2, tag4) | |
| 4983 | + }); | |
| 4984 | + }); | |
| 4985 | + return map7; | |
| 4986 | +}; | |
| 4987 | +function isSingleStringType(ast, key) { | |
| 4988 | + switch (ast._tag) { | |
| 4989 | + case "StringKeyword": | |
| 4990 | + case "Literal": | |
| 4991 | + case "TemplateLiteral": | |
| 4992 | + case "Enums": | |
| 4993 | + return true; | |
| 4994 | + case "TypeLiteral": { | |
| 4995 | + if (key !== void 0) { | |
| 4996 | + const ps = ast.propertySignatures.find((ps2) => ps2.name === key); | |
| 4997 | + return ps !== void 0 ? isSingleStringType(ps.type, key) : ast.indexSignatures.some((is2) => is(make7(is2.parameter))(key) && isSingleStringType(is2.type)); | |
| 4998 | + } | |
| 4999 | + return false; | |
1732 more lines aren’t shown here.
This diff is larger than a page shows: the files after these aren’t listed. Clone the repository to see all of it.