diff --git a/.dockerignore b/.dockerignore index d48d1b78..6c8a1b8d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -9,3 +9,11 @@ dist **/node_modules **/.vitepress/cache **/.vitepress/dist +**/.env +**/.env.* +!apps/admin/.env.development +!apps/admin/.env.production +!apps/admin/.env.test +**/dist-test +**/src/generated +.pnpm-store diff --git a/.github/workflows/distributions.yaml b/.github/workflows/distributions.yaml new file mode 100644 index 00000000..42e4aab3 --- /dev/null +++ b/.github/workflows/distributions.yaml @@ -0,0 +1,141 @@ +name: Source distributions + +on: + workflow_dispatch: + inputs: + sync_frontend: + description: Update the generated frontend branch from main + type: boolean + default: false + release_tag: + description: Attach assets to the existing release for this tag (optional) + type: string + +permissions: + contents: read + +defaults: + run: + shell: bash + +concurrency: + group: source-distributions + cancel-in-progress: false + +jobs: + verify: + if: github.ref == 'refs/heads/main' + runs-on: ubuntu-latest + timeout-minutes: 30 + outputs: + source: ${{ steps.source.outputs.commit }} + steps: + - uses: actions/checkout@v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - name: Select the source revision + id: source + env: + RELEASE_TAG: ${{ inputs.release_tag }} + SYNC_FRONTEND: ${{ inputs.sync_frontend }} + run: | + if [[ -n "$RELEASE_TAG" ]]; then + [[ "$SYNC_FRONTEND" == false ]] || { echo "Run branch sync and release attachment separately."; exit 1; } + [[ "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+([.-][a-zA-Z0-9.-]+)?$ ]] + source=$(git rev-parse --verify "refs/tags/$RELEASE_TAG^{commit}") + git merge-base --is-ancestor "$source" "$GITHUB_SHA" + git checkout --detach "$source" + [[ "v$(node -p 'require("./package.json").version')" == "$RELEASE_TAG" ]] + fi + echo "commit=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT" + - uses: actions/setup-node@v7.1.0 + with: + node-version-file: .nvmrc + - uses: pnpm/action-setup@v6.1.0 + - name: Export both source distributions + env: + HUSKY: '0' + run: | + pnpm install --frozen-lockfile + pnpm dist:frontend + pnpm dist:fullstack + cd dist/distributions + sha256sum ray-template-*.tar.gz > SHA256SUMS.txt + - name: Verify independent installations and builds + env: + HUSKY: '0' + run: | + version=$(node -p 'require("./package.json").version') + for edition in frontend fullstack; do + name="ray-template-$edition-$version" + tar -xzf "dist/distributions/$name.tar.gz" -C "$RUNNER_TEMP" + ( + cd "$RUNNER_TEMP/$name" + pnpm install --frozen-lockfile + pnpm check + if [[ "$edition" == fullstack ]]; then + node deploy/smoke.mjs + fi + ) + done + - uses: actions/upload-artifact@v7 + with: + name: source-distributions + path: | + dist/distributions/ray-template-*.tar.gz + dist/distributions/SHA256SUMS.txt + if-no-files-found: error + compression-level: 0 + + sync-frontend: + if: inputs.sync_frontend && inputs.release_tag == '' + needs: verify + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v7.0.1 + with: + fetch-depth: 0 + - uses: actions/download-artifact@v8 + with: + name: source-distributions + path: ${{ runner.temp }}/source-distributions + - name: Update the generated branch + run: | + version=$(node -p 'require("./package.json").version') + name="ray-template-frontend-$version" + artifacts="$RUNNER_TEMP/source-distributions" + (cd "$artifacts" && sha256sum --check SHA256SUMS.txt) + tar -xzf "$artifacts/$name.tar.gz" -C "$RUNNER_TEMP" + git config user.name 'github-actions[bot]' + git config user.email '41898282+github-actions[bot]@users.noreply.github.com' + bash scripts/sync-frontend.sh "$RUNNER_TEMP/$name" + + attach-release: + if: inputs.release_tag != '' && !inputs.sync_frontend + needs: verify + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - uses: actions/checkout@v7.0.1 + with: + fetch-depth: 0 + persist-credentials: false + - uses: actions/download-artifact@v8 + with: + name: source-distributions + path: ${{ runner.temp }}/source-distributions + - name: Attach source archives to the existing release + env: + GH_TOKEN: ${{ github.token }} + RELEASE_TAG: ${{ inputs.release_tag }} + SOURCE: ${{ needs.verify.outputs.source }} + run: | + [[ "$(git rev-parse --verify "refs/tags/$RELEASE_TAG^{commit}")" == "$SOURCE" ]] + gh release view "$RELEASE_TAG" --repo "$GITHUB_REPOSITORY" --json tagName >/dev/null + cd "$RUNNER_TEMP/source-distributions" + sha256sum --check SHA256SUMS.txt + gh release upload "$RELEASE_TAG" ray-template-*.tar.gz SHA256SUMS.txt --repo "$GITHUB_REPOSITORY" diff --git a/.gitignore b/.gitignore index 05959f0d..d7d33c5f 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,5 @@ coverage/ .env.*.local .ai-local/ .harness-local/ +.pnpm-store/ apps/docs/.vitepress/cache/ diff --git a/.prettierignore b/.prettierignore index 3ea9a76b..971c89e1 100644 --- a/.prettierignore +++ b/.prettierignore @@ -15,6 +15,11 @@ coverage/ .husky/_/ .ai-local/ .harness-local/ +**/dist-test/ +apps/server/src/generated/ +.pnpm-store/ CHANGELOG.md packages/icons/src/ packages/ui/src/RChart/src/themes/ + +packages/demo-data/src/route-catalog.json diff --git a/.prettierrc.cjs b/.prettierrc.cjs index a0a886eb..f4e12dec 100644 --- a/.prettierrc.cjs +++ b/.prettierrc.cjs @@ -19,4 +19,12 @@ module.exports = { singleAttributePerLine: false, bracketSameLine: false, plugins: ['@ianvs/prettier-plugin-sort-imports'], + overrides: [ + { + files: 'apps/server/**/*.ts', + options: { + importOrderParserPlugins: ['typescript', 'decorators-legacy'], + }, + }, + ], } diff --git a/README.md b/README.md index 09b8cc81..cc5b759c 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Ray Template is an open-source frontend template for admin dashboards, operations consoles, and internal tools. It brings together a working application, reusable packages, and interactive documentation. Start with the demo, choose a look, and connect your business APIs. -**4 visual styles · 5 navigation layouts · 11 TablePro examples · 9 shared packages** +**4 visual styles · 5 navigation layouts · 11 TablePro examples · 10 shared packages** [![The complete Ray Admin welcome page in the default Modern light style with side navigation](docs/assets/readme/welcome-modern-light.png)](https://xiaodaigua-ray.github.io/ray-template/#/dashboard) @@ -82,10 +82,10 @@ Ray Admin and the documentation live in one **pnpm monorepo**. Business integrat flowchart TB Admin["Ray Admin · apps/admin"] Docs["Interactive docs · apps/docs"] - Shared["9 shared workspace packages"] + Shared["10 shared workspace packages"] UI["Interface: ui · admin-shell"] Interaction["Interaction: composables · directives · icons"] - Data["Data: http · api-contracts · routing · utils"] + Data["Data: http · api-contracts · demo-data · routing · utils"] Admin --> Shared Docs --> Shared Shared --> UI @@ -121,6 +121,29 @@ Open [http://127.0.0.1:9527/ray-template/](http://127.0.0.1:9527/ray-template/) 2. **Build a page.** Start with an [existing example](apps/admin/src/views/demo), register its view ID, and add a route with bilingual menu labels. 3. **Connect your API.** Keep the page contract and connect your backend using the [integration guide](apps/docs/guide/backend.md). +## Choose a source distribution + +The frontend distribution contains Admin, documentation, shared packages, and Mock. It installs and runs independently without a database or Redis. Run `pnpm dist:frontend` to produce `ray-template-frontend-.tar.gz` and its source directory under `dist/distributions/`. Extract it, then run `pnpm install --frozen-lockfile` and `pnpm dev`. + +Each artifact includes `distribution.json` with its version, source commit and workspace state, workspace list, and content digest. Export prunes the lockfile, dependencies, commands, and fullstack-only documentation, and excludes local configuration, credentials, build output, and installed dependencies. See [distributions and startup](apps/docs/guide/distributions.md). + + + +The complete source also includes an optional [NestJS server](apps/server). PostgreSQL stores users, permissions, sessions, route configuration, and audits; Redis provides rate limits and cache for demonstration reads. Run `pnpm dist:fullstack` to export the matching fullstack source archive. + +After installing dependencies, prepare Docker Compose and run: + +```sh +pnpm fullstack:setup +pnpm dev:full +``` + +`setup` creates the private `apps/server/.env.local`, starts PostgreSQL and Redis, applies migrations, and initializes the administrator. The generated administrator password is stored in that file; Mock passwords do not authenticate against the server. Repeating setup preserves existing configuration and accounts. For existing PostgreSQL and Redis services, provide `DATABASE_URL` and `REDIS_URL` and run `pnpm fullstack:setup --external`. `pnpm fullstack:stop` stops Compose services while retaining their data volumes. + +The [Source distributions workflow](.github/workflows/distributions.yaml) verifies both archives before it can update the generated `frontend` branch or attach assets to an existing GitHub Release. Those actions are explicitly selected when running the workflow from `main`. See the [Compose and release instructions](apps/docs/guide/distributions.md#容器启动). + + + ## Development and delivery **Vue 3 · TypeScript / TSX · Naive UI · Vite / Rolldown · Pinia · Vue Router · Vue I18n · Axios · MSW · Vitest** diff --git a/README.zh-CN.md b/README.zh-CN.md index 5078b7b5..cc84c24a 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -6,7 +6,7 @@ Ray Template 是基于 Vue 3、TypeScript / TSX 和 Naive UI 的开源中后台模板,适合管理后台、运营工作台和内部工具。完整应用、共享包和交互文档放在同一工作区,克隆即可运行,再按业务调整界面、页面和接口。 -**4 种视觉风格 · 5 种导航布局 · 11 个 TablePro 示例 · 9 个共享包** +**4 种视觉风格 · 5 种导航布局 · 11 个 TablePro 示例 · 10 个共享包** [![默认 Modern 浅色风格的完整欢迎页,展示侧边导航和工作空间概览](docs/assets/readme/welcome-modern-light.png)](https://xiaodaigua-ray.github.io/ray-template/#/dashboard) @@ -82,10 +82,10 @@ Ray Admin 与文档站采用 **pnpm Monorepo**。业务接入留在应用层, flowchart TB Admin["Ray Admin · apps/admin"] Docs["交互文档 · apps/docs"] - Shared["9 个共享 workspace 包"] + Shared["10 个共享 workspace 包"] UI["界面:ui · admin-shell"] Interaction["交互:composables · directives · icons"] - Data["数据:http · api-contracts · routing · utils"] + Data["数据:http · api-contracts · demo-data · routing · utils"] Admin --> Shared Docs --> Shared Shared --> UI @@ -121,6 +121,29 @@ pnpm dev 2. **写第一个页面**:参考[现有示例](apps/admin/src/views/demo),登记页面组件 ID,添加路由及中英文菜单文案。 3. **接入业务接口**:保留页面契约,按[后端接入指南](apps/docs/guide/backend.md)连接自己的服务。 +## 选择源码发行版本 + +纯前端发行包包含 Admin、文档、共享包和 Mock,独立安装与运行,不需要数据库或 Redis。执行 `pnpm dist:frontend`,在 `dist/distributions/` 得到 `ray-template-frontend-.tar.gz` 和对应源码目录。解压后执行 `pnpm install --frozen-lockfile`、`pnpm dev`。 + +每份发行物都包含 `distribution.json`,记录版本、来源提交及工作区状态、工作区清单和内容摘要。导出会裁剪锁文件与依赖、命令和仅供全栈使用的说明,并排除本地配置、凭据、构建输出和依赖目录。详情见[发行版本与快速启动](apps/docs/guide/distributions.md)。 + + + +完整源码还包含可选的 [NestJS 服务端](apps/server),以 PostgreSQL 保存用户、权限、会话、路由与审计,并使用 Redis 提供限流和演示数据缓存。执行 `pnpm dist:fullstack` 生成同版本的全栈源码归档。 + +安装依赖后,准备 Docker Compose,执行: + +```sh +pnpm fullstack:setup +pnpm dev:full +``` + +`setup` 创建私有的 `apps/server/.env.local`、启动数据库与 Redis、迁移并初始化管理员。管理员密码随机生成并保存在该文件中;真实后端不接受 Mock 演示密码。重复执行保留已有配置和账号。已经有 PostgreSQL、Redis 时,可提供 `DATABASE_URL`、`REDIS_URL` 并执行 `pnpm fullstack:setup --external`。`pnpm fullstack:stop` 停止 Compose 服务并保留数据卷。 + +[源码发行工作流](.github/workflows/distributions.yaml) 验证两个归档后,可以生成或更新 `frontend` 分支,也可以给已有 GitHub Release 附加源码归档。需要从 `main` 手动运行并选择对应操作。容器启动见[发行版本与快速启动](apps/docs/guide/distributions.md#容器启动)。 + + + ## 开发与交付 **Vue 3 · TypeScript / TSX · Naive UI · Vite / Rolldown · Pinia · Vue Router · Vue I18n · Axios · MSW · Vitest** diff --git a/__test__/app/signing.spec.tsx b/__test__/app/signing.spec.tsx new file mode 100644 index 00000000..67043822 --- /dev/null +++ b/__test__/app/signing.spec.tsx @@ -0,0 +1,51 @@ +import Signing from '@/views/login/components/Signing' +import { flushPromises, mount } from '@vue/test-utils' +import { createMemoryHistory, createRouter } from 'vue-router' + +const signing = vi.fn() + +vi.mock('@/api/admin/client', () => ({ apiMockEnabled: false })) +vi.mock('@/hooks', () => ({ + useI18n: () => ({ t: (key: string) => key }), +})) +vi.mock('@/store', () => ({ + useSigningActions: () => ({ signing }), +})) + +it('submits the real login form with native credential fields and no demo shortcuts', async () => { + signing.mockResolvedValue({ + code: 0, + data: { id: 'test-account', username: 'qa-account' }, + }) + const router = createRouter({ + history: createMemoryHistory(), + routes: ['/', '/welcome'].map((path) => ({ + path, + component: { render: () => null }, + })), + }) + + await router.push('/') + const wrapper = mount(Signing, { global: { plugins: [router] } }) + + try { + const username = wrapper.get('input[name="username"]') + const password = wrapper.get('input[name="password"]') + + expect(username.attributes('autocomplete')).toBe('username') + expect(password.attributes('autocomplete')).toBe('current-password') + expect(password.attributes('type')).toBe('password') + expect(wrapper.text()).not.toMatch(/UseDemo|UseMember|UseManager/u) + await username.setValue('qa-account') + await password.setValue('qa-fixture-password') + await wrapper.get('form').trigger('submit') + await flushPromises() + expect(signing).toHaveBeenCalledExactlyOnceWith({ + name: 'qa-account', + pwd: 'qa-fixture-password', + }) + expect(router.currentRoute.value.path).toBe('/welcome') + } finally { + wrapper.unmount() + } +}) diff --git a/__test__/distribution/distributions.spec.ts b/__test__/distribution/distributions.spec.ts new file mode 100644 index 00000000..9347f928 --- /dev/null +++ b/__test__/distribution/distributions.spec.ts @@ -0,0 +1,479 @@ +// @vitest-environment node + +import { spawnSync } from 'node:child_process' +import { + chmodSync, + existsSync, + mkdirSync, + mkdtempSync, + readdirSync, + readFileSync, + rmSync, + statSync, + symlinkSync, + writeFileSync, +} from 'node:fs' +import { tmpdir } from 'node:os' +import { dirname, join } from 'node:path' +import { parse, parseAllDocuments, stringify } from 'yaml' +import { + checkDistributions, + exportDistribution, + pruneLockfile, +} from '../../scripts/distributions.mjs' + +let fixture: string +const readJson = (path: string) => JSON.parse(readFileSync(path, 'utf8')) +const reference = (version: string) => ({ specifier: version, version }) + +function write(path: string, value: string | object) { + const target = join(fixture, path) + + mkdirSync(dirname(target), { recursive: true }) + writeFileSync( + target, + typeof value === 'string' ? value : JSON.stringify(value), + ) +} + +function lockfile() { + const manager = { + lockfileVersion: '9.0', + importers: { + '.': { packageManagerDependencies: { pnpm: reference('12.0.0') } }, + }, + packages: { 'pnpm@12.0.0': {}, 'pm-native@1.0.0': {} }, + snapshots: { + 'pnpm@12.0.0': { optionalDependencies: { 'pm-native': '1.0.0' } }, + 'pm-native@1.0.0': {}, + }, + } + const workspace = { + lockfileVersion: '9.0', + settings: { autoInstallPeers: true }, + importers: { + '.': { devDependencies: { yaml: reference('2.9.1') } }, + 'apps/admin': { + dependencies: { + '@ray-template/ui': reference('link:../../packages/ui'), + alias: reference('real-package@1.0.0(peer@2.0.0(nested@3.0.0))'), + }, + }, + 'apps/docs': { + dependencies: { + '@ray-template/ui': reference('link:../../packages/ui'), + }, + }, + 'apps/server': { + dependencies: { + '@ray-template/api-contracts': reference( + 'link:../../packages/api-contracts', + ), + '@ray-template/server-store': reference( + 'link:../../packages/server-store', + ), + '@nestjs/core': reference('12.0.0'), + }, + }, + 'packages/ui': { + dependencies: { + '@ray-template/api-contracts': reference('link:../api-contracts'), + vue: reference('3.5.0'), + }, + }, + 'packages/api-contracts': { + dependencies: { valibot: reference('1.5.0') }, + }, + 'packages/server-store': { dependencies: { pg: reference('8.0.0') } }, + }, + packages: { + 'yaml@2.9.1': {}, + 'vue@3.5.0': {}, + 'valibot@1.5.0': {}, + 'real-package@1.0.0': {}, + 'peer@2.0.0': {}, + 'nested@3.0.0': {}, + 'native-optional@1.0.0': {}, + '@nestjs/core@12.0.0': {}, + 'pg@8.0.0': {}, + 'pg-protocol@1.0.0': {}, + 'unused@1.0.0': {}, + }, + snapshots: { + 'yaml@2.9.1': {}, + 'vue@3.5.0': {}, + 'valibot@1.5.0': {}, + 'real-package@1.0.0(peer@2.0.0(nested@3.0.0))': { + optionalDependencies: { 'native-optional': '1.0.0' }, + }, + 'peer@2.0.0(nested@3.0.0)': {}, + 'nested@3.0.0': {}, + 'native-optional@1.0.0': {}, + '@nestjs/core@12.0.0': {}, + 'pg@8.0.0': { dependencies: { 'pg-protocol': '1.0.0' } }, + 'pg-protocol@1.0.0': {}, + 'unused@1.0.0': {}, + }, + } + + return `---\n${stringify(manager)}\n---\n${stringify(workspace)}` +} + +beforeEach(() => { + fixture = mkdtempSync(join(tmpdir(), 'ray-distribution-')) + write('package.json', { + name: 'ray-template', + version: '6.0.1', + private: true, + scripts: { + dev: 'vite', + 'check:frontend': 'pnpm typecheck && pnpm test:run', + check: 'pnpm check:frontend && pnpm server:check && pnpm dist:check', + setup: 'node scripts/fullstack.mjs setup', + 'dev:full': 'node scripts/fullstack.mjs dev', + 'server:check': 'pnpm --filter @ray-template/server check', + 'dist:frontend': 'node scripts/distributions.mjs frontend', + 'dist:fullstack': 'node scripts/distributions.mjs fullstack', + 'dist:check': 'node scripts/distributions.mjs --check', + }, + devDependencies: { yaml: '2.9.1' }, + }) + write('apps/admin/package.json', { + name: '@ray-template/admin', + dependencies: { + '@ray-template/ui': 'workspace:*', + alias: 'npm:real-package@1.0.0', + }, + }) + write('apps/docs/package.json', { + name: '@ray-template/docs', + dependencies: { '@ray-template/ui': 'workspace:*' }, + }) + write('apps/server/package.json', { + name: '@ray-template/server', + dependencies: { + '@ray-template/api-contracts': 'workspace:*', + '@ray-template/server-store': 'workspace:*', + '@nestjs/core': '12.0.0', + }, + }) + write('packages/ui/package.json', { + name: '@ray-template/ui', + dependencies: { '@ray-template/api-contracts': 'workspace:*' }, + peerDependencies: { vue: '3.5.0' }, + }) + write('packages/api-contracts/package.json', { + name: '@ray-template/api-contracts', + dependencies: { valibot: '1.5.0' }, + }) + write('packages/server-store/package.json', { + name: '@ray-template/server-store', + dependencies: { pg: '8.0.0' }, + }) + write('packages/ui/src/index.ts', 'export const shared = true\n') + write('apps/server/src/main.ts', 'export const server = true\n') + write('apps/admin/src/main.ts', 'export const admin = true\n') + write('scripts/distributions.mjs', '// exporter\n') + write('scripts/fullstack.mjs', '// server launcher\n') + write('deploy/compose.yaml', 'services: {}\n') + write('.github/workflows/ci.yaml', 'name: CI\n') + write('.github/workflows/distributions.yaml', 'name: Distributions\n') + write('.husky/pre-commit', 'pnpm lint-staged\n') + chmodSync(join(fixture, '.husky/pre-commit'), 0o755) + write( + 'pnpm-workspace.yaml', + 'packages:\n - apps/*\n - packages/*\nverifyDepsBeforeRun: false\n', + ) + write('pnpm-lock.yaml', lockfile()) + write('harness/scopes.json', { + toolchain: { checks: ['packages:check'] }, + server: { checks: ['server:check'] }, + }) + write('harness/context/server.md', '# Server\n') + write('tsconfig.json', { + references: [ + { path: './tsconfig.app.json' }, + { path: './apps/server/tsconfig.json' }, + ], + }) + write('tsconfig.app.json', '{}\n') + write( + 'README.md', + '# Template\n\nFrontend instructions.\n\n\n[Server](apps/server/README.md)\n\n\nShared instructions.\n', + ) +}) + +afterEach(() => { + rmSync(fixture, { recursive: true, force: true }) +}) + +it('exports a real frontend workspace without server files, scripts or dependency graph', async () => { + const sourceManifest = readFileSync(join(fixture, 'package.json'), 'utf8') + const sourceLock = readFileSync(join(fixture, 'pnpm-lock.yaml'), 'utf8') + const { directory, manifest } = await exportDistribution( + fixture, + 'frontend', + { + archive: false, + }, + ) + const exported = readJson(join(directory, 'package.json')) + const locks = parseAllDocuments( + readFileSync(join(directory, 'pnpm-lock.yaml'), 'utf8'), + ).map((document) => document.toJS()) + + expect(exported.scripts).not.toHaveProperty('server:check') + expect(exported.scripts).not.toHaveProperty('setup') + expect(exported.scripts).not.toHaveProperty('dev:full') + expect(exported.scripts).not.toHaveProperty('dist:fullstack') + expect(exported.scripts.check).toBe('pnpm check:frontend && pnpm dist:check') + expect(exported.scripts.dev).toBe('vite') + expect(existsSync(join(directory, 'apps/server'))).toBe(false) + expect(existsSync(join(directory, 'packages/server-store'))).toBe(false) + expect(existsSync(join(directory, 'scripts/fullstack.mjs'))).toBe(false) + expect(existsSync(join(directory, 'deploy'))).toBe(false) + expect( + existsSync(join(directory, '.github/workflows/distributions.yaml')), + ).toBe(false) + expect(existsSync(join(directory, '.github/workflows/ci.yaml'))).toBe(true) + expect(readJson(join(directory, 'harness/scopes.json'))).not.toHaveProperty( + 'server', + ) + expect(readJson(join(directory, 'tsconfig.json')).references).toEqual([ + { path: './tsconfig.app.json' }, + ]) + expect(readFileSync(join(directory, 'README.md'), 'utf8')).toContain( + 'Frontend instructions.', + ) + expect(readFileSync(join(directory, 'README.md'), 'utf8')).not.toContain( + '[Server]', + ) + expect( + parse(readFileSync(join(directory, 'pnpm-workspace.yaml'), 'utf8')) + .packages, + ).toEqual([ + 'apps/admin', + 'apps/docs', + 'packages/api-contracts', + 'packages/ui', + ]) + expect(locks).toHaveLength(2) + expect(locks[0].snapshots).toHaveProperty('pm-native@1.0.0') + expect(Object.keys(locks[1].snapshots)).toEqual( + expect.arrayContaining([ + 'real-package@1.0.0(peer@2.0.0(nested@3.0.0))', + 'peer@2.0.0(nested@3.0.0)', + 'nested@3.0.0', + 'native-optional@1.0.0', + ]), + ) + expect(locks[1].snapshots).not.toHaveProperty('@nestjs/core@12.0.0') + expect(locks[1].snapshots).not.toHaveProperty('pg@8.0.0') + expect(locks[1].packages).not.toHaveProperty('pg-protocol@1.0.0') + expect(locks[1].packages).not.toHaveProperty('unused@1.0.0') + expect(manifest.edition).toBe('frontend') + expect(manifest.contentSha256).toMatch(/^[a-f0-9]{64}$/) + expect(manifest.workspaces).not.toContain('apps/server') + expect(readFileSync(join(fixture, 'package.json'), 'utf8')).toBe( + sourceManifest, + ) + expect(readFileSync(join(fixture, 'pnpm-lock.yaml'), 'utf8')).toBe(sourceLock) + + if (process.platform !== 'win32') { + expect(statSync(join(directory, '.husky/pre-commit')).mode & 0o777).toBe( + 0o755, + ) + } +}) + +it('exports fullstack with its backend and transitive packages', async () => { + const { directory, manifest } = await exportDistribution( + fixture, + 'fullstack', + { + archive: false, + }, + ) + const lock = parseAllDocuments( + readFileSync(join(directory, 'pnpm-lock.yaml'), 'utf8'), + )[1].toJS() + + expect(existsSync(join(directory, 'apps/server/src/main.ts'))).toBe(true) + expect( + existsSync(join(directory, 'packages/server-store/package.json')), + ).toBe(true) + expect(existsSync(join(directory, 'deploy/compose.yaml'))).toBe(true) + expect(readJson(join(directory, 'package.json')).scripts).toHaveProperty( + 'dev:full', + ) + expect(lock.snapshots).toHaveProperty('pg-protocol@1.0.0') + expect(manifest.workspaces).toContain('apps/server') +}) + +it('omits local secrets, unapproved root files and generated output while including new source', async () => { + for (const path of [ + '.env', + '.env.local', + 'credentials.json', + '.git/config', + 'apps/server/.env', + 'apps/server/src/generated/client.ts', + 'apps/server/dist-test/result.js', + 'apps/admin/.env.local', + 'apps/admin/node_modules/secret.txt', + 'packages/ui/dist/index.js', + 'apps/docs/.vitepress/cache/leak.json', + 'scripts/private.pem', + 'docs/.local/token', + '.husky/_/husky.sh', + ]) + write(path, 'private data') + + write('apps/server/.env.example', 'DATABASE_URL=postgresql://example\n') + write('apps/server/.gitignore', '/src/generated/\n/dist-test/\n/.env.local\n') + write('apps/admin/.env.development', 'VITE_API_MOCK=true\n') + write( + 'packages/ui/src/new-uncommitted.ts', + 'export const uncommitted = true\n', + ) + write('__test__/cache/keep.spec.ts', 'export const regression = true\n') + write('apps/admin/src/utils/cache/index.ts', 'export const storage = true\n') + const { directory } = await exportDistribution(fixture, 'fullstack', { + archive: false, + }) + + expect(existsSync(join(directory, 'apps/server/.env.example'))).toBe(true) + expect(existsSync(join(directory, 'apps/server/.gitignore'))).toBe(true) + expect(existsSync(join(directory, 'apps/server/src/generated'))).toBe(false) + expect(existsSync(join(directory, 'apps/server/dist-test'))).toBe(false) + expect(existsSync(join(directory, 'apps/admin/.env.development'))).toBe(true) + expect( + existsSync(join(directory, 'packages/ui/src/new-uncommitted.ts')), + ).toBe(true) + expect(existsSync(join(directory, '__test__/cache/keep.spec.ts'))).toBe(true) + expect( + existsSync(join(directory, 'apps/admin/src/utils/cache/index.ts')), + ).toBe(true) + expect(existsSync(join(directory, 'apps/admin/.env.local'))).toBe(false) + expect(existsSync(join(directory, 'apps/server/.env'))).toBe(false) + expect(existsSync(join(directory, '.env'))).toBe(false) + expect(existsSync(join(directory, 'credentials.json'))).toBe(false) + expect(existsSync(join(directory, '.git'))).toBe(false) + expect(existsSync(join(directory, 'packages/ui/dist'))).toBe(false) + expect(existsSync(join(directory, 'scripts/private.pem'))).toBe(false) +}) + +it('validates exports read-only and supports frontend-only extracted projects', async () => { + const entries = readdirSync(fixture) + + expect(checkDistributions(fixture).map(({ edition }) => edition)).toEqual([ + 'frontend', + 'fullstack', + ]) + expect(readdirSync(fixture)).toEqual(entries) + + const { directory } = await exportDistribution(fixture, 'frontend', { + archive: false, + }) + + expect(checkDistributions(directory).map(({ edition }) => edition)).toEqual([ + 'frontend', + ]) + await expect( + exportDistribution(directory, 'fullstack', { archive: false }), + ).rejects.toThrow('Workspace dependency is missing') +}) + +it('refuses broken dependency graphs and missing lockfile importers', async () => { + write('packages/ui/package.json', { + name: '@ray-template/ui', + dependencies: { '@ray-template/server': 'workspace:*' }, + }) + expect(() => checkDistributions(fixture)).toThrow( + 'Frontend dependency reaches the server', + ) + expect(() => + pruneLockfile(lockfile(), new Set(['.', 'apps/missing'])), + ).toThrow('Workspace importer is missing') + expect(() => + pruneLockfile('lockfileVersion: 6\nimporters: {}', new Set()), + ).toThrow('version 9') +}) + +it('refuses credentials in package-manager config and malformed section markers', async () => { + write('.npmrc', '//registry.npmjs.org/:_authToken=do-not-export\n') + expect(() => checkDistributions(fixture)).toThrow('Credential-bearing .npmrc') + rmSync(join(fixture, '.npmrc')) + write('README.md', '\nMissing end\n') + expect(() => checkDistributions(fixture)).toThrow( + 'Unpaired fullstack section marker', + ) +}) + +it('replaces only recognized generated output and keeps artifact content reproducible', async () => { + const output = 'dist/distributions/ray-template-frontend-6.0.1' + + write(`${output}/keep.txt`, 'user data') + await expect( + exportDistribution(fixture, 'frontend', { archive: false }), + ).rejects.toThrow('unrecognized distribution') + expect(readFileSync(join(fixture, output, 'keep.txt'), 'utf8')).toBe( + 'user data', + ) + rmSync(join(fixture, output), { recursive: true }) + const first = await exportDistribution(fixture, 'frontend', { + archive: false, + }) + const second = await exportDistribution(fixture, 'frontend', { + archive: false, + }) + + expect(first.manifest.contentSha256).toBe(second.manifest.contentSha256) +}) + +it.skipIf(process.platform === 'win32')( + 'rejects existing and dangling output symlinks and source symlinks', + async () => { + const outside = mkdtempSync(join(tmpdir(), 'ray-distribution-outside-')) + + try { + symlinkSync(outside, join(fixture, 'dist'), 'dir') + await expect( + exportDistribution(fixture, 'frontend', { archive: false }), + ).rejects.toThrow('symlink') + expect(readdirSync(outside)).toEqual([]) + rmSync(join(fixture, 'dist')) + mkdirSync(join(fixture, 'dist/distributions'), { recursive: true }) + symlinkSync( + join(outside, 'new-file'), + join(fixture, 'dist/distributions/ray-template-frontend-6.0.1.tar.gz'), + ) + await expect(exportDistribution(fixture, 'frontend')).rejects.toThrow( + 'symlink', + ) + expect(existsSync(join(outside, 'new-file'))).toBe(false) + rmSync(join(fixture, 'dist'), { recursive: true }) + symlinkSync( + join(fixture, 'package.json'), + join(fixture, 'packages/ui/src/linked.json'), + ) + expect(() => checkDistributions(fixture)).toThrow('Source symlinks') + } finally { + rmSync(outside, { recursive: true, force: true }) + } + }, +) + +it('creates a portable archive containing one distribution root and its provenance', async () => { + const { archive } = await exportDistribution(fixture, 'frontend') + const result = spawnSync('tar', ['-tzf', archive!], { encoding: 'utf8' }) + + expect(result.status).toBe(0) + expect(result.stdout).toContain( + 'ray-template-frontend-6.0.1/distribution.json', + ) + expect(result.stdout).toContain( + 'ray-template-frontend-6.0.1/apps/admin/package.json', + ) + expect(result.stdout).not.toContain('apps/server') +}) diff --git a/__test__/hooks/useSiderBar.spec.ts b/__test__/hooks/useSiderBar.spec.ts index e5292379..7cc4984d 100644 --- a/__test__/hooks/useSiderBar.spec.ts +++ b/__test__/hooks/useSiderBar.spec.ts @@ -198,6 +198,59 @@ it('keeps status routes out of tabs and clears active business navigation', asyn } }) +it('removes shortcuts that lead through or to a route the current role cannot open', async () => { + const shortcuts = [ + { path: '/private-link', redirect: '/private', meta: {} }, + { + path: '/admin-link', + redirect: '/reports', + meta: { role: ['admin'] }, + }, + { path: '/via-admin', redirect: '/admin-link', meta: {} }, + { path: '/open-link', redirect: '/reports', meta: {} }, + ] + + for (const shortcut of shortcuts) router.addRoute(shortcut) + + state.routes = [...state.routes, ...shortcuts] + await menu.setupAppMenu() + expect(menu.options.map(({ fullPath }) => fullPath)).toContain('/via-admin') + + piniaSigningStore().signingCallback.role = 'member' + await flushPromises() + expect(menu.options.map(({ fullPath }) => fullPath)).toEqual([ + '/reports', + '/orders', + '/open-link', + ]) +}) + +it('closes the 403 view back to an allowed tab without storing a denied tab', async () => { + piniaSigningStore().signingCallback.role = 'member' + await router.push('/reports?sort=desc#summary') + await router.push('/private') + await flushPromises() + + expect(router.currentRoute.value.path).toBe('/403') + expect(actions.getCurrentTagIndex()).toBe(-1) + await actions.closeForbiddenPage() + await flushPromises() + + expect(router.currentRoute.value.fullPath).toBe('/reports?sort=desc#summary') + expect(menu.menuTagOptions.map(({ fullPath }) => fullPath)).toEqual([ + '/reports?sort=desc#summary', + ]) +}) + +it('closes a directly opened 403 to the workspace with no business tags', async () => { + await router.push('/403') + await actions.closeForbiddenPage() + await flushPromises() + + expect(router.currentRoute.value.path).toBe('/welcome') + expect(menu.menuTagOptions).toEqual([]) +}) + it('removes revoked tags and cached views without choosing another active page', async () => { await router.push('/reports') await router.push('/private?mode=edit#section') diff --git a/__test__/router/permission.spec.ts b/__test__/router/permission.spec.ts index a1823fd6..7e64b80b 100644 --- a/__test__/router/permission.spec.ts +++ b/__test__/router/permission.spec.ts @@ -21,8 +21,26 @@ function setupRouter(rootRole?: string[]) { { path: '/500', name: 'ErrorPage500', component }, { path: '/dashboard', component, meta: { role: rootRole } }, { path: '/allowed', component, meta: { role: ['admin'] } }, - { path: '/denied', component, meta: { role: ['editor'] } }, + { + path: '/denied', + alias: '/denied-alias', + component, + meta: { role: ['editor'] }, + }, { path: '/legacy', redirect: '/allowed' }, + { path: '/alias-shortcut', redirect: '/denied-alias' }, + { + path: '/private-shortcut', + redirect: '/allowed', + meta: { role: ['editor'] }, + }, + { path: '/via-private', redirect: '/private-shortcut' }, + { + path: '/restricted-group', + component, + meta: { role: ['editor'] }, + children: [{ path: 'page', component, meta: { role: ['admin'] } }], + }, { path: '/docs', name: 'RayTemplateDoc', @@ -83,6 +101,34 @@ describe('Router 5 permission guard', () => { expect(router.currentRoute.value.query.from).toBe('/denied') }) + it.each([ + '/alias-shortcut', + '/private-shortcut', + '/via-private', + '/restricted-group/page', + ])('blocks %s and keeps the attempted URL', async (path) => { + setStorage(APP_CATCH_KEY.token, 'demo-token', 'localStorage') + const router = setupRouter() + const attempted = `${path}?filter=open#row` + + await router.push(attempted) + + expect(router.currentRoute.value.path).toBe('/403') + expect(router.currentRoute.value.query.from).toBe(attempted) + }) + + it('retains a restricted redirect entry through sign-in for permission checking', async () => { + const router = setupRouter() + const attempted = '/via-private?source=link#report' + + await router.push(attempted) + expect(router.currentRoute.value.query.redirect).toBe(attempted) + setStorage(APP_CATCH_KEY.token, 'demo-token', 'localStorage') + expect( + resolveLandingPath(router, router.currentRoute.value.query.redirect), + ).toBe('/welcome') + }) + it('does not depend on the legacy dashboard being permitted', async () => { const router = setupRouter(['editor']) diff --git a/__test__/workspace/boundaries.spec.ts b/__test__/workspace/boundaries.spec.ts new file mode 100644 index 00000000..cd3b3ee3 --- /dev/null +++ b/__test__/workspace/boundaries.spec.ts @@ -0,0 +1,129 @@ +// @vitest-environment node +import { spawnSync } from 'node:child_process' +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join, resolve } from 'node:path' +import { afterEach, describe, expect, it } from 'vitest' + +const directories: string[] = [] +const checker = resolve('scripts/check-package-boundaries.mjs') + +function fixture() { + const root = mkdtempSync(join(tmpdir(), 'ray-boundaries-')) + + directories.push(root) + writeFileSync( + join(root, 'package.json'), + JSON.stringify({ version: '1.0.0' }), + ) + mkdirSync(join(root, 'apps')) + mkdirSync(join(root, 'packages')) + + return { + add( + group: string, + name: string, + runtime: string, + source = '', + dependencies = {}, + ) { + const directory = join(root, group, name) + + mkdirSync(directory) + writeFileSync( + join(directory, 'package.json'), + JSON.stringify({ + name: `@ray-template/${name}`, + version: '1.0.0', + rayTemplate: { runtime }, + exports: { '.': './index.ts' }, + dependencies, + }), + ) + writeFileSync(join(directory, 'index.ts'), source) + }, + check() { + const result = spawnSync(process.execPath, [checker, root], { + encoding: 'utf8', + }) + + return { status: result.status, output: result.stdout + result.stderr } + }, + } +} + +afterEach(() => { + for (const directory of directories.splice(0)) + rmSync(directory, { recursive: true, force: true }) +}) + +describe('workspace ownership', () => { + it('permits independent applications to share universal contracts', () => { + const project = fixture() + + project.add( + 'packages', + 'contracts', + 'universal', + 'export const version = 1', + ) + + for (const [name, runtime] of [ + ['admin', 'browser'], + ['server', 'server'], + ]) { + project.add( + 'apps', + name, + runtime, + "import { version } from '@ray-template/contracts'", + { '@ray-template/contracts': 'workspace:*' }, + ) + } + + expect(project.check().status).toBe(0) + }) + + it('rejects application dependencies even when their exports exist', () => { + const project = fixture() + + project.add('apps', 'server', 'server') + project.add('apps', 'admin', 'browser', '', { + '@ray-template/server': 'workspace:*', + }) + expect(project.check().output).toContain( + 'applications cannot be dependencies', + ) + }) + + it('rejects browser dependencies and Node builtins in universal packages', () => { + const project = fixture() + + project.add('packages', 'ui', 'browser') + project.add( + 'packages', + 'contracts', + 'universal', + "import fs from 'node:fs'", + { '@ray-template/ui': 'workspace:*' }, + ) + const result = project.check() + + expect(result.status).toBe(1) + expect(result.output).toContain('universal cannot depend on browser') + expect(result.output).toContain('node:fs') + }) + + it('rejects undeclared app imports and relative workspace escapes', () => { + const project = fixture() + + project.add( + 'apps', + 'admin', + 'browser', + "import missing from 'undeclared'\nimport other from '../server/index.ts'", + ) + expect(project.check().output).toContain('undeclared') + expect(project.check().output).toContain('../server/index.ts') + }) +}) diff --git a/apps/admin/package.json b/apps/admin/package.json index 1329840f..b24ddad5 100644 --- a/apps/admin/package.json +++ b/apps/admin/package.json @@ -38,6 +38,13 @@ "vue-i18n": "11.4.17", "vue-router": "5.4.0", "vue3-next-qrcode": "4.1.1", - "@ray-template/api-contracts": "workspace:*" + "@ray-template/api-contracts": "workspace:*", + "@ray-template/demo-data": "workspace:*" + }, + "rayTemplate": { + "runtime": "browser" + }, + "devDependencies": { + "vite": "8.3.5" } } diff --git a/apps/admin/public/contracts/admin-api.json b/apps/admin/public/contracts/admin-api.json index 9842a523..a4815f52 100644 --- a/apps/admin/public/contracts/admin-api.json +++ b/apps/admin/public/contracts/admin-api.json @@ -3036,8 +3036,13 @@ "get": { "operationId": "getRouteConfig", "summary": "getRouteConfig", - "description": "Session or public bootstrap endpoint.", - "security": [], + "description": "Public navigation snapshot. Request view=editor with routes:write to read the complete saved configuration, including disabled demo routes.", + "security": [ + {}, + { + "bearerAuth": [] + } + ], "responses": { "200": { "description": "Success", @@ -3125,7 +3130,17 @@ } } } - } + }, + "parameters": [ + { + "name": "view", + "in": "query", + "required": false, + "schema": { + "const": "editor" + } + } + ] }, "put": { "operationId": "updateRouteConfig", diff --git a/apps/admin/src/api/admin/index.ts b/apps/admin/src/api/admin/index.ts index a5b4d5c1..55309ac6 100644 --- a/apps/admin/src/api/admin/index.ts +++ b/apps/admin/src/api/admin/index.ts @@ -21,8 +21,11 @@ export const getAdminSession = () => adminRequest('auth/session', sessionSchema, { method: 'get' }) export const logoutAdmin = () => adminRequest('auth/logout', v.null(), { method: 'post' }) -export const getAdminRoutes = () => - adminRequest('route-config', routeConfigSchema, { method: 'get' }) +export const getAdminRoutes = (view?: 'editor') => + adminRequest('route-config', routeConfigSchema, { + method: 'get', + params: view ? { view } : void 0, + }) export const updateAdminRoutes = (config: RouteConfig) => adminRequest('route-config', routeConfigSchema, { method: 'put', diff --git a/apps/admin/src/demo-data/people.ts b/apps/admin/src/demo-data/people.ts index a907954d..4dea4675 100644 --- a/apps/admin/src/demo-data/people.ts +++ b/apps/admin/src/demo-data/people.ts @@ -1,52 +1,10 @@ -import type { PaginationResponse } from '@/types/modules/axios' -import { faker } from '@faker-js/faker/locale/zh_CN' -import type { Person, PersonListParams } from '@ray-template/api-contracts/demo' +import type { PersonListParams } from '@ray-template/api-contracts/demo' +import { listPeople as queryPeople } from '@ray-template/demo-data/people' export type { Person, PersonListParams } from '@ray-template/api-contracts/demo' -let people: Person[] | undefined +export const listPeople = (params: PersonListParams = {}) => { + const { items, total } = queryPeople(params) -export const listPeople = ({ - page, - pageSize, - email, - name, - sortAge, -}: PersonListParams = {}): PaginationResponse => { - // 同一会话内复用数据,让翻页和从上一页复制的搜索词都可重复使用。 - people ??= Array.from({ length: 100 }, () => ({ - id: faker.string.uuid(), - address: faker.location.state() + faker.location.city(), - email: faker.internet.email(), - name: faker.person.fullName(), - age: faker.number.int({ min: 18, max: 60 }), - createDate: faker.date.past().toISOString().slice(0, 10), - })) - - const emailQuery = email?.trim().toLowerCase() - const nameQuery = name?.trim().toLowerCase() - const matches = people.filter( - (person) => - (!emailQuery || person.email.toLowerCase().includes(emailQuery)) && - (!nameQuery || person.name.toLowerCase().includes(nameQuery)), - ) - - if (sortAge) { - const direction = sortAge === 'ascend' ? 1 : -1 - - matches.sort((left, right) => direction * (left.age - right.age)) - } - - const validPage = page !== void 0 && Number.isSafeInteger(page) && page > 0 - const validSize = - pageSize !== void 0 && Number.isSafeInteger(pageSize) && pageSize > 0 - const start = validPage && validSize ? (page - 1) * pageSize : 0 - - return { - code: 200, - msg: '请求成功', - data: - validPage && validSize ? matches.slice(start, start + pageSize) : matches, - total: matches.length, - } + return { code: 200, msg: '请求成功', data: items, total } } diff --git a/apps/admin/src/hooks/template/useSiderBar.ts b/apps/admin/src/hooks/template/useSiderBar.ts index 7f22c38e..0d8fdc30 100644 --- a/apps/admin/src/hooks/template/useSiderBar.ts +++ b/apps/admin/src/hooks/template/useSiderBar.ts @@ -1,4 +1,5 @@ -import { WELCOME_ROUTE_PATH } from '@/router/constant' +import { FORBIDDEN_ROUTE_PATH, WELCOME_ROUTE_PATH } from '@/router/constant' +import { resolveLandingPath } from '@/router/utils/resolve-landing-path' import { useMenuActions, useMenuGetters } from '@/store' import type { Key, MenuTagOptions } from '@/types' import { useVueRouter } from './useVueRouter' @@ -127,6 +128,21 @@ export function useSiderBar() { return router.replace(WELCOME_ROUTE_PATH) } + const closeForbiddenPage = () => { + if (router.currentRoute.value.path !== FORBIDDEN_ROUTE_PATH) return + + const previous = resolveLandingPath( + router, + router.options.history.state.back, + ) + const target = + previous === WELCOME_ROUTE_PATH + ? resolveLandingPath(router, getMenuTagOptions.value.at(-1)?.fullPath) + : previous + + return router.replace(target) + } + /** * * @param target 要保留的边界标签对象、索引或路径 @@ -193,6 +209,7 @@ export function useSiderBar() { return { close, closeAll, + closeForbiddenPage, closeRight, closeLeft, closeOther, diff --git a/apps/admin/src/layout/components/MenuTag/index.tsx b/apps/admin/src/layout/components/MenuTag/index.tsx index 957ba7a2..ed859a70 100644 --- a/apps/admin/src/layout/components/MenuTag/index.tsx +++ b/apps/admin/src/layout/components/MenuTag/index.tsx @@ -1,5 +1,6 @@ import { RIcon, RMoreDropdown } from '@/components' import { useI18n, useMaximize, useSiderBar, useSpinning } from '@/hooks' +import { FORBIDDEN_ROUTE_PATH } from '@/router/constant' import { useMenuActions, useMenuGetters, useRuntimeGetters } from '@/store' import type { AppMenuOption, MenuTagOptions } from '@/types' import { ShellTab } from '@ray-template/admin-shell' @@ -21,6 +22,9 @@ export default defineComponent({ setup(_, { expose }) { const scrollRef = useTemplateRef('scrollRef') const tagsRef = useTemplateRef('tags') + const actionsButton = useTemplateRef('actionsButton') + const route = useRoute() + const showingForbidden = computed(() => route.path === FORBIDDEN_ROUTE_PATH) const { t } = useI18n('menuTag') const { getCurrentMenuOption, getMenuTagOptions } = useMenuGetters() const getMenuKey = computed( @@ -31,6 +35,7 @@ export default defineComponent({ const { reload } = useSpinning() const { close, + closeForbiddenPage, closeAll: $closeAll, closeRight: $closeRight, closeLeft: $closeLeft, @@ -40,14 +45,27 @@ export default defineComponent({ } = useSiderBar() // 当前右键标签页索引位置 const currentContextmenuIndex = ref(-1) + const closeStatus = async (restoreFocus: boolean) => { + const navigation = closeForbiddenPage() + + if (!navigation || (await navigation) || !restoreFocus) return + + await nextTick() + const active = tagsRef.value?.querySelector( + '.menu-tag__tab[aria-current="page"]', + ) + const focus = active ?? actionsButton.value + + focus?.focus() + } // 下拉菜单 const moreOptions = computed(() => [ { label: t('closeCurrent'), key: 'closeCurrentPage', - disabled: !canClose( - getMenuTagOptions.value[currentContextmenuIndex.value], - ), + disabled: + !(showingForbidden.value && currentContextmenuIndex.value === -1) && + !canClose(getMenuTagOptions.value[currentContextmenuIndex.value]), icon: () => , }, { @@ -107,6 +125,9 @@ export default defineComponent({ ]) const actionMap = { closeCurrentPage: () => { + if (showingForbidden.value && currentContextmenuIndex.value === -1) + return closeStatus(true) + closeCurrentMenuTag(currentContextmenuIndex.value) }, reloadCurrentPage: () => { @@ -218,7 +239,7 @@ export default defineComponent({ const fn = actionMap[key as keyof typeof actionMap] - fn?.() + return fn?.() } // 右键点击标签页 @@ -284,6 +305,8 @@ export default defineComponent({ syncScroll, scrollRef, tagsRef, + showingForbidden, + closeStatus, actionDropdownSelect, actionState, menuTagContextMenu, @@ -389,6 +412,17 @@ export default defineComponent({ diff --git a/apps/admin/src/views/route-management/index.tsx b/apps/admin/src/views/route-management/index.tsx index 536c36c4..ba0769ab 100644 --- a/apps/admin/src/views/route-management/index.tsx +++ b/apps/admin/src/views/route-management/index.tsx @@ -1,6 +1,6 @@ import './index.scss' import AppPageHeader from '@/app-components/app/AppPageHeader' -import { useI18n } from '@/hooks' +import { useAccess, useI18n } from '@/hooks' import { getStaticAppRoutes } from '@/router/app-route-modules' import { exportRouteConfig, parseRouteConfig } from '@/router/config/contract' import type { RouteConfig } from '@/router/config/schema' @@ -32,6 +32,7 @@ export default defineComponent({ name: 'RouteManagement', setup() { const { t } = useI18n('routeManagement') + const { hasPermission } = useAccess() const source = ref(routeSourceStatus.requested) const draft = ref('') const checked = shallowRef() @@ -66,9 +67,6 @@ export default defineComponent({ } } - if (routeSourceStatus.config) setDraft(routeSourceStatus.config) - else loadStatic() - const validate = () => { try { const config = parseRouteConfig(draft.value) @@ -132,13 +130,22 @@ export default defineComponent({ busy.value = true try { - setDraft(await fetchRemoteRouteConfig()) + setDraft( + await fetchRemoteRouteConfig( + hasPermission('routes:write') ? 'editor' : void 0, + ), + ) } catch (reason) { report(reason) } finally { busy.value = false } } + + if (routeSourceStatus.active === 'remote') void loadRemote() + else if (routeSourceStatus.config) setDraft(routeSourceStatus.config) + else loadStatic() + const apply = async () => { if (busy.value) return diff --git a/apps/admin/src/views/route-management/visual.tsx b/apps/admin/src/views/route-management/visual.tsx index 2d40d076..533da6d0 100644 --- a/apps/admin/src/views/route-management/visual.tsx +++ b/apps/admin/src/views/route-management/visual.tsx @@ -48,6 +48,8 @@ export default defineComponent({ const { t } = useI18n('routeManagement') const { hasPermission } = useAccess() const saving = ref(false) + const loading = ref(false) + const loaded = ref(false) const text = (key: string) => t(key) const { t: translate } = useI18n() const records = ref([]) @@ -104,10 +106,14 @@ export default defineComponent({ valid.value = false } const load = async () => { + loading.value = true + try { const config = routeSourceStatus.active === 'remote' - ? await fetchRemoteRouteConfig() + ? await fetchRemoteRouteConfig( + hasPermission('routes:write') ? 'editor' : void 0, + ) : (routeSourceStatus.config ?? exportRouteConfig(getStaticAppRoutes())) @@ -115,8 +121,11 @@ export default defineComponent({ selected.value = tree.value.options[0]?.key as number | undefined expanded.value = [] clearResult() + loaded.value = true } catch (reason) { report(reason) + } finally { + loading.value = false } } @@ -138,7 +147,13 @@ export default defineComponent({ } } const apply = async () => { - if (saving.value || !hasPermission('routes:write')) return + if ( + !loaded.value || + loading.value || + saving.value || + !hasPermission('routes:write') + ) + return const config = validate() @@ -352,7 +367,9 @@ export default defineComponent({ type="primary" onClick={apply} loading={saving.value} - disabled={!hasPermission('routes:write')} + disabled={ + !loaded.value || loading.value || !hasPermission('routes:write') + } > {text('apply')} diff --git a/apps/docs/.vitepress/sidebar.mts b/apps/docs/.vitepress/sidebar.mts index ad4b389b..756edcfb 100644 --- a/apps/docs/.vitepress/sidebar.mts +++ b/apps/docs/.vitepress/sidebar.mts @@ -10,6 +10,7 @@ const guide = [ text: '入门', items: [ entry('快速开始', '/guide/start'), + entry('发行版本与快速启动', '/guide/distributions'), entry('v6 Monorepo 架构', '/guide/architecture'), entry('v5 与 v6 的版本分界', '/migration'), entry('第一个业务页面', '/guide/first-page'), diff --git a/apps/docs/guide/architecture.md b/apps/docs/guide/architecture.md index 5df2b844..1fd2cd09 100644 --- a/apps/docs/guide/architecture.md +++ b/apps/docs/guide/architecture.md @@ -7,26 +7,36 @@ ray-template/ ├── apps/ │ ├── admin/ # Ray Admin:登录、会话、路由和业务页面 │ └── docs/ # VitePress:指南、API 与交互示例 -├── packages/ # 两个应用共用的八个私有 workspace 包 +├── packages/ # 十个私有 workspace 包,按运行时边界复用 ├── harness/ # 任务入口与验收命令 └── pnpm-lock.yaml # 工作区共用锁文件 ``` ## 各包负责什么 -| 包 | 公开能力与使用方式 | -| --------------------------- | -------------------------------------------------------------------------------------------- | -| `@ray-template/utils` | 精度运算、对象和类型处理、文件工具、接收存储实现的 JSON 工具。精度运算从 `/precision` 导入。 | -| `@ray-template/composables` | 设备宽度、元素全屏、截图、打印和其他独立 Vue Hooks,例如 `/useElementFullscreen`。 | -| `@ray-template/directives` | 复制、防抖、节流、省略、水波纹等指令,可单独导入或统一注册。 | -| `@ray-template/icons` | SVG 资源、图标名称类型和资源查找。组件和路由配置使用同一套名称。 | -| `@ray-template/ui` | 组件、样式、主题与类型。通过 `/table-pro`、`/barcode` 或 `/chart` 等入口按需导入。 | -| `@ray-template/http` | `createHttpClient` 创建实例与独立的取消器。宿主提供地址、请求头和拦截器。 | -| `@ray-template/routing` | 路由 Schema、配置校验、路由展开和菜单处理。宿主提供页面注册表。 | -| `@ray-template/admin-shell` | 布局、顶部导航、标签、设置和路由过渡。宿主提供菜单、选中状态、偏好和内容。 | +| 包 | 公开能力与使用方式 | +| ----------------------------- | -------------------------------------------------------------------------------------------- | +| `@ray-template/utils` | 精度运算、对象和类型处理、文件工具、接收存储实现的 JSON 工具。精度运算从 `/precision` 导入。 | +| `@ray-template/composables` | 设备宽度、元素全屏、截图、打印和其他独立 Vue Hooks,例如 `/useElementFullscreen`。 | +| `@ray-template/directives` | 复制、防抖、节流、省略、水波纹等指令,可单独导入或统一注册。 | +| `@ray-template/icons` | SVG 资源、图标名称类型和资源查找。组件和路由配置使用同一套名称。 | +| `@ray-template/ui` | 组件、样式、主题与类型。通过 `/table-pro`、`/barcode` 或 `/chart` 等入口按需导入。 | +| `@ray-template/http` | `createHttpClient` 创建实例与独立的取消器。宿主提供地址、请求头和拦截器。 | +| `@ray-template/api-contracts` | 通用请求与响应、Valibot 校验、路由 Schema 和 OpenAPI;不依赖浏览器或服务端框架。 | +| `@ray-template/demo-data` | Mock 与后端演示共用的数据、查询辅助和初始路由,调用方决定是否启用。 | +| `@ray-template/routing` | 路由 Schema 兼容入口、浏览器路由展开和菜单处理。宿主提供页面注册表。 | +| `@ray-template/admin-shell` | 布局、顶部导航、标签、设置和路由过渡。宿主提供菜单、选中状态、偏好和内容。 | 共享包通过 `package.json` 的 `exports` 暴露入口,只依赖自己声明的包。`pnpm packages:check` 检查跨包导入和依赖循环。应用的登录、路由守卫、业务 API、Pinia 实例和语言加载由 `apps/admin` 负责。 +应用不能作为其他工作区的依赖;包通过 `rayTemplate.runtime` 标明 `browser`、`server` 或 `universal`。通用包只依赖通用包,浏览器与服务端通过 HTTP 和共享契约交互。路由 Schema 的权威来源是 `packages/api-contracts/src/routes.ts`,旧 routing 入口保留转导出。源码发行方式见[发行版本与快速启动](./distributions)。 + + + +可选的 `apps/server` 独立构建和运行,内部业务模块使用 NestJS、PostgreSQL 和 Redis。前端不会导入其控制器、数据库模型或配置。纯前端导出会移除整个服务端工作区及专属依赖。 + + + ## Ray Admin 怎么组装 `apps/admin/src/main.ts` 安装 Pinia、国际化、路由和指令。应用入口为组件提供主题、翻译、图标和列偏好存储,路由层把注册的页面交给后台外壳。登录、角色和会话由应用处理,真实业务的服务端负责接口授权。 diff --git a/apps/docs/guide/backend.md b/apps/docs/guide/backend.md index 2fa7abd8..fcbbe88c 100644 --- a/apps/docs/guide/backend.md +++ b/apps/docs/guide/backend.md @@ -1,6 +1,6 @@ # 服务端接入与标准契约 -登录、会话、用户管理与路由管理使用同一套 HTTP API。开发环境与静态在线演示都由 MSW 在网络层模拟响应;页面和 Store 不直接读取 Mock 数据库。接入自有服务端时,保留页面与调用方法,替换接口地址和实现即可。 +登录、会话、用户管理与路由管理使用同一套 HTTP API。源码发行和启动方式见[发行版本与快速启动](./distributions)。开发环境与静态在线演示都由 MSW 在网络层模拟响应;页面和 Store 不直接读取 Mock 数据库。接入自有服务端时,保留页面与调用方法,替换接口地址和实现即可。 -正常启动从 `GET /admin/route-config` 读取版本化路由 JSON,按 `meta.order` 排序;路由树用于菜单与面包屑,页面记录展开后注册到 Vue Router。Mock 的初始路由表位于 `apps/admin/src/mocks/data/routes.json`,前端只保留组件 ID 注册表和外壳必需路由。默认使用 hash 路由,例如 `/ray-template/#/orders`。 +正常启动从 `GET /admin/route-config` 读取版本化路由 JSON,按 `meta.order` 排序;路由树用于菜单与面包屑,页面记录展开后注册到 Vue Router。Mock 的初始路由表位于 `packages/demo-data/src/routes.json`,前端只保留组件 ID 注册表和外壳必需路由。默认使用 hash 路由,例如 `/ray-template/#/orders`。 ## 路由配置交互校验 @@ -36,11 +36,11 @@ import RouteConfigDemo from '../examples/RouteConfigDemo.vue' | `ignoreAutoResetScroll` | 允许页面保留内容区滚动位置,详见滚动工具实现。 | | `extra` | 菜单标记的文本、图标、类型和显隐,见 [useBadge](../reference/hooks/navigation#usebadge)。 | -嵌套子路由使用相对路径时会继承父路径。内置示例按用途分组,并以绝对路径保留原有页面地址。查看 [布局与路由示例](https://github.com/XiaoDaiGua-Ray/ray-template/blob/main/apps/admin/src/mocks/data/routes.json) 里的分组及多级菜单。 +嵌套子路由使用相对路径时会继承父路径。内置示例按用途分组,并以绝对路径保留原有页面地址。查看 [布局与路由示例](https://github.com/XiaoDaiGua-Ray/ray-template/blob/main/packages/demo-data/src/routes.json) 里的分组及多级菜单。 ## 登录和角色 -默认登录页为 `/`。无会话访问业务地址时,守卫将完整地址放入登录页的 `redirect` 参数;登录后仅恢复当前角色仍有权限的已注册业务地址,保留 query 和 hash。没有有效目标时进入 `/welcome`,不会自动选择仪表盘或第一个菜单。菜单隐藏的页面仍可能允许直达。接入真实业务时,在后端校验会话、权限和资源归属。 +默认登录页为 `/`。无会话访问业务地址时,守卫将完整地址放入登录页的 `redirect` 参数;登录后仅恢复当前角色仍有权限的已注册业务地址,保留 query 和 hash。没有有效目标时进入 `/welcome`,不会自动选择仪表盘或第一个菜单。对重定向路由,菜单和守卫都会检查入口、各级跳转和最终目标的权限。菜单隐藏的页面仍可能允许直达。接入真实业务时,在后端校验会话、权限和资源归属。 ## 空工作区和状态页 @@ -48,7 +48,7 @@ import RouteConfigDemo from '../examples/RouteConfigDemo.vue' 所有业务标签都可以关闭,包括原首页和最后一项。关闭当前标签后切换到相邻项;关闭最后一项或全部标签进入空工作区,同时释放对应 KeepAlive 缓存。一个具体 pathname 保留一个标签,查询参数或片段变化会更新标签保存的完整地址。角色变化后,失去权限的标签与缓存会被移除,不会自动激活其他业务页。 -- `/403`:已登录,但当前页面无权限。 +- `/403`:已登录,但当前页面无权限。页签栏的「关闭当前页面」会返回仍有权限的上一页或已打开页签,没有可恢复的页面时回到工作区。 - `/404`:目标页面不存在;原始目标保留在 `query.from`。 - `/500`:路由解析或页面懒加载失败;只对仍存在且允许访问的 `query.from` 显示重试。 diff --git a/apps/docs/guide/start.md b/apps/docs/guide/start.md index 819a93c2..f98d0dcd 100644 --- a/apps/docs/guide/start.md +++ b/apps/docs/guide/start.md @@ -2,6 +2,8 @@ 本文使用 Ray Template v6。v5 项目请先查看[版本分界](../migration)。 +可以选择独立的纯前端源码发行包;完整源码还提供可选的后端接入流程,见[发行版本与快速启动](./distributions)。 + ## 启动工作台 准备 Node.js 26.13.0 和 pnpm 12.16.1。以下以 nvm 为例: diff --git a/apps/docs/package.json b/apps/docs/package.json index ed42949e..b73b1dfc 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -26,5 +26,8 @@ "sass": "1.107.1", "vite": "6.4.5", "vitepress": "1.6.4" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/apps/docs/public/contracts/admin-api.json b/apps/docs/public/contracts/admin-api.json index 9842a523..a4815f52 100644 --- a/apps/docs/public/contracts/admin-api.json +++ b/apps/docs/public/contracts/admin-api.json @@ -3036,8 +3036,13 @@ "get": { "operationId": "getRouteConfig", "summary": "getRouteConfig", - "description": "Session or public bootstrap endpoint.", - "security": [], + "description": "Public navigation snapshot. Request view=editor with routes:write to read the complete saved configuration, including disabled demo routes.", + "security": [ + {}, + { + "bearerAuth": [] + } + ], "responses": { "200": { "description": "Success", @@ -3125,7 +3130,17 @@ } } } - } + }, + "parameters": [ + { + "name": "view", + "in": "query", + "required": false, + "schema": { + "const": "editor" + } + } + ] }, "put": { "operationId": "updateRouteConfig", diff --git a/apps/docs/reference/table-pro-examples.md b/apps/docs/reference/table-pro-examples.md index ae3fbd5c..d17334da 100644 --- a/apps/docs/reference/table-pro-examples.md +++ b/apps/docs/reference/table-pro-examples.md @@ -68,7 +68,7 @@ import AdminExample from '../examples/AdminExample.vue' <<< ../../admin/src/api/demo/data.ts -<<< ../../admin/src/mocks/data/orders.ts +<<< ../../../packages/demo-data/src/orders.ts ::: ## 自适应高度与虚拟滚动 diff --git a/apps/server/.gitignore b/apps/server/.gitignore new file mode 100644 index 00000000..0d23dcbe --- /dev/null +++ b/apps/server/.gitignore @@ -0,0 +1,4 @@ +/dist/ +/dist-test/ +/src/generated/ +/.env.local diff --git a/apps/server/README.md b/apps/server/README.md new file mode 100644 index 00000000..77c43a1f --- /dev/null +++ b/apps/server/README.md @@ -0,0 +1,52 @@ +# Ray Template server + +An optional NestJS application implementing the shared admin HTTP contract. It owns PostgreSQL persistence and API authorization. Browser applications consume the contract package, not this application or Prisma models. + +## Runtime and configuration + +Use the repository's pinned Node.js and pnpm versions. PostgreSQL and Redis must be reachable before starting the server. Configuration is loaded from `apps/server/.env.local` by the development, start and credential scripts. The Prisma config loads the same file for migrations. The root fullstack setup command prepares local development configuration. + +Required connection fields are `DATABASE_URL` and `REDIS_URL`. Keep credentials in local environment files or a deployment secret store; never in `VITE_*` variables. See [platform configuration](src/platform/README.md) for exact origin allowlists, trusted proxies, rate limits, logging and readiness settings. + +```sh +pnpm --filter @ray-template/server db:migrate +pnpm --filter @ray-template/server db:seed +pnpm --filter @ray-template/server dev +``` + +Initialization requires `ADMIN_PASSWORD` (12–128 characters) when creating the first account. `ADMIN_USERNAME` defaults to `admin`; `ADMIN_EMAIL` is optional. There is no built-in login password and no HTTP database reset endpoint. Re-running the seed preserves existing users, credentials, role assignments, permission assignments and route configuration. + +## API and ownership + +The API prefix is `/api`. Controllers provide `/admin/auth/login`, `/admin/auth/session`, `/admin/auth/logout`, `/admin/users`, user options/status/batch deletion, and `/admin/route-config`. Success responses use `{ code: 200, msg: 'OK', data }`; failures return the corresponding HTTP status with `data: null` and a stable `error.key`. + +The startup route configuration is public because the admin application needs it before login. `GET /admin/route-config?view=editor` and route writes require `routes:write`; writes use the same semantic validator and generated view/icon catalog as the frontend. Protected core endpoints require an active server session. The global guard enforces endpoint permissions; mutation services recheck the actor and targets inside serializable transactions. + +When `DEMO_ENABLED=true`, the public `/admin/demo/*` endpoints use the same fixture queries as Mock. Redis caches only the fixed request and chart fixtures and the two search-option locales for five minutes. In production demos default to off: these endpoints are absent and the public route configuration omits demo views, empty groups and redirects that would point to hidden views. The authorized editor still receives the complete saved configuration. + +Usernames and email addresses have normalized unique database keys. Department queries include descendants. Bulk updates and deletion are atomic, deduplicate IDs, and reject changes to missing/protected targets. A user cannot delete or disable their own account or change their own role. Non-admin actors cannot manage roles with permissions they do not hold. + +Authentication uses random opaque bearer tokens. Only SHA-256 token digests are stored; authorization reads current account status and role permissions from PostgreSQL on every request. Passwords use salted Node.js scrypt. Expired sessions are rejected; logout, credential reset, account disabling and role changes revoke effective access. Mutations and authentication changes write audit records without passwords, tokens or request bodies. + +New users created through the profile API have no password. Set or reset one explicitly through the credential command using environment variables, not command-line password arguments: + +```sh +pnpm --filter @ray-template/server credential:set +``` + +This command reads `CREDENTIAL_USERNAME` and `CREDENTIAL_PASSWORD`, preserves account status/role, and revokes all sessions for that user. Remove temporary credential variables from local files after use. Expired sessions can be pruned with `node --env-file-if-exists=.env.local dist/cli.mjs cleanup-sessions` from this application directory. + +The initial browser integration preserves the existing Bearer contract. Moving browser credentials to HttpOnly cookies requires a coordinated login-contract, request-client and CSRF change; it is not implied by enabling the backend. + +## Build and checks + +```sh +pnpm --filter @ray-template/server check +pnpm --filter @ray-template/server test:integration +``` + +`check` generates the Prisma client, type-checks, runs unit/platform tests, and bundles production entry points. The bundler includes workspace TypeScript source; npm runtime dependencies remain external. Production runs `dist/main.mjs` with this application's installed dependencies. + +Integration tests require `TEST_DATABASE_URL` and `TEST_REDIS_URL` pointing to disposable services. They create an isolated random PostgreSQL schema, apply the checked-in migration SQL, exercise HTTP requests against Nest, and drop only that schema afterward. Redis counters use a unique test prefix and expire. Tests never reset the configured database. They cover authorization, uniqueness, transaction atomicity, credential/session invalidation, route validation, restart persistence and repeatable initialization. The unit command does not claim that PostgreSQL integration passed. + +Database migrations are explicit deployment operations; starting the HTTP server does not migrate or reseed data. Deployments must provide TLS at the proxy, database backups, bounded log retention and reviewed trusted proxy settings. Readiness depends on both PostgreSQL and Redis; rate-limit failures deny protected API traffic rather than bypassing throttling. diff --git a/apps/server/package.json b/apps/server/package.json new file mode 100644 index 00000000..d61bb99b --- /dev/null +++ b/apps/server/package.json @@ -0,0 +1,52 @@ +{ + "name": "@ray-template/server", + "version": "6.0.1", + "private": true, + "type": "module", + "scripts": { + "dev": "node --env-file-if-exists=.env.local scripts/build.mjs --watch", + "build": "pnpm db:generate && node scripts/build.mjs", + "start": "node --env-file-if-exists=.env.local dist/main.mjs", + "typecheck": "pnpm db:generate && tsc --noEmit", + "test": "pnpm db:generate && node scripts/build.mjs --tests && node --test dist-test/unit.test.mjs dist-test/platform.test.mjs", + "test:integration": "pnpm db:generate && node scripts/build.mjs --tests && node --test dist-test/integration.test.mjs", + "check": "pnpm typecheck && pnpm test && pnpm build", + "db:generate": "prisma generate", + "db:migrate": "prisma migrate deploy", + "db:seed": "pnpm build && node --env-file-if-exists=.env.local dist/cli.mjs seed", + "credential:set": "pnpm build && node --env-file-if-exists=.env.local dist/cli.mjs password" + }, + "dependencies": { + "@faker-js/faker": "10.6.0", + "@nestjs/common": "12.3.3", + "@nestjs/core": "12.3.3", + "@nestjs/platform-express": "12.3.3", + "@prisma/adapter-pg": "7.10.1", + "@prisma/client": "7.10.1", + "@ray-template/api-contracts": "workspace:*", + "@ray-template/demo-data": "workspace:*", + "pg": "8.23.1", + "redis": "6.3.1", + "reflect-metadata": "0.2.2", + "rxjs": "7.8.2", + "valibot": "1.5.0", + "express": "5.3.0" + }, + "devDependencies": { + "@types/express": "5.0.6", + "@types/node": "26.6.6", + "@types/pg": "8.23.1", + "esbuild": "0.28.2", + "prisma": "7.10.1", + "typescript": "6.0.3" + }, + "rayTemplate": { + "runtime": "server" + }, + "files": [ + "dist", + "prisma", + "prisma.config.ts", + "README.md" + ] +} diff --git a/apps/server/prisma.config.ts b/apps/server/prisma.config.ts new file mode 100644 index 00000000..46ce71e1 --- /dev/null +++ b/apps/server/prisma.config.ts @@ -0,0 +1,15 @@ +import { existsSync } from 'node:fs' +import { loadEnvFile } from 'node:process' +import { defineConfig } from 'prisma/config' + +const envFile = new URL('.env.local', import.meta.url) + +if (existsSync(envFile)) loadEnvFile(envFile) + +export default defineConfig({ + schema: 'prisma/schema.prisma', + migrations: { path: 'prisma/migrations' }, + datasource: { + url: process.env.DATABASE_URL ?? 'postgresql://127.0.0.1/ray_template', + }, +}) diff --git a/apps/server/prisma/migrations/20261106000000_admin/migration.sql b/apps/server/prisma/migrations/20261106000000_admin/migration.sql new file mode 100644 index 00000000..57a8dcf3 --- /dev/null +++ b/apps/server/prisma/migrations/20261106000000_admin/migration.sql @@ -0,0 +1,68 @@ +CREATE TABLE "Department" ( + "id" TEXT PRIMARY KEY, + "parentId" TEXT REFERENCES "Department"("id") ON DELETE RESTRICT, + "name" TEXT NOT NULL, + "labelKey" TEXT +); +CREATE INDEX "Department_parentId_idx" ON "Department"("parentId"); +CREATE TABLE "Role" ( + "value" TEXT PRIMARY KEY, + "label" TEXT NOT NULL, + "labelKey" TEXT +); +CREATE TABLE "Permission" ("code" TEXT PRIMARY KEY); +CREATE TABLE "RolePermission" ( + "roleValue" TEXT NOT NULL REFERENCES "Role"("value") ON DELETE CASCADE, + "permissionCode" TEXT NOT NULL REFERENCES "Permission"("code") ON DELETE CASCADE, + PRIMARY KEY ("roleValue", "permissionCode") +); +CREATE TABLE "User" ( + "id" TEXT PRIMARY KEY, + "username" TEXT NOT NULL, + "usernameKey" TEXT NOT NULL, + "name" TEXT NOT NULL, + "email" TEXT NOT NULL, + "emailKey" TEXT NOT NULL, + "phone" TEXT NOT NULL DEFAULT '', + "departmentId" TEXT NOT NULL REFERENCES "Department"("id") ON DELETE RESTRICT, + "role" TEXT NOT NULL REFERENCES "Role"("value") ON DELETE RESTRICT, + "status" TEXT NOT NULL DEFAULT 'enabled', + "remark" TEXT NOT NULL DEFAULT '', + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(3) NOT NULL, + CONSTRAINT "User_status_check" CHECK ("status" IN ('enabled', 'disabled')), + CONSTRAINT "User_usernameKey_check" CHECK ("usernameKey" = lower("username")), + CONSTRAINT "User_emailKey_check" CHECK ("emailKey" = lower("email")) +); +CREATE UNIQUE INDEX "User_usernameKey_key" ON "User"("usernameKey"); +CREATE UNIQUE INDEX "User_emailKey_key" ON "User"("emailKey"); +CREATE INDEX "User_departmentId_idx" ON "User"("departmentId"); +CREATE INDEX "User_role_status_idx" ON "User"("role", "status"); +CREATE TABLE "Credential" ( + "userId" TEXT PRIMARY KEY REFERENCES "User"("id") ON DELETE CASCADE, + "passwordHash" TEXT NOT NULL, + "updatedAt" TIMESTAMPTZ(3) NOT NULL +); +CREATE TABLE "Session" ( + "tokenHash" TEXT PRIMARY KEY, + "userId" TEXT NOT NULL REFERENCES "User"("id") ON DELETE CASCADE, + "expiresAt" TIMESTAMPTZ(3) NOT NULL, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP +); +CREATE INDEX "Session_userId_idx" ON "Session"("userId"); +CREATE INDEX "Session_expiresAt_idx" ON "Session"("expiresAt"); +CREATE TABLE "RouteConfig" ( + "id" TEXT PRIMARY KEY, + "config" JSONB NOT NULL, + "updatedAt" TIMESTAMPTZ(3) NOT NULL +); +CREATE TABLE "AuditLog" ( + "id" TEXT PRIMARY KEY, + "actorId" TEXT, + "action" TEXT NOT NULL, + "resourceId" TEXT, + "requestId" TEXT, + "createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP +); +CREATE INDEX "AuditLog_createdAt_idx" ON "AuditLog"("createdAt"); +CREATE INDEX "AuditLog_actorId_createdAt_idx" ON "AuditLog"("actorId", "createdAt"); diff --git a/apps/server/prisma/migrations/migration_lock.toml b/apps/server/prisma/migrations/migration_lock.toml new file mode 100644 index 00000000..2fe25d87 --- /dev/null +++ b/apps/server/prisma/migrations/migration_lock.toml @@ -0,0 +1 @@ +provider = "postgresql" diff --git a/apps/server/prisma/schema.prisma b/apps/server/prisma/schema.prisma new file mode 100644 index 00000000..07c769cb --- /dev/null +++ b/apps/server/prisma/schema.prisma @@ -0,0 +1,101 @@ +generator client { + provider = "prisma-client" + output = "../src/generated/prisma" +} + +datasource db { + provider = "postgresql" +} + +model Department { + id String @id + parentId String? + name String + labelKey String? + parent Department? @relation("DepartmentTree", fields: [parentId], references: [id], onDelete: Restrict) + children Department[] @relation("DepartmentTree") + users User[] + + @@index([parentId]) +} + +model Role { + value String @id + label String + labelKey String? + permissions RolePermission[] + users User[] +} + +model Permission { + code String @id + roles RolePermission[] +} + +model RolePermission { + roleValue String + permissionCode String + role Role @relation(fields: [roleValue], references: [value], onDelete: Cascade) + permission Permission @relation(fields: [permissionCode], references: [code], onDelete: Cascade) + + @@id([roleValue, permissionCode]) +} + +model User { + id String @id @default(uuid()) + username String + usernameKey String @unique + name String + email String + emailKey String @unique + phone String @default("") + departmentId String + role String + status String @default("enabled") + remark String @default("") + createdAt DateTime @default(now()) @db.Timestamptz(3) + updatedAt DateTime @updatedAt @db.Timestamptz(3) + department Department @relation(fields: [departmentId], references: [id], onDelete: Restrict) + roleRecord Role @relation(fields: [role], references: [value], onDelete: Restrict) + credential Credential? + sessions Session[] + + @@index([departmentId]) + @@index([role, status]) +} + +model Credential { + userId String @id + passwordHash String + updatedAt DateTime @updatedAt @db.Timestamptz(3) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) +} + +model Session { + tokenHash String @id + userId String + expiresAt DateTime @db.Timestamptz(3) + createdAt DateTime @default(now()) @db.Timestamptz(3) + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + + @@index([userId]) + @@index([expiresAt]) +} + +model RouteConfig { + id String @id + config Json + updatedAt DateTime @updatedAt @db.Timestamptz(3) +} + +model AuditLog { + id String @id @default(uuid()) + actorId String? + action String + resourceId String? + requestId String? + createdAt DateTime @default(now()) @db.Timestamptz(3) + + @@index([createdAt]) + @@index([actorId, createdAt]) +} diff --git a/apps/server/scripts/build.mjs b/apps/server/scripts/build.mjs new file mode 100644 index 00000000..b73badb3 --- /dev/null +++ b/apps/server/scripts/build.mjs @@ -0,0 +1,104 @@ +import { spawn } from 'node:child_process' +import { fileURLToPath } from 'node:url' +import { build, context } from 'esbuild' + +const tests = process.argv.includes('--tests') +const watch = process.argv.includes('--watch') +const options = { + absWorkingDir: fileURLToPath(new URL('../', import.meta.url)), + entryPoints: tests + ? { + 'unit.test': 'test/unit.test.ts', + 'integration.test': 'test/integration.test.ts', + 'platform.test': 'test/platform.test.ts', + } + : { main: 'src/main.ts', cli: 'src/cli.ts' }, + outdir: tests ? 'dist-test' : 'dist', + outExtension: { '.js': '.mjs' }, + bundle: true, + platform: 'node', + format: 'esm', + target: 'node26', + packages: 'external', + sourcemap: true, + tsconfig: 'tsconfig.json', + plugins: [ + { + name: 'workspace-source', + setup(builder) { + // workspace 包导出源码;服务端产物内联这些入口,运行时只加载 npm 依赖。 + builder.onResolve({ filter: /^@ray-template\// }, (args) => ({ + path: fileURLToPath(import.meta.resolve(args.path)), + external: false, + })) + }, + }, + ], +} + +if (watch) { + let child + let stopping = false + const stopChild = async () => { + const running = child + + child = void 0 + + if (!running || running.exitCode !== null || running.signalCode !== null) + return + + await new Promise((resolve) => { + const timeout = setTimeout(() => running.kill('SIGKILL'), 5000) + + running.once('exit', () => { + clearTimeout(timeout) + resolve() + }) + running.kill('SIGTERM') + }) + } + + options.plugins.push({ + name: 'restart-server', + setup(builder) { + builder.onEnd(async (result) => { + if (result.errors.length || stopping) return + + await stopChild() + + if (stopping) return + + const running = spawn(process.execPath, ['dist/main.mjs'], { + cwd: options.absWorkingDir, + stdio: 'inherit', + env: process.env, + }) + + child = running + const failed = (code) => { + if (child === running && !stopping) { + process.exitCode = code || 1 + void close() + } + } + + running.once('error', () => failed(1)) + running.once('exit', failed) + }) + }, + }) + const watcher = await context(options) + const close = async () => { + if (stopping) return + + stopping = true + await watcher.dispose() + await stopChild() + } + + process.once('SIGINT', () => void close()) + process.once('SIGTERM', () => void close()) + await watcher.watch() +} else { + await build(options) +} diff --git a/apps/server/src/app.ts b/apps/server/src/app.ts new file mode 100644 index 00000000..ef476adc --- /dev/null +++ b/apps/server/src/app.ts @@ -0,0 +1,65 @@ +import 'reflect-metadata' +import { Module } from '@nestjs/common' +import type { DynamicModule } from '@nestjs/common' +import { NestFactory } from '@nestjs/core' +import type { NestExpressApplication } from '@nestjs/platform-express' +import { ApiExceptionFilter, EnvelopeInterceptor } from './http' +import { DatabaseModule, DatabaseService } from './infrastructure/database' +import { AuthModule } from './modules/auth/auth.module' +import { DemoController } from './modules/demo/demo.controller' +import { RoutesModule } from './modules/routes/routes.module' +import { UsersModule } from './modules/users/users.module' +import { loadServerConfig, PlatformRuntime } from './platform/index' +import type { LogSink, ServerConfig } from './platform/index' +import { PlatformLifecycle } from './platform/lifecycle' + +@Module({}) +export class AppModule { + static register(config: ServerConfig): DynamicModule { + return { + module: AppModule, + imports: [ + DatabaseModule.register(config), + AuthModule, + UsersModule, + RoutesModule, + ], + controllers: config.demoEnabled ? [DemoController] : [], + providers: [PlatformLifecycle], + } + } +} + +export async function createApp( + config: ServerConfig = loadServerConfig(), + options: { logSink?: LogSink } = {}, +) { + const app = await NestFactory.create( + AppModule.register(config), + { + logger: false, + bodyParser: false, + abortOnError: false, + }, + ) + + try { + const database = app.get(DatabaseService) + const runtime = await PlatformRuntime.create(config, { + checkDatabase: () => database.ping(), + logSink: options.logSink, + }) + + app.get(PlatformLifecycle).runtime = runtime + runtime.install(app) + app.setGlobalPrefix('api') + app.useGlobalInterceptors(new EnvelopeInterceptor()) + app.useGlobalFilters(new ApiExceptionFilter()) + await app.init() + + return app + } catch (error) { + await app.close() + throw error + } +} diff --git a/apps/server/src/cli.ts b/apps/server/src/cli.ts new file mode 100644 index 00000000..c4866c25 --- /dev/null +++ b/apps/server/src/cli.ts @@ -0,0 +1,52 @@ +import { createDatabase } from './infrastructure/database' +import { loadServerConfig } from './platform/index' +import { seedDatabase, setPassword } from './seed' + +const config = loadServerConfig() +const database = createDatabase(config.databaseUrl) +const command = process.argv[2] + +try { + if (command === 'seed') { + const result = await seedDatabase(database, { + username: process.env.ADMIN_USERNAME, + email: process.env.ADMIN_EMAIL, + password: process.env.ADMIN_PASSWORD, + }) + + console.log( + result.created + ? 'Administrator initialized.' + : 'Existing administrator preserved.', + ) + } else if (command === 'password') { + const username = process.argv[3] ?? process.env.CREDENTIAL_USERNAME + const password = process.env.CREDENTIAL_PASSWORD + + if (!username || !password) + throw new Error( + 'Set CREDENTIAL_USERNAME and CREDENTIAL_PASSWORD before running credential:set.', + ) + + await setPassword(database, username, password) + console.log('Credential updated and active sessions revoked.') + } else if (command === 'cleanup-sessions') { + const result = await database.session.deleteMany({ + where: { expiresAt: { lte: new Date() } }, + }) + + console.log(`Removed ${result.count} expired sessions.`) + } else { + throw new Error('Use seed, password, or cleanup-sessions.') + } +} catch (error) { + // Prisma 错误可能包含连接信息和参数;命令行只输出预期的操作错误。 + console.error( + error instanceof Error && error.name === 'Error' && !('code' in error) + ? error.message + : 'Database operation failed.', + ) + process.exitCode = 1 +} finally { + await database.$disconnect() +} diff --git a/apps/server/src/config.ts b/apps/server/src/config.ts new file mode 100644 index 00000000..1612c8d2 --- /dev/null +++ b/apps/server/src/config.ts @@ -0,0 +1 @@ +export const SERVER_CONFIG = Symbol('SERVER_CONFIG') diff --git a/apps/server/src/http.ts b/apps/server/src/http.ts new file mode 100644 index 00000000..b2e1361c --- /dev/null +++ b/apps/server/src/http.ts @@ -0,0 +1,151 @@ +import { Catch, HttpException, Injectable } from '@nestjs/common' +import type { + ArgumentsHost, + CallHandler, + ExceptionFilter, + ExecutionContext, + NestInterceptor, +} from '@nestjs/common' +import type { ApiResponse } from '@ray-template/api-contracts/admin' +import type { Request, Response } from 'express' +import { map } from 'rxjs' +import * as v from 'valibot' +import { standardLogSink, writeLog } from './platform/index' + +export class ApiError extends Error { + constructor( + readonly status: number, + readonly key: string, + ) { + super(key) + } +} + +export function parseInput( + schema: S, + input: unknown, +) { + const parsed = v.safeParse(schema, input) + + if (!parsed.success) throw new ApiError(400, 'invalid') + + return parsed.output +} + +export function tokenFrom(request: Request) { + const header = request.headers.authorization + + return /^Bearer [A-Za-z0-9_-]{32,128}$/u.test(header ?? '') + ? header!.slice(7) + : null +} + +export function requestIdFrom(request: Request) { + const id = request.res?.getHeader('x-request-id') + + return typeof id === 'string' ? id : null +} + +export function queryInput(query: Request['query'], booleans: string[] = []) { + const values: Record = { ...query } + + for (const key of ['page', 'pageSize']) { + if (key in values) { + if (typeof values[key] !== 'string' || !/^\d+$/u.test(values[key])) + throw new ApiError(400, 'invalid') + + values[key] = Number(values[key]) + + if (!Number.isSafeInteger(values[key])) throw new ApiError(400, 'invalid') + } + } + + for (const key of booleans) { + if (values[key] === 'true') values[key] = true + else if (values[key] === 'false') values[key] = false + } + + return values +} + +@Injectable() +export class EnvelopeInterceptor implements NestInterceptor { + intercept(context: ExecutionContext, next: CallHandler) { + const response = context.switchToHttp().getResponse() + + response.status(200) + + return next.handle().pipe( + map((data: unknown): ApiResponse => ({ + code: 200, + msg: 'OK', + data: data ?? null, + })), + ) + } +} + +@Catch() +export class ApiExceptionFilter implements ExceptionFilter { + catch(error: unknown, host: ArgumentsHost) { + const response = host.switchToHttp().getResponse() + + if (response.headersSent) return + + let status = 500 + let key = 'internal' + + if (error instanceof ApiError) { + status = error.status + key = error.key + } else if (error instanceof HttpException) { + status = error.getStatus() + key = + { + 400: 'invalid', + 401: 'unauthorized', + 403: 'forbidden', + 404: 'notFound', + 413: 'invalid', + 429: 'tooManyRequests', + 503: 'serviceUnavailable', + }[status] ?? 'requestFailed' + } else if (error instanceof Error && 'code' in error) { + if (error.code === 'P2002') { + const meta = 'meta' in error ? error.meta : null + const target = JSON.stringify(meta) + + status = 409 + key = target?.includes('email') ? 'duplicateEmail' : 'duplicateUsername' + } else if (error.code === 'P2025') { + status = 404 + key = 'notFound' + } else if (error.code === 'P2003') { + status = 400 + key = 'invalid' + } else if (/^P10|^P20/u.test(String(error.code))) { + status = 503 + key = 'storage' + } + } + + if (status >= 500) { + const code = + error instanceof Error && + 'code' in error && + /^P\d{4}$/u.test(String(error.code)) + ? String(error.code) + : 'UNEXPECTED_ERROR' + + writeLog(standardLogSink, 'error', 'http.exception', { + requestId: String(response.getHeader('x-request-id') ?? ''), + code, + statusCode: status, + }) + } + + response + .status(status) + .json({ code: status, msg: key, data: null, error: { key } }) + } +} diff --git a/apps/server/src/infrastructure/database.ts b/apps/server/src/infrastructure/database.ts new file mode 100644 index 00000000..10e8e12c --- /dev/null +++ b/apps/server/src/infrastructure/database.ts @@ -0,0 +1,91 @@ +import { Global, Inject, Injectable, Module } from '@nestjs/common' +import type { + DynamicModule, + OnModuleDestroy, + OnModuleInit, +} from '@nestjs/common' +import { PrismaPg } from '@prisma/adapter-pg' +import { SERVER_CONFIG } from '../config' +import { PrismaClient } from '../generated/prisma/client' +import type { Prisma } from '../generated/prisma/client' +import type { ServerConfig } from '../platform/index' + +export function createDatabase(databaseUrl: string) { + const schema = new URL(databaseUrl).searchParams.get('schema') ?? 'public' + const adapter = new PrismaPg( + { connectionString: databaseUrl, connectionTimeoutMillis: 5000, max: 10 }, + { schema }, + ) + + return new PrismaClient({ adapter }) +} + +export type Database = PrismaClient | Prisma.TransactionClient + +export async function writeTransaction( + database: PrismaClient, + action: (transaction: Prisma.TransactionClient) => Promise, +) { + // 权限复核和目标变更放在同一事务内,避免并发降权后仍写入数据。 + for (let attempt = 0; ; attempt++) { + try { + return await database.$transaction(action, { + isolationLevel: 'Serializable', + maxWait: 5000, + timeout: 10000, + }) + } catch (error) { + if ( + attempt < 2 && + error instanceof Error && + 'code' in error && + error.code === 'P2034' + ) + continue + + throw error + } + } +} + +@Injectable() +export class DatabaseService implements OnModuleInit, OnModuleDestroy { + readonly prisma: PrismaClient + + constructor(@Inject(SERVER_CONFIG) config: ServerConfig) { + this.prisma = createDatabase(config.databaseUrl) + } + + async onModuleInit() { + await this.prisma.$connect() + } + + async onModuleDestroy() { + await this.prisma.$disconnect() + } + + async ping() { + await this.prisma.$queryRaw`SELECT 1` + } + + async write( + action: (transaction: Prisma.TransactionClient) => Promise, + ) { + return writeTransaction(this.prisma, action) + } +} + +@Global() +@Module({}) +export class DatabaseModule { + static register(config: ServerConfig): DynamicModule { + return { + module: DatabaseModule, + providers: [ + { provide: SERVER_CONFIG, useValue: config }, + DatabaseService, + ], + exports: [SERVER_CONFIG, DatabaseService], + } + } +} diff --git a/apps/server/src/main.ts b/apps/server/src/main.ts new file mode 100644 index 00000000..036af54c --- /dev/null +++ b/apps/server/src/main.ts @@ -0,0 +1,22 @@ +import { createApp } from './app' +import { loadServerConfig, standardLogSink, writeLog } from './platform/index' + +try { + const config = loadServerConfig() + const app = await createApp(config) + + try { + app.enableShutdownHooks() + await app.listen(config.port, config.host) + } catch (error) { + await app.close() + throw error + } + + writeLog(standardLogSink, 'info', 'server.started') +} catch (error) { + writeLog(standardLogSink, 'error', 'server.start_failed', { + code: error instanceof Error ? error.name : 'UnknownError', + }) + process.exitCode = 1 +} diff --git a/apps/server/src/modules/auth/auth.controller.ts b/apps/server/src/modules/auth/auth.controller.ts new file mode 100644 index 00000000..e3cdc0e6 --- /dev/null +++ b/apps/server/src/modules/auth/auth.controller.ts @@ -0,0 +1,26 @@ +import { Body, Controller, Get, Inject, Post, Req } from '@nestjs/common' +import type { Request } from 'express' +import { requestIdFrom, tokenFrom } from '../../http' +import { Public } from './auth.guard' +import { AuthService } from './auth.service' + +@Controller('admin/auth') +export class AuthController { + constructor(@Inject(AuthService) private readonly auth: AuthService) {} + + @Public() + @Post('login') + login(@Body() input: unknown, @Req() request: Request) { + return this.auth.login(input, requestIdFrom(request)) + } + + @Get('session') + session(@Req() request: Request) { + return this.auth.session(tokenFrom(request)) + } + + @Post('logout') + logout(@Req() request: Request) { + return this.auth.logout(tokenFrom(request), requestIdFrom(request)) + } +} diff --git a/apps/server/src/modules/auth/auth.guard.ts b/apps/server/src/modules/auth/auth.guard.ts new file mode 100644 index 00000000..48d6c5b3 --- /dev/null +++ b/apps/server/src/modules/auth/auth.guard.ts @@ -0,0 +1,37 @@ +import { Inject, Injectable, SetMetadata } from '@nestjs/common' +import type { CanActivate, ExecutionContext } from '@nestjs/common' +import { Reflector } from '@nestjs/core' +import type { Request } from 'express' +import { tokenFrom } from '../../http' +import { AuthService } from './auth.service' + +const PUBLIC = Symbol('public') +const PERMISSION = Symbol('permission') + +export const Public = () => SetMetadata(PUBLIC, true) +export const RequirePermission = (permission: string) => + SetMetadata(PERMISSION, permission) + +@Injectable() +export class AuthGuard implements CanActivate { + constructor( + @Inject(Reflector) private readonly reflector: Reflector, + @Inject(AuthService) private readonly auth: AuthService, + ) {} + + async canActivate(context: ExecutionContext) { + const targets = [context.getHandler(), context.getClass()] + + if (this.reflector.getAllAndOverride(PUBLIC, targets)) return true + + const permission = this.reflector.getAllAndOverride( + PERMISSION, + targets, + ) + const request = context.switchToHttp().getRequest() + + await this.auth.authenticate(tokenFrom(request), permission) + + return true + } +} diff --git a/apps/server/src/modules/auth/auth.module.ts b/apps/server/src/modules/auth/auth.module.ts new file mode 100644 index 00000000..fccf6f07 --- /dev/null +++ b/apps/server/src/modules/auth/auth.module.ts @@ -0,0 +1,13 @@ +import { Global, Module } from '@nestjs/common' +import { APP_GUARD } from '@nestjs/core' +import { AuthController } from './auth.controller' +import { AuthGuard } from './auth.guard' +import { AuthService } from './auth.service' + +@Global() +@Module({ + controllers: [AuthController], + providers: [AuthService, { provide: APP_GUARD, useClass: AuthGuard }], + exports: [AuthService], +}) +export class AuthModule {} diff --git a/apps/server/src/modules/auth/auth.service.ts b/apps/server/src/modules/auth/auth.service.ts new file mode 100644 index 00000000..215e2531 --- /dev/null +++ b/apps/server/src/modules/auth/auth.service.ts @@ -0,0 +1,142 @@ +import { Inject, Injectable } from '@nestjs/common' +import { loginInputSchema } from '@ray-template/api-contracts/admin' +import type { SessionInfo } from '@ray-template/api-contracts/admin' +import { SERVER_CONFIG } from '../../config' +import { ApiError, parseInput } from '../../http' +import { DatabaseService } from '../../infrastructure/database' +import type { Database } from '../../infrastructure/database' +import type { ServerConfig } from '../../platform/index' +import { createToken, tokenHash, verifyPassword } from './password' + +export interface AuthContext extends SessionInfo { + tokenHash: string +} + +@Injectable() +export class AuthService { + constructor( + @Inject(DatabaseService) private readonly database: DatabaseService, + @Inject(SERVER_CONFIG) private readonly config: ServerConfig, + ) {} + + async authenticate( + token: string | null, + permission?: string, + database: Database = this.database.prisma, + ): Promise { + if (!token) throw new ApiError(401, 'unauthorized') + + const hash = tokenHash(token) + const session = await database.session.findUnique({ + where: { tokenHash: hash }, + include: { + user: { include: { roleRecord: { include: { permissions: true } } } }, + }, + }) + + if ( + !session || + session.expiresAt.getTime() <= Date.now() || + session.user.status !== 'enabled' + ) + throw new ApiError(401, 'unauthorized') + + const { id, username, name, role, roleRecord } = session.user + const permissions = roleRecord.permissions.map( + ({ permissionCode }) => permissionCode, + ) + + if (permission && !permissions.includes(permission)) + throw new ApiError(403, 'forbidden') + + return { user: { id, username, name, role }, permissions, tokenHash: hash } + } + + async login(input: unknown, requestId: string | null) { + const { username, password } = parseInput(loginInputSchema, input) + const user = await this.database.prisma.user.findUnique({ + where: { usernameKey: username.toLowerCase() }, + include: { credential: true }, + }) + const valid = await verifyPassword( + password, + user?.credential?.passwordHash ?? null, + ) + + if (!valid || !user || user.status !== 'enabled') { + await this.database.prisma.auditLog.create({ + data: { action: 'auth.login.failed', requestId }, + }) + throw new ApiError(401, 'invalidCredentials') + } + + const accessToken = createToken() + const hash = tokenHash(accessToken) + const expiresAt = new Date( + Date.now() + this.config.sessionTtlSeconds * 1000, + ) + + return this.database.write(async (transaction) => { + const current = await transaction.user.findUnique({ + where: { id: user.id }, + include: { + credential: true, + roleRecord: { include: { permissions: true } }, + }, + }) + + // 派生密码期间可能发生停用或重置;新会话必须以事务内的凭据状态为准。 + if ( + !current || + current.status !== 'enabled' || + current.credential?.passwordHash !== user.credential?.passwordHash + ) + throw new ApiError(401, 'invalidCredentials') + + await transaction.session.deleteMany({ + where: { userId: user.id, expiresAt: { lte: new Date() } }, + }) + await transaction.session.create({ + data: { tokenHash: hash, userId: user.id, expiresAt }, + }) + await transaction.auditLog.create({ + data: { actorId: user.id, action: 'auth.login', requestId }, + }) + + return { + accessToken, + expiresAt: expiresAt.toISOString(), + user: { + id: current.id, + username: current.username, + name: current.name, + role: current.role, + }, + permissions: current.roleRecord.permissions.map( + ({ permissionCode }) => permissionCode, + ), + } + }) + } + + async session(token: string | null): Promise { + const { user, permissions } = await this.authenticate(token) + + return { user, permissions } + } + + async logout(token: string | null, requestId: string | null) { + await this.database.write(async (transaction) => { + const session = await this.authenticate(token, void 0, transaction) + + await transaction.session.delete({ + where: { tokenHash: session.tokenHash }, + }) + await transaction.auditLog.create({ + data: { actorId: session.user.id, action: 'auth.logout', requestId }, + }) + }) + + return null + } +} diff --git a/apps/server/src/modules/auth/password.ts b/apps/server/src/modules/auth/password.ts new file mode 100644 index 00000000..ec55a383 --- /dev/null +++ b/apps/server/src/modules/auth/password.ts @@ -0,0 +1,49 @@ +import { createHash, randomBytes, scrypt, timingSafeEqual } from 'node:crypto' + +const keyLength = 64 +const cost = { N: 32768, r: 8, p: 1, maxmem: 64 * 1024 * 1024 } + +function derive(password: string, salt: Buffer) { + return new Promise((resolve, reject) => { + scrypt(password, salt, keyLength, cost, (error, key) => { + if (error) reject(error) + else resolve(key) + }) + }) +} + +export function validateNewPassword(password: string) { + if (password.length < 12 || password.length > 128) + throw new Error('Passwords must contain 12 to 128 characters.') +} + +export async function hashPassword(password: string) { + validateNewPassword(password) + + const salt = randomBytes(16) + const key = await derive(password, salt) + + return `scrypt$${salt.toString('hex')}$${key.toString('hex')}` +} + +export async function verifyPassword(password: string, stored: string | null) { + const parts = stored?.split('$') ?? [] + const valid = + parts.length === 3 && + parts[0] === 'scrypt' && + /^[a-f\d]{32}$/u.test(parts[1]) && + /^[a-f\d]{128}$/u.test(parts[2]) + const salt = valid ? Buffer.from(parts[1], 'hex') : Buffer.alloc(16) + const expected = valid + ? Buffer.from(parts[2], 'hex') + : Buffer.alloc(keyLength) + const actual = await derive(password, salt) + + // 未配置凭据的账号也执行同样的派生工作,避免直接暴露账号是否存在。 + return timingSafeEqual(actual, expected) && valid +} + +export const tokenHash = (token: string) => + createHash('sha256').update(token).digest('hex') + +export const createToken = () => randomBytes(32).toString('base64url') diff --git a/apps/server/src/modules/demo/demo.controller.ts b/apps/server/src/modules/demo/demo.controller.ts new file mode 100644 index 00000000..587ced43 --- /dev/null +++ b/apps/server/src/modules/demo/demo.controller.ts @@ -0,0 +1,140 @@ +import { + Body, + Controller, + Get, + Inject, + Param, + Post, + Query, +} from '@nestjs/common' +import { + chartsQuerySchema, + chartsSchema, + orderSearchInputSchema, + ownerSearchInputSchema, + personListQuerySchema, + requestFixtureSchema, + routePeopleQuerySchema, + searchOptionsQuerySchema, + searchOptionsSchema, +} from '@ray-template/api-contracts/demo' +import { + getDemoCharts, + getOrderOptions, + listPeople, + listRouteDemoPeople, + requestFixture, + routeDemoPeople, + searchDemoOrders, + searchDemoOwners, +} from '@ray-template/demo-data' +import type { Request } from 'express' +import * as v from 'valibot' +import { ApiError, parseInput, queryInput } from '../../http' +import { PlatformLifecycle } from '../../platform/lifecycle' +import { Public } from '../auth/auth.guard' + +@Public() +@Controller('admin/demo') +export class DemoController { + constructor( + @Inject(PlatformLifecycle) private readonly platform: PlatformLifecycle, + ) {} + + @Get('request') + requestFixture() { + return this.cached('request', () => requestFixture, requestFixtureSchema) + } + + @Get('charts') + charts(@Query() query: Request['query']) { + const { refresh } = parseInput( + chartsQuerySchema, + queryInput(query, ['refresh']), + ) + + return refresh + ? getDemoCharts(true) + : this.cached('charts', getDemoCharts, chartsSchema) + } + + @Get('search-options') + options(@Query() query: Request['query']) { + const { locale = 'zh-CN' } = parseInput(searchOptionsQuerySchema, query) + const language = locale === 'zh-CN' ? 'zh-CN' : 'en-US' + + return this.cached( + `options:${language}`, + () => getOrderOptions(language), + searchOptionsSchema, + ) + } + + @Get('people') + people(@Query() query: Request['query']) { + const input = parseInput(personListQuerySchema, queryInput(query, ['fail'])) + + if (input.fail) throw new ApiError(503, 'requestFailed') + + return listPeople({ + ...input, + page: input.page ?? 1, + pageSize: input.pageSize ?? 10, + }) + } + + @Get('route-people') + routePeople(@Query() query: Request['query']) { + return listRouteDemoPeople( + parseInput(routePeopleQuerySchema, queryInput(query)), + ) + } + + @Get('route-people/:id') + routePerson(@Param('id') id: string) { + const key = Number(id) + + if (!/^\d+$/u.test(id) || !Number.isSafeInteger(key)) + throw new ApiError(400, 'invalid') + + const person = routeDemoPeople.find((row) => row.key === key) + + if (!person) throw new ApiError(404, 'notFound') + + return person + } + + @Post('owners/search') + owners(@Body() body: unknown) { + const { orgId, keyword, locale, fail } = parseInput( + ownerSearchInputSchema, + body, + ) + + if (fail) throw new ApiError(503, 'requestFailed') + + return searchDemoOwners(orgId, keyword, locale) + } + + @Post('orders/search') + orders(@Body() body: unknown) { + const { query, locale, fail } = parseInput(orderSearchInputSchema, body) + + if (fail) throw new ApiError(503, 'requestFailed') + + return searchDemoOrders(query, locale) + } + + private cached( + key: string, + load: () => T, + schema: v.GenericSchema, + ) { + return this.platform.cache.getOrLoad( + `demo:v1:${key}`, + 300, + async () => load(), + (value): value is T => v.is(schema, value), + ) + } +} diff --git a/apps/server/src/modules/routes/routes.controller.ts b/apps/server/src/modules/routes/routes.controller.ts new file mode 100644 index 00000000..a4de0b45 --- /dev/null +++ b/apps/server/src/modules/routes/routes.controller.ts @@ -0,0 +1,81 @@ +import { Body, Controller, Get, Inject, Put, Query, Req } from '@nestjs/common' +import { parseApplicationRoutes } from '@ray-template/demo-data' +import type { Request } from 'express' +import { SERVER_CONFIG } from '../../config' +import type { Prisma } from '../../generated/prisma/client' +import { ApiError, requestIdFrom, tokenFrom } from '../../http' +import { DatabaseService } from '../../infrastructure/database' +import type { ServerConfig } from '../../platform/index' +import { Public, RequirePermission } from '../auth/auth.guard' +import { AuthService } from '../auth/auth.service' +import { withoutDemoRoutes } from './runtime-routes' + +@Controller('admin/route-config') +export class RoutesController { + constructor( + @Inject(DatabaseService) private readonly database: DatabaseService, + @Inject(AuthService) private readonly auth: AuthService, + @Inject(SERVER_CONFIG) private readonly config: ServerConfig, + ) {} + + @Public() + @Get() + async get(@Req() request: Request, @Query('view') view: unknown) { + if (view !== void 0 && view !== 'editor') throw new ApiError(400, 'invalid') + + if (view === 'editor') + await this.auth.authenticate(tokenFrom(request), 'routes:write') + + const record = await this.database.prisma.routeConfig.findUnique({ + where: { id: 'admin' }, + }) + + if (!record) throw new ApiError(503, 'notInitialized') + + try { + const routes = parseApplicationRoutes(JSON.stringify(record.config)) + + return this.config.demoEnabled || view === 'editor' + ? routes + : withoutDemoRoutes(routes) + } catch { + throw new ApiError(503, 'invalidRoutes') + } + } + + @Put() + @RequirePermission('routes:write') + save(@Body() input: unknown, @Req() request: Request) { + let config: ReturnType + + try { + config = parseApplicationRoutes(JSON.stringify(input)) + } catch { + throw new ApiError(400, 'invalidRoutes') + } + + return this.database.write(async (transaction) => { + const session = await this.auth.authenticate( + tokenFrom(request), + 'routes:write', + transaction, + ) + + await transaction.routeConfig.upsert({ + where: { id: 'admin' }, + create: { id: 'admin', config: config as Prisma.InputJsonValue }, + update: { config: config as Prisma.InputJsonValue }, + }) + await transaction.auditLog.create({ + data: { + actorId: session.user.id, + action: 'routes.update', + resourceId: 'admin', + requestId: requestIdFrom(request), + }, + }) + + return config + }) + } +} diff --git a/apps/server/src/modules/routes/routes.module.ts b/apps/server/src/modules/routes/routes.module.ts new file mode 100644 index 00000000..0d3fd8a9 --- /dev/null +++ b/apps/server/src/modules/routes/routes.module.ts @@ -0,0 +1,5 @@ +import { Module } from '@nestjs/common' +import { RoutesController } from './routes.controller' + +@Module({ controllers: [RoutesController] }) +export class RoutesModule {} diff --git a/apps/server/src/modules/routes/runtime-routes.ts b/apps/server/src/modules/routes/runtime-routes.ts new file mode 100644 index 00000000..764646d1 --- /dev/null +++ b/apps/server/src/modules/routes/runtime-routes.ts @@ -0,0 +1,48 @@ +import type { + RouteConfig, + RouteConfigRecord, +} from '@ray-template/api-contracts/routes' + +export function withoutDemoRoutes(config: RouteConfig): RouteConfig { + const leaves = new Map() + const visit = (routes: RouteConfigRecord[], parent = '') => { + for (const route of routes) { + const path = route.path.startsWith('/') + ? route.path + : `${parent}/${route.path}` + + if (route.children) visit(route.children, path) + else { + leaves.set(path.toLowerCase(), route) + + for (const alias of [route.alias ?? []].flat()) + leaves.set(alias.toLowerCase(), route) + } + } + } + + visit(config.routes) + + const isVisible = (route: RouteConfigRecord): boolean => { + if (route.component?.startsWith('demo/')) return false + + if (!route.redirect) return true + + // 校验已排除循环;指向关闭页面的别名与重定向也不能留在运行菜单中。 + const target = leaves.get(route.redirect.toLowerCase()) + + return !!target && isVisible(target) + } + const prune = (routes: RouteConfigRecord[]): RouteConfigRecord[] => + routes.flatMap((route) => { + if (!isVisible(route)) return [] + + if (!route.children) return [route] + + const children = prune(route.children) + + return children.length ? [{ ...route, children }] : [] + }) + + return { ...config, routes: prune(config.routes) } +} diff --git a/apps/server/src/modules/users/users.controller.ts b/apps/server/src/modules/users/users.controller.ts new file mode 100644 index 00000000..e5dd9ac6 --- /dev/null +++ b/apps/server/src/modules/users/users.controller.ts @@ -0,0 +1,76 @@ +import { + Body, + Controller, + Get, + Inject, + Param, + Patch, + Post, + Put, + Query, + Req, +} from '@nestjs/common' +import type { Request } from 'express' +import { queryInput, requestIdFrom, tokenFrom } from '../../http' +import { RequirePermission } from '../auth/auth.guard' +import { UsersService } from './users.service' + +@Controller('admin/users') +export class UsersController { + constructor(@Inject(UsersService) private readonly users: UsersService) {} + + @Get('options') + @RequirePermission('users:read') + options(@Req() request: Request) { + return this.users.options(tokenFrom(request)) + } + + @Get() + @RequirePermission('users:read') + list(@Query() query: Request['query']) { + return this.users.list(queryInput(query)) + } + + @Get(':id') + @RequirePermission('users:read') + get(@Param('id') id: string) { + return this.users.get(id) + } + + @Post() + @RequirePermission('users:create') + create(@Body() input: unknown, @Req() request: Request) { + return this.users.save(input, tokenFrom(request), requestIdFrom(request)) + } + + @Put(':id') + @RequirePermission('users:update') + update( + @Param('id') id: string, + @Body() input: unknown, + @Req() request: Request, + ) { + return this.users.save( + input, + tokenFrom(request), + requestIdFrom(request), + id, + ) + } + + @Post('batch-delete') + @RequirePermission('users:delete') + delete(@Body() input: unknown, @Req() request: Request) { + return this.users.delete(input, tokenFrom(request), requestIdFrom(request)) + } + + @Patch('status') + @RequirePermission('users:status') + status(@Body() input: unknown, @Req() request: Request) { + return this.users.changeStatus( + input, + tokenFrom(request), + requestIdFrom(request), + ) + } +} diff --git a/apps/server/src/modules/users/users.module.ts b/apps/server/src/modules/users/users.module.ts new file mode 100644 index 00000000..689487d7 --- /dev/null +++ b/apps/server/src/modules/users/users.module.ts @@ -0,0 +1,6 @@ +import { Module } from '@nestjs/common' +import { UsersController } from './users.controller' +import { UsersService } from './users.service' + +@Module({ controllers: [UsersController], providers: [UsersService] }) +export class UsersModule {} diff --git a/apps/server/src/modules/users/users.service.ts b/apps/server/src/modules/users/users.service.ts new file mode 100644 index 00000000..1a53538c --- /dev/null +++ b/apps/server/src/modules/users/users.service.ts @@ -0,0 +1,328 @@ +import { Inject, Injectable } from '@nestjs/common' +import { + idsSchema, + statusInputSchema, + userInputSchema, + userListQuerySchema, +} from '@ray-template/api-contracts/admin' +import type { AdminUser, UserInput } from '@ray-template/api-contracts/admin' +import type { Prisma, User } from '../../generated/prisma/client' +import { ApiError, parseInput } from '../../http' +import { DatabaseService } from '../../infrastructure/database' +import type { Database } from '../../infrastructure/database' +import { AuthService } from '../auth/auth.service' +import type { AuthContext } from '../auth/auth.service' + +export function userView(user: User): AdminUser { + return { + id: user.id, + username: user.username, + name: user.name, + email: user.email, + phone: user.phone, + departmentId: user.departmentId, + role: user.role, + status: user.status as AdminUser['status'], + remark: user.remark, + createdAt: user.createdAt.toISOString(), + } +} + +@Injectable() +export class UsersService { + constructor( + @Inject(DatabaseService) private readonly database: DatabaseService, + @Inject(AuthService) private readonly auth: AuthService, + ) {} + + async options(token: string | null) { + const session = await this.auth.authenticate(token, 'users:read') + const [departments, roles] = await Promise.all([ + this.database.prisma.department.findMany({ orderBy: { id: 'asc' } }), + this.database.prisma.role.findMany({ + include: { permissions: true }, + orderBy: { value: 'asc' }, + }), + ]) + + return { + departments: departments.map(({ labelKey, ...department }) => ({ + ...department, + ...(labelKey ? { labelKey } : {}), + })), + roles: roles.map(({ value, label, labelKey, permissions }) => ({ + value, + label, + ...(labelKey ? { labelKey } : {}), + disabled: + session.user.role !== 'admin' && + permissions.some( + ({ permissionCode }) => + !session.permissions.includes(permissionCode), + ), + })), + } + } + + async list(input: unknown) { + const params = parseInput(userListQuerySchema, input) + const { page = 1, pageSize = 10 } = params + + if ( + !Number.isSafeInteger(page) || + !Number.isSafeInteger((page - 1) * pageSize) + ) + throw new ApiError(400, 'invalid') + + const where: Prisma.UserWhereInput = {} + + for (const field of ['name', 'username', 'email'] as const) { + if (params[field]) + where[field] = { contains: params[field], mode: 'insensitive' } + } + + if (params.role) where.role = params.role + + if (params.status) where.status = params.status + + if (params.departmentId) { + const departments = await this.database.prisma.department.findMany() + const included = new Set([params.departmentId]) + let changed = true + + while (changed) { + changed = false + + for (const department of departments) { + if ( + department.parentId && + included.has(department.parentId) && + !included.has(department.id) + ) { + included.add(department.id) + changed = true + } + } + } + + where.departmentId = { in: [...included] } + } + + const [users, total] = await this.database.prisma.$transaction( + [ + this.database.prisma.user.findMany({ + where, + skip: (page - 1) * pageSize, + take: pageSize, + orderBy: [{ createdAt: 'desc' }, { id: 'asc' }], + }), + this.database.prisma.user.count({ where }), + ], + { isolationLevel: 'RepeatableRead' }, + ) + + return { items: users.map(userView), total } + } + + async get(id: string) { + return userView(await this.findUser(this.database.prisma, id)) + } + + private async findUser(database: Database, id: string) { + const user = await database.user.findUnique({ where: { id } }) + + if (!user) throw new ApiError(404, 'notFound') + + return user + } + + private async assertManageRole( + database: Database, + session: AuthContext, + role: string, + ) { + const target = await database.role.findUnique({ + where: { value: role }, + include: { permissions: true }, + }) + + if (!target) throw new ApiError(400, 'invalid') + + if ( + session.user.role !== 'admin' && + target.permissions.some( + ({ permissionCode }) => !session.permissions.includes(permissionCode), + ) + ) + throw new ApiError(403, 'forbidden') + } + + private async validateUnique( + database: Database, + value: UserInput, + id?: string, + ) { + const duplicate = await database.user.findFirst({ + where: { + usernameKey: value.username.toLowerCase(), + ...(id ? { id: { not: id } } : {}), + }, + }) + + if (duplicate) throw new ApiError(409, 'duplicateUsername') + + const duplicateEmail = await database.user.findFirst({ + where: { + emailKey: value.email.toLowerCase(), + ...(id ? { id: { not: id } } : {}), + }, + }) + + if (duplicateEmail) throw new ApiError(409, 'duplicateEmail') + } + + async save( + input: unknown, + token: string | null, + requestId: string | null, + id?: string, + ) { + const value = parseInput(userInputSchema, input) + + return this.database.write(async (transaction) => { + const session = await this.auth.authenticate( + token, + id ? 'users:update' : 'users:create', + transaction, + ) + const existing = id ? await this.findUser(transaction, id) : null + + if (existing) + await this.assertManageRole(transaction, session, existing.role) + + await this.assertManageRole(transaction, session, value.role) + + if ( + !(await transaction.department.findUnique({ + where: { id: value.departmentId }, + })) + ) + throw new ApiError(400, 'invalid') + + if ( + id === session.user.id && + (value.status !== 'enabled' || value.role !== session.user.role) + ) + throw new ApiError(409, 'selfProtected') + + await this.validateUnique(transaction, value, id) + + const data = { + ...value, + usernameKey: value.username.toLowerCase(), + emailKey: value.email.toLowerCase(), + } + const user = existing + ? await transaction.user.update({ where: { id }, data }) + : await transaction.user.create({ data }) + + if ( + existing && + (existing.role !== user.role || user.status === 'disabled') + ) { + await transaction.session.deleteMany({ where: { userId: user.id } }) + } + + await transaction.auditLog.create({ + data: { + actorId: session.user.id, + action: existing ? 'users.update' : 'users.create', + resourceId: user.id, + requestId, + }, + }) + + return userView(user) + }) + } + + async delete(input: unknown, token: string | null, requestId: string | null) { + const ids = [...new Set(parseInput(idsSchema, input).ids)] + + return this.database.write(async (transaction) => { + const session = await this.auth.authenticate( + token, + 'users:delete', + transaction, + ) + + for (const id of ids) { + const user = await this.findUser(transaction, id) + + await this.assertManageRole(transaction, session, user.role) + + if (id === session.user.id) throw new ApiError(409, 'selfProtected') + } + + const result = await transaction.user.deleteMany({ + where: { id: { in: ids } }, + }) + + await transaction.auditLog.createMany({ + data: ids.map((id) => ({ + actorId: session.user.id, + action: 'users.delete', + resourceId: id, + requestId, + })), + }) + + return { affected: result.count } + }) + } + + async changeStatus( + input: unknown, + token: string | null, + requestId: string | null, + ) { + const parsed = parseInput(statusInputSchema, input) + const ids = [...new Set(parsed.ids)] + + return this.database.write(async (transaction) => { + const session = await this.auth.authenticate( + token, + 'users:status', + transaction, + ) + + for (const id of ids) { + const user = await this.findUser(transaction, id) + + await this.assertManageRole(transaction, session, user.role) + + if (id === session.user.id && parsed.status === 'disabled') + throw new ApiError(409, 'selfProtected') + } + + const result = await transaction.user.updateMany({ + where: { id: { in: ids } }, + data: { status: parsed.status }, + }) + + if (parsed.status === 'disabled') + await transaction.session.deleteMany({ where: { userId: { in: ids } } }) + + await transaction.auditLog.createMany({ + data: ids.map((id) => ({ + actorId: session.user.id, + action: `users.${parsed.status}`, + resourceId: id, + requestId, + })), + }) + + return { affected: result.count } + }) + } +} diff --git a/apps/server/src/platform/README.md b/apps/server/src/platform/README.md new file mode 100644 index 00000000..ec006941 --- /dev/null +++ b/apps/server/src/platform/README.md @@ -0,0 +1,47 @@ +# Server platform + +`PlatformRuntime` owns the Redis connection, HTTP security middleware, request logs, rate limits, read-through cache, and health probes. Authentication and authorization remain in the business modules; permission decisions and sessions must never use the optional read-through cache. + +Create the Nest application with `bodyParser: false`, install the runtime before `app.init()` or `app.listen()`, and await `runtime.close()` during application shutdown. The runtime installs its bounded JSON parser after logging and security headers, so malformed and oversized payloads also receive the standard error envelope and request ID. The API exception filter remains responsible for controller failures. + +## Configuration + +| Variable | Default | Meaning | +| ---------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------- | +| `NODE_ENV` | `development` | `development`, `test`, or `production` | +| `HOST` | `127.0.0.1` | Listening interface; containers explicitly use `0.0.0.0` | +| `PORT` | `3000` | HTTP port; port zero is allowed only in tests | +| `DATABASE_URL` | Required | PostgreSQL connection URL | +| `REDIS_URL` | Required | Redis connection URL; use `rediss:` for TLS | +| `REDIS_KEY_PREFIX` | `ray:` | Isolate applications and environments sharing Redis | +| `CORS_ORIGINS` | Empty | Comma-separated exact origins, including the web application's origin; no wildcard or paths | +| `TRUST_PROXY` | `false` | Comma-separated trusted proxy IP addresses/CIDRs; unrestricted trust and hop counts are rejected | +| `DEMO_ENABLED` | `false` in production, otherwise `true` | Whether the host registers read-only demonstration endpoints | +| `SESSION_TTL_SECONDS` | `28800` | Session expiry consumed by the authentication module | +| `BODY_LIMIT_BYTES` | `262144` | JSON payload limit, up to 1 MiB | +| `REQUEST_TIMEOUT_MS` | `15000` | Node's request reception timeout, not a controller execution deadline | +| `RATE_LIMIT_MAX` | `300` | Requests per client IP per fixed 60-second window | +| `LOGIN_RATE_LIMIT_MAX` | `10` | Login attempts per normalized account per fixed 15-minute window; IP limit is five times this value | + +No-origin requests are accepted; browser origins must be explicitly listed. Credentials are Bearer tokens and CORS does not enable cookie credentials. A future cookie authentication mode must define CSRF protection and the corresponding contract separately. + +Proxy trust defaults to the direct socket address. Configure only proxies that overwrite incoming forwarding headers; otherwise a caller may impersonate another IP. Exact CORS matching is a browser boundary, not authorization. + +## Redis behavior + +Rate counters use an atomic Lua increment/expiry operation. Account and IP identities are hashed before becoming Redis keys. Login limiting happens before password verification and covers case-insensitive Express routes. Limits count both successful and unsuccessful attempts. An unavailable Redis connection makes admin API requests fail closed with HTTP 503 and readiness fail; no per-process production fallback exists. + +`runtime.cache.getOrLoad(key, ttlSeconds, loader, validator?)` is for reconstructible, non-sensitive reads such as demonstration chart data. Cache failures load the original data, while loader errors propagate. Validate cached payloads at the consuming contract when appropriate. `invalidate(key)` propagates Redis failures so callers cannot mistake failed invalidation for success. + +The client disables offline command queues, bounds connection and command waits, reconnects after transient failures, and closes gracefully. A connection failure never prints the connection URL. Tests use a unique key prefix and TTL-bound keys; they must not flush a shared Redis database. + +## HTTP observability and probes + +Every response has `X-Request-Id`. A valid bounded incoming ID is reused; otherwise a random UUID is generated. Completion logs contain only timestamp, level, event, request ID, HTTP method, route template, status, and duration. Unmatched or rejected requests do not log raw paths. Request bodies, headers, query strings, resource IDs, and raw error messages are excluded. Dependency errors use a small allowlist of diagnostic codes. + +- `GET /api/health/live` reports whether the process can answer HTTP. +- `GET /api/health/ready` checks PostgreSQL and Redis with a bounded read-only probe and returns 503 on failure. It exposes no connection details. + +Node's request/header timeouts bound slow request reception. They do not race a transaction against an HTTP response: the database layer owns query and transaction timeouts. There is no attempt to report a timed-out mutation as cancelled while it continues committing. + +Platform tests cover configuration, redaction, real HTTP security/CORS/body limits, forwarded-header spoofing, rate-limit denial, fail-closed Redis outages, readiness, and cache behavior. Set `TEST_REDIS_URL` to include the real Redis concurrency and expiry regression. diff --git a/apps/server/src/platform/config.ts b/apps/server/src/platform/config.ts new file mode 100644 index 00000000..3be59b1b --- /dev/null +++ b/apps/server/src/platform/config.ts @@ -0,0 +1,146 @@ +import { isIP } from 'node:net' + +export interface ServerConfig { + nodeEnv: 'development' | 'test' | 'production' + host: string + port: number + databaseUrl: string + redisUrl: string + redisKeyPrefix: string + corsOrigins: string[] + trustProxy: false | string[] + demoEnabled: boolean + sessionTtlSeconds: number + bodyLimitBytes: number + requestTimeoutMs: number + rateLimitMax: number + loginRateLimitMax: number +} + +export function loadServerConfig( + env: NodeJS.ProcessEnv = process.env, +): ServerConfig { + const nodeEnv = env.NODE_ENV ?? 'development' + + if (!['development', 'test', 'production'].includes(nodeEnv)) { + throw new Error('NODE_ENV must be development, test or production.') + } + + const integer = (key: string, fallback: number, min: number, max: number) => { + const input = env[key] ?? String(fallback) + const value = Number(input) + + if ( + !/^\d+$/u.test(input) || + !Number.isSafeInteger(value) || + value < min || + value > max + ) { + throw new Error(`${key} must be an integer between ${min} and ${max}.`) + } + + return value + } + const boolean = (key: string, fallback: boolean) => { + const input = env[key] + + if (input === void 0) return fallback + + if (input === 'true') return true + + if (input === 'false') return false + + throw new Error(`${key} must be true or false.`) + } + const connection = (key: string, protocols: string[]) => { + const value = env[key] + + try { + const parsed = new URL(value ?? '') + + if (!protocols.includes(parsed.protocol) || !parsed.hostname) + throw new Error() + } catch { + // 配置错误只报告字段名,连接串可能携带数据库或 Redis 密码。 + throw new Error( + `${key} must be a valid ${protocols.join('/')} connection URL.`, + ) + } + + return value! + } + const corsOrigins = (env.CORS_ORIGINS ?? '') + .split(',') + .map((item) => item.trim()) + .filter(Boolean) + + if (corsOrigins.length > 16) + throw new Error('CORS_ORIGINS accepts at most 16 origins.') + + for (const origin of corsOrigins) { + try { + const parsed = new URL(origin) + + if ( + !['https:', 'http:'].includes(parsed.protocol) || + parsed.origin !== origin + ) + throw new Error() + } catch { + throw new Error( + 'CORS_ORIGINS must contain exact HTTP(S) origins without paths or wildcards.', + ) + } + } + + const proxyValue = env.TRUST_PROXY?.trim() || 'false' + const trustProxy = + proxyValue === 'false' + ? false + : proxyValue.split(',').map((item) => item.trim()) + + if (trustProxy) { + for (const entry of trustProxy) { + const [address, mask, extra] = entry.split('/') + const family = isIP(address) + + if ( + !family || + extra !== void 0 || + (mask !== void 0 && + (!/^\d+$/u.test(mask) || + Number(mask) < 1 || + Number(mask) > (family === 4 ? 32 : 128))) + ) { + throw new Error( + 'TRUST_PROXY must be false or a comma-separated list of trusted IP addresses/CIDRs.', + ) + } + } + } + + const redisKeyPrefix = env.REDIS_KEY_PREFIX || `ray:${nodeEnv}` + + if (!/^[a-zA-Z0-9:_-]{1,80}$/u.test(redisKeyPrefix)) { + throw new Error( + 'REDIS_KEY_PREFIX accepts 1–80 letters, digits, colons, underscores or hyphens.', + ) + } + + return { + nodeEnv: nodeEnv as ServerConfig['nodeEnv'], + host: env.HOST || '127.0.0.1', + port: integer('PORT', 3000, nodeEnv === 'test' ? 0 : 1, 65535), + databaseUrl: connection('DATABASE_URL', ['postgres:', 'postgresql:']), + redisUrl: connection('REDIS_URL', ['redis:', 'rediss:']), + redisKeyPrefix, + corsOrigins, + trustProxy, + demoEnabled: boolean('DEMO_ENABLED', nodeEnv !== 'production'), + sessionTtlSeconds: integer('SESSION_TTL_SECONDS', 28800, 60, 604800), + bodyLimitBytes: integer('BODY_LIMIT_BYTES', 262144, 1024, 1048576), + requestTimeoutMs: integer('REQUEST_TIMEOUT_MS', 15000, 1000, 120000), + rateLimitMax: integer('RATE_LIMIT_MAX', 300, 1, 100000), + loginRateLimitMax: integer('LOGIN_RATE_LIMIT_MAX', 10, 1, 1000), + } +} diff --git a/apps/server/src/platform/index.ts b/apps/server/src/platform/index.ts new file mode 100644 index 00000000..67d4a259 --- /dev/null +++ b/apps/server/src/platform/index.ts @@ -0,0 +1,7 @@ +export { loadServerConfig } from './config.js' +export type { ServerConfig } from './config.js' +export { PlatformRuntime } from './runtime.js' +export { RedisJsonCache, RedisRateLimiter, RedisStore } from './redis.js' +export type { RedisCommands } from './redis.js' +export { standardLogSink, writeLog } from './logging.js' +export type { LogSink } from './logging.js' diff --git a/apps/server/src/platform/lifecycle.ts b/apps/server/src/platform/lifecycle.ts new file mode 100644 index 00000000..b48be19f --- /dev/null +++ b/apps/server/src/platform/lifecycle.ts @@ -0,0 +1,18 @@ +import { Injectable } from '@nestjs/common' +import type { OnApplicationShutdown } from '@nestjs/common' +import type { PlatformRuntime } from './runtime' + +@Injectable() +export class PlatformLifecycle implements OnApplicationShutdown { + runtime: PlatformRuntime | null = null + + get cache() { + if (!this.runtime) throw new Error('Platform has not started.') + + return this.runtime.cache + } + + async onApplicationShutdown() { + await this.runtime?.close() + } +} diff --git a/apps/server/src/platform/logging.ts b/apps/server/src/platform/logging.ts new file mode 100644 index 00000000..02b7d00b --- /dev/null +++ b/apps/server/src/platform/logging.ts @@ -0,0 +1,63 @@ +import { randomUUID } from 'node:crypto' +import type { Request } from 'express' + +export type LogSink = (line: string) => void +export interface LogFields { + requestId?: string + method?: string + route?: string + statusCode?: number + durationMs?: number + code?: string +} + +export const standardLogSink: LogSink = (line) => + process.stdout.write(`${line}\n`) + +export function writeLog( + sink: LogSink, + level: 'info' | 'warn' | 'error', + event: string, + fields: LogFields = {}, +) { + // 只输出白名单字段,不序列化请求、错误对象、查询串或连接配置。 + sink( + JSON.stringify({ + timestamp: new Date().toISOString(), + level, + event, + requestId: fields.requestId, + method: fields.method, + route: fields.route, + statusCode: fields.statusCode, + durationMs: fields.durationMs, + code: fields.code, + }), + ) +} + +export function requestIdFor(value: unknown): string { + return typeof value === 'string' && /^[a-zA-Z0-9_-]{8,64}$/u.test(value) + ? value + : randomUUID() +} + +export function requestRoute(request: Request): string { + const route = request.route as { path?: unknown } | null + + return typeof route?.path === 'string' ? route.path : '' +} + +export function safeErrorCode(error: unknown): string { + const code = + typeof error === 'object' && error !== null && 'code' in error + ? error.code + : null + + return typeof code === 'string' && + ['ECONNREFUSED', 'ECONNRESET', 'ETIMEDOUT', 'ENOTFOUND', 'EPIPE'].includes( + code, + ) + ? code + : 'DEPENDENCY_ERROR' +} diff --git a/apps/server/src/platform/redis.ts b/apps/server/src/platform/redis.ts new file mode 100644 index 00000000..c526084c --- /dev/null +++ b/apps/server/src/platform/redis.ts @@ -0,0 +1,197 @@ +import { createHash } from 'node:crypto' +import { createClient } from 'redis' +import type { ServerConfig } from './config.js' +import { safeErrorCode, standardLogSink, writeLog } from './logging.js' +import type { LogSink } from './logging.js' + +const windowScript = ` +local count = redis.call('INCR', KEYS[1]) +if count == 1 then redis.call('PEXPIRE', KEYS[1], ARGV[1]) end +local remaining = redis.call('PTTL', KEYS[1]) +return {count, remaining} +` + +export interface RedisCommands { + isReady: boolean + eval( + script: string, + options: { keys: string[]; arguments: string[] }, + ): Promise + get(key: string): Promise + set(key: string, value: string, options: { EX: number }): Promise + del(key: string): Promise + ping(): Promise +} + +function within(operation: Promise, milliseconds = 2000): Promise { + let timeout: ReturnType + + return Promise.race([ + operation, + new Promise((_, reject) => { + timeout = setTimeout( + () => reject(new Error('Redis command timed out.')), + milliseconds, + ) + timeout.unref() + }), + ]).finally(() => clearTimeout(timeout)) +} + +export class RedisStore { + private client: ReturnType + private closing = false + private closePromise?: Promise + + constructor( + config: ServerConfig, + private readonly sink: LogSink = standardLogSink, + ) { + this.client = createClient({ + url: config.redisUrl, + disableOfflineQueue: true, + socket: { + connectTimeout: 3000, + reconnectStrategy: (retries) => Math.min(100 * 2 ** retries, 3000), + }, + }) + this.client.on('error', (error: unknown) => { + if (!this.closing) + writeLog(this.sink, 'error', 'redis.error', { + code: safeErrorCode(error), + }) + }) + } + + async connect(): Promise { + try { + await within(this.client.connect(), 5000) + } catch { + if (this.client.isOpen) this.client.destroy() + + throw new Error( + 'Redis is unavailable. Check REDIS_URL and service readiness.', + ) + } + } + + get commands(): RedisCommands { + return this.client + } + + close(): Promise { + this.closePromise ??= this.closeClient() + + return this.closePromise + } + + private async closeClient(): Promise { + this.closing = true + + if (!this.client.isOpen) return + + try { + await within(this.client.close()) + } catch { + if (this.client.isOpen) this.client.destroy() + } + } +} + +export class RedisRateLimiter { + constructor( + private readonly client: RedisCommands, + private readonly prefix: string, + ) {} + + async consume( + bucket: string, + identity: string, + limit: number, + windowMs: number, + ): Promise<{ allowed: boolean; retryAfterSeconds: number }> { + if (!this.client.isReady) throw new Error('Redis is unavailable.') + + const digest = createHash('sha256').update(identity).digest('hex') + const result = await within( + this.client.eval(windowScript, { + keys: [`${this.prefix}:limit:${bucket}:${digest}`], + arguments: [String(windowMs)], + }), + ) + + if ( + !Array.isArray(result) || + typeof result[0] !== 'number' || + typeof result[1] !== 'number' || + result[1] < 0 + ) { + throw new Error('Redis returned an invalid rate limit result.') + } + + return { + allowed: result[0] <= limit, + retryAfterSeconds: Math.max(1, Math.ceil(result[1] / 1000)), + } + } +} + +export class RedisJsonCache { + constructor( + private readonly client: RedisCommands, + private readonly prefix: string, + private readonly sink: LogSink = standardLogSink, + ) {} + + private key(key: string) { + return `${this.prefix}:cache:${createHash('sha256').update(key).digest('hex')}` + } + + async getOrLoad( + key: string, + ttlSeconds: number, + load: () => Promise, + validate?: (value: unknown) => value is T, + ): Promise { + if (!Number.isInteger(ttlSeconds) || ttlSeconds < 1 || ttlSeconds > 86400) + throw new Error('Cache TTL must be between 1 and 86400 seconds.') + + try { + if (this.client.isReady) { + const cached = await within(this.client.get(this.key(key))) + + if (cached !== null) { + const value: unknown = JSON.parse(cached) + + if (!validate || validate(value)) return value as T + } + } + } catch (error) { + writeLog(this.sink, 'warn', 'cache.read_failed', { + code: safeErrorCode(error), + }) + } + + const value = await load() + + try { + if (this.client.isReady) + await within( + this.client.set(this.key(key), JSON.stringify(value), { + EX: ttlSeconds, + }), + ) + } catch (error) { + // 缓存只供可重建的读取结果使用,权限和会话从不经过此降级路径。 + writeLog(this.sink, 'warn', 'cache.write_failed', { + code: safeErrorCode(error), + }) + } + + return value + } + + async invalidate(key: string): Promise { + await within(this.client.del(this.key(key))) + } +} diff --git a/apps/server/src/platform/runtime.ts b/apps/server/src/platform/runtime.ts new file mode 100644 index 00000000..95283ee8 --- /dev/null +++ b/apps/server/src/platform/runtime.ts @@ -0,0 +1,325 @@ +import type { Server } from 'node:http' +import type { NestExpressApplication } from '@nestjs/platform-express' +import type { + ErrorRequestHandler, + NextFunction, + Request, + Response, +} from 'express' +import type { ServerConfig } from './config.js' +import { + requestIdFor, + requestRoute, + safeErrorCode, + standardLogSink, + writeLog, +} from './logging.js' +import type { LogSink } from './logging.js' +import { RedisJsonCache, RedisRateLimiter, RedisStore } from './redis.js' +import type { RedisCommands } from './redis.js' + +interface RuntimeOptions { + checkDatabase: () => Promise + logSink?: LogSink +} + +function failure(response: Response, status: number, key: string) { + response + .status(status) + .json({ code: status, msg: key, data: null, error: { key } }) +} + +export class PlatformRuntime { + readonly cache: RedisJsonCache + private readonly limiter: RedisRateLimiter + private readonly sink: LogSink + private installed = false + + constructor( + private readonly config: ServerConfig, + private readonly commands: RedisCommands, + private readonly options: RuntimeOptions, + private readonly closeRedis: () => Promise = async () => {}, + ) { + this.sink = options.logSink ?? standardLogSink + this.limiter = new RedisRateLimiter(commands, config.redisKeyPrefix) + this.cache = new RedisJsonCache(commands, config.redisKeyPrefix, this.sink) + } + + static async create( + config: ServerConfig, + options: RuntimeOptions, + ): Promise { + const store = new RedisStore(config, options.logSink) + + await store.connect() + + return new PlatformRuntime(config, store.commands, options, () => + store.close(), + ) + } + + install(app: NestExpressApplication): void { + if (this.installed) + throw new Error('PlatformRuntime has already been installed.') + + this.installed = true + const instance = app.getHttpAdapter().getInstance() as { + set: (key: string, value: unknown) => void + disable: (key: string) => void + } + + instance.disable('x-powered-by') + instance.set('trust proxy', this.config.trustProxy) + app.use((request: Request, response: Response, next: NextFunction) => { + const startedAt = performance.now() + const requestId = requestIdFor(request.headers['x-request-id']) + let logged = false + + response.locals.requestId = requestId + response.setHeader('X-Request-Id', requestId) + response.setHeader('X-Content-Type-Options', 'nosniff') + response.setHeader('X-Frame-Options', 'DENY') + response.setHeader('Referrer-Policy', 'no-referrer') + response.setHeader('Cross-Origin-Resource-Policy', 'same-site') + response.setHeader( + 'Content-Security-Policy', + "default-src 'none'; frame-ancestors 'none'; base-uri 'none'; form-action 'none'", + ) + response.setHeader( + 'Permissions-Policy', + 'camera=(), microphone=(), geolocation=()', + ) + response.setHeader('Cache-Control', 'no-store') + response.vary('Origin') + + if (this.config.nodeEnv === 'production') + response.setHeader('Strict-Transport-Security', 'max-age=31536000') + + const logRequest = () => { + if (logged) return + + logged = true + writeLog(this.sink, 'info', 'http.request', { + requestId, + method: request.method, + route: requestRoute(request), + statusCode: response.writableFinished ? response.statusCode : 499, + durationMs: Math.round((performance.now() - startedAt) * 100) / 100, + }) + } + + response.once('finish', logRequest) + response.once('close', logRequest) + const origin = request.headers.origin + + if (origin && !this.config.corsOrigins.includes(origin)) { + failure(response, 403, 'forbidden') + + return + } + + if (origin) { + response.setHeader('Access-Control-Allow-Origin', origin) + response.setHeader( + 'Access-Control-Expose-Headers', + 'X-Request-Id, Retry-After', + ) + } + + if (request.method === 'OPTIONS') { + response.setHeader( + 'Access-Control-Allow-Methods', + 'GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS', + ) + response.setHeader( + 'Access-Control-Allow-Headers', + 'Authorization, Content-Type, X-Request-Id', + ) + response.setHeader('Access-Control-Max-Age', '600') + response.status(204).end() + + return + } + + next() + }) + app.useBodyParser('json', { + limit: this.config.bodyLimitBytes, + strict: true, + }) + const parserErrors: ErrorRequestHandler = ( + error: unknown, + _request, + response, + next, + ) => { + const status = + typeof error === 'object' && error !== null && 'status' in error + ? error.status + : null + + if (status === 400 || status === 413 || status === 415) { + failure( + response, + status, + status === 413 ? 'payloadTooLarge' : 'invalid', + ) + + return + } + + next(error) + } + + app.use(parserErrors) + app.use((request: Request, response: Response, next: NextFunction) => { + if (!request.path.toLowerCase().startsWith('/api/admin/')) { + next() + + return + } + + void this.limitRequest(request, response) + .then((allowed) => { + if (allowed) next() + }) + .catch((error: unknown) => { + writeLog(this.sink, 'error', 'http.rate_limit_unavailable', { + requestId: String(response.locals.requestId), + code: safeErrorCode(error), + }) + failure(response, 503, 'serviceUnavailable') + }) + }) + app.use( + '/api/health/live', + (request: Request, response: Response, next: NextFunction) => { + if (!['GET', 'HEAD'].includes(request.method) || request.path !== '/') { + next() + + return + } + + response.json({ code: 200, msg: 'OK', data: { status: 'ok' } }) + }, + ) + app.use( + '/api/health/ready', + (request: Request, response: Response, next: NextFunction) => { + if (!['GET', 'HEAD'].includes(request.method) || request.path !== '/') { + next() + + return + } + + void this.readiness().then((ready) => { + if (ready) + response.json({ code: 200, msg: 'OK', data: { status: 'ready' } }) + else failure(response, 503, 'serviceUnavailable') + }) + }, + ) + const server = app.getHttpServer() as Server + + server.requestTimeout = this.config.requestTimeoutMs + server.headersTimeout = Math.min(10000, this.config.requestTimeoutMs) + server.keepAliveTimeout = 5000 + server.once('close', () => { + void this.close() + }) + } + + private async limitRequest( + request: Request, + response: Response, + ): Promise { + const ip = request.ip || request.socket.remoteAddress || 'unknown' + const limits: Array<{ + bucket: string + identity: string + limit: number + windowMs: number + }> = [ + { + bucket: 'api', + identity: ip, + limit: this.config.rateLimitMax, + windowMs: 60000, + }, + ] + + if ( + request.method === 'POST' && + /^\/api\/admin\/auth\/login\/?$/u.test(request.path.toLowerCase()) + ) { + limits.push({ + bucket: 'login-ip', + identity: ip, + limit: this.config.loginRateLimitMax * 5, + windowMs: 900000, + }) + const username: unknown = request.body?.username + + if ( + typeof username === 'string' && + username.length <= 80 && + username.trim() + ) { + limits.push({ + bucket: 'login-account', + identity: username.trim().toLowerCase(), + limit: this.config.loginRateLimitMax, + windowMs: 900000, + }) + } + } + + for (const limit of limits) { + const result = await this.limiter.consume( + limit.bucket, + limit.identity, + limit.limit, + limit.windowMs, + ) + + if (!result.allowed) { + response.setHeader('Retry-After', result.retryAfterSeconds) + failure(response, 429, 'tooManyRequests') + + return false + } + } + + return true + } + + async readiness(): Promise { + if (!this.commands.isReady) return false + + let timeout: ReturnType + + try { + await Promise.race([ + Promise.all([this.options.checkDatabase(), this.commands.ping()]), + new Promise((_, reject) => { + timeout = setTimeout( + () => reject(new Error('Readiness timed out.')), + 2000, + ) + timeout.unref() + }), + ]) + + return true + } catch { + return false + } finally { + clearTimeout(timeout!) + } + } + + async close(): Promise { + await this.closeRedis() + } +} diff --git a/apps/server/src/seed.ts b/apps/server/src/seed.ts new file mode 100644 index 00000000..336174bb --- /dev/null +++ b/apps/server/src/seed.ts @@ -0,0 +1,147 @@ +import { + permissionCodes, + userInputSchema, +} from '@ray-template/api-contracts/admin' +import { initialRoutes, initialUserOptions } from '@ray-template/demo-data' +import type { Prisma, PrismaClient } from './generated/prisma/client' +import { parseInput } from './http' +import { writeTransaction } from './infrastructure/database' +import { hashPassword } from './modules/auth/password' + +const permissionsFor = (role: string) => + role === 'admin' + ? permissionCodes.filter((code) => code !== 'users:reset') + : role === 'manager' + ? [ + 'users:read', + 'users:create', + 'users:update', + 'users:status', + 'routes:read', + ] + : ['users:read', 'routes:read'] + +export async function seedDatabase( + database: PrismaClient, + options: { username?: string; email?: string; password?: string }, +) { + const username = options.username ?? 'admin' + const value = parseInput(userInputSchema, { + username, + email: options.email ?? `${username}@example.com`, + name: username, + phone: '', + role: 'admin', + status: 'enabled', + departmentId: 'engineering', + remark: '', + }) + const existing = await database.user.findUnique({ + where: { usernameKey: username.toLowerCase() }, + }) + + if (!existing && !options.password) + throw new Error( + 'ADMIN_PASSWORD is required to initialize the first administrator.', + ) + + const passwordHash = !existing ? await hashPassword(options.password!) : null + + return database.$transaction( + async (transaction) => { + for (const department of initialUserOptions.departments) { + await transaction.department.upsert({ + where: { id: department.id }, + create: department, + update: {}, + }) + } + + for (const code of permissionCodes.filter( + (code) => code !== 'users:reset', + )) { + await transaction.permission.upsert({ + where: { code }, + create: { code }, + update: {}, + }) + } + + for (const role of initialUserOptions.roles) { + await transaction.role.upsert({ + where: { value: role.value }, + create: { + value: role.value, + label: role.label, + labelKey: role.labelKey, + permissions: { + create: permissionsFor(role.value).map((permissionCode) => ({ + permissionCode, + })), + }, + }, + update: {}, + }) + } + + await transaction.routeConfig.upsert({ + where: { id: 'admin' }, + create: { id: 'admin', config: initialRoutes as Prisma.InputJsonValue }, + update: {}, + }) + const current = await transaction.user.findUnique({ + where: { usernameKey: username.toLowerCase() }, + }) + + if (current) return { userId: current.id, created: false } + + if (!passwordHash) + throw new Error( + 'ADMIN_PASSWORD is required to initialize the first administrator.', + ) + + const user = await transaction.user.create({ + data: { + ...value, + usernameKey: value.username.toLowerCase(), + emailKey: value.email.toLowerCase(), + credential: { create: { passwordHash } }, + }, + }) + + if (!existing) + await transaction.auditLog.create({ + data: { action: 'system.bootstrap', resourceId: user.id }, + }) + + return { userId: user.id, created: !existing } + }, + { timeout: 15000 }, + ) +} + +export async function setPassword( + database: PrismaClient, + username: string, + password: string, +) { + const passwordHash = await hashPassword(password) + + await writeTransaction(database, async (transaction) => { + const user = await transaction.user.findUnique({ + where: { usernameKey: username.trim().toLowerCase() }, + }) + + if (!user) throw new Error('The requested account does not exist.') + + await transaction.credential.upsert({ + where: { userId: user.id }, + create: { userId: user.id, passwordHash }, + update: { passwordHash }, + }) + await transaction.session.deleteMany({ where: { userId: user.id } }) + await transaction.auditLog.create({ + data: { action: 'credentials.reset', resourceId: user.id }, + }) + }) +} diff --git a/apps/server/test/integration.test.ts b/apps/server/test/integration.test.ts new file mode 100644 index 00000000..f59ef079 --- /dev/null +++ b/apps/server/test/integration.test.ts @@ -0,0 +1,725 @@ +import assert from 'node:assert/strict' +import { spawnSync } from 'node:child_process' +import { createHash, randomBytes } from 'node:crypto' +import { + copyFile, + mkdir, + mkdtemp, + readdir, + readFile, + rm, + writeFile, +} from 'node:fs/promises' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { after, before, test } from 'node:test' +import { + loginResultSchema, + sessionSchema, + userListSchema, + userOptionsSchema, + userSchema, +} from '@ray-template/api-contracts/admin' +import type { + AdminUser, + ApiResponse, + LoginResult, + UserInput, +} from '@ray-template/api-contracts/admin' +import { + chartsSchema, + ordersResultSchema, + ownerOptionsSchema, + peopleResultSchema, + requestFixtureSchema, + routeDemoPersonSchema, + routePeopleResultSchema, + searchOptionsSchema, +} from '@ray-template/api-contracts/demo' +import type { RouteConfig } from '@ray-template/api-contracts/routes' +import { parseApplicationRoutes } from '@ray-template/demo-data' +import { Pool } from 'pg' +import { createClient } from 'redis' +import * as v from 'valibot' +import { createApp } from '../src/app' +import { createDatabase } from '../src/infrastructure/database' +import { createToken, tokenHash } from '../src/modules/auth/password' +import { loadServerConfig } from '../src/platform/index' +import { seedDatabase, setPassword } from '../src/seed' + +assert.ok( + process.env.TEST_DATABASE_URL, + 'Set TEST_DATABASE_URL to a disposable PostgreSQL database before running server integration tests.', +) +assert.ok( + process.env.TEST_REDIS_URL, + 'Set TEST_REDIS_URL to a disposable Redis instance before running server integration tests.', +) + +const suffix = randomBytes(8).toString('hex') +const schema = `ray_test_${suffix}` +const databaseUrl = new URL(process.env.TEST_DATABASE_URL) + +databaseUrl.searchParams.set('schema', schema) + +const pool = new Pool({ + connectionString: process.env.TEST_DATABASE_URL, + max: 1, +}) +const database = createDatabase(databaseUrl.toString()) +const password = `integration-${createToken()}` +const config = loadServerConfig({ + NODE_ENV: 'test', + DATABASE_URL: databaseUrl.toString(), + REDIS_URL: process.env.TEST_REDIS_URL, + REDIS_KEY_PREFIX: `ray:test:${suffix}`, + PORT: '0', + SESSION_TTL_SECONDS: '3600', + LOGIN_RATE_LIMIT_MAX: '100', + RATE_LIMIT_MAX: '10000', +}) +let app: Awaited> | null = null +let base = '' +let adminToken = '' +let adminId = '' + +async function request( + path: string, + options: { + method?: string + body?: unknown + token?: string + origin?: string + } = {}, +) { + const response = await fetch(`${options.origin ?? base}/api/${path}`, { + method: options.method ?? 'GET', + headers: { + 'Content-Type': 'application/json', + ...(options.token ? { Authorization: `Bearer ${options.token}` } : {}), + }, + body: options.body === void 0 ? void 0 : JSON.stringify(options.body), + }) + + return { + status: response.status, + headers: response.headers, + body: (await response.json()) as ApiResponse, + } +} + +async function login(username: string, supplied = password) { + const result = await request('admin/auth/login', { + method: 'POST', + body: { username, password: supplied }, + }) + + assert.equal(result.status, 200) + v.parse(loginResultSchema, result.body.data) + + return result.body.data +} + +const input = ( + username: string, + extra: Partial = {}, +): UserInput => ({ + username, + email: `${username}@example.com`, + name: username, + phone: '', + departmentId: 'engineering', + role: 'member', + status: 'enabled', + remark: '', + ...extra, +}) + +async function create(username: string, extra: Partial = {}) { + const result = await request('admin/users', { + method: 'POST', + token: adminToken, + body: input(username, extra), + }) + + assert.equal(result.status, 200) + v.parse(userSchema, result.body.data) + + return result.body.data +} + +before(async () => { + await pool.query(`CREATE SCHEMA "${schema}"`) + await pool.query(`SET search_path TO "${schema}"`) + const directory = new URL('../prisma/migrations/', import.meta.url) + const migrations = await readdir(directory, { withFileTypes: true }) + + for (const migration of migrations + .filter((entry) => entry.isDirectory()) + .sort((left, right) => left.name.localeCompare(right.name))) { + await pool.query( + await readFile( + new URL(`${migration.name}/migration.sql`, directory), + 'utf8', + ), + ) + } + + const seeded = await seedDatabase(database, { username: 'admin', password }) + + adminId = seeded.userId + app = await createApp(config, { logSink: () => {} }) + await app.listen(0, '127.0.0.1') + base = await app.getUrl() + adminToken = (await login('admin')).accessToken +}) + +after(async () => { + await app?.close() + await database.$disconnect() + await pool.query(`DROP SCHEMA IF EXISTS "${schema}" CASCADE`) + await pool.end() + const redis = createClient({ + url: config.redisUrl, + socket: { connectTimeout: 2000, reconnectStrategy: false }, + }) + + redis.on('error', () => {}) + + try { + await redis.connect() + const keys = await redis.keys(`${config.redisKeyPrefix}:*`) + + if (keys.length) await redis.del(keys) + } finally { + if (redis.isOpen) await redis.quit() + } +}) + +test('public startup routes, authentication, envelope and current permissions match shared contracts', async () => { + const routes = await request('admin/route-config') + + assert.equal(routes.status, 200) + parseApplicationRoutes(JSON.stringify(routes.body.data)) + assert.equal((await request('admin/users')).status, 401) + assert.equal((await request('admin/route-config?view=editor')).status, 401) + assert.equal( + ( + await request('admin/auth/login', { + method: 'POST', + body: { username: 'admin', password: 'wrong' }, + }) + ).status, + 401, + ) + const session = await request('admin/auth/session', { token: adminToken }) + + v.parse(sessionSchema, session.body.data) + assert.ok(session.headers.get('x-request-id')) + const stored = await database.session.findUnique({ + where: { tokenHash: tokenHash(adminToken) }, + }) + + assert.ok(stored) + assert.notEqual(stored.tokenHash, adminToken) + const options = await request('admin/users/options', { token: adminToken }) + + v.parse(userOptionsSchema, options.body.data) +}) + +test('the development launcher refuses a port already serving backend readiness', async () => { + const fixture = await mkdtemp(join(tmpdir(), 'ray-launcher-')) + + try { + await mkdir(join(fixture, 'scripts')) + await mkdir(join(fixture, 'apps/server'), { recursive: true }) + await writeFile(join(fixture, 'apps/server/.env.local'), '') + await copyFile( + new URL('../../../scripts/fullstack.mjs', import.meta.url), + join(fixture, 'scripts/fullstack.mjs'), + ) + const port = new URL(base).port + const result = spawnSync( + process.execPath, + ['scripts/fullstack.mjs', 'dev'], + { + cwd: fixture, + env: { + ...process.env, + PORT: port, + ADMIN_DEV_PORT: port === '9527' ? '9528' : '9527', + }, + encoding: 'utf8', + timeout: 5000, + }, + ) + + assert.equal(result.status, 1) + assert.match(result.stderr, /Backend port \d+ is not available/u) + assert.equal((await fetch(`${base}/api/health/ready`)).status, 200) + } finally { + await rm(fixture, { force: true, recursive: true }) + } +}) + +test('read-only and manager accounts cannot bypass endpoint or role authorization', async () => { + const reader = await create('reader') + const manager = await create('manager', { role: 'manager' }) + + await setPassword(database, reader.username, password) + await setPassword(database, manager.username, password) + const memberToken = (await login('reader')).accessToken + const managerToken = (await login('manager')).accessToken + + assert.equal( + (await request('admin/route-config?view=editor', { token: memberToken })) + .status, + 403, + ) + + assert.equal( + ( + await request('admin/users', { + method: 'POST', + token: memberToken, + body: input('no-create'), + }) + ).status, + 403, + ) + assert.equal( + ( + await request('admin/users', { + method: 'POST', + token: managerToken, + body: input('no-admin', { role: 'admin' }), + }) + ).status, + 403, + ) + assert.equal( + ( + await request(`admin/users/${adminId}`, { + method: 'PUT', + token: managerToken, + body: input('admin'), + }) + ).status, + 403, + ) + assert.equal( + ( + await request('admin/route-config', { + method: 'PUT', + token: memberToken, + body: { version: 1, routes: [] }, + }) + ).status, + 403, + ) + const list = await request('admin/users?page=1&pageSize=10', { + token: memberToken, + }) + + v.parse(userListSchema, list.body.data) +}) + +test('creation, case-insensitive uniqueness, filtering and serialization protect credentials', async () => { + const user = await create('CaseAccount', { departmentId: 'platform' }) + const duplicate = await request('admin/users', { + method: 'POST', + token: adminToken, + body: input('caseaccount'), + }) + + assert.equal(duplicate.status, 409) + assert.equal(duplicate.body.error?.key, 'duplicateUsername') + const duplicateEmail = await request('admin/users', { + method: 'POST', + token: adminToken, + body: input('other-name', { email: 'CASEACCOUNT@EXAMPLE.COM' }), + }) + + assert.equal(duplicateEmail.status, 409) + assert.equal(duplicateEmail.body.error?.key, 'duplicateEmail') + assert.equal( + ( + await request('admin/auth/login', { + method: 'POST', + body: { username: user.username, password }, + }) + ).status, + 401, + ) + const listed = await request<{ items: AdminUser[]; total: number }>( + 'admin/users?departmentId=engineering&name=CaseAccount&page=1&pageSize=1', + { token: adminToken }, + ) + + assert.equal(listed.body.data.total, 1) + assert.equal(listed.body.data.items[0].id, user.id) + assert.equal(JSON.stringify(listed.body).includes('passwordHash'), false) + assert.equal(JSON.stringify(listed.body).includes('usernameKey'), false) + assert.equal( + (await request('admin/users?page=1&page=2', { token: adminToken })).status, + 400, + ) + assert.equal( + (await request('admin/users?pageSize=101', { token: adminToken })).status, + 400, + ) + assert.equal( + (await request('admin/users?page=9007199254740992', { token: adminToken })) + .status, + 400, + ) +}) + +test('batch changes are all-or-none and current account remains protected', async () => { + const user = await create('batch-target') + const failedStatus = await request('admin/users/status', { + method: 'PATCH', + token: adminToken, + body: { ids: [user.id, adminId], status: 'disabled' }, + }) + + assert.equal(failedStatus.status, 409) + assert.equal( + (await database.user.findUniqueOrThrow({ where: { id: user.id } })).status, + 'enabled', + ) + const failedDelete = await request('admin/users/batch-delete', { + method: 'POST', + token: adminToken, + body: { ids: [user.id, 'missing-user'] }, + }) + + assert.equal(failedDelete.status, 404) + assert.ok(await database.user.findUnique({ where: { id: user.id } })) + assert.equal( + ( + await request(`admin/users/${adminId}`, { + method: 'PUT', + token: adminToken, + body: input('admin', { role: 'member' }), + }) + ).status, + 409, + ) + const deleted = await request<{ affected: number }>( + 'admin/users/batch-delete', + { method: 'POST', token: adminToken, body: { ids: [user.id, user.id] } }, + ) + + assert.equal(deleted.body.data.affected, 1) +}) + +test('logout, expiry, password reset and disabling an account revoke effective access', async () => { + const user = await create('sessions-user') + + await setPassword(database, user.username, password) + const first = await login(user.username) + + assert.equal( + ( + await request('admin/auth/logout', { + method: 'POST', + token: first.accessToken, + }) + ).status, + 200, + ) + assert.equal( + (await request('admin/auth/session', { token: first.accessToken })).status, + 401, + ) + const expired = await login(user.username) + + await database.session.update({ + where: { tokenHash: tokenHash(expired.accessToken) }, + data: { expiresAt: new Date(Date.now() - 1000) }, + }) + assert.equal( + (await request('admin/auth/session', { token: expired.accessToken })) + .status, + 401, + ) + const reset = await login(user.username) + const nextPassword = `${password}x` + + await setPassword(database, user.username, nextPassword) + assert.equal( + (await request('admin/auth/session', { token: reset.accessToken })).status, + 401, + ) + assert.equal( + ( + await request('admin/auth/login', { + method: 'POST', + body: { username: user.username, password }, + }) + ).status, + 401, + ) + const active = await login(user.username, nextPassword) + + assert.equal( + ( + await request('admin/users/status', { + method: 'PATCH', + token: adminToken, + body: { ids: [user.id], status: 'disabled' }, + }) + ).status, + 200, + ) + assert.equal( + (await request('admin/auth/session', { token: active.accessToken })).status, + 401, + ) + await request('admin/users/status', { + method: 'PATCH', + token: adminToken, + body: { ids: [user.id], status: 'enabled' }, + }) + assert.equal( + (await request('admin/auth/session', { token: active.accessToken })).status, + 401, + ) +}) + +test('route validation prevents unusable startup data and valid changes survive application restart', async () => { + const before = await request<{ version: number; routes: unknown[] }>( + 'admin/route-config', + ) + const bad = await request('admin/route-config', { + method: 'PUT', + token: adminToken, + body: { + version: 1, + routes: [{ path: '/unknown', component: 'unknown-view', meta: {} }], + }, + }) + + assert.equal(bad.status, 400) + assert.deepEqual( + (await request('admin/route-config')).body.data, + before.body.data, + ) + const valid = { + version: 1, + routes: [ + { + path: '/dashboard', + name: 'RDashboard', + component: 'dashboard', + meta: { keepAlive: true, noLocalTitle: 'Integration Dashboard' }, + }, + ], + } + + assert.equal( + ( + await request('admin/route-config', { + method: 'PUT', + token: adminToken, + body: valid, + }) + ).status, + 200, + ) + await app!.close() + app = await createApp(config, { logSink: () => {} }) + await app.listen(0, '127.0.0.1') + base = await app.getUrl() + assert.deepEqual((await request('admin/route-config')).body.data, valid) + assert.equal( + (await request('admin/auth/session', { token: adminToken })).status, + 200, + ) + const seeded = await seedDatabase(database, { username: 'admin' }) + + assert.equal(seeded.created, false) + assert.deepEqual((await request('admin/route-config')).body.data, valid) + await request('admin/route-config', { + method: 'PUT', + token: adminToken, + body: before.body.data, + }) + const audit = await database.auditLog.findMany({ + where: { action: 'routes.update' }, + }) + + assert.ok(audit.length >= 2) + assert.ok( + audit.every((record) => record.actorId === adminId && record.requestId), + ) + assert.equal(JSON.stringify(audit).includes(password), false) +}) + +test('enabled demos implement the shared API, cache fixed reads and validate input', async () => { + const get = async (path: string, schema: S) => { + const result = await request(`admin/demo/${path}`) + + assert.equal(result.status, 200) + + return v.parse(schema, result.body.data) + } + const post = async ( + path: string, + schema: S, + body: unknown, + ) => { + const result = await request(`admin/demo/${path}`, { method: 'POST', body }) + + assert.equal(result.status, 200) + + return v.parse(schema, result.body.data) + } + + await get('request', requestFixtureSchema) + const charts = await get('charts', chartsSchema) + const refreshed = await get('charts?refresh=true', chartsSchema) + + assert.deepEqual(charts.days, refreshed.days) + assert.deepEqual(await get('charts?refresh=false', chartsSchema), charts) + const people = await get( + 'people?page=2&pageSize=3&sortAge=ascend', + peopleResultSchema, + ) + + assert.equal(people.items.length, 3) + assert.ok(people.items[0].age <= people.items[2].age) + const routePeople = await get( + 'route-people?page=2&pageSize=2', + routePeopleResultSchema, + ) + + assert.deepEqual( + routePeople.items.map(({ key }) => key), + [2, 3], + ) + assert.deepEqual( + await get('route-people/2', routeDemoPersonSchema), + routePeople.items[0], + ) + const english = await get('search-options?locale=en-US', searchOptionsSchema) + const chinese = await get('search-options', searchOptionsSchema) + + assert.equal(english.organizations[0].label, 'North') + assert.equal(chinese.organizations[0].label, '北区') + assert.deepEqual( + await post('owners/search', ownerOptionsSchema, { + orgId: 'north', + keyword: 'chen', + locale: 'en-US', + }), + [{ label: 'Chen', value: 'n1' }], + ) + const orders = await post('orders/search', ordersResultSchema, { + query: { ownerId: 'n1', page: 2, pageSize: 3 }, + locale: 'en-US', + }) + + assert.ok(orders.total > 3) + assert.equal(orders.items.length, 3) + assert.ok(orders.items.every(({ owner }) => owner === 'Chen')) + assert.equal( + (await request('admin/demo/people?fail=true')).body.error?.key, + 'requestFailed', + ) + assert.equal((await request('admin/demo/people?fail=yes')).status, 400) + assert.equal((await request('admin/demo/route-people/999')).status, 404) + assert.equal( + ( + await request('admin/demo/orders/search', { + method: 'POST', + body: { query: { pageSize: 101 }, locale: 'en-US' }, + }) + ).status, + 400, + ) + + const redis = createClient({ url: config.redisUrl }) + + await redis.connect() + + try { + const digest = createHash('sha256').update('demo:v1:charts').digest('hex') + const key = `${config.redisKeyPrefix}:cache:${digest}` + + assert.deepEqual(JSON.parse((await redis.get(key))!), charts) + assert.ok((await redis.ttl(key)) > 0) + } finally { + await redis.quit() + } +}) + +test('disabling demos hides runtime routes and endpoints without dropping editable routes', async () => { + const original = (await request('admin/route-config')).body.data + const full: RouteConfig = { + ...original, + routes: [ + ...original.routes, + { + path: '/extra-demo', + component: 'demo/form', + alias: '/demo-alias', + meta: {}, + }, + { path: '/go-demo', redirect: '/demo-alias', meta: {} }, + { path: '/go-home', redirect: '/dashboard', meta: {} }, + ], + } + + assert.equal( + ( + await request('admin/route-config', { + method: 'PUT', + token: adminToken, + body: full, + }) + ).status, + 200, + ) + const disabled = await createApp( + { ...config, demoEnabled: false }, + { logSink: () => {} }, + ) + + try { + await disabled.listen(0, '127.0.0.1') + const origin = await disabled.getUrl() + const runtime = await request('admin/route-config', { origin }) + + assert.equal(runtime.status, 200) + const effective = parseApplicationRoutes(JSON.stringify(runtime.body.data)) + + assert.equal(JSON.stringify(effective).includes('demo/'), false) + assert.deepEqual( + effective.routes.map(({ path }) => path), + ['/dashboard', '/system', '/go-home'], + ) + assert.equal((await request('admin/demo/charts', { origin })).status, 404) + assert.equal( + (await request('admin/route-config?view=editor', { origin })).status, + 401, + ) + assert.deepEqual( + ( + await request('admin/route-config?view=editor', { + origin, + token: adminToken, + }) + ).body.data, + full, + ) + } finally { + await disabled.close() + await request('admin/route-config', { + method: 'PUT', + token: adminToken, + body: original, + }) + } +}) diff --git a/apps/server/test/platform.test.ts b/apps/server/test/platform.test.ts new file mode 100644 index 00000000..565c0e0e --- /dev/null +++ b/apps/server/test/platform.test.ts @@ -0,0 +1,428 @@ +import assert from 'node:assert/strict' +import { randomUUID } from 'node:crypto' +import type { AddressInfo } from 'node:net' +import { test } from 'node:test' +import { Module } from '@nestjs/common' +import { NestFactory } from '@nestjs/core' +import type { NestExpressApplication } from '@nestjs/platform-express' +import type { Express, Request, Response } from 'express' +import { loadServerConfig } from '../src/platform/config.js' +import { + requestIdFor, + safeErrorCode, + writeLog, +} from '../src/platform/logging.js' +import { + RedisJsonCache, + RedisRateLimiter, + RedisStore, +} from '../src/platform/redis.js' +import type { RedisCommands } from '../src/platform/redis.js' +import { PlatformRuntime } from '../src/platform/runtime.js' + +const config = (extra: NodeJS.ProcessEnv = {}) => + loadServerConfig({ + NODE_ENV: 'test', + DATABASE_URL: 'postgresql://test:test@127.0.0.1:5432/test', + REDIS_URL: process.env.TEST_REDIS_URL || 'redis://127.0.0.1:6379', + CORS_ORIGINS: 'http://localhost:9527', + REDIS_KEY_PREFIX: `ray:test:${randomUUID()}`, + ...extra, + }) + +class TestRedis implements RedisCommands { + isReady = true + readonly values = new Map() + readonly counters = new Map() + readonly consumedKeys: string[] = [] + + async eval( + _script: string, + options: { keys: string[]; arguments: string[] }, + ) { + const key = options.keys[0] + const count = (this.counters.get(key) ?? 0) + 1 + + this.counters.set(key, count) + this.consumedKeys.push(key) + + return [count, Number(options.arguments[0])] + } + + async get(key: string) { + return this.values.get(key) ?? null + } + async set(key: string, value: string) { + this.values.set(key, value) + } + async del(key: string) { + this.values.delete(key) + } + async ping() { + return 'PONG' + } +} + +class TestModule {} + +Module({})(TestModule) + +async function withHttp( + options: { + env?: NodeJS.ProcessEnv + redis?: TestRedis + checkDatabase?: () => Promise + }, + run: (input: { + url: string + logs: string[] + redis: TestRedis + calls: () => number + }) => Promise, +) { + const redis = options.redis ?? new TestRedis() + const logs: string[] = [] + const app = await NestFactory.create(TestModule, { + logger: false, + bodyParser: false, + }) + const runtime = new PlatformRuntime(config(options.env), redis, { + checkDatabase: options.checkDatabase ?? (async () => true), + logSink: (line) => logs.push(line), + }) + + runtime.install(app) + let calls = 0 + const handler = (_request: Request, response: Response) => { + calls += 1 + response.json({ code: 200, msg: 'OK', data: null }) + } + + const express = app.getHttpAdapter().getInstance() as Express + + express.post('/api/admin/auth/login', handler) + express.get('/api/admin/users/:id', handler) + await app.listen(0, '127.0.0.1') + const address = app.getHttpServer().address() as AddressInfo + + try { + await run({ + url: `http://127.0.0.1:${address.port}`, + logs, + redis, + calls: () => calls, + }) + } finally { + await app.close() + await runtime.close() + } +} + +test('configuration rejects malformed and unsafe inputs without exposing secrets', () => { + const value = config() + + assert.equal(value.trustProxy, false) + assert.equal(value.demoEnabled, true) + assert.equal(value.sessionTtlSeconds, 28800) + assert.equal(config({ NODE_ENV: 'production' }).demoEnabled, false) + assert.deepEqual( + config({ TRUST_PROXY: '127.0.0.1,10.0.0.0/8,::1' }).trustProxy, + ['127.0.0.1', '10.0.0.0/8', '::1'], + ) + + for (const env of [ + { CORS_ORIGINS: '*' }, + { CORS_ORIGINS: 'https://example.com/path' }, + { TRUST_PROXY: 'true' }, + { TRUST_PROXY: '1' }, + { TRUST_PROXY: '0.0.0.0/0' }, + { TRUST_PROXY: '::/0' }, + { TRUST_PROXY: '10.0.0.0/99' }, + { NODE_ENV: 'prod' }, + { RATE_LIMIT_MAX: 'Infinity' }, + { SESSION_TTL_SECONDS: '0' }, + { DEMO_ENABLED: 'yes' }, + { REDIS_KEY_PREFIX: 'space is forbidden' }, + ]) + assert.throws(() => config(env)) + + assert.throws( + () => + config({ DATABASE_URL: 'mysql://root:private-password@localhost/db' }), + (error: unknown) => + error instanceof Error && !error.message.includes('private-password'), + ) +}) + +test('logs preserve diagnostic fields while omitting arbitrary secrets and error messages', () => { + const lines: string[] = [] + + writeLog((line) => lines.push(line), 'warn', 'dependency.failed', { + requestId: 'request-1234', + statusCode: 503, + password: 'secret-password', + accessToken: 'secret-token', + body: { password: 'secret-body' }, + } as Parameters[3]) + assert.equal(lines.length, 1) + assert.equal(JSON.parse(lines[0]).requestId, 'request-1234') + assert.doesNotMatch(lines[0], /secret|password|accessToken|body/u) + assert.equal( + safeErrorCode({ code: 'ECONNREFUSED', message: 'secret' }), + 'ECONNREFUSED', + ) + assert.equal(safeErrorCode({ code: 'private-password' }), 'DEPENDENCY_ERROR') + assert.equal(requestIdFor('valid-request-123'), 'valid-request-123') + assert.notEqual(requestIdFor('line\nbreak'), 'line\nbreak') +}) + +test('HTTP security, CORS and JSON limits run before handlers', async () => { + await withHttp( + { env: { BODY_LIMIT_BYTES: '1024' } }, + async ({ url, calls }) => { + const request = (body: string, origin = 'http://localhost:9527') => + fetch(`${url}/api/admin/auth/login`, { + method: 'POST', + headers: { 'content-type': 'application/json', origin }, + body, + }) + const denied = await request( + '{"username":"admin"}', + 'https://attacker.example', + ) + + assert.equal(denied.status, 403) + assert.equal(calls(), 0) + assert.equal(denied.headers.get('x-content-type-options'), 'nosniff') + assert.equal(denied.headers.get('x-powered-by'), null) + const malformed = await request('{invalid-secret') + + assert.equal(malformed.status, 400) + assert.doesNotMatch(await malformed.text(), /invalid-secret/u) + const oversized = await request( + JSON.stringify({ password: 'x'.repeat(2048) }), + ) + + assert.equal(oversized.status, 413) + assert.equal(calls(), 0) + const allowed = await request('{"username":"admin"}') + + assert.equal(allowed.status, 200) + assert.equal( + allowed.headers.get('access-control-allow-origin'), + 'http://localhost:9527', + ) + assert.ok(allowed.headers.get('x-request-id')) + assert.equal(allowed.headers.get('cache-control'), 'no-store') + assert.equal(calls(), 1) + }, + ) +}) + +test('login limit normalizes usernames, covers case-insensitive routes and ignores spoofed proxy headers', async () => { + await withHttp( + { env: { LOGIN_RATE_LIMIT_MAX: '1' } }, + async ({ url, redis, calls }) => { + const request = (username: string, forwarded: string, path: string) => + fetch(`${url}${path}`, { + method: 'POST', + headers: { + 'content-type': 'application/json', + 'x-forwarded-for': forwarded, + }, + body: JSON.stringify({ username, password: 'secret-password' }), + }) + const first = await request('Admin', '1.1.1.1', '/api/admin/auth/login') + const second = await request( + ' ADMIN ', + '2.2.2.2', + '/API/ADMIN/AUTH/LOGIN/', + ) + + assert.equal(first.status, 200) + assert.equal(second.status, 429) + assert.ok(Number(second.headers.get('retry-after')) > 0) + assert.equal( + ((await second.json()) as { error: { key: string } }).error.key, + 'tooManyRequests', + ) + assert.equal(calls(), 1) + const ipKeys = redis.consumedKeys.filter((key) => + key.includes(':limit:api:'), + ) + + assert.equal(ipKeys[0], ipKeys[1]) + assert.ok( + redis.consumedKeys.every( + (key) => !key.includes('Admin') && !key.includes('secret-password'), + ), + ) + }, + ) +}) + +test('Redis outage fails closed for API access but liveness remains healthy', async () => { + const redis = new TestRedis() + + redis.isReady = false + await withHttp({ redis }, async ({ url, calls }) => { + const blocked = await fetch( + `${url}/api/admin/users/secret-id?token=secret-query`, + { headers: { authorization: 'Bearer secret-token' } }, + ) + + assert.equal(blocked.status, 503) + assert.equal(calls(), 0) + assert.equal((await fetch(`${url}/api/health/live`)).status, 200) + assert.equal((await fetch(`${url}/api/health/ready`)).status, 503) + }) +}) + +test('request logs use route templates and omit credentials, query strings and resource IDs', async () => { + await withHttp({}, async ({ url, logs }) => { + const response = await fetch( + `${url}/api/admin/users/private-user-id?token=private-query`, + { + headers: { + authorization: 'Bearer private-token', + cookie: 'session=private-cookie', + }, + }, + ) + + await response.text() + const requests = logs + .map((line) => JSON.parse(line)) + .filter((entry) => entry.event === 'http.request') + + assert.equal(requests.length, 1) + assert.equal(requests[0].route, '/api/admin/users/:id') + assert.equal(requests[0].statusCode, 200) + assert.doesNotMatch(logs.join('\n'), /private-|authorization|cookie/u) + }) +}) + +test('readiness checks database as well as Redis without exposing connection errors', async () => { + await withHttp( + { + checkDatabase: async () => { + throw new Error('postgresql://private-secret') + }, + }, + async ({ url }) => { + const response = await fetch(`${url}/api/health/ready`) + + assert.equal(response.status, 503) + assert.doesNotMatch(await response.text(), /postgresql|private-secret/u) + }, + ) +}) + +test('cache TTL, hits, invalid data and outages preserve loader failures and fresh results', async () => { + const redis = new TestRedis() + const cache = new RedisJsonCache(redis, 'test', () => {}) + let calls = 0 + const loader = async () => ({ value: ++calls }) + const valid = (value: unknown): value is { value: number } => + typeof value === 'object' && + value !== null && + 'value' in value && + typeof value.value === 'number' + + assert.deepEqual(await cache.getOrLoad('key', 30, loader, valid), { + value: 1, + }) + assert.deepEqual(await cache.getOrLoad('key', 30, loader, valid), { + value: 1, + }) + + for (const key of redis.values.keys()) redis.values.set(key, '{broken') + + assert.deepEqual(await cache.getOrLoad('key', 30, loader, valid), { + value: 2, + }) + await cache.invalidate('key') + assert.deepEqual(await cache.getOrLoad('key', 30, loader, valid), { + value: 3, + }) + redis.isReady = false + assert.deepEqual(await cache.getOrLoad('key', 30, loader, valid), { + value: 4, + }) + await assert.rejects( + () => + cache.getOrLoad('bad', 30, async () => { + throw new Error('loader failed') + }), + /loader failed/u, + ) + await assert.rejects(() => cache.getOrLoad('bad', 0, loader), /TTL/u) +}) + +test('Redis limiter rejects malformed counters and dependency failures', async () => { + const redis = new TestRedis() + const limiter = new RedisRateLimiter(redis, 'test') + + redis.eval = async () => [1, -1] + await assert.rejects( + () => limiter.consume('login', 'admin', 1, 60000), + /invalid/u, + ) + redis.isReady = false + await assert.rejects( + () => limiter.consume('login', 'admin', 1, 60000), + /unavailable/u, + ) +}) + +test( + 'real Redis rate limits atomically across concurrent callers and expires the bucket', + { skip: !process.env.TEST_REDIS_URL }, + async () => { + const value = config() + const store = new RedisStore(value, () => {}) + + await store.connect() + + try { + const limiter = new RedisRateLimiter(store.commands, value.redisKeyPrefix) + const outcomes = await Promise.all( + Array.from({ length: 25 }, () => + limiter.consume('login', 'test-user', 10, 10000), + ), + ) + + assert.equal(outcomes.filter((item) => item.allowed).length, 10) + assert.equal( + (await limiter.consume('expiry', 'test-user', 1, 100)).allowed, + true, + ) + assert.equal( + (await limiter.consume('expiry', 'test-user', 1, 100)).allowed, + false, + ) + await new Promise((resolve) => setTimeout(resolve, 140)) + assert.equal( + (await limiter.consume('expiry', 'test-user', 1, 100)).allowed, + true, + ) + const cache = new RedisJsonCache( + store.commands, + value.redisKeyPrefix, + () => {}, + ) + + assert.deepEqual( + await cache.getOrLoad('sample', 1, async () => ({ test: true })), + { test: true }, + ) + assert.deepEqual( + await cache.getOrLoad('sample', 1, async () => ({ test: false })), + { test: true }, + ) + await cache.invalidate('sample') + } finally { + await store.close() + } + }, +) diff --git a/apps/server/test/unit.test.ts b/apps/server/test/unit.test.ts new file mode 100644 index 00000000..33fa090c --- /dev/null +++ b/apps/server/test/unit.test.ts @@ -0,0 +1,51 @@ +import assert from 'node:assert/strict' +import { test } from 'node:test' +import { userInputSchema } from '@ray-template/api-contracts/admin' +import { ApiError, parseInput, queryInput } from '../src/http' +import { + createToken, + hashPassword, + tokenHash, + validateNewPassword, + verifyPassword, +} from '../src/modules/auth/password' + +test('password credentials use independent salts and reject corrupt or incorrect credentials', async () => { + const password = `unit-${createToken()}` + const first = await hashPassword(password) + const second = await hashPassword(password) + + assert.notEqual(first, second) + assert.equal(first.includes(password), false) + assert.equal(await verifyPassword(password, first), true) + assert.equal(await verifyPassword(`${password}wrong`, first), false) + assert.equal(await verifyPassword(password, null), false) + assert.equal(await verifyPassword(password, 'scrypt$bad$bad'), false) + assert.throws(() => validateNewPassword('short')) + assert.throws(() => validateNewPassword('x'.repeat(129))) +}) + +test('session tokens are unguessable identifiers and only their digest is persisted', () => { + const first = createToken() + const second = createToken() + + assert.notEqual(first, second) + assert.notEqual(tokenHash(first), first) + assert.equal(tokenHash(first), tokenHash(first)) + assert.notEqual(tokenHash(first), tokenHash(second)) +}) + +test('HTTP query conversion rejects arrays and ambiguous numeric strings', () => { + assert.deepEqual(queryInput({ page: '2', pageSize: '25', name: 'Alex' }), { + page: 2, + pageSize: 25, + name: 'Alex', + }) + assert.throws(() => queryInput({ page: ['1', '2'] }), ApiError) + assert.throws(() => queryInput({ pageSize: '1e2' }), ApiError) + assert.throws(() => queryInput({ page: '' }), ApiError) + assert.throws( + () => parseInput(userInputSchema, { username: 'bad' }), + ApiError, + ) +}) diff --git a/apps/server/tsconfig.json b/apps/server/tsconfig.json new file mode 100644 index 00000000..2a74dc81 --- /dev/null +++ b/apps/server/tsconfig.json @@ -0,0 +1,18 @@ +{ + "compilerOptions": { + "target": "ES2023", + "module": "ESNext", + "moduleResolution": "Bundler", + "lib": ["ES2023"], + "types": ["node"], + "strict": true, + "noEmit": true, + "esModuleInterop": true, + "resolveJsonModule": true, + "allowImportingTsExtensions": true, + "experimentalDecorators": true, + "emitDecoratorMetadata": false, + "skipLibCheck": true + }, + "include": ["src/**/*.ts", "test/**/*.ts", "prisma.config.ts"] +} diff --git a/deploy/Dockerfile b/deploy/Dockerfile new file mode 100644 index 00000000..2ba6afeb --- /dev/null +++ b/deploy/Dockerfile @@ -0,0 +1,28 @@ +FROM node:26.13.0-bookworm-slim AS node-base +RUN apt-get update && apt-get install -y --no-install-recommends openssl ca-certificates \ + && rm -rf /var/lib/apt/lists/* + +FROM node-base AS workspace +WORKDIR /workspace +RUN npm install --global pnpm@12.16.1 +COPY . . +RUN HUSKY=0 pnpm install --frozen-lockfile + +FROM workspace AS server-build +RUN pnpm server:build +RUN pnpm --filter @ray-template/server deploy --legacy /server + +FROM workspace AS admin-build +RUN VITE_API_MOCK=false VITE_API_BASE_URL=/api/ pnpm build + +FROM node-base AS server +WORKDIR /app +COPY --from=server-build --chown=node:node /server . +USER node +EXPOSE 3000 +CMD ["node", "dist/main.mjs"] + +FROM nginx:stable-alpine AS admin +COPY --from=admin-build /workspace/dist/production /usr/share/nginx/html/ray-template +COPY deploy/nginx.conf /etc/nginx/conf.d/default.conf +EXPOSE 80 diff --git a/deploy/compose.yaml b/deploy/compose.yaml new file mode 100644 index 00000000..330804a9 --- /dev/null +++ b/deploy/compose.yaml @@ -0,0 +1,115 @@ +x-server-environment: &server-environment + NODE_ENV: production + HOST: 0.0.0.0 + PORT: '3000' + DATABASE_URL: ${APP_DATABASE_URL:-postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@postgres:5432/${POSTGRES_DB:-ray_template}} + REDIS_URL: ${APP_REDIS_URL:-redis://:${REDIS_PASSWORD}@redis:6379} + DEMO_ENABLED: ${APP_DEMO_ENABLED:-false} + CORS_ORIGINS: ${APP_ORIGINS:-http://127.0.0.1:${APP_PORT:-8080},http://localhost:${APP_PORT:-8080}} + +services: + postgres: + image: postgres:18-alpine + environment: + POSTGRES_USER: ${POSTGRES_USER:?Run pnpm fullstack:setup first} + POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:?Run pnpm fullstack:setup first} + POSTGRES_DB: ${POSTGRES_DB:-ray_template} + ports: + - '127.0.0.1:${POSTGRES_PORT:-5432}:5432' + volumes: + - postgres:/var/lib/postgresql + healthcheck: + test: + ['CMD-SHELL', 'pg_isready -U "$${POSTGRES_USER}" -d "$${POSTGRES_DB}"'] + interval: 3s + timeout: 3s + retries: 20 + redis: + image: redis:8.2.11-alpine + environment: + REDIS_PASSWORD: ${REDIS_PASSWORD:?Run pnpm fullstack:setup first} + REDISCLI_AUTH: ${REDIS_PASSWORD:?Run pnpm fullstack:setup first} + command: + [ + 'sh', + '-c', + 'exec redis-server --appendonly yes --requirepass "$${REDIS_PASSWORD}"', + ] + ports: + - '127.0.0.1:${REDIS_PORT:-6379}:6379' + volumes: + - redis:/data + healthcheck: + test: ['CMD', 'redis-cli', 'ping'] + interval: 3s + timeout: 3s + retries: 20 + initialize: + profiles: ['app'] + build: + context: .. + dockerfile: deploy/Dockerfile + target: server + environment: + <<: *server-environment + ADMIN_USERNAME: ${ADMIN_USERNAME:-admin} + ADMIN_EMAIL: ${ADMIN_EMAIL:-admin@example.com} + ADMIN_PASSWORD: ${ADMIN_PASSWORD:?Run pnpm fullstack:setup first} + command: + [ + 'sh', + '-c', + './node_modules/.bin/prisma migrate deploy && node dist/cli.mjs seed', + ] + depends_on: + postgres: { condition: service_healthy } + redis: { condition: service_healthy } + server: + profiles: ['app'] + build: + context: .. + dockerfile: deploy/Dockerfile + target: server + environment: + <<: *server-environment + TRUST_PROXY: ${APP_PROXY_NETWORK:-172.30.67}.2 + LOGIN_RATE_LIMIT_MAX: ${APP_LOGIN_RATE_LIMIT_MAX:-10} + command: ['node', 'dist/main.mjs'] + depends_on: + initialize: { condition: service_completed_successfully } + networks: [default, proxy] + healthcheck: + test: + [ + 'CMD', + 'node', + '-e', + 'fetch("http://127.0.0.1:3000/api/health/ready").then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))', + ] + interval: 10s + timeout: 4s + retries: 5 + admin: + profiles: ['app'] + build: + context: .. + dockerfile: deploy/Dockerfile + target: admin + ports: + - '127.0.0.1:${APP_PORT:-8080}:80' + networks: + proxy: + ipv4_address: ${APP_PROXY_NETWORK:-172.30.67}.2 + depends_on: + server: { condition: service_healthy } +volumes: + postgres: + redis: + +networks: + default: {} + proxy: + ipam: + config: + - subnet: ${APP_PROXY_NETWORK:-172.30.67}.0/24 + ip_range: ${APP_PROXY_NETWORK:-172.30.67}.128/25 diff --git a/deploy/nginx.conf b/deploy/nginx.conf new file mode 100644 index 00000000..5480c559 --- /dev/null +++ b/deploy/nginx.conf @@ -0,0 +1,20 @@ +server { + listen 80; + server_tokens off; + absolute_redirect off; + root /usr/share/nginx/html; + location = / { return 302 /ray-template/; } + location /api/ { + proxy_pass http://server:3000; + proxy_set_header Host $http_host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header X-Forwarded-Host $http_host; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_read_timeout 30s; + client_max_body_size 256k; + } + location /ray-template/ { + try_files $uri $uri/ /ray-template/index.html; + } +} diff --git a/deploy/smoke.mjs b/deploy/smoke.mjs new file mode 100644 index 00000000..e6556e9c --- /dev/null +++ b/deploy/smoke.mjs @@ -0,0 +1,175 @@ +import assert from 'node:assert/strict' +import { spawnSync } from 'node:child_process' +import { createHash, randomBytes } from 'node:crypto' +import { createServer } from 'node:net' +import { fileURLToPath } from 'node:url' + +const root = fileURLToPath(new URL('../', import.meta.url)) +const suffix = randomBytes(5).toString('hex') +const project = `ray-smoke-${suffix}` +const password = randomBytes(18).toString('base64url') +const subnet = `10.219.${randomBytes(1)[0]}` +const ports = [] + +async function reservePort() { + const server = createServer() + + await new Promise((resolve, reject) => { + server.once('error', reject) + server.listen(0, '127.0.0.1', resolve) + }) + ports.push(server) + + return server.address().port +} + +const [postgresPort, redisPort, appPort] = await Promise.all([ + reservePort(), + reservePort(), + reservePort(), +]) + +for (const server of ports) server.close() + +const origin = `http://127.0.0.1:${appPort}` +const env = { + ...process.env, + POSTGRES_USER: 'ray', + POSTGRES_DB: 'ray_template', + POSTGRES_PASSWORD: randomBytes(18).toString('base64url'), + POSTGRES_PORT: String(postgresPort), + REDIS_PASSWORD: randomBytes(18).toString('base64url'), + REDIS_PORT: String(redisPort), + ADMIN_USERNAME: 'smoke_admin', + ADMIN_EMAIL: 'smoke-admin@example.test', + ADMIN_PASSWORD: password, + APP_PORT: String(appPort), + APP_ORIGINS: '', + APP_PROXY_NETWORK: subnet, + APP_DEMO_ENABLED: 'false', + APP_DATABASE_URL: '', + APP_REDIS_URL: '', + APP_LOGIN_RATE_LIMIT_MAX: '1', +} + +function compose(args, capture = false) { + const result = spawnSync( + 'docker', + [ + 'compose', + '--project-name', + project, + '--profile', + 'app', + '-f', + 'deploy/compose.yaml', + ...args, + ], + { cwd: root, env, encoding: 'utf8', stdio: capture ? 'pipe' : 'inherit' }, + ) + + if (result.error || result.status !== 0) + throw new Error(`Docker Compose ${args[0]} failed.`, { + cause: result.error, + }) + + return result.stdout +} + +const api = (path, options) => + fetch(`${origin}/api/${path}`, { + signal: AbortSignal.timeout(5000), + ...options, + }) +const login = (username, forwarded) => + api('admin/auth/login', { + method: 'POST', + headers: { + Origin: origin, + 'Content-Type': 'application/json', + 'X-Forwarded-For': forwarded, + }, + body: JSON.stringify({ username, password }), + }) + +compose(['config', '--quiet']) + +try { + compose(['up', '--build', '--detach', '--wait', '--wait-timeout', '150']) + const entry = await fetch(origin, { + redirect: 'manual', + signal: AbortSignal.timeout(5000), + }) + + assert.equal(entry.status, 302) + assert.equal(entry.headers.get('location'), '/ray-template/') + const page = await fetch(`${origin}/ray-template/`, { + signal: AbortSignal.timeout(5000), + }) + + assert.equal(page.status, 200) + assert.match(await page.text(), /]*src="\/ray-template\//u) + assert.equal((await api('health/ready')).status, 200) + assert.equal((await api('admin/demo/charts')).status, 404) + const denied = await api('admin/route-config', { + headers: { Origin: 'https://untrusted.example.test' }, + }) + + assert.equal(denied.status, 403) + const response = await login('smoke_admin', '198.51.100.10') + + assert.equal(response.status, 200) + assert.equal(response.headers.get('access-control-allow-origin'), origin) + const { data } = await response.json() + + assert.equal( + ( + await api('admin/users', { + headers: { Authorization: `Bearer ${data.accessToken}` }, + }) + ).status, + 200, + ) + + for (let attempt = 1; attempt <= 5; attempt++) { + assert.equal( + (await login(`unknown-${attempt}`, `198.51.100.${10 + attempt}`)).status, + attempt < 5 ? 401 : 429, + ) + } + + // 使用 Nginx 实际看到的地址验证限流键,确保没有退回代理自身的地址。 + const accessLog = compose(['logs', '--no-log-prefix', 'admin'], true) + const clientIp = /^(\S+) - .*"POST \/api\/admin\/auth\/login /mu.exec( + accessLog, + )?.[1] + + assert.ok(clientIp, 'Expected a proxied login in the Nginx access log.') + const digest = createHash('sha256').update(clientIp).digest('hex') + const count = compose( + [ + 'exec', + '-T', + 'redis', + 'redis-cli', + 'GET', + `ray:production:limit:login-ip:${digest}`, + ], + true, + ) + + assert.equal(count.trim(), '6') + console.log( + 'Compose smoke passed: initialized data, built admin, readiness, login, CORS, demo gating and forwarded client rate limits.', + ) +} catch (error) { + try { + compose(['logs', '--tail', '25', 'initialize', 'server']) + } catch { + // 可能在镜像构建阶段已失败,保留最初的错误。 + } + + throw error +} finally { + compose(['down', '--volumes', '--remove-orphans']) +} diff --git a/docs/architecture.md b/docs/architecture.md index e5e6f720..5de64ee4 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -13,19 +13,38 @@ Ray Template is a pnpm workspace. The admin application owns host integration, t | [docs](./), [harness](../harness/README.md) | Maintainer conventions and cross-module explanations. Harness owns task navigation, targeted checks, and evidence. Reader-facing documentation belongs in `apps/docs`. | | [scripts](../scripts), [vite-helper](../vite-helper), [unplugin](../unplugin) | Repository checks, Vite plugin helpers, and generated auto-import declarations. Build, type, and CI configuration remains at the root. | -| Shared package | Implementation ownership | Host boundary | -| --------------------------------------------------------------------- | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | -| [@ray-template/utils](../packages/utils/package.json) | Precision, type checks, data/file utilities, and generic JSON storage | Callers supply Storage. Application keys, cache backends, and legacy AES formats stay in the application. | -| [@ray-template/composables](../packages/composables/package.json) | Vue composables and DOM, element, and scope utilities | Application-specific navigation, theme, and content-area hooks stay in the application. | -| [@ray-template/directives](../packages/directives/package.json) | Vue directives and registration | The host supplies copy notifications and decides when to register. | -| [@ray-template/icons](../packages/icons/package.json) | SVG files, manifests, icon-name types, and lookups | The build generates spritemaps. The host supplies icon-resolution services. | -| [@ray-template/ui](../packages/ui/package.json) | Shared components, themes, and UI service interfaces | The admin application injects translation, theme, storage, and other services. Application component entry points re-export shared components. | -| [@ray-template/http](../packages/http/package.json) | Independent HTTP clients, interceptors, and cancellation | The application supplies request configuration and interceptors, and wraps business APIs. | -| [@ray-template/api-contracts](../packages/api-contracts/package.json) | Business/demo API types, runtime schemas, and OpenAPI | Independent of browsers and mocks. The application, mocks, and integrating backends share the protocol. | -| [@ray-template/routing](../packages/routing/package.json) | Route configuration validation, expansion, and menu traversal | The application owns the view registry, configuration sources, roles, sessions, and guards. | -| [@ray-template/admin-shell](../packages/admin-shell/package.json) | Layout shell, settings, transitions, and cached-page rendering | The host supplies route state, preferences, navigation, and content slots. | +| Shared package | Implementation ownership | Host boundary | +| --------------------------------------------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- | +| [@ray-template/utils](../packages/utils/package.json) | Precision, type checks, data/file utilities, and generic JSON storage | Callers supply Storage. Application keys, cache backends, and legacy AES formats stay in the application. | +| [@ray-template/composables](../packages/composables/package.json) | Vue composables and DOM, element, and scope utilities | Application-specific navigation, theme, and content-area hooks stay in the application. | +| [@ray-template/directives](../packages/directives/package.json) | Vue directives and registration | The host supplies copy notifications and decides when to register. | +| [@ray-template/icons](../packages/icons/package.json) | SVG files, manifests, icon-name types, and lookups | The build generates spritemaps. The host supplies icon-resolution services. | +| [@ray-template/ui](../packages/ui/package.json) | Shared components, themes, and UI service interfaces | The admin application injects translation, theme, storage, and other services. Application component entry points re-export shared components. | +| [@ray-template/http](../packages/http/package.json) | Independent HTTP clients, interceptors, and cancellation | The application supplies request configuration and interceptors, and wraps business APIs. | +| [@ray-template/api-contracts](../packages/api-contracts/package.json) | Business/demo API types, runtime schemas, route contracts, and OpenAPI | Independent of browsers and mocks. The application, mocks, and integrating backends share the protocol. | +| [@ray-template/demo-data](../packages/demo-data/package.json) | Runtime-neutral fixtures, initial route data, and demonstration query helpers | Mock and optional backend consumers decide when demonstration behavior is enabled. | +| [@ray-template/routing](../packages/routing/package.json) | Browser route expansion, menu traversal, and compatibility schema exports | The application owns the view registry, configuration sources, roles, sessions, and guards. | +| [@ray-template/admin-shell](../packages/admin-shell/package.json) | Layout shell, settings, transitions, and cached-page rendering | The host supplies route state, preferences, navigation, and content slots. | -Application `@/components`, `@/hooks`, and `@/utils` include compatibility entry points. Follow actual exports to determine ownership. Shared packages must not depend on application aliases or relative imports across workspaces. The [package-boundary check](../scripts/check-package-boundaries.mjs) validates dependency declarations, public entry points, and cycles. +Application `@/components`, `@/hooks`, and `@/utils` include compatibility entry points. Follow actual exports to determine ownership. Shared packages must not depend on application aliases or relative imports across workspaces. The [package-boundary check](../scripts/check-package-boundaries.mjs) validates dependency declarations, public entry points, and cycles. Each workspace declares `rayTemplate.runtime` as `browser`, `server`, or `universal`: applications cannot be dependencies; universal packages depend only on universal packages; browser/server workspaces cannot import each other. The canonical route schemas and structural validation live in `packages/api-contracts`; `packages/routing` retains compatibility exports and browser view binding. `packages/demo-data/src/routes.json` owns the initial route fixture. + +## Source distributions + +The [distribution exporter](../scripts/distributions.mjs) creates source directories and `.tar.gz` archives under `dist/distributions`. The frontend edition retains Admin, Docs, and their reachable workspace dependencies, with a pruned lockfile and usable scripts. `distribution.json` records the edition, version, source commit/worktree state, workspace set, file count, and content digest. Explicit source inputs exclude local credentials, dependencies, generated builds, and verification evidence. + +Markdown blocks delimited by the HTML comment markers `fullstack:start` and `fullstack:end` are removed from frontend exports. Keep references to omitted server files inside these blocks. Export is local only; branch/Release publication is a separate integration step. Read the [distribution guide](../apps/docs/guide/distributions.md) for user commands. + + + +## Optional server workspace + +[apps/server](../apps/server) owns NestJS controllers/services, PostgreSQL persistence through Prisma, migrations, credential initialization, authorization, and audit records. It consumes only universal workspace packages and keeps ORM models out of browser contracts. [Platform infrastructure](../apps/server/src/platform/README.md) owns Redis rate limits/cache, request IDs and redacted JSON logs, security headers, CORS, health probes, and resource shutdown. Database sessions and authorization are never cached. + +The [fullstack launcher](../scripts/fullstack.mjs) creates private local configuration once, starts PostgreSQL/Redis through [Compose](../deploy/compose.yaml), migrates/seeds without resetting existing accounts, and waits for backend readiness before starting Vite with a same-origin API proxy. External databases are supported through `setup --external`. Fullstack source export adds this workspace and its deployment configuration. Docker and production deployment require independent runtime acceptance. + +The server has its own [TypeScript configuration](../apps/server/tsconfig.json) and build output. Tests under `apps/server/test` use Node's test runner; database integration tests require explicit test PostgreSQL and Redis URLs. Frontend builds do not initialize server resources. + + ## Key runtime flows @@ -45,13 +64,14 @@ Maintain guides and runnable examples for public behavior changes through [appli The [root configuration](../tsconfig.json) references four projects. Strict mode, module resolution, and type-checking aliases live in the [shared configuration](../tsconfig.base.json). When changing aliases, check [Vite](../vite.custom.config.ts) and [Vitest](../vitest.config.ts) as well. -| Configuration | Coverage | -| ------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | -| [Application](../tsconfig.app.json) | Admin `apps/admin/src`, Vue JSX, and generated declarations. | -| [Node](../tsconfig.node.json) | Root build/test configuration, `vite-helper`, and build helpers. | -| [Tests](../tsconfig.test.json) | `__test__` and referenced source, loading Vitest and Node types. Vitest configuration and individual test files determine the runtime environment. | -| [Shared packages](../tsconfig.packages.json) | `packages/*/src`, without inheriting application aliases or auto-import declarations. | -| [Documentation site](../apps/docs/tsconfig.json) | Independent documentation-example checks, run by `pnpm docs:check`. | +| Configuration | Coverage | +| ------------------------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| [Application](../tsconfig.app.json) | Admin `apps/admin/src`, Vue JSX, and generated declarations. | +| [Node](../tsconfig.node.json) | Root build/test configuration, `vite-helper`, and build helpers. | +| [Tests](../tsconfig.test.json) | `__test__` and referenced source, loading Vitest and Node types. Vitest configuration and individual test files determine the runtime environment. | +| [Shared packages](../tsconfig.packages.json) | `packages/*/src`, without inheriting application aliases or auto-import declarations. | +| [Universal contracts/data](../tsconfig.universal.json) | Node-only type-checking environment for API contracts and demo data; no browser DOM library. | +| [Documentation site](../apps/docs/tsconfig.json) | Independent documentation-example checks, run by `pnpm docs:check`. | `pnpm typecheck` first validates icon synchronization, then runs `vue-tsc --build` for the four projects referenced by the root configuration. Incremental caches live in `node_modules/.cache/ray-template/`. Use `pnpm exec vue-tsc -p ` for an individual project. diff --git a/docs/docs-handoff.md b/docs/docs-handoff.md index cb82708f..2eb77a52 100644 --- a/docs/docs-handoff.md +++ b/docs/docs-handoff.md @@ -23,7 +23,7 @@ The site targets v6. Source links use monorepo paths, and release builds use `RA ## Pending reader-guide updates -Application evidence is available in the [routing integration guide](../apps/admin/src/router/README.md), [schema](../packages/routing/src/schema.ts), [Segment notes](../packages/ui/src/RSegment/README.md), and [page design guide](ui-design.md). Add source switching, API examples, and version validation to `apps/docs/guide/routing.md`; document `fitContent` selection states and transitions in the component reference. Use updated login and management-page screenshots and check deployment subpaths. +Application evidence is available in the [routing integration guide](../apps/admin/src/router/README.md), [schema](../packages/api-contracts/src/routes.ts), [Segment notes](../packages/ui/src/RSegment/README.md), and [page design guide](ui-design.md). Add source switching, API examples, and version validation to `apps/docs/guide/routing.md`; document `fitContent` selection states and transitions in the component reference. Use updated login and management-page screenshots and check deployment subpaths. Update `guide/layout.md` for reduced motion and the floating exit button. Add visual and JSON entry points to `guide/routing.md`, making clear that applying visual configuration stores it only in the current browser. Explain in `reference/hooks/layout.md` that loading indicators are positioned relative to the visible content area. diff --git a/docs/toolchain-upgrade.md b/docs/toolchain-upgrade.md index 31eff943..01bfac8e 100644 --- a/docs/toolchain-upgrade.md +++ b/docs/toolchain-upgrade.md @@ -237,3 +237,14 @@ Translated agent entry points, Harness topics and workflow, internal architectur ### Remote CI follow-up The [historical Ubuntu failure](https://github.com/XiaoDaiGua-Ray/ray-template/actions/runs/41588971650) was in `detectOperatingSystem.spec.ts`: the test read the Linux runner's actual user agent but always expected `Unknown`. Commit `83bada95` covers systems with mocked user agents and touch-point counts. [CI](https://github.com/XiaoDaiGua-Ray/ray-template/actions/runs/41612553267) for recorded baseline `80e80775` passed Ubuntu, macOS, Windows, and deployment. The matrix continues to run the same `pnpm check`. + + + +## 2026-11-06: Optional server and source distributions checkpoint + +Added explicit browser/server/universal workspace ownership, universal route contracts and shared demo fixtures, and independent frontend/fullstack source exports with pruned lockfiles. The optional server pins NestJS 12.3.3, Prisma 7.10.1, node-redis 6.3.1 and esbuild 0.28.2. Prisma runtime checks and migration-engine downloads are explicitly allowed. The documentation still uses Vite 6; its Vue Router runtime does not load the optional Vite plugin, so that single peer combination is explicitly recorded in the workspace config. + +Full Harness verification passed with Node 26.13.0 and pnpm 12.16.1: 103 frontend test files / 535 tests, 13 backend unit/platform tests with real Redis, API and workspace checks, types, lint/format, and both application builds. Six backend HTTP integration tests separately passed on temporary PostgreSQL 18.6 and Redis 8.2.11. The real external-service setup command applied Prisma migrations and initialized a private local administrator. No fixed production passwords were introduced. + +An exported frontend archive extracted outside the repository passed frozen dependency installation, API/package/Harness checks and production build. Frontend/fullstack archive projection and nine distribution regressions passed. Fullstack standalone install, container images, browser integration and remote workflows remain pending. Follow the [pause checkpoint](../harness/plan.md) for remaining scope and local evidence. No Git commit, push, branch publication or release was performed. + diff --git a/eslint.config.mjs b/eslint.config.mjs index d25d77ff..283f66ff 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -14,6 +14,9 @@ export default defineConfig([ '**/coverage/**', '**/.ai-local/**', '**/.harness-local/**', + '**/dist-test/**', + 'apps/server/src/generated/**', + '**/.pnpm-store/**', '**/public/**', '**/playground-dist/**', 'unplugin/**', diff --git a/harness/README.md b/harness/README.md index d137b0aa..825c8252 100644 --- a/harness/README.md +++ b/harness/README.md @@ -65,12 +65,12 @@ GitHub Actions runs the same `pnpm check` on Linux, Windows, and macOS. Use `pnp Use browser verification only for changes to visible effects, user actions, or browser-specific capabilities. Maintainer documentation, comments, tests, Harness changes, and logic changes with no page impact do not trigger UI/UX verification. Reader-documentation wording corrections can be checked in source and with formatting tools; open the relevant page when rendering structure, example interaction, or layout is at risk. Report missing required browser evidence accurately; screenshots do not replace functional regressions. -By default, use `pnpm dev` and open `http://127.0.0.1:9527/ray-template/`. Reproduce the affected page and action flow with local demo data, and inspect relevant console errors. Add dimensions below only when their corresponding behavior changes. Do not exhaustively combine pages, languages, themes, and viewports. +By default, use `pnpm dev` and open `http://127.0.0.1:9527/ray-template/`. Verify the affected page and action flow in one locale with local demo data, and check the DevTools Console for relevant warnings and errors. Missing-key warnings cover translation lookups performed in development. Add dimensions below only when their corresponding behavior changes. | Change | Additional checks | | --------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- | | Local interaction, validation, or state | Affected action and relevant success, failure, or recovery paths. Check keyboard operation when keyboard/focus behavior changes. | -| Copy or internationalization | Chinese and English on the affected page, interpolation, and fallback behavior. Check wrapping when text length affects layout. | +| Copy or internationalization | Check changed keys in both language files. Test locale switching, interpolation, fallback, and text wrapping where affected. | | Layout, sizing, scrolling, or responsiveness | The affected area at desktop and narrow widths, such as 390px. Check only affected layout modes and long content. | | Themes, colors, or shared visual variables | Light/dark themes and relevant readability. Select representative actual consumers of shared styles. | | Routing, permissions, or cache behavior | Menu entry, direct navigation, reload, and restoration for relevant roles/sources. Do not recheck unrelated pages. | diff --git a/harness/context/routing.md b/harness/context/routing.md index ca1e4962..8cbf2459 100644 --- a/harness/context/routing.md +++ b/harness/context/routing.md @@ -4,7 +4,7 @@ Use this topic to add pages or menus, debug direct navigation and reloads, or ch | Question | Read first | Follow through | | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| Static page registration and menu order | [Initial route JSON](../../apps/admin/src/mocks/data/routes.json), [route module assembly](../../apps/admin/src/router/app-route-modules.ts) | [Views](../../apps/admin/src/views), [menu store](../../apps/admin/src/store/modules/menu/index.ts), [shared route expansion](../../packages/routing/src/expand-routes.ts) | +| Static page registration and menu order | [Initial route JSON](../../packages/demo-data/src/routes.json), [route module assembly](../../apps/admin/src/router/app-route-modules.ts) | [Views](../../apps/admin/src/views), [menu store](../../apps/admin/src/store/modules/menu/index.ts), [shared route expansion](../../packages/routing/src/expand-routes.ts) | | Dynamic JSON fields, validation errors, and allowed views | [Shared schema](../../packages/routing/src/schema.ts), [JSON Schema export](../../packages/routing/src/json-schema.ts), [application view-ID registry](../../apps/admin/src/router/config/views.ts) | [Application binding](../../apps/admin/src/router/config/contract.ts), [management page](../../apps/admin/src/views/route-management), [reader guide](../../apps/docs/guide/routing.md) | | Static, local, and remote sources and fallback | [Source loading and saving](../../apps/admin/src/router/config/source.ts) | [Router initialization](../../apps/admin/src/router/index.ts), [registered routes](../../apps/admin/src/router/routes.ts) | | Menu visibility, direct access, and post-login landing | [Navigation guards](../../apps/admin/src/router/utils/permission.ts), [route and allowlist configuration](../../apps/admin/src/app-config/router-config.ts) | [Menu visibility](../../apps/admin/src/router/utils/valid-menu-item-show.ts), [session store](../../apps/admin/src/store/modules/signing/index.ts), [shared navigation traversal](../../packages/routing/src/navigation.ts) | diff --git a/harness/context/server.md b/harness/context/server.md new file mode 100644 index 00000000..471e8c75 --- /dev/null +++ b/harness/context/server.md @@ -0,0 +1,13 @@ +# Optional NestJS server + +Use this topic for the fullstack distribution, database persistence, authentication, permissions, Redis limits/cache, security, logs, and server startup. + +Read the [server guide](../../apps/server/README.md), [platform contract](../../apps/server/src/platform/README.md), [shared contracts](../../packages/api-contracts/README.md), and [source distribution guide](../../apps/docs/guide/distributions.md). + +- [Bootstrap](../../apps/server/src/app.ts) owns Nest modules and platform lifecycle. [Platform](../../apps/server/src/platform/index.ts) owns environment validation, Redis, request logging, security headers, CORS, limits, and health checks. +- [Database](../../apps/server/src/infrastructure/database.ts) owns Prisma lifetime and transaction retries. [Schema](../../apps/server/prisma/schema.prisma) and migrations are server-only. [Seed](../../apps/server/src/seed.ts) must preserve existing data. +- [Authentication](../../apps/server/src/modules/auth/auth.service.ts) checks live sessions and permission grants. Credential/session state must not use the reusable data cache. +- [Users](../../apps/server/src/modules/users/users.service.ts) validates and authorizes writes inside transactions. [Routes](../../apps/server/src/modules/routes/routes.controller.ts) use the shared route parser and generated catalog. +- [Fullstack launcher](../../scripts/fullstack.mjs) creates local configuration and orchestrates services. [Distribution exporter](../../scripts/distributions.mjs) projects independent frontend/fullstack workspaces; it never publishes branches or releases. + +`pnpm harness verify server` runs type checks, unit/platform tests, and the backend build without requiring PostgreSQL. Real HTTP integration is explicit: set `TEST_DATABASE_URL` and `TEST_REDIS_URL`, then run `pnpm server:test:integration`. Tests own random schemas/prefixes and clean only those resources. Run the full Harness at integration completion and browser verification for the affected login, user and routing flows. Container builds and remote publication require independent evidence. diff --git a/harness/plan.md b/harness/plan.md index b70bd480..0216d01c 100644 --- a/harness/plan.md +++ b/harness/plan.md @@ -1,5 +1,50 @@ # AI Harness development plan + + +## 2026-11-06: Optional backend and source distributions + +The approved scope is one development workspace with independently usable frontend and fullstack source distributions, followed by a NestJS backend. Backend security, authentication, Redis, logging, and operational foundations are part of this batch. No remote commit, branch publication, release, or deployment is authorized by this implementation task. + +1. Establish application isolation and universal contract boundaries. Move route schemas and reusable demo fixtures into browser-independent workspace packages; preserve frontend compatibility entry points. +2. Export frontend and fullstack source trees and archives from the same source, including independent frozen-installable lockfiles. Exclude secrets, local evidence, dependencies, and build outputs. Prepare release/branch automation without publishing it. +3. Add NestJS and PostgreSQL persistence behind the existing API contract. Preserve Bearer sessions for this integration; cookie authentication is a separate protocol migration. Include revocation, RBAC, atomic writes, account protection, audit records, Redis limits/cache, configuration validation, sanitized logs, health checks, and graceful shutdown. +4. Provide repeatable setup, local fullstack orchestration, Compose configuration, database migrations, and credential provisioning without fixed passwords. Preserve existing data on repeated setup. + +Acceptance: both distributions pass isolated frozen installation and their checks/builds; backend HTTP tests use real PostgreSQL and Redis; frontend mock mode and the real-backend login/user/route flows work in a browser; full Harness checks pass once after integration. Docker/remote workflows require separate evidence and must not be reported as verified without execution. Local reports belong in `.harness-local/`. + +Parallel ownership: the lead owns integration, shared packages, package-boundary checks, launchers and documentation; distribution and backend agents own their assigned new files, with platform infrastructure isolated under the server's `src/platform` directory. + +### Pause checkpoint requested by the user + +The user requested an active pause before 17:55 Asia/Shanghai on 2026-11-06 because connectivity will end at 18:00. Resume this implementation in the same worktree; changes are uncommitted and unpublished. + +Implemented: workspace runtime ownership checks; shared universal route schemas/semantic parser and generated view/icon catalog; shared demo fixtures; independent frontend/fullstack source export with pruned lockfiles and provenance; NestJS core auth/users/routes with PostgreSQL persistence, scrypt passwords, hashed opaque tokens, live authorization, atomic writes and audit; Redis limits/cache infrastructure, configuration validation, sanitized logs, CORS/security headers, health and shutdown; setup/Compose/development launchers; bilingual delivery and backend documentation. `pnpm fullstack:setup` replaces the proposed `pnpm setup` because the latter is a pnpm builtin. Login demo buttons are now restricted to Mock mode; real sign-in inputs use username/current-password autofill, stable names and required fields. + +Observed validation before pause: + +- Frontend checks: 103 Vitest files / 535 tests, types, lint, format, API/package checks, production build and documentation build passed. Full `pnpm harness verify all` passed; report: `.harness-local/runs/all-JcqVqb/report.json`, log: `.harness-local/full-check.log`. +- Server: type check/build and 13 unit/platform tests passed, including real Redis. Six HTTP integration tests passed on real PostgreSQL and Redis, covering authorization, uniqueness, transaction atomicity, revocation, semantic route validation, process restart persistence and repeat seed. +- Real `pnpm fullstack:setup --external` passed Prisma migrate deploy and administrator initialization in an isolated local PostgreSQL schema. The generated private `.env.local` is ignored and must never enter artifacts or logs. +- Frontend source archive extracted outside the repository passed frozen install, package/Harness/API checks and production build. The source exporter passed nine regression cases. Fullstack source projection passed structural checks; its standalone installation is still pending. +- Local PostgreSQL 18.6 and Redis 8.2.11 binaries are retained under `.harness-local/services/`. Their test endpoints were localhost ports 15432/16379; services must be restarted before real integration tests. Both temporary services were stopped before the pause. + +Remaining work at the pause, in order: + +1. Implement the optional Nest demo endpoints using shared fixtures and the Redis read cache. The backend currently implements core admin endpoints only; existing frontend demo/chart calls are not yet served. Ensure `DEMO_ENABLED=false` has an explicit menu/endpoint policy. +2. Run actual `pnpm dev:full` startup/shutdown/error-path checks and browser acceptance for mock and real-backend login, user operations, permissions, route saves and reloads. Login gating/autofill changes have source/build verification only. +3. Validate the isolated fullstack archive, package deploy output and Compose images. Docker is absent locally; the container definitions are unverified. Verify forwarded client IP trust, origins and non-default ports before calling container setup production-ready. +4. Implement source-release artifact and generated frontend-branch workflow (currently not written). No branch, tag, release, commit or deployment has been published; obtain required Git/publication authorization before those remote actions. +5. Review combined changes, add focused missing regressions (launcher and real-backend login/demo flows), rerun only affected checks after fixes, and regenerate final archives. Preserve the initial one-mainline/two-distribution design and production credential separation. + +Modern Web Guidance applied: `autofill-sign-in-form` ("Use `autocomplete="current-password"` for the password input in a sign-in form") and `forms` ("turn off text correction on fields that hold identifiers rather than prose"). The retrieved guide is retained at `/var/folders/3n/76yvbw114mn8205ykb9npv2r0000gn/T/mwg-guide-73479-1793958308167.md`; browser acceptance is pending. + +### Resumed implementation + +The same worktree now includes the demo controllers and shared queries, the protected editor snapshot, the hardened dev launcher and Compose entry point, and a manually dispatched source distribution workflow. Mock and backend mode were exercised in Chrome with isolated test data, including real sign-in, user changes, read-only permissions, route persistence, and demo reads. The workflow can verify and archive a source revision, update the generated `frontend` branch, or attach assets to an existing release. Local acceptance evidence is kept in `.harness-local/fullstack-resume/`; remote workflow execution and publication require a separate authorized run. + + + The goal is to help developers and AI agents taking over Ray Template find relevant code by task, reproduce checks independently, and pass observed results to the next maintainer. Entry points and commands are in the [AI Harness](README.md). | Phase | Work | Acceptance criteria | diff --git a/harness/run.mjs b/harness/run.mjs index 3ba6e494..2512a0d0 100644 --- a/harness/run.mjs +++ b/harness/run.mjs @@ -23,6 +23,7 @@ const allowedChecks = new Set([ 'docs:check', 'icons:check', 'packages:check', + 'server:check', 'typecheck', ]) const indexFiles = [ diff --git a/harness/scopes.json b/harness/scopes.json index dcc7c95a..c866ad1d 100644 --- a/harness/scopes.json +++ b/harness/scopes.json @@ -72,10 +72,15 @@ }, "toolchain": { "description": "Workspaces, public exports, type checking, Vite, builds, and CI", - "checks": ["packages:check", "typecheck"] + "checks": ["packages:check", "typecheck"], + "tests": ["__test__/workspace/boundaries.spec.ts", "__test__/distribution/"] }, "harness": { "description": "Indexes, regression scope, verification commands, and local reports", "tests": ["__test__/harness/"] + }, + "server": { + "description": "Optional backend, PostgreSQL, Redis, security, sessions, and startup", + "checks": ["server:check"] } } diff --git a/llms.txt b/llms.txt index 88388328..2e717fa2 100644 --- a/llms.txt +++ b/llms.txt @@ -6,6 +6,10 @@ Follow [AGENTS.md](AGENTS.md) and select the entry point for the task. Read this ## Task index + +- [server](harness/context/server.md): Optional NestJS backend, PostgreSQL, Redis, security, authentication, logs, and source distributions. + + - [routing](harness/context/routing.md): Pages and menus, dynamic route JSON, view IDs, roles, and guards. - [layout](harness/context/layout.md): Bootstrap, providers, navigation, KeepAlive, Pinia, and preference import/export. - [ui](harness/context/ui.md): Shared components, pages and login, themes and bilingual copy, hooks, and directives. diff --git a/package.json b/package.json index 5471853e..6fa3f858 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dev": "pnpm icons:generate && vite", "icons:generate": "node scripts/icons.mjs", "icons:check": "node scripts/icons.mjs --check", - "typecheck": "pnpm icons:check && vue-tsc --build", + "typecheck": "pnpm icons:check && vue-tsc --build && tsc -p tsconfig.universal.json", "build": "pnpm icons:generate && pnpm typecheck && vite build", "preview": "vite preview", "docs:dev": "pnpm --filter @ray-template/docs dev", @@ -29,12 +29,28 @@ "format": "prettier --write .", "format:check": "prettier --check .", "harness": "node harness/run.mjs", - "check": "pnpm env:check && pnpm harness check && pnpm api:check && pnpm packages:check && pnpm icons:generate && pnpm typecheck && pnpm lint && pnpm format:check && pnpm test:run && vite build && pnpm docs:check", + "check": "pnpm check:frontend && pnpm server:check && pnpm dist:check", "env:check": "node scripts/doctor.mjs", "packages:check": "node scripts/check-package-boundaries.mjs", "pages:build": "pnpm build && pnpm docs:build && node scripts/assemble-pages.mjs", "api:generate": "node scripts/admin-api.mjs", - "api:check": "node scripts/admin-api.mjs --check" + "api:check": "node scripts/admin-api.mjs --check", + "check:frontend": "pnpm env:check && pnpm harness check && pnpm api:check && pnpm packages:check && pnpm icons:generate && pnpm typecheck && pnpm lint && pnpm format:check && pnpm test:run && vite build && pnpm docs:check", + "dist:frontend": "node scripts/distributions.mjs frontend", + "dist:fullstack": "node scripts/distributions.mjs fullstack", + "dist:check": "node scripts/distributions.mjs --check", + "dev:full": "node scripts/fullstack.mjs dev", + "fullstack:stop": "node scripts/fullstack.mjs stop", + "server:dev": "pnpm --filter @ray-template/server dev", + "server:build": "pnpm --filter @ray-template/server build", + "server:start": "pnpm --filter @ray-template/server start", + "server:check": "pnpm --filter @ray-template/server check", + "server:test": "pnpm --filter @ray-template/server test", + "server:test:integration": "pnpm --filter @ray-template/server test:integration", + "server:db:migrate": "pnpm --filter @ray-template/server db:migrate", + "server:db:seed": "pnpm --filter @ray-template/server db:seed", + "server:credential:set": "pnpm --filter @ray-template/server credential:set", + "fullstack:setup": "node scripts/fullstack.mjs setup" }, "lint-staged": { "*.{js,mjs,cjs,ts,tsx,vue}": [ @@ -80,7 +96,8 @@ "vue-i18n": "11.4.17", "vue-router": "5.4.0", "vue3-next-qrcode": "4.1.1", - "@ray-template/api-contracts": "workspace:*" + "@ray-template/api-contracts": "workspace:*", + "@ray-template/demo-data": "workspace:*" }, "devDependencies": { "@commitlint/cli": "21.2.4", @@ -123,7 +140,9 @@ "vite-svg-loader": "5.1.3", "vitest": "5.0.5", "vue-eslint-parser": "10.4.1", - "vue-tsc": "3.3.14" + "vue-tsc": "3.3.14", + "yaml": "2.9.1", + "esbuild": "0.28.2" }, "description": "Ray Template is an open-source Vue 3 admin dashboard template built with TypeScript (TSX), Vite and Naive UI. Includes role-based routing, responsive layouts and data tables.", "repository": { @@ -140,7 +159,7 @@ "vite", "naive-ui", "pinia", - "中后台模板" + "\u4e2d\u540e\u53f0\u6a21\u677f" ], "license": "MIT", "author": { diff --git a/packages/admin-shell/package.json b/packages/admin-shell/package.json index cb200997..083047d6 100644 --- a/packages/admin-shell/package.json +++ b/packages/admin-shell/package.json @@ -18,5 +18,8 @@ "vue": "3.5.44", "naive-ui": "2.45.3", "vue-router": "5.4.0" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/packages/api-contracts/package.json b/packages/api-contracts/package.json index 0afb1cf0..5e0d9b10 100644 --- a/packages/api-contracts/package.json +++ b/packages/api-contracts/package.json @@ -6,11 +6,16 @@ ".": "./src/index.ts", "./admin": "./src/admin.ts", "./demo": "./src/demo.ts", - "./openapi": "./src/openapi.ts" + "./openapi": "./src/openapi.ts", + "./routes": "./src/routes.ts", + "./route-json-schema": "./src/route-json-schema.ts", + "./route-validation": "./src/route-validation.ts" }, "dependencies": { - "@ray-template/routing": "workspace:*", "@valibot/to-json-schema": "1.8.0", "valibot": "1.5.0" + }, + "rayTemplate": { + "runtime": "universal" } } diff --git a/packages/api-contracts/src/openapi.ts b/packages/api-contracts/src/openapi.ts index 605f44d0..71460188 100644 --- a/packages/api-contracts/src/openapi.ts +++ b/packages/api-contracts/src/openapi.ts @@ -1,4 +1,3 @@ -import { routeConfigSchema } from '@ray-template/routing/schema' import { toJsonSchema } from '@valibot/to-json-schema' import * as v from 'valibot' import { @@ -31,6 +30,7 @@ import { searchOptionsQuerySchema, searchOptionsSchema, } from './demo.ts' +import { routeConfigSchema } from './routes.ts' export function getAdminOpenApi() { const schemas = Object.fromEntries( @@ -228,7 +228,20 @@ export function getAdminOpenApi() { '/admin/auth/session': { get: operation('getSession', 'Session') }, '/admin/auth/logout': { post: operation('logout', null) }, '/admin/route-config': { - get: operation('getRouteConfig', 'RouteConfig', void 0, void 0, true), + get: { + ...operation('getRouteConfig', 'RouteConfig', void 0, void 0, true), + description: + 'Public navigation snapshot. Request view=editor with routes:write to read the complete saved configuration, including disabled demo routes.', + security: [{}, { bearerAuth: [] }], + parameters: [ + { + name: 'view', + in: 'query', + required: false, + schema: { const: 'editor' }, + }, + ], + }, put: operation( 'updateRouteConfig', 'RouteConfig', diff --git a/packages/api-contracts/src/route-json-schema.ts b/packages/api-contracts/src/route-json-schema.ts new file mode 100644 index 00000000..fd52cfa8 --- /dev/null +++ b/packages/api-contracts/src/route-json-schema.ts @@ -0,0 +1,9 @@ +import { toJsonSchema } from '@valibot/to-json-schema' +import { routeConfigSchema, routeRecordSchema } from './routes.ts' + +export const getRouteJsonSchema = () => + toJsonSchema(routeConfigSchema, { + target: 'draft-2020-12', + definitions: { route: routeRecordSchema }, + ignoreActions: ['check', 'finite'], + }) diff --git a/packages/api-contracts/src/route-validation.ts b/packages/api-contracts/src/route-validation.ts new file mode 100644 index 00000000..b5696b4d --- /dev/null +++ b/packages/api-contracts/src/route-validation.ts @@ -0,0 +1,199 @@ +import { getDotPath, safeParse } from 'valibot' +import { routeConfigSchema } from './routes.ts' +import type { RouteConfig, RouteConfigRecord } from './routes.ts' + +export interface RouteValidationCatalog { + managementPath: string + reservedPaths?: readonly string[] + reservedNames?: readonly string[] + findRouteView(id: string): { name: string } | undefined + isIconName(value: string): boolean + normalizeIcon(value: string): string +} + +const joinRoutePath = (parent: string, path: string) => + path.startsWith('/') ? path : `${parent.replace(/\/$/, '')}/${path}` + +export function createRouteParser(catalog: RouteValidationCatalog) { + const reservedPaths = + catalog.reservedPaths?.map((path) => path.toLowerCase()) ?? [] + const isReservedPath = (path: string) => + path === '/' || + path === catalog.managementPath || + path.startsWith(`${catalog.managementPath}/`) || + reservedPaths.some( + (reserved) => path === reserved || path.startsWith(`${reserved}/`), + ) + const reservedNames = new Set( + catalog.reservedNames?.map((name) => name.toLowerCase()), + ) + const configLimit = 256 * 1024 + const asList = (value: string | string[] | undefined) => + typeof value === 'string' ? [value] : (value ?? []) + + function parseRouteConfig(text: string): RouteConfig { + if (text.length > configLimit) + throw new Error('Route configuration exceeds 256 KiB.') + + const input = JSON.parse(text) + let count = 0 + const checkDepth = (routes: unknown, depth: number) => { + if (!Array.isArray(routes)) return + + count += routes.length + + if (count > 300 || depth > 8) + throw new Error('Use at most 300 routes and 8 menu levels.') + + for (const item of routes) checkDepth(item?.children, depth + 1) + } + + checkDepth(input?.routes, 1) + + const result = safeParse(routeConfigSchema, input) + + if (!result.success) { + throw new Error( + result.issues + .slice(0, 20) + .map((issue) => `${getDotPath(issue) ?? 'config'}: ${issue.message}`) + .join('\n'), + ) + } + + const config = result.output + + const paths = new Map() + const names = new Set(reservedNames) + const menuPaths = new Set() + const matchPatterns = new Set() + + const visit = (records: RouteConfigRecord[], parent = '') => { + for (const record of records) { + const { name, component, children, alias, redirect, props, meta } = + record + const path = joinRoutePath(parent, record.path) + const fail = (message: string): never => { + throw new Error(`${path}: ${message}`) + } + + const menuPath = path.toLowerCase() + + if (menuPaths.has(menuPath) || isReservedPath(menuPath)) + fail('Duplicate or reserved menu path.') + + menuPaths.add(menuPath) + + if (meta.windowOpen && !URL.canParse(meta.windowOpen)) + fail('Invalid external URL.') + + if (name) { + const key = name.toLowerCase() + + if (names.has(key)) fail(`Duplicate or reserved name "${name}".`) + + names.add(key) + } + + if (meta.icon) meta.icon = catalog.normalizeIcon(meta.icon) + + if (meta.extra?.icon) + meta.extra.icon = catalog.normalizeIcon(meta.extra.icon) + + for (const icon of [meta.icon, meta.extra?.icon]) { + if (icon && !catalog.isIconName(icon)) fail(`Unknown icon "${icon}".`) + } + + if (children?.length) { + if ( + (component && component !== 'layout') || + alias || + redirect || + props !== void 0 || + meta.windowOpen + ) + fail('Groups accept layout, children and menu metadata.') + + if (path.includes(':')) fail('Use static paths for menu groups.') + + visit(children, path) + continue + } + + const view = component && catalog.findRouteView(component) + + if (component && !view) fail(`Unknown view "${component}".`) + + if ( + Number(!!component) + + Number(!!redirect) + + Number(!!meta.windowOpen) !== + 1 + ) + fail('Specify exactly one view, redirect or external URL.') + + if (props !== void 0 && !view) fail('Props require a view.') + + if (meta.keepAlive && (!view || name !== view.name)) + fail('keepAlive requires the registered component name.') + + if (path.includes(':') && !meta.hidden && !meta.sameLevel) + fail('Parameterized paths must be hidden or sameLevel.') + + for (const address of [path, ...asList(alias)]) { + const key = address.toLowerCase() + + if ( + key + .split('/') + .some((segment) => segment === '.' || segment === '..') + ) + fail(`Invalid path "${address}".`) + + if (isReservedPath(key) || paths.has(key)) + fail(`Duplicate or reserved path "${address}".`) + + if (address !== path && (address.includes(':') || path.includes(':'))) + fail('Aliases require a static page path.') + + const pattern = key.replace(/:[a-z_]\w*/g, ':param') + + if (matchPatterns.has(pattern)) + fail(`Conflicting parameter pattern "${address}".`) + + matchPatterns.add(pattern) + paths.set(key, record) + } + } + } + + visit(config.routes) + + for (const [path, record] of paths) { + let current = record + const visited = new Set() + + while (current.redirect) { + const next = paths.get(current.redirect.toLowerCase()) + + if ( + visited.has(current) || + !next || + next.meta.windowOpen || + current.redirect.includes(':') + ) { + throw new Error( + `${path}: Redirects must reach a configured page without a cycle.`, + ) + } + + visited.add(current) + current = next + } + } + + return config + } + + return parseRouteConfig +} diff --git a/packages/api-contracts/src/routes.ts b/packages/api-contracts/src/routes.ts new file mode 100644 index 00000000..5f2e1eff --- /dev/null +++ b/packages/api-contracts/src/routes.ts @@ -0,0 +1,179 @@ +import * as v from 'valibot' + +const text = v.pipe(v.string(), v.minLength(1), v.maxLength(256)) +const finiteNumber = v.pipe(v.number(), v.finite()) +const title = v.union([text, finiteNumber]) +const icon = v.pipe(text, v.regex(/^[\w-]+\/[\w-]+$/)) +const segment = '(?:[\\w~.-]+|:[A-Za-z_]\\w*\\??)' +const absolutePath = v.pipe( + text, + v.regex(new RegExp(`^/${segment}(?:/${segment})*$`)), +) +const unsafeProp = + /^(?:[oO][nN]|innerHTML$|outerHTML$|srcdoc$|__proto__$|constructor$|prototype$)/ +const viewProps = v.pipe( + v.record(v.string(), v.unknown()), + v.check( + (value) => Object.keys(value).every((key) => !unsafeProp.test(key)), + 'Unsafe view prop.', + ), + v.metadata({ propertyNames: { not: { pattern: unsafeProp.source } } }), +) + +const routeFields = { + path: v.pipe( + text, + v.regex(new RegExp(`^/?${segment}(?:/${segment})*$`)), + v.description( + 'Absolute or relative child path. Supports named and optional parameters.', + ), + ), + name: v.optional( + v.pipe( + text, + v.regex(/^[A-Za-z_][\w.-]*$/), + v.description('Unique Vue Router name. Required for keepAlive.'), + ), + ), + component: v.optional( + v.pipe( + text, + v.description('Registered view ID. Use layout for a menu group.'), + ), + ), + alias: v.optional( + v.pipe( + v.union([ + absolutePath, + v.pipe(v.array(absolutePath), v.minLength(1), v.maxLength(16)), + ]), + v.description('Absolute alternative path(s) for a leaf.'), + ), + ), + redirect: v.optional( + v.pipe( + absolutePath, + v.description('Absolute path of another configured page.'), + ), + ), + props: v.optional( + v.pipe( + v.union([v.boolean(), viewProps]), + v.description('Pass route params (true) or a JSON object to the view.'), + ), + ), + meta: v.strictObject({ + i18nKey: v.optional( + v.pipe(text, v.description('Translation key for the menu title.')), + ), + noLocalTitle: v.optional( + v.pipe(title, v.description('Literal title if i18nKey is absent.')), + ), + icon: v.optional( + v.pipe(icon, v.description('IconName from src/icons/manifest.ts.')), + ), + role: v.optional( + v.pipe( + v.array(title), + v.maxLength(32), + v.description( + 'Allowed roles. Omitted or empty means any authenticated role.', + ), + ), + ), + hidden: v.optional( + v.pipe( + v.boolean(), + v.description( + 'Hide from the menu. Direct navigation still uses the role guard.', + ), + ), + ), + sameLevel: v.optional( + v.pipe( + v.boolean(), + v.description('Append a breadcrumb without replacing the current tab.'), + ), + ), + order: v.optional( + v.pipe(finiteNumber, v.description('Menu sort order at the top level.')), + ), + env: v.optional( + v.pipe( + v.union([text, v.pipe(v.array(text), v.maxLength(16))]), + v.description('Vite mode(s) in which the menu item is visible.'), + ), + ), + windowOpen: v.optional( + v.pipe( + v.string(), + v.maxLength(2048), + v.regex(/^[Hh][Tt][Tt][Pp][Ss]?:\/\//), + v.description('Open this HTTP(S) URL in a new tab.'), + ), + ), + ignoreAutoResetScroll: v.optional( + v.pipe( + v.boolean(), + v.description('Keep the content scroll position on navigation.'), + ), + ), + keepAlive: v.optional( + v.pipe( + v.boolean(), + v.description( + 'Keep the view mounted. name must match the registered view name.', + ), + ), + ), + extra: v.optional( + v.pipe( + v.strictObject({ + label: v.optional(title), + i18nLabel: v.optional(text), + icon: v.optional(icon), + show: v.optional(v.boolean()), + type: v.optional( + v.picklist([ + 'default', + 'primary', + 'info', + 'success', + 'warning', + 'error', + ]), + ), + }), + v.description('Optional menu badge.'), + ), + ), + }), +} + +type RouteFields = v.InferOutput< + v.StrictObjectSchema +> + +export type RouteConfigRecord = RouteFields & { children?: RouteConfigRecord[] } + +export const routeRecordSchema: v.GenericSchema = + v.strictObject({ + ...routeFields, + children: v.optional( + v.pipe( + v.array(v.lazy(() => routeRecordSchema)), + v.minLength(1), + v.maxLength(300), + ), + ), + }) + +export const routeConfigSchema = v.pipe( + v.strictObject({ + version: v.literal(1), + routes: v.pipe(v.array(routeRecordSchema), v.maxLength(300)), + }), + v.title('Ray Template route configuration'), +) + +export type RouteConfig = v.InferOutput diff --git a/packages/composables/package.json b/packages/composables/package.json index 0f8f2554..832aa6ed 100644 --- a/packages/composables/package.json +++ b/packages/composables/package.json @@ -28,5 +28,8 @@ "peerDependencies": { "vue": "3.5.44", "naive-ui": "2.45.3" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/packages/demo-data/README.md b/packages/demo-data/README.md new file mode 100644 index 00000000..86a62e37 --- /dev/null +++ b/packages/demo-data/README.md @@ -0,0 +1,7 @@ +# @ray-template/demo-data + +Browser-independent fixtures and query helpers shared by the frontend HTTP mocks and the optional server demo module. They depend only on the API contracts, Valibot, and Faker. They contain no accounts with usable production credentials, database connection, Storage access, or application imports. + +The root export exposes `initialRoutes`, `initialUserOptions`, `charts`, `requestFixture`, and the query helpers. Focused subpaths expose `orders`, `people`, `users`, and `route-people`. The frontend compatibility files delegate here. Backend seed initialization must preserve existing records and provision credentials separately. + +Route JSON contains registered view identifiers, never executable components. Update the frontend view catalog alongside route configuration when adding a page. diff --git a/packages/demo-data/package.json b/packages/demo-data/package.json new file mode 100644 index 00000000..cd4c485f --- /dev/null +++ b/packages/demo-data/package.json @@ -0,0 +1,20 @@ +{ + "name": "@ray-template/demo-data", + "private": true, + "type": "module", + "exports": { + ".": "./src/index.ts", + "./orders": "./src/orders.ts", + "./users": "./src/users.ts", + "./people": "./src/people.ts", + "./route-people": "./src/route-people.ts" + }, + "dependencies": { + "@faker-js/faker": "10.6.0", + "@ray-template/api-contracts": "workspace:*", + "valibot": "1.5.0" + }, + "rayTemplate": { + "runtime": "universal" + } +} diff --git a/apps/admin/src/mocks/data/charts.json b/packages/demo-data/src/charts.json similarity index 100% rename from apps/admin/src/mocks/data/charts.json rename to packages/demo-data/src/charts.json diff --git a/packages/demo-data/src/index.ts b/packages/demo-data/src/index.ts new file mode 100644 index 00000000..0b1dd573 --- /dev/null +++ b/packages/demo-data/src/index.ts @@ -0,0 +1,23 @@ +import { createRouteParser } from '@ray-template/api-contracts/route-validation' +import routeCatalog from './route-catalog.json' with { type: 'json' } +import routes from './routes.json' with { type: 'json' } + +const views = new Map(routeCatalog.views.map((view) => [view.id, view])) +const icons = new Set(routeCatalog.icons) +const aliases: Record = routeCatalog.iconAliases + +export const parseApplicationRoutes = createRouteParser({ + ...routeCatalog, + findRouteView: (id) => views.get(id), + isIconName: (name) => icons.has(name), + normalizeIcon: (name) => aliases[name] ?? name, +}) + +export const initialRoutes = parseApplicationRoutes(JSON.stringify(routes)) +export { default as charts } from './charts.json' with { type: 'json' } +export { default as requestFixture } from './request.json' with { type: 'json' } +export * from './users.ts' +export * from './orders.ts' +export * from './people.ts' +export * from './route-people.ts' +export * from './queries.ts' diff --git a/packages/demo-data/src/orders.ts b/packages/demo-data/src/orders.ts new file mode 100644 index 00000000..0c873789 --- /dev/null +++ b/packages/demo-data/src/orders.ts @@ -0,0 +1,152 @@ +import type { + DemoOrder, + DemoOrderQuery, + SearchOptions, +} from '@ray-template/api-contracts/demo' + +export const statuses = ['pending', 'paid', 'closed'] as const +export const organizations = ['north', 'south'] as const +export const products = ['notes', 'keyboard', 'notebook', 'monitor'] as const +export const warehouses = [ + 'north-main', + 'north-backup', + 'south-main', + 'south-backup', +] as const +export const owners = [ + { id: 'n1', orgId: 'north' }, + { id: 'n2', orgId: 'north' }, + { id: 's1', orgId: 'south' }, + { id: 's2', orgId: 'south' }, +] as const + +const labels = { + 'zh-CN': { + teams: ['北区', '南区'], + people: ['陈晨', '林岚', '周宁', '王雨'], + statuses: ['待处理', '已支付', '已关闭'], + products: ['便签', '键盘', '笔记本', '显示器'], + groups: ['办公用品', '电子设备'], + warehouses: ['北区主仓', '北区备仓', '南区主仓', '南区备仓'], + deliveries: ['普通', '加急'], + }, + 'en-US': { + teams: ['North', 'South'], + people: ['Chen', 'Lin', 'Zhou', 'Wang'], + statuses: ['Pending', 'Paid', 'Closed'], + products: ['Notes', 'Keyboard', 'Notebook', 'Monitor'], + groups: ['Office supplies', 'Electronics'], + warehouses: ['North main', 'North backup', 'South main', 'South backup'], + deliveries: ['Standard', 'Express'], + }, +} + +export const getOrderLabels = (locale: string) => + labels[locale === 'zh-CN' ? 'zh-CN' : 'en-US'] + +export function getOrderOptions(locale: string): SearchOptions { + const copy = getOrderLabels(locale) + + return { + statuses: statuses.map((value, index) => ({ + value, + label: copy.statuses[index], + })), + organizations: organizations.map((value, index) => ({ + value, + label: copy.teams[index], + })), + productCategories: copy.groups.map((label, group) => ({ + value: `category-${group}`, + label, + children: products + .slice(group * 2, group * 2 + 2) + .map((value, index) => ({ + value, + label: copy.products[group * 2 + index], + })), + })), + warehouseRegions: organizations.map((value, region) => ({ + value, + label: copy.teams[region], + children: warehouses + .slice(region * 2, region * 2 + 2) + .map((value, index) => ({ + value, + label: copy.warehouses[region * 2 + index], + })), + })), + deliveries: ['standard', 'express'].map((value, index) => ({ + value, + label: copy.deliveries[index], + })), + } +} + +export const orders = Array.from({ length: 96 }, (_, index) => { + const ownerIndex = index % owners.length + const { orgId, id: ownerId } = owners[ownerIndex] + const productIndex = Math.floor(index / 3) % products.length + const statusIndex = index % statuses.length + const warehouseIndex = Math.floor(index / 8) % warehouses.length + const day = 1 + (index % 12) + const hour = index % 3 === 0 ? 9 : 14 + + return { + id: index + 1, + orderNo: `ORD-${String(index + 1).padStart(3, '0')}`, + productIndex, + productId: products[productIndex], + statusIndex, + status: statuses[statusIndex], + createdAt: `2026-11-${String(day).padStart(2, '0')}`, + orgId, + ownerId, + ownerIndex, + warehouseIndex, + warehouseId: warehouses[warehouseIndex], + amount: [0, 59, 129, 199, 349, 699, 1299, 2499][index % 8], + invoiced: Math.floor(index / 4) % 2 === 0, + delivery: index % 3 === 0 ? 'express' : 'standard', + deliveryAt: new Date(2026, 10, day + 1, hour).getTime(), + deliveryTime: hour === 9 ? '09:00:00' : '14:00:00', + } +}) + +export function orderMatchesQuery(row: DemoOrder, query: DemoOrderQuery) { + const { + keyword, + status, + createdFrom, + createdTo, + orgId, + ownerId, + productId, + warehouseId, + minAmount, + invoiced, + delivery, + deliveryFrom, + deliveryTo, + deliveryTime, + } = query + + return ( + `${row.orderNo} ${row.product}` + .toLowerCase() + .includes(String(keyword ?? '').toLowerCase()) && + (!status?.length || status.includes(row.status)) && + (typeof createdFrom !== 'string' || row.createdAt >= createdFrom) && + (typeof createdTo !== 'string' || row.createdAt <= createdTo) && + (orgId == null || row.orgId === orgId) && + (ownerId == null || row.ownerId === ownerId) && + (productId == null || row.productId === productId) && + (warehouseId == null || row.warehouseId === warehouseId) && + (typeof minAmount !== 'number' || row.amount >= minAmount) && + (invoiced == null || row.invoiced === invoiced) && + (delivery == null || row.delivery === delivery) && + (typeof deliveryFrom !== 'number' || row.deliveryAt >= deliveryFrom) && + (typeof deliveryTo !== 'number' || row.deliveryAt <= deliveryTo) && + (deliveryTime == null || row.deliveryTime === deliveryTime) + ) +} diff --git a/packages/demo-data/src/people.ts b/packages/demo-data/src/people.ts new file mode 100644 index 00000000..9b82b883 --- /dev/null +++ b/packages/demo-data/src/people.ts @@ -0,0 +1,57 @@ +import { faker } from '@faker-js/faker/locale/zh_CN' +import type { + PeopleResult, + Person, + PersonListParams, +} from '@ray-template/api-contracts/demo' + +export type { + PeopleResult, + Person, + PersonListParams, +} from '@ray-template/api-contracts/demo' + +let people: Person[] | undefined + +export const listPeople = ({ + page, + pageSize, + email, + name, + sortAge, +}: PersonListParams = {}): PeopleResult => { + // 同一会话内复用数据,让翻页和从上一页复制的搜索词都可重复使用。 + people ??= Array.from({ length: 100 }, () => ({ + id: faker.string.uuid(), + address: faker.location.state() + faker.location.city(), + email: faker.internet.email(), + name: faker.person.fullName(), + age: faker.number.int({ min: 18, max: 60 }), + createDate: faker.date.past().toISOString().slice(0, 10), + })) + + const emailQuery = email?.trim().toLowerCase() + const nameQuery = name?.trim().toLowerCase() + const matches = people.filter( + (person) => + (!emailQuery || person.email.toLowerCase().includes(emailQuery)) && + (!nameQuery || person.name.toLowerCase().includes(nameQuery)), + ) + + if (sortAge) { + const direction = sortAge === 'ascend' ? 1 : -1 + + matches.sort((left, right) => direction * (left.age - right.age)) + } + + const validPage = page !== void 0 && Number.isSafeInteger(page) && page > 0 + const validSize = + pageSize !== void 0 && Number.isSafeInteger(pageSize) && pageSize > 0 + const start = validPage && validSize ? (page - 1) * pageSize : 0 + + return { + items: + validPage && validSize ? matches.slice(start, start + pageSize) : matches, + total: matches.length, + } +} diff --git a/packages/demo-data/src/queries.ts b/packages/demo-data/src/queries.ts new file mode 100644 index 00000000..685fb940 --- /dev/null +++ b/packages/demo-data/src/queries.ts @@ -0,0 +1,82 @@ +import type { + DemoCharts, + DemoOrder, + DemoOrderQuery, + OwnerOptions, + RoutePeopleQuery, + RoutePeopleResult, +} from '@ray-template/api-contracts/demo' +import charts from './charts.json' with { type: 'json' } +import { getOrderLabels, orderMatchesQuery, orders, owners } from './orders.ts' +import { routeDemoPeople } from './route-people.ts' + +export function getDemoCharts(refresh = false): DemoCharts { + if (!refresh) return charts + + return { + ...charts, + lines: charts.lines.map((line) => ({ + ...line, + values: line.values.map(() => Math.floor((Math.random() + 1) * 100)), + })), + } +} + +export function listRouteDemoPeople({ + page = 1, + pageSize = 10, + name, +}: RoutePeopleQuery): RoutePeopleResult { + const matches = routeDemoPeople.filter( + (person) => name === void 0 || person.name === name, + ) + + return { + items: matches.slice((page - 1) * pageSize, page * pageSize), + total: matches.length, + } +} + +export function searchDemoOwners( + organization: string, + keyword: string, + locale: string, +): OwnerOptions { + const copy = getOrderLabels(locale) + const search = keyword.trim().toLowerCase() + + return owners.flatMap(({ id, orgId }, index) => + orgId === organization && copy.people[index].toLowerCase().includes(search) + ? [{ label: copy.people[index], value: id }] + : [], + ) +} + +export function searchDemoOrders(query: DemoOrderQuery, locale: string) { + const copy = getOrderLabels(locale) + const matches = orders + .map( + ({ + productIndex, + statusIndex, + ownerIndex, + warehouseIndex, + ...row + }): DemoOrder => ({ + ...row, + product: copy.products[productIndex], + statusLabel: copy.statuses[statusIndex], + organization: copy.teams[row.orgId === 'north' ? 0 : 1], + owner: copy.people[ownerIndex], + warehouse: copy.warehouses[warehouseIndex], + deliveryLabel: copy.deliveries[row.delivery === 'express' ? 1 : 0], + }), + ) + .filter((row) => orderMatchesQuery(row, query)) + const { page = 1, pageSize = 5 } = query + + return { + items: matches.slice((page - 1) * pageSize, page * pageSize), + total: matches.length, + } +} diff --git a/apps/admin/src/mocks/data/request.json b/packages/demo-data/src/request.json similarity index 100% rename from apps/admin/src/mocks/data/request.json rename to packages/demo-data/src/request.json diff --git a/packages/demo-data/src/route-catalog.json b/packages/demo-data/src/route-catalog.json new file mode 100644 index 00000000..ec469e4a --- /dev/null +++ b/packages/demo-data/src/route-catalog.json @@ -0,0 +1,257 @@ +{ + "views": [ + { + "id": "dashboard", + "name": "RDashboard" + }, + { + "id": "system/users", + "name": "UserManagement" + }, + { + "id": "demo/axios", + "name": "RAxios" + }, + { + "id": "demo/barcode-demo", + "name": "BarcodeDemo" + }, + { + "id": "demo/cache-demo", + "name": "CacheDemo" + }, + { + "id": "demo/context-menu", + "name": "ContextMenuDemo" + }, + { + "id": "demo/directive", + "name": "RDirective" + }, + { + "id": "demo/doc", + "name": "RTemplateDoc" + }, + { + "id": "demo/draggable-card", + "name": "DraggableCardDemo" + }, + { + "id": "demo/echart", + "name": "REchart" + }, + { + "id": "demo/flow-demo", + "name": "RFlowDemo" + }, + { + "id": "demo/form", + "name": "RFormDemo" + }, + { + "id": "demo/hooks/web-hooks", + "name": "WebHooks" + }, + { + "id": "demo/iframe", + "name": "IframeDemo" + }, + { + "id": "demo/layout-demo", + "name": "LayoutDemo" + }, + { + "id": "demo/modal-demo", + "name": "ModalDemo" + }, + { + "id": "demo/multi/views/multi-menu-one", + "name": "MultiMenuOne" + }, + { + "id": "demo/multi/views/multi-menu-two/views/sub-menu-other", + "name": "SubMenuOther" + }, + { + "id": "demo/multi/views/multi-menu-two/views/sub-menu/views/multi-menu-two-one", + "name": "MultiMenuTwoOne" + }, + { + "id": "demo/precision", + "name": "CalculatePrecision" + }, + { + "id": "demo/qrcode", + "name": "RQRCodeDemo" + }, + { + "id": "demo/rely/views/rely-about", + "name": "RelyAbout" + }, + { + "id": "demo/router-demo/router-demo-detail", + "name": "RouterDemoDetail" + }, + { + "id": "demo/router-demo/router-demo-home", + "name": "RouterDemoHome" + }, + { + "id": "demo/scroll-reveal", + "name": "ScrollReveal" + }, + { + "id": "demo/segment", + "name": "SegmentDemo" + }, + { + "id": "demo/svg-icons", + "name": "PreviewSVGIcons" + }, + { + "id": "demo/tables/auto-height", + "name": "TableDemoAutoHeight" + }, + { + "id": "demo/tables/basic", + "name": "TableDemoBasic" + }, + { + "id": "demo/tables/columns", + "name": "TableDemoColumns" + }, + { + "id": "demo/tables/controlled", + "name": "TableDemoControlled" + }, + { + "id": "demo/tables/custom", + "name": "TableDemoCustom" + }, + { + "id": "demo/tables/hooks-output", + "name": "TableDemoHooksOutput" + }, + { + "id": "demo/tables/hooks-query", + "name": "TableDemoHooksQuery" + }, + { + "id": "demo/tables/hooks-selection", + "name": "TableDemoHooksSelection" + }, + { + "id": "demo/tables/printing", + "name": "TableDemoPrinting" + }, + { + "id": "demo/tables/remote", + "name": "TableDemoRemote" + }, + { + "id": "demo/tables/search", + "name": "TableDemoSearch" + }, + { + "id": "demo/template-hooks", + "name": "TemplateHooks" + } + ], + "managementPath": "/route-management", + "reservedPaths": [ + "/welcome", + "/403", + "/404", + "/500" + ], + "reservedNames": [ + "RWelcome", + "ErrorPage403", + "ErrorPage404", + "ErrorPage500", + "RNotFound", + "RLogin", + "RLayout", + "RNotFound", + "RouteManagement", + "RouteManagementVisual", + "ErrorPage", + "RayTemplateDoc" + ], + "icons": [ + "action/add", + "action/adjustment", + "action/close", + "action/close_all", + "action/close_left", + "action/close_other", + "action/close_right", + "action/copy", + "action/copy-image", + "action/delete", + "action/download", + "action/draggable", + "action/edit", + "action/external-link", + "action/filter", + "action/fullscreen", + "action/fullscreen_fold", + "action/link", + "action/lock", + "action/more", + "action/mouse", + "action/out", + "action/print", + "action/reload", + "action/search", + "action/setting", + "action/shared", + "action/table-bordered", + "action/table-striped", + "action/upload", + "directional/enter", + "directional/expanded", + "directional/left_arrow", + "directional/resize_h", + "directional/right_arrow", + "directional/row_end", + "directional/row_head", + "logo/axios", + "logo/github", + "logo/google", + "logo/ray", + "logo/twitter", + "navigation/appearance", + "navigation/barcode", + "navigation/components", + "navigation/dashboard", + "navigation/database", + "navigation/document", + "navigation/echart", + "navigation/flow", + "navigation/form", + "navigation/icons", + "navigation/layout", + "navigation/menu", + "navigation/other", + "navigation/qr_code", + "navigation/rely", + "navigation/routing", + "navigation/table", + "navigation/window", + "status/error", + "status/question", + "status/success", + "status/warning", + "system/dark", + "system/language", + "system/light", + "system/system_os", + "system/watermark" + ], + "iconAliases": { + "action/export_excel": "action/download", + "logo/office": "navigation/table", + "illustration/login_bg": "navigation/other" + } +} diff --git a/packages/demo-data/src/route-people.ts b/packages/demo-data/src/route-people.ts new file mode 100644 index 00000000..9b6da5b2 --- /dev/null +++ b/packages/demo-data/src/route-people.ts @@ -0,0 +1,11 @@ +import type { RouteDemoPerson } from '@ray-template/api-contracts/demo' + +export const routeDemoPeople: RouteDemoPerson[] = Array.from( + { length: 10 }, + (_, index) => ({ + key: index, + name: `张三${index}`, + address: 'New York No. 1 Lake Park', + phone: '010-121212', + }), +) diff --git a/apps/admin/src/mocks/data/routes.json b/packages/demo-data/src/routes.json similarity index 100% rename from apps/admin/src/mocks/data/routes.json rename to packages/demo-data/src/routes.json diff --git a/packages/demo-data/src/users.ts b/packages/demo-data/src/users.ts new file mode 100644 index 00000000..fc7d419a --- /dev/null +++ b/packages/demo-data/src/users.ts @@ -0,0 +1,69 @@ +import type { AdminUser, UserOptions } from '@ray-template/api-contracts/admin' + +const departments = [ + { id: 'product', parentId: 'company' }, + { id: 'engineering', parentId: 'company' }, + { id: 'platform', parentId: 'engineering' }, + { id: 'experience', parentId: 'engineering' }, + { id: 'operations', parentId: 'company' }, +] + +export const initialUserOptions: UserOptions = { + departments: [ + { + id: 'company', + parentId: null, + name: 'Ray Studio', + labelKey: 'userManagement.departments.company', + }, + ...departments.map((item) => ({ + ...item, + name: item.id, + labelKey: `userManagement.departments.${item.id}`, + })), + ], + roles: ['admin', 'manager', 'member'].map((value) => ({ + value, + label: value, + labelKey: `userManagement.roles.${value}`, + })), +} + +export const createInitialUsers = (): AdminUser[] => + [ + 'Alex Chen', + 'Jordan Lee', + 'Casey Lin', + 'Morgan Wu', + 'Taylor Wang', + 'Avery Liu', + 'Riley Zhao', + 'Jamie Sun', + 'Robin Xu', + 'Sam Zhou', + 'Drew Huang', + 'Quinn Yang', + 'Skyler He', + 'Cameron Lu', + 'Reese Ma', + 'Parker Guo', + 'Charlie Yu', + 'Dakota Shen', + 'Emery Han', + 'Finley Luo', + 'Hayden Tang', + 'Jules Gao', + 'Kendall Song', + 'Logan Feng', + ].map((name, index) => ({ + id: `demo-user-${index + 1}`, + username: `user${String(index + 1).padStart(3, '0')}`, + name, + email: `user${index + 1}@example.com`, + phone: '', + departmentId: departments[index % departments.length]!.id, + role: index === 0 ? 'admin' : index % 5 === 0 ? 'manager' : 'member', + status: index % 6 === 5 ? 'disabled' : 'enabled', + remark: '', + createdAt: new Date(Date.UTC(2026, 0, index + 1, 9)).toISOString(), + })) diff --git a/packages/directives/package.json b/packages/directives/package.json index f4ec3872..6e993fd1 100644 --- a/packages/directives/package.json +++ b/packages/directives/package.json @@ -26,5 +26,8 @@ }, "peerDependencies": { "vue": "3.5.44" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/packages/http/package.json b/packages/http/package.json index a1b2e947..1cef44e2 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -11,5 +11,8 @@ "dependencies": { "axios": "1.21.0", "@ray-template/utils": "workspace:*" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/packages/icons/package.json b/packages/icons/package.json index c08e3eab..67b58245 100644 --- a/packages/icons/package.json +++ b/packages/icons/package.json @@ -6,5 +6,8 @@ ".": "./src/index.ts", "./manifest": "./src/manifest.ts", "./assets": "./src/assets.ts" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/packages/icons/src/index.ts b/packages/icons/src/index.ts index 1d1c9f0f..5b191250 100644 --- a/packages/icons/src/index.ts +++ b/packages/icons/src/index.ts @@ -1,10 +1,10 @@ -import { iconNames, isIconName } from './manifest' -import type { IconName } from './manifest' +import { iconNames, isIconName } from './manifest.ts' +import type { IconName } from './manifest.ts' -export { iconNames, iconPackages, isIconName } from './manifest' -export type { IconName, IconPackage } from './manifest' +export { iconNames, iconPackages, isIconName } from './manifest.ts' +export type { IconName, IconPackage } from './manifest.ts' -const retiredIcons = new Map([ +export const retiredIcons = new Map([ ['action/export_excel', 'action/download'], ['logo/office', 'navigation/table'], ['illustration/login_bg', 'navigation/other'], diff --git a/packages/routing/package.json b/packages/routing/package.json index 4095486e..cce72de8 100644 --- a/packages/routing/package.json +++ b/packages/routing/package.json @@ -14,11 +14,15 @@ "@valibot/to-json-schema": "1.8.0", "valibot": "1.5.0", "@ray-template/icons": "workspace:*", - "@ray-template/utils": "workspace:*" + "@ray-template/utils": "workspace:*", + "@ray-template/api-contracts": "workspace:*" }, "peerDependencies": { "vue": "3.5.44", "vue-router": "5.4.0", "naive-ui": "2.45.3" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/packages/routing/src/contract.ts b/packages/routing/src/contract.ts index 239c13ec..f1b88667 100644 --- a/packages/routing/src/contract.ts +++ b/packages/routing/src/contract.ts @@ -1,7 +1,5 @@ +import { createRouteParser } from '@ray-template/api-contracts/route-validation' import { isIconName, replaceRetiredIconName } from '@ray-template/icons' -import { getDotPath, safeParse } from 'valibot' -import { joinRoutePath } from './join-route-path' -import { routeConfigSchema } from './schema' import type { RouteConfig, RouteConfigRecord } from './schema' import type { AppRouteRecordRaw } from './types' @@ -24,191 +22,12 @@ export interface RouteCatalog { } export function createRouteContract(catalog: RouteCatalog) { - const { - layout: LAYOUT, - findRouteView, - findRouteViewId, - managementPath: ROUTE_MANAGEMENT_PATH, - } = catalog - const reservedPaths = - catalog.reservedPaths?.map((path) => path.toLowerCase()) ?? [] - const isReservedPath = (path: string) => - path === '/' || - path === ROUTE_MANAGEMENT_PATH || - path.startsWith(`${ROUTE_MANAGEMENT_PATH}/`) || - reservedPaths.some( - (reserved) => path === reserved || path.startsWith(`${reserved}/`), - ) - const reservedNames = new Set( - catalog.reservedNames?.map((name) => name.toLowerCase()), - ) - const configLimit = 256 * 1024 - const asList = (value: string | string[] | undefined) => - typeof value === 'string' ? [value] : (value ?? []) - - function parseRouteConfig(text: string): RouteConfig { - if (text.length > configLimit) - throw new Error('Route configuration exceeds 256 KiB.') - - const input = JSON.parse(text) - let count = 0 - const checkDepth = (routes: unknown, depth: number) => { - if (!Array.isArray(routes)) return - - count += routes.length - - if (count > 300 || depth > 8) - throw new Error('Use at most 300 routes and 8 menu levels.') - - for (const item of routes) checkDepth(item?.children, depth + 1) - } - - checkDepth(input?.routes, 1) - - const result = safeParse(routeConfigSchema, input) - - if (!result.success) { - throw new Error( - result.issues - .slice(0, 20) - .map((issue) => `${getDotPath(issue) ?? 'config'}: ${issue.message}`) - .join('\n'), - ) - } - - const config = result.output - - const paths = new Map() - const names = new Set(reservedNames) - const menuPaths = new Set() - const matchPatterns = new Set() - - const visit = (records: RouteConfigRecord[], parent = '') => { - for (const record of records) { - const { name, component, children, alias, redirect, props, meta } = - record - const path = joinRoutePath(parent, record.path) - const fail = (message: string): never => { - throw new Error(`${path}: ${message}`) - } - - const menuPath = path.toLowerCase() - - if (menuPaths.has(menuPath) || isReservedPath(menuPath)) - fail('Duplicate or reserved menu path.') - - menuPaths.add(menuPath) - - if (meta.windowOpen && !URL.canParse(meta.windowOpen)) - fail('Invalid external URL.') - - if (name) { - const key = name.toLowerCase() - - if (names.has(key)) fail(`Duplicate or reserved name "${name}".`) - - names.add(key) - } - - if (meta.icon) meta.icon = replaceRetiredIconName(meta.icon) - - if (meta.extra?.icon) - meta.extra.icon = replaceRetiredIconName(meta.extra.icon) - - for (const icon of [meta.icon, meta.extra?.icon]) { - if (icon && !isIconName(icon)) fail(`Unknown icon "${icon}".`) - } - - if (children?.length) { - if ( - (component && component !== 'layout') || - alias || - redirect || - props !== void 0 || - meta.windowOpen - ) - fail('Groups accept layout, children and menu metadata.') - - if (path.includes(':')) fail('Use static paths for menu groups.') - - visit(children, path) - continue - } - - const view = component && findRouteView(component) - - if (component && !view) fail(`Unknown view "${component}".`) - - if ( - Number(!!component) + - Number(!!redirect) + - Number(!!meta.windowOpen) !== - 1 - ) - fail('Specify exactly one view, redirect or external URL.') - - if (props !== void 0 && !view) fail('Props require a view.') - - if (meta.keepAlive && (!view || name !== view.name)) - fail('keepAlive requires the registered component name.') - - if (path.includes(':') && !meta.hidden && !meta.sameLevel) - fail('Parameterized paths must be hidden or sameLevel.') - - for (const address of [path, ...asList(alias)]) { - const key = address.toLowerCase() - - if ( - key - .split('/') - .some((segment) => segment === '.' || segment === '..') - ) - fail(`Invalid path "${address}".`) - - if (isReservedPath(key) || paths.has(key)) - fail(`Duplicate or reserved path "${address}".`) - - if (address !== path && (address.includes(':') || path.includes(':'))) - fail('Aliases require a static page path.') - - const pattern = key.replace(/:[a-z_]\w*/g, ':param') - - if (matchPatterns.has(pattern)) - fail(`Conflicting parameter pattern "${address}".`) - - matchPatterns.add(pattern) - paths.set(key, record) - } - } - } - - visit(config.routes) - - for (const [path, record] of paths) { - let current = record - const visited = new Set() - - while (current.redirect) { - const next = paths.get(current.redirect.toLowerCase()) - - if ( - visited.has(current) || - !next || - next.meta.windowOpen || - current.redirect.includes(':') - ) { - throw new Error( - `${path}: Redirects must reach a configured page without a cycle.`, - ) - } - - visited.add(current) - current = next - } - } - - return config - } + const { layout: LAYOUT, findRouteView, findRouteViewId } = catalog + const parseRouteConfig = createRouteParser({ + ...catalog, + isIconName, + normalizeIcon: replaceRetiredIconName, + }) function toRuntimeRoutes(config: RouteConfig): AppRouteRecordRaw[] { const toRoute = ({ diff --git a/packages/routing/src/json-schema.ts b/packages/routing/src/json-schema.ts index 411a5495..34d76151 100644 --- a/packages/routing/src/json-schema.ts +++ b/packages/routing/src/json-schema.ts @@ -1,9 +1 @@ -import { toJsonSchema } from '@valibot/to-json-schema' -import { routeConfigSchema, routeRecordSchema } from './schema.ts' - -export const getRouteJsonSchema = () => - toJsonSchema(routeConfigSchema, { - target: 'draft-2020-12', - definitions: { route: routeRecordSchema }, - ignoreActions: ['check', 'finite'], - }) +export * from '@ray-template/api-contracts/route-json-schema' diff --git a/packages/routing/src/schema.ts b/packages/routing/src/schema.ts index 5f2e1eff..52143de7 100644 --- a/packages/routing/src/schema.ts +++ b/packages/routing/src/schema.ts @@ -1,179 +1 @@ -import * as v from 'valibot' - -const text = v.pipe(v.string(), v.minLength(1), v.maxLength(256)) -const finiteNumber = v.pipe(v.number(), v.finite()) -const title = v.union([text, finiteNumber]) -const icon = v.pipe(text, v.regex(/^[\w-]+\/[\w-]+$/)) -const segment = '(?:[\\w~.-]+|:[A-Za-z_]\\w*\\??)' -const absolutePath = v.pipe( - text, - v.regex(new RegExp(`^/${segment}(?:/${segment})*$`)), -) -const unsafeProp = - /^(?:[oO][nN]|innerHTML$|outerHTML$|srcdoc$|__proto__$|constructor$|prototype$)/ -const viewProps = v.pipe( - v.record(v.string(), v.unknown()), - v.check( - (value) => Object.keys(value).every((key) => !unsafeProp.test(key)), - 'Unsafe view prop.', - ), - v.metadata({ propertyNames: { not: { pattern: unsafeProp.source } } }), -) - -const routeFields = { - path: v.pipe( - text, - v.regex(new RegExp(`^/?${segment}(?:/${segment})*$`)), - v.description( - 'Absolute or relative child path. Supports named and optional parameters.', - ), - ), - name: v.optional( - v.pipe( - text, - v.regex(/^[A-Za-z_][\w.-]*$/), - v.description('Unique Vue Router name. Required for keepAlive.'), - ), - ), - component: v.optional( - v.pipe( - text, - v.description('Registered view ID. Use layout for a menu group.'), - ), - ), - alias: v.optional( - v.pipe( - v.union([ - absolutePath, - v.pipe(v.array(absolutePath), v.minLength(1), v.maxLength(16)), - ]), - v.description('Absolute alternative path(s) for a leaf.'), - ), - ), - redirect: v.optional( - v.pipe( - absolutePath, - v.description('Absolute path of another configured page.'), - ), - ), - props: v.optional( - v.pipe( - v.union([v.boolean(), viewProps]), - v.description('Pass route params (true) or a JSON object to the view.'), - ), - ), - meta: v.strictObject({ - i18nKey: v.optional( - v.pipe(text, v.description('Translation key for the menu title.')), - ), - noLocalTitle: v.optional( - v.pipe(title, v.description('Literal title if i18nKey is absent.')), - ), - icon: v.optional( - v.pipe(icon, v.description('IconName from src/icons/manifest.ts.')), - ), - role: v.optional( - v.pipe( - v.array(title), - v.maxLength(32), - v.description( - 'Allowed roles. Omitted or empty means any authenticated role.', - ), - ), - ), - hidden: v.optional( - v.pipe( - v.boolean(), - v.description( - 'Hide from the menu. Direct navigation still uses the role guard.', - ), - ), - ), - sameLevel: v.optional( - v.pipe( - v.boolean(), - v.description('Append a breadcrumb without replacing the current tab.'), - ), - ), - order: v.optional( - v.pipe(finiteNumber, v.description('Menu sort order at the top level.')), - ), - env: v.optional( - v.pipe( - v.union([text, v.pipe(v.array(text), v.maxLength(16))]), - v.description('Vite mode(s) in which the menu item is visible.'), - ), - ), - windowOpen: v.optional( - v.pipe( - v.string(), - v.maxLength(2048), - v.regex(/^[Hh][Tt][Tt][Pp][Ss]?:\/\//), - v.description('Open this HTTP(S) URL in a new tab.'), - ), - ), - ignoreAutoResetScroll: v.optional( - v.pipe( - v.boolean(), - v.description('Keep the content scroll position on navigation.'), - ), - ), - keepAlive: v.optional( - v.pipe( - v.boolean(), - v.description( - 'Keep the view mounted. name must match the registered view name.', - ), - ), - ), - extra: v.optional( - v.pipe( - v.strictObject({ - label: v.optional(title), - i18nLabel: v.optional(text), - icon: v.optional(icon), - show: v.optional(v.boolean()), - type: v.optional( - v.picklist([ - 'default', - 'primary', - 'info', - 'success', - 'warning', - 'error', - ]), - ), - }), - v.description('Optional menu badge.'), - ), - ), - }), -} - -type RouteFields = v.InferOutput< - v.StrictObjectSchema -> - -export type RouteConfigRecord = RouteFields & { children?: RouteConfigRecord[] } - -export const routeRecordSchema: v.GenericSchema = - v.strictObject({ - ...routeFields, - children: v.optional( - v.pipe( - v.array(v.lazy(() => routeRecordSchema)), - v.minLength(1), - v.maxLength(300), - ), - ), - }) - -export const routeConfigSchema = v.pipe( - v.strictObject({ - version: v.literal(1), - routes: v.pipe(v.array(routeRecordSchema), v.maxLength(300)), - }), - v.title('Ray Template route configuration'), -) - -export type RouteConfig = v.InferOutput +export * from '@ray-template/api-contracts/routes' diff --git a/packages/ui/package.json b/packages/ui/package.json index 3357408b..ce217b0d 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -37,5 +37,8 @@ "peerDependencies": { "vue": "3.5.44", "naive-ui": "2.45.3" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/packages/utils/package.json b/packages/utils/package.json index e3cb2540..12fc2c5a 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -17,5 +17,8 @@ "dependencies": { "currency.js": "2.0.4", "lodash-es": "4.18.1" + }, + "rayTemplate": { + "runtime": "browser" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 44502665..4deed931 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -190,6 +190,9 @@ importers: '@ray-template/composables': specifier: workspace:* version: link:packages/composables + '@ray-template/demo-data': + specifier: workspace:* + version: link:packages/demo-data '@ray-template/directives': specifier: workspace:* version: link:packages/directives @@ -273,7 +276,7 @@ importers: version: 11.4.17(vue@3.5.44(typescript@6.0.3)) vue-router: specifier: 5.4.0 - version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.25.12)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) vue3-next-qrcode: specifier: 4.1.1 version: 4.1.1(vue@3.5.44(typescript@6.0.3)) @@ -292,10 +295,10 @@ importers: version: 4.7.1(@vue/compiler-sfc@3.5.44)(prettier@3.9.10) '@intlify/unplugin-vue-i18n': specifier: 11.2.8 - version: 11.2.8(rollup@4.67.4)(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue-i18n@11.4.17(vue@3.5.44(typescript@6.0.3)))(vue@3.5.44(typescript@6.0.3)) + version: 11.2.8(rollup@4.67.4)(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue-i18n@11.4.17(vue@3.5.44(typescript@6.0.3)))(vue@3.5.44(typescript@6.0.3)) '@spiriit/vite-plugin-svg-spritemap': specifier: 7.2.0 - version: 7.2.0(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 7.2.0(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) '@types/crypto-js': specifier: 4.2.2 version: 4.2.2 @@ -310,10 +313,10 @@ importers: version: 26.6.6 '@vitejs/plugin-vue': specifier: 6.0.10 - version: 6.0.10(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 6.0.10(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) '@vitejs/plugin-vue-jsx': specifier: 5.1.6 - version: 5.1.6(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 5.1.6(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) '@vitest/ui': specifier: 5.0.5 version: 5.0.5(vitest@5.0.5) @@ -323,6 +326,9 @@ importers: autoprefixer: specifier: 10.6.2 version: 10.6.2(postcss@8.5.32) + esbuild: + specifier: 0.28.2 + version: 0.28.2 eslint: specifier: 10.14.0 version: 10.14.0(jiti@2.7.0) @@ -367,16 +373,16 @@ importers: version: 8.72.1(eslint@10.14.0(jiti@2.7.0))(typescript@6.0.3) unocss: specifier: 66.12.0 - version: 66.12.0(@oxc-project/types@0.156.0)(cac@7.1.0)(rolldown@1.2.16)(rollup@4.67.4)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + version: 66.12.0(@oxc-project/types@0.156.0)(cac@7.1.0)(rolldown@1.2.16)(rollup@4.67.4)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) unplugin-auto-import: specifier: 21.1.0 - version: 21.1.0(@vueuse/core@15.0.0(vue@3.5.44(typescript@6.0.3)))(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + version: 21.1.0(@vueuse/core@15.0.0(vue@3.5.44(typescript@6.0.3)))(esbuild@0.28.2)(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) unplugin-vue-components: specifier: 32.1.0 - version: 32.1.0(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 32.1.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) vite: specifier: 8.3.5 - version: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + version: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) vite-bundle-analyzer: specifier: 1.3.9 version: 1.3.9 @@ -385,22 +391,25 @@ importers: version: 1.1.0(rollup@4.67.4) vite-plugin-ejs: specifier: 2.0.0 - version: 2.0.0(ejs@7.0.2)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + version: 2.0.0(ejs@7.0.2)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) vite-plugin-inspect: specifier: 12.1.0 - version: 12.1.0(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + version: 12.1.0(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) vite-svg-loader: specifier: 5.1.3 version: 5.1.3(vue@3.5.44(typescript@6.0.3)) vitest: specifier: 5.0.5 - version: 5.0.5(@types/node@26.6.6)(@vitest/ui@5.0.5)(happy-dom@21.0.4)(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + version: 5.0.5(@types/node@26.6.6)(@vitest/ui@5.0.5)(happy-dom@21.0.4)(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) vue-eslint-parser: specifier: 10.4.1 version: 10.4.1(eslint@10.14.0(jiti@2.7.0)) vue-tsc: specifier: 3.3.14 version: 3.3.14(typescript@6.0.3) + yaml: + specifier: 2.9.1 + version: 2.9.1 apps/admin: dependencies: @@ -422,6 +431,9 @@ importers: '@ray-template/composables': specifier: workspace:* version: link:../../packages/composables + '@ray-template/demo-data': + specifier: workspace:* + version: link:../../packages/demo-data '@ray-template/directives': specifier: workspace:* version: link:../../packages/directives @@ -505,10 +517,14 @@ importers: version: 11.4.17(vue@3.5.44(typescript@6.0.3)) vue-router: specifier: 5.4.0 - version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.25.12)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) vue3-next-qrcode: specifier: 4.1.1 version: 4.1.1(vue@3.5.44(typescript@6.0.3)) + devDependencies: + vite: + specifier: 8.3.5 + version: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) apps/docs: dependencies: @@ -544,7 +560,7 @@ importers: version: 3.5.44(typescript@6.0.3) vue-router: specifier: 5.4.0 - version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.25.12)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) devDependencies: '@vitejs/plugin-vue-jsx': specifier: 5.1.6 @@ -559,6 +575,70 @@ importers: specifier: 1.6.4 version: 1.6.4(@algolia/client-search@5.61.0)(@types/node@26.6.6)(async-validator@4.2.5)(axios@1.21.0(debug@4.4.3))(jiti@2.7.0)(lightningcss@1.33.0)(postcss@8.5.32)(sass@1.107.1)(search-insights@2.17.3)(typescript@6.0.3)(yaml@2.9.1) + apps/server: + dependencies: + '@faker-js/faker': + specifier: 10.6.0 + version: 10.6.0 + '@nestjs/common': + specifier: 12.3.3 + version: 12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2) + '@nestjs/core': + specifier: 12.3.3 + version: 12.3.3(@nestjs/common@12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/platform-express@12.3.3)(reflect-metadata@0.2.2)(rxjs@7.8.2) + '@nestjs/platform-express': + specifier: 12.3.3 + version: 12.3.3(@nestjs/common@12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@12.3.3) + '@prisma/adapter-pg': + specifier: 7.10.1 + version: 7.10.1 + '@prisma/client': + specifier: 7.10.1 + version: 7.10.1(prisma@7.10.1(@types/node@26.6.6)(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(typescript@6.0.3))(typescript@6.0.3) + '@ray-template/api-contracts': + specifier: workspace:* + version: link:../../packages/api-contracts + '@ray-template/demo-data': + specifier: workspace:* + version: link:../../packages/demo-data + express: + specifier: 5.3.0 + version: 5.3.0 + pg: + specifier: 8.23.1 + version: 8.23.1 + redis: + specifier: 6.3.1 + version: 6.3.1 + reflect-metadata: + specifier: 0.2.2 + version: 0.2.2 + rxjs: + specifier: 7.8.2 + version: 7.8.2 + valibot: + specifier: 1.5.0 + version: 1.5.0(typescript@6.0.3) + devDependencies: + '@types/express': + specifier: 5.0.6 + version: 5.0.6 + '@types/node': + specifier: 26.6.6 + version: 26.6.6 + '@types/pg': + specifier: 8.23.1 + version: 8.23.1 + esbuild: + specifier: 0.28.2 + version: 0.28.2 + prisma: + specifier: 7.10.1 + version: 7.10.1(@types/node@26.6.6)(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(typescript@6.0.3) + typescript: + specifier: 6.0.3 + version: 6.0.3 + packages/admin-shell: dependencies: '@ray-template/composables': @@ -587,13 +667,10 @@ importers: version: 3.5.44(typescript@6.0.3) vue-router: specifier: 5.4.0 - version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.25.12)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) packages/api-contracts: dependencies: - '@ray-template/routing': - specifier: workspace:* - version: link:../routing '@valibot/to-json-schema': specifier: 1.8.0 version: 1.8.0(valibot@1.5.0(typescript@6.0.3)) @@ -628,6 +705,18 @@ importers: specifier: 3.5.44 version: 3.5.44(typescript@6.0.3) + packages/demo-data: + dependencies: + '@faker-js/faker': + specifier: 10.6.0 + version: 10.6.0 + '@ray-template/api-contracts': + specifier: workspace:* + version: link:../api-contracts + valibot: + specifier: 1.5.0 + version: 1.5.0(typescript@6.0.3) + packages/directives: dependencies: '@ray-template/composables': @@ -662,6 +751,9 @@ importers: packages/routing: dependencies: + '@ray-template/api-contracts': + specifier: workspace:* + version: link:../api-contracts '@ray-template/icons': specifier: workspace:* version: link:../icons @@ -682,7 +774,7 @@ importers: version: 3.5.44(typescript@6.0.3) vue-router: specifier: 5.4.0 - version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.25.12)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) + version: 5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)) packages/ui: dependencies: @@ -953,6 +1045,9 @@ packages: resolution: {integrity: sha512-KV8Y+teoRsmXeEPS4sCJY1kwV+hcPzHP1qQqgCxrjKOehLdBaxpsFBfoJ8MXWFV80y6Jw56+TM95wR0Per8dYw==} engines: {node: ^22.18.0 || >=24.11.0} + '@borewit/text-codec@0.2.3': + resolution: {integrity: sha512-49CycTz1aAZmvFcwkeFyhud1HUmRIB5Tabf7ALV+VA4Iu85MTfz2cUwzPagMFAdVBvrWdkCxG67I30tUwwpKsw==} + '@cacheable/memory@2.2.0': resolution: {integrity: sha512-CTLKqLItRCEixEAewD3/j9DB3/o96gpTPD4eJ1v+DGOlxZRZncRQkGYqqnAGCscYd6RNeXfGeiuCphsPtqyIfQ==} @@ -1095,6 +1190,20 @@ packages: search-insights: optional: true + '@electric-sql/pglite-socket@0.1.3': + resolution: {integrity: sha512-LAciWM0M1dCL8hlsxu2venbVZcdxema0BtDfpWYVqr+Y468UADw0pFWidhKw1M8sfJ8rdLT71tjMmnirf/IZRQ==} + hasBin: true + peerDependencies: + '@electric-sql/pglite': 0.4.3 + + '@electric-sql/pglite-tools@0.3.3': + resolution: {integrity: sha512-AlzLJTRJ8+UFgK8CmxIpyIpJ0+YaFw02IiOSdYrqxwPXdSyeIShz8aa9Tq+tYFXdPwcaMp/Fc80mQZ1dkOQ/wg==} + peerDependencies: + '@electric-sql/pglite': 0.4.3 + + '@electric-sql/pglite@0.4.3': + resolution: {integrity: sha512-ichuWTgtd4mOM1G4SpyGJa5trT03lWbMypDV0fUXUCXg5hiHqVAz/bZyV68NqmkLB7WcYmj1RMJVSp8HV/v/ZQ==} + '@emotion/hash@0.8.0': resolution: {integrity: sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==} @@ -1104,156 +1213,312 @@ packages: cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.28.2': + resolution: {integrity: sha512-XExcO+dvLKvVtNTibSTBej1NCAbaGhWn9Ww1ZPx80qsahhPFe/8jgWP0IchNe0F3HwkU7n8ejhH8bjonqht8mQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + '@esbuild/android-arm64@0.25.12': resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==} engines: {node: '>=18'} cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.28.2': + resolution: {integrity: sha512-5YfKeeI8qWfBZIX+u2xZC3Zlb3Os/gLS2sbEKM+I4ZOcsWmHS2WLysCcQZDAFRslDUU5Oiq44gf6PYN1vGwG5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm@0.25.12': resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==} engines: {node: '>=18'} cpu: [arm] os: [android] + '@esbuild/android-arm@0.28.2': + resolution: {integrity: sha512-kXXoiPVVGQcnIYGOeaovwOURpniDBpSq4A03qkQ+BMQqtGG6HYap3xne9C1O1yo4TR3qxlCX5IqqmX6fFo2Lqg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + '@esbuild/android-x64@0.25.12': resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==} engines: {node: '>=18'} cpu: [x64] os: [android] + '@esbuild/android-x64@0.28.2': + resolution: {integrity: sha512-O387ite7SzUyCcy3JQX4P4bLtEA7bLLkx+esve5JHnyYfNTxcVpXZo9jhdB0lTKN44gztELTdU7nS8Nr16Fs1Q==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + '@esbuild/darwin-arm64@0.25.12': resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==} engines: {node: '>=18'} cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.28.2': + resolution: {integrity: sha512-n4KqkOQrraxHJcgjM1RvwbigfQKIKJVpM7xp+KsxiyUSrRdIXnt73VhrPAx0fV44hgfmIVKjxMN9J1t5jySVkw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-x64@0.25.12': resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==} engines: {node: '>=18'} cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.28.2': + resolution: {integrity: sha512-uq6suIWYP37qzGddBKPw5QEQPi6HiLGsO7UmkpfyaYNQ3D+rN6w6WfwH+nuqcGXWvawGwxOEroO4YGnFh95azw==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + '@esbuild/freebsd-arm64@0.25.12': resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==} engines: {node: '>=18'} cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.28.2': + resolution: {integrity: sha512-n+I0BTSRIoy+d6RPKnEVwql5UwBJolytvY4mAOIEJorKlqgPII8ix6slVVrfZ5Tnj7glIZvloylbB/EJPMWEXw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-x64@0.25.12': resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==} engines: {node: '>=18'} cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.28.2': + resolution: {integrity: sha512-78XJTJkvPs0kz2w61301PJjXl4g7q3JqiYMZ/M/yVI73EHBrCRTgkhu9oqG7vPqq+a/yadEW8aD+agKlk5xrmg==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + '@esbuild/linux-arm64@0.25.12': resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==} engines: {node: '>=18'} cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.28.2': + resolution: {integrity: sha512-pW4AC0P3it8c7do9MVM4p51FzHzdM/TZrerurgRcHJ2WTa1VQ1CIq18xncfpBJw4ojkiZZrKW2yIBWBP92j6Ug==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm@0.25.12': resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==} engines: {node: '>=18'} cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.28.2': + resolution: {integrity: sha512-XlDnu2q5yoqems+xay6wSAcg9DDD7K9RLKZEBOMZm3ckNpJBvOX20tSfby8KfrrhINDyv9V2YVZKY/SpoGJI8w==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + '@esbuild/linux-ia32@0.25.12': resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==} engines: {node: '>=18'} cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.28.2': + resolution: {integrity: sha512-CYbnj78HsIeA+DhgUKgFCfvNsTHFhMMrinUrMZpDXJXKN8T3XViTZ/+wtHeVxEWY8ewSzTFN+nRmSwO2tZaLUQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-loong64@0.25.12': resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==} engines: {node: '>=18'} cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.28.2': + resolution: {integrity: sha512-buwkd8nsph4R+ajRvw0qM5Hja/TXQow3ptzWO2EbG/cqcIkHloRrdlBtQlshyYGTNFvfkfJ5tpPLVkY4DtsPfQ==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-mips64el@0.25.12': resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==} engines: {node: '>=18'} cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.28.2': + resolution: {integrity: sha512-ZVykbDyk7519VwiNb9Lcj9m8XM6v5V9uKPvrEMkkEedVewf+0itkhahp4HDpgERXhwLRpWFypsGbG/J8s0QjJA==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-ppc64@0.25.12': resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==} engines: {node: '>=18'} cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.28.2': + resolution: {integrity: sha512-CAXl+Dtd9UUuJd8pKKdwh6MLm3MUMiqMPmhZ3tTSXPqfyQ3vDl6R5hZdZ/kYojK4ofXtdfSv1tFq8XzWx3heNQ==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-riscv64@0.25.12': resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==} engines: {node: '>=18'} cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.28.2': + resolution: {integrity: sha512-GeXCej4IQtU1B+QlDV8W/RRvbzI3O/Stss+/bCXv4lZls5WGRtu2a+3JkA3i4qIUlMXpcHebWpF8AkJhATowuA==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-s390x@0.25.12': resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==} engines: {node: '>=18'} cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.28.2': + resolution: {integrity: sha512-3H1weTYZPxt/WOhByszQZybS9w5lKzUn1FDMsgEChbHWQwHYQQRfBxgCcZvPhjHfKyJjIievvMmEUawJrdY9Dg==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-x64@0.25.12': resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==} engines: {node: '>=18'} cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.28.2': + resolution: {integrity: sha512-4xTZr1FUmSoQW4XIWmit3tzQrUTZM+N3P0XV8xROKYF50XfI7xeO90+1bZvNwxIufQ9hDQVRJH5YhgPVF8A/HQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + '@esbuild/netbsd-arm64@0.25.12': resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==} engines: {node: '>=18'} cpu: [arm64] os: [netbsd] + '@esbuild/netbsd-arm64@0.28.2': + resolution: {integrity: sha512-sSATRjPeDBg3pdgHoQfoYBob11Kk1FGa9lui5RIHZCoCkJa9QKlvl3/vKz2usCmYYjs7ymJR/2Nnsqe+Hjt5nw==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + '@esbuild/netbsd-x64@0.25.12': resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==} engines: {node: '>=18'} cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.28.2': + resolution: {integrity: sha512-lqnzCV+mM0gIADaKihiCg6ifgfU2L3h5E33rNQBN1Y4MaVGnzryzmvvf7UHxprpQdE8hpqLolJ9Rl+SkIRDpyw==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + '@esbuild/openbsd-arm64@0.25.12': resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==} engines: {node: '>=18'} cpu: [arm64] os: [openbsd] + '@esbuild/openbsd-arm64@0.28.2': + resolution: {integrity: sha512-AL2qJILH7lNjrDmCQDvdxMfAUIv8KMNZOvrwAQ8i8//ntL9FflhOyMJ8OZSMBb8/AWXe3/5v5S20y3zCoZWKoQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + '@esbuild/openbsd-x64@0.25.12': resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==} engines: {node: '>=18'} cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.28.2': + resolution: {integrity: sha512-QtiuPytchRyC4rwUKhexJdQKvDuZ6hWloi3igqPQNUJCS1/v9EiO3UTOXR6A3FoMo4fnAKbWJdqaIwhOzh8qEw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + '@esbuild/openharmony-arm64@0.25.12': resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==} engines: {node: '>=18'} cpu: [arm64] os: [openharmony] + '@esbuild/openharmony-arm64@0.28.2': + resolution: {integrity: sha512-WkhYDmpTjLvGlScA1rwjRUmhl4k8oXR3cIbtqWmELgU/dFeHHlEllxDvdWcNJV9rbzCexB5vz8gtNewWLgCT7Q==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + '@esbuild/sunos-x64@0.25.12': resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==} engines: {node: '>=18'} cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.28.2': + resolution: {integrity: sha512-GPMSkTOtMnv2U2F8gxe4Io6qmVs+YKyp832Etqqxr0hFngmXQ3rzwytelm3GIn7T4VviRUlf3sOgBOiTdvaf7g==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + '@esbuild/win32-arm64@0.25.12': resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==} engines: {node: '>=18'} cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.28.2': + resolution: {integrity: sha512-PIhhEkE9uPBleRBrQEJpUn7MBnibZzbGzYWPmY3x+YoVg/95zbjB4CxPPOQ8l5tYYM4mMaCthF8/1DIfBQQyWQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-ia32@0.25.12': resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==} engines: {node: '>=18'} cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.28.2': + resolution: {integrity: sha512-YmJbfTlvU7Sdn9BB+4PRES4oB6pxgS37MAONj+hBr/cpXS1aBPKXxNnDbu+QCWPj0o9dgyxeq79g6c5P8KeuYA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-x64@0.25.12': resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==} engines: {node: '>=18'} cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.28.2': + resolution: {integrity: sha512-5ebpxr3nWMzrL/rnUI755Jkuee0bHL/Gq0WTF9lvcpv73wAp5eu8MfBUgWK9bhWvZjj7yX8etf/8tI8Ney695g==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@eslint-community/eslint-utils@4.10.1': resolution: {integrity: sha512-cuadcxVFE8sDK6iWJbs8Sn0av2Nrh2QSGQhVlBW9AaAHqHwjWsZHT8LJ4hFGPh7ASBV2deFdM7H/DPjulmh8rg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -1488,6 +1753,10 @@ packages: peerDependencies: '@logicflow/core': ^2.2.5 + '@lukeed/csprng@1.1.0': + resolution: {integrity: sha512-Z7C/xXCiGWsg0KuKsHTKJxbWhpI3Vs5GwLfOean7MGyVFGqdRgBbAjOCh6u4bbjPc/8MJ2pZmK/0DLdCbivLDA==} + engines: {node: '>=8'} + '@mswjs/interceptors@0.40.0': resolution: {integrity: sha512-EFd6cVbHsgLa6wa4RljGj6Wk75qoHxUSyc5asLyyPSyuhIcdS2Q3Phw6ImS1q+CkALthJRShiYfKANcQMuMqsQ==} engines: {node: '>=18'} @@ -1499,6 +1768,43 @@ packages: os: [linux] libc: [glibc] + '@nestjs/common@12.3.3': + resolution: {integrity: sha512-e5HbxvNqNnsQfzYEfnjTCx9AExxYUu7YQxIO6yp09WtQl9MwOiZWilccWxC18spcbujZ6xacaH7Vfk/flYG0Pw==} + peerDependencies: + class-transformer: '>=0.4.1' + class-validator: '>=0.13.2' + reflect-metadata: ^0.1.12 || ^0.2.0 + rxjs: ^7.1.0 + peerDependenciesMeta: + class-transformer: + optional: true + class-validator: + optional: true + + '@nestjs/core@12.3.3': + resolution: {integrity: sha512-RElBJf+lxWEKNo/2CN1b8A7hvHmdMCEcXa3Hw2MW79W/PfX3A0gEtdc3o3hRneBd6MxmEvL95miZ/qvZS1W5kw==} + engines: {node: '>= 20'} + peerDependencies: + '@nestjs/common': ^12.0.0 + '@nestjs/microservices': ^12.0.0 + '@nestjs/platform-express': ^12.0.0 + '@nestjs/websockets': ^12.0.0 + reflect-metadata: ^0.1.12 || ^0.2.0 + rxjs: ^7.1.0 + peerDependenciesMeta: + '@nestjs/microservices': + optional: true + '@nestjs/platform-express': + optional: true + '@nestjs/websockets': + optional: true + + '@nestjs/platform-express@12.3.3': + resolution: {integrity: sha512-WUD0hBPChdTmAak9WQJ/S0KjlmBnDvWHIPCUZzrSnVvPVkvrW5Bbk2uW2cq1J15e6ArwjyR4XWAUZ8s4ftuNvQ==} + peerDependencies: + '@nestjs/common': ^12.0.0 + '@nestjs/core': ^12.0.0 + '@one-ini/wasm@0.2.1': resolution: {integrity: sha512-TUqERXGNTifZ9y2g3wPxQrw3HpHv/02DsW3D90T9x0hhonrL1ZqpSmNrU2XkoIq0fP1N6gZfVQzy2Fw1ZvGBNg==} @@ -1724,9 +2030,182 @@ packages: '@polka/url@1.0.0-next.29': resolution: {integrity: sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==} + '@prisma/adapter-pg@7.10.1': + resolution: {integrity: sha512-EP9ruPYHjKP80WZlb5qVaEXKgZjJieBFjAxcBtQnDAHD6+16UN4keVmBh6L/RUpuDQT2FQRbvKNgq5d4Ix+IkQ==} + + '@prisma/client-runtime-utils@7.10.1': + resolution: {integrity: sha512-AzoATVIgmO3lcZfM443+9SI7+cyLMW2+Psw4op8WQHpHvHCX//CKxv8fwhiL0yGWF8DjdQrFewxrZo5McBdB8g==} + + '@prisma/client@7.10.1': + resolution: {integrity: sha512-5tgAbFGh//zVOC6WPNVgziOErJHYkUE+wmqCwbIyq6IrTXUYtv9y2iBFGh/Owo99Mx0+cr0j1FOrxkYBMuyhaQ==} + engines: {node: ^20.19 || ^22.12 || >=24.0} + peerDependencies: + prisma: '*' + typescript: '>=5.4.0' + peerDependenciesMeta: + prisma: + optional: true + typescript: + optional: true + + '@prisma/config@7.10.1': + resolution: {integrity: sha512-+0swF5ELUa3P/9cIR26+gpYjjCbGE0qvEBZhV4zMDkYsrtHjZ884MQbOnWFWXj600N0sSJNnHbtBqe12yDngWg==} + + '@prisma/debug@7.10.1': + resolution: {integrity: sha512-eFCAkGZ13D/qPg48JBlG5IWi9cSBBOC7oG3abDPcAkYioDWlIjh0YJJLK2J7qo5S+xWWD8I6egAN/8KbCaiMCA==} + + '@prisma/debug@7.2.0': + resolution: {integrity: sha512-YSGTiSlBAVJPzX4ONZmMotL+ozJwQjRmZweQNIq/ER0tQJKJynNkRB3kyvt37eOfsbMCXk3gnLF6J9OJ4QWftw==} + + '@prisma/dev@0.24.17': + resolution: {integrity: sha512-UvdZzmpFwknnfreh6Jije84ekkYGPYEJhXG1tFzCsCfQyzJifrOo38eZc0qajzvaC6OLUOrN9ML5XfCnEZL9DA==} + + '@prisma/driver-adapter-utils@7.10.1': + resolution: {integrity: sha512-DJ4c6xvVnm3s9ZUyql9nCUicADSqyvH+CjXRCM9L6m5zJxCNmebCElG6X4irICq3rosBwlX+S19Dxq/4IrZk3A==} + + '@prisma/engines-version@8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8': + resolution: {integrity: sha512-XjXmwjN2NE340RpXoXv8ZF8aNAvr0FE+7gNfkKeW6vyjXs7F8uxvEbWQoVrhioXDQoIsnNmv7r+wxvzfdEZaWA==} + + '@prisma/engines@7.10.1': + resolution: {integrity: sha512-R6/ghv1Bu36FhCdQLFof1pNtyoWoeDzJLYeTKjgqb4eGtOAJx7ZqJtcm4pzkahLfZ9rYz8AkmsMDwkyiYbXPCQ==} + + '@prisma/fetch-engine@7.10.1': + resolution: {integrity: sha512-qZezeaExLWG2ptbHOrMxdiWluKHgqEclTdJbvY6pk6+Wg7EiVkeq5U3cXz9ti8nd0bngNvsDgledLHVRg5LF1w==} + + '@prisma/get-platform@7.10.1': + resolution: {integrity: sha512-iVnghHne5vcaobBjPVCMEjh5r/1UCj394EIGTUclasFRatpR/MQwcM2veLv5kgoFSyYP54nch/lNFCQRYcDxvg==} + + '@prisma/get-platform@7.2.0': + resolution: {integrity: sha512-k1V0l0Td1732EHpAfi2eySTezyllok9dXb6UQanajkJQzPUGi3vO2z7jdkz67SypFTdmbnyGYxvEvYZdZsMAVA==} + + '@prisma/query-plan-executor@7.2.0': + resolution: {integrity: sha512-EOZmNzcV8uJ0mae3DhTsiHgoNCuu1J9mULQpGCh62zN3PxPTd+qI9tJvk5jOst8WHKQNwJWR3b39t0XvfBB0WQ==} + + '@prisma/streams-local@0.1.11': + resolution: {integrity: sha512-0TcebL559MByKqTJ+SsrFIEg228iw8UCVRFckzgfRSiJqczhs+MuAgWOF9lnOIV/IVqvu+KMnFTH0eDeTQMpUg==} + engines: {bun: '>=1.2.0', node: '>=22.0.0'} + + '@prisma/studio-core@0.33.0': + resolution: {integrity: sha512-V2fX/nKEymNTrHXwfP26PGjoLStO35Ogu+ex7CFJbLrMYEcZxxZpiSNOs7px23Hk5mzLWvM5RsqG6Ka+rha+wg==} + engines: {node: ^20.19 || ^22.12 || >=24.0, pnpm: '8'} + peerDependencies: + '@types/react': ^18.0.0 || ^19.0.0 + react: ^18.0.0 || ^19.0.0 + react-dom: ^18.0.0 || ^19.0.0 + '@quansync/fs@1.1.0': resolution: {integrity: sha512-qAPG/t3HqML1TlN7sY/pTbEjzFVAKsMjNNMGheyDosro+kT4iw2KCUoHcVdmliwWjorm4elZbgNQyU2eD97eDg==} + '@radix-ui/primitive@1.1.3': + resolution: {integrity: sha512-JTF99U/6XIjCBo0wqkU5sK10glYe27MRRsfwoiq5zzOEZLHU3A3KCMa5X/azekYRCJ0HlwI0crAXS/5dEHTzDg==} + + '@radix-ui/react-compose-refs@1.1.2': + resolution: {integrity: sha512-z4eqJvfiNnFMHIIvXP3CY57y2WJs5g2v3X0zm9mEJkrkNv4rDxu+sg9Jh8EkXyeqBkB7SOcboo9dMVqhyrACIg==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + + '@radix-ui/react-primitive@2.1.3': + resolution: {integrity: sha512-m9gTwRkhy2lvCPe6QJp4d3G1TYEUHn/FzJUtq9MjH46an1wJU+GdoGC5VLof8RX8Ft/DlpshApkhswDLZzHIcQ==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + + '@radix-ui/react-slot@1.2.3': + resolution: {integrity: sha512-aeNmHnBxbi2St0au6VBVC7JXFlhLlOnvIIlePNniyUNAClzmtAUEY8/pBiK3iHjufOlwA+c20/8jngo7xcrg8A==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + + '@radix-ui/react-toggle@1.1.10': + resolution: {integrity: sha512-lS1odchhFTeZv3xwHH31YPObmJn8gOg7Lq12inrr0+BH/l3Tsq32VfjqH1oh80ARM3mlkfMic15n0kg4sD1poQ==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + + '@radix-ui/react-use-controllable-state@1.2.2': + resolution: {integrity: sha512-BjasUjixPFdS+NKkypcyyN5Pmg83Olst0+c6vGov0diwTEo6mgdqVR6hxcEgFuh4QrAs7Rc+9KuGJ9TVCj0Zzg==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + + '@radix-ui/react-use-effect-event@0.0.2': + resolution: {integrity: sha512-Qp8WbZOBe+blgpuUT+lw2xheLP8q0oatc9UpmiemEICxGvFLYmHm9QowVZGHtJlGbS6A6yJ3iViad/2cVjnOiA==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + + '@radix-ui/react-use-layout-effect@1.1.1': + resolution: {integrity: sha512-RbJRS4UWQFkzHTTwVymMTUv8EqYhOp8dOOviLj2ugtTiXRaRQS7GLGxZTLL1jWhMeoSCf5zmcZkqTl9IiYfXcQ==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + + '@redis/bloom@6.3.1': + resolution: {integrity: sha512-dpF9j2yJDoPzSCaZn0MSB3xzmnXQVJeTSAWJcQVcgbmluwhpFeemmII0cF1t+WYfoVS+shEFq79+MmUItgzJLg==} + engines: {node: '>= 20.0.0'} + peerDependencies: + '@redis/client': ^6.3.1 + + '@redis/client@6.3.1': + resolution: {integrity: sha512-masbfVKULdoAofwddepZxRhWa4w6zvBHn6TRn90TRPrRkVIlGCur3pFqwWaCbMxtYI9twepkz63e/T/tEH8GjA==} + engines: {node: '>= 20.0.0'} + peerDependencies: + '@node-rs/xxhash': ^1.1.0 + '@opentelemetry/api': '>=1 <2' + peerDependenciesMeta: + '@node-rs/xxhash': + optional: true + '@opentelemetry/api': + optional: true + + '@redis/json@6.3.1': + resolution: {integrity: sha512-fMz4kUwJzEftcU9EMaqsjZcUwzpTQLOYRqhQsAD6uKvZWeamblK13ZhgO5SzVSZVk31jmwLeTRpU5GAl5egfUw==} + engines: {node: '>= 20.0.0'} + peerDependencies: + '@redis/client': ^6.3.1 + + '@redis/search@6.3.1': + resolution: {integrity: sha512-T67pvPUpW82VrZLvihO8O2DFMC7eY2oMAzMzapCbiPZn7mdWqHMEIlohYim12gIawT5kn6qT/Cvmm4WulKB+kQ==} + engines: {node: '>= 20.0.0'} + peerDependencies: + '@redis/client': ^6.3.1 + + '@redis/time-series@6.3.1': + resolution: {integrity: sha512-MNDgrm+i63M/1a+XA+HcDsScwt4uBh/fGGJ84swTQZTFK5K5wMmxdlTRa4ZgmNJzjxMaszW/ipPScMUGV3aAMg==} + engines: {node: '>= 20.0.0'} + peerDependencies: + '@redis/client': ^6.3.1 + '@rolldown/binding-android-arm-eabi@1.2.16': resolution: {integrity: sha512-ia3DwAs0OsMGS7+IConptSiyk9pEXkOx/AbJ2n/lAGxH3QkWQus1t8d7gnAT38FCU2sQu8lUbeR6AiZFv4JxaA==} engines: {node: ^20.19.0 || >=22.12.0} @@ -2029,12 +2508,61 @@ packages: vue: optional: true + '@standard-schema/spec@1.1.0': + resolution: {integrity: sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==} + + '@tokenizer/inflate@0.6.0': + resolution: {integrity: sha512-+0RDxhBkyT9xMnGdJAwmats9yxRLR8ypJrQgrnLqOu4Gv/aHlnxYgdGVy2QTwvBl6IF/w2Hr+ZNirH+iMUbVZA==} + engines: {node: '>=18'} + + '@tokenizer/token@0.3.0': + resolution: {integrity: sha512-OvjF+z51L3ov0OyAU0duzsYuvO01PH7x4t6DJx+guahgTnBHkhJdG7soQeTSFLWN3efnHyibZ4Z8l2EuWwJN3A==} + + '@types/body-parser@1.19.6': + resolution: {integrity: sha512-HLFeCYgz89uk22N5Qg3dvGvsv46B8GLvKKo1zKG4NybA8U2DiEO3w9lqGg29t/tfLRJpJ6iQxnVw4OnB7MoM9g==} + '@types/chai@5.2.3': resolution: {integrity: sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==} + '@types/connect@3.4.38': + resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} + '@types/crypto-js@4.2.2': resolution: {integrity: sha512-sDOLlVbHhXpAUAL0YHDUUwDZf3iN4Bwi4W6a0W0b+QcAezUbRtH4FVb+9J4h+XFPW7l/gQ9F8qC7P+Ec4k8QVQ==} + '@types/d3-array@3.0.3': + resolution: {integrity: sha512-Reoy+pKnvsksN0lQUlcH6dOGjRZ/3WRwXR//m+/8lt1BXeI4xyaUZoqULNjyXXRuh0Mj4LNpkCvhUpQlY3X5xQ==} + + '@types/d3-color@3.1.0': + resolution: {integrity: sha512-HKuicPHJuvPgCD+np6Se9MQvS6OCbJmOjGvylzMJRlDwUXjKTTXs6Pwgk79O09Vj/ho3u1ofXnhFOaEWWPrlwA==} + + '@types/d3-delaunay@6.0.1': + resolution: {integrity: sha512-tLxQ2sfT0p6sxdG75c6f/ekqxjyYR0+LwPrsO1mbC9YDBzPJhs2HbJJRrn8Ez1DBoHRo2yx7YEATI+8V1nGMnQ==} + + '@types/d3-format@3.0.1': + resolution: {integrity: sha512-5KY70ifCCzorkLuIkDe0Z9YTf9RR2CjBX1iaJG+rgM/cPP+sO+q9YdQ9WdhQcgPj1EQiJ2/0+yUkkziTG6Lubg==} + + '@types/d3-geo@3.1.0': + resolution: {integrity: sha512-856sckF0oP/diXtS4jNsiQw/UuK5fQG8l/a9VVLeSouf1/PPbBE1i1W852zVwKwYCBkFJJB7nCFTbk6UMEXBOQ==} + + '@types/d3-interpolate@3.0.1': + resolution: {integrity: sha512-jx5leotSeac3jr0RePOH1KdR9rISG91QIE4Q2PYTu4OymLTZfA3SrnURSLzKH48HmXVUru50b8nje4E79oQSQw==} + + '@types/d3-path@3.1.1': + resolution: {integrity: sha512-VMZBYyQvbGmWyWVea0EHs/BwLgxc+MKi1zLDCONksozI4YJMcTt8ZEuIR4Sb1MMTE8MMW49v0IwI5+b7RmfWlg==} + + '@types/d3-scale@4.0.2': + resolution: {integrity: sha512-Yk4htunhPAwN0XGlIwArRomOjdoBFXC3+kCxK2Ubg7I9shQlVSJy/pG/Ht5ASN+gdMIalpk8TJ5xV74jFsetLA==} + + '@types/d3-shape@3.1.7': + resolution: {integrity: sha512-VLvUQ33C+3J+8p+Daf+nYSOsjB4GXp19/S/aGo60m9h1v6XaxjiT82lKVWJCfzhtuZ3yD7i/TPeC/fuKLLOSmg==} + + '@types/d3-time-format@2.1.0': + resolution: {integrity: sha512-/myT3I7EwlukNOX2xVdMzb8FRgNzRMpsZddwst9Ld/VFe6LyJyRp0s32l/V9XoUzk+Gqu56F/oGk6507+8BxrA==} + + '@types/d3-time@3.0.0': + resolution: {integrity: sha512-sZLCdHvBUcNby1cB6Fd3ZBrABbjz3v1Vm90nysCQ6Vt7vd6e/h9Lt7SiJUoEX0l4Dzc7P5llKyhqSi1ycSf1Hg==} + '@types/deep-eql@4.0.2': resolution: {integrity: sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==} @@ -2044,9 +2572,21 @@ packages: '@types/estree@1.0.10': resolution: {integrity: sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==} + '@types/express-serve-static-core@5.1.3': + resolution: {integrity: sha512-dPfW8NFiOF4wOHc7+N/QSxlY9cfSsenewGbAz8C8U/MULPd/YZ27LvJUIlzaXie7e6Ove9YunJGgC9tbHD2cKw==} + + '@types/express@5.0.6': + resolution: {integrity: sha512-sKYVuV7Sv9fbPIt/442koC7+IIwK5olP1KWeD88e/idgoJqDm3JV/YUiPwkoKK92ylff2MGxSz1CSjsXelx0YA==} + + '@types/geojson@7946.0.16': + resolution: {integrity: sha512-6C8nqWur3j98U6+lXDfTUWIfgvZU+EumvpHKcYjujKH7woYyLj2sUmff0tRhrqM7BohUw7Pz3ZB1jj2gW9Fvmg==} + '@types/hast@3.0.5': resolution: {integrity: sha512-rp/ezSWaD1m44dPKICGhiskI13nVr7qTloFwDa/IYkhhf5nzwP+zIQcIJh3WIFSBOy/H1PzB40jPjMDksN4F+g==} + '@types/http-errors@2.0.5': + resolution: {integrity: sha512-r8Tayk8HJnX0FztbZN7oVqGccWgw98T/0neJphO91KkmOzug1KkofZURD4UaD5uH8AqcFLfdPErnBod0u71/qg==} + '@types/js-cookie@3.0.6': resolution: {integrity: sha512-wkw9yd1kEXOPnvEeEV1Go1MmxtBJL0RR79aOTAApecWFVu7w0NNXNqhcWgvw2YgZDYadliXkl14pa3WXw5jlCQ==} @@ -2077,6 +2617,24 @@ packages: '@types/node@26.6.6': resolution: {integrity: sha512-MzQj+8Kx3XI40OmUAE6Qoh58ZMNstNNMwn2nfd3qWsfe7nDNSqJNzes4njhz6AHwrSHOffSLwXU6yb474Q4aog==} + '@types/pg@8.23.1': + resolution: {integrity: sha512-fKVHpikPdg4GKks3JuLEhvwSyvwzF23hnabPy6DD8ljVbC7+6J5dQzdv4arV6jqq57djnMgs1HKBxX4P8aBI3A==} + + '@types/qs@6.15.1': + resolution: {integrity: sha512-GZHUBZR9hckSUhrxmp1nG6NwdpM9fCunJwyThLW1X3AyHgd9IlHb6VANpQQqDr2o/qQp6McZ3y/IA2rVzKzSbw==} + + '@types/range-parser@1.2.7': + resolution: {integrity: sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==} + + '@types/react@19.3.0': + resolution: {integrity: sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==} + + '@types/send@1.2.1': + resolution: {integrity: sha512-arsCikDvlU99zl1g69TcAB3mzZPpxgw0UQnaHeC1Nwb015xp8bknZv5rIfri9xTOcMuaVgvabfIRA7PSZVuZIQ==} + + '@types/serve-static@2.2.0': + resolution: {integrity: sha512-8mam4H1NHLtu7nmtalF7eyBH14QyOASmcxHhSfEoRyr0nP/YdoesEtU+uSRvMe96TW/HPTtkoKqQLl53N7UXMQ==} + '@types/statuses@2.0.6': resolution: {integrity: sha512-xMAgYwceFhRA2zY+XbEA7mxYbA093wdiW8Vu6gZPGWy9cmOyU9XesH1tNcEWsKFd5Vzrqx5T3D38PWx1FIIXkA==} @@ -2239,6 +2797,41 @@ packages: peerDependencies: valibot: ^1.5.0 + '@visx/curve@4.0.1-alpha.0': + resolution: {integrity: sha512-jRu61Uz274pV1zyioXmboyrLutYbnKsgjj4njSGCnhdXj5GkZvZbg+ThDb6oOzoAnJOBRLz4rzPlWvNJOzuVMg==} + + '@visx/event@4.0.1-alpha.0': + resolution: {integrity: sha512-EQqCMSv/s8NbFjo+hz3FKsvvYfP+2QslsFJ/24/O5l/W+7UC6J6aAvO0ujVwrTwdYbuQ+vhxKi1xdPdKR/qj1g==} + + '@visx/grid@4.0.1-alpha.0': + resolution: {integrity: sha512-rycutGmTHO+znNdPumheWMglm7YfpffvRwUkVy5zy4WoORIuKTMkDxwnOzHG2xMxU3EE/YCd37xFV5AxA30yeg==} + peerDependencies: + react: ^16.14.0 || ^17.0.0-0 || ^18.0.0-0 || ^19.0.0-0 + + '@visx/group@4.0.1-alpha.0': + resolution: {integrity: sha512-V19l7iQ7jccBv8kao/EByuI6o4xtxzzLV9nqVI1hRvmdzTVsuLpqlwzYCZUXJaTVvUWf8s4D2SQFjGkj/Nw+0w==} + peerDependencies: + react: ^16.14.0 || ^17.0.0-0 || ^18.0.0-0 || ^19.0.0-0 + + '@visx/point@4.0.1-alpha.0': + resolution: {integrity: sha512-ijTfr/Nx09f03vIj9nyTr3z4Xth4Y75427UaogJh6dnIRLMEFHQOwNu791sbfiNj0a+ZXuaE32h0vKrFe4/8Qg==} + + '@visx/responsive@4.0.1-alpha.0': + resolution: {integrity: sha512-o+1zGywQZY0+yOx3Iw87wc4bbPJRr/HnIukTwfOz4UVyj9pB1OQNVHB7OORO1+LBHJceWpB31co/ZV9KHncKrA==} + peerDependencies: + react: ^16.14.0 || ^17.0.0-0 || ^18.0.0-0 || ^19.0.0-0 + + '@visx/scale@4.0.1-alpha.0': + resolution: {integrity: sha512-nzjeE87vFSAXGWFiiNfBpNLAf0Q8Qmf6syvKLjqNi4kGZkdhbUll3E/59YsgWXmjM8+llPLWzGsP+JPvo5eq1A==} + + '@visx/shape@4.0.1-alpha.0': + resolution: {integrity: sha512-62QeiVNmPlterQGwhkEDcbq7M0MqY0lBsK5QKXtM9ZoPZWkuGV3aykA3+Xu20B2FAvyJq4LqJzBc7Sxr+EAdbA==} + peerDependencies: + react: ^16.14.0 || ^17.0.0-0 || ^18.0.0-0 || ^19.0.0-0 + + '@visx/vendor@4.0.0-alpha.0': + resolution: {integrity: sha512-6I+MuqXBcv9jnlcVowHoHKSdk9gXTWkHLKyqBwRWg7LY6A3Ei8SHfubpqGV5rBUSppxMq2RszPJUS6w+H0YgmQ==} + '@vitejs/devtools-kit@0.7.6': resolution: {integrity: sha512-VtnTo296ypQyksFcPgrUyDDxh/SuAa/18uWEitbODcJIu5eilMFQyaSzsLKgp0HQPsxo/Kfzbfl5gowNGfjwqQ==} peerDependencies: @@ -2529,6 +3122,10 @@ packages: resolution: {integrity: sha512-/XrFJgzQQQHpti1raDJC6m4ws6aNktmjBlhk8Fdlk7LwCEuDoieEJJY9OFHjfiFJFFRM2tK+Ky/IsfbbmlMu1w==} engines: {node: ^22.22.2 || ^24.15.0 || >=26.0.0} + accepts@2.0.0: + resolution: {integrity: sha512-5cvg6CtKwfgdmVqY1WIiXKc3Q1bkRqGLi+2W/6ao+6Y7gu/RCwRuAhGEzh5B4KlszSuTLgZYuqFqo5bImjNKng==} + engines: {node: '>= 0.6'} + acorn-jsx@5.3.2: resolution: {integrity: sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==} peerDependencies: @@ -2576,6 +3173,9 @@ packages: resolution: {integrity: sha512-9k3v7xcHwgdO/DruxGIg4HtjvlAZlcnsX/mzqUb1t3NkYnl9kK2UJ+Gq0io+vQf7iT//BD/HB/NBkUR1LWxoeA==} engines: {node: '>=14'} + append-field@1.0.0: + resolution: {integrity: sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==} + argparse@2.0.1: resolution: {integrity: sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==} @@ -2612,6 +3212,10 @@ packages: peerDependencies: postcss: ^8.1.0 + aws-ssl-profiles@1.1.2: + resolution: {integrity: sha512-NZKeq9AfyQvEeNlN0zSYAaWrmBffJh3IELMZfRpJVWgrpEbtEpnjvzqBPf+mxoI287JohRDoa+/nsfqqiZmF6g==} + engines: {node: '>= 6.0.0'} + axios@1.21.0: resolution: {integrity: sha512-YCzXMB53Q9PZBsh7yN7wtapit4WepwcHS2fP8QhGsBxSz5YtgYobV7GGlWlAJi+RxfU77GQTQi2DSLUma42EYA==} @@ -2624,9 +3228,16 @@ packages: engines: {node: '>=6.0.0'} hasBin: true + better-result@2.10.0: + resolution: {integrity: sha512-oQhh0y1qo2/ZKdAAEvHZAqKKiHOFU5k/bW96fE2ScgQOVkJRiHwB+nOS1SgFsYqRlxMDWvefXi9Q3px7QvgNDw==} + birpc@2.9.0: resolution: {integrity: sha512-KrayHS5pBi69Xi9JmvoqrIgYGDkD6mcSe/i6YKi3w5kekCLzrX4+nawcXqrj2tIp50Kw/mT/s3p+GVK0A0sKxw==} + body-parser@2.4.0: + resolution: {integrity: sha512-Ifk1KcLrxaGt1occQagQNFNNOqRt1LFuehEnHHzB8Z6cRgIxRU1TBaiIsUiCdA+gy5PL7Y1IX31DNKkRmxtXjQ==} + engines: {node: '>=18'} + boolbase@1.0.0: resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} @@ -2647,6 +3258,22 @@ packages: resolution: {integrity: sha512-DdH81/zPLVS11EUgWq3tEu/xn+EzljlMYooDNdzWEnFha3R3NBMpMV1UqYIpjYHV/SgpFKMIX1Oh7o06SjM/oA==} engines: {node: '>=18'} + busboy@1.6.0: + resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} + engines: {node: '>=10.16.0'} + + bytes@3.1.2: + resolution: {integrity: sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==} + engines: {node: '>= 0.8'} + + c12@3.3.4: + resolution: {integrity: sha512-cM0ApFQSBXuourJejzwv/AuPRvAxordTyParRVcHjjtXirtkzM0uK2L9TTn9s0cXZbG7E55jCivRQzoxYmRAlA==} + peerDependencies: + magicast: '*' + peerDependenciesMeta: + magicast: + optional: true + cac@7.1.0: resolution: {integrity: sha512-LMDU/U2yA4IPIY8KT0NsNPWEYZvAMkbgyspxJ6btJaYV+WMDOHAZCmB0lsTObiHaRS1V/ztKAl7+TSkTqXyeoA==} engines: {node: '>=20.19.0'} @@ -2658,6 +3285,10 @@ packages: resolution: {integrity: sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==} engines: {node: '>= 0.4'} + call-bound@1.0.4: + resolution: {integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==} + engines: {node: '>= 0.4'} + callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -2728,6 +3359,9 @@ packages: confbox@0.1.8: resolution: {integrity: sha512-RMtmw0iFkeR4YV+fUOSucriAQNb9g8zFR52MWCtl+cCZOFRNL6zeB395vPzFhEjjn4fMxXudmELnl/KF/WrK6w==} + confbox@0.2.4: + resolution: {integrity: sha512-ysOGlgTFbN2/Y6Cg3Iye8YKulHw+R2fNXHrgSmXISQdMnomY6eNDprVdW9R5xBguEqI954+S6709UyiO7B+6OQ==} + confbox@0.3.2: resolution: {integrity: sha512-ZUAKhKlkCOrIGKc8cj7zek9s9z1mveHif/25nUshI2BzCRzF7KH7KHa+Lnh2ubq+e1tIlaFuP763mzW4qVoehg==} @@ -2738,6 +3372,14 @@ packages: resolution: {integrity: sha512-5IKcdX0nnYavi6G7TtOhwkYzyjfJlatbjMjuLSfE2kYT5pMDOilZ4OvMhi637CcDICTmz3wARPoyhqyX1Y+XvA==} engines: {node: ^14.18.0 || >=16.10.0} + content-disposition@2.0.1: + resolution: {integrity: sha512-e+H0ZXHSWYrENhQzw1LPuP4oF5MzVKmDU6d3hxlvaPEYLLg62MxtQNPRx4SYSuYJSBUgnQIG4HIN2tEtNv7Dog==} + engines: {node: '>=18'} + + content-type@2.1.0: + resolution: {integrity: sha512-mj7UPXE0jaqaOsukNZRUEfEi2AcL7C/vwmwcHV0O97eO1E1pxBZuyjlZrx5seTaNBg1U6+o35wpa35Qfcc+7ag==} + engines: {node: '>=18'} + conventional-changelog-angular@9.4.0: resolution: {integrity: sha512-HdxRxuS8bBXVIuo4V82gvSwAXT0vYQUizrjs/izmPg5JdDstr8v8I5hduGL3iQbG+o310dUDxC4+LetuS5hu9w==} engines: {node: '>=22'} @@ -2754,6 +3396,14 @@ packages: convert-source-map@2.0.0: resolution: {integrity: sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==} + cookie-signature@1.2.2: + resolution: {integrity: sha512-D76uU73ulSXrD1UXF4KE2TMxVVwhsnCgfAyTg9k8P6KGZjlXKrOLe4dJQKI3Bxi5wjesZoFXJWElNWBjPZMbhg==} + engines: {node: '>=6.6.0'} + + cookie@0.7.2: + resolution: {integrity: sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==} + engines: {node: '>= 0.6'} + cookie@1.1.1: resolution: {integrity: sha512-ei8Aos7ja0weRpFzJnEA9UHJ/7XQmqglbRwnf2ATjcB9Wq874VKH9kfjjirM6UhU2/E5fFYadylyhFldcqSidQ==} engines: {node: '>=18'} @@ -2762,6 +3412,10 @@ packages: resolution: {integrity: sha512-vePst2VLTSqPglW7Q98VwFpGiGpOHTyXIo81MO5VyLecA5zMbZw/P/V1vmwD1jksa2iJpn/YkDrJ3XhTfzUyhQ==} engines: {node: '>=18'} + cors@2.8.6: + resolution: {integrity: sha512-tJtZBBHA6vjIAaF6EnIaq6laBBP9aq/Y3ouVJjEfoHbRBcHBAHYcMh/w8LDrk2PvIMMq8gmopa5D4V8RmbrxGw==} + engines: {node: '>= 0.10'} + cosmiconfig@9.0.2: resolution: {integrity: sha512-gtTZxTDau1wL7Y7zifc2dd8jHSK/k6BTx/2Xp/BpdlAdnlYWFVt7qhJqgwi7637yRwRQ3qL4ZidbB4I8tA5VOg==} engines: {node: '>=14'} @@ -2828,6 +3482,58 @@ packages: resolution: {integrity: sha512-6/OplJYgJ0RUlli74d93HJ/OsKVBi8lB1+Z6eJYS1YZzBuIp4qKKHpJ7ad+GvTlWmLR/hLJOWTykN5Nm8NJ7+w==} engines: {node: '>=4'} + d3-array@3.2.1: + resolution: {integrity: sha512-gUY/qeHq/yNqqoCKNq4vtpFLdoCdvyNpWoC/KNjhGbhDuQpAM9sIQQKkXSNpXa9h5KySs/gzm7R88WkUutgwWQ==} + engines: {node: '>=12'} + + d3-array@3.2.4: + resolution: {integrity: sha512-tdQAmyA18i4J7wprpYq8ClcxZy3SC31QMeByyCFyRt7BVHdREQZ5lpzoe5mFEYZUWe+oq8HBvk9JjpibyEV4Jg==} + engines: {node: '>=12'} + + d3-color@3.1.0: + resolution: {integrity: sha512-zg/chbXyeBtMQ1LbD/WSoW2DpC3I0mpmPdW+ynRTj/x2DAWYrIY7qeZIHidozwV24m4iavr15lNwIwLxRmOxhA==} + engines: {node: '>=12'} + + d3-delaunay@6.0.2: + resolution: {integrity: sha512-IMLNldruDQScrcfT+MWnazhHbDJhcRJyOEBAJfwQnHle1RPh6WDuLvxNArUju2VSMSUuKlY5BGHRJ2cYyoFLQQ==} + engines: {node: '>=12'} + + d3-format@3.1.0: + resolution: {integrity: sha512-YyUI6AEuY/Wpt8KWLgZHsIU86atmikuoOmCfommt0LYHiQSPjvX2AcFc38PX0CBpr2RCyZhjex+NS/LPOv6YqA==} + engines: {node: '>=12'} + + d3-geo@3.1.0: + resolution: {integrity: sha512-JEo5HxXDdDYXCaWdwLRt79y7giK8SbhZJbFWXqbRTolCHFI5jRqteLzCsq51NKbUoX0PjBVSohxrx+NoOUujYA==} + engines: {node: '>=12'} + + d3-interpolate@3.0.1: + resolution: {integrity: sha512-3bYs1rOD33uo8aqJfKP3JWPAibgw8Zm2+L9vBKEHJ2Rg+viTR7o5Mmv5mZcieN+FRYaAOWX5SJATX6k1PWz72g==} + engines: {node: '>=12'} + + d3-path@3.1.0: + resolution: {integrity: sha512-p3KP5HCf/bvjBSSKuXid6Zqijx7wIfNW+J/maPs+iwR35at5JCbLUT0LzF1cnjbCHWhqzQTIN2Jpe8pRebIEFQ==} + engines: {node: '>=12'} + + d3-path@3.1.1: + resolution: {integrity: sha512-jsbgV8zIT38ReB9O7X7gcLndTQRONSqNNd+oGIaTBdUug4r5jFmp0N6RY9R5GWbdUDucn0qoTGyfjapT4tDhcg==} + engines: {node: '>=12'} + + d3-scale@4.0.2: + resolution: {integrity: sha512-GZW464g1SH7ag3Y7hXjf8RoUuAFIqklOAq3MRl4OaWabTFJY9PN/E1YklhXLh+OQ3fM9yS2nOkCoS+WLZ6kvxQ==} + engines: {node: '>=12'} + + d3-shape@3.2.0: + resolution: {integrity: sha512-SaLBuwGm3MOViRq2ABk3eLoxwZELpH6zhl3FbAoJ7Vm1gofKx6El1Ib5z23NUEhF9AsGl7y+dzLe5Cw2AArGTA==} + engines: {node: '>=12'} + + d3-time-format@4.1.0: + resolution: {integrity: sha512-dJxPBlzC7NugB2PDLwo9Q8JiTR3M3e4/XANkreKSUxF8vvXKqm1Yfq4Q5dl8budlunRVlUUaDUgFt7eA8D6NLg==} + engines: {node: '>=12'} + + d3-time@3.1.0: + resolution: {integrity: sha512-VqKjzBLejbSMT4IgbmVgDjpkYrNWUYJnbCGo874u7MMKIWsILRX+OpX/gTk8MqjpT1A/c6HY2dCA77ZN0lkQ2Q==} + engines: {node: '>=12'} + date-fns-tz@3.2.0: resolution: {integrity: sha512-sg8HqoTEulcbbbVXeg84u5UnlsQa8GS5QXMqjjYIhS4abEVVKIUwe0/l/UhrZdKaL/W5eWZNlbTeEIiOXTcsBQ==} peerDependencies: @@ -2851,6 +3557,10 @@ packages: deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} + deepmerge-ts@8.0.2: + resolution: {integrity: sha512-uqbvqLUMrc6p0MO+WBRtTxY55hmyh94WRwI5a++PZe54X+bfVh59FSN7uWCBCW1CCVjzjnrwzfI8zidE2obMMw==} + engines: {node: '>=16.9.0'} + default-browser-id@5.0.1: resolution: {integrity: sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==} engines: {node: '>=18'} @@ -2866,6 +3576,9 @@ packages: defu@6.1.7: resolution: {integrity: sha512-7z22QmUWiQ/2d0KkdYmANbRUVABpZ9SNYyH5vx6PZ+nE5bcC0l7uFvEfHlyld/HcGBFTL536ClDt3DEcSlEJAQ==} + delaunator@5.1.0: + resolution: {integrity: sha512-AGrQ4QSgssa1NGmWmLPqN5NY2KajF5MqxetNEO+o0n3ZwZZeTmt7bBnvzHWrmkZFxGgr4HdyFgelzgi06otLuQ==} + delayed-stream@1.0.0: resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} engines: {node: '>=0.4.0'} @@ -2873,6 +3586,10 @@ packages: delegate@3.2.0: resolution: {integrity: sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==} + depd@2.0.0: + resolution: {integrity: sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==} + engines: {node: '>= 0.8'} + dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -2912,6 +3629,10 @@ packages: domutils@3.2.2: resolution: {integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==} + dotenv@17.4.2: + resolution: {integrity: sha512-nI4U3TottKAcAD9LLud4Cb7b2QztQMUEfHbvhTH09bqXTxnSie8WnjPALV/WMCrJZ6UV/qHJ6L03OqO3LcdYZw==} + engines: {node: '>=12'} + dunder-proto@1.0.1: resolution: {integrity: sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==} engines: {node: '>= 0.4'} @@ -2924,6 +3645,12 @@ packages: engines: {node: '>=20'} hasBin: true + ee-first@1.1.1: + resolution: {integrity: sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==} + + effect@3.20.0: + resolution: {integrity: sha512-qMLfDJscrNG8p/aw+IkT9W7fgj50Z4wG5bLBy0Txsxz8iUHjDIkOgO3SV0WZfnQbNG2VJYb0b+rDLMrhM4+Krw==} + ejs@7.0.2: resolution: {integrity: sha512-LcDSEP6Oclb9sTiSyG0MpG0RuKvLDRxCOOt+2sIk+kdk1rMkFU8SRnT0qaNt5zvU0LOV1YXXOvIoZL/sKwabvw==} engines: {node: '>=0.12.18'} @@ -2932,6 +3659,9 @@ packages: electron-to-chromium@1.5.472: resolution: {integrity: sha512-s4+nfT29b0FKpVKoaIxl2pWsoNcn7A/nMPSrxayw4T3BsmPeV2lF9Y06BsAQeMGhCTQ4nYJ5XST7jkqe4ZEqFw==} + elkjs@0.11.1: + resolution: {integrity: sha512-zxxR9k+rx5ktMwT/FwyLdPCrq7xN6e4VGGHH8hA01vVYKjTFik7nHOxBnAYtrgYUB1RpAiLvA1/U2YraWxyKKg==} + emoji-regex-xs@1.0.0: resolution: {integrity: sha512-LRlerrMYoIDrT6jgpeZ2YYl/L8EulRTt5hQcYjy5AInh7HWXKimpqx68aknBFpGL2+/IcogTcaydJEgaTmOpDg==} @@ -2941,6 +3671,14 @@ packages: emoji-regex@8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} + empathic@2.0.0: + resolution: {integrity: sha512-i6UzDscO/XfAcNYD75CfICkmfLedpyPDdozrLMmQc5ORaQcdMoc21OnlEylMIqI7U8eniKrPMxxtj8k0vhmJhA==} + engines: {node: '>=14'} + + encodeurl@2.0.1: + resolution: {integrity: sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==} + engines: {node: '>= 0.8'} + entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} @@ -2953,6 +3691,10 @@ packages: resolution: {integrity: sha512-+h1lkLKhZMTYjog1VEpJNG7NZJWcuc2DDk/qsqSTRRCOXiLjeQ1d1/udrUGhqMxUgAlwKNZ0cf2uqan5GLuS2A==} engines: {node: '>=6'} + env-paths@3.0.0: + resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + error-ex@1.3.4: resolution: {integrity: sha512-sqQamAnR14VgCr1A618A3sGrygcpK+HEbenA/HiEAkkUwcZIIB/tgWqHFxWgOyDh4nB4JCRimh79dR5Ywc9MDQ==} @@ -2986,10 +3728,18 @@ packages: engines: {node: '>=18'} hasBin: true + esbuild@0.28.2: + resolution: {integrity: sha512-HKVLS8dvII+xoKW9kmqxbRKrnWEXfJJr/FZhhJmiqIB0e053QNYFqOBouTMO/k5sID4MvCiUCvv8b9M4h32wIA==} + engines: {node: '>=18'} + hasBin: true + escalade@3.2.0: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} + escape-html@1.0.3: + resolution: {integrity: sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==} + escape-string-regexp@4.0.0: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} @@ -3070,6 +3820,10 @@ packages: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} + etag@1.8.1: + resolution: {integrity: sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==} + engines: {node: '>= 0.6'} + evtd@0.2.4: resolution: {integrity: sha512-qaeGN5bx63s/AXgQo8gj6fBkxge+OoLddLniox5qtLAEY5HSnuSlISXVPxnSae1dWblvTh4/HoMIB+mbMsvZzw==} @@ -3077,9 +3831,20 @@ packages: resolution: {integrity: sha512-KfYbmpRm0VbLjEvVa9yGwCi9GI34xvi7A/HXYWQO65CSD2u3MczUJSuwXKFIxlGsgBQizV9q5J9NHj4VG0n+pA==} engines: {node: '>=12.0.0'} + express@5.3.0: + resolution: {integrity: sha512-qCqy1xSoaugxOD4IVHb1ZWdkvCF2W3aE2okKouWj8VwJ+ztskSiXoBnCSJqfKT+cVPJhuJqe9YLbY425+Zh00g==} + engines: {node: '>= 18'} + exsolve@1.2.0: resolution: {integrity: sha512-h1pQPR9XoeSMdntRNCjyTznaume4UpfXrULBnlkZ2CUM/G5eSa+pBByGldO5uR8dxbPC+OuJXsPPNf+JZ81ADg==} + fast-check@3.23.2: + resolution: {integrity: sha512-h5+1OzzfCC3Ef7VbtKdcv7zsstUQwUDlYpUTvjeUsJAssPgLn7QzbboPtL5ro04Mq0rPOsMzl7q5hIbRs2wD1A==} + engines: {node: '>=8.0.0'} + + fast-decode-uri-component@1.0.1: + resolution: {integrity: sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==} + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -3089,6 +3854,12 @@ packages: fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} + fast-querystring@1.1.2: + resolution: {integrity: sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==} + + fast-safe-stringify@2.1.1: + resolution: {integrity: sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==} + fast-uri@3.1.9: resolution: {integrity: sha512-hS/0Wt3Ya043oKXs0sIxrMpKQITXhMLIrVAKKXi4gozGC9v7YRWVnXIZzjNPTO02M9BdxLCWqK1yRXgNziVyJQ==} @@ -3107,6 +3878,18 @@ packages: file-entry-cache@11.1.5: resolution: {integrity: sha512-+PFTHITI08JIGhnNpGNI8T8inUpgZfk3GNEqfT9R2zZV2iFXg3CvqzSl/uEhs7TSGujYRELEANyDvS8Fj7+S7Q==} + file-type@22.3.0: + resolution: {integrity: sha512-PrPedgnnWl5bWz3JHgar0QSzRvzeyFh7dZ9JpYOgcPZu4KALS9zw4MMa6qXRYyjeBsAlpaWB2boLuG991+0HIQ==} + engines: {node: '>=22'} + + finalhandler@2.1.1: + resolution: {integrity: sha512-S8KoZgRZN+a5rNwqTxlZZePjT/4cnm0ROV70LedRHZ0p8u9fRID0hJUZQpkKLzro8LfmC8sx23bY6tVNxv8pQA==} + engines: {node: '>= 18.0.0'} + + find-my-way@9.7.0: + resolution: {integrity: sha512-f2JHn75x2JlwUwLenZypgczR7YWMb/uO9BvUXtus+JMgkbIkLADd38cI4EiV+OQqrGo1Zlq6V8wnqMJ8e62wUQ==} + engines: {node: '>=20'} + find-up@5.0.0: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} engines: {node: '>=10'} @@ -3129,13 +3912,25 @@ packages: debug: optional: true + foreground-child@3.3.1: + resolution: {integrity: sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==} + engines: {node: '>=14'} + form-data@4.0.6: resolution: {integrity: sha512-vKatAh4SlVfgbv+YtmhiRjhEMJsYpsG1Y2rMQtR+SVSbytsSD1YGzDIcrAJmdFec88u/+VoGmxnl+80gL1tRCQ==} engines: {node: '>= 6'} + forwarded@0.2.0: + resolution: {integrity: sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==} + engines: {node: '>= 0.6'} + fraction.js@5.3.4: resolution: {integrity: sha512-1X1NTtiJphryn/uLQz3whtY6jK3fTqoE3ohKs0tT+Ujr1W59oopxmoEh7Lu5p6vBaPbgoM0bzveAW4Qi5RyWDQ==} + fresh@2.0.0: + resolution: {integrity: sha512-Rx/WycZ60HOaqLKAi6cHRKKI7zxWbJ31MhntmtwMoaTeF7XFH9hhBp8vITaMidfljRQ6eYWCKkaTK+ykVJHP2A==} + engines: {node: '>= 0.8'} + fsevents@2.3.3: resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} @@ -3147,6 +3942,9 @@ packages: fzf@0.5.2: resolution: {integrity: sha512-Tt4kuxLXFKHy8KT40zwsUPUkg1CrsgY25FxA2U/j/0WgEDCk3ddc/zLTCCcbSHX9FcKtLuVaDGtGE/STWC+j3Q==} + generate-function@2.3.1: + resolution: {integrity: sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==} + gensync@1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} @@ -3163,10 +3961,17 @@ packages: resolution: {integrity: sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==} engines: {node: '>= 0.4'} + get-port-please@3.2.0: + resolution: {integrity: sha512-I9QVvBw5U/hw3RmWpYKRumUeaDgxTPd401x364rLmWBJcOQ753eov1eTgzDqRG9bqFIfDc7gfzcQEWrUri3o1A==} + get-proto@1.0.1: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} + giget@3.3.1: + resolution: {integrity: sha512-r+mvuDjrjMpsdw46Kmeydb8bdHm7wOKw8wNBtTndkjbPjgAp5oUJUxRE76wZFknxIPokfWvep2qSXK37aXE6zg==} + hasBin: true + glob-parent@6.0.2: resolution: {integrity: sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==} engines: {node: '>=10.13.0'} @@ -3190,6 +3995,15 @@ packages: resolution: {integrity: sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==} engines: {node: '>= 0.4'} + graceful-fs@4.2.11: + resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + + grammex@3.1.13: + resolution: {integrity: sha512-LnPnhOBLEJEVKS8WFDVaA397L9Kq55Q9oSITJiVLHVdhAclfUkWzQv74KhvZHKL2Q09Pb1XdsrOsZ4LfTFFTEg==} + + graphmatch@1.1.1: + resolution: {integrity: sha512-5ykVn/EXM1hF0XCaWh05VbYvEiOL2lY1kBxZtaYsyvjp7cmWOU1XsAdfQBwClraEofXDT197lFbXOEVMHpvQOg==} + graphql@16.14.2: resolution: {integrity: sha512-Chq1s4CY7jmh8gO2qvLIJyfCDIN+EHLFW/9iShnp1z8FjBQMoodWP1kDC36VAMXXIvAjj4ARa7ntfAV2BrjsbA==} engines: {node: ^12.22.0 || ^14.16.0 || ^16.0.0 || >=17.0.0} @@ -3258,6 +4072,10 @@ packages: html-void-elements@3.0.0: resolution: {integrity: sha512-bEqo66MRXsUGxWHV5IP0PUiAWwoEjba4VCzg0LjFJBpchPaTfyfCKTG6bc5F8ucKec3q5y6qOdGyYTSBEvhCrg==} + http-errors@2.0.1: + resolution: {integrity: sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==} + engines: {node: '>= 0.8'} + https-proxy-agent@5.0.1: resolution: {integrity: sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==} engines: {node: '>= 6'} @@ -3267,6 +4085,13 @@ packages: engines: {node: '>=18'} hasBin: true + iconv-lite@0.7.3: + resolution: {integrity: sha512-IKXpvIzjnC9XTAUbVBcMfGS0EPaIXtW6v+zr+RRp+hqULEpo0owZax6wyRwPOJbWbzjYspQwusTsfVr0ifh4uQ==} + engines: {node: '>=0.10.0'} + + ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + ignore@5.3.2: resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==} engines: {node: '>= 4'} @@ -3289,6 +4114,9 @@ packages: resolution: {integrity: sha512-JmXMZ6wuvDmLiHEml9ykzqO6lwFbof0GG4IkcGaENdCRDDmMVnny7s5HsIgHCbaq0w2MyPhDqkhTUgS2LU2PHA==} engines: {node: '>=0.8.19'} + inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + ini@1.3.8: resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} @@ -3299,6 +4127,14 @@ packages: interactjs@1.10.28: resolution: {integrity: sha512-QCa4ksTPd2p/FZ4I6hrH6fogjLqru1TxYywRiKYNuLZtrlAxTIYUa/MYsE7PnUgWZJU3SrGVDjiz065BeaXYng==} + internmap@2.0.3: + resolution: {integrity: sha512-5Hh7Y1wQbvY5ooGgPbDaL5iYLAPzMTUrjMulskHLH6wnv/A+1q5rgEaiuqEjB+oxGXIVZs1FF+R/KPN3ZSQYYg==} + engines: {node: '>=12'} + + ipaddr.js@1.9.1: + resolution: {integrity: sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==} + engines: {node: '>= 0.10'} + is-arrayish@0.2.1: resolution: {integrity: sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==} @@ -3335,6 +4171,12 @@ packages: resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==} engines: {node: '>=12'} + is-promise@4.0.0: + resolution: {integrity: sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==} + + is-property@1.0.2: + resolution: {integrity: sha512-Ks/IoX00TtClbGQr4TWXemAnktAQvYB7HzcCxDGqEZU6oCmb2INHuOoKxbtR+HFkmYWBKv/dOZtGRiAjDhj92g==} + is-wsl@3.1.1: resolution: {integrity: sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==} engines: {node: '>=16'} @@ -3342,6 +4184,10 @@ packages: isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} + iterare@1.2.1: + resolution: {integrity: sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==} + engines: {node: '>=6'} + jiti@2.7.0: resolution: {integrity: sha512-AC/7JofJvZGrrneWNaEnJeOLUx+JlGt7tNa0wZiRPT4MY1wmfKjt2+6O2p2uz2+skll8OZZmJMNqeke7kKbNgQ==} hasBin: true @@ -3485,6 +4331,10 @@ packages: engines: {node: '>=22.22.1'} hasBin: true + load-esm@1.0.3: + resolution: {integrity: sha512-v5xlu8eHD1+6r8EHTg6hfmO97LN8ugKtiXcy5e6oN72iD2r6u0RPfLl6fxM+7Wnh2ZRq15o0russMst44WauPA==} + engines: {node: '>=13.2.0'} + local-pkg@1.2.1: resolution: {integrity: sha512-++gUqRDEvcnN6Zhqrr+y/CkVEHhlrR96vZn3nZZPYzMcBUyBtTKzB9NadClFIsIVSsu+3i9tfk/erqy9kAmt7Q==} engines: {node: '>=14'} @@ -3499,6 +4349,9 @@ packages: lodash@4.18.1: resolution: {integrity: sha512-dMInicTPVE8d1e5otfwmmjlxkZoUpiVLwyeTdUsi/Caj/gfzzblBcCE5sRHV/AsjuCmxWrte2TNGSYuCeCq+0Q==} + long@5.3.2: + resolution: {integrity: sha512-mNAgZ1GmyNhD7AuqnTG3/VQ26o760+ZYBPKjPvugO8+nLbYfX6TVpJPseBvopbdY+qpZ/lKUnmEc1LeZYS3QAA==} + lru-cache@11.5.3: resolution: {integrity: sha512-U4N8FgzmWxc8k1VH8Kr6lQg18U7Fjvby6wXHVRX/ZZ7IwWbRMgrRbP0Wrb5q5NVinryp4SQampHKdvtecItxUg==} engines: {node: 20 || >=22} @@ -3506,6 +4359,10 @@ packages: lru-cache@5.1.1: resolution: {integrity: sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==} + lru.min@1.1.5: + resolution: {integrity: sha512-5J9ysMYUpYIg9RF2vJpy9SinEmSviFSe0GyPpCQ4L5QSkLAgeLXlTAOu2ZwWUU5m+0SBl6gUU1R1ZQB3aKypfA==} + engines: {bun: '>=1.0.0', deno: '>=1.30.0', node: '>=8.0.0'} + magic-string-ast@1.0.3: resolution: {integrity: sha512-CvkkH1i81zl7mmb94DsRiFeG9V2fR2JeuK8yDgS8oiZSFa++wWLEgZ5ufEOyLHbvSbD1gTRKv9NdX69Rnvr9JA==} engines: {node: '>=20.19.0'} @@ -3535,9 +4392,21 @@ packages: mdn-data@2.27.1: resolution: {integrity: sha512-9Yubnt3e8A0OKwxYSXyhLymGW4sCufcLG6VdiDdUGVkPhpqLxlvP5vl1983gQjJl3tqbrM731mjaZaP68AgosQ==} + media-typer@0.3.0: + resolution: {integrity: sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==} + engines: {node: '>= 0.6'} + + media-typer@1.1.1: + resolution: {integrity: sha512-yz3xRaG20c6/BOzvYoDaGtPmGscs7YivItZEEqe6GbwNfHuxu9YNmvnEkMzKldAGY4/80pRcQRZSEnhquk9XuQ==} + engines: {node: '>= 0.8'} + medium-editor@5.23.3: resolution: {integrity: sha512-he9/TdjX8f8MGdXGfCs8AllrYnqXJJvjNkDKmPg3aPW/uoIrlRqtkFthrwvmd+u4QyzEiadhCCM0EwTiRdUCJw==} + merge-descriptors@2.0.0: + resolution: {integrity: sha512-Snk314V5ayFLhp3fkUREub6WtjBfPdCPY1Ln8/8munuLuiYhsABgBVWsozAG+MWMbVEvcdcpbi9R7ww22l9Q3g==} + engines: {node: '>=18'} + micromark-util-character@2.1.1: resolution: {integrity: sha512-wv8tdUTJ3thSFFFJKtpYKOYiGP2+v96Hvk4Tu8KpCAsTMs6yi+nVmGh1syvSCsaxz45J6Jbw+9DD6g97+NV67Q==} @@ -3557,10 +4426,18 @@ packages: resolution: {integrity: sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==} engines: {node: '>= 0.6'} + mime-db@1.54.0: + resolution: {integrity: sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==} + engines: {node: '>= 0.6'} + mime-types@2.1.35: resolution: {integrity: sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==} engines: {node: '>= 0.6'} + mime-types@3.0.2: + resolution: {integrity: sha512-Lbgzdk0h4juoQ9fCKXW4by0UJqj+nOOrI9MJ1sSj4nI8aI2eo1qmvQEie4VD1glsS250n15LsWsYtCugiStS5A==} + engines: {node: '>=18'} + mini-svg-data-uri@1.4.4: resolution: {integrity: sha512-r9deDe9p5FJUPZAk3A59wGH7Ii9YrjjWw0jmw/liSbHl2CHiyXj6FcDXDu2K3TjVAXqiJdaw3xxwlZZr9E6nHg==} hasBin: true @@ -3623,16 +4500,30 @@ packages: muggle-string@0.4.1: resolution: {integrity: sha512-VNTrAak/KhO2i8dqqnqnAHOa3cYBwXEZe9h+D5h/1ZqFSTEFHdM65lR7RoIqq3tBBYavsOXV84NoHXZ0AkPyqQ==} + multer@2.5.0: + resolution: {integrity: sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==} + engines: {node: '>= 10.16.0'} + mute-stream@2.0.0: resolution: {integrity: sha512-WWdIxpyjEn+FhQJQQv9aQAYlHoNVdzIzUySNV1gHUPDSdZJ3yZn7pAAbQcV7B56Mvu881q9FZV+0Vx2xC44VWA==} engines: {node: ^18.17.0 || >=20.5.0} + mysql2@3.24.4: + resolution: {integrity: sha512-A2olluVlj0mvgyIRRISMEzXc51m+21mRtcMVjJyIpt2GG98+XrC9m9HzsqcMsX2LcnfccJvY5NB22g8fENBnOA==} + engines: {node: '>= 8.0'} + peerDependencies: + '@types/node': '>= 8' + naive-ui@2.45.3: resolution: {integrity: sha512-D83gJ+6zUdkQ5DuUbmlfyaM1t8pV5WMPa6KmL9mByqQuiL12qBdA0n/iEIth4dQw1x/duNGpOS2anpt5FKO1kw==} engines: {node: '>=20'} peerDependencies: vue: ^3.0.0 + named-placeholders@1.1.6: + resolution: {integrity: sha512-Tz09sEL2EEuv5fFowm419c1+a/jSMiBjI9gHxVLrVdbUkkNUUfjsVYs9pVZu5oCon/kmRh9TfLEObFtkVxmY0w==} + engines: {node: '>=8.0.0'} + nanoid@3.3.20: resolution: {integrity: sha512-uKdg2G3GNCKQn9byYOpxbGqrT2fGO5KRt5J/8b3pok8rT6qxGWF6hxMyJiEYtAf+FVyYuD9hRaDqX5uPFYJ4ZQ==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -3641,6 +4532,10 @@ packages: natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} + negotiator@1.1.0: + resolution: {integrity: sha512-NMPBRMJgiQHjbd8phG3Vebdx4kZ1H121rbl5IkMqeOsahptB9BKo/d7oJ3zTXqTgagn2bWlNSXkh0QUGM31RYg==} + engines: {node: '>=18'} + node-addon-api@7.1.1: resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} @@ -3666,6 +4561,10 @@ packages: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} + object-inspect@1.13.4: + resolution: {integrity: sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==} + engines: {node: '>= 0.4'} + obug@2.2.1: resolution: {integrity: sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==} engines: {node: '>=12.20.0'} @@ -3680,6 +4579,13 @@ packages: ohash@2.0.12: resolution: {integrity: sha512-65S/5gk9YSsaRjcyf7Nfa6h/d3E8/1gslpXfI4W7Dxn/oap8IKRuNT5VXkLQ1YFKIEg4apRY4Pj6aiwFzrDdmw==} + on-finished@2.4.2: + resolution: {integrity: sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==} + engines: {node: '>= 0.8'} + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + oniguruma-to-es@3.1.1: resolution: {integrity: sha512-bUH8SDvPkH3ho3dvwJwfonjlQ4R80vjyvrU8YpxuROddv55vAEJrTuCuCVUhhsHbtlD9tGGbaNApGQckXhS8iQ==} @@ -3731,6 +4637,10 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} + parseurl@1.3.3: + resolution: {integrity: sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==} + engines: {node: '>= 0.8'} + path-browserify@1.0.1: resolution: {integrity: sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g==} @@ -3749,6 +4659,9 @@ packages: path-to-regexp@6.3.0: resolution: {integrity: sha512-Yhpw4T9C6hPpgPeA28us07OJeqZ5EzQTkbfwuhsUg0c237RomFoETJgmp2sa3F/41gfLE6G5cqcYwznmeEeOlQ==} + path-to-regexp@8.4.2: + resolution: {integrity: sha512-qRcuIdP69NPm4qbACK+aDogI5CBDMi1jKe0ry5rSQJz8JVLsC7jV8XpiJjGRLLol3N+R5ihGYcrPLTno6pAdBA==} + pathe@2.0.3: resolution: {integrity: sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==} @@ -3758,6 +4671,40 @@ packages: perfect-debounce@2.1.0: resolution: {integrity: sha512-LjgdTytVFXeUgtHZr9WYViYSM/g8MkcTPYDlPa3cDqMirHjKiSZPYd6DoL7pK8AJQr+uWkQvCjHNdiMqsrJs+g==} + pg-cloudflare@1.4.1: + resolution: {integrity: sha512-6PQbsFWZcp9EmJEwy5cGQ2La+AMWpP46lgbb8X+U/XsHIUweYDNCpeuKck5RxL2MdVFi7krbbEi5nX4Zh7JhrQ==} + + pg-connection-string@2.14.1: + resolution: {integrity: sha512-qR3kGNPBLpCNtz0evbKA0Y/MRFXwSSdT+pTJvYp/bXTcReZbvX1kzF0IyTc1QnxqF7AZbOeBhNL8R5mYQZV/MA==} + + pg-int8@1.0.1: + resolution: {integrity: sha512-WCtabS6t3c8SkpDBUlb1kjOs7l66xsGdKpIPZsg4wR+B3+u9UAum2odSsF9tnvxg80h4ZxLWMy4pRjOsFIqQpw==} + engines: {node: '>=4.0.0'} + + pg-pool@3.14.0: + resolution: {integrity: sha512-gKtPkFdQPU3DksooVLi9LsjZxrsBUZIpa+7aVx+LV5pNh0KzP4Zleud2po+ConrxbuXGBJ6Hfer6hdgpIBpBaw==} + peerDependencies: + pg: '>=8.0' + + pg-protocol@1.16.1: + resolution: {integrity: sha512-p9VOFMiHB/ZbJATetbg+99PxssTVSQRnyuPSQ67mN1+1KBOjZaZ83ZQzltnxPhJwSsC3nwVjJ10DVJlerbFzLg==} + + pg-types@2.2.0: + resolution: {integrity: sha512-qTAAlrEsl8s4OiEQY69wDvcMIdQN6wdz5ojQiOy6YRMuynxenON0O5oCpJI6lshc6scgAY8qvJ2On/p+CXY0GA==} + engines: {node: '>=4'} + + pg@8.23.1: + resolution: {integrity: sha512-aL96AHANtWjPLDOLqnhx+ngp9+UK7ETEU8VJrDCGvsSSi/mGLcWYsS6Herg7lmaBJe4uwrfqsa7gTEFaSizDoQ==} + engines: {node: '>= 16.0.0'} + peerDependencies: + pg-native: '>=3.0.1' + peerDependenciesMeta: + pg-native: + optional: true + + pgpass@1.0.5: + resolution: {integrity: sha512-FdW9r/jQZhSeohs1Z3sI1yxFQNFvMcnmfuj4WBMUTxOrAyLMaTcE1aAMBiTlbMNaXvBCQuVi0R7hd8udDSP7ug==} + picocolors@1.1.1: resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} @@ -3809,6 +4756,30 @@ packages: resolution: {integrity: sha512-LJlKCCAUFKOuZxipUdYw1NzIITEsPcgyOG9LkvRJvuKj/bRzbuRY0ARXvL0pWGpsZvn8jku+LMep2eU0seHp8g==} engines: {node: ^10 || ^12 || >=14} + postgres-array@2.0.0: + resolution: {integrity: sha512-VpZrUqU5A69eQyW2c5CA1jtLecCsN2U/bD6VilrFDWq5+5UIEVO7nazS3TEcHf1zuPYO/sqGvUvW62g86RXZuA==} + engines: {node: '>=4'} + + postgres-array@3.0.4: + resolution: {integrity: sha512-nAUSGfSDGOaOAEGwqsRY27GPOea7CNipJPOA7lPbdEpx5Kg3qzdP0AaWC5MlhTWV9s4hFX39nomVZ+C4tnGOJQ==} + engines: {node: '>=12'} + + postgres-bytea@1.0.1: + resolution: {integrity: sha512-5+5HqXnsZPE65IJZSMkZtURARZelel2oXUEO8rH83VS/hxH5vv1uHquPg5wZs8yMAfdv971IU+kcPUczi7NVBQ==} + engines: {node: '>=0.10.0'} + + postgres-date@1.0.7: + resolution: {integrity: sha512-suDmjLVQg78nMK2UZ454hAG+OAW+HQPZ6n++TNDUX+L0+uUlLywnoxJKDou51Zm+zTCjrCl0Nq6J9C5hP9vK/Q==} + engines: {node: '>=0.10.0'} + + postgres-interval@1.2.0: + resolution: {integrity: sha512-9ZhXKM/rw350N1ovuWHbGxnGh/SNJ4cnxHiM0rxE4VN41wsg8P8zWn9hv/buK00RP4WvlOyr/RBDiptyxVbkZQ==} + engines: {node: '>=0.10.0'} + + postgres@3.4.7: + resolution: {integrity: sha512-Jtc2612XINuBjIl/QTWsV5UvE8UHuNblcO3vVADSrKsrc6RqGX6lOW1cEo3CM2v0XG4Nat8nI+YM7/f26VxXLw==} + engines: {node: '>=12'} + powershell-utils@0.2.1: resolution: {integrity: sha512-C+y9x90UElAddDZmV4qOx9W53B61PO7cIqWz2dQsWlwswuq4mr8NEwytdGKboYbQlGZ3awrkTeNvcZiZNHnQ8A==} engines: {node: '>=20'} @@ -3833,12 +4804,32 @@ packages: print-js@1.6.0: resolution: {integrity: sha512-BfnOIzSKbqGRtO4o0rnj/K3681BSd2QUrsIZy/+WdCIugjIswjmx3lDEZpXB2ruGf9d4b3YNINri81+J0FsBWg==} + prisma@7.10.1: + resolution: {integrity: sha512-GoVeErHGGtsSjsflQ1r2BA3RKTXtxNraQJz8OLkLhoLr7OgCscdx4qw4WMM4HnERYc+a1cq2VnMNbep+vOjNcQ==} + engines: {node: ^20.19 || ^22.12 || >=24.0} + hasBin: true + peerDependencies: + better-sqlite3: '>=9.0.0' + typescript: '>=5.4.0' + peerDependenciesMeta: + better-sqlite3: + optional: true + typescript: + optional: true + + proper-lockfile@4.1.2: + resolution: {integrity: sha512-TjNPblN4BwAWMXU8s9AEz4JmQxnD1NNL7bNOY/AKUzyamc379FWASUhc/K1pL2noVb+XmZKLL68cjzLsiOAMaA==} + property-information@7.2.0: resolution: {integrity: sha512-IAtzIB6sUiWaJYrX9smp3V46pBGbBeLFRGdh25kg1334VcBlD8HzhPeNIWQH9zhGmo2itIe25EHt9dQP7G5hmg==} proto-list@1.2.4: resolution: {integrity: sha512-vtK/94akxsTMhe0/cbfpR+syPuszcuwhqVjJq26CuNDgFGj682oRBXOP5MJpv2r7JtE8MsiepGIqvvOTBwn2vA==} + proxy-addr@2.0.8: + resolution: {integrity: sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==} + engines: {node: '>= 0.10'} + proxy-from-env@2.1.0: resolution: {integrity: sha512-cJ+oHTW1VAEa8cJslgmUZrc+sjRKgAKl3Zyse6+PV38hZe/V6Z14TbCuXcan9F9ghlz4QrFr2c92TNF82UkYHA==} engines: {node: '>=10'} @@ -3847,23 +4838,57 @@ packages: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} + pure-rand@6.1.0: + resolution: {integrity: sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==} + qified@0.10.1: resolution: {integrity: sha512-+Owyggi9IxT1ePKGafcI87ubSmxol6smwJ+RAHDQlx9+9cPwFWDiKFFCPuWhr9ignlGpZ9vDQLw67N4dcTVFEA==} engines: {node: '>=20'} + qs@6.17.1: + resolution: {integrity: sha512-jd3COkaKVgGUW+ZHyEHCG9bH7RoaaiWuMgzsIBjUMVjLAaWGWpoUAVwljVvBHxRu/2qEHnadLGZrkutYUBPQJA==} + engines: {node: '>=0.6'} + quansync@0.2.11: resolution: {integrity: sha512-AifT7QEbW9Nri4tAwR5M/uzpBuqfZf+zwaEM/QkzEjj7NBuFD2rBuy0K3dE+8wltbezDV7JMA0WfnCPYRSYbXA==} quansync@1.0.0: resolution: {integrity: sha512-5xZacEEufv3HSTPQuchrvV6soaiACMFnq1H8wkVioctoH3TRha9Sz66lOxRwPK/qZj7HPiSveih9yAyh98gvqA==} + range-parser@1.3.0: + resolution: {integrity: sha512-hek2mFQpPuI4E1BBKrSto+BU3e3x4xuarsbiwr3+lf7p44juvFMV0XFWQAP3xUyqXA4RrXLIoaSUGbSt056ZMw==} + engines: {node: '>= 0.6'} + rangy@1.3.2: resolution: {integrity: sha512-fS1C4MOyk8T+ZJZdLcgrukPWxkyDXa+Hd2Kj+Zg4wIK71yrWgmjzHubzPMY1G+WD9EgGxMp3fIL0zQ1ickmSWA==} + raw-body@3.0.2: + resolution: {integrity: sha512-K5zQjDllxWkf7Z5xJdV0/B0WTNqx6vxG70zJE4N0kBs4LovmEYWJzQGxC9bS9RAKu3bgM40lrd5zoLJ12MQ5BA==} + engines: {node: '>= 0.10'} + + rc9@3.1.0: + resolution: {integrity: sha512-ufjkNVzbRHKcCOmTahZkmVsyc3W+MSk3jY03m+a7tGHkIsdVMG9l10/3HvFbWkkKzY5VFp3pkRsIo/UYgmFL7Q==} + + react-dom@19.3.1: + resolution: {integrity: sha512-Y0bARz53lhEC1NMCASs0/j+faB/zqt3R8hpvg1e8+61ZVJ4UL0UdC4cBbXfZMcIuhrfgeILTLe+ZeBCavQPtKQ==} + peerDependencies: + react: ^19.3.1 + + react@19.3.1: + resolution: {integrity: sha512-QNhWdt7nrgVWWQG58QuGsAR3jv3Hbe4mb4vz7w2csnHavciZJgda1CPNaldF6eVxv90ud3jUXpKlHL69gO38yw==} + engines: {node: '>=0.10.0'} + readdirp@5.1.1: resolution: {integrity: sha512-Kko+Y5XQ6fM+Ce3dq3m9YGxnacYZYl9cA1wZjaF3Vbry2L3i1qVg8+CAgNPsXRArPMUMCaOR7oa9Nqntc43JKA==} engines: {node: '>= 20.19.0'} + redis@6.3.1: + resolution: {integrity: sha512-mV96ZKxQ4CGn3SyEGaY0Lb9YA443mdVey3c+mdr0NAUaBxiOZGoYCWX8PoM55kictSOmxlJRtZJxIsmZm3jL+w==} + engines: {node: '>= 20.0.0'} + + reflect-metadata@0.2.2: + resolution: {integrity: sha512-urBwgfrvVP/eAyXx4hluJivBKzuEbSQs9rKWCrCkbSxNv8mxPcUZKeuoF3Uy4mJl3Lwprp6yy5/39VWigZ4K6Q==} + regex-recursion@6.0.2: resolution: {integrity: sha512-0YCaSCq2VRIebiaUviZNs0cBz1kg5kVS2UKUfNIx8YVs1cN3AV7NTctO5FOKBA+UT2BPJIWZauYHPqJODG50cg==} @@ -3873,6 +4898,9 @@ packages: regex@6.1.0: resolution: {integrity: sha512-6VwtthbV4o/7+OaAF9I5L5V3llLEsoPyq9P1JVXkedTP33c7MfCG0/5NOPcSJn0TzXcG9YUrR0gQSWioew3LDg==} + remeda@2.33.4: + resolution: {integrity: sha512-ygHswjlc/opg2VrtiYvUOPLjxjtdKvjGz1/plDhkG66hjNjFr1xmfrs2ClNFo/E6TyUFiwYNh53bKV26oBoMGQ==} + require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -3889,12 +4917,23 @@ packages: resolution: {integrity: sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==} engines: {node: '>=8'} + ret@0.5.1: + resolution: {integrity: sha512-Z/nyvABwcRnRD2mMP7Kz6G1dFZZqX1mNErOnxF42OCQKE07b9k9hK9SQxHL3LFEZUdzQaLM4dId1E/E6Vm4WhA==} + engines: {node: '>=10'} + + retry@0.12.0: + resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} + engines: {node: '>= 4'} + rettime@0.7.0: resolution: {integrity: sha512-LPRKoHnLKd/r3dVxcwO7vhCW+orkOGj9ViueosEBK6ie89CijnfRlhaDhHq/3Hxu4CkWQtxwlBG0mzTQY6uQjw==} rfdc@1.4.1: resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} + robust-predicates@3.0.3: + resolution: {integrity: sha512-NS3levdsRIUOmiJ8FZWCP7LG3QpJyrs/TE0Zpf1yvZu8cAJJ6QMW92H1c7kWpdIHo8RvmLxN/o2JXTKHp74lUA==} + rolldown@1.2.16: resolution: {integrity: sha512-bWvlMpFKiTfDKfnK7FC2MPgPeWCf/Kpwsq49ApdW+FQaBZb6O6dZ4MAPbPUjp7hYQrw/RobqCzn64BRrQecGHw==} engines: {node: ^20.19.0 || >=22.12.0} @@ -3918,6 +4957,10 @@ packages: resolution: {integrity: sha512-ySeaQkSrua+ut9g+65I7FHqOFBaY8tV0FmccXItoq0q21se32Q3u4YiW7/RqXSosWgYJaaKwRHXy3BST9PeCNQ==} engines: {node: '>=20.19.0'} + router@2.2.0: + resolution: {integrity: sha512-nLTrUKm2UyiL7rlhapu/Zl45FwNgkZGaCpZbIHajDYgwlJCOzLSk+cIPAnsEqV955GjILJnKbdQC1nVPz+gAYQ==} + engines: {node: '>= 18'} + rs-module-lexer@2.9.0: resolution: {integrity: sha512-kJ/M0Y0kzDM9VqK7zakLkyeLiiCJNgiqMHfK6KZcS/pj4Boy6AHlt/QHnS/wTRgx1D7dtaogRk6gApfsMofHjQ==} engines: {node: '>=14'} @@ -3926,6 +4969,16 @@ packages: resolution: {integrity: sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==} engines: {node: '>=18'} + rxjs@7.8.2: + resolution: {integrity: sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA==} + + safe-regex2@5.1.2: + resolution: {integrity: sha512-tAtCGFPPP02VroDVzp4daGi6bC7jWG+41D47GKf18FeH/ubvKQHT9VmhAkvtjNOmJwqtApzWeUpEhkyEYULvmw==} + hasBin: true + + safer-buffer@2.1.2: + resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + sass@1.107.1: resolution: {integrity: sha512-aJ1/LvxOOb04YhmiBjzZn3jVwdHKol+OVhoMV6fFl02fF9T3i+5Mg9l/CnzqtM+NX5Jn5o3lAbs/ZJivTCLHfQ==} engines: {node: '>=20.19.0'} @@ -3935,6 +4988,9 @@ packages: resolution: {integrity: sha512-42tBVwLWnaQvW5zc4HbZrTuWccECCZfBi92FDuwtqxasH+JbPB3/FOKb1m222K42R4WxuxzzMsTswfzgtSu64Q==} engines: {node: '>=11.0.0'} + scheduler@0.28.0: + resolution: {integrity: sha512-juorfCmIkIw8tT+p5BXSm6PJjQF/ycEYmKyzURCIt/RaZIhL+PulbQ9Yu2z1HdOJDdqDTlxA1+xKBmHXJsczAw==} + screenfull@5.2.0: resolution: {integrity: sha512-9BakfsO2aUQN2K9Fdbj87RJIEZ82Q9IGim7FqM5OsebfoFC6ZHXgDq/KvniuLTPdeM8wY2o6Dj3WQ7KeQCj3cA==} engines: {node: '>=0.10.0'} @@ -3960,6 +5016,17 @@ packages: engines: {node: '>=10'} hasBin: true + send@1.2.1: + resolution: {integrity: sha512-1gnZf7DFcoIcajTjTwjwuDjzuz4PPcY2StKPlsGAQ1+YH20IRVrBaXSWmdjowTJ6u8Rc01PoYOGHXfP1mYcZNQ==} + engines: {node: '>= 18'} + + serve-static@2.2.1: + resolution: {integrity: sha512-xRXBn0pPqQTVQiC8wyQrKs2MOlX24zQ0POGaj0kultvoOCstBQM5yvOhAVSUwOMjQtTvsPWoNCHfPGwaaQJhTw==} + engines: {node: '>= 18'} + + setprototypeof@1.2.0: + resolution: {integrity: sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==} + shebang-command@2.0.0: resolution: {integrity: sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==} engines: {node: '>=8'} @@ -3971,6 +5038,25 @@ packages: shiki@2.5.0: resolution: {integrity: sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ==} + side-channel-list@1.0.1: + resolution: {integrity: sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==} + engines: {node: '>= 0.4'} + + side-channel-map@1.0.1: + resolution: {integrity: sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==} + engines: {node: '>= 0.4'} + + side-channel-weakmap@1.0.2: + resolution: {integrity: sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==} + engines: {node: '>= 0.4'} + + side-channel@1.1.1: + resolution: {integrity: sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==} + engines: {node: '>= 0.4'} + + signal-exit@3.0.7: + resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} + signal-exit@4.1.0: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} @@ -3990,6 +5076,14 @@ packages: resolution: {integrity: sha512-1POYv7uv2gXoyGFpBCmpDVSNV74IfsWlDW216UPjbWufNf+bSU6GdbDsxdcxtfwb4xlI3yxzOTKClUosxARYrQ==} engines: {node: '>=0.10.0'} + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + + sql-escaper@1.5.2: + resolution: {integrity: sha512-6CKD38c31SENivxOADeMNLdukOnUxUcflKtzVWzace7Riv1v7cAEym5Cx9Q7gYZ3ezIJI7ZpqecQq8cqNeSSFg==} + engines: {bun: '>=1.0.0', deno: '>=2.0.0', node: '>=12.0.0'} + srvx@1.0.8: resolution: {integrity: sha512-ngFS/J6St4PJfHRHGjr78xkPPtbyXtdMOLNE4x/XZunEK3OhV7aGUWMHf9WTUEy6wm1U0W4okkd82ZFFWRVQTw==} engines: {node: '>=20.16.0'} @@ -3999,9 +5093,16 @@ packages: resolution: {integrity: sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==} engines: {node: '>= 0.8'} + std-env@3.10.0: + resolution: {integrity: sha512-5GS12FdOZNliM5mAOxFRg7Ir0pWz8MdpYm6AY6VPkGpbA7ZzmbzNcBJQ0GPvvyWgcY7QAhCgf9Uy89I03faLkg==} + std-env@4.3.0: resolution: {integrity: sha512-OtU/EgQ1kIm5KwqQpBC6ZEMXrZRui11w8zgfTWp8cdO9B8OaPsbA8bTHO2P+HNo1VlUTGMVBwPhydu6poeXiag==} + streamsearch@1.1.0: + resolution: {integrity: sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==} + engines: {node: '>=10.0.0'} + strict-event-emitter@0.5.1: resolution: {integrity: sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==} @@ -4035,6 +5136,10 @@ packages: strip-literal@4.0.0: resolution: {integrity: sha512-PaqAvfUZKBwc/SLmNZtHmzK+v19Z4O4eS3cKPeGvbIv/U3pnyEq4Tuw3/4v/FwfM8VQaEawsyCcOQ0P+kpwWWw==} + strtok3@10.7.0: + resolution: {integrity: sha512-iAqrCpp7UXD2FZiHWhLXqdJ6CmNeVzRkkHAyyhhKMVtbVm2KtPX3D/bJNonvtcyLTHS4rwqP2pz9fsjK1K4z0Q==} + engines: {node: '>=18'} + superjson@2.2.6: resolution: {integrity: sha512-H+ue8Zo4vJmV2nRjpx86P35lzwDT3nItnIsocgumgr0hHMQ+ZGq5vrERg9kJBo5AWGmxZDhzDo+WVIJqkB0cGA==} engines: {node: '>=16'} @@ -4073,6 +5178,14 @@ packages: resolution: {integrity: sha512-48dH6aSpQnpbzDUc4vIQZ1VjB8tkK+e8c1yx05/SZK+rkssgjEOlxDd/yU8/a4vGYQ9vRgJr9dwMq9TJ0b3X2Q==} hasBin: true + toidentifier@1.0.1: + resolution: {integrity: sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==} + engines: {node: '>=0.6'} + + token-types@6.2.0: + resolution: {integrity: sha512-s9euYHM//T3loJtbNUYdbAzsMlvKBeRS+XCLFy+UGosMQH19Hwjap5k19i4PPAEJJBsVIpMpVTxl4fIqCuNfUg==} + engines: {node: '>=14.16'} + totalist@3.0.1: resolution: {integrity: sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==} engines: {node: '>=6'} @@ -4096,6 +5209,9 @@ packages: tslib@2.3.0: resolution: {integrity: sha512-N82ooyxVNm6h1riLCoyS9e3fuJ3AMG2zIZs2Gd1ATcSFjSA23Q0fzjjZeh0jbJvWVDZ0cJT8yaNNaaXHzueNjg==} + tslib@2.9.1: + resolution: {integrity: sha512-a4Ux9VKuIMHsOS7ENbEq6hK2ZGYIT27Rtl0E4eD9KqwxhKiQeMZE/9xb3IdYwWaSOyIBQLExhQgXDTYoiCxnWA==} + type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -4104,6 +5220,14 @@ packages: resolution: {integrity: sha512-TeTSQ6H5YHvpqVwBRcnLDCBnDOHWYu7IvGbHT6N8AOymcr9PJGjc1GTtiWZTYg0NCgYwvnYWEkVChQAr9bjfwA==} engines: {node: '>=16'} + type-is@1.6.18: + resolution: {integrity: sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==} + engines: {node: '>= 0.6'} + + type-is@2.1.0: + resolution: {integrity: sha512-faYHw0anBbc/kWF3zFTEnxSFOAGUX9GFbOBthvDdLsIlEoWOFOtS0zgCiQYwIskL9iGXZL3kAXD8OoZ4GmMATA==} + engines: {node: '>= 18'} + typescript-eslint@8.72.1: resolution: {integrity: sha512-3Li9FfPmQp45nxEtFD1ZCrYFI3cYK5kpyNtmm1H7lMagm8u9sy6PTjy3ytwQZs7KNukOyKFHAZ6z6GjYFeaeXw==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} @@ -4119,6 +5243,14 @@ packages: ufo@1.6.4: resolution: {integrity: sha512-JFNbkD1Svwe0KvGi8GOeLcP4kAWQ609twvCdcHxq1oSL8svv39ZuSvajcD8B+5D0eL4+s1Is2D/O6KN3qcTeRA==} + uid@2.0.2: + resolution: {integrity: sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==} + engines: {node: '>=8'} + + uint8array-extras@1.6.0: + resolution: {integrity: sha512-8iAasVS4wUx0gPLjH8Xtz2PeDzTSiy8QiLGu2DT3X5GU+egFEQhpnbtkehbAwjvDcxIERmCYcysiODFmE3Ud0Q==} + engines: {node: '>=18'} + unconfig-core@7.5.0: resolution: {integrity: sha512-Su3FauozOGP44ZmKdHy2oE6LPjk51M/TRRjHv2HNCWiDvfvCoxC2lno6jevMA91MYAdCdwP05QnWdWpSbncX/w==} @@ -4169,6 +5301,10 @@ packages: '@unocss/webpack': optional: true + unpipe@1.0.0: + resolution: {integrity: sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==} + engines: {node: '>= 0.8'} + unplugin-auto-import@21.1.0: resolution: {integrity: sha512-EzrSqWIBulEqCuP7idADXH+tVKYrbwKlR5+r/lOWik0o+Ksny1kitmtryHGNSv7puzzORlcIwT/x2JStiszlHA==} engines: {node: '>=20.19.0'} @@ -4254,6 +5390,14 @@ packages: resolution: {integrity: sha512-Sc5u1VVln93y1Xnz4R+CunOZc7R9LUcTmhj7Rc7Eg3HVcf7rVn2FOoa812fe0W8p3jD7xeoGSYbfqCGGH2B6xw==} hasBin: true + valibot@1.4.2: + resolution: {integrity: sha512-gjdCvJ6d3RyHAneqxMYMW9QMCwYMb3jpOO0IyHZV1bnRHFBHrX3VkIILt5XYR0WhwHiH7Mty8ovuPZ/O3gamrg==} + peerDependencies: + typescript: '>=5' + peerDependenciesMeta: + typescript: + optional: true + valibot@1.5.0: resolution: {integrity: sha512-nil6AkP2TChWL43Z5uJ6GTxX01CUA+g8LWUM+N/rB9NBbkUMaUsi9PUNzlUPgoKASgmx9f7eGOYpJ04/fSa6FQ==} peerDependencies: @@ -4265,6 +5409,10 @@ packages: vanilla-picker@2.12.3: resolution: {integrity: sha512-qVkT1E7yMbUsB2mmJNFmaXMWE2hF8ffqzMMwe9zdAikd8u2VfnsVY2HQcOUi2F38bgbxzlJBEdS1UUhOXdF9GQ==} + vary@1.1.2: + resolution: {integrity: sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==} + engines: {node: '>= 0.8'} + vdirs@0.1.8: resolution: {integrity: sha512-H9V1zGRLQZg9b+GdMk8MXDN2Lva0zx72MPahDKc30v+DtwKjfyOSXWRIX4t2mhDubM1H09gPhWeth/BJWPHGUw==} peerDependencies: @@ -4571,6 +5719,9 @@ packages: resolution: {integrity: sha512-42AtmgqjV+X1VpdOfyTGOYRi0/zsoLqtXQckTmqTeybT+BDIbM/Guxo7x3pE2vtpr1ok6xRqM9OpBe+Jyoqyww==} engines: {node: '>=18'} + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + ws@8.22.1: resolution: {integrity: sha512-oyL6OPYme/CmiFvNuGzeoxCJ4nOrZE2O1FwM9MWM1AsGri6nLXB2pg+lNA8aLeXMSav0J6eIVS1j6vUPzUtK9g==} engines: {node: '>=10.0.0'} @@ -4591,6 +5742,10 @@ packages: resolution: {integrity: sha512-EvGK8EJ3DhaHfbRlETOWAS5pO9MZITeauHKJyb8wyajUfQUenkIg2MvLDTZ4T/TgIcm3HU0TFBgWWboAZ30UHg==} engines: {node: '>=18'} + xtend@4.0.2: + resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} + engines: {node: '>=0.4'} + y18n@5.0.8: resolution: {integrity: sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==} engines: {node: '>=10'} @@ -4631,6 +5786,9 @@ packages: resolution: {integrity: sha512-U/PBtDf35ff0D8X8D0jfdzHYEPFxAI7jJlxZXwCSez5M3190m+QobIfh+sWDWSHMCWWJN2AWamkegn6vr6YBTw==} engines: {node: '>=18'} + zeptomatch@2.1.0: + resolution: {integrity: sha512-KiGErG2J0G82LSpniV0CtIzjlJ10E04j02VOudJsPyPwNZgGnRKQy7I1R7GMyg/QswnE4l7ohSGrQbQbjXPPDA==} + zigpty@0.2.1: resolution: {integrity: sha512-MR9JqJx2wf5f4wz8zpx050AlqrmWeIW+1h0SO5iEyhG3HFRjY5luC3szS2ux2EGuPjE5OU9ZAuiCBeMWBTrqZw==} @@ -4944,6 +6102,8 @@ snapshots: '@babel/helper-string-parser': 8.0.8 '@babel/helper-validator-identifier': 8.0.6 + '@borewit/text-codec@0.2.3': {} + '@cacheable/memory@2.2.0': dependencies: '@cacheable/utils': 2.5.0 @@ -5126,86 +6286,174 @@ snapshots: transitivePeerDependencies: - '@algolia/client-search' + '@electric-sql/pglite-socket@0.1.3(@electric-sql/pglite@0.4.3)': + dependencies: + '@electric-sql/pglite': 0.4.3 + + '@electric-sql/pglite-tools@0.3.3(@electric-sql/pglite@0.4.3)': + dependencies: + '@electric-sql/pglite': 0.4.3 + + '@electric-sql/pglite@0.4.3': {} + '@emotion/hash@0.8.0': {} '@esbuild/aix-ppc64@0.25.12': optional: true + '@esbuild/aix-ppc64@0.28.2': + optional: true + '@esbuild/android-arm64@0.25.12': optional: true + '@esbuild/android-arm64@0.28.2': + optional: true + '@esbuild/android-arm@0.25.12': optional: true + '@esbuild/android-arm@0.28.2': + optional: true + '@esbuild/android-x64@0.25.12': optional: true + '@esbuild/android-x64@0.28.2': + optional: true + '@esbuild/darwin-arm64@0.25.12': optional: true + '@esbuild/darwin-arm64@0.28.2': + optional: true + '@esbuild/darwin-x64@0.25.12': optional: true + '@esbuild/darwin-x64@0.28.2': + optional: true + '@esbuild/freebsd-arm64@0.25.12': optional: true + '@esbuild/freebsd-arm64@0.28.2': + optional: true + '@esbuild/freebsd-x64@0.25.12': optional: true + '@esbuild/freebsd-x64@0.28.2': + optional: true + '@esbuild/linux-arm64@0.25.12': optional: true + '@esbuild/linux-arm64@0.28.2': + optional: true + '@esbuild/linux-arm@0.25.12': optional: true + '@esbuild/linux-arm@0.28.2': + optional: true + '@esbuild/linux-ia32@0.25.12': optional: true + '@esbuild/linux-ia32@0.28.2': + optional: true + '@esbuild/linux-loong64@0.25.12': optional: true + '@esbuild/linux-loong64@0.28.2': + optional: true + '@esbuild/linux-mips64el@0.25.12': optional: true + '@esbuild/linux-mips64el@0.28.2': + optional: true + '@esbuild/linux-ppc64@0.25.12': optional: true + '@esbuild/linux-ppc64@0.28.2': + optional: true + '@esbuild/linux-riscv64@0.25.12': optional: true + '@esbuild/linux-riscv64@0.28.2': + optional: true + '@esbuild/linux-s390x@0.25.12': optional: true + '@esbuild/linux-s390x@0.28.2': + optional: true + '@esbuild/linux-x64@0.25.12': optional: true + '@esbuild/linux-x64@0.28.2': + optional: true + '@esbuild/netbsd-arm64@0.25.12': optional: true + '@esbuild/netbsd-arm64@0.28.2': + optional: true + '@esbuild/netbsd-x64@0.25.12': optional: true + '@esbuild/netbsd-x64@0.28.2': + optional: true + '@esbuild/openbsd-arm64@0.25.12': optional: true + '@esbuild/openbsd-arm64@0.28.2': + optional: true + '@esbuild/openbsd-x64@0.25.12': optional: true + '@esbuild/openbsd-x64@0.28.2': + optional: true + '@esbuild/openharmony-arm64@0.25.12': optional: true + '@esbuild/openharmony-arm64@0.28.2': + optional: true + '@esbuild/sunos-x64@0.25.12': optional: true + '@esbuild/sunos-x64@0.28.2': + optional: true + '@esbuild/win32-arm64@0.25.12': optional: true + '@esbuild/win32-arm64@0.28.2': + optional: true + '@esbuild/win32-ia32@0.25.12': optional: true + '@esbuild/win32-ia32@0.28.2': + optional: true + '@esbuild/win32-x64@0.25.12': optional: true + '@esbuild/win32-x64@0.28.2': + optional: true + '@eslint-community/eslint-utils@4.10.1(eslint@10.14.0(jiti@2.7.0))': dependencies: eslint: 10.14.0(jiti@2.7.0) @@ -5343,7 +6591,7 @@ snapshots: '@intlify/shared@11.4.17': {} - '@intlify/unplugin-vue-i18n@11.2.8(rollup@4.67.4)(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue-i18n@11.4.17(vue@3.5.44(typescript@6.0.3)))(vue@3.5.44(typescript@6.0.3))': + '@intlify/unplugin-vue-i18n@11.2.8(rollup@4.67.4)(typescript@6.0.3)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue-i18n@11.4.17(vue@3.5.44(typescript@6.0.3)))(vue@3.5.44(typescript@6.0.3))': dependencies: '@intlify/bundle-utils': 11.2.8(vue-i18n@11.4.17(vue@3.5.44(typescript@6.0.3))) '@intlify/shared': 11.4.17 @@ -5358,7 +6606,7 @@ snapshots: unplugin: 2.3.11 vue: 3.5.44(typescript@6.0.3) optionalDependencies: - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) vue-i18n: 11.4.17(vue@3.5.44(typescript@6.0.3)) transitivePeerDependencies: - rollup @@ -5436,6 +6684,8 @@ snapshots: transitivePeerDependencies: - preact-render-to-string + '@lukeed/csprng@1.1.0': {} + '@mswjs/interceptors@0.40.0': dependencies: '@open-draft/deferred-promise': 2.2.0 @@ -5448,6 +6698,44 @@ snapshots: '@napi-rs/lzma-linux-x64-gnu@1.5.1': optional: true + '@nestjs/common@12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2)': + dependencies: + '@standard-schema/spec': 1.1.0 + file-type: 22.3.0 + iterare: 1.2.1 + load-esm: 1.0.3 + reflect-metadata: 0.2.2 + rxjs: 7.8.2 + tslib: 2.9.1 + uid: 2.0.2 + transitivePeerDependencies: + - supports-color + + '@nestjs/core@12.3.3(@nestjs/common@12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/platform-express@12.3.3)(reflect-metadata@0.2.2)(rxjs@7.8.2)': + dependencies: + '@nestjs/common': 12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2) + fast-safe-stringify: 2.1.1 + iterare: 1.2.1 + path-to-regexp: 8.4.2 + reflect-metadata: 0.2.2 + rxjs: 7.8.2 + tslib: 2.9.1 + uid: 2.0.2 + optionalDependencies: + '@nestjs/platform-express': 12.3.3(@nestjs/common@12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@12.3.3) + + '@nestjs/platform-express@12.3.3(@nestjs/common@12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@12.3.3)': + dependencies: + '@nestjs/common': 12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2) + '@nestjs/core': 12.3.3(@nestjs/common@12.3.3(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/platform-express@12.3.3)(reflect-metadata@0.2.2)(rxjs@7.8.2) + cors: 2.8.6 + express: 5.3.0 + multer: 2.5.0 + path-to-regexp: 8.4.2 + tslib: 2.9.1 + transitivePeerDependencies: + - supports-color + '@one-ini/wasm@0.2.1': {} '@open-draft/deferred-promise@2.2.0': {} @@ -5579,10 +6867,188 @@ snapshots: '@polka/url@1.0.0-next.29': {} + '@prisma/adapter-pg@7.10.1': + dependencies: + '@prisma/driver-adapter-utils': 7.10.1 + '@types/pg': 8.23.1 + pg: 8.23.1 + postgres-array: 3.0.4 + transitivePeerDependencies: + - pg-native + + '@prisma/client-runtime-utils@7.10.1': {} + + '@prisma/client@7.10.1(prisma@7.10.1(@types/node@26.6.6)(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(typescript@6.0.3))(typescript@6.0.3)': + dependencies: + '@prisma/client-runtime-utils': 7.10.1 + optionalDependencies: + prisma: 7.10.1(@types/node@26.6.6)(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(typescript@6.0.3) + typescript: 6.0.3 + + '@prisma/config@7.10.1': + dependencies: + c12: 3.3.4 + deepmerge-ts: 8.0.2 + effect: 3.20.0 + empathic: 2.0.0 + transitivePeerDependencies: + - magicast + + '@prisma/debug@7.10.1': {} + + '@prisma/debug@7.2.0': {} + + '@prisma/dev@0.24.17(typescript@6.0.3)': + dependencies: + '@electric-sql/pglite': 0.4.3 + '@electric-sql/pglite-socket': 0.1.3(@electric-sql/pglite@0.4.3) + '@electric-sql/pglite-tools': 0.3.3(@electric-sql/pglite@0.4.3) + '@prisma/get-platform': 7.2.0 + '@prisma/query-plan-executor': 7.2.0 + '@prisma/streams-local': 0.1.11 + find-my-way: 9.7.0 + foreground-child: 3.3.1 + get-port-please: 3.2.0 + pathe: 2.0.3 + proper-lockfile: 4.1.2 + remeda: 2.33.4 + std-env: 3.10.0 + valibot: 1.4.2(typescript@6.0.3) + zeptomatch: 2.1.0 + transitivePeerDependencies: + - typescript + + '@prisma/driver-adapter-utils@7.10.1': + dependencies: + '@prisma/debug': 7.10.1 + + '@prisma/engines-version@8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8': {} + + '@prisma/engines@7.10.1': + dependencies: + '@prisma/debug': 7.10.1 + '@prisma/engines-version': 8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8 + '@prisma/fetch-engine': 7.10.1 + '@prisma/get-platform': 7.10.1 + + '@prisma/fetch-engine@7.10.1': + dependencies: + '@prisma/debug': 7.10.1 + '@prisma/engines-version': 8.1.0-1.d1b3f377ca835d73fd50954a5e22128b9ebdd6b8 + '@prisma/get-platform': 7.10.1 + + '@prisma/get-platform@7.10.1': + dependencies: + '@prisma/debug': 7.10.1 + + '@prisma/get-platform@7.2.0': + dependencies: + '@prisma/debug': 7.2.0 + + '@prisma/query-plan-executor@7.2.0': {} + + '@prisma/streams-local@0.1.11': + dependencies: + ajv: 8.20.0 + better-result: 2.10.0 + env-paths: 3.0.0 + proper-lockfile: 4.1.2 + + '@prisma/studio-core@0.33.0(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)': + dependencies: + '@radix-ui/react-toggle': 1.1.10(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + '@types/react': 19.3.0 + '@visx/curve': 4.0.1-alpha.0 + '@visx/event': 4.0.1-alpha.0 + '@visx/grid': 4.0.1-alpha.0(react@19.3.1) + '@visx/group': 4.0.1-alpha.0(react@19.3.1) + '@visx/responsive': 4.0.1-alpha.0(react@19.3.1) + '@visx/scale': 4.0.1-alpha.0 + '@visx/shape': 4.0.1-alpha.0(react@19.3.1) + d3-array: 3.2.4 + d3-shape: 3.2.0 + elkjs: 0.11.1 + react: 19.3.1 + react-dom: 19.3.1(react@19.3.1) + transitivePeerDependencies: + - '@types/react-dom' + '@quansync/fs@1.1.0': dependencies: quansync: 1.0.0 + '@radix-ui/primitive@1.1.3': {} + + '@radix-ui/react-compose-refs@1.1.2(@types/react@19.3.0)(react@19.3.1)': + dependencies: + react: 19.3.1 + optionalDependencies: + '@types/react': 19.3.0 + + '@radix-ui/react-primitive@2.1.3(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)': + dependencies: + '@radix-ui/react-slot': 1.2.3(@types/react@19.3.0)(react@19.3.1) + react: 19.3.1 + react-dom: 19.3.1(react@19.3.1) + optionalDependencies: + '@types/react': 19.3.0 + + '@radix-ui/react-slot@1.2.3(@types/react@19.3.0)(react@19.3.1)': + dependencies: + '@radix-ui/react-compose-refs': 1.1.2(@types/react@19.3.0)(react@19.3.1) + react: 19.3.1 + optionalDependencies: + '@types/react': 19.3.0 + + '@radix-ui/react-toggle@1.1.10(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)': + dependencies: + '@radix-ui/primitive': 1.1.3 + '@radix-ui/react-primitive': 2.1.3(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + '@radix-ui/react-use-controllable-state': 1.2.2(@types/react@19.3.0)(react@19.3.1) + react: 19.3.1 + react-dom: 19.3.1(react@19.3.1) + optionalDependencies: + '@types/react': 19.3.0 + + '@radix-ui/react-use-controllable-state@1.2.2(@types/react@19.3.0)(react@19.3.1)': + dependencies: + '@radix-ui/react-use-effect-event': 0.0.2(@types/react@19.3.0)(react@19.3.1) + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.3.0)(react@19.3.1) + react: 19.3.1 + optionalDependencies: + '@types/react': 19.3.0 + + '@radix-ui/react-use-effect-event@0.0.2(@types/react@19.3.0)(react@19.3.1)': + dependencies: + '@radix-ui/react-use-layout-effect': 1.1.1(@types/react@19.3.0)(react@19.3.1) + react: 19.3.1 + optionalDependencies: + '@types/react': 19.3.0 + + '@radix-ui/react-use-layout-effect@1.1.1(@types/react@19.3.0)(react@19.3.1)': + dependencies: + react: 19.3.1 + optionalDependencies: + '@types/react': 19.3.0 + + '@redis/bloom@6.3.1(@redis/client@6.3.1)': + dependencies: + '@redis/client': 6.3.1 + + '@redis/client@6.3.1': {} + + '@redis/json@6.3.1(@redis/client@6.3.1)': + dependencies: + '@redis/client': 6.3.1 + + '@redis/search@6.3.1(@redis/client@6.3.1)': + dependencies: + '@redis/client': 6.3.1 + + '@redis/time-series@6.3.1(@redis/client@6.3.1)': + dependencies: + '@redis/client': 6.3.1 + '@rolldown/binding-android-arm-eabi@1.2.16': optional: true @@ -5764,33 +7230,101 @@ snapshots: '@sphinxxxx/color-conversion@2.2.2': {} - '@spiriit/vite-plugin-svg-spritemap@7.2.0(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': + '@spiriit/vite-plugin-svg-spritemap@7.2.0(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': dependencies: '@xmldom/xmldom': 0.9.12 mini-svg-data-uri: 1.4.4 picomatch: 4.0.7 tinyglobby: 0.2.17 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) optionalDependencies: vue: 3.5.44(typescript@6.0.3) + '@standard-schema/spec@1.1.0': {} + + '@tokenizer/inflate@0.6.0': + dependencies: + debug: 4.4.3 + strtok3: 10.7.0 + token-types: 6.2.0 + transitivePeerDependencies: + - supports-color + + '@tokenizer/token@0.3.0': {} + + '@types/body-parser@1.19.6': + dependencies: + '@types/connect': 3.4.38 + '@types/node': 26.6.6 + '@types/chai@5.2.3': dependencies: '@types/deep-eql': 4.0.2 assertion-error: 2.0.1 + '@types/connect@3.4.38': + dependencies: + '@types/node': 26.6.6 + '@types/crypto-js@4.2.2': {} + '@types/d3-array@3.0.3': {} + + '@types/d3-color@3.1.0': {} + + '@types/d3-delaunay@6.0.1': {} + + '@types/d3-format@3.0.1': {} + + '@types/d3-geo@3.1.0': + dependencies: + '@types/geojson': 7946.0.16 + + '@types/d3-interpolate@3.0.1': + dependencies: + '@types/d3-color': 3.1.0 + + '@types/d3-path@3.1.1': {} + + '@types/d3-scale@4.0.2': + dependencies: + '@types/d3-time': 3.0.0 + + '@types/d3-shape@3.1.7': + dependencies: + '@types/d3-path': 3.1.1 + + '@types/d3-time-format@2.1.0': {} + + '@types/d3-time@3.0.0': {} + '@types/deep-eql@4.0.2': {} '@types/esrecurse@4.3.1': {} '@types/estree@1.0.10': {} + '@types/express-serve-static-core@5.1.3': + dependencies: + '@types/node': 26.6.6 + '@types/qs': 6.15.1 + '@types/range-parser': 1.2.7 + '@types/send': 1.2.1 + + '@types/express@5.0.6': + dependencies: + '@types/body-parser': 1.19.6 + '@types/express-serve-static-core': 5.1.3 + '@types/serve-static': 2.2.0 + + '@types/geojson@7946.0.16': {} + '@types/hast@3.0.5': dependencies: '@types/unist': 3.0.3 + '@types/http-errors@2.0.5': {} + '@types/js-cookie@3.0.6': {} '@types/jsbarcode@3.11.4': @@ -5822,6 +7356,29 @@ snapshots: dependencies: undici-types: 8.9.0 + '@types/pg@8.23.1': + dependencies: + '@types/node': 26.6.6 + pg-protocol: 1.16.1 + pg-types: 2.2.0 + + '@types/qs@6.15.1': {} + + '@types/range-parser@1.2.7': {} + + '@types/react@19.3.0': + dependencies: + csstype: 3.2.3 + + '@types/send@1.2.1': + dependencies: + '@types/node': 26.6.6 + + '@types/serve-static@2.2.0': + dependencies: + '@types/http-errors': 2.0.5 + '@types/node': 26.6.6 + '@types/statuses@2.0.6': {} '@types/unist@3.0.3': {} @@ -6072,7 +7629,7 @@ snapshots: dependencies: '@unocss/core': 66.12.0 - '@unocss/vite@66.12.0(cac@7.1.0)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))': + '@unocss/vite@66.12.0(cac@7.1.0)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))': dependencies: '@jridgewell/remapping': 2.3.5 '@unocss/config': 66.12.0 @@ -6083,7 +7640,7 @@ snapshots: pathe: 2.0.3 tinyglobby: 0.2.17 unplugin-utils: 0.3.2 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) transitivePeerDependencies: - '@devframes/agentic' - cac @@ -6094,7 +7651,84 @@ snapshots: dependencies: valibot: 1.5.0(typescript@6.0.3) - '@vitejs/devtools-kit@0.7.6(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))': + '@visx/curve@4.0.1-alpha.0': + dependencies: + '@visx/vendor': 4.0.0-alpha.0 + + '@visx/event@4.0.1-alpha.0': + dependencies: + '@types/react': 19.3.0 + '@visx/point': 4.0.1-alpha.0 + + '@visx/grid@4.0.1-alpha.0(react@19.3.1)': + dependencies: + '@types/react': 19.3.0 + '@visx/curve': 4.0.1-alpha.0 + '@visx/group': 4.0.1-alpha.0(react@19.3.1) + '@visx/point': 4.0.1-alpha.0 + '@visx/scale': 4.0.1-alpha.0 + '@visx/shape': 4.0.1-alpha.0(react@19.3.1) + classnames: 2.5.1 + react: 19.3.1 + + '@visx/group@4.0.1-alpha.0(react@19.3.1)': + dependencies: + '@types/react': 19.3.0 + classnames: 2.5.1 + react: 19.3.1 + + '@visx/point@4.0.1-alpha.0': {} + + '@visx/responsive@4.0.1-alpha.0(react@19.3.1)': + dependencies: + '@types/lodash': 4.17.27 + '@types/react': 19.3.0 + lodash: 4.18.1 + react: 19.3.1 + + '@visx/scale@4.0.1-alpha.0': + dependencies: + '@visx/vendor': 4.0.0-alpha.0 + + '@visx/shape@4.0.1-alpha.0(react@19.3.1)': + dependencies: + '@types/lodash': 4.17.27 + '@types/react': 19.3.0 + '@visx/curve': 4.0.1-alpha.0 + '@visx/group': 4.0.1-alpha.0(react@19.3.1) + '@visx/scale': 4.0.1-alpha.0 + '@visx/vendor': 4.0.0-alpha.0 + classnames: 2.5.1 + lodash: 4.18.1 + react: 19.3.1 + + '@visx/vendor@4.0.0-alpha.0': + dependencies: + '@types/d3-array': 3.0.3 + '@types/d3-color': 3.1.0 + '@types/d3-delaunay': 6.0.1 + '@types/d3-format': 3.0.1 + '@types/d3-geo': 3.1.0 + '@types/d3-interpolate': 3.0.1 + '@types/d3-path': 3.1.1 + '@types/d3-scale': 4.0.2 + '@types/d3-shape': 3.1.7 + '@types/d3-time': 3.0.0 + '@types/d3-time-format': 2.1.0 + d3-array: 3.2.1 + d3-color: 3.1.0 + d3-delaunay: 6.0.2 + d3-format: 3.1.0 + d3-geo: 3.1.0 + d3-interpolate: 3.0.1 + d3-path: 3.1.0 + d3-scale: 4.0.2 + d3-shape: 3.2.0 + d3-time: 3.1.0 + d3-time-format: 4.1.0 + internmap: 2.0.3 + + '@vitejs/devtools-kit@0.7.6(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))': dependencies: '@devframes/hub': 1.3.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.3.0(cac@7.1.0)(srvx@1.0.8)) '@devframes/json-render': 1.3.0(@devframes/hub@1.3.0(crossws@0.4.17(srvx@1.0.8))(devframe@1.3.0(cac@7.1.0)(srvx@1.0.8)))(devframe@1.3.0(cac@7.1.0)(srvx@1.0.8)) @@ -6102,7 +7736,7 @@ snapshots: local-pkg: 1.2.1 nostics: 1.3.0 package-manager-detector: 1.9.0 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) transitivePeerDependencies: - '@devframes/agentic' - cac @@ -6122,14 +7756,14 @@ snapshots: transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue-jsx@5.1.6(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': + '@vitejs/plugin-vue-jsx@5.1.6(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': dependencies: '@babel/core': 7.29.7 '@babel/plugin-syntax-typescript': 7.29.7(@babel/core@7.29.7) '@babel/plugin-transform-typescript': 7.29.9(@babel/core@7.29.7) '@rolldown/pluginutils': 1.0.1 '@vue/babel-plugin-jsx': 2.0.1(@babel/core@7.29.7) - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) vue: 3.5.44(typescript@6.0.3) transitivePeerDependencies: - supports-color @@ -6139,13 +7773,13 @@ snapshots: vite: 6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1) vue: 3.5.44(typescript@6.0.3) - '@vitejs/plugin-vue@6.0.10(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': + '@vitejs/plugin-vue@6.0.10(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3))': dependencies: '@rolldown/pluginutils': 1.0.1 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) vue: 3.5.44(typescript@6.0.3) - '@vitest/mocker@5.0.5(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))': + '@vitest/mocker@5.0.5(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))': dependencies: '@jridgewell/trace-mapping': 0.3.31 '@vitest/spy': 5.0.5 @@ -6153,7 +7787,7 @@ snapshots: magic-string: 1.4.5 optionalDependencies: msw: 2.11.6(@types/node@26.6.6)(typescript@6.0.3) - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) '@vitest/pretty-format@5.0.5': dependencies: @@ -6169,7 +7803,7 @@ snapshots: pathe: 2.0.3 sirv: 3.0.2 tinyrainbow: 3.2.0 - vitest: 5.0.5(@types/node@26.6.6)(@vitest/ui@5.0.5)(happy-dom@21.0.4)(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + vitest: 5.0.5(@types/node@26.6.6)(@vitest/ui@5.0.5)(happy-dom@21.0.4)(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) '@vitest/utils@5.0.5': dependencies: @@ -6421,6 +8055,11 @@ snapshots: abbrev@5.0.0: {} + accepts@2.0.0: + dependencies: + mime-types: 3.0.2 + negotiator: 1.1.0 + acorn-jsx@5.3.2(acorn@8.19.0): dependencies: acorn: 8.19.0 @@ -6478,6 +8117,8 @@ snapshots: ansis@4.4.0: {} + append-field@1.0.0: {} + argparse@2.0.1: {} argue-cli@3.2.0: {} @@ -6514,6 +8155,8 @@ snapshots: postcss: 8.5.32 postcss-value-parser: 4.2.0 + aws-ssl-profiles@1.1.2: {} + axios@1.21.0(debug@4.4.3): dependencies: follow-redirects: 1.16.2(debug@4.4.3) @@ -6528,8 +8171,24 @@ snapshots: baseline-browser-mapping@2.11.34: {} + better-result@2.10.0: {} + birpc@2.9.0: {} + body-parser@2.4.0: + dependencies: + bytes: 3.1.2 + content-type: 2.1.0 + debug: 4.4.3 + http-errors: 2.0.1 + iconv-lite: 0.7.3 + on-finished: 2.4.2 + qs: 6.17.1 + raw-body: 3.0.2 + type-is: 2.1.0 + transitivePeerDependencies: + - supports-color + boolbase@1.0.0: {} brace-expansion@5.0.12: @@ -6552,6 +8211,27 @@ snapshots: dependencies: run-applescript: 7.1.0 + busboy@1.6.0: + dependencies: + streamsearch: 1.1.0 + + bytes@3.1.2: {} + + c12@3.3.4: + dependencies: + chokidar: 5.0.0 + confbox: 0.2.4 + defu: 6.1.7 + dotenv: 17.4.2 + exsolve: 1.2.0 + giget: 3.3.1 + jiti: 2.7.0 + ohash: 2.0.12 + pathe: 2.0.3 + perfect-debounce: 2.1.0 + pkg-types: 2.4.0 + rc9: 3.1.0 + cac@7.1.0: {} cacheable@2.5.0: @@ -6567,6 +8247,11 @@ snapshots: es-errors: 1.3.0 function-bind: 1.1.2 + call-bound@1.0.4: + dependencies: + call-bind-apply-helpers: 1.0.2 + get-intrinsic: 1.3.0 + callsites@3.1.0: {} caniuse-lite@1.0.30001820: {} @@ -6625,6 +8310,8 @@ snapshots: confbox@0.1.8: {} + confbox@0.2.4: {} + confbox@0.3.2: {} config-chain@1.1.13: @@ -6634,6 +8321,10 @@ snapshots: consola@3.4.2: {} + content-disposition@2.0.1: {} + + content-type@2.1.0: {} + conventional-changelog-angular@9.4.0: dependencies: '@conventional-changelog/template': 1.4.0 @@ -6649,10 +8340,19 @@ snapshots: convert-source-map@2.0.0: {} + cookie-signature@1.2.2: {} + + cookie@0.7.2: {} + cookie@1.1.1: {} copy-anything@4.1.5: {} + cors@2.8.6: + dependencies: + object-assign: 4.1.1 + vary: 1.1.2 + cosmiconfig@9.0.2(typescript@6.0.3): dependencies: env-paths: 2.2.1 @@ -6716,6 +8416,54 @@ snapshots: currency.js@2.0.4: {} + d3-array@3.2.1: + dependencies: + internmap: 2.0.3 + + d3-array@3.2.4: + dependencies: + internmap: 2.0.3 + + d3-color@3.1.0: {} + + d3-delaunay@6.0.2: + dependencies: + delaunator: 5.1.0 + + d3-format@3.1.0: {} + + d3-geo@3.1.0: + dependencies: + d3-array: 3.2.4 + + d3-interpolate@3.0.1: + dependencies: + d3-color: 3.1.0 + + d3-path@3.1.0: {} + + d3-path@3.1.1: {} + + d3-scale@4.0.2: + dependencies: + d3-array: 3.2.4 + d3-format: 3.1.0 + d3-interpolate: 3.0.1 + d3-time: 3.1.0 + d3-time-format: 4.1.0 + + d3-shape@3.2.0: + dependencies: + d3-path: 3.1.1 + + d3-time-format@4.1.0: + dependencies: + d3-time: 3.1.0 + + d3-time@3.1.0: + dependencies: + d3-array: 3.2.4 + date-fns-tz@3.2.0(date-fns@4.4.0): dependencies: date-fns: 4.4.0 @@ -6730,6 +8478,8 @@ snapshots: deep-is@0.1.4: {} + deepmerge-ts@8.0.2: {} + default-browser-id@5.0.1: {} default-browser@5.5.1: @@ -6741,10 +8491,16 @@ snapshots: defu@6.1.7: {} + delaunator@5.1.0: + dependencies: + robust-predicates: 3.0.3 + delayed-stream@1.0.0: {} delegate@3.2.0: {} + depd@2.0.0: {} + dequal@2.0.3: {} destr@2.0.5: {} @@ -6785,6 +8541,8 @@ snapshots: domelementtype: 2.3.0 domhandler: 5.0.3 + dotenv@17.4.2: {} + dunder-proto@1.0.1: dependencies: call-bind-apply-helpers: 1.0.2 @@ -6803,22 +8561,37 @@ snapshots: minimatch: 11.0.4 semver: 7.8.5 + ee-first@1.1.1: {} + + effect@3.20.0: + dependencies: + '@standard-schema/spec': 1.1.0 + fast-check: 3.23.2 + ejs@7.0.2: {} electron-to-chromium@1.5.472: {} + elkjs@0.11.1: {} + emoji-regex-xs@1.0.0: {} emoji-regex@10.6.0: {} emoji-regex@8.0.0: {} + empathic@2.0.0: {} + + encodeurl@2.0.1: {} + entities@4.5.0: {} entities@7.0.1: {} env-paths@2.2.1: {} + env-paths@3.0.0: {} + error-ex@1.3.4: dependencies: is-arrayish: 0.2.1 @@ -6873,8 +8646,39 @@ snapshots: '@esbuild/win32-ia32': 0.25.12 '@esbuild/win32-x64': 0.25.12 + esbuild@0.28.2: + optionalDependencies: + '@esbuild/aix-ppc64': 0.28.2 + '@esbuild/android-arm': 0.28.2 + '@esbuild/android-arm64': 0.28.2 + '@esbuild/android-x64': 0.28.2 + '@esbuild/darwin-arm64': 0.28.2 + '@esbuild/darwin-x64': 0.28.2 + '@esbuild/freebsd-arm64': 0.28.2 + '@esbuild/freebsd-x64': 0.28.2 + '@esbuild/linux-arm': 0.28.2 + '@esbuild/linux-arm64': 0.28.2 + '@esbuild/linux-ia32': 0.28.2 + '@esbuild/linux-loong64': 0.28.2 + '@esbuild/linux-mips64el': 0.28.2 + '@esbuild/linux-ppc64': 0.28.2 + '@esbuild/linux-riscv64': 0.28.2 + '@esbuild/linux-s390x': 0.28.2 + '@esbuild/linux-x64': 0.28.2 + '@esbuild/netbsd-arm64': 0.28.2 + '@esbuild/netbsd-x64': 0.28.2 + '@esbuild/openbsd-arm64': 0.28.2 + '@esbuild/openbsd-x64': 0.28.2 + '@esbuild/openharmony-arm64': 0.28.2 + '@esbuild/sunos-x64': 0.28.2 + '@esbuild/win32-arm64': 0.28.2 + '@esbuild/win32-ia32': 0.28.2 + '@esbuild/win32-x64': 0.28.2 + escalade@3.2.0: {} + escape-html@1.0.3: {} + escape-string-regexp@4.0.0: {} escape-string-regexp@5.0.0: {} @@ -6974,18 +8778,65 @@ snapshots: esutils@2.0.3: {} + etag@1.8.1: {} + evtd@0.2.4: {} expect-type@1.4.0: {} + express@5.3.0: + dependencies: + accepts: 2.0.0 + body-parser: 2.4.0 + content-disposition: 2.0.1 + content-type: 2.1.0 + cookie: 0.7.2 + cookie-signature: 1.2.2 + debug: 4.4.3 + depd: 2.0.0 + encodeurl: 2.0.1 + escape-html: 1.0.3 + etag: 1.8.1 + finalhandler: 2.1.1 + fresh: 2.0.0 + http-errors: 2.0.1 + merge-descriptors: 2.0.0 + mime-types: 3.0.2 + on-finished: 2.4.2 + once: 1.4.0 + parseurl: 1.3.3 + proxy-addr: 2.0.8 + qs: 6.17.1 + range-parser: 1.3.0 + router: 2.2.0 + send: 1.2.1 + serve-static: 2.2.1 + statuses: 2.0.2 + type-is: 2.1.0 + vary: 1.1.2 + transitivePeerDependencies: + - supports-color + exsolve@1.2.0: {} + fast-check@3.23.2: + dependencies: + pure-rand: 6.1.0 + + fast-decode-uri-component@1.0.1: {} + fast-deep-equal@3.1.3: {} fast-json-stable-stringify@2.1.0: {} fast-levenshtein@2.0.6: {} + fast-querystring@1.1.2: + dependencies: + fast-decode-uri-component: 1.0.1 + + fast-safe-stringify@2.1.1: {} + fast-uri@3.1.9: {} fdir@6.5.0(picomatch@4.0.7): @@ -6998,6 +8849,32 @@ snapshots: dependencies: flat-cache: 6.1.23 + file-type@22.3.0: + dependencies: + '@tokenizer/inflate': 0.6.0 + strtok3: 10.7.0 + token-types: 6.2.0 + uint8array-extras: 1.6.0 + transitivePeerDependencies: + - supports-color + + finalhandler@2.1.1: + dependencies: + debug: 4.4.3 + encodeurl: 2.0.1 + escape-html: 1.0.3 + on-finished: 2.4.2 + parseurl: 1.3.3 + statuses: 2.0.2 + transitivePeerDependencies: + - supports-color + + find-my-way@9.7.0: + dependencies: + fast-deep-equal: 3.1.3 + fast-querystring: 1.1.2 + safe-regex2: 5.1.2 + find-up@5.0.0: dependencies: locate-path: 6.0.0 @@ -7019,6 +8896,11 @@ snapshots: optionalDependencies: debug: 4.4.3 + foreground-child@3.3.1: + dependencies: + cross-spawn: 7.0.6 + signal-exit: 4.1.0 + form-data@4.0.6: dependencies: asynckit: 0.4.0 @@ -7027,8 +8909,12 @@ snapshots: hasown: 2.0.4 mime-types: 2.1.35 + forwarded@0.2.0: {} + fraction.js@5.3.4: {} + fresh@2.0.0: {} + fsevents@2.3.3: optional: true @@ -7036,6 +8922,10 @@ snapshots: fzf@0.5.2: {} + generate-function@2.3.1: + dependencies: + is-property: 1.0.2 + gensync@1.0.0-beta.2: {} get-caller-file@2.0.5: {} @@ -7055,11 +8945,15 @@ snapshots: hasown: 2.0.4 math-intrinsics: 1.1.0 + get-port-please@3.2.0: {} + get-proto@1.0.1: dependencies: dunder-proto: 1.0.1 es-object-atoms: 1.1.2 + giget@3.3.1: {} + glob-parent@6.0.2: dependencies: is-glob: 4.0.3 @@ -7082,6 +8976,12 @@ snapshots: gopd@1.2.0: {} + graceful-fs@4.2.11: {} + + grammex@3.1.13: {} + + graphmatch@1.1.1: {} + graphql@16.14.2: {} h3@2.0.8(crossws@0.4.17(srvx@1.0.8)): @@ -7152,6 +9052,14 @@ snapshots: html-void-elements@3.0.0: {} + http-errors@2.0.1: + dependencies: + depd: 2.0.0 + inherits: 2.0.4 + setprototypeof: 1.2.0 + statuses: 2.0.2 + toidentifier: 1.0.1 + https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 @@ -7161,6 +9069,12 @@ snapshots: husky@9.1.7: {} + iconv-lite@0.7.3: + dependencies: + safer-buffer: 2.1.2 + + ieee754@1.2.1: {} + ignore@5.3.2: {} ignore@7.0.14: {} @@ -7176,6 +9090,8 @@ snapshots: imurmurhash@0.1.4: {} + inherits@2.0.4: {} + ini@1.3.8: {} ini@6.0.0: {} @@ -7184,6 +9100,10 @@ snapshots: dependencies: '@interactjs/types': 1.10.28 + internmap@2.0.3: {} + + ipaddr.js@1.9.1: {} + is-arrayish@0.2.1: {} is-docker@3.0.0: {} @@ -7206,12 +9126,18 @@ snapshots: is-plain-obj@4.1.0: {} + is-promise@4.0.0: {} + + is-property@1.0.2: {} + is-wsl@3.1.1: dependencies: is-inside-container: 1.0.0 isexe@2.0.0: {} + iterare@1.2.1: {} + jiti@2.7.0: {} js-beautify@2.0.3: @@ -7323,6 +9249,8 @@ snapshots: optionalDependencies: yaml: 2.9.1 + load-esm@1.0.3: {} + local-pkg@1.2.1: dependencies: mlly: 1.8.2 @@ -7337,12 +9265,16 @@ snapshots: lodash@4.18.1: {} + long@5.3.2: {} + lru-cache@11.5.3: {} lru-cache@5.1.1: dependencies: yallist: 3.1.1 + lru.min@1.1.5: {} + magic-string-ast@1.0.3: dependencies: magic-string: 0.30.21 @@ -7377,8 +9309,14 @@ snapshots: mdn-data@2.27.1: {} + media-typer@0.3.0: {} + + media-typer@1.1.1: {} + medium-editor@5.23.3: {} + merge-descriptors@2.0.0: {} + micromark-util-character@2.1.1: dependencies: micromark-util-symbol: 2.0.1 @@ -7398,10 +9336,16 @@ snapshots: mime-db@1.52.0: {} + mime-db@1.54.0: {} + mime-types@2.1.35: dependencies: mime-db: 1.52.0 + mime-types@3.0.2: + dependencies: + mime-db: 1.54.0 + mini-svg-data-uri@1.4.4: {} minimatch@11.0.3: @@ -7472,8 +9416,25 @@ snapshots: muggle-string@0.4.1: {} + multer@2.5.0: + dependencies: + append-field: 1.0.0 + busboy: 1.6.0 + type-is: 1.6.18 + mute-stream@2.0.0: {} + mysql2@3.24.4(@types/node@26.6.6): + dependencies: + '@types/node': 26.6.6 + aws-ssl-profiles: 1.1.2 + generate-function: 2.3.1 + iconv-lite: 0.7.3 + long: 5.3.2 + lru.min: 1.1.5 + named-placeholders: 1.1.6 + sql-escaper: 1.5.2 + naive-ui@2.45.3(vue@3.5.44(typescript@6.0.3)): dependencies: '@css-render/plugin-bem': 0.15.14(css-render@0.15.14) @@ -7496,10 +9457,18 @@ snapshots: vue: 3.5.44(typescript@6.0.3) vueuc: 0.4.66(vue@3.5.44(typescript@6.0.3)) + named-placeholders@1.1.6: + dependencies: + lru.min: 1.1.5 + nanoid@3.3.20: {} natural-compare@1.4.0: {} + negotiator@1.1.0: + dependencies: + content-type: 2.1.0 + node-addon-api@7.1.1: optional: true @@ -7519,6 +9488,8 @@ snapshots: object-assign@4.1.1: {} + object-inspect@1.13.4: {} + obug@2.2.1: {} obug@3.0.0: {} @@ -7531,6 +9502,14 @@ snapshots: ohash@2.0.12: {} + on-finished@2.4.2: + dependencies: + ee-first: 1.1.1 + + once@1.4.0: + dependencies: + wrappy: 1.0.2 + oniguruma-to-es@3.1.1: dependencies: emoji-regex-xs: 1.0.0 @@ -7608,6 +9587,8 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + parseurl@1.3.3: {} + path-browserify@1.0.1: {} path-exists@4.0.0: {} @@ -7621,12 +9602,49 @@ snapshots: path-to-regexp@6.3.0: {} + path-to-regexp@8.4.2: {} + pathe@2.0.3: {} perfect-debounce@1.0.0: {} perfect-debounce@2.1.0: {} + pg-cloudflare@1.4.1: + optional: true + + pg-connection-string@2.14.1: {} + + pg-int8@1.0.1: {} + + pg-pool@3.14.0(pg@8.23.1): + dependencies: + pg: 8.23.1 + + pg-protocol@1.16.1: {} + + pg-types@2.2.0: + dependencies: + pg-int8: 1.0.1 + postgres-array: 2.0.0 + postgres-bytea: 1.0.1 + postgres-date: 1.0.7 + postgres-interval: 1.2.0 + + pg@8.23.1: + dependencies: + pg-connection-string: 2.14.1 + pg-pool: 3.14.0(pg@8.23.1) + pg-protocol: 1.16.1 + pg-types: 2.2.0 + pgpass: 1.0.5 + optionalDependencies: + pg-cloudflare: 1.4.1 + + pgpass@1.0.5: + dependencies: + split2: 4.2.0 + picocolors@1.1.1: {} picomatch@4.0.7: {} @@ -7674,6 +9692,20 @@ snapshots: picocolors: 1.1.1 source-map-js: 1.2.2 + postgres-array@2.0.0: {} + + postgres-array@3.0.4: {} + + postgres-bytea@1.0.1: {} + + postgres-date@1.0.7: {} + + postgres-interval@1.2.0: + dependencies: + xtend: 4.0.2 + + postgres@3.4.7: {} + powershell-utils@0.2.1: {} preact@10.29.8: {} @@ -7684,26 +9716,96 @@ snapshots: print-js@1.6.0: {} + prisma@7.10.1(@types/node@26.6.6)(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1)(typescript@6.0.3): + dependencies: + '@prisma/config': 7.10.1 + '@prisma/dev': 0.24.17(typescript@6.0.3) + '@prisma/engines': 7.10.1 + '@prisma/studio-core': 0.33.0(@types/react@19.3.0)(react-dom@19.3.1(react@19.3.1))(react@19.3.1) + mysql2: 3.24.4(@types/node@26.6.6) + postgres: 3.4.7 + optionalDependencies: + typescript: 6.0.3 + transitivePeerDependencies: + - '@types/node' + - '@types/react' + - '@types/react-dom' + - magicast + - react + - react-dom + + proper-lockfile@4.1.2: + dependencies: + graceful-fs: 4.2.11 + retry: 0.12.0 + signal-exit: 3.0.7 + property-information@7.2.0: {} proto-list@1.2.4: {} + proxy-addr@2.0.8: + dependencies: + forwarded: 0.2.0 + ipaddr.js: 1.9.1 + proxy-from-env@2.1.0: {} punycode@2.3.1: {} + pure-rand@6.1.0: {} + qified@0.10.1: dependencies: hookified: 2.2.0 + qs@6.17.1: + dependencies: + es-define-property: 1.0.1 + side-channel: 1.1.1 + quansync@0.2.11: {} quansync@1.0.0: {} + range-parser@1.3.0: {} + rangy@1.3.2: {} + raw-body@3.0.2: + dependencies: + bytes: 3.1.2 + http-errors: 2.0.1 + iconv-lite: 0.7.3 + unpipe: 1.0.0 + + rc9@3.1.0: + dependencies: + defu: 6.1.7 + destr: 2.0.5 + + react-dom@19.3.1(react@19.3.1): + dependencies: + react: 19.3.1 + scheduler: 0.28.0 + + react@19.3.1: {} + readdirp@5.1.1: {} + redis@6.3.1: + dependencies: + '@redis/bloom': 6.3.1(@redis/client@6.3.1) + '@redis/client': 6.3.1 + '@redis/json': 6.3.1(@redis/client@6.3.1) + '@redis/search': 6.3.1(@redis/client@6.3.1) + '@redis/time-series': 6.3.1(@redis/client@6.3.1) + transitivePeerDependencies: + - '@node-rs/xxhash' + - '@opentelemetry/api' + + reflect-metadata@0.2.2: {} + regex-recursion@6.0.2: dependencies: regex-utilities: 2.3.0 @@ -7714,6 +9816,8 @@ snapshots: dependencies: regex-utilities: 2.3.0 + remeda@2.33.4: {} + require-directory@2.1.1: {} require-from-string@2.0.2: {} @@ -7722,10 +9826,16 @@ snapshots: resolve-from@5.0.0: {} + ret@0.5.1: {} + + retry@0.12.0: {} + rettime@0.7.0: {} rfdc@1.4.1: {} + robust-predicates@3.0.3: {} + rolldown@1.2.16: dependencies: '@oxc-project/types': 0.156.0 @@ -7786,6 +9896,16 @@ snapshots: rou3@1.0.0: {} + router@2.2.0: + dependencies: + debug: 4.4.3 + depd: 2.0.0 + is-promise: 4.0.0 + parseurl: 1.3.3 + path-to-regexp: 8.4.2 + transitivePeerDependencies: + - supports-color + rs-module-lexer@2.9.0: optionalDependencies: '@xn-sakina/rml-darwin-arm64': 2.9.0 @@ -7800,6 +9920,16 @@ snapshots: run-applescript@7.1.0: {} + rxjs@7.8.2: + dependencies: + tslib: 2.3.0 + + safe-regex2@5.1.2: + dependencies: + ret: 0.5.1 + + safer-buffer@2.1.2: {} + sass@1.107.1: dependencies: chokidar: 5.0.0 @@ -7810,6 +9940,8 @@ snapshots: sax@1.6.1: {} + scheduler@0.28.0: {} + screenfull@5.2.0: {} scule@1.3.0: {} @@ -7824,6 +9956,33 @@ snapshots: semver@7.8.5: {} + send@1.2.1: + dependencies: + debug: 4.4.3 + encodeurl: 2.0.1 + escape-html: 1.0.3 + etag: 1.8.1 + fresh: 2.0.0 + http-errors: 2.0.1 + mime-types: 3.0.2 + ms: 2.1.3 + on-finished: 2.4.2 + range-parser: 1.3.0 + statuses: 2.0.2 + transitivePeerDependencies: + - supports-color + + serve-static@2.2.1: + dependencies: + encodeurl: 2.0.1 + escape-html: 1.0.3 + parseurl: 1.3.3 + send: 1.2.1 + transitivePeerDependencies: + - supports-color + + setprototypeof@1.2.0: {} + shebang-command@2.0.0: dependencies: shebang-regex: 3.0.0 @@ -7841,6 +10000,36 @@ snapshots: '@shikijs/vscode-textmate': 10.1.0 '@types/hast': 3.0.5 + side-channel-list@1.0.1: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + + side-channel-map@1.0.1: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + + side-channel-weakmap@1.0.2: + dependencies: + call-bound: 1.0.4 + es-errors: 1.3.0 + get-intrinsic: 1.3.0 + object-inspect: 1.13.4 + side-channel-map: 1.0.1 + + side-channel@1.1.1: + dependencies: + es-errors: 1.3.0 + object-inspect: 1.13.4 + side-channel-list: 1.0.1 + side-channel-map: 1.0.1 + side-channel-weakmap: 1.0.2 + + signal-exit@3.0.7: {} + signal-exit@4.1.0: {} sirv@3.0.2: @@ -7855,12 +10044,20 @@ snapshots: speakingurl@14.0.1: {} + split2@4.2.0: {} + + sql-escaper@1.5.2: {} + srvx@1.0.8: {} statuses@2.0.2: {} + std-env@3.10.0: {} + std-env@4.3.0: {} + streamsearch@1.1.0: {} + strict-event-emitter@0.5.1: {} string-argv@0.3.2: {} @@ -7899,6 +10096,10 @@ snapshots: dependencies: js-tokens: 10.0.0 + strtok3@10.7.0: + dependencies: + '@tokenizer/token': 0.3.0 + superjson@2.2.6: dependencies: copy-anything: 4.1.5 @@ -7934,6 +10135,14 @@ snapshots: dependencies: tldts-core: 7.4.20 + toidentifier@1.0.1: {} + + token-types@6.2.0: + dependencies: + '@borewit/text-codec': 0.2.3 + '@tokenizer/token': 0.3.0 + ieee754: 1.2.1 + totalist@3.0.1: {} tough-cookie@6.0.2: @@ -7950,12 +10159,25 @@ snapshots: tslib@2.3.0: {} + tslib@2.9.1: {} + type-check@0.4.0: dependencies: prelude-ls: 1.2.1 type-fest@4.41.0: {} + type-is@1.6.18: + dependencies: + media-typer: 0.3.0 + mime-types: 2.1.35 + + type-is@2.1.0: + dependencies: + content-type: 2.1.0 + media-typer: 1.1.1 + mime-types: 3.0.2 + typescript-eslint@8.72.1(eslint@10.14.0(jiti@2.7.0))(typescript@6.0.3): dependencies: '@typescript-eslint/eslint-plugin': 8.72.1(@typescript-eslint/parser@8.72.1(eslint@10.14.0(jiti@2.7.0))(typescript@6.0.3))(eslint@10.14.0(jiti@2.7.0))(typescript@6.0.3) @@ -7971,6 +10193,12 @@ snapshots: ufo@1.6.4: {} + uid@2.0.2: + dependencies: + '@lukeed/csprng': 1.1.0 + + uint8array-extras@1.6.0: {} + unconfig-core@7.5.0: dependencies: '@quansync/fs': 1.1.0 @@ -7986,7 +10214,7 @@ snapshots: undici-types@8.9.0: {} - unimport@6.5.0(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): + unimport@6.5.0(esbuild@0.28.2)(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: acorn: 8.19.0 escape-string-regexp: 5.0.0 @@ -8000,7 +10228,7 @@ snapshots: scule: 1.3.0 strip-literal: 4.0.0 tinyglobby: 0.2.17 - unplugin: 3.7.0(esbuild@0.25.12)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + unplugin: 3.7.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) unplugin-utils: 0.3.2 optionalDependencies: oxc-parser: 0.153.0 @@ -8039,7 +10267,7 @@ snapshots: unist-util-is: 6.0.1 unist-util-visit-parents: 6.1.0 - unocss@66.12.0(@oxc-project/types@0.156.0)(cac@7.1.0)(rolldown@1.2.16)(rollup@4.67.4)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): + unocss@66.12.0(@oxc-project/types@0.156.0)(cac@7.1.0)(rolldown@1.2.16)(rollup@4.67.4)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: '@unocss/cli': 66.12.0 '@unocss/core': 66.12.0 @@ -8058,7 +10286,7 @@ snapshots: '@unocss/transformer-compile-class': 66.12.0 '@unocss/transformer-directives': 66.12.0 '@unocss/transformer-variant-group': 66.12.0 - '@unocss/vite': 66.12.0(cac@7.1.0)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + '@unocss/vite': 66.12.0(cac@7.1.0)(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) transitivePeerDependencies: - '@devframes/agentic' - '@oxc-project/types' @@ -8069,13 +10297,15 @@ snapshots: - srvx - vite - unplugin-auto-import@21.1.0(@vueuse/core@15.0.0(vue@3.5.44(typescript@6.0.3)))(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): + unpipe@1.0.0: {} + + unplugin-auto-import@21.1.0(@vueuse/core@15.0.0(vue@3.5.44(typescript@6.0.3)))(esbuild@0.28.2)(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: local-pkg: 1.2.1 magic-string: 1.4.5 picomatch: 4.0.7 - unimport: 6.5.0(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) - unplugin: 3.7.0(esbuild@0.25.12)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + unimport: 6.5.0(esbuild@0.28.2)(oxc-parser@0.153.0)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + unplugin: 3.7.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) unplugin-utils: 0.3.2 optionalDependencies: '@vueuse/core': 15.0.0(vue@3.5.44(typescript@6.0.3)) @@ -8097,7 +10327,7 @@ snapshots: pathe: 2.0.3 picomatch: 4.0.7 - unplugin-vue-components@32.1.0(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)): + unplugin-vue-components@32.1.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)): dependencies: chokidar: 5.0.0 local-pkg: 1.2.1 @@ -8106,7 +10336,7 @@ snapshots: obug: 2.2.1 picomatch: 4.0.7 tinyglobby: 0.2.17 - unplugin: 3.7.0(esbuild@0.25.12)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + unplugin: 3.7.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) unplugin-utils: 0.3.2 vue: 3.5.44(typescript@6.0.3) transitivePeerDependencies: @@ -8128,29 +10358,29 @@ snapshots: picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 - unplugin@3.7.0(esbuild@0.25.12)(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1)): + unplugin@3.7.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: '@jridgewell/remapping': 2.3.5 '@rolldown/pluginutils': 1.0.1 picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 optionalDependencies: - esbuild: 0.25.12 + esbuild: 0.28.2 rolldown: 1.2.16 rollup: 4.67.4 vite: 6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1) - unplugin@3.7.0(esbuild@0.25.12)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): + unplugin@3.7.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: '@jridgewell/remapping': 2.3.5 '@rolldown/pluginutils': 1.0.1 picomatch: 4.0.7 webpack-virtual-modules: 0.6.2 optionalDependencies: - esbuild: 0.25.12 + esbuild: 0.28.2 rolldown: 1.2.16 rollup: 4.67.4 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) until-async@3.0.2: {} @@ -8168,6 +10398,10 @@ snapshots: uuid@14.0.3: {} + valibot@1.4.2(typescript@6.0.3): + optionalDependencies: + typescript: 6.0.3 + valibot@1.5.0(typescript@6.0.3): optionalDependencies: typescript: 6.0.3 @@ -8176,6 +10410,8 @@ snapshots: dependencies: '@sphinxxxx/color-conversion': 2.2.2 + vary@1.1.2: {} + vdirs@0.1.8(vue@3.5.44(typescript@6.0.3)): dependencies: evtd: 0.2.4 @@ -8207,14 +10443,14 @@ snapshots: - rollup - supports-color - vite-plugin-ejs@2.0.0(ejs@7.0.2)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): + vite-plugin-ejs@2.0.0(ejs@7.0.2)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: ejs: 7.0.2 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) - vite-plugin-inspect@12.1.0(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): + vite-plugin-inspect@12.1.0(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: - '@vitejs/devtools-kit': 0.7.6(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + '@vitejs/devtools-kit': 0.7.6(cac@7.1.0)(crossws@0.4.17(srvx@1.0.8))(srvx@1.0.8)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) ansis: 4.4.0 error-stack-parser-es: 2.0.1 obug: 3.0.0 @@ -8223,7 +10459,7 @@ snapshots: perfect-debounce: 2.1.0 sirv: 3.0.2 unplugin-utils: 0.3.2 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) transitivePeerDependencies: - '@devframes/agentic' - cac @@ -8255,7 +10491,7 @@ snapshots: sass: 1.107.1 yaml: 2.9.1 - vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1): + vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1): dependencies: lightningcss: 1.33.0 picomatch: 4.0.7 @@ -8264,7 +10500,7 @@ snapshots: tinyglobby: 0.2.17 optionalDependencies: '@types/node': 26.6.6 - esbuild: 0.25.12 + esbuild: 0.28.2 fsevents: 2.3.3 jiti: 2.7.0 sass: 1.107.1 @@ -8323,10 +10559,10 @@ snapshots: - universal-cookie - yaml - vitest@5.0.5(@types/node@26.6.6)(@vitest/ui@5.0.5)(happy-dom@21.0.4)(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): + vitest@5.0.5(@types/node@26.6.6)(@vitest/ui@5.0.5)(happy-dom@21.0.4)(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)): dependencies: '@types/chai': 5.2.3 - '@vitest/mocker': 5.0.5(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + '@vitest/mocker': 5.0.5(msw@2.11.6(@types/node@26.6.6)(typescript@6.0.3))(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 @@ -8337,7 +10573,7 @@ snapshots: tinybench: 6.2.2 tinyexec: 1.3.1 tinyglobby: 0.2.17 - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) why-is-node-running: 3.2.1 optionalDependencies: '@types/node': 26.6.6 @@ -8399,7 +10635,7 @@ snapshots: '@vue/devtools-api': 6.6.4 vue: 3.5.44(typescript@6.0.3) - vue-router@5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.25.12)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)): + vue-router@5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)): dependencies: '@vue-macros/common': 3.1.4(vue@3.5.44(typescript@6.0.3)) '@vue/devtools-api': 8.2.1 @@ -8415,7 +10651,7 @@ snapshots: picomatch: 4.0.7 scule: 1.3.0 tinyglobby: 0.2.17 - unplugin: 3.7.0(esbuild@0.25.12)(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1)) + unplugin: 3.7.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@6.4.5(@types/node@26.6.6)(jiti@2.7.0)(lightningcss@1.33.0)(sass@1.107.1)(yaml@2.9.1)) unplugin-utils: 0.3.2 vue: 3.5.44(typescript@6.0.3) optionalDependencies: @@ -8433,7 +10669,7 @@ snapshots: - unloader - webpack - vue-router@5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.25.12)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)): + vue-router@5.4.0(@vue/compiler-sfc@3.5.44)(esbuild@0.28.2)(pinia@4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)))(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1))(vue@3.5.44(typescript@6.0.3)): dependencies: '@vue-macros/common': 3.1.4(vue@3.5.44(typescript@6.0.3)) '@vue/devtools-api': 8.2.1 @@ -8449,13 +10685,13 @@ snapshots: picomatch: 4.0.7 scule: 1.3.0 tinyglobby: 0.2.17 - unplugin: 3.7.0(esbuild@0.25.12)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) + unplugin: 3.7.0(esbuild@0.28.2)(rolldown@1.2.16)(rollup@4.67.4)(vite@8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1)) unplugin-utils: 0.3.2 vue: 3.5.44(typescript@6.0.3) optionalDependencies: '@vue/compiler-sfc': 3.5.44 pinia: 4.1.0(@vue/devtools-api@8.2.1)(typescript@6.0.3)(vue@3.5.44(typescript@6.0.3)) - vite: 8.3.5(@types/node@26.6.6)(esbuild@0.25.12)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) + vite: 8.3.5(@types/node@26.6.6)(esbuild@0.28.2)(jiti@2.7.0)(sass@1.107.1)(yaml@2.9.1) transitivePeerDependencies: - '@farmfe/core' - '@rsbuild/core' @@ -8529,6 +10765,8 @@ snapshots: string-width: 7.2.0 strip-ansi: 7.2.0 + wrappy@1.0.2: {} + ws@8.22.1: {} wsl-utils@1.0.1: @@ -8538,6 +10776,8 @@ snapshots: xml-name-validator@5.0.0: {} + xtend@4.0.2: {} + y18n@5.0.8: {} yallist@3.1.1: {} @@ -8576,6 +10816,11 @@ snapshots: yoctocolors-cjs@2.1.3: {} + zeptomatch@2.1.0: + dependencies: + grammex: 3.1.13 + graphmatch: 1.1.1 + zigpty@0.2.1: {} zod@4.6.7: {} diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 45a8d615..94b3c673 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -11,6 +11,9 @@ overrides: 'minimatch@>=10.0.0 <11.0.1': 11.0.4 'glob@>=9.0.0 <14.0.2': 14.0.3 allowBuilds: + # Prisma preinstall checks the runtime; engines downloads the migration binary. + prisma: true + '@prisma/engines': true # 发布包已包含构建产物,postinstall 仅输出 AI 提示,不参与应用构建。 '@logicflow/core': false # worker 由显式生成命令同步并校验,避免安装阶段自动改写公共资源。 @@ -20,6 +23,9 @@ allowBuilds: rs-module-lexer: true vue-demi: true peerDependencyRules: + allowedVersions: + # Docs uses Vue Router runtime only; its optional Vite plugin is not loaded. + 'vue-router@5.4.0>vite': 6.4.5 ignoreMissing: - '@algolia/client-search' - search-insights diff --git a/scripts/admin-api.mjs b/scripts/admin-api.mjs index 51412e7e..d986a339 100644 --- a/scripts/admin-api.mjs +++ b/scripts/admin-api.mjs @@ -1,5 +1,12 @@ import { mkdirSync, readFileSync, writeFileSync } from 'node:fs' import { getAdminOpenApi } from '@ray-template/api-contracts/openapi' +import { iconNames, retiredIcons } from '@ray-template/icons' +import { routeViewCatalog } from '../apps/admin/src/router/config/views.ts' +import { + ROUTE_MANAGEMENT_PATH, + SYSTEM_ROUTE_NAMES, + SYSTEM_ROUTE_PATHS, +} from '../apps/admin/src/router/constant/index.ts' const file = new URL( '../apps/admin/public/contracts/admin-api.json', @@ -42,3 +49,16 @@ if (process.argv.includes('--check')) { console.log('Generated Admin API contracts for the app and docs.') } + +const catalogFile = new URL( + '../packages/demo-data/src/route-catalog.json', + import.meta.url, +) +const catalogContent = `${JSON.stringify({ views: routeViewCatalog, managementPath: ROUTE_MANAGEMENT_PATH, reservedPaths: SYSTEM_ROUTE_PATHS, reservedNames: [...SYSTEM_ROUTE_NAMES, 'RLogin', 'RLayout', 'RNotFound', 'RouteManagement', 'RouteManagementVisual', 'ErrorPage', 'RayTemplateDoc'], icons: iconNames, iconAliases: Object.fromEntries(retiredIcons) }, null, 2)}\n` + +if (process.argv.includes('--check')) { + if (readFileSync(catalogFile, 'utf8') !== catalogContent) + throw new Error('Route catalog is stale. Run pnpm api:generate.') +} else { + writeFileSync(catalogFile, catalogContent) +} diff --git a/scripts/check-package-boundaries.mjs b/scripts/check-package-boundaries.mjs index 2f35d237..97442d34 100644 --- a/scripts/check-package-boundaries.mjs +++ b/scripts/check-package-boundaries.mjs @@ -1,9 +1,16 @@ import { readdirSync, readFileSync } from 'node:fs' -import { dirname, join, relative, resolve, sep } from 'node:path' +import { builtinModules } from 'node:module' +import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path' import { fileURLToPath } from 'node:url' import ts from 'typescript' -const root = fileURLToPath(new URL('../', import.meta.url)) +const root = resolve( + process.argv[2] ?? fileURLToPath(new URL('../', import.meta.url)), +) +const builtins = new Set([ + ...builtinModules, + ...builtinModules.map((name) => `node:${name}`), +]) const projects = ['packages', 'apps'].flatMap((group) => readdirSync(join(root, group), { withFileTypes: true }) .filter((entry) => entry.isDirectory()) @@ -19,7 +26,12 @@ const manifests = new Map( const errors = [] const { version } = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) -for (const app of ['@ray-template/admin', '@ray-template/docs']) { +for (const app of projects + .filter(({ group }) => group === 'apps') + .map( + ({ dir }) => + JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8')).name, + )) { if (manifests.get(app)?.version !== version) { errors.push(`${app} must use workspace version ${version}.`) } @@ -32,6 +44,43 @@ for (const { group, dir } of projects) { ...manifest.peerDependencies, ...manifest.devDependencies, } + const runtime = manifest.rayTemplate?.runtime + + if (!['browser', 'server', 'universal'].includes(runtime)) + errors.push(`${manifest.name}: declare rayTemplate.runtime.`) + + for (const [name, range] of Object.entries(declared)) { + const target = manifests.get(name) + + if (!target) continue + + if (!String(range).startsWith('workspace:')) + errors.push(`${manifest.name}: ${name} must use workspace protocol.`) + + if ( + projects.some( + (project) => + project.group === 'apps' && + JSON.parse(readFileSync(join(project.dir, 'package.json'), 'utf8')) + .name === name, + ) + ) + errors.push( + `${manifest.name}: applications cannot be dependencies (${name}).`, + ) + + const targetRuntime = target.rayTemplate?.runtime + + if ( + (runtime === 'universal' && targetRuntime !== 'universal') || + (runtime === 'server' && targetRuntime === 'browser') || + (runtime === 'browser' && targetRuntime === 'server') + ) + errors.push( + `${manifest.name}: ${runtime} cannot depend on ${targetRuntime} ${name}.`, + ) + } + const files = readdirSync(dir, { recursive: true, withFileTypes: true }) for (const file of files) { @@ -42,7 +91,15 @@ for (const { group, dir } of projects) { !/\.(?:[cm]?tsx?|vue)$/.test(file.name) || relative(dir, path) .split(sep) - .some((part) => ['node_modules', 'dist', 'cache'].includes(part)) + .some((part) => + [ + 'node_modules', + 'dist', + 'cache', + 'generated', + '.harness-local', + ].includes(part), + ) ) continue @@ -56,6 +113,8 @@ for (const { group, dir } of projects) { const { importedFiles } = ts.preProcessFile(script, true, true) for (const { fileName: specifier } of importedFiles) { + if (specifier.startsWith('virtual:') || specifier.includes('*')) continue + let invalid = false if ( @@ -66,7 +125,8 @@ for (const { group, dir } of projects) { } else if (specifier.startsWith('.')) { const target = relative(dir, resolve(dirname(path), specifier)) - invalid = target === '..' || target.startsWith('..' + sep) + invalid = + isAbsolute(target) || target === '..' || target.startsWith('..' + sep) } else if (specifier.startsWith('@ray-template/')) { const parts = specifier.split('/') const name = parts.slice(0, 2).join('/') @@ -81,13 +141,15 @@ for (const { group, dir } of projects) { key === entry || (key.endsWith('/*') && entry.startsWith(key.slice(0, -1))), ) - } else if (group === 'packages' && !specifier.startsWith('node:')) { + } else if (!builtins.has(specifier)) { const parts = specifier.split('/') const name = parts.slice(0, specifier.startsWith('@') ? 2 : 1).join('/') invalid = !declared[name] } + if (runtime === 'universal' && builtins.has(specifier)) invalid = true + if (invalid) errors.push(`${relative(root, path)}: ${specifier}`) } } diff --git a/scripts/distributions.d.mts b/scripts/distributions.d.mts new file mode 100644 index 00000000..57ed9978 --- /dev/null +++ b/scripts/distributions.d.mts @@ -0,0 +1,28 @@ +export type DistributionEdition = 'frontend' | 'fullstack' + +export interface DistributionManifest { + formatVersion: number + generatedBy: string + edition: DistributionEdition + version: string + source: { commit: string | null; dirty: boolean } + workspaces: string[] + fileCount: number + contentSha256: string +} + +export function pruneLockfile(content: string, importers: Set): string +export function exportDistribution( + root: string, + edition: DistributionEdition, + options?: { archive?: boolean }, +): Promise<{ + directory: string + archive: string | null + manifest: DistributionManifest +}> +export function checkDistributions(root?: string): { + edition: DistributionEdition + files: number + workspaces: number +}[] diff --git a/scripts/distributions.mjs b/scripts/distributions.mjs new file mode 100644 index 00000000..d6a80c04 --- /dev/null +++ b/scripts/distributions.mjs @@ -0,0 +1,702 @@ +import { spawnSync } from 'node:child_process' +import { createHash } from 'node:crypto' +import { + chmodSync, + copyFileSync, + existsSync, + lstatSync, + mkdirSync, + readdirSync, + readFileSync, + realpathSync, + rmSync, + writeFileSync, +} from 'node:fs' +import { dirname, join, relative, resolve, sep } from 'node:path' +import { fileURLToPath } from 'node:url' +import { format, resolveConfig } from 'prettier' +import { parse, parseAllDocuments, stringify } from 'yaml' + +const repository = fileURLToPath(new URL('../', import.meta.url)) +const generator = 'ray-template/distributions' +const dependencyFields = [ + 'dependencies', + 'devDependencies', + 'optionalDependencies', + 'peerDependencies', +] +const lockDependencyFields = [ + 'dependencies', + 'devDependencies', + 'optionalDependencies', + 'configDependencies', + 'packageManagerDependencies', +] +const rootFiles = new Set([ + 'AGENTS.md', + 'CHANGELOG.md', + 'CODE_OF_CONDUCT.md', + 'LICENSE', + 'README.md', + 'README.zh-CN.md', + 'README.commit.md', + 'TODO.md', + 'llms.txt', + 'package.json', + 'pnpm-lock.yaml', + 'pnpm-workspace.yaml', + '.nvmrc', + '.npmrc', + '.gitignore', + '.gitattributes', + '.editorconfig', + '.prettierignore', + '.prettierrc.cjs', + '.dockerignore', + '.npmignore', + 'Dockerfile', + 'docker-compose.yml', +]) +const sourceDirectories = [ + 'scripts', + 'harness', + 'docs', + '__test__', + 'vite-helper', + 'unplugin', + '.github', + '.husky', +] +const fullstackPaths = [ + 'apps/server', + 'scripts/fullstack.mjs', + 'scripts/sync-frontend.sh', + 'deploy', + 'harness/context/server.md', + '.github/workflows/distributions.yaml', +] +const excludedDirectories = new Set([ + 'node_modules', + 'dist', + 'dist-ssr', + 'dist-test', + 'coverage', + 'logs', + 'playground-dist', +]) +const publicEnvironments = new Set([ + 'apps/admin/.env.development', + 'apps/admin/.env.production', + 'apps/admin/.env.test', +]) +const fullstackScript = (name) => + /^(?:server:|fullstack:)/.test(name) || + ['setup', 'dev:full', 'dist:fullstack'].includes(name) +const json = (value) => `${JSON.stringify(value, null, 2)}\n` +const readJson = (file) => JSON.parse(readFileSync(file, 'utf8')) +const portable = (path) => path.split(sep).join('/') + +function within(path, directory) { + return path === directory || path.startsWith(`${directory}/`) +} + +function workspaceProjects(root) { + const projects = new Map() + + for (const group of ['apps', 'packages']) { + for (const entry of readdirSync(join(root, group), { + withFileTypes: true, + })) { + const directory = `${group}/${entry.name}` + const file = join(root, directory, 'package.json') + + if (!entry.isDirectory() || !existsSync(file)) continue + + const manifest = readJson(file) + + if (!manifest.name || projects.has(manifest.name)) { + throw new Error(`Missing or duplicate workspace name: ${directory}`) + } + + projects.set(manifest.name, { directory, manifest }) + } + } + + return projects +} + +function selectProjects(root, edition, manifest) { + const projects = workspaceProjects(root) + const selected = new Map() + const visit = (name) => { + if (selected.has(name)) return + + const project = projects.get(name) + + if (!project) throw new Error(`Workspace dependency is missing: ${name}`) + + if (edition === 'frontend' && within(project.directory, 'apps/server')) { + throw new Error(`Frontend dependency reaches the server: ${name}`) + } + + selected.set(name, project) + visitDependencies(project.manifest) + } + const visitDependencies = (source) => { + for (const field of dependencyFields) { + for (const [name, version] of Object.entries(source[field] ?? {})) { + if (String(version).startsWith('workspace:')) visit(name) + } + } + } + + visit('@ray-template/admin') + visit('@ray-template/docs') + + if (edition === 'fullstack') visit('@ray-template/server') + + visitDependencies(manifest) + + return selected +} + +function peerReferences(key) { + const references = [] + let depth = 0 + let start = 0 + + for (let index = 0; index < key.length; index++) { + if (key[index] === '(') { + if (depth === 0) start = index + 1 + + depth++ + } else if (key[index] === ')') { + depth-- + + if (depth === 0) references.push(key.slice(start, index)) + } + } + + return references +} + +/** + * + * @param content pnpm 的多文档锁文件内容 + * @param importers 发行物保留的 workspace 相对路径 + * + * @description + * 同时保留包管理器文档和应用文档,只移除不可达依赖,不重新解析版本。 + */ +export function pruneLockfile(content, importers) { + const foundImporters = new Set() + const output = parseAllDocuments(content) + .map((document) => { + if (document.errors.length) throw document.errors[0] + + const lock = document.toJS() + + if (String(lock.lockfileVersion) !== '9.0' || !lock.importers) { + throw new Error( + 'Only pnpm lockfile version 9 with importers is supported.', + ) + } + + lock.importers = Object.fromEntries( + Object.entries(lock.importers).filter(([path]) => importers.has(path)), + ) + + for (const path of Object.keys(lock.importers)) foundImporters.add(path) + + const snapshots = lock.snapshots ?? {} + const packages = lock.packages ?? {} + const reachable = new Set() + const reachablePackages = new Set() + const visitSnapshot = (key) => { + if (reachable.has(key)) return + + const snapshot = snapshots[key] + + if (!snapshot) throw new Error(`Missing lockfile snapshot: ${key}`) + + reachable.add(key) + + const base = Object.hasOwn(packages, key) + ? key + : Object.keys(packages).find((name) => key.startsWith(`${name}(`)) + + if (!base) throw new Error(`Missing lockfile package: ${key}`) + + reachablePackages.add(base) + + for (const field of ['dependencies', 'optionalDependencies']) { + for (const [name, reference] of Object.entries( + snapshot[field] ?? {}, + )) { + visitDependency(name, reference) + } + } + + for (const peer of peerReferences(key)) { + if (Object.hasOwn(snapshots, peer)) visitSnapshot(peer) + } + } + const visitDependency = (name, reference) => { + if (/^(?:link:|workspace:)/.test(reference)) return + + const key = [`${name}@${reference}`, reference].find((candidate) => + Object.hasOwn(snapshots, candidate), + ) + + if (!key) throw new Error(`Unresolved lockfile dependency: ${name}`) + + visitSnapshot(key) + } + + for (const importer of Object.values(lock.importers)) { + for (const field of lockDependencyFields) { + for (const [name, dependency] of Object.entries( + importer[field] ?? {}, + )) { + const reference = + typeof dependency === 'string' ? dependency : dependency.version + + if (typeof reference !== 'string') { + throw new Error(`Invalid lockfile dependency: ${name}`) + } + + visitDependency(name, reference) + } + } + } + + lock.packages = Object.fromEntries( + Object.entries(packages).filter(([key]) => reachablePackages.has(key)), + ) + lock.snapshots = Object.fromEntries( + Object.entries(snapshots).filter(([key]) => reachable.has(key)), + ) + + return `---\n${stringify(lock, { lineWidth: 0 })}` + }) + .join('\n') + + for (const path of importers) { + if (!foundImporters.has(path)) { + throw new Error( + `Workspace importer is missing from the lockfile: ${path}`, + ) + } + } + + return output +} + +function stripFullstackSections(content, path) { + const start = '' + const end = '' + let result = '' + let offset = 0 + + while (offset < content.length) { + const begin = content.indexOf(start, offset) + const finish = content.indexOf(end, offset) + + if (begin === -1 && finish === -1) return result + content.slice(offset) + + if (begin === -1 || finish < begin) { + throw new Error(`Unpaired fullstack section marker: ${path}`) + } + + if ( + content.indexOf(start, begin + start.length) < finish && + content.indexOf(start, begin + start.length) !== -1 + ) { + throw new Error(`Nested fullstack section marker: ${path}`) + } + + result += content.slice(offset, begin) + offset = finish + end.length + } + + return result +} + +function included(path, edition) { + const parts = path.split('/') + const name = parts.at(-1) + + if (within(path, 'apps/server/src/generated')) return false + + if (path.includes('/.vitepress/cache') || within(path, '.husky/_')) + return false + + if ( + edition === 'frontend' && + fullstackPaths.some((target) => within(path, target)) + ) { + return false + } + + if (parts.some((part) => excludedDirectories.has(part))) return false + + if (name.startsWith('.env')) { + return publicEnvironments.has(path) || name === '.env.example' + } + + if (/\.(?:log|local|tsbuildinfo|pem|key|p12|pfx)$/.test(name)) return false + + return !parts.some( + (part, index) => + part.startsWith('.') && + ![ + '.github', + '.husky', + '.vitepress', + '.nojekyll', + '.gitignore', + '.eslintrc-auto-import.json', + ].includes(part) && + !(index === 0 && rootFiles.has(path)), + ) +} + +function sourceFiles(root, edition, projects) { + const files = [] + const visit = (path) => { + if (!included(path, edition)) return + + const stat = lstatSync(join(root, path)) + + if (stat.isSymbolicLink()) + throw new Error(`Source symlinks cannot be exported: ${path}`) + + if (stat.isDirectory()) { + for (const name of readdirSync(join(root, path)).sort()) + visit(`${path}/${name}`) + } else if (stat.isFile()) { + files.push(path) + } + } + + for (const name of readdirSync(root).sort()) { + if ( + rootFiles.has(name) || + /^(?:tsconfig(?:\.[\w-]+)?\.json|(?:vite(?:\.[\w-]+)?|vitest|uno|eslint|postcss|commitlint)\.config\.[cm]?[jt]s)$/.test( + name, + ) + ) { + visit(name) + } + } + + for (const directory of [ + ...sourceDirectories, + ...[...projects.values()].map((project) => project.directory), + ...(edition === 'fullstack' ? ['deploy'] : []), + ]) { + if (existsSync(join(root, directory))) visit(directory) + } + + return [...new Set(files)].sort() +} + +function prepareDistribution(root, edition) { + if (!['frontend', 'fullstack'].includes(edition)) { + throw new Error(`Unknown distribution: ${edition}`) + } + + const manifest = readJson(join(root, 'package.json')) + + if (!/^[\w.-]+$/.test(manifest.version ?? '')) { + throw new Error('The package version is not safe for an artifact filename.') + } + + const projects = selectProjects(root, edition, manifest) + const importers = new Set([ + '.', + ...[...projects.values()].map(({ directory }) => directory), + ]) + const files = sourceFiles(root, edition, projects) + const overrides = new Map() + + if (edition === 'frontend') { + manifest.scripts = Object.fromEntries( + Object.entries(manifest.scripts ?? {}).filter( + ([name]) => !fullstackScript(name), + ), + ) + + if (manifest.scripts['check:frontend']) { + manifest.scripts.check = 'pnpm check:frontend && pnpm dist:check' + } + + overrides.set('package.json', json(manifest)) + + if (files.includes('harness/scopes.json')) { + const scopes = readJson(join(root, 'harness/scopes.json')) + + delete scopes.server + + for (const scope of Object.values(scopes)) { + if (scope.checks) + scope.checks = scope.checks.filter((name) => !fullstackScript(name)) + } + + overrides.set('harness/scopes.json', json(scopes)) + } + + if (files.includes('tsconfig.json')) { + const config = readJson(join(root, 'tsconfig.json')) + + if (config.references) { + config.references = config.references.filter( + ({ path }) => !within(path.replace(/^\.\//, ''), 'apps/server'), + ) + } + + overrides.set('tsconfig.json', json(config)) + } + + for (const path of files.filter((path) => /\.(?:md|txt)$/.test(path))) { + const content = readFileSync(join(root, path), 'utf8') + const stripped = stripFullstackSections(content, path) + + if (stripped !== content) overrides.set(path, stripped) + } + } + + const workspace = parse( + readFileSync(join(root, 'pnpm-workspace.yaml'), 'utf8'), + ) + + workspace.packages = [...importers].filter((path) => path !== '.').sort() + overrides.set('pnpm-workspace.yaml', stringify(workspace, { lineWidth: 0 })) + overrides.set( + 'pnpm-lock.yaml', + pruneLockfile( + readFileSync(join(root, 'pnpm-lock.yaml'), 'utf8'), + importers, + ), + ) + + if ( + files.includes('.npmrc') && + /(?:_auth(?:Token)?|_password|username|certfile|keyfile)\s*=/i.test( + readFileSync(join(root, '.npmrc'), 'utf8'), + ) + ) { + throw new Error('Credential-bearing .npmrc cannot be exported.') + } + + return { manifest, projects, files, overrides } +} + +function assertOutputPath(root, path) { + const fromRoot = relative(root, path) + + if (!fromRoot || fromRoot.startsWith(`..${sep}`) || fromRoot === '..') { + throw new Error('Distribution output must stay inside the repository.') + } + + let cursor = root + + for (const part of fromRoot.split(sep)) { + cursor = join(cursor, part) + + if (lstatSync(cursor, { throwIfNoEntry: false })?.isSymbolicLink()) { + throw new Error('Distribution output must not traverse a symlink.') + } + } +} + +function sourceRevision(root) { + const revision = spawnSync('git', ['rev-parse', '--show-toplevel', 'HEAD'], { + cwd: root, + encoding: 'utf8', + }) + const [directory, commit] = revision.stdout?.trim().split('\n') ?? [] + + if (revision.status === 0 && realpathSync(directory) === root) { + const status = spawnSync('git', ['status', '--porcelain'], { + cwd: root, + encoding: 'utf8', + }) + + return { + commit, + dirty: status.stdout.trim().length > 0, + } + } + + const previous = join(root, 'distribution.json') + + return existsSync(previous) + ? readJson(previous).source + : { commit: null, dirty: true } +} + +/** + * + * @param root 源码仓库目录 + * @param edition frontend 或 fullstack + * @param options 是否生成 tar.gz 归档;测试可仅导出目录 + * + * @description + * 仅替换 dist/distributions 中带本工具标记的同名产物,源码与其他输出保持不变。 + */ +export async function exportDistribution(root, edition, options = {}) { + root = realpathSync(root) + + const plan = prepareDistribution(root, edition) + const name = `ray-template-${edition}-${plan.manifest.version}` + const output = join(root, 'dist/distributions') + const directory = join(output, name) + const archive = join(output, `${name}.tar.gz`) + const formatting = await resolveConfig(join(root, 'package.json')) + + for (const [path, content] of plan.overrides) { + if (/\.(?:json|yaml|md)$/.test(path) && !path.endsWith('-lock.yaml')) { + plan.overrides.set( + path, + await format(content, { ...formatting, filepath: path }), + ) + } + } + + assertOutputPath(root, directory) + assertOutputPath(root, archive) + + if (existsSync(directory)) { + const marker = join(directory, 'distribution.json') + + if ( + !existsSync(marker) || + lstatSync(marker).isSymbolicLink() || + readJson(marker).generatedBy !== generator + ) { + throw new Error( + `Refusing to replace an unrecognized distribution: ${name}`, + ) + } + + rmSync(directory, { recursive: true }) + } else if (existsSync(archive)) { + throw new Error( + `Refusing to replace an archive without its distribution directory: ${name}`, + ) + } + + mkdirSync(directory, { recursive: true }) + + const hash = createHash('sha256') + + for (const path of plan.files) { + const source = join(root, path) + const destination = join(directory, path) + const content = plan.overrides.get(path) + + mkdirSync(dirname(destination), { recursive: true }) + + if (content === void 0) copyFileSync(source, destination) + else writeFileSync(destination, content) + + chmodSync(destination, lstatSync(source).mode & 0o777) + hash.update(path) + hash.update('\0') + hash.update(readFileSync(destination)) + hash.update('\0') + } + + const manifest = { + formatVersion: 1, + generatedBy: generator, + edition, + version: plan.manifest.version, + source: sourceRevision(root), + workspaces: [...plan.projects.values()] + .map(({ directory }) => directory) + .sort(), + fileCount: plan.files.length, + contentSha256: hash.digest('hex'), + } + + writeFileSync( + join(directory, 'distribution.json'), + await format(json(manifest), { + ...formatting, + filepath: 'distribution.json', + }), + ) + + if (options.archive !== false) { + const result = spawnSync( + 'tar', + ['--no-xattrs', '-czf', archive, '-C', output, name], + { + encoding: 'utf8', + env: { ...process.env, COPYFILE_DISABLE: '1' }, + }, + ) + + if (result.error || result.status !== 0) { + throw new Error( + `Failed to archive distribution: ${result.error?.message ?? result.stderr}`, + ) + } + } + + return { + directory, + archive: options.archive === false ? null : archive, + manifest, + } +} + +export function checkDistributions(root = repository) { + const editions = existsSync(join(root, 'apps/server/package.json')) + ? ['frontend', 'fullstack'] + : ['frontend'] + + return editions.map((edition) => { + const plan = prepareDistribution(root, edition) + + return { edition, files: plan.files.length, workspaces: plan.projects.size } + }) +} + +if ( + process.argv[1] && + resolve(process.argv[1]) === fileURLToPath(import.meta.url) +) { + try { + const [edition, ...extra] = process.argv.slice(2) + + if ( + extra.length || + !['frontend', 'fullstack', '--check'].includes(edition) + ) { + throw new Error( + 'Usage: node scripts/distributions.mjs ', + ) + } + + if (edition === '--check') { + for (const result of checkDistributions()) { + console.log( + `Verified ${result.edition}: ${result.workspaces} workspaces, ${result.files} source files.`, + ) + } + } else { + const result = await exportDistribution(repository, edition) + + console.log( + `Exported ${portable(relative(repository, result.directory))}`, + ) + console.log(`Archive: ${portable(relative(repository, result.archive))}`) + } + } catch (error) { + console.error(error.message) + process.exitCode = 1 + } +} diff --git a/scripts/fullstack.mjs b/scripts/fullstack.mjs new file mode 100644 index 00000000..95753bbf --- /dev/null +++ b/scripts/fullstack.mjs @@ -0,0 +1,330 @@ +import { spawn } from 'node:child_process' +import { randomBytes } from 'node:crypto' +import { existsSync, readFileSync, writeFileSync } from 'node:fs' +import { createServer } from 'node:net' +import { setTimeout as delay } from 'node:timers/promises' +import { fileURLToPath } from 'node:url' +import { parseEnv } from 'node:util' + +const root = fileURLToPath(new URL('../', import.meta.url)) +const envFile = new URL('../apps/server/.env.local', import.meta.url) +const pnpm = process.platform === 'win32' ? 'pnpm.cmd' : 'pnpm' +const [action, ...flags] = process.argv.slice(2) + +if ( + !['setup', 'dev', 'stop'].includes(action) || + (flags.length > 0 && (action !== 'setup' || flags.join(' ') !== '--external')) +) { + console.error( + 'Use pnpm fullstack:setup [--external], pnpm dev:full, or pnpm fullstack:stop.', + ) + process.exit(1) +} + +function run(command, args, env = process.env) { + return new Promise((resolve, reject) => { + const child = spawn(command, args, { + cwd: root, + env, + stdio: 'inherit', + shell: process.platform === 'win32' && command === pnpm, + }) + + child.once('error', () => + reject( + new Error( + `${command} could not start. Install it or use pnpm fullstack:setup --external with existing PostgreSQL and Redis.`, + ), + ), + ) + child.once('exit', (code) => + code === 0 + ? resolve() + : reject(new Error(`${command} exited with code ${code}.`)), + ) + }) +} + +function configuration() { + if (!existsSync(envFile)) + throw new Error( + 'Run pnpm fullstack:setup first (or pnpm fullstack:setup --external with DATABASE_URL and REDIS_URL).', + ) + + return { ...parseEnv(readFileSync(envFile, 'utf8')), ...process.env } +} + +const compose = [ + 'compose', + '--project-name', + 'ray-template', + '--env-file', + fileURLToPath(envFile), + '-f', + 'deploy/compose.yaml', +] + +function portFrom(env, key, fallback) { + const port = env[key] ?? fallback + + if (!/^\d{1,5}$/u.test(port) || Number(port) < 1 || Number(port) > 65535) + throw new Error(`${key} must be a port between 1 and 65535.`) + + return String(Number(port)) +} + +const devOrigins = (port) => [ + new URL(`http://127.0.0.1:${port}`).origin, + new URL(`http://localhost:${port}`).origin, +] + +async function verifyBackendPort(port) { + await new Promise((resolve, reject) => { + const probe = createServer() + + probe.once('error', () => + reject(new Error(`Backend port ${port} is not available on 127.0.0.1.`)), + ) + probe.listen(Number(port), '127.0.0.1', () => probe.close(resolve)) + }) +} + +async function dev(env) { + const port = portFrom(env, 'PORT', '3000') + const adminPort = portFrom(env, 'ADMIN_DEV_PORT', '9527') + + if (port === adminPort) + throw new Error('PORT and ADMIN_DEV_PORT must differ.') + + await verifyBackendPort(port) + + const target = `http://127.0.0.1:${port}` + const serverEnv = { + ...env, + HOST: '127.0.0.1', + PORT: port, + CORS_ORIGINS: [ + ...new Set([ + ...(env.CORS_ORIGINS?.split(',') + .map((value) => value.trim()) + .filter(Boolean) ?? []), + ...devOrigins(adminPort), + ]), + ].join(','), + } + const controller = new AbortController() + const { signal } = controller + const children = new Set() + const windows = process.platform === 'win32' + + const terminate = (child, killSignal) => { + if (!child.pid) return + + if (windows) { + const killer = spawn( + 'taskkill', + ['/pid', String(child.pid), '/t', '/f'], + { + stdio: 'ignore', + }, + ) + + killer.once('error', () => child.kill()) + + return + } + + try { + process.kill(-child.pid, killSignal) + } catch (error) { + if (error.code !== 'ESRCH') throw error + } + } + const stop = (reason) => { + if (signal.aborted) return + + controller.abort() + + if (reason) { + console.error(reason) + process.exitCode = 1 + } + + const running = [...children] + + for (const child of running) terminate(child, 'SIGTERM') + + if (running.length && !windows) { + setTimeout(() => { + for (const child of running) terminate(child, 'SIGKILL') + }, 6000).unref() + } + } + const start = (label, args, processEnv, persistent = false) => + new Promise((resolve) => { + // pnpm 会再启动脚本进程,退出时需要回收完整进程树。 + const child = spawn(pnpm, args, { + cwd: root, + env: processEnv, + stdio: 'inherit', + detached: !windows, + shell: windows, + }) + + children.add(child) + const finish = (code) => { + if (!signal.aborted && (persistent || code !== 0)) + stop(`${label} stopped unexpectedly.`) + + children.delete(child) + resolve() + } + + child.once('error', () => finish(1)) + child.once('exit', finish) + }) + const interrupt = () => stop() + + process.on('SIGINT', interrupt) + process.on('SIGTERM', interrupt) + + try { + await start( + 'Prisma generation', + ['--filter', '@ray-template/server', 'db:generate'], + serverEnv, + ) + + if (signal.aborted) return + + const backend = start('Backend', ['server:dev'], serverEnv, true) + let ready = false + const deadline = Date.now() + 30000 + + while (!signal.aborted && Date.now() < deadline) { + try { + const response = await fetch(`${target}/api/health/ready`, { + signal: AbortSignal.any([signal, AbortSignal.timeout(1000)]), + }) + + if (response.ok) { + ready = true + break + } + } catch { + /* 启动时允许后端尚未监听。 */ + } + + await delay(300, void 0, { signal }).catch(() => {}) + } + + if (!ready || signal.aborted) { + if (!signal.aborted) + stop('Backend readiness timed out. Check PostgreSQL and Redis.') + + await backend + + return + } + + await Promise.all([ + backend, + start( + 'Admin', + ['dev', '--port', adminPort, '--strictPort'], + { + ...process.env, + VITE_API_MOCK: 'false', + VITE_API_BASE_URL: '/api/', + RAY_API_PROXY_TARGET: target, + }, + true, + ), + ]) + } finally { + process.off('SIGINT', interrupt) + process.off('SIGTERM', interrupt) + } +} + +try { + if (action === 'setup') { + const external = flags.includes('--external') + + if (!existsSync(envFile)) { + if (external && (!process.env.DATABASE_URL || !process.env.REDIS_URL)) + throw new Error('External setup requires DATABASE_URL and REDIS_URL.') + + const password = randomBytes(24).toString('base64url') + const redisPassword = randomBytes(24).toString('base64url') + const postgresPort = portFrom(process.env, 'POSTGRES_PORT', '5432') + const redisPort = portFrom(process.env, 'REDIS_PORT', '6379') + const adminPort = portFrom(process.env, 'ADMIN_DEV_PORT', '9527') + const values = { + NODE_ENV: 'development', + HOST: '127.0.0.1', + PORT: portFrom(process.env, 'PORT', '3000'), + ADMIN_DEV_PORT: adminPort, + POSTGRES_USER: 'ray', + POSTGRES_DB: 'ray_template', + POSTGRES_PASSWORD: password, + POSTGRES_PORT: postgresPort, + REDIS_PASSWORD: redisPassword, + REDIS_PORT: redisPort, + DATABASE_URL: external + ? process.env.DATABASE_URL + : `postgresql://ray:${password}@127.0.0.1:${postgresPort}/ray_template`, + REDIS_URL: external + ? process.env.REDIS_URL + : `redis://:${redisPassword}@127.0.0.1:${redisPort}`, + ADMIN_USERNAME: process.env.ADMIN_USERNAME || 'admin', + ADMIN_EMAIL: process.env.ADMIN_EMAIL || 'admin@example.com', + ADMIN_PASSWORD: + process.env.ADMIN_PASSWORD || randomBytes(18).toString('base64url'), + CORS_ORIGINS: devOrigins(adminPort).join(','), + TRUST_PROXY: 'false', + DEMO_ENABLED: 'true', + } + + // 配置只创建一次,避免重复初始化覆盖用户配置和已修改的凭据。 + writeFileSync( + envFile, + Object.entries(values) + .map(([key, value]) => `${key}=${JSON.stringify(value)}`) + .join('\n') + '\n', + { flag: 'wx', mode: 0o600 }, + ) + console.log( + 'Created apps/server/.env.local. Initial administrator credentials are stored there; keep this file private.', + ) + } + + const env = configuration() + + if (!external) + await run( + 'docker', + [...compose, 'up', '-d', '--wait', 'postgres', 'redis'], + env, + ) + + await run(pnpm, ['server:db:migrate'], env) + await run(pnpm, ['server:db:seed'], env) + console.log( + 'Fullstack setup complete. Run pnpm dev:full; use the administrator account from apps/server/.env.local.', + ) + } else if (action === 'stop') { + await run( + 'docker', + [...compose, '--profile', 'app', 'stop'], + configuration(), + ) + } else { + await dev(configuration()) + } +} catch (error) { + console.error( + error instanceof Error ? error.message : 'Fullstack command failed.', + ) + process.exitCode = 1 +} diff --git a/scripts/sync-frontend.sh b/scripts/sync-frontend.sh new file mode 100644 index 00000000..ce80a2a6 --- /dev/null +++ b/scripts/sync-frontend.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +set -euo pipefail + +directory=$(cd "${1:?Provide the extracted frontend distribution}" && pwd -P) +source=$(git rev-parse HEAD) +git_dir=$(git rev-parse --absolute-git-dir) +ref=refs/heads/frontend + +node -e ' + const { readFileSync } = require("node:fs") + const manifest = JSON.parse(readFileSync(process.argv[1], "utf8")) + if (manifest.generatedBy !== "ray-template/distributions" || + manifest.edition !== "frontend" || + manifest.source?.dirty !== false || + manifest.source.commit !== process.argv[2]) + throw new Error("Use a clean frontend distribution generated from this checkout.") +' "$directory/distribution.json" "$source" + +scratch=$(mktemp -d) +trap 'rm -rf "$scratch"' EXIT +export GIT_INDEX_FILE="$scratch/index" +tree=$( + cd "$directory" + git --git-dir="$git_dir" --work-tree="$directory" add --force --all -- . + git --git-dir="$git_dir" write-tree +) +commit_args=("$tree" -m "chore(distributions): generate frontend from $source") +remote_tip=$(git ls-remote --heads origin "$ref") +if [[ -n "$remote_tip" ]]; then + git fetch --no-tags origin "$ref" + tip=$(git rev-parse FETCH_HEAD) + previous=$(git show "$tip:distribution.json" | node -e ' + const manifest = JSON.parse(require("node:fs").readFileSync(0, "utf8")) + if (manifest.generatedBy !== "ray-template/distributions" || + manifest.edition !== "frontend" || + manifest.source?.dirty !== false || + !/^[0-9a-f]{40}$/.test(manifest.source.commit)) + throw new Error("The existing frontend branch is not a generated distribution.") + process.stdout.write(manifest.source.commit) + ') + [[ "$(git show -s --format=%s "$tip")" == "chore(distributions): generate frontend from $previous" ]] || + { echo "The existing frontend tip was not generated by this script." >&2; exit 1; } + git merge-base --is-ancestor "$previous" "$source" + if [[ "$(git rev-parse "$tip^{tree}")" == "$tree" ]]; then + echo "Frontend branch already matches the generated source." + exit 0 + fi + commit_args+=(-p "$tip") +fi + +commit=$(git commit-tree "${commit_args[@]}") +git push origin "$commit:$ref" diff --git a/tsconfig.universal.json b/tsconfig.universal.json new file mode 100644 index 00000000..a920f363 --- /dev/null +++ b/tsconfig.universal.json @@ -0,0 +1,13 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "lib": ["ESNext"], + "types": ["node"], + "paths": {}, + "tsBuildInfoFile": "./node_modules/.cache/ray-template/tsconfig.universal.tsbuildinfo" + }, + "include": [ + "packages/api-contracts/src/**/*.ts", + "packages/demo-data/src/**/*.ts" + ] +} diff --git a/vite.config.ts b/vite.config.ts index d9c2ad01..e83e7b5b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -103,6 +103,9 @@ export default defineConfig(({ mode }) => { }, server: { ...server, + ...(process.env.RAY_API_PROXY_TARGET + ? { proxy: { '/api/': { target: process.env.RAY_API_PROXY_TARGET } } } + : {}), }, } })