From 8c8ebae6b7db7e3bb8dd9a779a2fa2e773600aa1 Mon Sep 17 00:00:00 2001 From: Sunwuyuan Date: Sun, 1 Feb 2026 20:08:13 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=81=E7=A7=BB=E5=88=B0postgresql=EF=BC=88?= =?UTF-8?q?=E5=8F=B9=E6=B0=94=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 4 - .idea/.gitignore | 8 + .idea/FixClassworksKV.iml | 12 + .idea/modules.xml | 8 + .idea/vcs.xml | 6 + API_AUTOAUTH.md | 276 +++ API_QUICK_REFERENCE.md | 0 Dockerfile | 2 +- MIGRATION_CHECKLIST.md | 129 ++ NEW_APIS_SUMMARY.md | 0 REFRESH_TOKEN_API.md | 489 ++++ REFRESH_TOKEN_QUICKSTART.md | 112 + REFRESH_TOKEN_SUMMARY.md | 174 ++ SOCKET_API.md | 565 +++++ config/oauth.js | 6 +- docker/schema.prisma | 91 + generated/prisma/browser.ts | 44 + generated/prisma/client.ts | 66 + generated/prisma/commonInputTypes.ts | 502 +++++ generated/prisma/enums.ts | 15 + generated/prisma/internal/class.ts | 232 ++ generated/prisma/internal/prismaNamespace.ts | 1186 ++++++++++ .../prisma/internal/prismaNamespaceBrowser.ts | 197 ++ generated/prisma/models.ts | 16 + generated/prisma/models/Account.ts | 1648 ++++++++++++++ generated/prisma/models/AppInstall.ts | 1528 +++++++++++++ generated/prisma/models/AutoAuth.ts | 1460 ++++++++++++ generated/prisma/models/Device.ts | 1972 +++++++++++++++++ generated/prisma/models/KVStore.ts | 1419 ++++++++++++ middleware/device.js | 17 +- middleware/jwt-auth.js | 2 +- middleware/kvTokenAuth.js | 7 +- middleware/uuidAuth.js | 7 +- package-lock.json | 4 +- package.json | 3 +- prisma/migrations/0_init/migration.sql | 98 +- .../migration.sql | 19 - .../migration.sql | 14 + prisma/schema.prisma | 111 +- routes/accounts.js | 66 +- routes/apps.js | 78 +- routes/auto-auth.js | 70 +- routes/device-auth.js | 6 +- routes/device.js | 24 +- routes/kv-token.js | 72 +- utils/deviceCodeStore.js | 6 +- utils/jwt.js | 2 +- utils/kvStore.js | 174 +- utils/metrics.js | 3 +- utils/siteinfo.js | 10 +- utils/socket.js | 36 +- utils/tokenManager.js | 62 +- 52 files changed, 12603 insertions(+), 455 deletions(-) create mode 100644 .idea/.gitignore create mode 100644 .idea/FixClassworksKV.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 API_AUTOAUTH.md create mode 100644 API_QUICK_REFERENCE.md create mode 100644 MIGRATION_CHECKLIST.md create mode 100644 NEW_APIS_SUMMARY.md create mode 100644 REFRESH_TOKEN_API.md create mode 100644 REFRESH_TOKEN_QUICKSTART.md create mode 100644 REFRESH_TOKEN_SUMMARY.md create mode 100644 SOCKET_API.md create mode 100644 docker/schema.prisma create mode 100644 generated/prisma/browser.ts create mode 100644 generated/prisma/client.ts create mode 100644 generated/prisma/commonInputTypes.ts create mode 100644 generated/prisma/enums.ts create mode 100644 generated/prisma/internal/class.ts create mode 100644 generated/prisma/internal/prismaNamespace.ts create mode 100644 generated/prisma/internal/prismaNamespaceBrowser.ts create mode 100644 generated/prisma/models.ts create mode 100644 generated/prisma/models/Account.ts create mode 100644 generated/prisma/models/AppInstall.ts create mode 100644 generated/prisma/models/AutoAuth.ts create mode 100644 generated/prisma/models/Device.ts create mode 100644 generated/prisma/models/KVStore.ts delete mode 100644 prisma/migrations/20260201105825_fix_timestamp_defaults/migration.sql create mode 100644 prisma/migrations/20260201120205_fix_timestamp_defaults/migration.sql diff --git a/.gitignore b/.gitignore index df5de01..d23defa 100644 --- a/.gitignore +++ b/.gitignore @@ -145,7 +145,3 @@ dist prisma/database/data data/ - -/generated/prisma - -/generated/prisma diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/FixClassworksKV.iml b/.idea/FixClassworksKV.iml new file mode 100644 index 0000000..24643cc --- /dev/null +++ b/.idea/FixClassworksKV.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..09fff6f --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/API_AUTOAUTH.md b/API_AUTOAUTH.md new file mode 100644 index 0000000..7b73c17 --- /dev/null +++ b/API_AUTOAUTH.md @@ -0,0 +1,276 @@ +# AutoAuth 和新增 Apps API 文档 + +## 概述 + +本文档描述了自动授权 (AutoAuth) 相关的 API 接口以及新增的应用管理接口。 + +--- + +## Apps API 新增接口 + +### 1. 通过 namespace 和密码获取 token + +**端点**: `POST /apps/auth/token` + +**描述**: 通过设备的 namespace 和密码进行自动授权,创建新的 AppInstall 并返回 token。 + +**请求体**: +```json +{ + "namespace": "string (必填)", + "password": "string (可选,根据自动授权配置)", + "appId": "string (必填)" +} +``` + +**成功响应** (201 Created): +```json +{ + "success": true, + "token": "string", + "deviceType": "string | null", + "isReadOnly": boolean, + "installedAt": "datetime" +} +``` + +**错误响应**: +- `400 Bad Request`: 缺少必填字段 +- `404 Not Found`: 设备不存在或 namespace 不正确 +- `401 Unauthorized`: 密码不正确或需要提供密码 + +**说明**: +- 该接口会查找匹配的 AutoAuth 配置 +- 如果提供了密码,会验证密码是否匹配任何自动授权配置 +- 如果没有提供密码,会查找无密码的自动授权配置 +- 根据匹配的 AutoAuth 配置设置 `deviceType` 和 `isReadOnly` 属性 + +--- + +### 2. 设置学生名称 + +**端点**: `POST /apps/tokens/:token/set-student-name` + +**描述**: 为学生类型的 token 设置名称(更新 note 字段)。 + +**URL 参数**: +- `token`: AppInstall 的 token + +**请求体**: +```json +{ + "name": "string (必填)" +} +``` + +**成功响应** (200 OK): +```json +{ + "success": true, + "token": "string", + "name": "string", + "updatedAt": "datetime" +} +``` + +**错误响应**: +- `400 Bad Request`: 缺少名称或名称不在学生列表中 +- `403 Forbidden`: token 类型不是 student +- `404 Not Found`: token 不存在或设备未设置学生列表 + +**说明**: +- 只有 `deviceType` 为 `student` 的 token 才能使用此接口 +- 会验证提供的名称是否存在于设备的 `classworks-list-main` 键值中 +- 学生列表格式: `[{"id": 1, "name": "学生1"}, {"id": 2, "name": "学生2"}]` + +--- + +## AutoAuth 管理 API + +> 🔐 **所有 AutoAuth 管理接口都需要 JWT Account Token 认证** +> +> **重要**: 只有已绑定账户的设备才能使用这些接口。未绑定账户的设备无法管理 AutoAuth 配置。 +> +> 通过 HTTP Headers 提供: +> - `Authorization`: `Bearer {jwt_token}` - 账户的 JWT Token + +### 1. 获取设备的自动授权配置列表 + +**端点**: `GET /auto-auth/devices/:uuid/auth-configs` + +**认证**: 需要 JWT Token (账户必须是设备的拥有者) + +**URL 参数**: +- `uuid`: 设备的 UUID + +**成功响应** (200 OK): +```json +{ + "success": true, + "configs": [ + { + "id": "string", + "hasPassword": boolean, + "deviceType": "string | null", + "isReadOnly": boolean, + "createdAt": "datetime", + "updatedAt": "datetime" + } + ] +} +``` + +**说明**: +- 返回的配置不包含实际的密码哈希值,只显示是否有密码 + +--- + +### 2. 创建自动授权配置 + +**端点**: `POST /auto-auth/devices/:uuid/auth-configs` + +**认证**: 需要 JWT Token (账户必须是设备的拥有者) + +**URL 参数**: +- `uuid`: 设备的 UUID + +**请求体**: +```json +{ + "password": "string (可选)", + "deviceType": "string (可选: teacher|student|classroom|parent)", + "isReadOnly": boolean (可选,默认 false) +} +``` + +**成功响应** (201 Created): +```json +{ + "success": true, + "config": { + "id": "string", + "hasPassword": boolean, + "deviceType": "string | null", + "isReadOnly": boolean, + "createdAt": "datetime" + } +} +``` + +**错误响应**: +- `400 Bad Request`: 设备类型无效或密码配置已存在 + +**说明**: +- 同一设备的密码必须唯一(包括空密码) +- `deviceType` 必须是 `teacher`、`student`、`classroom`、`parent` 之一,或为空 + +--- + +### 3. 更新自动授权配置 + +**端点**: `PUT /auto-auth/devices/:uuid/auth-configs/:configId` + +**认证**: 需要 JWT Token (账户必须是设备的拥有者) + +**URL 参数**: +- `uuid`: 设备的 UUID +- `configId`: 自动授权配置的 ID + +**请求体**: +```json +{ + "password": "string (可选)", + "deviceType": "string (可选: teacher|student|classroom|parent)", + "isReadOnly": boolean (可选) +} +``` + +**成功响应** (200 OK): +```json +{ + "success": true, + "config": { + "id": "string", + "hasPassword": boolean, + "deviceType": "string | null", + "isReadOnly": boolean, + "updatedAt": "datetime" + } +} +``` + +**错误响应**: +- `400 Bad Request`: 设备类型无效或新密码与其他配置冲突 +- `403 Forbidden`: 无权操作此配置 +- `404 Not Found`: 配置不存在 + +**说明**: +- 只能更新属于当前设备的配置 +- 更新密码时会检查是否与该设备的其他配置冲突 + +--- + +### 4. 删除自动授权配置 + +**端点**: `DELETE /auto-auth/devices/:uuid/auth-configs/:configId` + +**认证**: 需要 JWT Token (账户必须是设备的拥有者) + +**URL 参数**: +- `uuid`: 设备的 UUID +- `configId`: 自动授权配置的 ID + +**成功响应** (204 No Content): +- 无响应体 + +**错误响应**: +- `403 Forbidden`: 无权操作此配置 +- `404 Not Found`: 配置不存在 + +**说明**: +- 只能删除属于当前设备的配置 + +--- + +## 设备类型 (deviceType) + +可选的设备类型值: +- `teacher`: 教师 +- `student`: 学生 +- `classroom`: 班级一体机 +- `parent`: 家长 +- `null`: 未指定类型 + +--- + +## 使用流程示例 + +### 场景 1: 学生使用 namespace 登录 + +1. 学生输入班级的 namespace 和密码 +2. 调用 `POST /apps/auth/token` 获取 token +3. 使用返回的 token 访问 KV 存储 +4. 如果是学生类型,调用 `POST /apps/tokens/:token/set-student-name` 设置自己的名称 + +### 场景 2: 管理员配置自动授权 + +1. 管理员通过账户登录获取 JWT Token +2. 调用 `POST /auto-auth/devices/:uuid/auth-configs` 创建多个授权配置: + - 教师密码(deviceType: teacher, isReadOnly: false) + - 学生密码(deviceType: student, isReadOnly: false) + - 家长密码(deviceType: parent, isReadOnly: true) +3. 学生/教师/家长使用对应密码通过 namespace 登录 + +**注意**: 设备必须已绑定到管理员的账户才能配置 AutoAuth + +--- + +## 注意事项 + +1. **密码安全**: 所有密码都使用 bcrypt 进行哈希存储 +2. **唯一性约束**: + - 同一设备的 namespace 必须唯一 + - 同一设备的 AutoAuth 密码必须唯一(包括 null) +3. **级联删除**: 删除设备会级联删除所有相关的 AutoAuth 配置和 AppInstall 记录 +4. **只读限制**: isReadOnly 为 true 的 token 在 KV 操作中会受到写入限制 +5. **账户绑定要求**: 只有已绑定账户的设备才能管理 AutoAuth 配置,未绑定账户的设备无法使用 AutoAuth 管理接口 diff --git a/API_QUICK_REFERENCE.md b/API_QUICK_REFERENCE.md new file mode 100644 index 0000000..e69de29 diff --git a/Dockerfile b/Dockerfile index f17a5a9..05be299 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:24-alpine +FROM node:22-alpine WORKDIR /app diff --git a/MIGRATION_CHECKLIST.md b/MIGRATION_CHECKLIST.md new file mode 100644 index 0000000..7fa6971 --- /dev/null +++ b/MIGRATION_CHECKLIST.md @@ -0,0 +1,129 @@ +# Refresh Token系统迁移检查清单 + +## 🔧 服务端迁移 + +### 数据库 +- [ ] 运行Prisma迁移: `npx prisma migrate dev --name add_refresh_token_system` +- [ ] 验证Account表新增字段: refreshToken, refreshTokenExpiry, tokenVersion + +### 环境配置 +- [ ] 添加 `ACCESS_TOKEN_EXPIRES_IN=15m` +- [ ] 添加 `REFRESH_TOKEN_EXPIRES_IN=7d` +- [ ] 添加 `REFRESH_TOKEN_SECRET=your-refresh-token-secret` +- [ ] (可选)配置RSA密钥对 + +### 代码验证 +- [ ] `utils/tokenManager.js` 文件已创建 +- [ ] `utils/jwt.js` 已更新(保持向后兼容) +- [ ] `middleware/jwt-auth.js` 已升级 +- [ ] `routes/accounts.js` 新增refresh相关端点 + +## 🖥️ 前端迁移 + +### OAuth回调处理 +- [ ] 更新回调URL参数解析(支持access_token和refresh_token) +- [ ] 保持对旧版token参数的兼容性 +- [ ] 实现TokenManager类 + +### Token管理 +- [ ] 实现Token刷新逻辑 +- [ ] 添加请求拦截器检查X-New-Access-Token响应头 +- [ ] 实现401错误自动重试机制 +- [ ] 添加登出功能(单设备/全设备) + +### 存储策略 +- [ ] Access Token存储(localStorage/sessionStorage) +- [ ] Refresh Token安全存储 +- [ ] 实现Token清理逻辑 + +## 🧪 测试验证 + +### 功能测试 +- [ ] OAuth登录流程测试 +- [ ] Token自动刷新测试 +- [ ] 手动refresh接口测试 +- [ ] 登出功能测试(单设备) +- [ ] 登出功能测试(全设备) +- [ ] Token信息查看测试 + +### 兼容性测试 +- [ ] 旧版JWT token仍然有效 +- [ ] 新旧token混合使用场景 +- [ ] API向后兼容性验证 + +### 错误处理测试 +- [ ] 过期token处理 +- [ ] 无效refresh token处理 +- [ ] 网络错误重试 +- [ ] 并发刷新场景 + +## 📊 监控配置 + +### 日志记录 +- [ ] Token生成日志 +- [ ] Token刷新日志 +- [ ] 认证失败日志 +- [ ] 登出操作日志 + +### 性能监控 +- [ ] Token刷新频率统计 +- [ ] API响应时间监控 +- [ ] 数据库查询性能 + +## 🔒 安全检查 + +### Token安全 +- [ ] 密钥强度验证 +- [ ] Token过期时间配置合理 +- [ ] HTTPS传输确认 +- [ ] 敏感信息不在日志中暴露 + +### 访问控制 +- [ ] Token撤销功能正常 +- [ ] 版本控制机制有效 +- [ ] 设备隔离正确 + +## 📚 文档检查 + +- [ ] API文档已更新 +- [ ] 前端集成指南已提供 +- [ ] 迁移步骤文档完整 +- [ ] 错误处理指南清晰 + +## 🚀 上线准备 + +### 部署前 +- [ ] 代码review完成 +- [ ] 单元测试通过 +- [ ] 集成测试通过 +- [ ] 性能测试通过 + +### 部署时 +- [ ] 数据库迁移执行 +- [ ] 环境变量配置 +- [ ] 服务重启验证 +- [ ] 健康检查通过 + +### 部署后 +- [ ] 新用户登录测试 +- [ ] 现有用户功能正常 +- [ ] 监控指标正常 +- [ ] 错误日志检查 + +## 🔄 回滚计划 + +### 紧急回滚 +- [ ] 回滚代码到上一版本 +- [ ] 恢复原环境变量 +- [ ] 数据库回滚方案(如需要) + +### 数据迁移回滚 +- [ ] 备份新增字段数据 +- [ ] 移除新增字段的迁移脚本 +- [ ] 验证旧版功能正常 + +--- + +**检查完成人员**: ___________ +**检查完成时间**: ___________ +**环境**: [ ] 开发 [ ] 测试 [ ] 生产 \ No newline at end of file diff --git a/NEW_APIS_SUMMARY.md b/NEW_APIS_SUMMARY.md new file mode 100644 index 0000000..e69de29 diff --git a/REFRESH_TOKEN_API.md b/REFRESH_TOKEN_API.md new file mode 100644 index 0000000..44c1929 --- /dev/null +++ b/REFRESH_TOKEN_API.md @@ -0,0 +1,489 @@ +# Refresh Token系统API文档 + +## 概述 + +ClassworksKV现在支持标准的Refresh Token认证系统,提供更安全的用户认证机制。新系统包含: + +- **Access Token**: 短期令牌(默认15分钟),用于API访问 +- **Refresh Token**: 长期令牌(默认7天),用于刷新Access Token +- **Token版本控制**: 支持令牌失效和安全登出 +- **向后兼容**: 支持旧版JWT令牌 + +## 配置选项 + +可以通过环境变量配置token系统: + +```bash +# Access Token配置 +ACCESS_TOKEN_EXPIRES_IN=15m # Access Token过期时间 +REFRESH_TOKEN_EXPIRES_IN=7d # Refresh Token过期时间 + +# 密钥配置(HS256算法) +JWT_SECRET=your-access-token-secret +REFRESH_TOKEN_SECRET=your-refresh-token-secret + +# RSA密钥配置(RS256算法,可选) +JWT_ALG=RS256 +ACCESS_TOKEN_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..." +ACCESS_TOKEN_PUBLIC_KEY="-----BEGIN RSA PUBLIC KEY-----\n..." +REFRESH_TOKEN_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..." +REFRESH_TOKEN_PUBLIC_KEY="-----BEGIN RSA PUBLIC KEY-----\n..." +``` + +## API端点 + +### 1. OAuth登录回调 + +OAuth登录成功后,系统会返回令牌对。 + +**回调URL参数(新版):** +``` +https://your-frontend.com/?access_token=eyJ...&refresh_token=eyJ...&expires_in=15m&success=true&provider=github +``` + +**旧版兼容参数:** +``` +https://your-frontend.com/?token=eyJ...&success=true&provider=github +``` + +### 2. 刷新访问令牌 + +当Access Token即将过期或已过期时,使用Refresh Token获取新的Access Token。 + +**端点:** `POST /api/accounts/refresh` + +**请求体:** +```json +{ + "refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..." +} +``` + +**响应(成功):** +```json +{ + "success": true, + "message": "令牌刷新成功", + "data": { + "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...", + "expires_in": "15m", + "account": { + "id": "clxxxx", + "provider": "github", + "email": "user@example.com", + "name": "User Name", + "avatarUrl": "https://..." + } + } +} +``` + +**错误响应:** +```json +{ + "success": false, + "message": "刷新令牌已过期" +} +``` + +**错误状态码:** +- `400`: 缺少刷新令牌 +- `401`: 无效的刷新令牌、令牌已过期、账户不存在、令牌版本不匹配 + +### 3. 登出(当前设备) + +撤销当前设备的Refresh Token,但不影响其他设备。 + +**端点:** `POST /api/accounts/logout` + +**请求头:** +``` +Authorization: Bearer +``` + +**响应:** +```json +{ + "success": true, + "message": "登出成功" +} +``` + +### 4. 登出所有设备 + +撤销账户的所有令牌,强制所有设备重新登录。 + +**端点:** `POST /api/accounts/logout-all` + +**请求头:** +``` +Authorization: Bearer +``` + +**响应:** +```json +{ + "success": true, + "message": "已从所有设备登出" +} +``` + +### 5. 获取令牌信息 + +查看当前令牌的详细信息和状态。 + +**端点:** `GET /api/accounts/token-info` + +**请求头:** +``` +Authorization: Bearer +``` + +**响应:** +```json +{ + "success": true, + "data": { + "accountId": "clxxxx", + "tokenType": "access", + "tokenVersion": 1, + "issuedAt": "2024-11-01T08:00:00.000Z", + "expiresAt": "2024-11-01T08:15:00.000Z", + "expiresIn": 900, + "isExpired": false, + "isLegacyToken": false, + "hasRefreshToken": true, + "refreshTokenExpiry": "2024-11-08T08:00:00.000Z" + } +} +``` + +## 自动刷新机制 + +### 响应头刷新 + +当Access Token剩余有效期少于5分钟时,系统会在响应头中提供新的Access Token: + +**响应头:** +``` +X-New-Access-Token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... +X-Token-Refreshed: true +``` + +前端应检查这些响应头并更新本地存储的token。 + +## 前端集成示例 + +### JavaScript/TypeScript + +```javascript +class TokenManager { + constructor() { + this.accessToken = localStorage.getItem('access_token'); + this.refreshToken = localStorage.getItem('refresh_token'); + } + + // 设置令牌对 + setTokens(accessToken, refreshToken) { + this.accessToken = accessToken; + this.refreshToken = refreshToken; + localStorage.setItem('access_token', accessToken); + localStorage.setItem('refresh_token', refreshToken); + } + + // 清除令牌 + clearTokens() { + this.accessToken = null; + this.refreshToken = null; + localStorage.removeItem('access_token'); + localStorage.removeItem('refresh_token'); + } + + // 刷新访问令牌 + async refreshAccessToken() { + if (!this.refreshToken) { + throw new Error('No refresh token available'); + } + + try { + const response = await fetch('/api/accounts/refresh', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ + refresh_token: this.refreshToken + }), + }); + + const data = await response.json(); + + if (data.success) { + this.accessToken = data.data.access_token; + localStorage.setItem('access_token', this.accessToken); + return this.accessToken; + } else { + throw new Error(data.message); + } + } catch (error) { + this.clearTokens(); + throw error; + } + } + + // API请求拦截器 + async request(url, options = {}) { + const headers = { + 'Authorization': `Bearer ${this.accessToken}`, + 'Content-Type': 'application/json', + ...options.headers, + }; + + const response = await fetch(url, { + ...options, + headers, + }); + + // 检查是否有新的访问令牌 + const newAccessToken = response.headers.get('X-New-Access-Token'); + if (newAccessToken) { + this.accessToken = newAccessToken; + localStorage.setItem('access_token', newAccessToken); + } + + // 如果token过期,尝试刷新 + if (response.status === 401) { + try { + await this.refreshAccessToken(); + // 重试请求 + return this.request(url, options); + } catch (refreshError) { + // 刷新失败,重定向到登录页 + window.location.href = '/login'; + throw refreshError; + } + } + + return response; + } + + // 登出 + async logout() { + try { + await this.request('/api/accounts/logout', { + method: 'POST', + }); + } catch (error) { + console.error('Logout error:', error); + } finally { + this.clearTokens(); + window.location.href = '/login'; + } + } + + // 登出所有设备 + async logoutAll() { + try { + await this.request('/api/accounts/logout-all', { + method: 'POST', + }); + } catch (error) { + console.error('Logout all error:', error); + } finally { + this.clearTokens(); + window.location.href = '/login'; + } + } +} + +// 使用示例 +const tokenManager = new TokenManager(); + +// OAuth回调处理 +function handleOAuthCallback() { + const params = new URLSearchParams(window.location.search); + const accessToken = params.get('access_token'); + const refreshToken = params.get('refresh_token'); + + if (accessToken && refreshToken) { + tokenManager.setTokens(accessToken, refreshToken); + // 重定向到应用主页 + window.location.href = '/dashboard'; + } else { + // 处理旧版回调 + const legacyToken = params.get('token'); + if (legacyToken) { + tokenManager.setTokens(legacyToken, null); + window.location.href = '/dashboard'; + } + } +} + +// API调用示例 +async function getUserProfile() { + try { + const response = await tokenManager.request('/api/accounts/profile'); + const data = await response.json(); + return data; + } catch (error) { + console.error('Failed to get user profile:', error); + throw error; + } +} +``` + +### React Hook + +```jsx +import { useState, useCallback, useEffect } from 'react'; + +export function useAuth() { + const [isAuthenticated, setIsAuthenticated] = useState(false); + const [user, setUser] = useState(null); + const [loading, setLoading] = useState(true); + + const tokenManager = new TokenManager(); + + const checkAuth = useCallback(async () => { + if (!tokenManager.accessToken) { + setIsAuthenticated(false); + setLoading(false); + return; + } + + try { + const response = await tokenManager.request('/api/accounts/profile'); + const data = await response.json(); + + if (data.success) { + setUser(data.data); + setIsAuthenticated(true); + } else { + setIsAuthenticated(false); + } + } catch (error) { + setIsAuthenticated(false); + } finally { + setLoading(false); + } + }, []); + + useEffect(() => { + checkAuth(); + }, [checkAuth]); + + const login = useCallback((accessToken, refreshToken) => { + tokenManager.setTokens(accessToken, refreshToken); + setIsAuthenticated(true); + checkAuth(); + }, [checkAuth]); + + const logout = useCallback(async () => { + await tokenManager.logout(); + setIsAuthenticated(false); + setUser(null); + }, []); + + return { + isAuthenticated, + user, + loading, + login, + logout, + tokenManager, + }; +} +``` + +## 安全考虑 + +### 1. Token存储 +- **Access Token**: 可以存储在内存或localStorage中 +- **Refresh Token**: 建议存储在httpOnly cookie中(需要后端支持),或者安全的本地存储 + +### 2. HTTPS +- 生产环境必须使用HTTPS传输令牌 + +### 3. Token轮换 +- 系统支持令牌版本控制,可以快速失效所有令牌 + +### 4. 过期时间 +- Access Token短期有效(15分钟) +- Refresh Token长期有效(7天) +- 可根据安全需求调整 + +## 迁移指南 + +### 从旧版JWT系统迁移 + +1. **前端更新**: + - 更新OAuth回调处理逻辑 + - 实现Token刷新机制 + - 处理新的响应头 + +2. **向后兼容**: + - 旧版JWT token仍然有效 + - 系统会在响应中标记`isLegacyToken: true` + - 建议用户重新登录获取新令牌 + +3. **数据库迁移**: + ```bash + # 运行Prisma迁移 + npm run prisma migrate dev --name add_refresh_token_support + ``` + +## 错误处理 + +### 常见错误 + +| 错误代码 | 错误信息 | 处理方式 | +|---------|---------|---------| +| 401 | JWT token已过期 | 使用refresh token刷新 | +| 401 | 无效的刷新令牌 | 重新登录 | +| 401 | 令牌版本不匹配 | 重新登录 | +| 401 | 账户不存在 | 重新登录 | + +### 错误处理流程 + +```mermaid +graph TD + A[API请求] --> B{Token有效?} + B -->|是| C[返回数据] + B -->|否,401错误| D{有Refresh Token?} + D -->|否| E[重定向登录] + D -->|是| F[尝试刷新Token] + F --> G{刷新成功?} + G -->|是| H[重试原请求] + G -->|否| E + H --> C +``` + +## 监控和日志 + +### 建议监控指标 + +- Token刷新频率 +- Token刷新失败率 +- 用户登出频率 +- 异常登录尝试 + +### 日志记录 + +系统会记录以下事件: +- Token生成 +- Token刷新 +- Token撤销 +- 认证失败 + +## 性能优化 + +### 1. Token缓存 +- 在内存中缓存已验证的token(适用于高并发场景) + +### 2. 数据库优化 +- 为`refreshToken`字段添加索引 +- 定期清理过期的refresh token + +### 3. 前端优化 +- 实现Token预刷新机制 +- 使用Web Workers处理Token逻辑 \ No newline at end of file diff --git a/REFRESH_TOKEN_QUICKSTART.md b/REFRESH_TOKEN_QUICKSTART.md new file mode 100644 index 0000000..2f96cf4 --- /dev/null +++ b/REFRESH_TOKEN_QUICKSTART.md @@ -0,0 +1,112 @@ +# Refresh Token系统 - 快速使用指南 + +## 🚀 快速开始 + +### 1. 环境变量配置 + +```bash +# 添加到 .env 文件 +ACCESS_TOKEN_EXPIRES_IN=15m +REFRESH_TOKEN_EXPIRES_IN=7d +REFRESH_TOKEN_SECRET=your-refresh-token-secret-change-this +``` + +### 2. 数据库迁移 + +```bash +npx prisma migrate dev --name add_refresh_token_system +``` + +### 3. 新的OAuth回调参数 + +登录成功后,回调URL现在包含: +``` +?access_token=eyJ...&refresh_token=eyJ...&expires_in=15m&success=true +``` + +## 📝 核心API + +### 刷新Token +```http +POST /api/accounts/refresh +Content-Type: application/json + +{ + "refresh_token": "eyJ..." +} +``` + +### 登出当前设备 +```http +POST /api/accounts/logout +Authorization: Bearer +``` + +### 登出所有设备 +```http +POST /api/accounts/logout-all +Authorization: Bearer +``` + +## 💻 前端集成 + +### 基础Token管理 +```javascript +class TokenManager { + setTokens(accessToken, refreshToken) { + localStorage.setItem('access_token', accessToken); + localStorage.setItem('refresh_token', refreshToken); + } + + async refreshToken() { + const refreshToken = localStorage.getItem('refresh_token'); + const response = await fetch('/api/accounts/refresh', { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ refresh_token: refreshToken }) + }); + + const data = await response.json(); + if (data.success) { + localStorage.setItem('access_token', data.data.access_token); + return data.data.access_token; + } + throw new Error(data.message); + } +} +``` + +### 自动刷新拦截器 +```javascript +// 检查响应头中的新token +const newToken = response.headers.get('X-New-Access-Token'); +if (newToken) { + localStorage.setItem('access_token', newToken); +} + +// 401错误时自动刷新 +if (response.status === 401) { + await tokenManager.refreshToken(); + // 重试请求 +} +``` + +## 🔒 安全特性 + +- ✅ 短期Access Token(15分钟) +- ✅ 长期Refresh Token(7天) +- ✅ Token版本控制 +- ✅ 设备级登出 +- ✅ 全局登出 +- ✅ 自动刷新机制 +- ✅ 向后兼容 + +## 🔄 迁移步骤 + +1. **更新环境变量** +2. **运行数据库迁移** +3. **更新前端OAuth回调处理** +4. **实现Token刷新逻辑** +5. **测试登出功能** + +详细文档请参考:`REFRESH_TOKEN_API.md` \ No newline at end of file diff --git a/REFRESH_TOKEN_SUMMARY.md b/REFRESH_TOKEN_SUMMARY.md new file mode 100644 index 0000000..36ef6f4 --- /dev/null +++ b/REFRESH_TOKEN_SUMMARY.md @@ -0,0 +1,174 @@ +# 账户登录密钥系统重构完成报告 + +## 📋 项目概述 + +已成功重构ClassworksKV的账户登录密钥系统,从单一JWT令牌升级为标准的Refresh Token系统,大幅提升了安全性和用户体验。 + +## ✅ 完成的工作 + +### 1. 数据库架构更新 +- 在`Account`模型中添加了`refreshToken`、`refreshTokenExpiry`和`tokenVersion`字段 +- 支持令牌版本控制,可快速失效所有设备的令牌 +- 向后兼容现有数据 + +### 2. 核心Token管理系统 +- **创建 `utils/tokenManager.js`**: 全新的令牌管理核心 + - 生成Access Token(15分钟有效期) + - 生成Refresh Token(7天有效期) + - 支持HS256和RS256算法 + - 令牌刷新和撤销功能 + - 安全验证机制 + +- **重构 `utils/jwt.js`**: 保持向后兼容性 + - 重新导出新的令牌管理功能 + - 保留旧版API供现有代码使用 + +### 3. 认证中间件升级 +- **更新 `middleware/jwt-auth.js`**: + - 支持新的Access Token验证 + - 自动检测即将过期的令牌并在响应头提供新令牌 + - 向后兼容旧版JWT令牌 + - 新增可选认证中间件 + +### 4. API端点扩展 +- **更新 `routes/accounts.js`**: + - OAuth回调现在返回令牌对(access_token + refresh_token) + - 新增 `/api/accounts/refresh` - 刷新访问令牌 + - 新增 `/api/accounts/logout` - 单设备登出 + - 新增 `/api/accounts/logout-all` - 全设备登出 + - 新增 `/api/accounts/token-info` - 查看令牌状态 + +### 5. 安全特性 +- **短期Access Token**: 默认15分钟,降低泄露风险 +- **长期Refresh Token**: 默认7天,用户体验友好 +- **令牌版本控制**: 支持立即失效所有设备的令牌 +- **自动刷新机制**: 在令牌即将过期时自动提供新令牌 +- **设备级管理**: 支持单设备或全设备登出 + +## 📚 文档输出 + +### 1. 详细API文档 +**文件**: `REFRESH_TOKEN_API.md` +- 完整的API接口说明 +- 前端集成示例(JavaScript/React) +- 安全考虑和最佳实践 +- 错误处理指南 +- 性能优化建议 + +### 2. 快速使用指南 +**文件**: `REFRESH_TOKEN_QUICKSTART.md` +- 环境配置说明 +- 核心API使用方法 +- 前端集成代码示例 +- 迁移步骤指导 + +## 🔧 配置说明 + +### 环境变量 +```bash +# Access Token配置 +ACCESS_TOKEN_EXPIRES_IN=15m # 访问令牌过期时间 +REFRESH_TOKEN_EXPIRES_IN=7d # 刷新令牌过期时间 + +# 密钥配置 +JWT_SECRET=your-access-token-secret # Access Token密钥 +REFRESH_TOKEN_SECRET=your-refresh-token-secret # Refresh Token密钥 + +# 可选:RSA算法配置 +JWT_ALG=RS256 +ACCESS_TOKEN_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----..." +ACCESS_TOKEN_PUBLIC_KEY="-----BEGIN RSA PUBLIC KEY-----..." +REFRESH_TOKEN_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----..." +REFRESH_TOKEN_PUBLIC_KEY="-----BEGIN RSA PUBLIC KEY-----..." +``` + +## 🚀 部署步骤 + +### 1. 数据库迁移 +```bash +npx prisma migrate dev --name add_refresh_token_system +``` + +### 2. 环境变量更新 +```bash +# 添加新的环境变量到 .env 文件 +echo "ACCESS_TOKEN_EXPIRES_IN=15m" >> .env +echo "REFRESH_TOKEN_EXPIRES_IN=7d" >> .env +echo "REFRESH_TOKEN_SECRET=your-refresh-token-secret-change-this" >> .env +``` + +### 3. 前端更新 +- 更新OAuth回调处理逻辑 +- 实现Token刷新机制 +- 添加自动重试逻辑 + +## 🔄 向后兼容性 + +- ✅ 现有JWT令牌继续有效 +- ✅ 旧版API端点保持不变 +- ✅ 渐进式迁移支持 +- ✅ 中间件自动检测令牌类型 + +## 📊 系统架构 + +``` +┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐ +│ 前端应用 │ │ ClassworksKV │ │ 数据库 │ +│ │ │ 服务端 │ │ │ +├─────────────────┤ ├──────────────────┤ ├─────────────────┤ +│ • Token存储 │◄──►│ • OAuth认证 │◄──►│ • Account表 │ +│ • 自动刷新 │ │ • Token生成 │ │ • refreshToken │ +│ • 请求拦截 │ │ • Token验证 │ │ • tokenVersion │ +│ • 错误处理 │ │ • Token刷新 │ │ • 过期时间 │ +└─────────────────┘ └──────────────────┘ └─────────────────┘ +``` + +## 🛡️ 安全增强 + +### 改进前(旧系统) +- 单一JWT令牌 +- 长期有效(7天) +- 泄露风险高 +- 无法远程登出 + +### 改进后(新系统) +- 双令牌系统 +- Access Token短期(15分钟) +- Refresh Token长期(7天) +- 令牌版本控制 +- 设备级管理 +- 自动刷新机制 + +## 📈 性能考虑 + +- **数据库**: 为refreshToken字段添加索引 +- **内存**: Token缓存机制(可选) +- **网络**: 预刷新机制减少延迟 +- **存储**: 定期清理过期令牌 + +## 🧪 测试建议 + +### 功能测试 +1. OAuth登录流程测试 +2. Token刷新功能测试 +3. 登出功能测试 +4. 过期处理测试 + +### 安全测试 +1. 令牌篡改测试 +2. 过期令牌测试 +3. 并发刷新测试 +4. 版本不匹配测试 + +## 📞 后续支持 + +- 监控令牌刷新频率 +- 分析用户登录模式 +- 优化过期时间配置 +- 收集用户反馈 + +--- + +**重构完成时间**: 2025年11月1日 +**文档版本**: v1.0 +**兼容性**: 向后兼容,支持渐进式迁移 \ No newline at end of file diff --git a/SOCKET_API.md b/SOCKET_API.md new file mode 100644 index 0000000..a907cb2 --- /dev/null +++ b/SOCKET_API.md @@ -0,0 +1,565 @@ +# Socket.IO 实时频道接口文档(前端) + +## 概述 + +ClassworksKV 提供基于 Socket.IO 的实时键值变更通知服务。前端使用 **KV token**(应用安装 token)加入频道,服务端会自动将 token 映射到对应设备的 uuid 房间。**同一设备的不同 token 会被归入同一频道**,因此多个客户端/应用可以共享实时更新。 + +**重要变更**:不再支持直接使用 uuid 加入频道,所有连接必须使用有效的 KV token。 + +## 安装依赖 + +前端项目安装 Socket.IO 客户端: + +```bash +# npm +npm install socket.io-client + +# pnpm +pnpm add socket.io-client + +# yarn +yarn add socket.io-client +``` + +## 连接服务器 + +### 基础连接 + +```typescript +import { io, Socket } from 'socket.io-client'; + +const SERVER_URL = 'http://localhost:3000'; // 替换为实际服务器地址 + +const socket: Socket = io(SERVER_URL, { + transports: ['websocket'], +}); +``` + +### 连接时自动加入频道(推荐) + +在连接握手时通过 query 参数传入 token,自动加入对应设备频道: + +```typescript +const socket = io(SERVER_URL, { + transports: ['websocket'], + query: { + token: '', // 或使用 apptoken 参数 + }, +}); + +// 监听加入成功 +socket.on('joined', (info) => { + console.log('已加入频道:', info); + // { by: 'token', uuid: 'device-uuid-xxx' } +}); + +// 监听加入失败 +socket.on('join-error', (error) => { + console.error('加入频道失败:', error); + // { by: 'token', reason: 'invalid_token' } +}); +``` + +## 事件接口 + +### 1. 客户端发送的事件 + +#### `join-token` - 使用 token 加入频道 + +连接后按需加入频道。 + +**载荷格式:** +```typescript +{ + token?: string; // KV token(二选一) + apptoken?: string; // 或使用 apptoken 字段 +} +``` + +**示例:** +```typescript +socket.emit('join-token', { token: '' }); +``` + +--- + +#### `leave-token` - 使用 token 离开频道 + +离开指定 token 对应的设备频道。 + +**载荷格式:** +```typescript +{ + token?: string; + apptoken?: string; +} +``` + +**示例:** +```typescript +socket.emit('leave-token', { token: '' }); +``` + +--- + +#### `leave-all` - 离开所有频道 + +断开前清理,离开该连接加入的所有设备频道。 + +**载荷:** 无 + +**示例:** +```typescript +socket.emit('leave-all'); +``` + +--- + +### 2. 服务端发送的事件 + +#### `joined` - 加入成功通知 + +当成功加入频道后,服务端会发送此事件。 + +**载荷格式:** +```typescript +{ + by: 'token'; + uuid: string; // 设备 uuid(用于调试/日志) +} +``` + +**示例:** +```typescript +socket.on('joined', (info) => { + console.log(`成功加入设备 ${info.uuid} 的频道`); +}); +``` + +--- + +#### `join-error` - 加入失败通知 + +token 无效或查询失败时触发。 + +**载荷格式:** +```typescript +{ + by: 'token'; + reason: 'invalid_token'; // 失败原因 +} +``` + +**示例:** +```typescript +socket.on('join-error', (error) => { + console.error('Token 无效,无法加入频道'); +}); +``` + +--- + +#### `kv-key-changed` - 键值变更广播 + +当设备下的 KV 键被创建/更新/删除时,向该设备频道内所有连接广播此事件。 + +**载荷格式:** +```typescript +{ + uuid: string; // 设备 uuid + key: string; // 变更的键名 + action: 'upsert' | 'delete'; // 操作类型 + + // 仅 action='upsert' 时存在: + created?: boolean; // 是否首次创建 + updatedAt?: string; // 更新时间(ISO 8601) + batch?: boolean; // 是否为批量导入中的单条 + + // 仅 action='delete' 时存在: + deletedAt?: string; // 删除时间(ISO 8601) +} +``` + +**示例:** +```typescript +socket.on('kv-key-changed', (msg) => { + if (msg.action === 'upsert') { + console.log(`键 ${msg.key} 已${msg.created ? '创建' : '更新'}`); + // 刷新本地缓存或重新获取数据 + } else if (msg.action === 'delete') { + console.log(`键 ${msg.key} 已删除`); + // 从本地缓存移除 + } +}); +``` + +**载荷示例:** + +- 新建/更新键: + ```json + { + "uuid": "device-001", + "key": "settings/theme", + "action": "upsert", + "created": false, + "updatedAt": "2025-10-25T08:30:00.000Z" + } + ``` + +- 删除键: + ```json + { + "uuid": "device-001", + "key": "settings/theme", + "action": "delete", + "deletedAt": "2025-10-25T08:35:00.000Z" + } + ``` + +- 批量导入中的单条: + ```json + { + "uuid": "device-001", + "key": "config/version", + "action": "upsert", + "created": true, + "updatedAt": "2025-10-25T08:40:00.000Z", + "batch": true + } + ``` + +--- + +#### `device-joined` - 设备频道连接数变化(可选) + +当有新连接加入某设备频道时广播,用于显示在线人数。 + +**载荷格式:** +```typescript +{ + uuid: string; // 设备 uuid + connections: number; // 当前连接数 +} +``` + +**示例:** +```typescript +socket.on('device-joined', (info) => { + console.log(`设备 ${info.uuid} 当前有 ${info.connections} 个连接`); +}); +``` + +--- + +## 完整使用示例 + +### React Hook 封装 + +```typescript +import { useEffect, useRef } from 'react'; +import { io, Socket } from 'socket.io-client'; + +const SERVER_URL = import.meta.env.VITE_SERVER_URL || 'http://localhost:3000'; + +interface KvKeyChange { + uuid: string; + key: string; + action: 'upsert' | 'delete'; + created?: boolean; + updatedAt?: string; + deletedAt?: string; + batch?: boolean; +} + +export function useKvChannel( + token: string | null, + onKeyChanged?: (event: KvKeyChange) => void +) { + const socketRef = useRef(null); + + useEffect(() => { + if (!token) return; + + // 创建连接并加入频道 + const socket = io(SERVER_URL, { + transports: ['websocket'], + query: { token }, + }); + + socket.on('joined', (info) => { + console.log('已加入设备频道:', info.uuid); + }); + + socket.on('join-error', (err) => { + console.error('加入频道失败:', err.reason); + }); + + socket.on('kv-key-changed', (msg: KvKeyChange) => { + onKeyChanged?.(msg); + }); + + socketRef.current = socket; + + return () => { + socket.emit('leave-all'); + socket.close(); + }; + }, [token]); + + return socketRef.current; +} +``` + +### Vue Composable 封装 + +```typescript +import { ref, watch, onUnmounted } from 'vue'; +import { io, Socket } from 'socket.io-client'; + +const SERVER_URL = import.meta.env.VITE_SERVER_URL || 'http://localhost:3000'; + +export function useKvChannel(token: Ref) { + const socket = ref(null); + const isConnected = ref(false); + const deviceUuid = ref(null); + + watch(token, (newToken) => { + // 清理旧连接 + if (socket.value) { + socket.value.emit('leave-all'); + socket.value.close(); + socket.value = null; + } + + if (!newToken) return; + + // 创建新连接 + const s = io(SERVER_URL, { + transports: ['websocket'], + query: { token: newToken }, + }); + + s.on('connect', () => { + isConnected.value = true; + }); + + s.on('disconnect', () => { + isConnected.value = false; + }); + + s.on('joined', (info) => { + deviceUuid.value = info.uuid; + console.log('已加入设备频道:', info.uuid); + }); + + s.on('join-error', (err) => { + console.error('加入失败:', err.reason); + }); + + socket.value = s; + }, { immediate: true }); + + onUnmounted(() => { + if (socket.value) { + socket.value.emit('leave-all'); + socket.value.close(); + } + }); + + return { socket, isConnected, deviceUuid }; +} +``` + +### 使用示例(React) + +```tsx +import { useKvChannel } from './hooks/useKvChannel'; + +function MyComponent() { + const token = localStorage.getItem('kv-token'); + + useKvChannel(token, (event) => { + console.log('KV 变更:', event); + + if (event.action === 'upsert') { + // 更新本地状态或重新获取数据 + fetchKeyValue(event.key); + } else if (event.action === 'delete') { + // 从本地移除 + removeFromCache(event.key); + } + }); + + return
实时监听中...
; +} +``` + +--- + +## REST API:查询在线设备 + +除了 Socket.IO 实时事件,还提供 HTTP 接口查询当前在线设备列表。 + +### `GET /devices/online` + +**响应格式:** +```typescript +{ + success: true; + devices: Array<{ + uuid: string; // 设备 uuid + connections: number; // 当前连接数 + name: string | null; // 设备名称(若已设置) + }>; +} +``` + +**示例:** +```typescript +const response = await fetch(`${SERVER_URL}/devices/online`); +const data = await response.json(); + +console.log('在线设备:', data.devices); +// [{ uuid: 'device-001', connections: 3, name: 'My Device' }, ...] +``` + +--- + +## 获取 KV Token + +前端需要先获取有效的 KV token 才能加入频道。Token 通过以下接口获取: + +### 安装应用获取 token + +**接口:** `POST /apps/devices/:uuid/install/:appId` + +**认证:** 需要设备 UUID 认证(密码或账户 JWT) + +**响应包含:** +```typescript +{ + id: string; + appId: string; + token: string; // 用于 KV 操作和加入频道 + note: string | null; + name: string | null; // 等同于 note,便于展示 + installedAt: string; +} +``` + +### 列出设备已有的 token + +**接口:** `GET /apps/tokens?uuid=` + +**响应:** +```typescript +{ + success: true; + tokens: Array<{ + id: string; + token: string; + appId: string; + installedAt: string; + note: string | null; + name: string | null; // 等同于 note + }>; + deviceUuid: string; +} +``` + +--- + +## 注意事项与最佳实践 + +1. **Token 必需**:所有连接必须提供有效的 KV token,不再支持直接使用 uuid。 + +2. **频道归并**:同一设备的不同 token 会自动归入同一房间(以设备 uuid 为房间名),因此多个应用/客户端可以共享实时更新。 + +3. **连接管理**: + - 组件卸载时调用 `leave-all` 或 `leave-token` 清理连接 + - 避免频繁创建/销毁连接,建议在应用全局维护单个 socket 实例 + +4. **重连处理**: + - Socket.IO 客户端内置自动重连 + - 在 `connect` 事件后重新 emit `join-token` 确保重连后仍在频道内(或在握手时传 token 自动加入) + +5. **CORS 配置**: + - 服务端通过环境变量 `FRONTEND_URL` 控制允许的来源 + - 未设置时默认为 `*`(允许所有来源) + - 生产环境建议设置为前端实际域名 + +6. **错误处理**: + - 监听 `join-error` 事件处理 token 无效情况 + - 监听 `connect_error` 处理网络连接失败 + +7. **性能优化**: + - 批量导入时会逐条广播,前端可根据 `batch: true` 标记做去抖处理 + - 建议在本地维护 KV 缓存,收到变更通知时增量更新而非全量刷新 + +--- + +## 环境变量配置 + +服务端需要配置以下环境变量: + +```env +# Socket.IO CORS 允许的来源 +FRONTEND_URL=http://localhost:5173 + +# 服务器端口(可选,默认 3000) +PORT=3000 +``` + +--- + +## 常见问题 + +### Q: 如何支持多个设备? + +A: 对每个设备的 token 分别调用 `join-token`,或在连接时传入一个 token,后续通过事件加入其他设备。 + +```typescript +socket.emit('join-token', { token: token1 }); +socket.emit('join-token', { token: token2 }); +``` + +### Q: 广播延迟有多大? + +A: 通常在毫秒级,取决于网络状况。WebSocket 连接建立后,广播几乎实时。 + +### Q: Token 过期怎么办? + +A: Token 本身不会过期,除非手动删除应用安装记录。如收到 `join-error`,检查 token 是否已被卸载。 + +### Q: 可以在 Node.js 后端使用吗? + +A: 可以,使用相同的 socket.io-client 包,接口完全一致。 + +--- + +## 更新日志 + +### v1.1.0 (2025-10-25) + +**破坏性变更:** +- 移除直接使用 uuid 加入频道的接口(`join-device` / `leave-device`) +- 现在必须使用 KV token 通过 `join-token` 或握手 query 加入 + +**新增:** +- `leave-all` 事件:离开所有已加入的频道 +- 握手时支持 `token` 和 `apptoken` 两种参数名 + +**改进:** +- 同一设备的不同 token 自动归入同一房间 +- 优化在线设备计数准确性 + +--- + +## 技术支持 + +如有问题,请查阅: +- 服务端源码:`utils/socket.js` +- KV 路由:`routes/kv-token.js` +- 设备管理:`routes/device.js` + +或提交 Issue 到项目仓库。 diff --git a/config/oauth.js b/config/oauth.js index f2ef74e..8e38584 100644 --- a/config/oauth.js +++ b/config/oauth.js @@ -18,9 +18,9 @@ export const oauthProviders = { zerocat: { clientId: process.env.ZEROCAT_CLIENT_ID, clientSecret: process.env.ZEROCAT_CLIENT_SECRET, - authorizationURL: "https://api.zcservice.houlang.cloud/oauth/authorize", - tokenURL: "https://api.zcservice.houlang.cloud/oauth/token", - userInfoURL: "https://api.zcservice.houlang.cloud/oauth/userinfo", + authorizationURL: "https://zerocat-api.houlang.cloud/oauth/authorize", + tokenURL: "https://zerocat-api.houlang.cloud/oauth/token", + userInfoURL: "https://zerocat-api.houlang.cloud/oauth/userinfo", scope: "user:basic user:email", // 展示相关 name: "ZeroCat", diff --git a/docker/schema.prisma b/docker/schema.prisma new file mode 100644 index 0000000..2966875 --- /dev/null +++ b/docker/schema.prisma @@ -0,0 +1,91 @@ +generator client { + provider = "prisma-client" + output = "../generated/prisma" +} + +datasource db { + provider = "postgresql" +} + +model KVStore { + deviceId Int + key String + value Json + creatorIp String? @default("") + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + // 关联关系 + device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade) + + @@id([deviceId, key]) +} + +model Account { + id String @id @default(cuid()) + provider String // OAuth提供者 (例如: google, github, gitlab等) + providerId String // 提供者返回的用户唯一ID + email String? // 用户邮箱 + name String? // 用户名称 + avatarUrl String? // 用户头像URL + providerData Json? // OAuth提供者返回的完整信息 + accessToken String? @db.Text // 账户访问令牌 + refreshToken String? @db.Text // 刷新令牌 + refreshTokenExpiry DateTime? // 刷新令牌过期时间 + tokenVersion Int @default(1) // 令牌版本,用于令牌失效 + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + // 关联的设备 + devices Device[] + + @@unique([provider, providerId]) // 确保同一提供者的用户ID唯一 +} + +model Device { + id Int @id @default(autoincrement()) + uuid String @unique // 设备的唯一标识符 + name String? + accountId String? // 关联的账户ID + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + password String? + passwordHint String? + namespace String? @unique // 用户自定义的唯一命名空间 + + // 关联关系 + account Account? @relation(fields: [accountId], references: [id], onDelete: SetNull) + appInstalls AppInstall[] + kvStore KVStore[] // 设备相关的KV存储 + autoAuths AutoAuth[] // 自动授权配置 +} + +model AppInstall { + id String @id @default(cuid()) + deviceId Int // 关联的设备ID + appId String // 应用ID (SHA256 hash) + token String @unique // 应用安装的唯一访问令牌,拥有完整KV读写权限 + note String? // 安装备注 + isReadOnly Boolean @default(false) // 是否只读 + deviceType String? // 设备类型: teacher(教师), student(学生), classroom(班级一体机), parent(家长) + installedAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + // 关联关系 + device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade) +} + +model AutoAuth { + id String @id @default(cuid()) + deviceId Int // 关联的设备ID + password String? // 配置密码,可以为空 + deviceType String? // 自动设备类型: teacher(教师), student(学生), classroom(班级一体机), parent(家长) + isReadOnly Boolean @default(false) // 是否只读 + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + // 关联关系 + device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade) + + @@unique([deviceId, password]) // 同一设备的密码必须唯一 +} diff --git a/generated/prisma/browser.ts b/generated/prisma/browser.ts new file mode 100644 index 0000000..8016d02 --- /dev/null +++ b/generated/prisma/browser.ts @@ -0,0 +1,44 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file should be your main import to use Prisma-related types and utilities in a browser. + * Use it to get access to models, enums, and input types. + * + * This file does not contain a `PrismaClient` class, nor several other helpers that are intended as server-side only. + * See `client.ts` for the standard, server-side entry point. + * + * 🟢 You can import this file directly. + */ + +import * as Prisma from './internal/prismaNamespaceBrowser.ts' +export { Prisma } +export * as $Enums from './enums.ts' +export * from './enums.ts'; +/** + * Model Account + * + */ +export type Account = Prisma.AccountModel +/** + * Model AppInstall + * + */ +export type AppInstall = Prisma.AppInstallModel +/** + * Model AutoAuth + * + */ +export type AutoAuth = Prisma.AutoAuthModel +/** + * Model Device + * + */ +export type Device = Prisma.DeviceModel +/** + * Model KVStore + * + */ +export type KVStore = Prisma.KVStoreModel diff --git a/generated/prisma/client.ts b/generated/prisma/client.ts new file mode 100644 index 0000000..f5d86d1 --- /dev/null +++ b/generated/prisma/client.ts @@ -0,0 +1,66 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types. + * If you're looking for something you can import in the client-side of your application, please refer to the `browser.ts` file instead. + * + * 🟢 You can import this file directly. + */ + +import * as process from 'node:process' +import * as path from 'node:path' +import { fileURLToPath } from 'node:url' +globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url)) + +import * as runtime from "@prisma/client/runtime/client" +import * as $Enums from "./enums.ts" +import * as $Class from "./internal/class.ts" +import * as Prisma from "./internal/prismaNamespace.ts" + +export * as $Enums from './enums.ts' +export * from "./enums.ts" +/** + * ## Prisma Client + * + * Type-safe database client for TypeScript + * @example + * ``` + * const prisma = new PrismaClient() + * // Fetch zero or more Accounts + * const accounts = await prisma.account.findMany() + * ``` + * + * Read more in our [docs](https://pris.ly/d/client). + */ +export const PrismaClient = $Class.getPrismaClientClass() +export type PrismaClient = $Class.PrismaClient +export { Prisma } + +/** + * Model Account + * + */ +export type Account = Prisma.AccountModel +/** + * Model AppInstall + * + */ +export type AppInstall = Prisma.AppInstallModel +/** + * Model AutoAuth + * + */ +export type AutoAuth = Prisma.AutoAuthModel +/** + * Model Device + * + */ +export type Device = Prisma.DeviceModel +/** + * Model KVStore + * + */ +export type KVStore = Prisma.KVStoreModel diff --git a/generated/prisma/commonInputTypes.ts b/generated/prisma/commonInputTypes.ts new file mode 100644 index 0000000..6198c32 --- /dev/null +++ b/generated/prisma/commonInputTypes.ts @@ -0,0 +1,502 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports various common sort, input & filter types that are not directly linked to a particular model. + * + * 🟢 You can import this file directly. + */ + +import type * as runtime from "@prisma/client/runtime/client" +import * as $Enums from "./enums.ts" +import type * as Prisma from "./internal/prismaNamespace.ts" + + +export type StringFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + mode?: Prisma.QueryMode + not?: Prisma.NestedStringFilter<$PrismaModel> | string +} + +export type StringNullableFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + mode?: Prisma.QueryMode + not?: Prisma.NestedStringNullableFilter<$PrismaModel> | string | null +} + +export type JsonNullableFilter<$PrismaModel = never> = +| Prisma.PatchUndefined< + Prisma.Either>, Exclude>, 'path'>>, + Required> + > +| Prisma.OptionalFlat>, 'path'>> + +export type JsonNullableFilterBase<$PrismaModel = never> = { + equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + path?: string[] + mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel> + string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter +} + +export type DateTimeFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeFilter<$PrismaModel> | Date | string +} + +export type DateTimeNullableFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null +} + +export type IntFilter<$PrismaModel = never> = { + equals?: number | Prisma.IntFieldRefInput<$PrismaModel> + in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + lt?: number | Prisma.IntFieldRefInput<$PrismaModel> + lte?: number | Prisma.IntFieldRefInput<$PrismaModel> + gt?: number | Prisma.IntFieldRefInput<$PrismaModel> + gte?: number | Prisma.IntFieldRefInput<$PrismaModel> + not?: Prisma.NestedIntFilter<$PrismaModel> | number +} + +export type SortOrderInput = { + sort: Prisma.SortOrder + nulls?: Prisma.NullsOrder +} + +export type StringWithAggregatesFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + mode?: Prisma.QueryMode + not?: Prisma.NestedStringWithAggregatesFilter<$PrismaModel> | string + _count?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedStringFilter<$PrismaModel> + _max?: Prisma.NestedStringFilter<$PrismaModel> +} + +export type StringNullableWithAggregatesFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + mode?: Prisma.QueryMode + not?: Prisma.NestedStringNullableWithAggregatesFilter<$PrismaModel> | string | null + _count?: Prisma.NestedIntNullableFilter<$PrismaModel> + _min?: Prisma.NestedStringNullableFilter<$PrismaModel> + _max?: Prisma.NestedStringNullableFilter<$PrismaModel> +} + +export type JsonNullableWithAggregatesFilter<$PrismaModel = never> = +| Prisma.PatchUndefined< + Prisma.Either>, Exclude>, 'path'>>, + Required> + > +| Prisma.OptionalFlat>, 'path'>> + +export type JsonNullableWithAggregatesFilterBase<$PrismaModel = never> = { + equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + path?: string[] + mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel> + string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + _count?: Prisma.NestedIntNullableFilter<$PrismaModel> + _min?: Prisma.NestedJsonNullableFilter<$PrismaModel> + _max?: Prisma.NestedJsonNullableFilter<$PrismaModel> +} + +export type DateTimeWithAggregatesFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeWithAggregatesFilter<$PrismaModel> | Date | string + _count?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedDateTimeFilter<$PrismaModel> + _max?: Prisma.NestedDateTimeFilter<$PrismaModel> +} + +export type DateTimeNullableWithAggregatesFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeNullableWithAggregatesFilter<$PrismaModel> | Date | string | null + _count?: Prisma.NestedIntNullableFilter<$PrismaModel> + _min?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> + _max?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> +} + +export type IntWithAggregatesFilter<$PrismaModel = never> = { + equals?: number | Prisma.IntFieldRefInput<$PrismaModel> + in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + lt?: number | Prisma.IntFieldRefInput<$PrismaModel> + lte?: number | Prisma.IntFieldRefInput<$PrismaModel> + gt?: number | Prisma.IntFieldRefInput<$PrismaModel> + gte?: number | Prisma.IntFieldRefInput<$PrismaModel> + not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number + _count?: Prisma.NestedIntFilter<$PrismaModel> + _avg?: Prisma.NestedFloatFilter<$PrismaModel> + _sum?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedIntFilter<$PrismaModel> + _max?: Prisma.NestedIntFilter<$PrismaModel> +} + +export type BoolFilter<$PrismaModel = never> = { + equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel> + not?: Prisma.NestedBoolFilter<$PrismaModel> | boolean +} + +export type BoolWithAggregatesFilter<$PrismaModel = never> = { + equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel> + not?: Prisma.NestedBoolWithAggregatesFilter<$PrismaModel> | boolean + _count?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedBoolFilter<$PrismaModel> + _max?: Prisma.NestedBoolFilter<$PrismaModel> +} + +export type JsonFilter<$PrismaModel = never> = +| Prisma.PatchUndefined< + Prisma.Either>, Exclude>, 'path'>>, + Required> + > +| Prisma.OptionalFlat>, 'path'>> + +export type JsonFilterBase<$PrismaModel = never> = { + equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + path?: string[] + mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel> + string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter +} + +export type JsonWithAggregatesFilter<$PrismaModel = never> = +| Prisma.PatchUndefined< + Prisma.Either>, Exclude>, 'path'>>, + Required> + > +| Prisma.OptionalFlat>, 'path'>> + +export type JsonWithAggregatesFilterBase<$PrismaModel = never> = { + equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + path?: string[] + mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel> + string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + _count?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedJsonFilter<$PrismaModel> + _max?: Prisma.NestedJsonFilter<$PrismaModel> +} + +export type NestedStringFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + not?: Prisma.NestedStringFilter<$PrismaModel> | string +} + +export type NestedStringNullableFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + not?: Prisma.NestedStringNullableFilter<$PrismaModel> | string | null +} + +export type NestedDateTimeFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeFilter<$PrismaModel> | Date | string +} + +export type NestedDateTimeNullableFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> | Date | string | null +} + +export type NestedIntFilter<$PrismaModel = never> = { + equals?: number | Prisma.IntFieldRefInput<$PrismaModel> + in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + lt?: number | Prisma.IntFieldRefInput<$PrismaModel> + lte?: number | Prisma.IntFieldRefInput<$PrismaModel> + gt?: number | Prisma.IntFieldRefInput<$PrismaModel> + gte?: number | Prisma.IntFieldRefInput<$PrismaModel> + not?: Prisma.NestedIntFilter<$PrismaModel> | number +} + +export type NestedStringWithAggregatesFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + not?: Prisma.NestedStringWithAggregatesFilter<$PrismaModel> | string + _count?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedStringFilter<$PrismaModel> + _max?: Prisma.NestedStringFilter<$PrismaModel> +} + +export type NestedStringNullableWithAggregatesFilter<$PrismaModel = never> = { + equals?: string | Prisma.StringFieldRefInput<$PrismaModel> | null + in?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + notIn?: string[] | Prisma.ListStringFieldRefInput<$PrismaModel> | null + lt?: string | Prisma.StringFieldRefInput<$PrismaModel> + lte?: string | Prisma.StringFieldRefInput<$PrismaModel> + gt?: string | Prisma.StringFieldRefInput<$PrismaModel> + gte?: string | Prisma.StringFieldRefInput<$PrismaModel> + contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + startsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + endsWith?: string | Prisma.StringFieldRefInput<$PrismaModel> + not?: Prisma.NestedStringNullableWithAggregatesFilter<$PrismaModel> | string | null + _count?: Prisma.NestedIntNullableFilter<$PrismaModel> + _min?: Prisma.NestedStringNullableFilter<$PrismaModel> + _max?: Prisma.NestedStringNullableFilter<$PrismaModel> +} + +export type NestedIntNullableFilter<$PrismaModel = never> = { + equals?: number | Prisma.IntFieldRefInput<$PrismaModel> | null + in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null + notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> | null + lt?: number | Prisma.IntFieldRefInput<$PrismaModel> + lte?: number | Prisma.IntFieldRefInput<$PrismaModel> + gt?: number | Prisma.IntFieldRefInput<$PrismaModel> + gte?: number | Prisma.IntFieldRefInput<$PrismaModel> + not?: Prisma.NestedIntNullableFilter<$PrismaModel> | number | null +} + +export type NestedJsonNullableFilter<$PrismaModel = never> = +| Prisma.PatchUndefined< + Prisma.Either>, Exclude>, 'path'>>, + Required> + > +| Prisma.OptionalFlat>, 'path'>> + +export type NestedJsonNullableFilterBase<$PrismaModel = never> = { + equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + path?: string[] + mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel> + string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter +} + +export type NestedDateTimeWithAggregatesFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeWithAggregatesFilter<$PrismaModel> | Date | string + _count?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedDateTimeFilter<$PrismaModel> + _max?: Prisma.NestedDateTimeFilter<$PrismaModel> +} + +export type NestedDateTimeNullableWithAggregatesFilter<$PrismaModel = never> = { + equals?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> | null + in?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + notIn?: Date[] | string[] | Prisma.ListDateTimeFieldRefInput<$PrismaModel> | null + lt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + lte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gt?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + gte?: Date | string | Prisma.DateTimeFieldRefInput<$PrismaModel> + not?: Prisma.NestedDateTimeNullableWithAggregatesFilter<$PrismaModel> | Date | string | null + _count?: Prisma.NestedIntNullableFilter<$PrismaModel> + _min?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> + _max?: Prisma.NestedDateTimeNullableFilter<$PrismaModel> +} + +export type NestedIntWithAggregatesFilter<$PrismaModel = never> = { + equals?: number | Prisma.IntFieldRefInput<$PrismaModel> + in?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + notIn?: number[] | Prisma.ListIntFieldRefInput<$PrismaModel> + lt?: number | Prisma.IntFieldRefInput<$PrismaModel> + lte?: number | Prisma.IntFieldRefInput<$PrismaModel> + gt?: number | Prisma.IntFieldRefInput<$PrismaModel> + gte?: number | Prisma.IntFieldRefInput<$PrismaModel> + not?: Prisma.NestedIntWithAggregatesFilter<$PrismaModel> | number + _count?: Prisma.NestedIntFilter<$PrismaModel> + _avg?: Prisma.NestedFloatFilter<$PrismaModel> + _sum?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedIntFilter<$PrismaModel> + _max?: Prisma.NestedIntFilter<$PrismaModel> +} + +export type NestedFloatFilter<$PrismaModel = never> = { + equals?: number | Prisma.FloatFieldRefInput<$PrismaModel> + in?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel> + notIn?: number[] | Prisma.ListFloatFieldRefInput<$PrismaModel> + lt?: number | Prisma.FloatFieldRefInput<$PrismaModel> + lte?: number | Prisma.FloatFieldRefInput<$PrismaModel> + gt?: number | Prisma.FloatFieldRefInput<$PrismaModel> + gte?: number | Prisma.FloatFieldRefInput<$PrismaModel> + not?: Prisma.NestedFloatFilter<$PrismaModel> | number +} + +export type NestedBoolFilter<$PrismaModel = never> = { + equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel> + not?: Prisma.NestedBoolFilter<$PrismaModel> | boolean +} + +export type NestedBoolWithAggregatesFilter<$PrismaModel = never> = { + equals?: boolean | Prisma.BooleanFieldRefInput<$PrismaModel> + not?: Prisma.NestedBoolWithAggregatesFilter<$PrismaModel> | boolean + _count?: Prisma.NestedIntFilter<$PrismaModel> + _min?: Prisma.NestedBoolFilter<$PrismaModel> + _max?: Prisma.NestedBoolFilter<$PrismaModel> +} + +export type NestedJsonFilter<$PrismaModel = never> = +| Prisma.PatchUndefined< + Prisma.Either>, Exclude>, 'path'>>, + Required> + > +| Prisma.OptionalFlat>, 'path'>> + +export type NestedJsonFilterBase<$PrismaModel = never> = { + equals?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter + path?: string[] + mode?: Prisma.QueryMode | Prisma.EnumQueryModeFieldRefInput<$PrismaModel> + string_contains?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_starts_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + string_ends_with?: string | Prisma.StringFieldRefInput<$PrismaModel> + array_starts_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_ends_with?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + array_contains?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | null + lt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + lte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gt?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + gte?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> + not?: runtime.InputJsonValue | Prisma.JsonFieldRefInput<$PrismaModel> | Prisma.JsonNullValueFilter +} + + diff --git a/generated/prisma/enums.ts b/generated/prisma/enums.ts new file mode 100644 index 0000000..043572d --- /dev/null +++ b/generated/prisma/enums.ts @@ -0,0 +1,15 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* +* This file exports all enum related types from the schema. +* +* 🟢 You can import this file directly. +*/ + + + +// This file is empty because there are no enums in the schema. +export {} diff --git a/generated/prisma/internal/class.ts b/generated/prisma/internal/class.ts new file mode 100644 index 0000000..364eb14 --- /dev/null +++ b/generated/prisma/internal/class.ts @@ -0,0 +1,232 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * WARNING: This is an internal file that is subject to change! + * + * 🛑 Under no circumstances should you import this file directly! 🛑 + * + * Please import the `PrismaClient` class from the `client.ts` file instead. + */ + +import * as runtime from "@prisma/client/runtime/client" +import type * as Prisma from "./prismaNamespace.ts" + + +const config: runtime.GetPrismaClientConfig = { + "previewFeatures": [], + "clientVersion": "7.3.0", + "engineVersion": "9d6ad21cbbceab97458517b147a6a09ff43aa735", + "activeProvider": "postgresql", + "inlineSchema": "generator client {\n provider = \"prisma-client\"\n output = \"../generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\nmodel Account {\n id String @id(map: \"idx_18303_PRIMARY\") @db.VarChar(191)\n provider String @db.VarChar(191)\n providerId String @db.VarChar(191)\n email String? @db.VarChar(191)\n name String? @db.VarChar(191)\n avatarUrl String? @db.VarChar(191)\n providerData Json? @db.Json\n accessToken String?\n createdAt DateTime @default(now()) @db.Timestamptz(6)\n updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)\n refreshToken String?\n refreshTokenExpiry DateTime? @db.Timestamptz(6)\n tokenVersion Int @default(1)\n\n devices Device[]\n\n @@unique([provider, providerId], map: \"idx_18303_Account_provider_providerId_key\")\n}\n\nmodel AppInstall {\n id String @id(map: \"idx_18310_PRIMARY\") @db.VarChar(191)\n deviceId Int\n appId String @db.VarChar(191)\n token String @unique(map: \"idx_18310_AppInstall_token_key\") @db.VarChar(191)\n note String? @db.VarChar(191)\n installedAt DateTime @default(now()) @db.Timestamptz(6)\n updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)\n deviceType String? @db.VarChar(191)\n isReadOnly Boolean @default(false)\n\n device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)\n\n @@index([deviceId], map: \"idx_18310_AppInstall_deviceId_fkey\")\n}\n\nmodel AutoAuth {\n id String @id(map: \"idx_18317_PRIMARY\") @db.VarChar(191)\n deviceId Int\n password String? @db.VarChar(191)\n deviceType String? @db.VarChar(191)\n isReadOnly Boolean @default(false)\n createdAt DateTime @default(now()) @db.Timestamptz(6)\n updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)\n\n device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)\n\n @@unique([deviceId, password], map: \"idx_18317_AutoAuth_deviceId_password_key\")\n}\n\nmodel Device {\n id Int @id(map: \"idx_18324_PRIMARY\")\n uuid String @unique(map: \"idx_18324_Device_uuid_key\") @db.VarChar(191)\n name String? @db.VarChar(191)\n accountId String? @db.VarChar(191)\n createdAt DateTime @default(now()) @db.Timestamptz(6)\n updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)\n password String? @db.VarChar(191)\n passwordHint String? @db.VarChar(191)\n namespace String? @unique(map: \"idx_18324_Device_namespace_key\") @db.VarChar(191)\n\n // 关联关系\n account Account? @relation(fields: [accountId], references: [id], onDelete: SetNull)\n appInstalls AppInstall[]\n kvStore KVStore[] // 设备相关的KV存储\n autoAuths AutoAuth[] // 自动授权配置\n\n @@index([accountId], map: \"idx_18324_Device_accountId_fkey\")\n}\n\nmodel KVStore {\n deviceId Int\n key String @db.VarChar(191)\n value Json @db.Json\n creatorIp String? @default(\"\") @db.VarChar(191)\n createdAt DateTime @default(now()) @db.Timestamptz(6)\n updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6)\n\n device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade)\n\n @@id([deviceId, key], map: \"idx_18330_PRIMARY\")\n}\n", + "runtimeDataModel": { + "models": {}, + "enums": {}, + "types": {} + } +} + +config.runtimeDataModel = JSON.parse("{\"models\":{\"Account\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"provider\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"providerId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"avatarUrl\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"providerData\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"accessToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"refreshToken\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"refreshTokenExpiry\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"tokenVersion\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"devices\",\"kind\":\"object\",\"type\":\"Device\",\"relationName\":\"AccountToDevice\"}],\"dbName\":null},\"AppInstall\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"deviceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"appId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"token\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"note\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"installedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"deviceType\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isReadOnly\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"device\",\"kind\":\"object\",\"type\":\"Device\",\"relationName\":\"AppInstallToDevice\"}],\"dbName\":null},\"AutoAuth\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"deviceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"deviceType\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"isReadOnly\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"device\",\"kind\":\"object\",\"type\":\"Device\",\"relationName\":\"AutoAuthToDevice\"}],\"dbName\":null},\"Device\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"uuid\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"accountId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"password\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"passwordHint\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"namespace\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"account\",\"kind\":\"object\",\"type\":\"Account\",\"relationName\":\"AccountToDevice\"},{\"name\":\"appInstalls\",\"kind\":\"object\",\"type\":\"AppInstall\",\"relationName\":\"AppInstallToDevice\"},{\"name\":\"kvStore\",\"kind\":\"object\",\"type\":\"KVStore\",\"relationName\":\"DeviceToKVStore\"},{\"name\":\"autoAuths\",\"kind\":\"object\",\"type\":\"AutoAuth\",\"relationName\":\"AutoAuthToDevice\"}],\"dbName\":null},\"KVStore\":{\"fields\":[{\"name\":\"deviceId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"key\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"value\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"creatorIp\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"device\",\"kind\":\"object\",\"type\":\"Device\",\"relationName\":\"DeviceToKVStore\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}") + +async function decodeBase64AsWasm(wasmBase64: string): Promise { + const { Buffer } = await import('node:buffer') + const wasmArray = Buffer.from(wasmBase64, 'base64') + return new WebAssembly.Module(wasmArray) +} + +config.compilerWasm = { + getRuntime: async () => await import("@prisma/client/runtime/query_compiler_fast_bg.postgresql.mjs"), + + getQueryCompilerWasmModule: async () => { + const { wasm } = await import("@prisma/client/runtime/query_compiler_fast_bg.postgresql.wasm-base64.mjs") + return await decodeBase64AsWasm(wasm) + }, + + importName: "./query_compiler_fast_bg.js" +} + + + +export type LogOptions = + 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array ? Prisma.GetEvents : never : never + +export interface PrismaClientConstructor { + /** + * ## Prisma Client + * + * Type-safe database client for TypeScript + * @example + * ``` + * const prisma = new PrismaClient() + * // Fetch zero or more Accounts + * const accounts = await prisma.account.findMany() + * ``` + * + * Read more in our [docs](https://pris.ly/d/client). + */ + + new < + Options extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions, + LogOpts extends LogOptions = LogOptions, + OmitOpts extends Prisma.PrismaClientOptions['omit'] = Options extends { omit: infer U } ? U : Prisma.PrismaClientOptions['omit'], + ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs + >(options: Prisma.Subset ): PrismaClient +} + +/** + * ## Prisma Client + * + * Type-safe database client for TypeScript + * @example + * ``` + * const prisma = new PrismaClient() + * // Fetch zero or more Accounts + * const accounts = await prisma.account.findMany() + * ``` + * + * Read more in our [docs](https://pris.ly/d/client). + */ + +export interface PrismaClient< + in LogOpts extends Prisma.LogLevel = never, + in out OmitOpts extends Prisma.PrismaClientOptions['omit'] = undefined, + in out ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs +> { + [K: symbol]: { types: Prisma.TypeMap['other'] } + + $on(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient; + + /** + * Connect with the database + */ + $connect(): runtime.Types.Utils.JsPromise; + + /** + * Disconnect from the database + */ + $disconnect(): runtime.Types.Utils.JsPromise; + +/** + * Executes a prepared raw query and returns the number of affected rows. + * @example + * ``` + * const result = await prisma.$executeRaw`UPDATE User SET cool = ${true} WHERE email = ${'user@email.com'};` + * ``` + * + * Read more in our [docs](https://pris.ly/d/raw-queries). + */ + $executeRaw(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise; + + /** + * Executes a raw query and returns the number of affected rows. + * Susceptible to SQL injections, see documentation. + * @example + * ``` + * const result = await prisma.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com') + * ``` + * + * Read more in our [docs](https://pris.ly/d/raw-queries). + */ + $executeRawUnsafe(query: string, ...values: any[]): Prisma.PrismaPromise; + + /** + * Performs a prepared raw query and returns the `SELECT` data. + * @example + * ``` + * const result = await prisma.$queryRaw`SELECT * FROM User WHERE id = ${1} OR email = ${'user@email.com'};` + * ``` + * + * Read more in our [docs](https://pris.ly/d/raw-queries). + */ + $queryRaw(query: TemplateStringsArray | Prisma.Sql, ...values: any[]): Prisma.PrismaPromise; + + /** + * Performs a raw query and returns the `SELECT` data. + * Susceptible to SQL injections, see documentation. + * @example + * ``` + * const result = await prisma.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com') + * ``` + * + * Read more in our [docs](https://pris.ly/d/raw-queries). + */ + $queryRawUnsafe(query: string, ...values: any[]): Prisma.PrismaPromise; + + + /** + * Allows the running of a sequence of read/write operations that are guaranteed to either succeed or fail as a whole. + * @example + * ``` + * const [george, bob, alice] = await prisma.$transaction([ + * prisma.user.create({ data: { name: 'George' } }), + * prisma.user.create({ data: { name: 'Bob' } }), + * prisma.user.create({ data: { name: 'Alice' } }), + * ]) + * ``` + * + * Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions). + */ + $transaction

[]>(arg: [...P], options?: { isolationLevel?: Prisma.TransactionIsolationLevel }): runtime.Types.Utils.JsPromise> + + $transaction(fn: (prisma: Omit) => runtime.Types.Utils.JsPromise, options?: { maxWait?: number, timeout?: number, isolationLevel?: Prisma.TransactionIsolationLevel }): runtime.Types.Utils.JsPromise + + $extends: runtime.Types.Extensions.ExtendsHook<"extends", Prisma.TypeMapCb, ExtArgs, runtime.Types.Utils.Call, { + extArgs: ExtArgs + }>> + + /** + * `prisma.account`: Exposes CRUD operations for the **Account** model. + * Example usage: + * ```ts + * // Fetch zero or more Accounts + * const accounts = await prisma.account.findMany() + * ``` + */ + get account(): Prisma.AccountDelegate; + + /** + * `prisma.appInstall`: Exposes CRUD operations for the **AppInstall** model. + * Example usage: + * ```ts + * // Fetch zero or more AppInstalls + * const appInstalls = await prisma.appInstall.findMany() + * ``` + */ + get appInstall(): Prisma.AppInstallDelegate; + + /** + * `prisma.autoAuth`: Exposes CRUD operations for the **AutoAuth** model. + * Example usage: + * ```ts + * // Fetch zero or more AutoAuths + * const autoAuths = await prisma.autoAuth.findMany() + * ``` + */ + get autoAuth(): Prisma.AutoAuthDelegate; + + /** + * `prisma.device`: Exposes CRUD operations for the **Device** model. + * Example usage: + * ```ts + * // Fetch zero or more Devices + * const devices = await prisma.device.findMany() + * ``` + */ + get device(): Prisma.DeviceDelegate; + + /** + * `prisma.kVStore`: Exposes CRUD operations for the **KVStore** model. + * Example usage: + * ```ts + * // Fetch zero or more KVStores + * const kVStores = await prisma.kVStore.findMany() + * ``` + */ + get kVStore(): Prisma.KVStoreDelegate; +} + +export function getPrismaClientClass(): PrismaClientConstructor { + return runtime.getPrismaClient(config) as unknown as PrismaClientConstructor +} diff --git a/generated/prisma/internal/prismaNamespace.ts b/generated/prisma/internal/prismaNamespace.ts new file mode 100644 index 0000000..d746ef6 --- /dev/null +++ b/generated/prisma/internal/prismaNamespace.ts @@ -0,0 +1,1186 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * WARNING: This is an internal file that is subject to change! + * + * 🛑 Under no circumstances should you import this file directly! 🛑 + * + * All exports from this file are wrapped under a `Prisma` namespace object in the client.ts file. + * While this enables partial backward compatibility, it is not part of the stable public API. + * + * If you are looking for your Models, Enums, and Input Types, please import them from the respective + * model files in the `model` directory! + */ + +import * as runtime from "@prisma/client/runtime/client" +import type * as Prisma from "../models.ts" +import { type PrismaClient } from "./class.ts" + +export type * from '../models.ts' + +export type DMMF = typeof runtime.DMMF + +export type PrismaPromise = runtime.Types.Public.PrismaPromise + +/** + * Prisma Errors + */ + +export const PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError +export type PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError + +export const PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError +export type PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError + +export const PrismaClientRustPanicError = runtime.PrismaClientRustPanicError +export type PrismaClientRustPanicError = runtime.PrismaClientRustPanicError + +export const PrismaClientInitializationError = runtime.PrismaClientInitializationError +export type PrismaClientInitializationError = runtime.PrismaClientInitializationError + +export const PrismaClientValidationError = runtime.PrismaClientValidationError +export type PrismaClientValidationError = runtime.PrismaClientValidationError + +/** + * Re-export of sql-template-tag + */ +export const sql = runtime.sqltag +export const empty = runtime.empty +export const join = runtime.join +export const raw = runtime.raw +export const Sql = runtime.Sql +export type Sql = runtime.Sql + + + +/** + * Decimal.js + */ +export const Decimal = runtime.Decimal +export type Decimal = runtime.Decimal + +export type DecimalJsLike = runtime.DecimalJsLike + +/** +* Extensions +*/ +export type Extension = runtime.Types.Extensions.UserArgs +export const getExtensionContext = runtime.Extensions.getExtensionContext +export type Args = runtime.Types.Public.Args +export type Payload = runtime.Types.Public.Payload +export type Result = runtime.Types.Public.Result +export type Exact = runtime.Types.Public.Exact + +export type PrismaVersion = { + client: string + engine: string +} + +/** + * Prisma Client JS version: 7.3.0 + * Query Engine version: 9d6ad21cbbceab97458517b147a6a09ff43aa735 + */ +export const prismaVersion: PrismaVersion = { + client: "7.3.0", + engine: "9d6ad21cbbceab97458517b147a6a09ff43aa735" +} + +/** + * Utility Types + */ + +export type Bytes = runtime.Bytes +export type JsonObject = runtime.JsonObject +export type JsonArray = runtime.JsonArray +export type JsonValue = runtime.JsonValue +export type InputJsonObject = runtime.InputJsonObject +export type InputJsonArray = runtime.InputJsonArray +export type InputJsonValue = runtime.InputJsonValue + + +export const NullTypes = { + DbNull: runtime.NullTypes.DbNull as (new (secret: never) => typeof runtime.DbNull), + JsonNull: runtime.NullTypes.JsonNull as (new (secret: never) => typeof runtime.JsonNull), + AnyNull: runtime.NullTypes.AnyNull as (new (secret: never) => typeof runtime.AnyNull), +} +/** + * Helper for filtering JSON entries that have `null` on the database (empty on the db) + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ +export const DbNull = runtime.DbNull + +/** + * Helper for filtering JSON entries that have JSON `null` values (not empty on the db) + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ +export const JsonNull = runtime.JsonNull + +/** + * Helper for filtering JSON entries that are `Prisma.DbNull` or `Prisma.JsonNull` + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ +export const AnyNull = runtime.AnyNull + + +type SelectAndInclude = { + select: any + include: any +} + +type SelectAndOmit = { + select: any + omit: any +} + +/** + * From T, pick a set of properties whose keys are in the union K + */ +type Prisma__Pick = { + [P in K]: T[P]; +}; + +export type Enumerable = T | Array; + +/** + * Subset + * @desc From `T` pick properties that exist in `U`. Simple version of Intersection + */ +export type Subset = { + [key in keyof T]: key extends keyof U ? T[key] : never; +}; + +/** + * SelectSubset + * @desc From `T` pick properties that exist in `U`. Simple version of Intersection. + * Additionally, it validates, if both select and include are present. If the case, it errors. + */ +export type SelectSubset = { + [key in keyof T]: key extends keyof U ? T[key] : never +} & + (T extends SelectAndInclude + ? 'Please either choose `select` or `include`.' + : T extends SelectAndOmit + ? 'Please either choose `select` or `omit`.' + : {}) + +/** + * Subset + Intersection + * @desc From `T` pick properties that exist in `U` and intersect `K` + */ +export type SubsetIntersection = { + [key in keyof T]: key extends keyof U ? T[key] : never +} & + K + +type Without = { [P in Exclude]?: never }; + +/** + * XOR is needed to have a real mutually exclusive union type + * https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types + */ +export type XOR = + T extends object ? + U extends object ? + (Without & U) | (Without & T) + : U : T + + +/** + * Is T a Record? + */ +type IsObject = T extends Array +? False +: T extends Date +? False +: T extends Uint8Array +? False +: T extends BigInt +? False +: T extends object +? True +: False + + +/** + * If it's T[], return T + */ +export type UnEnumerate = T extends Array ? U : T + +/** + * From ts-toolbelt + */ + +type __Either = Omit & + { + // Merge all but K + [P in K]: Prisma__Pick // With K possibilities + }[K] + +type EitherStrict = Strict<__Either> + +type EitherLoose = ComputeRaw<__Either> + +type _Either< + O extends object, + K extends Key, + strict extends Boolean +> = { + 1: EitherStrict + 0: EitherLoose +}[strict] + +export type Either< + O extends object, + K extends Key, + strict extends Boolean = 1 +> = O extends unknown ? _Either : never + +export type Union = any + +export type PatchUndefined = { + [K in keyof O]: O[K] extends undefined ? At : O[K] +} & {} + +/** Helper Types for "Merge" **/ +export type IntersectOf = ( + U extends unknown ? (k: U) => void : never +) extends (k: infer I) => void + ? I + : never + +export type Overwrite = { + [K in keyof O]: K extends keyof O1 ? O1[K] : O[K]; +} & {}; + +type _Merge = IntersectOf; +}>>; + +type Key = string | number | symbol; +type AtStrict = O[K & keyof O]; +type AtLoose = O extends unknown ? AtStrict : never; +export type At = { + 1: AtStrict; + 0: AtLoose; +}[strict]; + +export type ComputeRaw = A extends Function ? A : { + [K in keyof A]: A[K]; +} & {}; + +export type OptionalFlat = { + [K in keyof O]?: O[K]; +} & {}; + +type _Record = { + [P in K]: T; +}; + +// cause typescript not to expand types and preserve names +type NoExpand = T extends unknown ? T : never; + +// this type assumes the passed object is entirely optional +export type AtLeast = NoExpand< + O extends unknown + ? | (K extends keyof O ? { [P in K]: O[P] } & O : O) + | {[P in keyof O as P extends K ? P : never]-?: O[P]} & O + : never>; + +type _Strict = U extends unknown ? U & OptionalFlat<_Record, keyof U>, never>> : never; + +export type Strict = ComputeRaw<_Strict>; +/** End Helper Types for "Merge" **/ + +export type Merge = ComputeRaw<_Merge>>; + +export type Boolean = True | False + +export type True = 1 + +export type False = 0 + +export type Not = { + 0: 1 + 1: 0 +}[B] + +export type Extends = [A1] extends [never] + ? 0 // anything `never` is false + : A1 extends A2 + ? 1 + : 0 + +export type Has = Not< + Extends, U1> +> + +export type Or = { + 0: { + 0: 0 + 1: 1 + } + 1: { + 0: 1 + 1: 1 + } +}[B1][B2] + +export type Keys = U extends unknown ? keyof U : never + +export type GetScalarType = O extends object ? { + [P in keyof T]: P extends keyof O + ? O[P] + : never +} : never + +type FieldPaths< + T, + U = Omit +> = IsObject extends True ? U : T + +export type GetHavingFields = { + [K in keyof T]: Or< + Or, Extends<'AND', K>>, + Extends<'NOT', K> + > extends True + ? // infer is only needed to not hit TS limit + // based on the brilliant idea of Pierre-Antoine Mills + // https://github.com/microsoft/TypeScript/issues/30188#issuecomment-478938437 + T[K] extends infer TK + ? GetHavingFields extends object ? Merge> : never> + : never + : {} extends FieldPaths + ? never + : K +}[keyof T] + +/** + * Convert tuple to union + */ +type _TupleToUnion = T extends (infer E)[] ? E : never +type TupleToUnion = _TupleToUnion +export type MaybeTupleToUnion = T extends any[] ? TupleToUnion : T + +/** + * Like `Pick`, but additionally can also accept an array of keys + */ +export type PickEnumerable | keyof T> = Prisma__Pick> + +/** + * Exclude all keys with underscores + */ +export type ExcludeUnderscoreKeys = T extends `_${string}` ? never : T + + +export type FieldRef = runtime.FieldRef + +type FieldRefInputType = Model extends never ? never : FieldRef + + +export const ModelName = { + Account: 'Account', + AppInstall: 'AppInstall', + AutoAuth: 'AutoAuth', + Device: 'Device', + KVStore: 'KVStore' +} as const + +export type ModelName = (typeof ModelName)[keyof typeof ModelName] + + + +export interface TypeMapCb extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record> { + returns: TypeMap +} + +export type TypeMap = { + globalOmitOptions: { + omit: GlobalOmitOptions + } + meta: { + modelProps: "account" | "appInstall" | "autoAuth" | "device" | "kVStore" + txIsolationLevel: TransactionIsolationLevel + } + model: { + Account: { + payload: Prisma.$AccountPayload + fields: Prisma.AccountFieldRefs + operations: { + findUnique: { + args: Prisma.AccountFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.AccountFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.AccountFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.AccountFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.AccountFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.AccountCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.AccountCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.AccountCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.AccountDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.AccountUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.AccountDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.AccountUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.AccountUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.AccountUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.AccountAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.AccountGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.AccountCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } + AppInstall: { + payload: Prisma.$AppInstallPayload + fields: Prisma.AppInstallFieldRefs + operations: { + findUnique: { + args: Prisma.AppInstallFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.AppInstallFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.AppInstallFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.AppInstallFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.AppInstallFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.AppInstallCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.AppInstallCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.AppInstallCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.AppInstallDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.AppInstallUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.AppInstallDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.AppInstallUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.AppInstallUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.AppInstallUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.AppInstallAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.AppInstallGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.AppInstallCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } + AutoAuth: { + payload: Prisma.$AutoAuthPayload + fields: Prisma.AutoAuthFieldRefs + operations: { + findUnique: { + args: Prisma.AutoAuthFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.AutoAuthFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.AutoAuthFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.AutoAuthFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.AutoAuthFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.AutoAuthCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.AutoAuthCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.AutoAuthCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.AutoAuthDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.AutoAuthUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.AutoAuthDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.AutoAuthUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.AutoAuthUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.AutoAuthUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.AutoAuthAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.AutoAuthGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.AutoAuthCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } + Device: { + payload: Prisma.$DevicePayload + fields: Prisma.DeviceFieldRefs + operations: { + findUnique: { + args: Prisma.DeviceFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.DeviceFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.DeviceFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.DeviceFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.DeviceFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.DeviceCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.DeviceCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.DeviceCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.DeviceDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.DeviceUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.DeviceDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.DeviceUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.DeviceUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.DeviceUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.DeviceAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.DeviceGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.DeviceCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } + KVStore: { + payload: Prisma.$KVStorePayload + fields: Prisma.KVStoreFieldRefs + operations: { + findUnique: { + args: Prisma.KVStoreFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.KVStoreFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.KVStoreFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.KVStoreFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.KVStoreFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.KVStoreCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.KVStoreCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.KVStoreCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.KVStoreDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.KVStoreUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.KVStoreDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.KVStoreUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.KVStoreUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.KVStoreUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.KVStoreAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.KVStoreGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.KVStoreCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } + } +} & { + other: { + payload: any + operations: { + $executeRaw: { + args: [query: TemplateStringsArray | Sql, ...values: any[]], + result: any + } + $executeRawUnsafe: { + args: [query: string, ...values: any[]], + result: any + } + $queryRaw: { + args: [query: TemplateStringsArray | Sql, ...values: any[]], + result: any + } + $queryRawUnsafe: { + args: [query: string, ...values: any[]], + result: any + } + } + } +} + +/** + * Enums + */ + +export const TransactionIsolationLevel = runtime.makeStrictEnum({ + ReadUncommitted: 'ReadUncommitted', + ReadCommitted: 'ReadCommitted', + RepeatableRead: 'RepeatableRead', + Serializable: 'Serializable' +} as const) + +export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel] + + +export const AccountScalarFieldEnum = { + id: 'id', + provider: 'provider', + providerId: 'providerId', + email: 'email', + name: 'name', + avatarUrl: 'avatarUrl', + providerData: 'providerData', + accessToken: 'accessToken', + createdAt: 'createdAt', + updatedAt: 'updatedAt', + refreshToken: 'refreshToken', + refreshTokenExpiry: 'refreshTokenExpiry', + tokenVersion: 'tokenVersion' +} as const + +export type AccountScalarFieldEnum = (typeof AccountScalarFieldEnum)[keyof typeof AccountScalarFieldEnum] + + +export const AppInstallScalarFieldEnum = { + id: 'id', + deviceId: 'deviceId', + appId: 'appId', + token: 'token', + note: 'note', + installedAt: 'installedAt', + updatedAt: 'updatedAt', + deviceType: 'deviceType', + isReadOnly: 'isReadOnly' +} as const + +export type AppInstallScalarFieldEnum = (typeof AppInstallScalarFieldEnum)[keyof typeof AppInstallScalarFieldEnum] + + +export const AutoAuthScalarFieldEnum = { + id: 'id', + deviceId: 'deviceId', + password: 'password', + deviceType: 'deviceType', + isReadOnly: 'isReadOnly', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type AutoAuthScalarFieldEnum = (typeof AutoAuthScalarFieldEnum)[keyof typeof AutoAuthScalarFieldEnum] + + +export const DeviceScalarFieldEnum = { + id: 'id', + uuid: 'uuid', + name: 'name', + accountId: 'accountId', + createdAt: 'createdAt', + updatedAt: 'updatedAt', + password: 'password', + passwordHint: 'passwordHint', + namespace: 'namespace' +} as const + +export type DeviceScalarFieldEnum = (typeof DeviceScalarFieldEnum)[keyof typeof DeviceScalarFieldEnum] + + +export const KVStoreScalarFieldEnum = { + deviceId: 'deviceId', + key: 'key', + value: 'value', + creatorIp: 'creatorIp', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type KVStoreScalarFieldEnum = (typeof KVStoreScalarFieldEnum)[keyof typeof KVStoreScalarFieldEnum] + + +export const SortOrder = { + asc: 'asc', + desc: 'desc' +} as const + +export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder] + + +export const NullableJsonNullValueInput = { + DbNull: DbNull, + JsonNull: JsonNull +} as const + +export type NullableJsonNullValueInput = (typeof NullableJsonNullValueInput)[keyof typeof NullableJsonNullValueInput] + + +export const JsonNullValueInput = { + JsonNull: JsonNull +} as const + +export type JsonNullValueInput = (typeof JsonNullValueInput)[keyof typeof JsonNullValueInput] + + +export const QueryMode = { + default: 'default', + insensitive: 'insensitive' +} as const + +export type QueryMode = (typeof QueryMode)[keyof typeof QueryMode] + + +export const JsonNullValueFilter = { + DbNull: DbNull, + JsonNull: JsonNull, + AnyNull: AnyNull +} as const + +export type JsonNullValueFilter = (typeof JsonNullValueFilter)[keyof typeof JsonNullValueFilter] + + +export const NullsOrder = { + first: 'first', + last: 'last' +} as const + +export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder] + + + +/** + * Field references + */ + + +/** + * Reference to a field of type 'String' + */ +export type StringFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'String'> + + + +/** + * Reference to a field of type 'String[]' + */ +export type ListStringFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'String[]'> + + + +/** + * Reference to a field of type 'Json' + */ +export type JsonFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Json'> + + + +/** + * Reference to a field of type 'QueryMode' + */ +export type EnumQueryModeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'QueryMode'> + + + +/** + * Reference to a field of type 'DateTime' + */ +export type DateTimeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'DateTime'> + + + +/** + * Reference to a field of type 'DateTime[]' + */ +export type ListDateTimeFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'DateTime[]'> + + + +/** + * Reference to a field of type 'Int' + */ +export type IntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int'> + + + +/** + * Reference to a field of type 'Int[]' + */ +export type ListIntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Int[]'> + + + +/** + * Reference to a field of type 'Boolean' + */ +export type BooleanFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Boolean'> + + + +/** + * Reference to a field of type 'Float' + */ +export type FloatFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Float'> + + + +/** + * Reference to a field of type 'Float[]' + */ +export type ListFloatFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, 'Float[]'> + + +/** + * Batch Payload for updateMany & deleteMany & createMany + */ +export type BatchPayload = { + count: number +} + +export const defineExtension = runtime.Extensions.defineExtension as unknown as runtime.Types.Extensions.ExtendsHook<"define", TypeMapCb, runtime.Types.Extensions.DefaultArgs> +export type DefaultPrismaClient = PrismaClient +export type ErrorFormat = 'pretty' | 'colorless' | 'minimal' +export type PrismaClientOptions = ({ + /** + * Instance of a Driver Adapter, e.g., like one provided by `@prisma/adapter-pg`. + */ + adapter: runtime.SqlDriverAdapterFactory + accelerateUrl?: never +} | { + /** + * Prisma Accelerate URL allowing the client to connect through Accelerate instead of a direct database. + */ + accelerateUrl: string + adapter?: never +}) & { + /** + * @default "colorless" + */ + errorFormat?: ErrorFormat + /** + * @example + * ``` + * // Shorthand for `emit: 'stdout'` + * log: ['query', 'info', 'warn', 'error'] + * + * // Emit as events only + * log: [ + * { emit: 'event', level: 'query' }, + * { emit: 'event', level: 'info' }, + * { emit: 'event', level: 'warn' } + * { emit: 'event', level: 'error' } + * ] + * + * / Emit as events and log to stdout + * og: [ + * { emit: 'stdout', level: 'query' }, + * { emit: 'stdout', level: 'info' }, + * { emit: 'stdout', level: 'warn' } + * { emit: 'stdout', level: 'error' } + * + * ``` + * Read more in our [docs](https://pris.ly/d/logging). + */ + log?: (LogLevel | LogDefinition)[] + /** + * The default values for transactionOptions + * maxWait ?= 2000 + * timeout ?= 5000 + */ + transactionOptions?: { + maxWait?: number + timeout?: number + isolationLevel?: TransactionIsolationLevel + } + /** + * Global configuration for omitting model fields by default. + * + * @example + * ``` + * const prisma = new PrismaClient({ + * omit: { + * user: { + * password: true + * } + * } + * }) + * ``` + */ + omit?: GlobalOmitConfig + /** + * SQL commenter plugins that add metadata to SQL queries as comments. + * Comments follow the sqlcommenter format: https://google.github.io/sqlcommenter/ + * + * @example + * ``` + * const prisma = new PrismaClient({ + * adapter, + * comments: [ + * traceContext(), + * queryInsights(), + * ], + * }) + * ``` + */ + comments?: runtime.SqlCommenterPlugin[] +} +export type GlobalOmitConfig = { + account?: Prisma.AccountOmit + appInstall?: Prisma.AppInstallOmit + autoAuth?: Prisma.AutoAuthOmit + device?: Prisma.DeviceOmit + kVStore?: Prisma.KVStoreOmit +} + +/* Types for Logging */ +export type LogLevel = 'info' | 'query' | 'warn' | 'error' +export type LogDefinition = { + level: LogLevel + emit: 'stdout' | 'event' +} + +export type CheckIsLogLevel = T extends LogLevel ? T : never; + +export type GetLogType = CheckIsLogLevel< + T extends LogDefinition ? T['level'] : T +>; + +export type GetEvents = T extends Array + ? GetLogType + : never; + +export type QueryEvent = { + timestamp: Date + query: string + params: string + duration: number + target: string +} + +export type LogEvent = { + timestamp: Date + message: string + target: string +} +/* End Types for Logging */ + + +export type PrismaAction = + | 'findUnique' + | 'findUniqueOrThrow' + | 'findMany' + | 'findFirst' + | 'findFirstOrThrow' + | 'create' + | 'createMany' + | 'createManyAndReturn' + | 'update' + | 'updateMany' + | 'updateManyAndReturn' + | 'upsert' + | 'delete' + | 'deleteMany' + | 'executeRaw' + | 'queryRaw' + | 'aggregate' + | 'count' + | 'runCommandRaw' + | 'findRaw' + | 'groupBy' + +/** + * `PrismaClient` proxy available in interactive transactions. + */ +export type TransactionClient = Omit + diff --git a/generated/prisma/internal/prismaNamespaceBrowser.ts b/generated/prisma/internal/prismaNamespaceBrowser.ts new file mode 100644 index 0000000..6967530 --- /dev/null +++ b/generated/prisma/internal/prismaNamespaceBrowser.ts @@ -0,0 +1,197 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * WARNING: This is an internal file that is subject to change! + * + * 🛑 Under no circumstances should you import this file directly! 🛑 + * + * All exports from this file are wrapped under a `Prisma` namespace object in the browser.ts file. + * While this enables partial backward compatibility, it is not part of the stable public API. + * + * If you are looking for your Models, Enums, and Input Types, please import them from the respective + * model files in the `model` directory! + */ + +import * as runtime from "@prisma/client/runtime/index-browser" + +export type * from '../models.ts' +export type * from './prismaNamespace.ts' + +export const Decimal = runtime.Decimal + + +export const NullTypes = { + DbNull: runtime.NullTypes.DbNull as (new (secret: never) => typeof runtime.DbNull), + JsonNull: runtime.NullTypes.JsonNull as (new (secret: never) => typeof runtime.JsonNull), + AnyNull: runtime.NullTypes.AnyNull as (new (secret: never) => typeof runtime.AnyNull), +} +/** + * Helper for filtering JSON entries that have `null` on the database (empty on the db) + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ +export const DbNull = runtime.DbNull + +/** + * Helper for filtering JSON entries that have JSON `null` values (not empty on the db) + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ +export const JsonNull = runtime.JsonNull + +/** + * Helper for filtering JSON entries that are `Prisma.DbNull` or `Prisma.JsonNull` + * + * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field + */ +export const AnyNull = runtime.AnyNull + + +export const ModelName = { + Account: 'Account', + AppInstall: 'AppInstall', + AutoAuth: 'AutoAuth', + Device: 'Device', + KVStore: 'KVStore' +} as const + +export type ModelName = (typeof ModelName)[keyof typeof ModelName] + +/* + * Enums + */ + +export const TransactionIsolationLevel = runtime.makeStrictEnum({ + ReadUncommitted: 'ReadUncommitted', + ReadCommitted: 'ReadCommitted', + RepeatableRead: 'RepeatableRead', + Serializable: 'Serializable' +} as const) + +export type TransactionIsolationLevel = (typeof TransactionIsolationLevel)[keyof typeof TransactionIsolationLevel] + + +export const AccountScalarFieldEnum = { + id: 'id', + provider: 'provider', + providerId: 'providerId', + email: 'email', + name: 'name', + avatarUrl: 'avatarUrl', + providerData: 'providerData', + accessToken: 'accessToken', + createdAt: 'createdAt', + updatedAt: 'updatedAt', + refreshToken: 'refreshToken', + refreshTokenExpiry: 'refreshTokenExpiry', + tokenVersion: 'tokenVersion' +} as const + +export type AccountScalarFieldEnum = (typeof AccountScalarFieldEnum)[keyof typeof AccountScalarFieldEnum] + + +export const AppInstallScalarFieldEnum = { + id: 'id', + deviceId: 'deviceId', + appId: 'appId', + token: 'token', + note: 'note', + installedAt: 'installedAt', + updatedAt: 'updatedAt', + deviceType: 'deviceType', + isReadOnly: 'isReadOnly' +} as const + +export type AppInstallScalarFieldEnum = (typeof AppInstallScalarFieldEnum)[keyof typeof AppInstallScalarFieldEnum] + + +export const AutoAuthScalarFieldEnum = { + id: 'id', + deviceId: 'deviceId', + password: 'password', + deviceType: 'deviceType', + isReadOnly: 'isReadOnly', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type AutoAuthScalarFieldEnum = (typeof AutoAuthScalarFieldEnum)[keyof typeof AutoAuthScalarFieldEnum] + + +export const DeviceScalarFieldEnum = { + id: 'id', + uuid: 'uuid', + name: 'name', + accountId: 'accountId', + createdAt: 'createdAt', + updatedAt: 'updatedAt', + password: 'password', + passwordHint: 'passwordHint', + namespace: 'namespace' +} as const + +export type DeviceScalarFieldEnum = (typeof DeviceScalarFieldEnum)[keyof typeof DeviceScalarFieldEnum] + + +export const KVStoreScalarFieldEnum = { + deviceId: 'deviceId', + key: 'key', + value: 'value', + creatorIp: 'creatorIp', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type KVStoreScalarFieldEnum = (typeof KVStoreScalarFieldEnum)[keyof typeof KVStoreScalarFieldEnum] + + +export const SortOrder = { + asc: 'asc', + desc: 'desc' +} as const + +export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder] + + +export const NullableJsonNullValueInput = { + DbNull: DbNull, + JsonNull: JsonNull +} as const + +export type NullableJsonNullValueInput = (typeof NullableJsonNullValueInput)[keyof typeof NullableJsonNullValueInput] + + +export const JsonNullValueInput = { + JsonNull: JsonNull +} as const + +export type JsonNullValueInput = (typeof JsonNullValueInput)[keyof typeof JsonNullValueInput] + + +export const QueryMode = { + default: 'default', + insensitive: 'insensitive' +} as const + +export type QueryMode = (typeof QueryMode)[keyof typeof QueryMode] + + +export const JsonNullValueFilter = { + DbNull: DbNull, + JsonNull: JsonNull, + AnyNull: AnyNull +} as const + +export type JsonNullValueFilter = (typeof JsonNullValueFilter)[keyof typeof JsonNullValueFilter] + + +export const NullsOrder = { + first: 'first', + last: 'last' +} as const + +export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder] + diff --git a/generated/prisma/models.ts b/generated/prisma/models.ts new file mode 100644 index 0000000..5a83d0c --- /dev/null +++ b/generated/prisma/models.ts @@ -0,0 +1,16 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This is a barrel export file for all models and their related types. + * + * 🟢 You can import this file directly. + */ +export type * from './models/Account.ts' +export type * from './models/AppInstall.ts' +export type * from './models/AutoAuth.ts' +export type * from './models/Device.ts' +export type * from './models/KVStore.ts' +export type * from './commonInputTypes.ts' \ No newline at end of file diff --git a/generated/prisma/models/Account.ts b/generated/prisma/models/Account.ts new file mode 100644 index 0000000..884c1ac --- /dev/null +++ b/generated/prisma/models/Account.ts @@ -0,0 +1,1648 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `Account` model and its related types. + * + * 🟢 You can import this file directly. + */ +import type * as runtime from "@prisma/client/runtime/client" +import type * as $Enums from "../enums.ts" +import type * as Prisma from "../internal/prismaNamespace.ts" + +/** + * Model Account + * + */ +export type AccountModel = runtime.Types.Result.DefaultSelection + +export type AggregateAccount = { + _count: AccountCountAggregateOutputType | null + _avg: AccountAvgAggregateOutputType | null + _sum: AccountSumAggregateOutputType | null + _min: AccountMinAggregateOutputType | null + _max: AccountMaxAggregateOutputType | null +} + +export type AccountAvgAggregateOutputType = { + tokenVersion: number | null +} + +export type AccountSumAggregateOutputType = { + tokenVersion: number | null +} + +export type AccountMinAggregateOutputType = { + id: string | null + provider: string | null + providerId: string | null + email: string | null + name: string | null + avatarUrl: string | null + accessToken: string | null + createdAt: Date | null + updatedAt: Date | null + refreshToken: string | null + refreshTokenExpiry: Date | null + tokenVersion: number | null +} + +export type AccountMaxAggregateOutputType = { + id: string | null + provider: string | null + providerId: string | null + email: string | null + name: string | null + avatarUrl: string | null + accessToken: string | null + createdAt: Date | null + updatedAt: Date | null + refreshToken: string | null + refreshTokenExpiry: Date | null + tokenVersion: number | null +} + +export type AccountCountAggregateOutputType = { + id: number + provider: number + providerId: number + email: number + name: number + avatarUrl: number + providerData: number + accessToken: number + createdAt: number + updatedAt: number + refreshToken: number + refreshTokenExpiry: number + tokenVersion: number + _all: number +} + + +export type AccountAvgAggregateInputType = { + tokenVersion?: true +} + +export type AccountSumAggregateInputType = { + tokenVersion?: true +} + +export type AccountMinAggregateInputType = { + id?: true + provider?: true + providerId?: true + email?: true + name?: true + avatarUrl?: true + accessToken?: true + createdAt?: true + updatedAt?: true + refreshToken?: true + refreshTokenExpiry?: true + tokenVersion?: true +} + +export type AccountMaxAggregateInputType = { + id?: true + provider?: true + providerId?: true + email?: true + name?: true + avatarUrl?: true + accessToken?: true + createdAt?: true + updatedAt?: true + refreshToken?: true + refreshTokenExpiry?: true + tokenVersion?: true +} + +export type AccountCountAggregateInputType = { + id?: true + provider?: true + providerId?: true + email?: true + name?: true + avatarUrl?: true + providerData?: true + accessToken?: true + createdAt?: true + updatedAt?: true + refreshToken?: true + refreshTokenExpiry?: true + tokenVersion?: true + _all?: true +} + +export type AccountAggregateArgs = { + /** + * Filter which Account to aggregate. + */ + where?: Prisma.AccountWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Accounts to fetch. + */ + orderBy?: Prisma.AccountOrderByWithRelationInput | Prisma.AccountOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.AccountWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Accounts from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Accounts. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned Accounts + **/ + _count?: true | AccountCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ + _avg?: AccountAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ + _sum?: AccountSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: AccountMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: AccountMaxAggregateInputType +} + +export type GetAccountAggregateType = { + [P in keyof T & keyof AggregateAccount]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type AccountGroupByArgs = { + where?: Prisma.AccountWhereInput + orderBy?: Prisma.AccountOrderByWithAggregationInput | Prisma.AccountOrderByWithAggregationInput[] + by: Prisma.AccountScalarFieldEnum[] | Prisma.AccountScalarFieldEnum + having?: Prisma.AccountScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: AccountCountAggregateInputType | true + _avg?: AccountAvgAggregateInputType + _sum?: AccountSumAggregateInputType + _min?: AccountMinAggregateInputType + _max?: AccountMaxAggregateInputType +} + +export type AccountGroupByOutputType = { + id: string + provider: string + providerId: string + email: string | null + name: string | null + avatarUrl: string | null + providerData: runtime.JsonValue | null + accessToken: string | null + createdAt: Date + updatedAt: Date + refreshToken: string | null + refreshTokenExpiry: Date | null + tokenVersion: number + _count: AccountCountAggregateOutputType | null + _avg: AccountAvgAggregateOutputType | null + _sum: AccountSumAggregateOutputType | null + _min: AccountMinAggregateOutputType | null + _max: AccountMaxAggregateOutputType | null +} + +type GetAccountGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof AccountGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type AccountWhereInput = { + AND?: Prisma.AccountWhereInput | Prisma.AccountWhereInput[] + OR?: Prisma.AccountWhereInput[] + NOT?: Prisma.AccountWhereInput | Prisma.AccountWhereInput[] + id?: Prisma.StringFilter<"Account"> | string + provider?: Prisma.StringFilter<"Account"> | string + providerId?: Prisma.StringFilter<"Account"> | string + email?: Prisma.StringNullableFilter<"Account"> | string | null + name?: Prisma.StringNullableFilter<"Account"> | string | null + avatarUrl?: Prisma.StringNullableFilter<"Account"> | string | null + providerData?: Prisma.JsonNullableFilter<"Account"> + accessToken?: Prisma.StringNullableFilter<"Account"> | string | null + createdAt?: Prisma.DateTimeFilter<"Account"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Account"> | Date | string + refreshToken?: Prisma.StringNullableFilter<"Account"> | string | null + refreshTokenExpiry?: Prisma.DateTimeNullableFilter<"Account"> | Date | string | null + tokenVersion?: Prisma.IntFilter<"Account"> | number + devices?: Prisma.DeviceListRelationFilter +} + +export type AccountOrderByWithRelationInput = { + id?: Prisma.SortOrder + provider?: Prisma.SortOrder + providerId?: Prisma.SortOrder + email?: Prisma.SortOrderInput | Prisma.SortOrder + name?: Prisma.SortOrderInput | Prisma.SortOrder + avatarUrl?: Prisma.SortOrderInput | Prisma.SortOrder + providerData?: Prisma.SortOrderInput | Prisma.SortOrder + accessToken?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + refreshToken?: Prisma.SortOrderInput | Prisma.SortOrder + refreshTokenExpiry?: Prisma.SortOrderInput | Prisma.SortOrder + tokenVersion?: Prisma.SortOrder + devices?: Prisma.DeviceOrderByRelationAggregateInput +} + +export type AccountWhereUniqueInput = Prisma.AtLeast<{ + id?: string + provider_providerId?: Prisma.AccountProviderProviderIdCompoundUniqueInput + AND?: Prisma.AccountWhereInput | Prisma.AccountWhereInput[] + OR?: Prisma.AccountWhereInput[] + NOT?: Prisma.AccountWhereInput | Prisma.AccountWhereInput[] + provider?: Prisma.StringFilter<"Account"> | string + providerId?: Prisma.StringFilter<"Account"> | string + email?: Prisma.StringNullableFilter<"Account"> | string | null + name?: Prisma.StringNullableFilter<"Account"> | string | null + avatarUrl?: Prisma.StringNullableFilter<"Account"> | string | null + providerData?: Prisma.JsonNullableFilter<"Account"> + accessToken?: Prisma.StringNullableFilter<"Account"> | string | null + createdAt?: Prisma.DateTimeFilter<"Account"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Account"> | Date | string + refreshToken?: Prisma.StringNullableFilter<"Account"> | string | null + refreshTokenExpiry?: Prisma.DateTimeNullableFilter<"Account"> | Date | string | null + tokenVersion?: Prisma.IntFilter<"Account"> | number + devices?: Prisma.DeviceListRelationFilter +}, "id" | "provider_providerId"> + +export type AccountOrderByWithAggregationInput = { + id?: Prisma.SortOrder + provider?: Prisma.SortOrder + providerId?: Prisma.SortOrder + email?: Prisma.SortOrderInput | Prisma.SortOrder + name?: Prisma.SortOrderInput | Prisma.SortOrder + avatarUrl?: Prisma.SortOrderInput | Prisma.SortOrder + providerData?: Prisma.SortOrderInput | Prisma.SortOrder + accessToken?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + refreshToken?: Prisma.SortOrderInput | Prisma.SortOrder + refreshTokenExpiry?: Prisma.SortOrderInput | Prisma.SortOrder + tokenVersion?: Prisma.SortOrder + _count?: Prisma.AccountCountOrderByAggregateInput + _avg?: Prisma.AccountAvgOrderByAggregateInput + _max?: Prisma.AccountMaxOrderByAggregateInput + _min?: Prisma.AccountMinOrderByAggregateInput + _sum?: Prisma.AccountSumOrderByAggregateInput +} + +export type AccountScalarWhereWithAggregatesInput = { + AND?: Prisma.AccountScalarWhereWithAggregatesInput | Prisma.AccountScalarWhereWithAggregatesInput[] + OR?: Prisma.AccountScalarWhereWithAggregatesInput[] + NOT?: Prisma.AccountScalarWhereWithAggregatesInput | Prisma.AccountScalarWhereWithAggregatesInput[] + id?: Prisma.StringWithAggregatesFilter<"Account"> | string + provider?: Prisma.StringWithAggregatesFilter<"Account"> | string + providerId?: Prisma.StringWithAggregatesFilter<"Account"> | string + email?: Prisma.StringNullableWithAggregatesFilter<"Account"> | string | null + name?: Prisma.StringNullableWithAggregatesFilter<"Account"> | string | null + avatarUrl?: Prisma.StringNullableWithAggregatesFilter<"Account"> | string | null + providerData?: Prisma.JsonNullableWithAggregatesFilter<"Account"> + accessToken?: Prisma.StringNullableWithAggregatesFilter<"Account"> | string | null + createdAt?: Prisma.DateTimeWithAggregatesFilter<"Account"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"Account"> | Date | string + refreshToken?: Prisma.StringNullableWithAggregatesFilter<"Account"> | string | null + refreshTokenExpiry?: Prisma.DateTimeNullableWithAggregatesFilter<"Account"> | Date | string | null + tokenVersion?: Prisma.IntWithAggregatesFilter<"Account"> | number +} + +export type AccountCreateInput = { + id: string + provider: string + providerId: string + email?: string | null + name?: string | null + avatarUrl?: string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + refreshToken?: string | null + refreshTokenExpiry?: Date | string | null + tokenVersion?: number + devices?: Prisma.DeviceCreateNestedManyWithoutAccountInput +} + +export type AccountUncheckedCreateInput = { + id: string + provider: string + providerId: string + email?: string | null + name?: string | null + avatarUrl?: string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + refreshToken?: string | null + refreshTokenExpiry?: Date | string | null + tokenVersion?: number + devices?: Prisma.DeviceUncheckedCreateNestedManyWithoutAccountInput +} + +export type AccountUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + provider?: Prisma.StringFieldUpdateOperationsInput | string + providerId?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + avatarUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + refreshToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + refreshTokenExpiry?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + tokenVersion?: Prisma.IntFieldUpdateOperationsInput | number + devices?: Prisma.DeviceUpdateManyWithoutAccountNestedInput +} + +export type AccountUncheckedUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + provider?: Prisma.StringFieldUpdateOperationsInput | string + providerId?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + avatarUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + refreshToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + refreshTokenExpiry?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + tokenVersion?: Prisma.IntFieldUpdateOperationsInput | number + devices?: Prisma.DeviceUncheckedUpdateManyWithoutAccountNestedInput +} + +export type AccountCreateManyInput = { + id: string + provider: string + providerId: string + email?: string | null + name?: string | null + avatarUrl?: string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + refreshToken?: string | null + refreshTokenExpiry?: Date | string | null + tokenVersion?: number +} + +export type AccountUpdateManyMutationInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + provider?: Prisma.StringFieldUpdateOperationsInput | string + providerId?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + avatarUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + refreshToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + refreshTokenExpiry?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + tokenVersion?: Prisma.IntFieldUpdateOperationsInput | number +} + +export type AccountUncheckedUpdateManyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + provider?: Prisma.StringFieldUpdateOperationsInput | string + providerId?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + avatarUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + refreshToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + refreshTokenExpiry?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + tokenVersion?: Prisma.IntFieldUpdateOperationsInput | number +} + +export type AccountProviderProviderIdCompoundUniqueInput = { + provider: string + providerId: string +} + +export type AccountCountOrderByAggregateInput = { + id?: Prisma.SortOrder + provider?: Prisma.SortOrder + providerId?: Prisma.SortOrder + email?: Prisma.SortOrder + name?: Prisma.SortOrder + avatarUrl?: Prisma.SortOrder + providerData?: Prisma.SortOrder + accessToken?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + refreshToken?: Prisma.SortOrder + refreshTokenExpiry?: Prisma.SortOrder + tokenVersion?: Prisma.SortOrder +} + +export type AccountAvgOrderByAggregateInput = { + tokenVersion?: Prisma.SortOrder +} + +export type AccountMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + provider?: Prisma.SortOrder + providerId?: Prisma.SortOrder + email?: Prisma.SortOrder + name?: Prisma.SortOrder + avatarUrl?: Prisma.SortOrder + accessToken?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + refreshToken?: Prisma.SortOrder + refreshTokenExpiry?: Prisma.SortOrder + tokenVersion?: Prisma.SortOrder +} + +export type AccountMinOrderByAggregateInput = { + id?: Prisma.SortOrder + provider?: Prisma.SortOrder + providerId?: Prisma.SortOrder + email?: Prisma.SortOrder + name?: Prisma.SortOrder + avatarUrl?: Prisma.SortOrder + accessToken?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + refreshToken?: Prisma.SortOrder + refreshTokenExpiry?: Prisma.SortOrder + tokenVersion?: Prisma.SortOrder +} + +export type AccountSumOrderByAggregateInput = { + tokenVersion?: Prisma.SortOrder +} + +export type AccountNullableScalarRelationFilter = { + is?: Prisma.AccountWhereInput | null + isNot?: Prisma.AccountWhereInput | null +} + +export type StringFieldUpdateOperationsInput = { + set?: string +} + +export type NullableStringFieldUpdateOperationsInput = { + set?: string | null +} + +export type DateTimeFieldUpdateOperationsInput = { + set?: Date | string +} + +export type NullableDateTimeFieldUpdateOperationsInput = { + set?: Date | string | null +} + +export type IntFieldUpdateOperationsInput = { + set?: number + increment?: number + decrement?: number + multiply?: number + divide?: number +} + +export type AccountCreateNestedOneWithoutDevicesInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.AccountCreateOrConnectWithoutDevicesInput + connect?: Prisma.AccountWhereUniqueInput +} + +export type AccountUpdateOneWithoutDevicesNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.AccountCreateOrConnectWithoutDevicesInput + upsert?: Prisma.AccountUpsertWithoutDevicesInput + disconnect?: Prisma.AccountWhereInput | boolean + delete?: Prisma.AccountWhereInput | boolean + connect?: Prisma.AccountWhereUniqueInput + update?: Prisma.XOR, Prisma.AccountUncheckedUpdateWithoutDevicesInput> +} + +export type AccountCreateWithoutDevicesInput = { + id: string + provider: string + providerId: string + email?: string | null + name?: string | null + avatarUrl?: string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + refreshToken?: string | null + refreshTokenExpiry?: Date | string | null + tokenVersion?: number +} + +export type AccountUncheckedCreateWithoutDevicesInput = { + id: string + provider: string + providerId: string + email?: string | null + name?: string | null + avatarUrl?: string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: string | null + createdAt?: Date | string + updatedAt?: Date | string + refreshToken?: string | null + refreshTokenExpiry?: Date | string | null + tokenVersion?: number +} + +export type AccountCreateOrConnectWithoutDevicesInput = { + where: Prisma.AccountWhereUniqueInput + create: Prisma.XOR +} + +export type AccountUpsertWithoutDevicesInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.AccountWhereInput +} + +export type AccountUpdateToOneWithWhereWithoutDevicesInput = { + where?: Prisma.AccountWhereInput + data: Prisma.XOR +} + +export type AccountUpdateWithoutDevicesInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + provider?: Prisma.StringFieldUpdateOperationsInput | string + providerId?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + avatarUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + refreshToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + refreshTokenExpiry?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + tokenVersion?: Prisma.IntFieldUpdateOperationsInput | number +} + +export type AccountUncheckedUpdateWithoutDevicesInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + provider?: Prisma.StringFieldUpdateOperationsInput | string + providerId?: Prisma.StringFieldUpdateOperationsInput | string + email?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + avatarUrl?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + providerData?: Prisma.NullableJsonNullValueInput | runtime.InputJsonValue + accessToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + refreshToken?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + refreshTokenExpiry?: Prisma.NullableDateTimeFieldUpdateOperationsInput | Date | string | null + tokenVersion?: Prisma.IntFieldUpdateOperationsInput | number +} + + +/** + * Count Type AccountCountOutputType + */ + +export type AccountCountOutputType = { + devices: number +} + +export type AccountCountOutputTypeSelect = { + devices?: boolean | AccountCountOutputTypeCountDevicesArgs +} + +/** + * AccountCountOutputType without action + */ +export type AccountCountOutputTypeDefaultArgs = { + /** + * Select specific fields to fetch from the AccountCountOutputType + */ + select?: Prisma.AccountCountOutputTypeSelect | null +} + +/** + * AccountCountOutputType without action + */ +export type AccountCountOutputTypeCountDevicesArgs = { + where?: Prisma.DeviceWhereInput +} + + +export type AccountSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + provider?: boolean + providerId?: boolean + email?: boolean + name?: boolean + avatarUrl?: boolean + providerData?: boolean + accessToken?: boolean + createdAt?: boolean + updatedAt?: boolean + refreshToken?: boolean + refreshTokenExpiry?: boolean + tokenVersion?: boolean + devices?: boolean | Prisma.Account$devicesArgs + _count?: boolean | Prisma.AccountCountOutputTypeDefaultArgs +}, ExtArgs["result"]["account"]> + +export type AccountSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + provider?: boolean + providerId?: boolean + email?: boolean + name?: boolean + avatarUrl?: boolean + providerData?: boolean + accessToken?: boolean + createdAt?: boolean + updatedAt?: boolean + refreshToken?: boolean + refreshTokenExpiry?: boolean + tokenVersion?: boolean +}, ExtArgs["result"]["account"]> + +export type AccountSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + provider?: boolean + providerId?: boolean + email?: boolean + name?: boolean + avatarUrl?: boolean + providerData?: boolean + accessToken?: boolean + createdAt?: boolean + updatedAt?: boolean + refreshToken?: boolean + refreshTokenExpiry?: boolean + tokenVersion?: boolean +}, ExtArgs["result"]["account"]> + +export type AccountSelectScalar = { + id?: boolean + provider?: boolean + providerId?: boolean + email?: boolean + name?: boolean + avatarUrl?: boolean + providerData?: boolean + accessToken?: boolean + createdAt?: boolean + updatedAt?: boolean + refreshToken?: boolean + refreshTokenExpiry?: boolean + tokenVersion?: boolean +} + +export type AccountOmit = runtime.Types.Extensions.GetOmit<"id" | "provider" | "providerId" | "email" | "name" | "avatarUrl" | "providerData" | "accessToken" | "createdAt" | "updatedAt" | "refreshToken" | "refreshTokenExpiry" | "tokenVersion", ExtArgs["result"]["account"]> +export type AccountInclude = { + devices?: boolean | Prisma.Account$devicesArgs + _count?: boolean | Prisma.AccountCountOutputTypeDefaultArgs +} +export type AccountIncludeCreateManyAndReturn = {} +export type AccountIncludeUpdateManyAndReturn = {} + +export type $AccountPayload = { + name: "Account" + objects: { + devices: Prisma.$DevicePayload[] + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: string + provider: string + providerId: string + email: string | null + name: string | null + avatarUrl: string | null + providerData: runtime.JsonValue | null + accessToken: string | null + createdAt: Date + updatedAt: Date + refreshToken: string | null + refreshTokenExpiry: Date | null + tokenVersion: number + }, ExtArgs["result"]["account"]> + composites: {} +} + +export type AccountGetPayload = runtime.Types.Result.GetResult + +export type AccountCountArgs = + Omit & { + select?: AccountCountAggregateInputType | true + } + +export interface AccountDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['Account'], meta: { name: 'Account' } } + /** + * Find zero or one Account that matches the filter. + * @param {AccountFindUniqueArgs} args - Arguments to find a Account + * @example + * // Get one Account + * const account = await prisma.account.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one Account that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {AccountFindUniqueOrThrowArgs} args - Arguments to find a Account + * @example + * // Get one Account + * const account = await prisma.account.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Account that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AccountFindFirstArgs} args - Arguments to find a Account + * @example + * // Get one Account + * const account = await prisma.account.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Account that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AccountFindFirstOrThrowArgs} args - Arguments to find a Account + * @example + * // Get one Account + * const account = await prisma.account.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more Accounts that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AccountFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all Accounts + * const accounts = await prisma.account.findMany() + * + * // Get first 10 Accounts + * const accounts = await prisma.account.findMany({ take: 10 }) + * + * // Only select the `id` + * const accountWithIdOnly = await prisma.account.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a Account. + * @param {AccountCreateArgs} args - Arguments to create a Account. + * @example + * // Create one Account + * const Account = await prisma.account.create({ + * data: { + * // ... data to create a Account + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many Accounts. + * @param {AccountCreateManyArgs} args - Arguments to create many Accounts. + * @example + * // Create many Accounts + * const account = await prisma.account.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many Accounts and returns the data saved in the database. + * @param {AccountCreateManyAndReturnArgs} args - Arguments to create many Accounts. + * @example + * // Create many Accounts + * const account = await prisma.account.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many Accounts and only return the `id` + * const accountWithIdOnly = await prisma.account.createManyAndReturn({ + * select: { id: true }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + createManyAndReturn(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "createManyAndReturn", GlobalOmitOptions>> + + /** + * Delete a Account. + * @param {AccountDeleteArgs} args - Arguments to delete one Account. + * @example + * // Delete one Account + * const Account = await prisma.account.delete({ + * where: { + * // ... filter to delete one Account + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one Account. + * @param {AccountUpdateArgs} args - Arguments to update one Account. + * @example + * // Update one Account + * const account = await prisma.account.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more Accounts. + * @param {AccountDeleteManyArgs} args - Arguments to filter Accounts to delete. + * @example + * // Delete a few Accounts + * const { count } = await prisma.account.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Accounts. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AccountUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many Accounts + * const account = await prisma.account.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Accounts and returns the data updated in the database. + * @param {AccountUpdateManyAndReturnArgs} args - Arguments to update many Accounts. + * @example + * // Update many Accounts + * const account = await prisma.account.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more Accounts and only return the `id` + * const accountWithIdOnly = await prisma.account.updateManyAndReturn({ + * select: { id: true }, + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + updateManyAndReturn(args: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "updateManyAndReturn", GlobalOmitOptions>> + + /** + * Create or update one Account. + * @param {AccountUpsertArgs} args - Arguments to update or create a Account. + * @example + * // Update or create a Account + * const account = await prisma.account.upsert({ + * create: { + * // ... data to create a Account + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the Account we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__AccountClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of Accounts. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AccountCountArgs} args - Arguments to filter Accounts to count. + * @example + * // Count the number of Accounts + * const count = await prisma.account.count({ + * where: { + * // ... the filter for the Accounts we want to count + * } + * }) + **/ + count( + args?: Prisma.Subset, + ): Prisma.PrismaPromise< + T extends runtime.Types.Utils.Record<'select', any> + ? T['select'] extends true + ? number + : Prisma.GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a Account. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AccountAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Prisma.Subset): Prisma.PrismaPromise> + + /** + * Group by Account. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AccountGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends AccountGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: AccountGroupByArgs['orderBy'] } + : { orderBy?: AccountGroupByArgs['orderBy'] }, + OrderFields extends Prisma.ExcludeUnderscoreKeys>>, + ByFields extends Prisma.MaybeTupleToUnion, + ByValid extends Prisma.Has, + HavingFields extends Prisma.GetHavingFields, + HavingValid extends Prisma.Has, + ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, + InputErrors extends ByEmpty extends Prisma.True + ? `Error: "by" must not be empty.` + : HavingValid extends Prisma.False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: Prisma.SubsetIntersection & InputErrors): {} extends InputErrors ? GetAccountGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the Account model + */ +readonly fields: AccountFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for Account. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ +export interface Prisma__AccountClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + devices = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): runtime.Types.Utils.JsPromise +} + + + + +/** + * Fields of the Account model + */ +export interface AccountFieldRefs { + readonly id: Prisma.FieldRef<"Account", 'String'> + readonly provider: Prisma.FieldRef<"Account", 'String'> + readonly providerId: Prisma.FieldRef<"Account", 'String'> + readonly email: Prisma.FieldRef<"Account", 'String'> + readonly name: Prisma.FieldRef<"Account", 'String'> + readonly avatarUrl: Prisma.FieldRef<"Account", 'String'> + readonly providerData: Prisma.FieldRef<"Account", 'Json'> + readonly accessToken: Prisma.FieldRef<"Account", 'String'> + readonly createdAt: Prisma.FieldRef<"Account", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"Account", 'DateTime'> + readonly refreshToken: Prisma.FieldRef<"Account", 'String'> + readonly refreshTokenExpiry: Prisma.FieldRef<"Account", 'DateTime'> + readonly tokenVersion: Prisma.FieldRef<"Account", 'Int'> +} + + +// Custom InputTypes +/** + * Account findUnique + */ +export type AccountFindUniqueArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * Filter, which Account to fetch. + */ + where: Prisma.AccountWhereUniqueInput +} + +/** + * Account findUniqueOrThrow + */ +export type AccountFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * Filter, which Account to fetch. + */ + where: Prisma.AccountWhereUniqueInput +} + +/** + * Account findFirst + */ +export type AccountFindFirstArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * Filter, which Account to fetch. + */ + where?: Prisma.AccountWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Accounts to fetch. + */ + orderBy?: Prisma.AccountOrderByWithRelationInput | Prisma.AccountOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Accounts. + */ + cursor?: Prisma.AccountWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Accounts from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Accounts. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Accounts. + */ + distinct?: Prisma.AccountScalarFieldEnum | Prisma.AccountScalarFieldEnum[] +} + +/** + * Account findFirstOrThrow + */ +export type AccountFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * Filter, which Account to fetch. + */ + where?: Prisma.AccountWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Accounts to fetch. + */ + orderBy?: Prisma.AccountOrderByWithRelationInput | Prisma.AccountOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Accounts. + */ + cursor?: Prisma.AccountWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Accounts from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Accounts. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Accounts. + */ + distinct?: Prisma.AccountScalarFieldEnum | Prisma.AccountScalarFieldEnum[] +} + +/** + * Account findMany + */ +export type AccountFindManyArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * Filter, which Accounts to fetch. + */ + where?: Prisma.AccountWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Accounts to fetch. + */ + orderBy?: Prisma.AccountOrderByWithRelationInput | Prisma.AccountOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing Accounts. + */ + cursor?: Prisma.AccountWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Accounts from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Accounts. + */ + skip?: number + distinct?: Prisma.AccountScalarFieldEnum | Prisma.AccountScalarFieldEnum[] +} + +/** + * Account create + */ +export type AccountCreateArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * The data needed to create a Account. + */ + data: Prisma.XOR +} + +/** + * Account createMany + */ +export type AccountCreateManyArgs = { + /** + * The data used to create many Accounts. + */ + data: Prisma.AccountCreateManyInput | Prisma.AccountCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * Account createManyAndReturn + */ +export type AccountCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelectCreateManyAndReturn | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * The data used to create many Accounts. + */ + data: Prisma.AccountCreateManyInput | Prisma.AccountCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * Account update + */ +export type AccountUpdateArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * The data needed to update a Account. + */ + data: Prisma.XOR + /** + * Choose, which Account to update. + */ + where: Prisma.AccountWhereUniqueInput +} + +/** + * Account updateMany + */ +export type AccountUpdateManyArgs = { + /** + * The data used to update Accounts. + */ + data: Prisma.XOR + /** + * Filter which Accounts to update + */ + where?: Prisma.AccountWhereInput + /** + * Limit how many Accounts to update. + */ + limit?: number +} + +/** + * Account updateManyAndReturn + */ +export type AccountUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * The data used to update Accounts. + */ + data: Prisma.XOR + /** + * Filter which Accounts to update + */ + where?: Prisma.AccountWhereInput + /** + * Limit how many Accounts to update. + */ + limit?: number +} + +/** + * Account upsert + */ +export type AccountUpsertArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * The filter to search for the Account to update in case it exists. + */ + where: Prisma.AccountWhereUniqueInput + /** + * In case the Account found by the `where` argument doesn't exist, create a new Account with this data. + */ + create: Prisma.XOR + /** + * In case the Account was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * Account delete + */ +export type AccountDeleteArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + /** + * Filter which Account to delete. + */ + where: Prisma.AccountWhereUniqueInput +} + +/** + * Account deleteMany + */ +export type AccountDeleteManyArgs = { + /** + * Filter which Accounts to delete + */ + where?: Prisma.AccountWhereInput + /** + * Limit how many Accounts to delete. + */ + limit?: number +} + +/** + * Account.devices + */ +export type Account$devicesArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + where?: Prisma.DeviceWhereInput + orderBy?: Prisma.DeviceOrderByWithRelationInput | Prisma.DeviceOrderByWithRelationInput[] + cursor?: Prisma.DeviceWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.DeviceScalarFieldEnum | Prisma.DeviceScalarFieldEnum[] +} + +/** + * Account without action + */ +export type AccountDefaultArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null +} diff --git a/generated/prisma/models/AppInstall.ts b/generated/prisma/models/AppInstall.ts new file mode 100644 index 0000000..0db3ead --- /dev/null +++ b/generated/prisma/models/AppInstall.ts @@ -0,0 +1,1528 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `AppInstall` model and its related types. + * + * 🟢 You can import this file directly. + */ +import type * as runtime from "@prisma/client/runtime/client" +import type * as $Enums from "../enums.ts" +import type * as Prisma from "../internal/prismaNamespace.ts" + +/** + * Model AppInstall + * + */ +export type AppInstallModel = runtime.Types.Result.DefaultSelection + +export type AggregateAppInstall = { + _count: AppInstallCountAggregateOutputType | null + _avg: AppInstallAvgAggregateOutputType | null + _sum: AppInstallSumAggregateOutputType | null + _min: AppInstallMinAggregateOutputType | null + _max: AppInstallMaxAggregateOutputType | null +} + +export type AppInstallAvgAggregateOutputType = { + deviceId: number | null +} + +export type AppInstallSumAggregateOutputType = { + deviceId: number | null +} + +export type AppInstallMinAggregateOutputType = { + id: string | null + deviceId: number | null + appId: string | null + token: string | null + note: string | null + installedAt: Date | null + updatedAt: Date | null + deviceType: string | null + isReadOnly: boolean | null +} + +export type AppInstallMaxAggregateOutputType = { + id: string | null + deviceId: number | null + appId: string | null + token: string | null + note: string | null + installedAt: Date | null + updatedAt: Date | null + deviceType: string | null + isReadOnly: boolean | null +} + +export type AppInstallCountAggregateOutputType = { + id: number + deviceId: number + appId: number + token: number + note: number + installedAt: number + updatedAt: number + deviceType: number + isReadOnly: number + _all: number +} + + +export type AppInstallAvgAggregateInputType = { + deviceId?: true +} + +export type AppInstallSumAggregateInputType = { + deviceId?: true +} + +export type AppInstallMinAggregateInputType = { + id?: true + deviceId?: true + appId?: true + token?: true + note?: true + installedAt?: true + updatedAt?: true + deviceType?: true + isReadOnly?: true +} + +export type AppInstallMaxAggregateInputType = { + id?: true + deviceId?: true + appId?: true + token?: true + note?: true + installedAt?: true + updatedAt?: true + deviceType?: true + isReadOnly?: true +} + +export type AppInstallCountAggregateInputType = { + id?: true + deviceId?: true + appId?: true + token?: true + note?: true + installedAt?: true + updatedAt?: true + deviceType?: true + isReadOnly?: true + _all?: true +} + +export type AppInstallAggregateArgs = { + /** + * Filter which AppInstall to aggregate. + */ + where?: Prisma.AppInstallWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AppInstalls to fetch. + */ + orderBy?: Prisma.AppInstallOrderByWithRelationInput | Prisma.AppInstallOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.AppInstallWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AppInstalls from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AppInstalls. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned AppInstalls + **/ + _count?: true | AppInstallCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ + _avg?: AppInstallAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ + _sum?: AppInstallSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: AppInstallMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: AppInstallMaxAggregateInputType +} + +export type GetAppInstallAggregateType = { + [P in keyof T & keyof AggregateAppInstall]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type AppInstallGroupByArgs = { + where?: Prisma.AppInstallWhereInput + orderBy?: Prisma.AppInstallOrderByWithAggregationInput | Prisma.AppInstallOrderByWithAggregationInput[] + by: Prisma.AppInstallScalarFieldEnum[] | Prisma.AppInstallScalarFieldEnum + having?: Prisma.AppInstallScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: AppInstallCountAggregateInputType | true + _avg?: AppInstallAvgAggregateInputType + _sum?: AppInstallSumAggregateInputType + _min?: AppInstallMinAggregateInputType + _max?: AppInstallMaxAggregateInputType +} + +export type AppInstallGroupByOutputType = { + id: string + deviceId: number + appId: string + token: string + note: string | null + installedAt: Date + updatedAt: Date + deviceType: string | null + isReadOnly: boolean + _count: AppInstallCountAggregateOutputType | null + _avg: AppInstallAvgAggregateOutputType | null + _sum: AppInstallSumAggregateOutputType | null + _min: AppInstallMinAggregateOutputType | null + _max: AppInstallMaxAggregateOutputType | null +} + +type GetAppInstallGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof AppInstallGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type AppInstallWhereInput = { + AND?: Prisma.AppInstallWhereInput | Prisma.AppInstallWhereInput[] + OR?: Prisma.AppInstallWhereInput[] + NOT?: Prisma.AppInstallWhereInput | Prisma.AppInstallWhereInput[] + id?: Prisma.StringFilter<"AppInstall"> | string + deviceId?: Prisma.IntFilter<"AppInstall"> | number + appId?: Prisma.StringFilter<"AppInstall"> | string + token?: Prisma.StringFilter<"AppInstall"> | string + note?: Prisma.StringNullableFilter<"AppInstall"> | string | null + installedAt?: Prisma.DateTimeFilter<"AppInstall"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"AppInstall"> | Date | string + deviceType?: Prisma.StringNullableFilter<"AppInstall"> | string | null + isReadOnly?: Prisma.BoolFilter<"AppInstall"> | boolean + device?: Prisma.XOR +} + +export type AppInstallOrderByWithRelationInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + appId?: Prisma.SortOrder + token?: Prisma.SortOrder + note?: Prisma.SortOrderInput | Prisma.SortOrder + installedAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + deviceType?: Prisma.SortOrderInput | Prisma.SortOrder + isReadOnly?: Prisma.SortOrder + device?: Prisma.DeviceOrderByWithRelationInput +} + +export type AppInstallWhereUniqueInput = Prisma.AtLeast<{ + id?: string + token?: string + AND?: Prisma.AppInstallWhereInput | Prisma.AppInstallWhereInput[] + OR?: Prisma.AppInstallWhereInput[] + NOT?: Prisma.AppInstallWhereInput | Prisma.AppInstallWhereInput[] + deviceId?: Prisma.IntFilter<"AppInstall"> | number + appId?: Prisma.StringFilter<"AppInstall"> | string + note?: Prisma.StringNullableFilter<"AppInstall"> | string | null + installedAt?: Prisma.DateTimeFilter<"AppInstall"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"AppInstall"> | Date | string + deviceType?: Prisma.StringNullableFilter<"AppInstall"> | string | null + isReadOnly?: Prisma.BoolFilter<"AppInstall"> | boolean + device?: Prisma.XOR +}, "id" | "token"> + +export type AppInstallOrderByWithAggregationInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + appId?: Prisma.SortOrder + token?: Prisma.SortOrder + note?: Prisma.SortOrderInput | Prisma.SortOrder + installedAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + deviceType?: Prisma.SortOrderInput | Prisma.SortOrder + isReadOnly?: Prisma.SortOrder + _count?: Prisma.AppInstallCountOrderByAggregateInput + _avg?: Prisma.AppInstallAvgOrderByAggregateInput + _max?: Prisma.AppInstallMaxOrderByAggregateInput + _min?: Prisma.AppInstallMinOrderByAggregateInput + _sum?: Prisma.AppInstallSumOrderByAggregateInput +} + +export type AppInstallScalarWhereWithAggregatesInput = { + AND?: Prisma.AppInstallScalarWhereWithAggregatesInput | Prisma.AppInstallScalarWhereWithAggregatesInput[] + OR?: Prisma.AppInstallScalarWhereWithAggregatesInput[] + NOT?: Prisma.AppInstallScalarWhereWithAggregatesInput | Prisma.AppInstallScalarWhereWithAggregatesInput[] + id?: Prisma.StringWithAggregatesFilter<"AppInstall"> | string + deviceId?: Prisma.IntWithAggregatesFilter<"AppInstall"> | number + appId?: Prisma.StringWithAggregatesFilter<"AppInstall"> | string + token?: Prisma.StringWithAggregatesFilter<"AppInstall"> | string + note?: Prisma.StringNullableWithAggregatesFilter<"AppInstall"> | string | null + installedAt?: Prisma.DateTimeWithAggregatesFilter<"AppInstall"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"AppInstall"> | Date | string + deviceType?: Prisma.StringNullableWithAggregatesFilter<"AppInstall"> | string | null + isReadOnly?: Prisma.BoolWithAggregatesFilter<"AppInstall"> | boolean +} + +export type AppInstallCreateInput = { + id: string + appId: string + token: string + note?: string | null + installedAt?: Date | string + updatedAt?: Date | string + deviceType?: string | null + isReadOnly?: boolean + device: Prisma.DeviceCreateNestedOneWithoutAppInstallsInput +} + +export type AppInstallUncheckedCreateInput = { + id: string + deviceId: number + appId: string + token: string + note?: string | null + installedAt?: Date | string + updatedAt?: Date | string + deviceType?: string | null + isReadOnly?: boolean +} + +export type AppInstallUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + appId?: Prisma.StringFieldUpdateOperationsInput | string + token?: Prisma.StringFieldUpdateOperationsInput | string + note?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + installedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + device?: Prisma.DeviceUpdateOneRequiredWithoutAppInstallsNestedInput +} + +export type AppInstallUncheckedUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + deviceId?: Prisma.IntFieldUpdateOperationsInput | number + appId?: Prisma.StringFieldUpdateOperationsInput | string + token?: Prisma.StringFieldUpdateOperationsInput | string + note?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + installedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean +} + +export type AppInstallCreateManyInput = { + id: string + deviceId: number + appId: string + token: string + note?: string | null + installedAt?: Date | string + updatedAt?: Date | string + deviceType?: string | null + isReadOnly?: boolean +} + +export type AppInstallUpdateManyMutationInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + appId?: Prisma.StringFieldUpdateOperationsInput | string + token?: Prisma.StringFieldUpdateOperationsInput | string + note?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + installedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean +} + +export type AppInstallUncheckedUpdateManyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + deviceId?: Prisma.IntFieldUpdateOperationsInput | number + appId?: Prisma.StringFieldUpdateOperationsInput | string + token?: Prisma.StringFieldUpdateOperationsInput | string + note?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + installedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean +} + +export type AppInstallCountOrderByAggregateInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + appId?: Prisma.SortOrder + token?: Prisma.SortOrder + note?: Prisma.SortOrder + installedAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + deviceType?: Prisma.SortOrder + isReadOnly?: Prisma.SortOrder +} + +export type AppInstallAvgOrderByAggregateInput = { + deviceId?: Prisma.SortOrder +} + +export type AppInstallMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + appId?: Prisma.SortOrder + token?: Prisma.SortOrder + note?: Prisma.SortOrder + installedAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + deviceType?: Prisma.SortOrder + isReadOnly?: Prisma.SortOrder +} + +export type AppInstallMinOrderByAggregateInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + appId?: Prisma.SortOrder + token?: Prisma.SortOrder + note?: Prisma.SortOrder + installedAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + deviceType?: Prisma.SortOrder + isReadOnly?: Prisma.SortOrder +} + +export type AppInstallSumOrderByAggregateInput = { + deviceId?: Prisma.SortOrder +} + +export type AppInstallListRelationFilter = { + every?: Prisma.AppInstallWhereInput + some?: Prisma.AppInstallWhereInput + none?: Prisma.AppInstallWhereInput +} + +export type AppInstallOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type BoolFieldUpdateOperationsInput = { + set?: boolean +} + +export type AppInstallCreateNestedManyWithoutDeviceInput = { + create?: Prisma.XOR | Prisma.AppInstallCreateWithoutDeviceInput[] | Prisma.AppInstallUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AppInstallCreateOrConnectWithoutDeviceInput | Prisma.AppInstallCreateOrConnectWithoutDeviceInput[] + createMany?: Prisma.AppInstallCreateManyDeviceInputEnvelope + connect?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] +} + +export type AppInstallUncheckedCreateNestedManyWithoutDeviceInput = { + create?: Prisma.XOR | Prisma.AppInstallCreateWithoutDeviceInput[] | Prisma.AppInstallUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AppInstallCreateOrConnectWithoutDeviceInput | Prisma.AppInstallCreateOrConnectWithoutDeviceInput[] + createMany?: Prisma.AppInstallCreateManyDeviceInputEnvelope + connect?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] +} + +export type AppInstallUpdateManyWithoutDeviceNestedInput = { + create?: Prisma.XOR | Prisma.AppInstallCreateWithoutDeviceInput[] | Prisma.AppInstallUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AppInstallCreateOrConnectWithoutDeviceInput | Prisma.AppInstallCreateOrConnectWithoutDeviceInput[] + upsert?: Prisma.AppInstallUpsertWithWhereUniqueWithoutDeviceInput | Prisma.AppInstallUpsertWithWhereUniqueWithoutDeviceInput[] + createMany?: Prisma.AppInstallCreateManyDeviceInputEnvelope + set?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + disconnect?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + delete?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + connect?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + update?: Prisma.AppInstallUpdateWithWhereUniqueWithoutDeviceInput | Prisma.AppInstallUpdateWithWhereUniqueWithoutDeviceInput[] + updateMany?: Prisma.AppInstallUpdateManyWithWhereWithoutDeviceInput | Prisma.AppInstallUpdateManyWithWhereWithoutDeviceInput[] + deleteMany?: Prisma.AppInstallScalarWhereInput | Prisma.AppInstallScalarWhereInput[] +} + +export type AppInstallUncheckedUpdateManyWithoutDeviceNestedInput = { + create?: Prisma.XOR | Prisma.AppInstallCreateWithoutDeviceInput[] | Prisma.AppInstallUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AppInstallCreateOrConnectWithoutDeviceInput | Prisma.AppInstallCreateOrConnectWithoutDeviceInput[] + upsert?: Prisma.AppInstallUpsertWithWhereUniqueWithoutDeviceInput | Prisma.AppInstallUpsertWithWhereUniqueWithoutDeviceInput[] + createMany?: Prisma.AppInstallCreateManyDeviceInputEnvelope + set?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + disconnect?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + delete?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + connect?: Prisma.AppInstallWhereUniqueInput | Prisma.AppInstallWhereUniqueInput[] + update?: Prisma.AppInstallUpdateWithWhereUniqueWithoutDeviceInput | Prisma.AppInstallUpdateWithWhereUniqueWithoutDeviceInput[] + updateMany?: Prisma.AppInstallUpdateManyWithWhereWithoutDeviceInput | Prisma.AppInstallUpdateManyWithWhereWithoutDeviceInput[] + deleteMany?: Prisma.AppInstallScalarWhereInput | Prisma.AppInstallScalarWhereInput[] +} + +export type AppInstallCreateWithoutDeviceInput = { + id: string + appId: string + token: string + note?: string | null + installedAt?: Date | string + updatedAt?: Date | string + deviceType?: string | null + isReadOnly?: boolean +} + +export type AppInstallUncheckedCreateWithoutDeviceInput = { + id: string + appId: string + token: string + note?: string | null + installedAt?: Date | string + updatedAt?: Date | string + deviceType?: string | null + isReadOnly?: boolean +} + +export type AppInstallCreateOrConnectWithoutDeviceInput = { + where: Prisma.AppInstallWhereUniqueInput + create: Prisma.XOR +} + +export type AppInstallCreateManyDeviceInputEnvelope = { + data: Prisma.AppInstallCreateManyDeviceInput | Prisma.AppInstallCreateManyDeviceInput[] + skipDuplicates?: boolean +} + +export type AppInstallUpsertWithWhereUniqueWithoutDeviceInput = { + where: Prisma.AppInstallWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type AppInstallUpdateWithWhereUniqueWithoutDeviceInput = { + where: Prisma.AppInstallWhereUniqueInput + data: Prisma.XOR +} + +export type AppInstallUpdateManyWithWhereWithoutDeviceInput = { + where: Prisma.AppInstallScalarWhereInput + data: Prisma.XOR +} + +export type AppInstallScalarWhereInput = { + AND?: Prisma.AppInstallScalarWhereInput | Prisma.AppInstallScalarWhereInput[] + OR?: Prisma.AppInstallScalarWhereInput[] + NOT?: Prisma.AppInstallScalarWhereInput | Prisma.AppInstallScalarWhereInput[] + id?: Prisma.StringFilter<"AppInstall"> | string + deviceId?: Prisma.IntFilter<"AppInstall"> | number + appId?: Prisma.StringFilter<"AppInstall"> | string + token?: Prisma.StringFilter<"AppInstall"> | string + note?: Prisma.StringNullableFilter<"AppInstall"> | string | null + installedAt?: Prisma.DateTimeFilter<"AppInstall"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"AppInstall"> | Date | string + deviceType?: Prisma.StringNullableFilter<"AppInstall"> | string | null + isReadOnly?: Prisma.BoolFilter<"AppInstall"> | boolean +} + +export type AppInstallCreateManyDeviceInput = { + id: string + appId: string + token: string + note?: string | null + installedAt?: Date | string + updatedAt?: Date | string + deviceType?: string | null + isReadOnly?: boolean +} + +export type AppInstallUpdateWithoutDeviceInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + appId?: Prisma.StringFieldUpdateOperationsInput | string + token?: Prisma.StringFieldUpdateOperationsInput | string + note?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + installedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean +} + +export type AppInstallUncheckedUpdateWithoutDeviceInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + appId?: Prisma.StringFieldUpdateOperationsInput | string + token?: Prisma.StringFieldUpdateOperationsInput | string + note?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + installedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean +} + +export type AppInstallUncheckedUpdateManyWithoutDeviceInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + appId?: Prisma.StringFieldUpdateOperationsInput | string + token?: Prisma.StringFieldUpdateOperationsInput | string + note?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + installedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean +} + + + +export type AppInstallSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + deviceId?: boolean + appId?: boolean + token?: boolean + note?: boolean + installedAt?: boolean + updatedAt?: boolean + deviceType?: boolean + isReadOnly?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["appInstall"]> + +export type AppInstallSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + deviceId?: boolean + appId?: boolean + token?: boolean + note?: boolean + installedAt?: boolean + updatedAt?: boolean + deviceType?: boolean + isReadOnly?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["appInstall"]> + +export type AppInstallSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + deviceId?: boolean + appId?: boolean + token?: boolean + note?: boolean + installedAt?: boolean + updatedAt?: boolean + deviceType?: boolean + isReadOnly?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["appInstall"]> + +export type AppInstallSelectScalar = { + id?: boolean + deviceId?: boolean + appId?: boolean + token?: boolean + note?: boolean + installedAt?: boolean + updatedAt?: boolean + deviceType?: boolean + isReadOnly?: boolean +} + +export type AppInstallOmit = runtime.Types.Extensions.GetOmit<"id" | "deviceId" | "appId" | "token" | "note" | "installedAt" | "updatedAt" | "deviceType" | "isReadOnly", ExtArgs["result"]["appInstall"]> +export type AppInstallInclude = { + device?: boolean | Prisma.DeviceDefaultArgs +} +export type AppInstallIncludeCreateManyAndReturn = { + device?: boolean | Prisma.DeviceDefaultArgs +} +export type AppInstallIncludeUpdateManyAndReturn = { + device?: boolean | Prisma.DeviceDefaultArgs +} + +export type $AppInstallPayload = { + name: "AppInstall" + objects: { + device: Prisma.$DevicePayload + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: string + deviceId: number + appId: string + token: string + note: string | null + installedAt: Date + updatedAt: Date + deviceType: string | null + isReadOnly: boolean + }, ExtArgs["result"]["appInstall"]> + composites: {} +} + +export type AppInstallGetPayload = runtime.Types.Result.GetResult + +export type AppInstallCountArgs = + Omit & { + select?: AppInstallCountAggregateInputType | true + } + +export interface AppInstallDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['AppInstall'], meta: { name: 'AppInstall' } } + /** + * Find zero or one AppInstall that matches the filter. + * @param {AppInstallFindUniqueArgs} args - Arguments to find a AppInstall + * @example + * // Get one AppInstall + * const appInstall = await prisma.appInstall.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one AppInstall that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {AppInstallFindUniqueOrThrowArgs} args - Arguments to find a AppInstall + * @example + * // Get one AppInstall + * const appInstall = await prisma.appInstall.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first AppInstall that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AppInstallFindFirstArgs} args - Arguments to find a AppInstall + * @example + * // Get one AppInstall + * const appInstall = await prisma.appInstall.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first AppInstall that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AppInstallFindFirstOrThrowArgs} args - Arguments to find a AppInstall + * @example + * // Get one AppInstall + * const appInstall = await prisma.appInstall.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more AppInstalls that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AppInstallFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all AppInstalls + * const appInstalls = await prisma.appInstall.findMany() + * + * // Get first 10 AppInstalls + * const appInstalls = await prisma.appInstall.findMany({ take: 10 }) + * + * // Only select the `id` + * const appInstallWithIdOnly = await prisma.appInstall.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a AppInstall. + * @param {AppInstallCreateArgs} args - Arguments to create a AppInstall. + * @example + * // Create one AppInstall + * const AppInstall = await prisma.appInstall.create({ + * data: { + * // ... data to create a AppInstall + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many AppInstalls. + * @param {AppInstallCreateManyArgs} args - Arguments to create many AppInstalls. + * @example + * // Create many AppInstalls + * const appInstall = await prisma.appInstall.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many AppInstalls and returns the data saved in the database. + * @param {AppInstallCreateManyAndReturnArgs} args - Arguments to create many AppInstalls. + * @example + * // Create many AppInstalls + * const appInstall = await prisma.appInstall.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many AppInstalls and only return the `id` + * const appInstallWithIdOnly = await prisma.appInstall.createManyAndReturn({ + * select: { id: true }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + createManyAndReturn(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "createManyAndReturn", GlobalOmitOptions>> + + /** + * Delete a AppInstall. + * @param {AppInstallDeleteArgs} args - Arguments to delete one AppInstall. + * @example + * // Delete one AppInstall + * const AppInstall = await prisma.appInstall.delete({ + * where: { + * // ... filter to delete one AppInstall + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one AppInstall. + * @param {AppInstallUpdateArgs} args - Arguments to update one AppInstall. + * @example + * // Update one AppInstall + * const appInstall = await prisma.appInstall.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more AppInstalls. + * @param {AppInstallDeleteManyArgs} args - Arguments to filter AppInstalls to delete. + * @example + * // Delete a few AppInstalls + * const { count } = await prisma.appInstall.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more AppInstalls. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AppInstallUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many AppInstalls + * const appInstall = await prisma.appInstall.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more AppInstalls and returns the data updated in the database. + * @param {AppInstallUpdateManyAndReturnArgs} args - Arguments to update many AppInstalls. + * @example + * // Update many AppInstalls + * const appInstall = await prisma.appInstall.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more AppInstalls and only return the `id` + * const appInstallWithIdOnly = await prisma.appInstall.updateManyAndReturn({ + * select: { id: true }, + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + updateManyAndReturn(args: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "updateManyAndReturn", GlobalOmitOptions>> + + /** + * Create or update one AppInstall. + * @param {AppInstallUpsertArgs} args - Arguments to update or create a AppInstall. + * @example + * // Update or create a AppInstall + * const appInstall = await prisma.appInstall.upsert({ + * create: { + * // ... data to create a AppInstall + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the AppInstall we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__AppInstallClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of AppInstalls. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AppInstallCountArgs} args - Arguments to filter AppInstalls to count. + * @example + * // Count the number of AppInstalls + * const count = await prisma.appInstall.count({ + * where: { + * // ... the filter for the AppInstalls we want to count + * } + * }) + **/ + count( + args?: Prisma.Subset, + ): Prisma.PrismaPromise< + T extends runtime.Types.Utils.Record<'select', any> + ? T['select'] extends true + ? number + : Prisma.GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a AppInstall. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AppInstallAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Prisma.Subset): Prisma.PrismaPromise> + + /** + * Group by AppInstall. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AppInstallGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends AppInstallGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: AppInstallGroupByArgs['orderBy'] } + : { orderBy?: AppInstallGroupByArgs['orderBy'] }, + OrderFields extends Prisma.ExcludeUnderscoreKeys>>, + ByFields extends Prisma.MaybeTupleToUnion, + ByValid extends Prisma.Has, + HavingFields extends Prisma.GetHavingFields, + HavingValid extends Prisma.Has, + ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, + InputErrors extends ByEmpty extends Prisma.True + ? `Error: "by" must not be empty.` + : HavingValid extends Prisma.False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: Prisma.SubsetIntersection & InputErrors): {} extends InputErrors ? GetAppInstallGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the AppInstall model + */ +readonly fields: AppInstallFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for AppInstall. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ +export interface Prisma__AppInstallClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + device = {}>(args?: Prisma.Subset>): Prisma.Prisma__DeviceClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): runtime.Types.Utils.JsPromise +} + + + + +/** + * Fields of the AppInstall model + */ +export interface AppInstallFieldRefs { + readonly id: Prisma.FieldRef<"AppInstall", 'String'> + readonly deviceId: Prisma.FieldRef<"AppInstall", 'Int'> + readonly appId: Prisma.FieldRef<"AppInstall", 'String'> + readonly token: Prisma.FieldRef<"AppInstall", 'String'> + readonly note: Prisma.FieldRef<"AppInstall", 'String'> + readonly installedAt: Prisma.FieldRef<"AppInstall", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"AppInstall", 'DateTime'> + readonly deviceType: Prisma.FieldRef<"AppInstall", 'String'> + readonly isReadOnly: Prisma.FieldRef<"AppInstall", 'Boolean'> +} + + +// Custom InputTypes +/** + * AppInstall findUnique + */ +export type AppInstallFindUniqueArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * Filter, which AppInstall to fetch. + */ + where: Prisma.AppInstallWhereUniqueInput +} + +/** + * AppInstall findUniqueOrThrow + */ +export type AppInstallFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * Filter, which AppInstall to fetch. + */ + where: Prisma.AppInstallWhereUniqueInput +} + +/** + * AppInstall findFirst + */ +export type AppInstallFindFirstArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * Filter, which AppInstall to fetch. + */ + where?: Prisma.AppInstallWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AppInstalls to fetch. + */ + orderBy?: Prisma.AppInstallOrderByWithRelationInput | Prisma.AppInstallOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for AppInstalls. + */ + cursor?: Prisma.AppInstallWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AppInstalls from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AppInstalls. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of AppInstalls. + */ + distinct?: Prisma.AppInstallScalarFieldEnum | Prisma.AppInstallScalarFieldEnum[] +} + +/** + * AppInstall findFirstOrThrow + */ +export type AppInstallFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * Filter, which AppInstall to fetch. + */ + where?: Prisma.AppInstallWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AppInstalls to fetch. + */ + orderBy?: Prisma.AppInstallOrderByWithRelationInput | Prisma.AppInstallOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for AppInstalls. + */ + cursor?: Prisma.AppInstallWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AppInstalls from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AppInstalls. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of AppInstalls. + */ + distinct?: Prisma.AppInstallScalarFieldEnum | Prisma.AppInstallScalarFieldEnum[] +} + +/** + * AppInstall findMany + */ +export type AppInstallFindManyArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * Filter, which AppInstalls to fetch. + */ + where?: Prisma.AppInstallWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AppInstalls to fetch. + */ + orderBy?: Prisma.AppInstallOrderByWithRelationInput | Prisma.AppInstallOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing AppInstalls. + */ + cursor?: Prisma.AppInstallWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AppInstalls from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AppInstalls. + */ + skip?: number + distinct?: Prisma.AppInstallScalarFieldEnum | Prisma.AppInstallScalarFieldEnum[] +} + +/** + * AppInstall create + */ +export type AppInstallCreateArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * The data needed to create a AppInstall. + */ + data: Prisma.XOR +} + +/** + * AppInstall createMany + */ +export type AppInstallCreateManyArgs = { + /** + * The data used to create many AppInstalls. + */ + data: Prisma.AppInstallCreateManyInput | Prisma.AppInstallCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * AppInstall createManyAndReturn + */ +export type AppInstallCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelectCreateManyAndReturn | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * The data used to create many AppInstalls. + */ + data: Prisma.AppInstallCreateManyInput | Prisma.AppInstallCreateManyInput[] + skipDuplicates?: boolean + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallIncludeCreateManyAndReturn | null +} + +/** + * AppInstall update + */ +export type AppInstallUpdateArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * The data needed to update a AppInstall. + */ + data: Prisma.XOR + /** + * Choose, which AppInstall to update. + */ + where: Prisma.AppInstallWhereUniqueInput +} + +/** + * AppInstall updateMany + */ +export type AppInstallUpdateManyArgs = { + /** + * The data used to update AppInstalls. + */ + data: Prisma.XOR + /** + * Filter which AppInstalls to update + */ + where?: Prisma.AppInstallWhereInput + /** + * Limit how many AppInstalls to update. + */ + limit?: number +} + +/** + * AppInstall updateManyAndReturn + */ +export type AppInstallUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * The data used to update AppInstalls. + */ + data: Prisma.XOR + /** + * Filter which AppInstalls to update + */ + where?: Prisma.AppInstallWhereInput + /** + * Limit how many AppInstalls to update. + */ + limit?: number + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallIncludeUpdateManyAndReturn | null +} + +/** + * AppInstall upsert + */ +export type AppInstallUpsertArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * The filter to search for the AppInstall to update in case it exists. + */ + where: Prisma.AppInstallWhereUniqueInput + /** + * In case the AppInstall found by the `where` argument doesn't exist, create a new AppInstall with this data. + */ + create: Prisma.XOR + /** + * In case the AppInstall was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * AppInstall delete + */ +export type AppInstallDeleteArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + /** + * Filter which AppInstall to delete. + */ + where: Prisma.AppInstallWhereUniqueInput +} + +/** + * AppInstall deleteMany + */ +export type AppInstallDeleteManyArgs = { + /** + * Filter which AppInstalls to delete + */ + where?: Prisma.AppInstallWhereInput + /** + * Limit how many AppInstalls to delete. + */ + limit?: number +} + +/** + * AppInstall without action + */ +export type AppInstallDefaultArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null +} diff --git a/generated/prisma/models/AutoAuth.ts b/generated/prisma/models/AutoAuth.ts new file mode 100644 index 0000000..3304eb0 --- /dev/null +++ b/generated/prisma/models/AutoAuth.ts @@ -0,0 +1,1460 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `AutoAuth` model and its related types. + * + * 🟢 You can import this file directly. + */ +import type * as runtime from "@prisma/client/runtime/client" +import type * as $Enums from "../enums.ts" +import type * as Prisma from "../internal/prismaNamespace.ts" + +/** + * Model AutoAuth + * + */ +export type AutoAuthModel = runtime.Types.Result.DefaultSelection + +export type AggregateAutoAuth = { + _count: AutoAuthCountAggregateOutputType | null + _avg: AutoAuthAvgAggregateOutputType | null + _sum: AutoAuthSumAggregateOutputType | null + _min: AutoAuthMinAggregateOutputType | null + _max: AutoAuthMaxAggregateOutputType | null +} + +export type AutoAuthAvgAggregateOutputType = { + deviceId: number | null +} + +export type AutoAuthSumAggregateOutputType = { + deviceId: number | null +} + +export type AutoAuthMinAggregateOutputType = { + id: string | null + deviceId: number | null + password: string | null + deviceType: string | null + isReadOnly: boolean | null + createdAt: Date | null + updatedAt: Date | null +} + +export type AutoAuthMaxAggregateOutputType = { + id: string | null + deviceId: number | null + password: string | null + deviceType: string | null + isReadOnly: boolean | null + createdAt: Date | null + updatedAt: Date | null +} + +export type AutoAuthCountAggregateOutputType = { + id: number + deviceId: number + password: number + deviceType: number + isReadOnly: number + createdAt: number + updatedAt: number + _all: number +} + + +export type AutoAuthAvgAggregateInputType = { + deviceId?: true +} + +export type AutoAuthSumAggregateInputType = { + deviceId?: true +} + +export type AutoAuthMinAggregateInputType = { + id?: true + deviceId?: true + password?: true + deviceType?: true + isReadOnly?: true + createdAt?: true + updatedAt?: true +} + +export type AutoAuthMaxAggregateInputType = { + id?: true + deviceId?: true + password?: true + deviceType?: true + isReadOnly?: true + createdAt?: true + updatedAt?: true +} + +export type AutoAuthCountAggregateInputType = { + id?: true + deviceId?: true + password?: true + deviceType?: true + isReadOnly?: true + createdAt?: true + updatedAt?: true + _all?: true +} + +export type AutoAuthAggregateArgs = { + /** + * Filter which AutoAuth to aggregate. + */ + where?: Prisma.AutoAuthWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AutoAuths to fetch. + */ + orderBy?: Prisma.AutoAuthOrderByWithRelationInput | Prisma.AutoAuthOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.AutoAuthWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AutoAuths from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AutoAuths. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned AutoAuths + **/ + _count?: true | AutoAuthCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ + _avg?: AutoAuthAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ + _sum?: AutoAuthSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: AutoAuthMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: AutoAuthMaxAggregateInputType +} + +export type GetAutoAuthAggregateType = { + [P in keyof T & keyof AggregateAutoAuth]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type AutoAuthGroupByArgs = { + where?: Prisma.AutoAuthWhereInput + orderBy?: Prisma.AutoAuthOrderByWithAggregationInput | Prisma.AutoAuthOrderByWithAggregationInput[] + by: Prisma.AutoAuthScalarFieldEnum[] | Prisma.AutoAuthScalarFieldEnum + having?: Prisma.AutoAuthScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: AutoAuthCountAggregateInputType | true + _avg?: AutoAuthAvgAggregateInputType + _sum?: AutoAuthSumAggregateInputType + _min?: AutoAuthMinAggregateInputType + _max?: AutoAuthMaxAggregateInputType +} + +export type AutoAuthGroupByOutputType = { + id: string + deviceId: number + password: string | null + deviceType: string | null + isReadOnly: boolean + createdAt: Date + updatedAt: Date + _count: AutoAuthCountAggregateOutputType | null + _avg: AutoAuthAvgAggregateOutputType | null + _sum: AutoAuthSumAggregateOutputType | null + _min: AutoAuthMinAggregateOutputType | null + _max: AutoAuthMaxAggregateOutputType | null +} + +type GetAutoAuthGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof AutoAuthGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type AutoAuthWhereInput = { + AND?: Prisma.AutoAuthWhereInput | Prisma.AutoAuthWhereInput[] + OR?: Prisma.AutoAuthWhereInput[] + NOT?: Prisma.AutoAuthWhereInput | Prisma.AutoAuthWhereInput[] + id?: Prisma.StringFilter<"AutoAuth"> | string + deviceId?: Prisma.IntFilter<"AutoAuth"> | number + password?: Prisma.StringNullableFilter<"AutoAuth"> | string | null + deviceType?: Prisma.StringNullableFilter<"AutoAuth"> | string | null + isReadOnly?: Prisma.BoolFilter<"AutoAuth"> | boolean + createdAt?: Prisma.DateTimeFilter<"AutoAuth"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"AutoAuth"> | Date | string + device?: Prisma.XOR +} + +export type AutoAuthOrderByWithRelationInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + password?: Prisma.SortOrderInput | Prisma.SortOrder + deviceType?: Prisma.SortOrderInput | Prisma.SortOrder + isReadOnly?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + device?: Prisma.DeviceOrderByWithRelationInput +} + +export type AutoAuthWhereUniqueInput = Prisma.AtLeast<{ + id?: string + deviceId_password?: Prisma.AutoAuthDeviceIdPasswordCompoundUniqueInput + AND?: Prisma.AutoAuthWhereInput | Prisma.AutoAuthWhereInput[] + OR?: Prisma.AutoAuthWhereInput[] + NOT?: Prisma.AutoAuthWhereInput | Prisma.AutoAuthWhereInput[] + deviceId?: Prisma.IntFilter<"AutoAuth"> | number + password?: Prisma.StringNullableFilter<"AutoAuth"> | string | null + deviceType?: Prisma.StringNullableFilter<"AutoAuth"> | string | null + isReadOnly?: Prisma.BoolFilter<"AutoAuth"> | boolean + createdAt?: Prisma.DateTimeFilter<"AutoAuth"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"AutoAuth"> | Date | string + device?: Prisma.XOR +}, "id" | "deviceId_password"> + +export type AutoAuthOrderByWithAggregationInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + password?: Prisma.SortOrderInput | Prisma.SortOrder + deviceType?: Prisma.SortOrderInput | Prisma.SortOrder + isReadOnly?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + _count?: Prisma.AutoAuthCountOrderByAggregateInput + _avg?: Prisma.AutoAuthAvgOrderByAggregateInput + _max?: Prisma.AutoAuthMaxOrderByAggregateInput + _min?: Prisma.AutoAuthMinOrderByAggregateInput + _sum?: Prisma.AutoAuthSumOrderByAggregateInput +} + +export type AutoAuthScalarWhereWithAggregatesInput = { + AND?: Prisma.AutoAuthScalarWhereWithAggregatesInput | Prisma.AutoAuthScalarWhereWithAggregatesInput[] + OR?: Prisma.AutoAuthScalarWhereWithAggregatesInput[] + NOT?: Prisma.AutoAuthScalarWhereWithAggregatesInput | Prisma.AutoAuthScalarWhereWithAggregatesInput[] + id?: Prisma.StringWithAggregatesFilter<"AutoAuth"> | string + deviceId?: Prisma.IntWithAggregatesFilter<"AutoAuth"> | number + password?: Prisma.StringNullableWithAggregatesFilter<"AutoAuth"> | string | null + deviceType?: Prisma.StringNullableWithAggregatesFilter<"AutoAuth"> | string | null + isReadOnly?: Prisma.BoolWithAggregatesFilter<"AutoAuth"> | boolean + createdAt?: Prisma.DateTimeWithAggregatesFilter<"AutoAuth"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"AutoAuth"> | Date | string +} + +export type AutoAuthCreateInput = { + id: string + password?: string | null + deviceType?: string | null + isReadOnly?: boolean + createdAt?: Date | string + updatedAt?: Date | string + device: Prisma.DeviceCreateNestedOneWithoutAutoAuthsInput +} + +export type AutoAuthUncheckedCreateInput = { + id: string + deviceId: number + password?: string | null + deviceType?: string | null + isReadOnly?: boolean + createdAt?: Date | string + updatedAt?: Date | string +} + +export type AutoAuthUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + device?: Prisma.DeviceUpdateOneRequiredWithoutAutoAuthsNestedInput +} + +export type AutoAuthUncheckedUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + deviceId?: Prisma.IntFieldUpdateOperationsInput | number + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AutoAuthCreateManyInput = { + id: string + deviceId: number + password?: string | null + deviceType?: string | null + isReadOnly?: boolean + createdAt?: Date | string + updatedAt?: Date | string +} + +export type AutoAuthUpdateManyMutationInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AutoAuthUncheckedUpdateManyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + deviceId?: Prisma.IntFieldUpdateOperationsInput | number + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AutoAuthDeviceIdPasswordCompoundUniqueInput = { + deviceId: number + password: string +} + +export type AutoAuthCountOrderByAggregateInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + password?: Prisma.SortOrder + deviceType?: Prisma.SortOrder + isReadOnly?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type AutoAuthAvgOrderByAggregateInput = { + deviceId?: Prisma.SortOrder +} + +export type AutoAuthMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + password?: Prisma.SortOrder + deviceType?: Prisma.SortOrder + isReadOnly?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type AutoAuthMinOrderByAggregateInput = { + id?: Prisma.SortOrder + deviceId?: Prisma.SortOrder + password?: Prisma.SortOrder + deviceType?: Prisma.SortOrder + isReadOnly?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type AutoAuthSumOrderByAggregateInput = { + deviceId?: Prisma.SortOrder +} + +export type AutoAuthListRelationFilter = { + every?: Prisma.AutoAuthWhereInput + some?: Prisma.AutoAuthWhereInput + none?: Prisma.AutoAuthWhereInput +} + +export type AutoAuthOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type AutoAuthCreateNestedManyWithoutDeviceInput = { + create?: Prisma.XOR | Prisma.AutoAuthCreateWithoutDeviceInput[] | Prisma.AutoAuthUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AutoAuthCreateOrConnectWithoutDeviceInput | Prisma.AutoAuthCreateOrConnectWithoutDeviceInput[] + createMany?: Prisma.AutoAuthCreateManyDeviceInputEnvelope + connect?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] +} + +export type AutoAuthUncheckedCreateNestedManyWithoutDeviceInput = { + create?: Prisma.XOR | Prisma.AutoAuthCreateWithoutDeviceInput[] | Prisma.AutoAuthUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AutoAuthCreateOrConnectWithoutDeviceInput | Prisma.AutoAuthCreateOrConnectWithoutDeviceInput[] + createMany?: Prisma.AutoAuthCreateManyDeviceInputEnvelope + connect?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] +} + +export type AutoAuthUpdateManyWithoutDeviceNestedInput = { + create?: Prisma.XOR | Prisma.AutoAuthCreateWithoutDeviceInput[] | Prisma.AutoAuthUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AutoAuthCreateOrConnectWithoutDeviceInput | Prisma.AutoAuthCreateOrConnectWithoutDeviceInput[] + upsert?: Prisma.AutoAuthUpsertWithWhereUniqueWithoutDeviceInput | Prisma.AutoAuthUpsertWithWhereUniqueWithoutDeviceInput[] + createMany?: Prisma.AutoAuthCreateManyDeviceInputEnvelope + set?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + disconnect?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + delete?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + connect?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + update?: Prisma.AutoAuthUpdateWithWhereUniqueWithoutDeviceInput | Prisma.AutoAuthUpdateWithWhereUniqueWithoutDeviceInput[] + updateMany?: Prisma.AutoAuthUpdateManyWithWhereWithoutDeviceInput | Prisma.AutoAuthUpdateManyWithWhereWithoutDeviceInput[] + deleteMany?: Prisma.AutoAuthScalarWhereInput | Prisma.AutoAuthScalarWhereInput[] +} + +export type AutoAuthUncheckedUpdateManyWithoutDeviceNestedInput = { + create?: Prisma.XOR | Prisma.AutoAuthCreateWithoutDeviceInput[] | Prisma.AutoAuthUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.AutoAuthCreateOrConnectWithoutDeviceInput | Prisma.AutoAuthCreateOrConnectWithoutDeviceInput[] + upsert?: Prisma.AutoAuthUpsertWithWhereUniqueWithoutDeviceInput | Prisma.AutoAuthUpsertWithWhereUniqueWithoutDeviceInput[] + createMany?: Prisma.AutoAuthCreateManyDeviceInputEnvelope + set?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + disconnect?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + delete?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + connect?: Prisma.AutoAuthWhereUniqueInput | Prisma.AutoAuthWhereUniqueInput[] + update?: Prisma.AutoAuthUpdateWithWhereUniqueWithoutDeviceInput | Prisma.AutoAuthUpdateWithWhereUniqueWithoutDeviceInput[] + updateMany?: Prisma.AutoAuthUpdateManyWithWhereWithoutDeviceInput | Prisma.AutoAuthUpdateManyWithWhereWithoutDeviceInput[] + deleteMany?: Prisma.AutoAuthScalarWhereInput | Prisma.AutoAuthScalarWhereInput[] +} + +export type AutoAuthCreateWithoutDeviceInput = { + id: string + password?: string | null + deviceType?: string | null + isReadOnly?: boolean + createdAt?: Date | string + updatedAt?: Date | string +} + +export type AutoAuthUncheckedCreateWithoutDeviceInput = { + id: string + password?: string | null + deviceType?: string | null + isReadOnly?: boolean + createdAt?: Date | string + updatedAt?: Date | string +} + +export type AutoAuthCreateOrConnectWithoutDeviceInput = { + where: Prisma.AutoAuthWhereUniqueInput + create: Prisma.XOR +} + +export type AutoAuthCreateManyDeviceInputEnvelope = { + data: Prisma.AutoAuthCreateManyDeviceInput | Prisma.AutoAuthCreateManyDeviceInput[] + skipDuplicates?: boolean +} + +export type AutoAuthUpsertWithWhereUniqueWithoutDeviceInput = { + where: Prisma.AutoAuthWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type AutoAuthUpdateWithWhereUniqueWithoutDeviceInput = { + where: Prisma.AutoAuthWhereUniqueInput + data: Prisma.XOR +} + +export type AutoAuthUpdateManyWithWhereWithoutDeviceInput = { + where: Prisma.AutoAuthScalarWhereInput + data: Prisma.XOR +} + +export type AutoAuthScalarWhereInput = { + AND?: Prisma.AutoAuthScalarWhereInput | Prisma.AutoAuthScalarWhereInput[] + OR?: Prisma.AutoAuthScalarWhereInput[] + NOT?: Prisma.AutoAuthScalarWhereInput | Prisma.AutoAuthScalarWhereInput[] + id?: Prisma.StringFilter<"AutoAuth"> | string + deviceId?: Prisma.IntFilter<"AutoAuth"> | number + password?: Prisma.StringNullableFilter<"AutoAuth"> | string | null + deviceType?: Prisma.StringNullableFilter<"AutoAuth"> | string | null + isReadOnly?: Prisma.BoolFilter<"AutoAuth"> | boolean + createdAt?: Prisma.DateTimeFilter<"AutoAuth"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"AutoAuth"> | Date | string +} + +export type AutoAuthCreateManyDeviceInput = { + id: string + password?: string | null + deviceType?: string | null + isReadOnly?: boolean + createdAt?: Date | string + updatedAt?: Date | string +} + +export type AutoAuthUpdateWithoutDeviceInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AutoAuthUncheckedUpdateWithoutDeviceInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type AutoAuthUncheckedUpdateManyWithoutDeviceInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + deviceType?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + isReadOnly?: Prisma.BoolFieldUpdateOperationsInput | boolean + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + + + +export type AutoAuthSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + deviceId?: boolean + password?: boolean + deviceType?: boolean + isReadOnly?: boolean + createdAt?: boolean + updatedAt?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["autoAuth"]> + +export type AutoAuthSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + deviceId?: boolean + password?: boolean + deviceType?: boolean + isReadOnly?: boolean + createdAt?: boolean + updatedAt?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["autoAuth"]> + +export type AutoAuthSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + deviceId?: boolean + password?: boolean + deviceType?: boolean + isReadOnly?: boolean + createdAt?: boolean + updatedAt?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["autoAuth"]> + +export type AutoAuthSelectScalar = { + id?: boolean + deviceId?: boolean + password?: boolean + deviceType?: boolean + isReadOnly?: boolean + createdAt?: boolean + updatedAt?: boolean +} + +export type AutoAuthOmit = runtime.Types.Extensions.GetOmit<"id" | "deviceId" | "password" | "deviceType" | "isReadOnly" | "createdAt" | "updatedAt", ExtArgs["result"]["autoAuth"]> +export type AutoAuthInclude = { + device?: boolean | Prisma.DeviceDefaultArgs +} +export type AutoAuthIncludeCreateManyAndReturn = { + device?: boolean | Prisma.DeviceDefaultArgs +} +export type AutoAuthIncludeUpdateManyAndReturn = { + device?: boolean | Prisma.DeviceDefaultArgs +} + +export type $AutoAuthPayload = { + name: "AutoAuth" + objects: { + device: Prisma.$DevicePayload + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: string + deviceId: number + password: string | null + deviceType: string | null + isReadOnly: boolean + createdAt: Date + updatedAt: Date + }, ExtArgs["result"]["autoAuth"]> + composites: {} +} + +export type AutoAuthGetPayload = runtime.Types.Result.GetResult + +export type AutoAuthCountArgs = + Omit & { + select?: AutoAuthCountAggregateInputType | true + } + +export interface AutoAuthDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['AutoAuth'], meta: { name: 'AutoAuth' } } + /** + * Find zero or one AutoAuth that matches the filter. + * @param {AutoAuthFindUniqueArgs} args - Arguments to find a AutoAuth + * @example + * // Get one AutoAuth + * const autoAuth = await prisma.autoAuth.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one AutoAuth that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {AutoAuthFindUniqueOrThrowArgs} args - Arguments to find a AutoAuth + * @example + * // Get one AutoAuth + * const autoAuth = await prisma.autoAuth.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first AutoAuth that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AutoAuthFindFirstArgs} args - Arguments to find a AutoAuth + * @example + * // Get one AutoAuth + * const autoAuth = await prisma.autoAuth.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first AutoAuth that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AutoAuthFindFirstOrThrowArgs} args - Arguments to find a AutoAuth + * @example + * // Get one AutoAuth + * const autoAuth = await prisma.autoAuth.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more AutoAuths that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AutoAuthFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all AutoAuths + * const autoAuths = await prisma.autoAuth.findMany() + * + * // Get first 10 AutoAuths + * const autoAuths = await prisma.autoAuth.findMany({ take: 10 }) + * + * // Only select the `id` + * const autoAuthWithIdOnly = await prisma.autoAuth.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a AutoAuth. + * @param {AutoAuthCreateArgs} args - Arguments to create a AutoAuth. + * @example + * // Create one AutoAuth + * const AutoAuth = await prisma.autoAuth.create({ + * data: { + * // ... data to create a AutoAuth + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many AutoAuths. + * @param {AutoAuthCreateManyArgs} args - Arguments to create many AutoAuths. + * @example + * // Create many AutoAuths + * const autoAuth = await prisma.autoAuth.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many AutoAuths and returns the data saved in the database. + * @param {AutoAuthCreateManyAndReturnArgs} args - Arguments to create many AutoAuths. + * @example + * // Create many AutoAuths + * const autoAuth = await prisma.autoAuth.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many AutoAuths and only return the `id` + * const autoAuthWithIdOnly = await prisma.autoAuth.createManyAndReturn({ + * select: { id: true }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + createManyAndReturn(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "createManyAndReturn", GlobalOmitOptions>> + + /** + * Delete a AutoAuth. + * @param {AutoAuthDeleteArgs} args - Arguments to delete one AutoAuth. + * @example + * // Delete one AutoAuth + * const AutoAuth = await prisma.autoAuth.delete({ + * where: { + * // ... filter to delete one AutoAuth + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one AutoAuth. + * @param {AutoAuthUpdateArgs} args - Arguments to update one AutoAuth. + * @example + * // Update one AutoAuth + * const autoAuth = await prisma.autoAuth.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more AutoAuths. + * @param {AutoAuthDeleteManyArgs} args - Arguments to filter AutoAuths to delete. + * @example + * // Delete a few AutoAuths + * const { count } = await prisma.autoAuth.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more AutoAuths. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AutoAuthUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many AutoAuths + * const autoAuth = await prisma.autoAuth.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more AutoAuths and returns the data updated in the database. + * @param {AutoAuthUpdateManyAndReturnArgs} args - Arguments to update many AutoAuths. + * @example + * // Update many AutoAuths + * const autoAuth = await prisma.autoAuth.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more AutoAuths and only return the `id` + * const autoAuthWithIdOnly = await prisma.autoAuth.updateManyAndReturn({ + * select: { id: true }, + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + updateManyAndReturn(args: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "updateManyAndReturn", GlobalOmitOptions>> + + /** + * Create or update one AutoAuth. + * @param {AutoAuthUpsertArgs} args - Arguments to update or create a AutoAuth. + * @example + * // Update or create a AutoAuth + * const autoAuth = await prisma.autoAuth.upsert({ + * create: { + * // ... data to create a AutoAuth + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the AutoAuth we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__AutoAuthClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of AutoAuths. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AutoAuthCountArgs} args - Arguments to filter AutoAuths to count. + * @example + * // Count the number of AutoAuths + * const count = await prisma.autoAuth.count({ + * where: { + * // ... the filter for the AutoAuths we want to count + * } + * }) + **/ + count( + args?: Prisma.Subset, + ): Prisma.PrismaPromise< + T extends runtime.Types.Utils.Record<'select', any> + ? T['select'] extends true + ? number + : Prisma.GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a AutoAuth. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AutoAuthAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Prisma.Subset): Prisma.PrismaPromise> + + /** + * Group by AutoAuth. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {AutoAuthGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends AutoAuthGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: AutoAuthGroupByArgs['orderBy'] } + : { orderBy?: AutoAuthGroupByArgs['orderBy'] }, + OrderFields extends Prisma.ExcludeUnderscoreKeys>>, + ByFields extends Prisma.MaybeTupleToUnion, + ByValid extends Prisma.Has, + HavingFields extends Prisma.GetHavingFields, + HavingValid extends Prisma.Has, + ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, + InputErrors extends ByEmpty extends Prisma.True + ? `Error: "by" must not be empty.` + : HavingValid extends Prisma.False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: Prisma.SubsetIntersection & InputErrors): {} extends InputErrors ? GetAutoAuthGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the AutoAuth model + */ +readonly fields: AutoAuthFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for AutoAuth. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ +export interface Prisma__AutoAuthClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + device = {}>(args?: Prisma.Subset>): Prisma.Prisma__DeviceClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): runtime.Types.Utils.JsPromise +} + + + + +/** + * Fields of the AutoAuth model + */ +export interface AutoAuthFieldRefs { + readonly id: Prisma.FieldRef<"AutoAuth", 'String'> + readonly deviceId: Prisma.FieldRef<"AutoAuth", 'Int'> + readonly password: Prisma.FieldRef<"AutoAuth", 'String'> + readonly deviceType: Prisma.FieldRef<"AutoAuth", 'String'> + readonly isReadOnly: Prisma.FieldRef<"AutoAuth", 'Boolean'> + readonly createdAt: Prisma.FieldRef<"AutoAuth", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"AutoAuth", 'DateTime'> +} + + +// Custom InputTypes +/** + * AutoAuth findUnique + */ +export type AutoAuthFindUniqueArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * Filter, which AutoAuth to fetch. + */ + where: Prisma.AutoAuthWhereUniqueInput +} + +/** + * AutoAuth findUniqueOrThrow + */ +export type AutoAuthFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * Filter, which AutoAuth to fetch. + */ + where: Prisma.AutoAuthWhereUniqueInput +} + +/** + * AutoAuth findFirst + */ +export type AutoAuthFindFirstArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * Filter, which AutoAuth to fetch. + */ + where?: Prisma.AutoAuthWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AutoAuths to fetch. + */ + orderBy?: Prisma.AutoAuthOrderByWithRelationInput | Prisma.AutoAuthOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for AutoAuths. + */ + cursor?: Prisma.AutoAuthWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AutoAuths from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AutoAuths. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of AutoAuths. + */ + distinct?: Prisma.AutoAuthScalarFieldEnum | Prisma.AutoAuthScalarFieldEnum[] +} + +/** + * AutoAuth findFirstOrThrow + */ +export type AutoAuthFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * Filter, which AutoAuth to fetch. + */ + where?: Prisma.AutoAuthWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AutoAuths to fetch. + */ + orderBy?: Prisma.AutoAuthOrderByWithRelationInput | Prisma.AutoAuthOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for AutoAuths. + */ + cursor?: Prisma.AutoAuthWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AutoAuths from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AutoAuths. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of AutoAuths. + */ + distinct?: Prisma.AutoAuthScalarFieldEnum | Prisma.AutoAuthScalarFieldEnum[] +} + +/** + * AutoAuth findMany + */ +export type AutoAuthFindManyArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * Filter, which AutoAuths to fetch. + */ + where?: Prisma.AutoAuthWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of AutoAuths to fetch. + */ + orderBy?: Prisma.AutoAuthOrderByWithRelationInput | Prisma.AutoAuthOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing AutoAuths. + */ + cursor?: Prisma.AutoAuthWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` AutoAuths from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` AutoAuths. + */ + skip?: number + distinct?: Prisma.AutoAuthScalarFieldEnum | Prisma.AutoAuthScalarFieldEnum[] +} + +/** + * AutoAuth create + */ +export type AutoAuthCreateArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * The data needed to create a AutoAuth. + */ + data: Prisma.XOR +} + +/** + * AutoAuth createMany + */ +export type AutoAuthCreateManyArgs = { + /** + * The data used to create many AutoAuths. + */ + data: Prisma.AutoAuthCreateManyInput | Prisma.AutoAuthCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * AutoAuth createManyAndReturn + */ +export type AutoAuthCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelectCreateManyAndReturn | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * The data used to create many AutoAuths. + */ + data: Prisma.AutoAuthCreateManyInput | Prisma.AutoAuthCreateManyInput[] + skipDuplicates?: boolean + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthIncludeCreateManyAndReturn | null +} + +/** + * AutoAuth update + */ +export type AutoAuthUpdateArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * The data needed to update a AutoAuth. + */ + data: Prisma.XOR + /** + * Choose, which AutoAuth to update. + */ + where: Prisma.AutoAuthWhereUniqueInput +} + +/** + * AutoAuth updateMany + */ +export type AutoAuthUpdateManyArgs = { + /** + * The data used to update AutoAuths. + */ + data: Prisma.XOR + /** + * Filter which AutoAuths to update + */ + where?: Prisma.AutoAuthWhereInput + /** + * Limit how many AutoAuths to update. + */ + limit?: number +} + +/** + * AutoAuth updateManyAndReturn + */ +export type AutoAuthUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * The data used to update AutoAuths. + */ + data: Prisma.XOR + /** + * Filter which AutoAuths to update + */ + where?: Prisma.AutoAuthWhereInput + /** + * Limit how many AutoAuths to update. + */ + limit?: number + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthIncludeUpdateManyAndReturn | null +} + +/** + * AutoAuth upsert + */ +export type AutoAuthUpsertArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * The filter to search for the AutoAuth to update in case it exists. + */ + where: Prisma.AutoAuthWhereUniqueInput + /** + * In case the AutoAuth found by the `where` argument doesn't exist, create a new AutoAuth with this data. + */ + create: Prisma.XOR + /** + * In case the AutoAuth was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * AutoAuth delete + */ +export type AutoAuthDeleteArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + /** + * Filter which AutoAuth to delete. + */ + where: Prisma.AutoAuthWhereUniqueInput +} + +/** + * AutoAuth deleteMany + */ +export type AutoAuthDeleteManyArgs = { + /** + * Filter which AutoAuths to delete + */ + where?: Prisma.AutoAuthWhereInput + /** + * Limit how many AutoAuths to delete. + */ + limit?: number +} + +/** + * AutoAuth without action + */ +export type AutoAuthDefaultArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null +} diff --git a/generated/prisma/models/Device.ts b/generated/prisma/models/Device.ts new file mode 100644 index 0000000..f52c3f1 --- /dev/null +++ b/generated/prisma/models/Device.ts @@ -0,0 +1,1972 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `Device` model and its related types. + * + * 🟢 You can import this file directly. + */ +import type * as runtime from "@prisma/client/runtime/client" +import type * as $Enums from "../enums.ts" +import type * as Prisma from "../internal/prismaNamespace.ts" + +/** + * Model Device + * + */ +export type DeviceModel = runtime.Types.Result.DefaultSelection + +export type AggregateDevice = { + _count: DeviceCountAggregateOutputType | null + _avg: DeviceAvgAggregateOutputType | null + _sum: DeviceSumAggregateOutputType | null + _min: DeviceMinAggregateOutputType | null + _max: DeviceMaxAggregateOutputType | null +} + +export type DeviceAvgAggregateOutputType = { + id: number | null +} + +export type DeviceSumAggregateOutputType = { + id: number | null +} + +export type DeviceMinAggregateOutputType = { + id: number | null + uuid: string | null + name: string | null + accountId: string | null + createdAt: Date | null + updatedAt: Date | null + password: string | null + passwordHint: string | null + namespace: string | null +} + +export type DeviceMaxAggregateOutputType = { + id: number | null + uuid: string | null + name: string | null + accountId: string | null + createdAt: Date | null + updatedAt: Date | null + password: string | null + passwordHint: string | null + namespace: string | null +} + +export type DeviceCountAggregateOutputType = { + id: number + uuid: number + name: number + accountId: number + createdAt: number + updatedAt: number + password: number + passwordHint: number + namespace: number + _all: number +} + + +export type DeviceAvgAggregateInputType = { + id?: true +} + +export type DeviceSumAggregateInputType = { + id?: true +} + +export type DeviceMinAggregateInputType = { + id?: true + uuid?: true + name?: true + accountId?: true + createdAt?: true + updatedAt?: true + password?: true + passwordHint?: true + namespace?: true +} + +export type DeviceMaxAggregateInputType = { + id?: true + uuid?: true + name?: true + accountId?: true + createdAt?: true + updatedAt?: true + password?: true + passwordHint?: true + namespace?: true +} + +export type DeviceCountAggregateInputType = { + id?: true + uuid?: true + name?: true + accountId?: true + createdAt?: true + updatedAt?: true + password?: true + passwordHint?: true + namespace?: true + _all?: true +} + +export type DeviceAggregateArgs = { + /** + * Filter which Device to aggregate. + */ + where?: Prisma.DeviceWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Devices to fetch. + */ + orderBy?: Prisma.DeviceOrderByWithRelationInput | Prisma.DeviceOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.DeviceWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Devices from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Devices. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned Devices + **/ + _count?: true | DeviceCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ + _avg?: DeviceAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ + _sum?: DeviceSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: DeviceMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: DeviceMaxAggregateInputType +} + +export type GetDeviceAggregateType = { + [P in keyof T & keyof AggregateDevice]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type DeviceGroupByArgs = { + where?: Prisma.DeviceWhereInput + orderBy?: Prisma.DeviceOrderByWithAggregationInput | Prisma.DeviceOrderByWithAggregationInput[] + by: Prisma.DeviceScalarFieldEnum[] | Prisma.DeviceScalarFieldEnum + having?: Prisma.DeviceScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: DeviceCountAggregateInputType | true + _avg?: DeviceAvgAggregateInputType + _sum?: DeviceSumAggregateInputType + _min?: DeviceMinAggregateInputType + _max?: DeviceMaxAggregateInputType +} + +export type DeviceGroupByOutputType = { + id: number + uuid: string + name: string | null + accountId: string | null + createdAt: Date + updatedAt: Date + password: string | null + passwordHint: string | null + namespace: string | null + _count: DeviceCountAggregateOutputType | null + _avg: DeviceAvgAggregateOutputType | null + _sum: DeviceSumAggregateOutputType | null + _min: DeviceMinAggregateOutputType | null + _max: DeviceMaxAggregateOutputType | null +} + +type GetDeviceGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof DeviceGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type DeviceWhereInput = { + AND?: Prisma.DeviceWhereInput | Prisma.DeviceWhereInput[] + OR?: Prisma.DeviceWhereInput[] + NOT?: Prisma.DeviceWhereInput | Prisma.DeviceWhereInput[] + id?: Prisma.IntFilter<"Device"> | number + uuid?: Prisma.StringFilter<"Device"> | string + name?: Prisma.StringNullableFilter<"Device"> | string | null + accountId?: Prisma.StringNullableFilter<"Device"> | string | null + createdAt?: Prisma.DateTimeFilter<"Device"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Device"> | Date | string + password?: Prisma.StringNullableFilter<"Device"> | string | null + passwordHint?: Prisma.StringNullableFilter<"Device"> | string | null + namespace?: Prisma.StringNullableFilter<"Device"> | string | null + account?: Prisma.XOR | null + appInstalls?: Prisma.AppInstallListRelationFilter + kvStore?: Prisma.KVStoreListRelationFilter + autoAuths?: Prisma.AutoAuthListRelationFilter +} + +export type DeviceOrderByWithRelationInput = { + id?: Prisma.SortOrder + uuid?: Prisma.SortOrder + name?: Prisma.SortOrderInput | Prisma.SortOrder + accountId?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + password?: Prisma.SortOrderInput | Prisma.SortOrder + passwordHint?: Prisma.SortOrderInput | Prisma.SortOrder + namespace?: Prisma.SortOrderInput | Prisma.SortOrder + account?: Prisma.AccountOrderByWithRelationInput + appInstalls?: Prisma.AppInstallOrderByRelationAggregateInput + kvStore?: Prisma.KVStoreOrderByRelationAggregateInput + autoAuths?: Prisma.AutoAuthOrderByRelationAggregateInput +} + +export type DeviceWhereUniqueInput = Prisma.AtLeast<{ + id?: number + uuid?: string + namespace?: string + AND?: Prisma.DeviceWhereInput | Prisma.DeviceWhereInput[] + OR?: Prisma.DeviceWhereInput[] + NOT?: Prisma.DeviceWhereInput | Prisma.DeviceWhereInput[] + name?: Prisma.StringNullableFilter<"Device"> | string | null + accountId?: Prisma.StringNullableFilter<"Device"> | string | null + createdAt?: Prisma.DateTimeFilter<"Device"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Device"> | Date | string + password?: Prisma.StringNullableFilter<"Device"> | string | null + passwordHint?: Prisma.StringNullableFilter<"Device"> | string | null + account?: Prisma.XOR | null + appInstalls?: Prisma.AppInstallListRelationFilter + kvStore?: Prisma.KVStoreListRelationFilter + autoAuths?: Prisma.AutoAuthListRelationFilter +}, "id" | "uuid" | "namespace"> + +export type DeviceOrderByWithAggregationInput = { + id?: Prisma.SortOrder + uuid?: Prisma.SortOrder + name?: Prisma.SortOrderInput | Prisma.SortOrder + accountId?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + password?: Prisma.SortOrderInput | Prisma.SortOrder + passwordHint?: Prisma.SortOrderInput | Prisma.SortOrder + namespace?: Prisma.SortOrderInput | Prisma.SortOrder + _count?: Prisma.DeviceCountOrderByAggregateInput + _avg?: Prisma.DeviceAvgOrderByAggregateInput + _max?: Prisma.DeviceMaxOrderByAggregateInput + _min?: Prisma.DeviceMinOrderByAggregateInput + _sum?: Prisma.DeviceSumOrderByAggregateInput +} + +export type DeviceScalarWhereWithAggregatesInput = { + AND?: Prisma.DeviceScalarWhereWithAggregatesInput | Prisma.DeviceScalarWhereWithAggregatesInput[] + OR?: Prisma.DeviceScalarWhereWithAggregatesInput[] + NOT?: Prisma.DeviceScalarWhereWithAggregatesInput | Prisma.DeviceScalarWhereWithAggregatesInput[] + id?: Prisma.IntWithAggregatesFilter<"Device"> | number + uuid?: Prisma.StringWithAggregatesFilter<"Device"> | string + name?: Prisma.StringNullableWithAggregatesFilter<"Device"> | string | null + accountId?: Prisma.StringNullableWithAggregatesFilter<"Device"> | string | null + createdAt?: Prisma.DateTimeWithAggregatesFilter<"Device"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"Device"> | Date | string + password?: Prisma.StringNullableWithAggregatesFilter<"Device"> | string | null + passwordHint?: Prisma.StringNullableWithAggregatesFilter<"Device"> | string | null + namespace?: Prisma.StringNullableWithAggregatesFilter<"Device"> | string | null +} + +export type DeviceCreateInput = { + id: number + uuid: string + name?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + account?: Prisma.AccountCreateNestedOneWithoutDevicesInput + appInstalls?: Prisma.AppInstallCreateNestedManyWithoutDeviceInput + kvStore?: Prisma.KVStoreCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthCreateNestedManyWithoutDeviceInput +} + +export type DeviceUncheckedCreateInput = { + id: number + uuid: string + name?: string | null + accountId?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + appInstalls?: Prisma.AppInstallUncheckedCreateNestedManyWithoutDeviceInput + kvStore?: Prisma.KVStoreUncheckedCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthUncheckedCreateNestedManyWithoutDeviceInput +} + +export type DeviceUpdateInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + account?: Prisma.AccountUpdateOneWithoutDevicesNestedInput + appInstalls?: Prisma.AppInstallUpdateManyWithoutDeviceNestedInput + kvStore?: Prisma.KVStoreUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUpdateManyWithoutDeviceNestedInput +} + +export type DeviceUncheckedUpdateInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + accountId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + appInstalls?: Prisma.AppInstallUncheckedUpdateManyWithoutDeviceNestedInput + kvStore?: Prisma.KVStoreUncheckedUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUncheckedUpdateManyWithoutDeviceNestedInput +} + +export type DeviceCreateManyInput = { + id: number + uuid: string + name?: string | null + accountId?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null +} + +export type DeviceUpdateManyMutationInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null +} + +export type DeviceUncheckedUpdateManyInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + accountId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null +} + +export type DeviceListRelationFilter = { + every?: Prisma.DeviceWhereInput + some?: Prisma.DeviceWhereInput + none?: Prisma.DeviceWhereInput +} + +export type DeviceOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type DeviceScalarRelationFilter = { + is?: Prisma.DeviceWhereInput + isNot?: Prisma.DeviceWhereInput +} + +export type DeviceCountOrderByAggregateInput = { + id?: Prisma.SortOrder + uuid?: Prisma.SortOrder + name?: Prisma.SortOrder + accountId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + password?: Prisma.SortOrder + passwordHint?: Prisma.SortOrder + namespace?: Prisma.SortOrder +} + +export type DeviceAvgOrderByAggregateInput = { + id?: Prisma.SortOrder +} + +export type DeviceMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + uuid?: Prisma.SortOrder + name?: Prisma.SortOrder + accountId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + password?: Prisma.SortOrder + passwordHint?: Prisma.SortOrder + namespace?: Prisma.SortOrder +} + +export type DeviceMinOrderByAggregateInput = { + id?: Prisma.SortOrder + uuid?: Prisma.SortOrder + name?: Prisma.SortOrder + accountId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + password?: Prisma.SortOrder + passwordHint?: Prisma.SortOrder + namespace?: Prisma.SortOrder +} + +export type DeviceSumOrderByAggregateInput = { + id?: Prisma.SortOrder +} + +export type DeviceCreateNestedManyWithoutAccountInput = { + create?: Prisma.XOR | Prisma.DeviceCreateWithoutAccountInput[] | Prisma.DeviceUncheckedCreateWithoutAccountInput[] + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAccountInput | Prisma.DeviceCreateOrConnectWithoutAccountInput[] + createMany?: Prisma.DeviceCreateManyAccountInputEnvelope + connect?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] +} + +export type DeviceUncheckedCreateNestedManyWithoutAccountInput = { + create?: Prisma.XOR | Prisma.DeviceCreateWithoutAccountInput[] | Prisma.DeviceUncheckedCreateWithoutAccountInput[] + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAccountInput | Prisma.DeviceCreateOrConnectWithoutAccountInput[] + createMany?: Prisma.DeviceCreateManyAccountInputEnvelope + connect?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] +} + +export type DeviceUpdateManyWithoutAccountNestedInput = { + create?: Prisma.XOR | Prisma.DeviceCreateWithoutAccountInput[] | Prisma.DeviceUncheckedCreateWithoutAccountInput[] + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAccountInput | Prisma.DeviceCreateOrConnectWithoutAccountInput[] + upsert?: Prisma.DeviceUpsertWithWhereUniqueWithoutAccountInput | Prisma.DeviceUpsertWithWhereUniqueWithoutAccountInput[] + createMany?: Prisma.DeviceCreateManyAccountInputEnvelope + set?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + disconnect?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + delete?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + connect?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + update?: Prisma.DeviceUpdateWithWhereUniqueWithoutAccountInput | Prisma.DeviceUpdateWithWhereUniqueWithoutAccountInput[] + updateMany?: Prisma.DeviceUpdateManyWithWhereWithoutAccountInput | Prisma.DeviceUpdateManyWithWhereWithoutAccountInput[] + deleteMany?: Prisma.DeviceScalarWhereInput | Prisma.DeviceScalarWhereInput[] +} + +export type DeviceUncheckedUpdateManyWithoutAccountNestedInput = { + create?: Prisma.XOR | Prisma.DeviceCreateWithoutAccountInput[] | Prisma.DeviceUncheckedCreateWithoutAccountInput[] + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAccountInput | Prisma.DeviceCreateOrConnectWithoutAccountInput[] + upsert?: Prisma.DeviceUpsertWithWhereUniqueWithoutAccountInput | Prisma.DeviceUpsertWithWhereUniqueWithoutAccountInput[] + createMany?: Prisma.DeviceCreateManyAccountInputEnvelope + set?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + disconnect?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + delete?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + connect?: Prisma.DeviceWhereUniqueInput | Prisma.DeviceWhereUniqueInput[] + update?: Prisma.DeviceUpdateWithWhereUniqueWithoutAccountInput | Prisma.DeviceUpdateWithWhereUniqueWithoutAccountInput[] + updateMany?: Prisma.DeviceUpdateManyWithWhereWithoutAccountInput | Prisma.DeviceUpdateManyWithWhereWithoutAccountInput[] + deleteMany?: Prisma.DeviceScalarWhereInput | Prisma.DeviceScalarWhereInput[] +} + +export type DeviceCreateNestedOneWithoutAppInstallsInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAppInstallsInput + connect?: Prisma.DeviceWhereUniqueInput +} + +export type DeviceUpdateOneRequiredWithoutAppInstallsNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAppInstallsInput + upsert?: Prisma.DeviceUpsertWithoutAppInstallsInput + connect?: Prisma.DeviceWhereUniqueInput + update?: Prisma.XOR, Prisma.DeviceUncheckedUpdateWithoutAppInstallsInput> +} + +export type DeviceCreateNestedOneWithoutAutoAuthsInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAutoAuthsInput + connect?: Prisma.DeviceWhereUniqueInput +} + +export type DeviceUpdateOneRequiredWithoutAutoAuthsNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutAutoAuthsInput + upsert?: Prisma.DeviceUpsertWithoutAutoAuthsInput + connect?: Prisma.DeviceWhereUniqueInput + update?: Prisma.XOR, Prisma.DeviceUncheckedUpdateWithoutAutoAuthsInput> +} + +export type DeviceCreateNestedOneWithoutKvStoreInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutKvStoreInput + connect?: Prisma.DeviceWhereUniqueInput +} + +export type DeviceUpdateOneRequiredWithoutKvStoreNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.DeviceCreateOrConnectWithoutKvStoreInput + upsert?: Prisma.DeviceUpsertWithoutKvStoreInput + connect?: Prisma.DeviceWhereUniqueInput + update?: Prisma.XOR, Prisma.DeviceUncheckedUpdateWithoutKvStoreInput> +} + +export type DeviceCreateWithoutAccountInput = { + id: number + uuid: string + name?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + appInstalls?: Prisma.AppInstallCreateNestedManyWithoutDeviceInput + kvStore?: Prisma.KVStoreCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthCreateNestedManyWithoutDeviceInput +} + +export type DeviceUncheckedCreateWithoutAccountInput = { + id: number + uuid: string + name?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + appInstalls?: Prisma.AppInstallUncheckedCreateNestedManyWithoutDeviceInput + kvStore?: Prisma.KVStoreUncheckedCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthUncheckedCreateNestedManyWithoutDeviceInput +} + +export type DeviceCreateOrConnectWithoutAccountInput = { + where: Prisma.DeviceWhereUniqueInput + create: Prisma.XOR +} + +export type DeviceCreateManyAccountInputEnvelope = { + data: Prisma.DeviceCreateManyAccountInput | Prisma.DeviceCreateManyAccountInput[] + skipDuplicates?: boolean +} + +export type DeviceUpsertWithWhereUniqueWithoutAccountInput = { + where: Prisma.DeviceWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type DeviceUpdateWithWhereUniqueWithoutAccountInput = { + where: Prisma.DeviceWhereUniqueInput + data: Prisma.XOR +} + +export type DeviceUpdateManyWithWhereWithoutAccountInput = { + where: Prisma.DeviceScalarWhereInput + data: Prisma.XOR +} + +export type DeviceScalarWhereInput = { + AND?: Prisma.DeviceScalarWhereInput | Prisma.DeviceScalarWhereInput[] + OR?: Prisma.DeviceScalarWhereInput[] + NOT?: Prisma.DeviceScalarWhereInput | Prisma.DeviceScalarWhereInput[] + id?: Prisma.IntFilter<"Device"> | number + uuid?: Prisma.StringFilter<"Device"> | string + name?: Prisma.StringNullableFilter<"Device"> | string | null + accountId?: Prisma.StringNullableFilter<"Device"> | string | null + createdAt?: Prisma.DateTimeFilter<"Device"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Device"> | Date | string + password?: Prisma.StringNullableFilter<"Device"> | string | null + passwordHint?: Prisma.StringNullableFilter<"Device"> | string | null + namespace?: Prisma.StringNullableFilter<"Device"> | string | null +} + +export type DeviceCreateWithoutAppInstallsInput = { + id: number + uuid: string + name?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + account?: Prisma.AccountCreateNestedOneWithoutDevicesInput + kvStore?: Prisma.KVStoreCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthCreateNestedManyWithoutDeviceInput +} + +export type DeviceUncheckedCreateWithoutAppInstallsInput = { + id: number + uuid: string + name?: string | null + accountId?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + kvStore?: Prisma.KVStoreUncheckedCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthUncheckedCreateNestedManyWithoutDeviceInput +} + +export type DeviceCreateOrConnectWithoutAppInstallsInput = { + where: Prisma.DeviceWhereUniqueInput + create: Prisma.XOR +} + +export type DeviceUpsertWithoutAppInstallsInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.DeviceWhereInput +} + +export type DeviceUpdateToOneWithWhereWithoutAppInstallsInput = { + where?: Prisma.DeviceWhereInput + data: Prisma.XOR +} + +export type DeviceUpdateWithoutAppInstallsInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + account?: Prisma.AccountUpdateOneWithoutDevicesNestedInput + kvStore?: Prisma.KVStoreUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUpdateManyWithoutDeviceNestedInput +} + +export type DeviceUncheckedUpdateWithoutAppInstallsInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + accountId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + kvStore?: Prisma.KVStoreUncheckedUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUncheckedUpdateManyWithoutDeviceNestedInput +} + +export type DeviceCreateWithoutAutoAuthsInput = { + id: number + uuid: string + name?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + account?: Prisma.AccountCreateNestedOneWithoutDevicesInput + appInstalls?: Prisma.AppInstallCreateNestedManyWithoutDeviceInput + kvStore?: Prisma.KVStoreCreateNestedManyWithoutDeviceInput +} + +export type DeviceUncheckedCreateWithoutAutoAuthsInput = { + id: number + uuid: string + name?: string | null + accountId?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + appInstalls?: Prisma.AppInstallUncheckedCreateNestedManyWithoutDeviceInput + kvStore?: Prisma.KVStoreUncheckedCreateNestedManyWithoutDeviceInput +} + +export type DeviceCreateOrConnectWithoutAutoAuthsInput = { + where: Prisma.DeviceWhereUniqueInput + create: Prisma.XOR +} + +export type DeviceUpsertWithoutAutoAuthsInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.DeviceWhereInput +} + +export type DeviceUpdateToOneWithWhereWithoutAutoAuthsInput = { + where?: Prisma.DeviceWhereInput + data: Prisma.XOR +} + +export type DeviceUpdateWithoutAutoAuthsInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + account?: Prisma.AccountUpdateOneWithoutDevicesNestedInput + appInstalls?: Prisma.AppInstallUpdateManyWithoutDeviceNestedInput + kvStore?: Prisma.KVStoreUpdateManyWithoutDeviceNestedInput +} + +export type DeviceUncheckedUpdateWithoutAutoAuthsInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + accountId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + appInstalls?: Prisma.AppInstallUncheckedUpdateManyWithoutDeviceNestedInput + kvStore?: Prisma.KVStoreUncheckedUpdateManyWithoutDeviceNestedInput +} + +export type DeviceCreateWithoutKvStoreInput = { + id: number + uuid: string + name?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + account?: Prisma.AccountCreateNestedOneWithoutDevicesInput + appInstalls?: Prisma.AppInstallCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthCreateNestedManyWithoutDeviceInput +} + +export type DeviceUncheckedCreateWithoutKvStoreInput = { + id: number + uuid: string + name?: string | null + accountId?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null + appInstalls?: Prisma.AppInstallUncheckedCreateNestedManyWithoutDeviceInput + autoAuths?: Prisma.AutoAuthUncheckedCreateNestedManyWithoutDeviceInput +} + +export type DeviceCreateOrConnectWithoutKvStoreInput = { + where: Prisma.DeviceWhereUniqueInput + create: Prisma.XOR +} + +export type DeviceUpsertWithoutKvStoreInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.DeviceWhereInput +} + +export type DeviceUpdateToOneWithWhereWithoutKvStoreInput = { + where?: Prisma.DeviceWhereInput + data: Prisma.XOR +} + +export type DeviceUpdateWithoutKvStoreInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + account?: Prisma.AccountUpdateOneWithoutDevicesNestedInput + appInstalls?: Prisma.AppInstallUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUpdateManyWithoutDeviceNestedInput +} + +export type DeviceUncheckedUpdateWithoutKvStoreInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + accountId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + appInstalls?: Prisma.AppInstallUncheckedUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUncheckedUpdateManyWithoutDeviceNestedInput +} + +export type DeviceCreateManyAccountInput = { + id: number + uuid: string + name?: string | null + createdAt?: Date | string + updatedAt?: Date | string + password?: string | null + passwordHint?: string | null + namespace?: string | null +} + +export type DeviceUpdateWithoutAccountInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + appInstalls?: Prisma.AppInstallUpdateManyWithoutDeviceNestedInput + kvStore?: Prisma.KVStoreUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUpdateManyWithoutDeviceNestedInput +} + +export type DeviceUncheckedUpdateWithoutAccountInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + appInstalls?: Prisma.AppInstallUncheckedUpdateManyWithoutDeviceNestedInput + kvStore?: Prisma.KVStoreUncheckedUpdateManyWithoutDeviceNestedInput + autoAuths?: Prisma.AutoAuthUncheckedUpdateManyWithoutDeviceNestedInput +} + +export type DeviceUncheckedUpdateManyWithoutAccountInput = { + id?: Prisma.IntFieldUpdateOperationsInput | number + uuid?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + password?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + passwordHint?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + namespace?: Prisma.NullableStringFieldUpdateOperationsInput | string | null +} + + +/** + * Count Type DeviceCountOutputType + */ + +export type DeviceCountOutputType = { + appInstalls: number + kvStore: number + autoAuths: number +} + +export type DeviceCountOutputTypeSelect = { + appInstalls?: boolean | DeviceCountOutputTypeCountAppInstallsArgs + kvStore?: boolean | DeviceCountOutputTypeCountKvStoreArgs + autoAuths?: boolean | DeviceCountOutputTypeCountAutoAuthsArgs +} + +/** + * DeviceCountOutputType without action + */ +export type DeviceCountOutputTypeDefaultArgs = { + /** + * Select specific fields to fetch from the DeviceCountOutputType + */ + select?: Prisma.DeviceCountOutputTypeSelect | null +} + +/** + * DeviceCountOutputType without action + */ +export type DeviceCountOutputTypeCountAppInstallsArgs = { + where?: Prisma.AppInstallWhereInput +} + +/** + * DeviceCountOutputType without action + */ +export type DeviceCountOutputTypeCountKvStoreArgs = { + where?: Prisma.KVStoreWhereInput +} + +/** + * DeviceCountOutputType without action + */ +export type DeviceCountOutputTypeCountAutoAuthsArgs = { + where?: Prisma.AutoAuthWhereInput +} + + +export type DeviceSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + uuid?: boolean + name?: boolean + accountId?: boolean + createdAt?: boolean + updatedAt?: boolean + password?: boolean + passwordHint?: boolean + namespace?: boolean + account?: boolean | Prisma.Device$accountArgs + appInstalls?: boolean | Prisma.Device$appInstallsArgs + kvStore?: boolean | Prisma.Device$kvStoreArgs + autoAuths?: boolean | Prisma.Device$autoAuthsArgs + _count?: boolean | Prisma.DeviceCountOutputTypeDefaultArgs +}, ExtArgs["result"]["device"]> + +export type DeviceSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + uuid?: boolean + name?: boolean + accountId?: boolean + createdAt?: boolean + updatedAt?: boolean + password?: boolean + passwordHint?: boolean + namespace?: boolean + account?: boolean | Prisma.Device$accountArgs +}, ExtArgs["result"]["device"]> + +export type DeviceSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + uuid?: boolean + name?: boolean + accountId?: boolean + createdAt?: boolean + updatedAt?: boolean + password?: boolean + passwordHint?: boolean + namespace?: boolean + account?: boolean | Prisma.Device$accountArgs +}, ExtArgs["result"]["device"]> + +export type DeviceSelectScalar = { + id?: boolean + uuid?: boolean + name?: boolean + accountId?: boolean + createdAt?: boolean + updatedAt?: boolean + password?: boolean + passwordHint?: boolean + namespace?: boolean +} + +export type DeviceOmit = runtime.Types.Extensions.GetOmit<"id" | "uuid" | "name" | "accountId" | "createdAt" | "updatedAt" | "password" | "passwordHint" | "namespace", ExtArgs["result"]["device"]> +export type DeviceInclude = { + account?: boolean | Prisma.Device$accountArgs + appInstalls?: boolean | Prisma.Device$appInstallsArgs + kvStore?: boolean | Prisma.Device$kvStoreArgs + autoAuths?: boolean | Prisma.Device$autoAuthsArgs + _count?: boolean | Prisma.DeviceCountOutputTypeDefaultArgs +} +export type DeviceIncludeCreateManyAndReturn = { + account?: boolean | Prisma.Device$accountArgs +} +export type DeviceIncludeUpdateManyAndReturn = { + account?: boolean | Prisma.Device$accountArgs +} + +export type $DevicePayload = { + name: "Device" + objects: { + account: Prisma.$AccountPayload | null + appInstalls: Prisma.$AppInstallPayload[] + kvStore: Prisma.$KVStorePayload[] + autoAuths: Prisma.$AutoAuthPayload[] + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: number + uuid: string + name: string | null + accountId: string | null + createdAt: Date + updatedAt: Date + password: string | null + passwordHint: string | null + namespace: string | null + }, ExtArgs["result"]["device"]> + composites: {} +} + +export type DeviceGetPayload = runtime.Types.Result.GetResult + +export type DeviceCountArgs = + Omit & { + select?: DeviceCountAggregateInputType | true + } + +export interface DeviceDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['Device'], meta: { name: 'Device' } } + /** + * Find zero or one Device that matches the filter. + * @param {DeviceFindUniqueArgs} args - Arguments to find a Device + * @example + * // Get one Device + * const device = await prisma.device.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one Device that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {DeviceFindUniqueOrThrowArgs} args - Arguments to find a Device + * @example + * // Get one Device + * const device = await prisma.device.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Device that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {DeviceFindFirstArgs} args - Arguments to find a Device + * @example + * // Get one Device + * const device = await prisma.device.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Device that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {DeviceFindFirstOrThrowArgs} args - Arguments to find a Device + * @example + * // Get one Device + * const device = await prisma.device.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more Devices that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {DeviceFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all Devices + * const devices = await prisma.device.findMany() + * + * // Get first 10 Devices + * const devices = await prisma.device.findMany({ take: 10 }) + * + * // Only select the `id` + * const deviceWithIdOnly = await prisma.device.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a Device. + * @param {DeviceCreateArgs} args - Arguments to create a Device. + * @example + * // Create one Device + * const Device = await prisma.device.create({ + * data: { + * // ... data to create a Device + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many Devices. + * @param {DeviceCreateManyArgs} args - Arguments to create many Devices. + * @example + * // Create many Devices + * const device = await prisma.device.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many Devices and returns the data saved in the database. + * @param {DeviceCreateManyAndReturnArgs} args - Arguments to create many Devices. + * @example + * // Create many Devices + * const device = await prisma.device.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many Devices and only return the `id` + * const deviceWithIdOnly = await prisma.device.createManyAndReturn({ + * select: { id: true }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + createManyAndReturn(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "createManyAndReturn", GlobalOmitOptions>> + + /** + * Delete a Device. + * @param {DeviceDeleteArgs} args - Arguments to delete one Device. + * @example + * // Delete one Device + * const Device = await prisma.device.delete({ + * where: { + * // ... filter to delete one Device + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one Device. + * @param {DeviceUpdateArgs} args - Arguments to update one Device. + * @example + * // Update one Device + * const device = await prisma.device.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more Devices. + * @param {DeviceDeleteManyArgs} args - Arguments to filter Devices to delete. + * @example + * // Delete a few Devices + * const { count } = await prisma.device.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Devices. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {DeviceUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many Devices + * const device = await prisma.device.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Devices and returns the data updated in the database. + * @param {DeviceUpdateManyAndReturnArgs} args - Arguments to update many Devices. + * @example + * // Update many Devices + * const device = await prisma.device.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more Devices and only return the `id` + * const deviceWithIdOnly = await prisma.device.updateManyAndReturn({ + * select: { id: true }, + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + updateManyAndReturn(args: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "updateManyAndReturn", GlobalOmitOptions>> + + /** + * Create or update one Device. + * @param {DeviceUpsertArgs} args - Arguments to update or create a Device. + * @example + * // Update or create a Device + * const device = await prisma.device.upsert({ + * create: { + * // ... data to create a Device + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the Device we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__DeviceClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of Devices. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {DeviceCountArgs} args - Arguments to filter Devices to count. + * @example + * // Count the number of Devices + * const count = await prisma.device.count({ + * where: { + * // ... the filter for the Devices we want to count + * } + * }) + **/ + count( + args?: Prisma.Subset, + ): Prisma.PrismaPromise< + T extends runtime.Types.Utils.Record<'select', any> + ? T['select'] extends true + ? number + : Prisma.GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a Device. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {DeviceAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Prisma.Subset): Prisma.PrismaPromise> + + /** + * Group by Device. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {DeviceGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends DeviceGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: DeviceGroupByArgs['orderBy'] } + : { orderBy?: DeviceGroupByArgs['orderBy'] }, + OrderFields extends Prisma.ExcludeUnderscoreKeys>>, + ByFields extends Prisma.MaybeTupleToUnion, + ByValid extends Prisma.Has, + HavingFields extends Prisma.GetHavingFields, + HavingValid extends Prisma.Has, + ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, + InputErrors extends ByEmpty extends Prisma.True + ? `Error: "by" must not be empty.` + : HavingValid extends Prisma.False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: Prisma.SubsetIntersection & InputErrors): {} extends InputErrors ? GetDeviceGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the Device model + */ +readonly fields: DeviceFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for Device. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ +export interface Prisma__DeviceClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + account = {}>(args?: Prisma.Subset>): Prisma.Prisma__AccountClient, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + appInstalls = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + kvStore = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + autoAuths = {}>(args?: Prisma.Subset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions> | Null> + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): runtime.Types.Utils.JsPromise +} + + + + +/** + * Fields of the Device model + */ +export interface DeviceFieldRefs { + readonly id: Prisma.FieldRef<"Device", 'Int'> + readonly uuid: Prisma.FieldRef<"Device", 'String'> + readonly name: Prisma.FieldRef<"Device", 'String'> + readonly accountId: Prisma.FieldRef<"Device", 'String'> + readonly createdAt: Prisma.FieldRef<"Device", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"Device", 'DateTime'> + readonly password: Prisma.FieldRef<"Device", 'String'> + readonly passwordHint: Prisma.FieldRef<"Device", 'String'> + readonly namespace: Prisma.FieldRef<"Device", 'String'> +} + + +// Custom InputTypes +/** + * Device findUnique + */ +export type DeviceFindUniqueArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * Filter, which Device to fetch. + */ + where: Prisma.DeviceWhereUniqueInput +} + +/** + * Device findUniqueOrThrow + */ +export type DeviceFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * Filter, which Device to fetch. + */ + where: Prisma.DeviceWhereUniqueInput +} + +/** + * Device findFirst + */ +export type DeviceFindFirstArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * Filter, which Device to fetch. + */ + where?: Prisma.DeviceWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Devices to fetch. + */ + orderBy?: Prisma.DeviceOrderByWithRelationInput | Prisma.DeviceOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Devices. + */ + cursor?: Prisma.DeviceWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Devices from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Devices. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Devices. + */ + distinct?: Prisma.DeviceScalarFieldEnum | Prisma.DeviceScalarFieldEnum[] +} + +/** + * Device findFirstOrThrow + */ +export type DeviceFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * Filter, which Device to fetch. + */ + where?: Prisma.DeviceWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Devices to fetch. + */ + orderBy?: Prisma.DeviceOrderByWithRelationInput | Prisma.DeviceOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Devices. + */ + cursor?: Prisma.DeviceWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Devices from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Devices. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Devices. + */ + distinct?: Prisma.DeviceScalarFieldEnum | Prisma.DeviceScalarFieldEnum[] +} + +/** + * Device findMany + */ +export type DeviceFindManyArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * Filter, which Devices to fetch. + */ + where?: Prisma.DeviceWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Devices to fetch. + */ + orderBy?: Prisma.DeviceOrderByWithRelationInput | Prisma.DeviceOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing Devices. + */ + cursor?: Prisma.DeviceWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Devices from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` Devices. + */ + skip?: number + distinct?: Prisma.DeviceScalarFieldEnum | Prisma.DeviceScalarFieldEnum[] +} + +/** + * Device create + */ +export type DeviceCreateArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * The data needed to create a Device. + */ + data: Prisma.XOR +} + +/** + * Device createMany + */ +export type DeviceCreateManyArgs = { + /** + * The data used to create many Devices. + */ + data: Prisma.DeviceCreateManyInput | Prisma.DeviceCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * Device createManyAndReturn + */ +export type DeviceCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelectCreateManyAndReturn | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * The data used to create many Devices. + */ + data: Prisma.DeviceCreateManyInput | Prisma.DeviceCreateManyInput[] + skipDuplicates?: boolean + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceIncludeCreateManyAndReturn | null +} + +/** + * Device update + */ +export type DeviceUpdateArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * The data needed to update a Device. + */ + data: Prisma.XOR + /** + * Choose, which Device to update. + */ + where: Prisma.DeviceWhereUniqueInput +} + +/** + * Device updateMany + */ +export type DeviceUpdateManyArgs = { + /** + * The data used to update Devices. + */ + data: Prisma.XOR + /** + * Filter which Devices to update + */ + where?: Prisma.DeviceWhereInput + /** + * Limit how many Devices to update. + */ + limit?: number +} + +/** + * Device updateManyAndReturn + */ +export type DeviceUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * The data used to update Devices. + */ + data: Prisma.XOR + /** + * Filter which Devices to update + */ + where?: Prisma.DeviceWhereInput + /** + * Limit how many Devices to update. + */ + limit?: number + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceIncludeUpdateManyAndReturn | null +} + +/** + * Device upsert + */ +export type DeviceUpsertArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * The filter to search for the Device to update in case it exists. + */ + where: Prisma.DeviceWhereUniqueInput + /** + * In case the Device found by the `where` argument doesn't exist, create a new Device with this data. + */ + create: Prisma.XOR + /** + * In case the Device was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * Device delete + */ +export type DeviceDeleteArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null + /** + * Filter which Device to delete. + */ + where: Prisma.DeviceWhereUniqueInput +} + +/** + * Device deleteMany + */ +export type DeviceDeleteManyArgs = { + /** + * Filter which Devices to delete + */ + where?: Prisma.DeviceWhereInput + /** + * Limit how many Devices to delete. + */ + limit?: number +} + +/** + * Device.account + */ +export type Device$accountArgs = { + /** + * Select specific fields to fetch from the Account + */ + select?: Prisma.AccountSelect | null + /** + * Omit specific fields from the Account + */ + omit?: Prisma.AccountOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AccountInclude | null + where?: Prisma.AccountWhereInput +} + +/** + * Device.appInstalls + */ +export type Device$appInstallsArgs = { + /** + * Select specific fields to fetch from the AppInstall + */ + select?: Prisma.AppInstallSelect | null + /** + * Omit specific fields from the AppInstall + */ + omit?: Prisma.AppInstallOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AppInstallInclude | null + where?: Prisma.AppInstallWhereInput + orderBy?: Prisma.AppInstallOrderByWithRelationInput | Prisma.AppInstallOrderByWithRelationInput[] + cursor?: Prisma.AppInstallWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.AppInstallScalarFieldEnum | Prisma.AppInstallScalarFieldEnum[] +} + +/** + * Device.kvStore + */ +export type Device$kvStoreArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + where?: Prisma.KVStoreWhereInput + orderBy?: Prisma.KVStoreOrderByWithRelationInput | Prisma.KVStoreOrderByWithRelationInput[] + cursor?: Prisma.KVStoreWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.KVStoreScalarFieldEnum | Prisma.KVStoreScalarFieldEnum[] +} + +/** + * Device.autoAuths + */ +export type Device$autoAuthsArgs = { + /** + * Select specific fields to fetch from the AutoAuth + */ + select?: Prisma.AutoAuthSelect | null + /** + * Omit specific fields from the AutoAuth + */ + omit?: Prisma.AutoAuthOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.AutoAuthInclude | null + where?: Prisma.AutoAuthWhereInput + orderBy?: Prisma.AutoAuthOrderByWithRelationInput | Prisma.AutoAuthOrderByWithRelationInput[] + cursor?: Prisma.AutoAuthWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.AutoAuthScalarFieldEnum | Prisma.AutoAuthScalarFieldEnum[] +} + +/** + * Device without action + */ +export type DeviceDefaultArgs = { + /** + * Select specific fields to fetch from the Device + */ + select?: Prisma.DeviceSelect | null + /** + * Omit specific fields from the Device + */ + omit?: Prisma.DeviceOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.DeviceInclude | null +} diff --git a/generated/prisma/models/KVStore.ts b/generated/prisma/models/KVStore.ts new file mode 100644 index 0000000..2203a83 --- /dev/null +++ b/generated/prisma/models/KVStore.ts @@ -0,0 +1,1419 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `KVStore` model and its related types. + * + * 🟢 You can import this file directly. + */ +import type * as runtime from "@prisma/client/runtime/client" +import type * as $Enums from "../enums.ts" +import type * as Prisma from "../internal/prismaNamespace.ts" + +/** + * Model KVStore + * + */ +export type KVStoreModel = runtime.Types.Result.DefaultSelection + +export type AggregateKVStore = { + _count: KVStoreCountAggregateOutputType | null + _avg: KVStoreAvgAggregateOutputType | null + _sum: KVStoreSumAggregateOutputType | null + _min: KVStoreMinAggregateOutputType | null + _max: KVStoreMaxAggregateOutputType | null +} + +export type KVStoreAvgAggregateOutputType = { + deviceId: number | null +} + +export type KVStoreSumAggregateOutputType = { + deviceId: number | null +} + +export type KVStoreMinAggregateOutputType = { + deviceId: number | null + key: string | null + creatorIp: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type KVStoreMaxAggregateOutputType = { + deviceId: number | null + key: string | null + creatorIp: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type KVStoreCountAggregateOutputType = { + deviceId: number + key: number + value: number + creatorIp: number + createdAt: number + updatedAt: number + _all: number +} + + +export type KVStoreAvgAggregateInputType = { + deviceId?: true +} + +export type KVStoreSumAggregateInputType = { + deviceId?: true +} + +export type KVStoreMinAggregateInputType = { + deviceId?: true + key?: true + creatorIp?: true + createdAt?: true + updatedAt?: true +} + +export type KVStoreMaxAggregateInputType = { + deviceId?: true + key?: true + creatorIp?: true + createdAt?: true + updatedAt?: true +} + +export type KVStoreCountAggregateInputType = { + deviceId?: true + key?: true + value?: true + creatorIp?: true + createdAt?: true + updatedAt?: true + _all?: true +} + +export type KVStoreAggregateArgs = { + /** + * Filter which KVStore to aggregate. + */ + where?: Prisma.KVStoreWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of KVStores to fetch. + */ + orderBy?: Prisma.KVStoreOrderByWithRelationInput | Prisma.KVStoreOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.KVStoreWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` KVStores from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` KVStores. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned KVStores + **/ + _count?: true | KVStoreCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to average + **/ + _avg?: KVStoreAvgAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to sum + **/ + _sum?: KVStoreSumAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: KVStoreMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: KVStoreMaxAggregateInputType +} + +export type GetKVStoreAggregateType = { + [P in keyof T & keyof AggregateKVStore]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type KVStoreGroupByArgs = { + where?: Prisma.KVStoreWhereInput + orderBy?: Prisma.KVStoreOrderByWithAggregationInput | Prisma.KVStoreOrderByWithAggregationInput[] + by: Prisma.KVStoreScalarFieldEnum[] | Prisma.KVStoreScalarFieldEnum + having?: Prisma.KVStoreScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: KVStoreCountAggregateInputType | true + _avg?: KVStoreAvgAggregateInputType + _sum?: KVStoreSumAggregateInputType + _min?: KVStoreMinAggregateInputType + _max?: KVStoreMaxAggregateInputType +} + +export type KVStoreGroupByOutputType = { + deviceId: number + key: string + value: runtime.JsonValue + creatorIp: string | null + createdAt: Date + updatedAt: Date + _count: KVStoreCountAggregateOutputType | null + _avg: KVStoreAvgAggregateOutputType | null + _sum: KVStoreSumAggregateOutputType | null + _min: KVStoreMinAggregateOutputType | null + _max: KVStoreMaxAggregateOutputType | null +} + +type GetKVStoreGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof KVStoreGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type KVStoreWhereInput = { + AND?: Prisma.KVStoreWhereInput | Prisma.KVStoreWhereInput[] + OR?: Prisma.KVStoreWhereInput[] + NOT?: Prisma.KVStoreWhereInput | Prisma.KVStoreWhereInput[] + deviceId?: Prisma.IntFilter<"KVStore"> | number + key?: Prisma.StringFilter<"KVStore"> | string + value?: Prisma.JsonFilter<"KVStore"> + creatorIp?: Prisma.StringNullableFilter<"KVStore"> | string | null + createdAt?: Prisma.DateTimeFilter<"KVStore"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"KVStore"> | Date | string + device?: Prisma.XOR +} + +export type KVStoreOrderByWithRelationInput = { + deviceId?: Prisma.SortOrder + key?: Prisma.SortOrder + value?: Prisma.SortOrder + creatorIp?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + device?: Prisma.DeviceOrderByWithRelationInput +} + +export type KVStoreWhereUniqueInput = Prisma.AtLeast<{ + deviceId_key?: Prisma.KVStoreDeviceIdKeyCompoundUniqueInput + AND?: Prisma.KVStoreWhereInput | Prisma.KVStoreWhereInput[] + OR?: Prisma.KVStoreWhereInput[] + NOT?: Prisma.KVStoreWhereInput | Prisma.KVStoreWhereInput[] + deviceId?: Prisma.IntFilter<"KVStore"> | number + key?: Prisma.StringFilter<"KVStore"> | string + value?: Prisma.JsonFilter<"KVStore"> + creatorIp?: Prisma.StringNullableFilter<"KVStore"> | string | null + createdAt?: Prisma.DateTimeFilter<"KVStore"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"KVStore"> | Date | string + device?: Prisma.XOR +}, "deviceId_key"> + +export type KVStoreOrderByWithAggregationInput = { + deviceId?: Prisma.SortOrder + key?: Prisma.SortOrder + value?: Prisma.SortOrder + creatorIp?: Prisma.SortOrderInput | Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + _count?: Prisma.KVStoreCountOrderByAggregateInput + _avg?: Prisma.KVStoreAvgOrderByAggregateInput + _max?: Prisma.KVStoreMaxOrderByAggregateInput + _min?: Prisma.KVStoreMinOrderByAggregateInput + _sum?: Prisma.KVStoreSumOrderByAggregateInput +} + +export type KVStoreScalarWhereWithAggregatesInput = { + AND?: Prisma.KVStoreScalarWhereWithAggregatesInput | Prisma.KVStoreScalarWhereWithAggregatesInput[] + OR?: Prisma.KVStoreScalarWhereWithAggregatesInput[] + NOT?: Prisma.KVStoreScalarWhereWithAggregatesInput | Prisma.KVStoreScalarWhereWithAggregatesInput[] + deviceId?: Prisma.IntWithAggregatesFilter<"KVStore"> | number + key?: Prisma.StringWithAggregatesFilter<"KVStore"> | string + value?: Prisma.JsonWithAggregatesFilter<"KVStore"> + creatorIp?: Prisma.StringNullableWithAggregatesFilter<"KVStore"> | string | null + createdAt?: Prisma.DateTimeWithAggregatesFilter<"KVStore"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"KVStore"> | Date | string +} + +export type KVStoreCreateInput = { + key: string + value: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: string | null + createdAt?: Date | string + updatedAt?: Date | string + device: Prisma.DeviceCreateNestedOneWithoutKvStoreInput +} + +export type KVStoreUncheckedCreateInput = { + deviceId: number + key: string + value: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: string | null + createdAt?: Date | string + updatedAt?: Date | string +} + +export type KVStoreUpdateInput = { + key?: Prisma.StringFieldUpdateOperationsInput | string + value?: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + device?: Prisma.DeviceUpdateOneRequiredWithoutKvStoreNestedInput +} + +export type KVStoreUncheckedUpdateInput = { + deviceId?: Prisma.IntFieldUpdateOperationsInput | number + key?: Prisma.StringFieldUpdateOperationsInput | string + value?: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type KVStoreCreateManyInput = { + deviceId: number + key: string + value: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: string | null + createdAt?: Date | string + updatedAt?: Date | string +} + +export type KVStoreUpdateManyMutationInput = { + key?: Prisma.StringFieldUpdateOperationsInput | string + value?: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type KVStoreUncheckedUpdateManyInput = { + deviceId?: Prisma.IntFieldUpdateOperationsInput | number + key?: Prisma.StringFieldUpdateOperationsInput | string + value?: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type KVStoreListRelationFilter = { + every?: Prisma.KVStoreWhereInput + some?: Prisma.KVStoreWhereInput + none?: Prisma.KVStoreWhereInput +} + +export type KVStoreOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type KVStoreDeviceIdKeyCompoundUniqueInput = { + deviceId: number + key: string +} + +export type KVStoreCountOrderByAggregateInput = { + deviceId?: Prisma.SortOrder + key?: Prisma.SortOrder + value?: Prisma.SortOrder + creatorIp?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type KVStoreAvgOrderByAggregateInput = { + deviceId?: Prisma.SortOrder +} + +export type KVStoreMaxOrderByAggregateInput = { + deviceId?: Prisma.SortOrder + key?: Prisma.SortOrder + creatorIp?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type KVStoreMinOrderByAggregateInput = { + deviceId?: Prisma.SortOrder + key?: Prisma.SortOrder + creatorIp?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type KVStoreSumOrderByAggregateInput = { + deviceId?: Prisma.SortOrder +} + +export type KVStoreCreateNestedManyWithoutDeviceInput = { + create?: Prisma.XOR | Prisma.KVStoreCreateWithoutDeviceInput[] | Prisma.KVStoreUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.KVStoreCreateOrConnectWithoutDeviceInput | Prisma.KVStoreCreateOrConnectWithoutDeviceInput[] + createMany?: Prisma.KVStoreCreateManyDeviceInputEnvelope + connect?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] +} + +export type KVStoreUncheckedCreateNestedManyWithoutDeviceInput = { + create?: Prisma.XOR | Prisma.KVStoreCreateWithoutDeviceInput[] | Prisma.KVStoreUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.KVStoreCreateOrConnectWithoutDeviceInput | Prisma.KVStoreCreateOrConnectWithoutDeviceInput[] + createMany?: Prisma.KVStoreCreateManyDeviceInputEnvelope + connect?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] +} + +export type KVStoreUpdateManyWithoutDeviceNestedInput = { + create?: Prisma.XOR | Prisma.KVStoreCreateWithoutDeviceInput[] | Prisma.KVStoreUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.KVStoreCreateOrConnectWithoutDeviceInput | Prisma.KVStoreCreateOrConnectWithoutDeviceInput[] + upsert?: Prisma.KVStoreUpsertWithWhereUniqueWithoutDeviceInput | Prisma.KVStoreUpsertWithWhereUniqueWithoutDeviceInput[] + createMany?: Prisma.KVStoreCreateManyDeviceInputEnvelope + set?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + disconnect?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + delete?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + connect?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + update?: Prisma.KVStoreUpdateWithWhereUniqueWithoutDeviceInput | Prisma.KVStoreUpdateWithWhereUniqueWithoutDeviceInput[] + updateMany?: Prisma.KVStoreUpdateManyWithWhereWithoutDeviceInput | Prisma.KVStoreUpdateManyWithWhereWithoutDeviceInput[] + deleteMany?: Prisma.KVStoreScalarWhereInput | Prisma.KVStoreScalarWhereInput[] +} + +export type KVStoreUncheckedUpdateManyWithoutDeviceNestedInput = { + create?: Prisma.XOR | Prisma.KVStoreCreateWithoutDeviceInput[] | Prisma.KVStoreUncheckedCreateWithoutDeviceInput[] + connectOrCreate?: Prisma.KVStoreCreateOrConnectWithoutDeviceInput | Prisma.KVStoreCreateOrConnectWithoutDeviceInput[] + upsert?: Prisma.KVStoreUpsertWithWhereUniqueWithoutDeviceInput | Prisma.KVStoreUpsertWithWhereUniqueWithoutDeviceInput[] + createMany?: Prisma.KVStoreCreateManyDeviceInputEnvelope + set?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + disconnect?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + delete?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + connect?: Prisma.KVStoreWhereUniqueInput | Prisma.KVStoreWhereUniqueInput[] + update?: Prisma.KVStoreUpdateWithWhereUniqueWithoutDeviceInput | Prisma.KVStoreUpdateWithWhereUniqueWithoutDeviceInput[] + updateMany?: Prisma.KVStoreUpdateManyWithWhereWithoutDeviceInput | Prisma.KVStoreUpdateManyWithWhereWithoutDeviceInput[] + deleteMany?: Prisma.KVStoreScalarWhereInput | Prisma.KVStoreScalarWhereInput[] +} + +export type KVStoreCreateWithoutDeviceInput = { + key: string + value: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: string | null + createdAt?: Date | string + updatedAt?: Date | string +} + +export type KVStoreUncheckedCreateWithoutDeviceInput = { + key: string + value: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: string | null + createdAt?: Date | string + updatedAt?: Date | string +} + +export type KVStoreCreateOrConnectWithoutDeviceInput = { + where: Prisma.KVStoreWhereUniqueInput + create: Prisma.XOR +} + +export type KVStoreCreateManyDeviceInputEnvelope = { + data: Prisma.KVStoreCreateManyDeviceInput | Prisma.KVStoreCreateManyDeviceInput[] + skipDuplicates?: boolean +} + +export type KVStoreUpsertWithWhereUniqueWithoutDeviceInput = { + where: Prisma.KVStoreWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type KVStoreUpdateWithWhereUniqueWithoutDeviceInput = { + where: Prisma.KVStoreWhereUniqueInput + data: Prisma.XOR +} + +export type KVStoreUpdateManyWithWhereWithoutDeviceInput = { + where: Prisma.KVStoreScalarWhereInput + data: Prisma.XOR +} + +export type KVStoreScalarWhereInput = { + AND?: Prisma.KVStoreScalarWhereInput | Prisma.KVStoreScalarWhereInput[] + OR?: Prisma.KVStoreScalarWhereInput[] + NOT?: Prisma.KVStoreScalarWhereInput | Prisma.KVStoreScalarWhereInput[] + deviceId?: Prisma.IntFilter<"KVStore"> | number + key?: Prisma.StringFilter<"KVStore"> | string + value?: Prisma.JsonFilter<"KVStore"> + creatorIp?: Prisma.StringNullableFilter<"KVStore"> | string | null + createdAt?: Prisma.DateTimeFilter<"KVStore"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"KVStore"> | Date | string +} + +export type KVStoreCreateManyDeviceInput = { + key: string + value: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: string | null + createdAt?: Date | string + updatedAt?: Date | string +} + +export type KVStoreUpdateWithoutDeviceInput = { + key?: Prisma.StringFieldUpdateOperationsInput | string + value?: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type KVStoreUncheckedUpdateWithoutDeviceInput = { + key?: Prisma.StringFieldUpdateOperationsInput | string + value?: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type KVStoreUncheckedUpdateManyWithoutDeviceInput = { + key?: Prisma.StringFieldUpdateOperationsInput | string + value?: Prisma.JsonNullValueInput | runtime.InputJsonValue + creatorIp?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + + + +export type KVStoreSelect = runtime.Types.Extensions.GetSelect<{ + deviceId?: boolean + key?: boolean + value?: boolean + creatorIp?: boolean + createdAt?: boolean + updatedAt?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["kVStore"]> + +export type KVStoreSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + deviceId?: boolean + key?: boolean + value?: boolean + creatorIp?: boolean + createdAt?: boolean + updatedAt?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["kVStore"]> + +export type KVStoreSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + deviceId?: boolean + key?: boolean + value?: boolean + creatorIp?: boolean + createdAt?: boolean + updatedAt?: boolean + device?: boolean | Prisma.DeviceDefaultArgs +}, ExtArgs["result"]["kVStore"]> + +export type KVStoreSelectScalar = { + deviceId?: boolean + key?: boolean + value?: boolean + creatorIp?: boolean + createdAt?: boolean + updatedAt?: boolean +} + +export type KVStoreOmit = runtime.Types.Extensions.GetOmit<"deviceId" | "key" | "value" | "creatorIp" | "createdAt" | "updatedAt", ExtArgs["result"]["kVStore"]> +export type KVStoreInclude = { + device?: boolean | Prisma.DeviceDefaultArgs +} +export type KVStoreIncludeCreateManyAndReturn = { + device?: boolean | Prisma.DeviceDefaultArgs +} +export type KVStoreIncludeUpdateManyAndReturn = { + device?: boolean | Prisma.DeviceDefaultArgs +} + +export type $KVStorePayload = { + name: "KVStore" + objects: { + device: Prisma.$DevicePayload + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + deviceId: number + key: string + value: runtime.JsonValue + creatorIp: string | null + createdAt: Date + updatedAt: Date + }, ExtArgs["result"]["kVStore"]> + composites: {} +} + +export type KVStoreGetPayload = runtime.Types.Result.GetResult + +export type KVStoreCountArgs = + Omit & { + select?: KVStoreCountAggregateInputType | true + } + +export interface KVStoreDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['KVStore'], meta: { name: 'KVStore' } } + /** + * Find zero or one KVStore that matches the filter. + * @param {KVStoreFindUniqueArgs} args - Arguments to find a KVStore + * @example + * // Get one KVStore + * const kVStore = await prisma.kVStore.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one KVStore that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {KVStoreFindUniqueOrThrowArgs} args - Arguments to find a KVStore + * @example + * // Get one KVStore + * const kVStore = await prisma.kVStore.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first KVStore that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {KVStoreFindFirstArgs} args - Arguments to find a KVStore + * @example + * // Get one KVStore + * const kVStore = await prisma.kVStore.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first KVStore that matches the filter or + * throw `PrismaKnownClientError` with `P2025` code if no matches were found. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {KVStoreFindFirstOrThrowArgs} args - Arguments to find a KVStore + * @example + * // Get one KVStore + * const kVStore = await prisma.kVStore.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more KVStores that matches the filter. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {KVStoreFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all KVStores + * const kVStores = await prisma.kVStore.findMany() + * + * // Get first 10 KVStores + * const kVStores = await prisma.kVStore.findMany({ take: 10 }) + * + * // Only select the `deviceId` + * const kVStoreWithDeviceIdOnly = await prisma.kVStore.findMany({ select: { deviceId: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a KVStore. + * @param {KVStoreCreateArgs} args - Arguments to create a KVStore. + * @example + * // Create one KVStore + * const KVStore = await prisma.kVStore.create({ + * data: { + * // ... data to create a KVStore + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many KVStores. + * @param {KVStoreCreateManyArgs} args - Arguments to create many KVStores. + * @example + * // Create many KVStores + * const kVStore = await prisma.kVStore.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many KVStores and returns the data saved in the database. + * @param {KVStoreCreateManyAndReturnArgs} args - Arguments to create many KVStores. + * @example + * // Create many KVStores + * const kVStore = await prisma.kVStore.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many KVStores and only return the `deviceId` + * const kVStoreWithDeviceIdOnly = await prisma.kVStore.createManyAndReturn({ + * select: { deviceId: true }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + createManyAndReturn(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "createManyAndReturn", GlobalOmitOptions>> + + /** + * Delete a KVStore. + * @param {KVStoreDeleteArgs} args - Arguments to delete one KVStore. + * @example + * // Delete one KVStore + * const KVStore = await prisma.kVStore.delete({ + * where: { + * // ... filter to delete one KVStore + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one KVStore. + * @param {KVStoreUpdateArgs} args - Arguments to update one KVStore. + * @example + * // Update one KVStore + * const kVStore = await prisma.kVStore.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more KVStores. + * @param {KVStoreDeleteManyArgs} args - Arguments to filter KVStores to delete. + * @example + * // Delete a few KVStores + * const { count } = await prisma.kVStore.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more KVStores. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {KVStoreUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many KVStores + * const kVStore = await prisma.kVStore.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more KVStores and returns the data updated in the database. + * @param {KVStoreUpdateManyAndReturnArgs} args - Arguments to update many KVStores. + * @example + * // Update many KVStores + * const kVStore = await prisma.kVStore.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more KVStores and only return the `deviceId` + * const kVStoreWithDeviceIdOnly = await prisma.kVStore.updateManyAndReturn({ + * select: { deviceId: true }, + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * + */ + updateManyAndReturn(args: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "updateManyAndReturn", GlobalOmitOptions>> + + /** + * Create or update one KVStore. + * @param {KVStoreUpsertArgs} args - Arguments to update or create a KVStore. + * @example + * // Update or create a KVStore + * const kVStore = await prisma.kVStore.upsert({ + * create: { + * // ... data to create a KVStore + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the KVStore we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__KVStoreClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of KVStores. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {KVStoreCountArgs} args - Arguments to filter KVStores to count. + * @example + * // Count the number of KVStores + * const count = await prisma.kVStore.count({ + * where: { + * // ... the filter for the KVStores we want to count + * } + * }) + **/ + count( + args?: Prisma.Subset, + ): Prisma.PrismaPromise< + T extends runtime.Types.Utils.Record<'select', any> + ? T['select'] extends true + ? number + : Prisma.GetScalarType + : number + > + + /** + * Allows you to perform aggregations operations on a KVStore. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {KVStoreAggregateArgs} args - Select which aggregations you would like to apply and on what fields. + * @example + * // Ordered by age ascending + * // Where email contains prisma.io + * // Limited to the 10 users + * const aggregations = await prisma.user.aggregate({ + * _avg: { + * age: true, + * }, + * where: { + * email: { + * contains: "prisma.io", + * }, + * }, + * orderBy: { + * age: "asc", + * }, + * take: 10, + * }) + **/ + aggregate(args: Prisma.Subset): Prisma.PrismaPromise> + + /** + * Group by KVStore. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {KVStoreGroupByArgs} args - Group by arguments. + * @example + * // Group by city, order by createdAt, get count + * const result = await prisma.user.groupBy({ + * by: ['city', 'createdAt'], + * orderBy: { + * createdAt: true + * }, + * _count: { + * _all: true + * }, + * }) + * + **/ + groupBy< + T extends KVStoreGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: KVStoreGroupByArgs['orderBy'] } + : { orderBy?: KVStoreGroupByArgs['orderBy'] }, + OrderFields extends Prisma.ExcludeUnderscoreKeys>>, + ByFields extends Prisma.MaybeTupleToUnion, + ByValid extends Prisma.Has, + HavingFields extends Prisma.GetHavingFields, + HavingValid extends Prisma.Has, + ByEmpty extends T['by'] extends never[] ? Prisma.True : Prisma.False, + InputErrors extends ByEmpty extends Prisma.True + ? `Error: "by" must not be empty.` + : HavingValid extends Prisma.False + ? { + [P in HavingFields]: P extends ByFields + ? never + : P extends string + ? `Error: Field "${P}" used in "having" needs to be provided in "by".` + : [ + Error, + 'Field ', + P, + ` in "having" needs to be provided in "by"`, + ] + }[HavingFields] + : 'take' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "take", you also need to provide "orderBy"' + : 'skip' extends Prisma.Keys + ? 'orderBy' extends Prisma.Keys + ? ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + : 'Error: If you provide "skip", you also need to provide "orderBy"' + : ByValid extends Prisma.True + ? {} + : { + [P in OrderFields]: P extends ByFields + ? never + : `Error: Field "${P}" in "orderBy" needs to be provided in "by"` + }[OrderFields] + >(args: Prisma.SubsetIntersection & InputErrors): {} extends InputErrors ? GetKVStoreGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the KVStore model + */ +readonly fields: KVStoreFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for KVStore. + * Why is this prefixed with `Prisma__`? + * Because we want to prevent naming conflicts as mentioned in + * https://github.com/prisma/prisma-client-js/issues/707 + */ +export interface Prisma__KVStoreClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + device = {}>(args?: Prisma.Subset>): Prisma.Prisma__DeviceClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + /** + * Attaches callbacks for the resolution and/or rejection of the Promise. + * @param onfulfilled The callback to execute when the Promise is resolved. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of which ever callback is executed. + */ + then(onfulfilled?: ((value: T) => TResult1 | PromiseLike) | undefined | null, onrejected?: ((reason: any) => TResult2 | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback for only the rejection of the Promise. + * @param onrejected The callback to execute when the Promise is rejected. + * @returns A Promise for the completion of the callback. + */ + catch(onrejected?: ((reason: any) => TResult | PromiseLike) | undefined | null): runtime.Types.Utils.JsPromise + /** + * Attaches a callback that is invoked when the Promise is settled (fulfilled or rejected). The + * resolved value cannot be modified from the callback. + * @param onfinally The callback to execute when the Promise is settled (fulfilled or rejected). + * @returns A Promise for the completion of the callback. + */ + finally(onfinally?: (() => void) | undefined | null): runtime.Types.Utils.JsPromise +} + + + + +/** + * Fields of the KVStore model + */ +export interface KVStoreFieldRefs { + readonly deviceId: Prisma.FieldRef<"KVStore", 'Int'> + readonly key: Prisma.FieldRef<"KVStore", 'String'> + readonly value: Prisma.FieldRef<"KVStore", 'Json'> + readonly creatorIp: Prisma.FieldRef<"KVStore", 'String'> + readonly createdAt: Prisma.FieldRef<"KVStore", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"KVStore", 'DateTime'> +} + + +// Custom InputTypes +/** + * KVStore findUnique + */ +export type KVStoreFindUniqueArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * Filter, which KVStore to fetch. + */ + where: Prisma.KVStoreWhereUniqueInput +} + +/** + * KVStore findUniqueOrThrow + */ +export type KVStoreFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * Filter, which KVStore to fetch. + */ + where: Prisma.KVStoreWhereUniqueInput +} + +/** + * KVStore findFirst + */ +export type KVStoreFindFirstArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * Filter, which KVStore to fetch. + */ + where?: Prisma.KVStoreWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of KVStores to fetch. + */ + orderBy?: Prisma.KVStoreOrderByWithRelationInput | Prisma.KVStoreOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for KVStores. + */ + cursor?: Prisma.KVStoreWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` KVStores from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` KVStores. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of KVStores. + */ + distinct?: Prisma.KVStoreScalarFieldEnum | Prisma.KVStoreScalarFieldEnum[] +} + +/** + * KVStore findFirstOrThrow + */ +export type KVStoreFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * Filter, which KVStore to fetch. + */ + where?: Prisma.KVStoreWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of KVStores to fetch. + */ + orderBy?: Prisma.KVStoreOrderByWithRelationInput | Prisma.KVStoreOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for KVStores. + */ + cursor?: Prisma.KVStoreWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` KVStores from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` KVStores. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of KVStores. + */ + distinct?: Prisma.KVStoreScalarFieldEnum | Prisma.KVStoreScalarFieldEnum[] +} + +/** + * KVStore findMany + */ +export type KVStoreFindManyArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * Filter, which KVStores to fetch. + */ + where?: Prisma.KVStoreWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of KVStores to fetch. + */ + orderBy?: Prisma.KVStoreOrderByWithRelationInput | Prisma.KVStoreOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing KVStores. + */ + cursor?: Prisma.KVStoreWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` KVStores from the position of the cursor. + */ + take?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Skip the first `n` KVStores. + */ + skip?: number + distinct?: Prisma.KVStoreScalarFieldEnum | Prisma.KVStoreScalarFieldEnum[] +} + +/** + * KVStore create + */ +export type KVStoreCreateArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * The data needed to create a KVStore. + */ + data: Prisma.XOR +} + +/** + * KVStore createMany + */ +export type KVStoreCreateManyArgs = { + /** + * The data used to create many KVStores. + */ + data: Prisma.KVStoreCreateManyInput | Prisma.KVStoreCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * KVStore createManyAndReturn + */ +export type KVStoreCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelectCreateManyAndReturn | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * The data used to create many KVStores. + */ + data: Prisma.KVStoreCreateManyInput | Prisma.KVStoreCreateManyInput[] + skipDuplicates?: boolean + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreIncludeCreateManyAndReturn | null +} + +/** + * KVStore update + */ +export type KVStoreUpdateArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * The data needed to update a KVStore. + */ + data: Prisma.XOR + /** + * Choose, which KVStore to update. + */ + where: Prisma.KVStoreWhereUniqueInput +} + +/** + * KVStore updateMany + */ +export type KVStoreUpdateManyArgs = { + /** + * The data used to update KVStores. + */ + data: Prisma.XOR + /** + * Filter which KVStores to update + */ + where?: Prisma.KVStoreWhereInput + /** + * Limit how many KVStores to update. + */ + limit?: number +} + +/** + * KVStore updateManyAndReturn + */ +export type KVStoreUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * The data used to update KVStores. + */ + data: Prisma.XOR + /** + * Filter which KVStores to update + */ + where?: Prisma.KVStoreWhereInput + /** + * Limit how many KVStores to update. + */ + limit?: number + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreIncludeUpdateManyAndReturn | null +} + +/** + * KVStore upsert + */ +export type KVStoreUpsertArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * The filter to search for the KVStore to update in case it exists. + */ + where: Prisma.KVStoreWhereUniqueInput + /** + * In case the KVStore found by the `where` argument doesn't exist, create a new KVStore with this data. + */ + create: Prisma.XOR + /** + * In case the KVStore was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * KVStore delete + */ +export type KVStoreDeleteArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null + /** + * Filter which KVStore to delete. + */ + where: Prisma.KVStoreWhereUniqueInput +} + +/** + * KVStore deleteMany + */ +export type KVStoreDeleteManyArgs = { + /** + * Filter which KVStores to delete + */ + where?: Prisma.KVStoreWhereInput + /** + * Limit how many KVStores to delete. + */ + limit?: number +} + +/** + * KVStore without action + */ +export type KVStoreDefaultArgs = { + /** + * Select specific fields to fetch from the KVStore + */ + select?: Prisma.KVStoreSelect | null + /** + * Omit specific fields from the KVStore + */ + omit?: Prisma.KVStoreOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.KVStoreInclude | null +} diff --git a/middleware/device.js b/middleware/device.js index 0c8b0a0..aecac58 100644 --- a/middleware/device.js +++ b/middleware/device.js @@ -6,25 +6,24 @@ * 2. deviceInfoMiddleware - 仅获取设备信息,不创建新设备 * 3. passwordMiddleware - 验证设备密码 */ - -import {prisma} from "../utils/prisma.js"; import errors from "../utils/errors.js"; import {verifyDevicePassword} from "../utils/crypto.js"; import {analyzeDevice} from "../utils/deviceDetector.js"; +import { prisma } from "../utils/prisma.js"; /** * 为新设备创建默认的自动登录配置 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID */ -async function createDefaultAutoAuth(deviceid) { +async function createDefaultAutoAuth(deviceId) { try { // 创建默认的自动授权配置:不需要密码、类型是classroom(一体机) await prisma.autoAuth.create({ data: { - deviceid: deviceid, + deviceId: deviceId, password: null, // 无密码 - devicetype: "classroom", // 一体机类型 - isreadonly: false, // 非只读 + deviceType: "classroom", // 一体机类型 + isReadOnly: false, // 非只读 }, }); } catch (error) { @@ -59,7 +58,7 @@ export const deviceMiddleware = errors.catchAsync(async (req, res, next) => { if (!device) { // 设备不存在,自动创建并生成智能设备名称 const userAgent = req.headers['user-agent']; - const customDeviceType = req.body.devicetype || req.query.devicetype; + const customDeviceType = req.body.deviceType || req.query.deviceType; const note = req.body.note || req.query.note; // 生成设备名称,确保不为空 @@ -70,7 +69,7 @@ export const deviceMiddleware = errors.catchAsync(async (req, res, next) => { uuid: deviceUuid, name: deviceName, password: null, - passwordhint: null, + passwordHint: null, accountId: null, }, }); diff --git a/middleware/jwt-auth.js b/middleware/jwt-auth.js index b4c2620..4f959d4 100644 --- a/middleware/jwt-auth.js +++ b/middleware/jwt-auth.js @@ -8,8 +8,8 @@ import {generateAccessToken, validateAccountToken, verifyAccessToken} from "../utils/tokenManager.js"; import {verifyToken} from "../utils/jwt.js"; -import {prisma} from "../utils/prisma.js"; import errors from "../utils/errors.js"; +import { prisma } from "../utils/prisma.js"; /** * 新的JWT认证中间件(支持refresh token系统) diff --git a/middleware/kvTokenAuth.js b/middleware/kvTokenAuth.js index 448d080..4f62328 100644 --- a/middleware/kvTokenAuth.js +++ b/middleware/kvTokenAuth.js @@ -4,9 +4,8 @@ * 仅验证app token,设置设备和应用信息到res.locals * 适用于所有KV相关的接口 */ - -import {prisma} from "../utils/prisma.js"; import errors from "../utils/errors.js"; +import { prisma } from "../utils/prisma.js"; /** * KV Token认证中间件 @@ -22,7 +21,7 @@ export const kvTokenAuth = async (req, res, next) => { } // 查找token对应的应用安装信息 - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: {token}, include: { device: true, @@ -36,7 +35,7 @@ export const kvTokenAuth = async (req, res, next) => { // 将信息存储到res.locals供后续使用 res.locals.device = appInstall.device; res.locals.appInstall = appInstall; - res.locals.deviceid = appInstall.device.id; + res.locals.deviceId = appInstall.device.id; res.locals.token = token; next(); } catch (error) { diff --git a/middleware/uuidAuth.js b/middleware/uuidAuth.js index d34a712..3159487 100644 --- a/middleware/uuidAuth.js +++ b/middleware/uuidAuth.js @@ -5,11 +5,10 @@ * 2. 验证密码或账户JWT(二选一) * 3. 适用于需要设备上下文的接口 */ - -import {prisma} from "../utils/prisma.js"; import errors from "../utils/errors.js"; import {verifyToken as verifyAccountJWT} from "../utils/jwt.js"; import {verifyDevicePassword} from "../utils/crypto.js"; +import { prisma } from "../utils/prisma.js"; /** * UUID+密码/JWT混合认证中间件 @@ -33,7 +32,7 @@ export const uuidAuth = async (req, res, next) => { // 存储设备信息到locals res.locals.device = device; - res.locals.deviceid = device.id; + res.locals.deviceId = device.id; // 3. 验证密码或JWT(二选一) const password = extractPassword(req); @@ -104,7 +103,7 @@ export const extractDeviceInfo = async (req, res, next) => { throw errors.createError(404, "设备不存在"); } res.locals.device = device; - res.locals.deviceid = device.id; + res.locals.deviceId = device.id; next(); } diff --git a/package-lock.json b/package-lock.json index 603986b..6ac9231 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ClassworksKV", - "version": "1.3.12", + "version": "1.3.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ClassworksKV", - "version": "1.3.12", + "version": "1.3.9", "dependencies": { "@opentelemetry/auto-instrumentations-node": "^0.59.0", "@opentelemetry/exporter-trace-otlp-proto": "^0.205.0", diff --git a/package.json b/package.json index 31083c6..faa7447 100644 --- a/package.json +++ b/package.json @@ -32,12 +32,13 @@ "jsonwebtoken": "^9.0.2", "morgan": "~1.10.0", "node-device-detector": "^2.2.4", - "pg": "^8.18.0", "prom-client": "^15.1.3", + "pg": "^8.18.0", "socket.io": "^4.8.1", "uuid": "^11.1.0" }, "devDependencies": { + "dotenv": "^16.5.0", "prisma": "^7.3.0" } } diff --git a/prisma/migrations/0_init/migration.sql b/prisma/migrations/0_init/migration.sql index 4e105d9..c91f790 100644 --- a/prisma/migrations/0_init/migration.sql +++ b/prisma/migrations/0_init/migration.sql @@ -2,109 +2,109 @@ CREATE SCHEMA IF NOT EXISTS "public"; -- CreateTable -CREATE TABLE "account" ( +CREATE TABLE "Account" ( "id" VARCHAR(191) NOT NULL, "provider" VARCHAR(191) NOT NULL, - "providerid" VARCHAR(191) NOT NULL, + "providerId" VARCHAR(191) NOT NULL, "email" VARCHAR(191), "name" VARCHAR(191), - "avatarurl" VARCHAR(191), - "providerdata" JSON, - "accesstoken" TEXT, - "createdat" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedat" TIMESTAMPTZ(6) NOT NULL, - "refreshtoken" TEXT, - "refreshtokenexpiry" TIMESTAMPTZ(6), - "tokenversion" INTEGER NOT NULL DEFAULT 1, + "avatarUrl" VARCHAR(191), + "providerData" JSON, + "accessToken" TEXT, + "createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL, + "refreshToken" TEXT, + "refreshTokenExpiry" TIMESTAMPTZ(6), + "tokenVersion" INTEGER NOT NULL DEFAULT 1, - CONSTRAINT "idx_18048_primary" PRIMARY KEY ("id") + CONSTRAINT "idx_18303_PRIMARY" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "appinstall" ( +CREATE TABLE "AppInstall" ( "id" VARCHAR(191) NOT NULL, - "deviceid" INTEGER NOT NULL, - "appid" VARCHAR(191) NOT NULL, + "deviceId" INTEGER NOT NULL, + "appId" VARCHAR(191) NOT NULL, "token" VARCHAR(191) NOT NULL, "note" VARCHAR(191), - "installedat" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedat" TIMESTAMPTZ(6) NOT NULL, - "devicetype" VARCHAR(191), - "isreadonly" BOOLEAN NOT NULL DEFAULT false, + "installedAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL, + "deviceType" VARCHAR(191), + "isReadOnly" BOOLEAN NOT NULL DEFAULT false, - CONSTRAINT "idx_18055_primary" PRIMARY KEY ("id") + CONSTRAINT "idx_18310_PRIMARY" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "autoauth" ( +CREATE TABLE "AutoAuth" ( "id" VARCHAR(191) NOT NULL, - "deviceid" INTEGER NOT NULL, + "deviceId" INTEGER NOT NULL, "password" VARCHAR(191), - "devicetype" VARCHAR(191), - "isreadonly" BOOLEAN NOT NULL DEFAULT false, - "createdat" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedat" TIMESTAMPTZ(6) NOT NULL, + "deviceType" VARCHAR(191), + "isReadOnly" BOOLEAN NOT NULL DEFAULT false, + "createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL, - CONSTRAINT "idx_18062_primary" PRIMARY KEY ("id") + CONSTRAINT "idx_18317_PRIMARY" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "device" ( +CREATE TABLE "Device" ( "id" INTEGER NOT NULL, "uuid" VARCHAR(191) NOT NULL, "name" VARCHAR(191), - "accountid" VARCHAR(191), - "createdat" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedat" TIMESTAMPTZ(6) NOT NULL, + "accountId" VARCHAR(191), + "createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL, "password" VARCHAR(191), - "passwordhint" VARCHAR(191), + "passwordHint" VARCHAR(191), "namespace" VARCHAR(191), - CONSTRAINT "idx_18069_primary" PRIMARY KEY ("id") + CONSTRAINT "idx_18324_PRIMARY" PRIMARY KEY ("id") ); -- CreateTable -CREATE TABLE "kvstore" ( - "deviceid" INTEGER NOT NULL, +CREATE TABLE "KVStore" ( + "deviceId" INTEGER NOT NULL, "key" VARCHAR(191) NOT NULL, "value" JSON NOT NULL, - "creatorip" VARCHAR(191) DEFAULT '', - "createdat" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, - "updatedat" TIMESTAMPTZ(6) NOT NULL, + "creatorIp" VARCHAR(191) DEFAULT '', + "createdAt" TIMESTAMPTZ(6) NOT NULL DEFAULT CURRENT_TIMESTAMP, + "updatedAt" TIMESTAMPTZ(6) NOT NULL, - CONSTRAINT "idx_18075_primary" PRIMARY KEY ("deviceid","key") + CONSTRAINT "idx_18330_PRIMARY" PRIMARY KEY ("deviceId","key") ); -- CreateIndex -CREATE UNIQUE INDEX "idx_18048_account_provider_providerid_key" ON "account"("provider", "providerid"); +CREATE UNIQUE INDEX "idx_18303_Account_provider_providerId_key" ON "Account"("provider", "providerId"); -- CreateIndex -CREATE UNIQUE INDEX "idx_18055_appinstall_token_key" ON "appinstall"("token"); +CREATE UNIQUE INDEX "idx_18310_AppInstall_token_key" ON "AppInstall"("token"); -- CreateIndex -CREATE INDEX "idx_18055_appinstall_deviceid_fkey" ON "appinstall"("deviceid"); +CREATE INDEX "idx_18310_AppInstall_deviceId_fkey" ON "AppInstall"("deviceId"); -- CreateIndex -CREATE UNIQUE INDEX "idx_18062_autoauth_deviceid_password_key" ON "autoauth"("deviceid", "password"); +CREATE UNIQUE INDEX "idx_18317_AutoAuth_deviceId_password_key" ON "AutoAuth"("deviceId", "password"); -- CreateIndex -CREATE UNIQUE INDEX "idx_18069_device_uuid_key" ON "device"("uuid"); +CREATE UNIQUE INDEX "idx_18324_Device_uuid_key" ON "Device"("uuid"); -- CreateIndex -CREATE UNIQUE INDEX "idx_18069_device_namespace_key" ON "device"("namespace"); +CREATE UNIQUE INDEX "idx_18324_Device_namespace_key" ON "Device"("namespace"); -- CreateIndex -CREATE INDEX "idx_18069_device_accountid_fkey" ON "device"("accountid"); +CREATE INDEX "idx_18324_Device_accountId_fkey" ON "Device"("accountId"); -- AddForeignKey -ALTER TABLE "appinstall" ADD CONSTRAINT "appinstall_deviceid_fkey" FOREIGN KEY ("deviceid") REFERENCES "device"("id") ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE "AppInstall" ADD CONSTRAINT "AppInstall_deviceId_fkey" FOREIGN KEY ("deviceId") REFERENCES "Device"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "autoauth" ADD CONSTRAINT "autoauth_deviceid_fkey" FOREIGN KEY ("deviceid") REFERENCES "device"("id") ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE "AutoAuth" ADD CONSTRAINT "AutoAuth_deviceId_fkey" FOREIGN KEY ("deviceId") REFERENCES "Device"("id") ON DELETE CASCADE ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "device" ADD CONSTRAINT "device_accountid_fkey" FOREIGN KEY ("accountid") REFERENCES "account"("id") ON DELETE SET NULL ON UPDATE CASCADE; +ALTER TABLE "Device" ADD CONSTRAINT "Device_accountId_fkey" FOREIGN KEY ("accountId") REFERENCES "Account"("id") ON DELETE SET NULL ON UPDATE CASCADE; -- AddForeignKey -ALTER TABLE "kvstore" ADD CONSTRAINT "kvstore_deviceid_fkey" FOREIGN KEY ("deviceid") REFERENCES "device"("id") ON DELETE CASCADE ON UPDATE CASCADE; +ALTER TABLE "KVStore" ADD CONSTRAINT "KVStore_deviceId_fkey" FOREIGN KEY ("deviceId") REFERENCES "Device"("id") ON DELETE CASCADE ON UPDATE CASCADE; diff --git a/prisma/migrations/20260201105825_fix_timestamp_defaults/migration.sql b/prisma/migrations/20260201105825_fix_timestamp_defaults/migration.sql deleted file mode 100644 index 5058103..0000000 --- a/prisma/migrations/20260201105825_fix_timestamp_defaults/migration.sql +++ /dev/null @@ -1,19 +0,0 @@ --- AlterTable -ALTER TABLE "account" ALTER COLUMN "createdat" SET DEFAULT timezone('Asia/Shanghai', now()), -ALTER COLUMN "updatedat" SET DEFAULT timezone('Asia/Shanghai', now()); - --- AlterTable -ALTER TABLE "appinstall" ALTER COLUMN "installedat" SET DEFAULT timezone('Asia/Shanghai', now()), -ALTER COLUMN "updatedat" SET DEFAULT timezone('Asia/Shanghai', now()); - --- AlterTable -ALTER TABLE "autoauth" ALTER COLUMN "createdat" SET DEFAULT timezone('Asia/Shanghai', now()), -ALTER COLUMN "updatedat" SET DEFAULT timezone('Asia/Shanghai', now()); - --- AlterTable -ALTER TABLE "device" ALTER COLUMN "createdat" SET DEFAULT timezone('Asia/Shanghai', now()), -ALTER COLUMN "updatedat" SET DEFAULT timezone('Asia/Shanghai', now()); - --- AlterTable -ALTER TABLE "kvstore" ALTER COLUMN "createdat" SET DEFAULT timezone('Asia/Shanghai', now()), -ALTER COLUMN "updatedat" SET DEFAULT timezone('Asia/Shanghai', now()); diff --git a/prisma/migrations/20260201120205_fix_timestamp_defaults/migration.sql b/prisma/migrations/20260201120205_fix_timestamp_defaults/migration.sql new file mode 100644 index 0000000..6ab05e9 --- /dev/null +++ b/prisma/migrations/20260201120205_fix_timestamp_defaults/migration.sql @@ -0,0 +1,14 @@ +-- AlterTable +ALTER TABLE "Account" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP; + +-- AlterTable +ALTER TABLE "AppInstall" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP; + +-- AlterTable +ALTER TABLE "AutoAuth" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP; + +-- AlterTable +ALTER TABLE "Device" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP; + +-- AlterTable +ALTER TABLE "KVStore" ALTER COLUMN "updatedAt" SET DEFAULT CURRENT_TIMESTAMP; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 446dd97..3cec5ea 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -7,79 +7,84 @@ datasource db { provider = "postgresql" } -model account { - id String @id(map: "idx_18048_primary") @db.VarChar(191) +model Account { + id String @id(map: "idx_18303_PRIMARY") @db.VarChar(191) provider String @db.VarChar(191) - providerid String @db.VarChar(191) + providerId String @db.VarChar(191) email String? @db.VarChar(191) name String? @db.VarChar(191) - avatarurl String? @db.VarChar(191) - providerdata Json? @db.Json - accesstoken String? - createdat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @db.Timestamptz(6) - updatedat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @updatedAt @db.Timestamptz(6) - refreshtoken String? - refreshtokenexpiry DateTime? @db.Timestamptz(6) - tokenversion Int @default(1) - device device[] + avatarUrl String? @db.VarChar(191) + providerData Json? @db.Json + accessToken String? + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6) + refreshToken String? + refreshTokenExpiry DateTime? @db.Timestamptz(6) + tokenVersion Int @default(1) - @@unique([provider, providerid], map: "idx_18048_account_provider_providerid_key") + devices Device[] + + @@unique([provider, providerId], map: "idx_18303_Account_provider_providerId_key") } -model appinstall { - id String @id(map: "idx_18055_primary") @db.VarChar(191) - deviceid Int - appid String @db.VarChar(191) - token String @unique(map: "idx_18055_appinstall_token_key") @db.VarChar(191) +model AppInstall { + id String @id(map: "idx_18310_PRIMARY") @db.VarChar(191) + deviceId Int + appId String @db.VarChar(191) + token String @unique(map: "idx_18310_AppInstall_token_key") @db.VarChar(191) note String? @db.VarChar(191) - installedat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @db.Timestamptz(6) - updatedat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @updatedAt @db.Timestamptz(6) - devicetype String? @db.VarChar(191) - isreadonly Boolean @default(false) - device device @relation(fields: [deviceid], references: [id], onDelete: Cascade) + installedAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6) + deviceType String? @db.VarChar(191) + isReadOnly Boolean @default(false) - @@index([deviceid], map: "idx_18055_appinstall_deviceid_fkey") + device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade) + + @@index([deviceId], map: "idx_18310_AppInstall_deviceId_fkey") } -model autoauth { - id String @id(map: "idx_18062_primary") @db.VarChar(191) - deviceid Int +model AutoAuth { + id String @id(map: "idx_18317_PRIMARY") @db.VarChar(191) + deviceId Int password String? @db.VarChar(191) - devicetype String? @db.VarChar(191) - isreadonly Boolean @default(false) - createdat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @db.Timestamptz(6) - updatedat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @updatedAt @db.Timestamptz(6) - device device @relation(fields: [deviceid], references: [id], onDelete: Cascade) + deviceType String? @db.VarChar(191) + isReadOnly Boolean @default(false) + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6) - @@unique([deviceid, password], map: "idx_18062_autoauth_deviceid_password_key") + device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade) + + @@unique([deviceId, password], map: "idx_18317_AutoAuth_deviceId_password_key") } -model device { - id Int @id(map: "idx_18069_primary") - uuid String @unique(map: "idx_18069_device_uuid_key") @db.VarChar(191) +model Device { + id Int @id(map: "idx_18324_PRIMARY") + uuid String @unique(map: "idx_18324_Device_uuid_key") @db.VarChar(191) name String? @db.VarChar(191) - accountid String? @db.VarChar(191) - createdat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @db.Timestamptz(6) - updatedat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @updatedAt @db.Timestamptz(6) + accountId String? @db.VarChar(191) + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6) password String? @db.VarChar(191) - passwordhint String? @db.VarChar(191) - namespace String? @unique(map: "idx_18069_device_namespace_key") @db.VarChar(191) - appinstall appinstall[] - autoauth autoauth[] - account account? @relation(fields: [accountid], references: [id]) - kvstore kvstore[] + passwordHint String? @db.VarChar(191) + namespace String? @unique(map: "idx_18324_Device_namespace_key") @db.VarChar(191) - @@index([accountid], map: "idx_18069_device_accountid_fkey") + // 关联关系 + account Account? @relation(fields: [accountId], references: [id], onDelete: SetNull) + appInstalls AppInstall[] + kvStore KVStore[] // 设备相关的KV存储 + autoAuths AutoAuth[] // 自动授权配置 + @@index([accountId], map: "idx_18324_Device_accountId_fkey") } -model kvstore { - deviceid Int +model KVStore { + deviceId Int key String @db.VarChar(191) value Json @db.Json - creatorip String? @default("") @db.VarChar(191) - createdat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @db.Timestamptz(6) - updatedat DateTime @default(dbgenerated("timezone('Asia/Shanghai', now())")) @updatedAt @db.Timestamptz(6) - device device @relation(fields: [deviceid], references: [id], onDelete: Cascade) + creatorIp String? @default("") @db.VarChar(191) + createdAt DateTime @default(now()) @db.Timestamptz(6) + updatedAt DateTime @default(now()) @updatedAt @db.Timestamptz(6) - @@id([deviceid, key], map: "idx_18075_primary") + device Device @relation(fields: [deviceId], references: [id], onDelete: Cascade) + + @@id([deviceId, key], map: "idx_18330_PRIMARY") } diff --git a/routes/accounts.js b/routes/accounts.js index 679b669..ce3d8de 100644 --- a/routes/accounts.js +++ b/routes/accounts.js @@ -1,10 +1,10 @@ import {Router} from "express"; -import {prisma} from "../utils/prisma.js"; import crypto from "crypto"; import {generateState, getCallbackURL, oauthProviders} from "../config/oauth.js"; import {generateTokenPair, refreshAccessToken, revokeAllTokens, revokeRefreshToken} from "../utils/jwt.js"; import {jwtAuth} from "../middleware/jwt-auth.js"; import errors from "../utils/errors.js"; +import { prisma } from "../utils/prisma.js"; const router = Router(); @@ -232,10 +232,10 @@ router.get("/oauth/:provider/callback", async (req, res) => { // 2. 使用访问令牌获取用户信息 let userResponse; - // Casdoor 支持两种方式:Authorization Bearer 或 accesstoken 查询参数 + // Casdoor 支持两种方式:Authorization Bearer 或 accessToken 查询参数 if (provider === 'stcn') { const url = new URL(providerConfig.userInfoURL); - url.searchParams.set('accesstoken', tokenData.access_token); + url.searchParams.set('accessToken', tokenData.access_token); userResponse = await fetch(url, {headers: {"Accept": "application/json"}}); } else { userResponse = await fetch(providerConfig.userInfoURL, { @@ -256,14 +256,14 @@ router.get("/oauth/:provider/callback", async (req, res) => { providerId: String(userData.id), email: userData.email, name: userData.name || userData.login, - avatarurl: userData.avatar_url, + avatarUrl: userData.avatar_url, }; } else if (provider === "zerocat") { normalizedUser = { providerId: userData.openid, email: userData.email_verified ? userData.email : null, name: userData.nickname || userData.username, - avatarurl: userData.avatar, + avatarUrl: userData.avatar, }; } else if (provider === "hly") { // 厚浪云(Logto)标准OIDC用户信息 @@ -271,7 +271,7 @@ router.get("/oauth/:provider/callback", async (req, res) => { providerId: userData.sub, email: userData.email_verified ? userData.email : null, name: userData.name || userData.preferred_username || userData.nickname, - avatarurl: userData.picture, + avatarUrl: userData.picture, }; } else if (provider === "stcn") { // STCN(Casdoor)标准OIDC用户信息 @@ -279,7 +279,7 @@ router.get("/oauth/:provider/callback", async (req, res) => { providerId: userData.sub, email: userData.email_verified ? userData.email : userData.email || null, name: userData.name || userData.preferred_username || userData.nickname, - avatarurl: userData.picture, + avatarUrl: userData.picture, }; } else if (provider === "dlass") { // Dlass(Casdoor)标准OIDC用户信息 @@ -287,7 +287,7 @@ router.get("/oauth/:provider/callback", async (req, res) => { providerId: userData.sub, email: userData.email_verified ? userData.email : userData.email || null, name: userData.name || userData.preferred_username || userData.nickname, - avatarurl: userData.picture, + avatarUrl: userData.picture, }; } @@ -316,25 +316,25 @@ router.get("/oauth/:provider/callback", async (req, res) => { data: { email: normalizedUser.email || account.email, name: normalizedUser.name || account.name, - avatarurl: normalizedUser.avatarurl || account.avatarurl, + avatarUrl: normalizedUser.avatarUrl || account.avatarUrl, providerData: userData, - //refreshtoken: tokenData.refresh_token || account.refreshtoken, - updatedat: new Date(), + //refreshToken: tokenData.refresh_token || account.refreshToken, + updatedAt: new Date(), }, }); } else { // 创建新账户 - const accesstoken = generateAccessToken(); + const accessToken = generateAccessToken(); account = await prisma.account.create({ data: { provider, providerId: normalizedUser.providerId, email: normalizedUser.email, name: normalizedUser.name, - avatarurl: normalizedUser.avatarurl, + avatarUrl: normalizedUser.avatarUrl, providerData: userData, - accesstoken, - //refreshtoken: tokenData.refresh_token, + accessToken, + //refreshToken: tokenData.refresh_token, }, }); } @@ -345,9 +345,9 @@ router.get("/oauth/:provider/callback", async (req, res) => { // 6. 重定向到前端根路径,携带JWT token const frontendBaseUrl = process.env.FRONTEND_URL || "http://localhost:5173"; const callbackUrl = new URL(frontendBaseUrl); - callbackUrl.searchParams.append("access_token", tokens.accesstoken); - callbackUrl.searchParams.append("refresh_token", tokens.refreshtoken); - callbackUrl.searchParams.append("expires_in", tokens.accesstokenExpiresIn); + callbackUrl.searchParams.append("access_token", tokens.accessToken); + callbackUrl.searchParams.append("refresh_token", tokens.refreshToken); + callbackUrl.searchParams.append("expires_in", tokens.accessTokenExpiresIn); callbackUrl.searchParams.append("provider", provider); // 附带展示信息,便于前端显示品牌与名称 const pconf = oauthProviders[provider] || {}; @@ -392,7 +392,7 @@ router.get("/profile", jwtAuth, async (req, res, next) => { id: true, uuid: true, name: true, - createdat: true, + createdAt: true, }, }, }, @@ -421,9 +421,9 @@ router.get("/profile", jwtAuth, async (req, res, next) => { providerInfo, email: account.email, name: account.name, - avatarurl: account.avatarurl, + avatarUrl: account.avatarUrl, devices: account.devices, - createdat: account.createdat, + createdAt: account.createdAt, }, }); } catch (error) { @@ -487,7 +487,7 @@ router.post("/devices/bind", jwtAuth, async (req, res, next) => { success: true, message: "设备绑定成功", data: { - deviceid: updatedDevice.id, + deviceId: updatedDevice.id, uuid: updatedDevice.uuid, name: updatedDevice.name, }, @@ -592,8 +592,8 @@ router.get("/devices", jwtAuth, async (req, res, next) => { uuid: true, name: true, namespace: true, - createdat: true, - updatedat: true, + createdAt: true, + updatedAt: true, }, }, }, @@ -627,8 +627,8 @@ router.get("/device/:uuid/account", async (req, res, next) => { id: true, provider: true, name: true, - avatarurl: true, - createdat: true, + avatarUrl: true, + createdAt: true, }, }, }, @@ -654,8 +654,8 @@ router.get("/device/:uuid/account", async (req, res, next) => { id: device.account.id, provider: device.account.provider, name: device.account.name, - avatarurl: device.account.avatarurl, - bindTime: device.updatedat, // 绑定时间 + avatarUrl: device.account.avatarUrl, + bindTime: device.updatedAt, // 绑定时间 }, }); } catch (error) { @@ -690,8 +690,8 @@ router.post("/refresh", async (req, res, next) => { success: true, message: "令牌刷新成功", data: { - access_token: result.accesstoken, - expires_in: result.accesstokenExpiresIn, + access_token: result.accessToken, + expires_in: result.accessTokenExpiresIn, account: result.account, }, }); @@ -780,14 +780,14 @@ router.get("/token-info", jwtAuth, async (req, res, next) => { data: { accountId: account.id, tokenType: decoded.type || 'legacy', - tokenversion: decoded.tokenversion || account.tokenversion, + tokenVersion: decoded.tokenVersion || account.tokenVersion, issuedAt: new Date(decoded.iat * 1000), expiresAt: new Date(decoded.exp * 1000), expiresIn: expiresIn, isExpired: expiresIn <= 0, isLegacyToken: res.locals.isLegacyToken || false, - hasRefreshToken: !!account.refreshtoken, - refreshtokenExpiry: account.refreshtokenExpiry, + hasRefreshToken: !!account.refreshToken, + refreshTokenExpiry: account.refreshTokenExpiry, }, }); } catch (error) { diff --git a/routes/apps.js b/routes/apps.js index d70b1c6..1a93d0d 100644 --- a/routes/apps.js +++ b/routes/apps.js @@ -1,9 +1,9 @@ import {Router} from "express"; import {uuidAuth} from "../middleware/uuidAuth.js"; -import {prisma} from "../utils/prisma.js"; import crypto from "crypto"; import errors from "../utils/errors.js"; import {verifyDevicePassword} from "../utils/crypto.js"; +import { prisma } from "../utils/prisma.js"; const router = Router(); @@ -25,15 +25,15 @@ router.get( return next(errors.createError(404, "设备不存在")); } - const installations = await prisma.appinstall.findMany({ - where: {deviceid: device.id}, + const installations = await prisma.appInstall.findMany({ + where: {deviceId: device.id}, }); const apps = installations.map(install => ({ appId: install.appId, token: install.token, note: install.note, - installedAt: install.createdat, + installedAt: install.createdAt, })); return res.json({ @@ -60,9 +60,9 @@ router.post( const token = crypto.randomBytes(32).toString("hex"); // 创建安装记录 - const installation = await prisma.appinstall.create({ + const installation = await prisma.appInstall.create({ data: { - deviceid: device.id, + deviceId: device.id, appId: appId, token, note: note || null, @@ -75,7 +75,7 @@ router.post( token: installation.token, note: installation.note, name: installation.note, // 备注同时作为名称返回 - installedAt: installation.createdat, + installedAt: installation.createdAt, }); }) ); @@ -91,7 +91,7 @@ router.delete( const device = res.locals.device; const {installId} = req.params; - const installation = await prisma.appinstall.findUnique({ + const installation = await prisma.appInstall.findUnique({ where: {id: installId}, }); @@ -100,11 +100,11 @@ router.delete( } // 确保安装记录属于当前设备 - if (installation.deviceid !== device.id) { + if (installation.deviceId !== device.id) { return next(errors.createError(403, "无权操作此安装记录")); } - await prisma.appinstall.delete({ + await prisma.appInstall.delete({ where: {id: installation.id}, }); @@ -135,8 +135,8 @@ router.get( } // 获取该设备的所有应用安装记录(即token) - const installations = await prisma.appinstall.findMany({ - where: {deviceid: device.id}, + const installations = await prisma.appInstall.findMany({ + where: {deviceId: device.id}, orderBy: {installedAt: 'desc'}, }); @@ -179,7 +179,7 @@ router.post( const device = await prisma.device.findUnique({ where: {namespace}, include: { - autoauths: true, + autoAuths: true, }, }); @@ -193,11 +193,11 @@ router.post( // 如果提供了密码,查找匹配密码的自动授权 if (password) { // 首先尝试直接匹配明文密码 - matchedAutoAuth = device.autoauths.find(auth => auth.password === password); + matchedAutoAuth = device.autoAuths.find(auth => auth.password === password); // 如果没有匹配到,尝试验证哈希密码(向后兼容) if (!matchedAutoAuth) { - for (const autoAuth of device.autoauths) { + for (const autoAuth of device.autoAuths) { if (autoAuth.password && autoAuth.password.startsWith('$2')) { // bcrypt 哈希以 $2 开头 try { if (await verifyDevicePassword(password, autoAuth.password)) { @@ -225,7 +225,7 @@ router.post( } } else { // 如果没有提供密码,查找密码为空的自动授权 - matchedAutoAuth = device.autoauths.find(auth => !auth.password); + matchedAutoAuth = device.autoAuths.find(auth => !auth.password); if (!matchedAutoAuth) { return next(errors.createError(401, "需要提供密码")); @@ -235,22 +235,22 @@ router.post( // 根据自动授权配置创建 AppInstall const token = crypto.randomBytes(32).toString("hex"); - const installation = await prisma.appinstall.create({ + const installation = await prisma.appInstall.create({ data: { - deviceid: device.id, + deviceId: device.id, appId: appId, token, note: null, - isreadonly: matchedAutoAuth.isreadonly, - devicetype: matchedAutoAuth.devicetype, + isReadOnly: matchedAutoAuth.isReadOnly, + deviceType: matchedAutoAuth.deviceType, }, }); return res.status(201).json({ success: true, token: installation.token, - devicetype: installation.devicetype, - isreadonly: installation.isreadonly, + deviceType: installation.deviceType, + isReadOnly: installation.isReadOnly, installedAt: installation.installedAt, }); }) @@ -272,7 +272,7 @@ router.post( } // 查找 token 对应的应用安装记录 - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: {token}, include: { device: true, @@ -284,15 +284,15 @@ router.post( } // 验证 token 类型是否为 student - if (!['student', 'parent'].includes(appInstall.devicetype)) { + if (!['student', 'parent'].includes(appInstall.deviceType)) { return next(errors.createError(403, "只有学生和家长类型的 token 可以设置名称")); } // 读取设备的 classworks-list-main 键值 - const kvRecord = await prisma.kvstore.findUnique({ + const kvRecord = await prisma.kVStore.findUnique({ where: { - deviceid_key: { - deviceid: appInstall.deviceid, + deviceId_key: { + deviceId: appInstall.deviceId, key: 'classworks-list-main', }, }, @@ -321,17 +321,17 @@ router.post( } // 更新 AppInstall 的 note 字段 - const updatedInstall = await prisma.appinstall.update({ + const updatedInstall = await prisma.appInstall.update({ where: {id: appInstall.id}, - data: {note: appInstall.devicetype === 'parent' ? `${name} 家长` : name}, + data: {note: appInstall.deviceType === 'parent' ? `${name} 家长` : name}, }); return res.json({ success: true, token: updatedInstall.token, name: updatedInstall.note, - devicetype: updatedInstall.devicetype, - updatedat: updatedInstall.updatedat, + deviceType: updatedInstall.deviceType, + updatedAt: updatedInstall.updatedAt, }); }) ); @@ -352,7 +352,7 @@ router.post( } // 查找 token 对应的应用安装记录 - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: {token}, include: { device: true, @@ -364,12 +364,12 @@ router.post( } // 验证 token 类型是否为 teacher - if (appInstall.devicetype !== 'teacher') { + if (appInstall.deviceType !== 'teacher') { return next(errors.createError(403, "只有教师类型的 token 可以使用此接口")); } // 更新 AppInstall 的 note 字段为教师名称 - const updatedInstall = await prisma.appinstall.update({ + const updatedInstall = await prisma.appInstall.update({ where: {id: appInstall.id}, data: {note: name}, }); @@ -378,8 +378,8 @@ router.post( success: true, token: updatedInstall.token, name: updatedInstall.note, - devicetype: updatedInstall.devicetype, - updatedat: updatedInstall.updatedat, + deviceType: updatedInstall.deviceType, + updatedAt: updatedInstall.updatedAt, }); }) ); @@ -396,7 +396,7 @@ router.put( const {note} = req.body; // 查找 token 对应的应用安装记录 - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: {token}, }); @@ -405,7 +405,7 @@ router.put( } // 更新 AppInstall 的 note 字段 - const updatedInstall = await prisma.appinstall.update({ + const updatedInstall = await prisma.appInstall.update({ where: {id: appInstall.id}, data: {note: note || null}, }); @@ -414,7 +414,7 @@ router.put( success: true, token: updatedInstall.token, note: updatedInstall.note, - updatedat: updatedInstall.updatedat, + updatedAt: updatedInstall.updatedAt, }); }) ); diff --git a/routes/auto-auth.js b/routes/auto-auth.js index a1d2963..3f0566d 100644 --- a/routes/auto-auth.js +++ b/routes/auto-auth.js @@ -1,7 +1,7 @@ import {Router} from "express"; import {jwtAuth} from "../middleware/jwt-auth.js"; -import {prisma} from "../utils/prisma.js"; import errors from "../utils/errors.js"; +import { prisma } from "../utils/prisma.js"; const router = Router(); @@ -30,13 +30,13 @@ router.get( return next(errors.createError(403, "该设备未绑定到您的账户")); } - const autoauths = await prisma.autoAuth.findMany({ - where: {deviceid: device.id}, - orderBy: {createdat: 'desc'}, + const autoAuths = await prisma.autoAuth.findMany({ + where: {deviceId: device.id}, + orderBy: {createdAt: 'desc'}, }); // 返回配置,智能处理密码显示 - const configs = autoauths.map(auth => { + const configs = autoAuths.map(auth => { // 检查是否是 bcrypt 哈希密码 const isHashedPassword = auth.password && auth.password.startsWith('$2'); @@ -44,10 +44,10 @@ router.get( id: auth.id, password: isHashedPassword ? null : auth.password, // 哈希密码不返回 isLegacyHash: isHashedPassword, // 标记是否为旧的哈希密码 - devicetype: auth.devicetype, - isreadonly: auth.isreadonly, - createdat: auth.createdat, - updatedat: auth.updatedat, + deviceType: auth.deviceType, + isReadOnly: auth.isReadOnly, + createdAt: auth.createdAt, + updatedAt: auth.updatedAt, }; }); @@ -61,7 +61,7 @@ router.get( /** * POST /auto-auth/devices/:uuid/auth-configs * 创建新的自动授权配置 (需要 JWT 认证,且设备必须绑定到该账户) - * Body: { password?: string, devicetype?: string, isreadonly?: boolean } + * Body: { password?: string, deviceType?: string, isReadOnly?: boolean } */ router.post( "/devices/:uuid/auth-configs", @@ -69,7 +69,7 @@ router.post( errors.catchAsync(async (req, res, next) => { const {uuid} = req.params; const account = res.locals.account; - const {password, devicetype, isreadonly} = req.body; + const {password, deviceType, isReadOnly} = req.body; // 查找设备并验证是否属于当前账户 const device = await prisma.device.findUnique({ @@ -85,9 +85,9 @@ router.post( return next(errors.createError(403, "该设备未绑定到您的账户")); } - // 验证 devicetype 如果提供的话 + // 验证 deviceType 如果提供的话 const validDeviceTypes = ['teacher', 'student', 'classroom', 'parent']; - if (devicetype && !validDeviceTypes.includes(devicetype)) { + if (deviceType && !validDeviceTypes.includes(deviceType)) { return next(errors.createError(400, `设备类型必须是以下之一: ${validDeviceTypes.join(', ')}`)); } @@ -96,7 +96,7 @@ router.post( // 查询该设备的所有自动授权配置,本地检查是否存在相同密码 const allAuths = await prisma.autoAuth.findMany({ - where: {deviceid: device.id}, + where: {deviceId: device.id}, }); const existingAuth = allAuths.find(auth => auth.password === plainPassword); @@ -108,10 +108,10 @@ router.post( // 创建新的自动授权配置(密码明文存储) const autoAuth = await prisma.autoAuth.create({ data: { - deviceid: device.id, + deviceId: device.id, password: plainPassword, - devicetype: devicetype || null, - isreadonly: isreadonly || false, + deviceType: deviceType || null, + isReadOnly: isReadOnly || false, }, }); @@ -120,9 +120,9 @@ router.post( config: { id: autoAuth.id, password: autoAuth.password, // 返回明文密码 - devicetype: autoAuth.devicetype, - isreadonly: autoAuth.isreadonly, - createdat: autoAuth.createdat, + deviceType: autoAuth.deviceType, + isReadOnly: autoAuth.isReadOnly, + createdAt: autoAuth.createdAt, }, }); }) @@ -130,7 +130,7 @@ router.post( /** * PUT /auto-auth/devices/:uuid/auth-configs/:configId * 更新自动授权配置 (需要 JWT 认证,且设备必须绑定到该账户) - * Body: { password?: string, devicetype?: string, isreadonly?: boolean } + * Body: { password?: string, deviceType?: string, isReadOnly?: boolean } */ router.put( "/devices/:uuid/auth-configs/:configId", @@ -138,7 +138,7 @@ router.put( errors.catchAsync(async (req, res, next) => { const {uuid, configId} = req.params; const account = res.locals.account; - const {password, devicetype, isreadonly} = req.body; + const {password, deviceType, isReadOnly} = req.body; // 查找设备并验证是否属于当前账户 const device = await prisma.device.findUnique({ @@ -164,13 +164,13 @@ router.put( } // 确保配置属于当前设备 - if (autoAuth.deviceid !== device.id) { + if (autoAuth.deviceId !== device.id) { return next(errors.createError(403, "无权操作此配置")); } - // 验证 devicetype + // 验证 deviceType const validDeviceTypes = ['teacher', 'student', 'classroom', 'parent']; - if (devicetype && !validDeviceTypes.includes(devicetype)) { + if (deviceType && !validDeviceTypes.includes(deviceType)) { return next(errors.createError(400, `设备类型必须是以下之一: ${validDeviceTypes.join(', ')}`)); } @@ -183,7 +183,7 @@ router.put( // 查询该设备的所有配置,本地检查新密码是否与其他配置冲突 const allAuths = await prisma.autoAuth.findMany({ - where: {deviceid: device.id}, + where: {deviceId: device.id}, }); const conflictAuth = allAuths.find(auth => @@ -197,12 +197,12 @@ router.put( updateData.password = plainPassword; } - if (devicetype !== undefined) { - updateData.devicetype = devicetype || null; + if (deviceType !== undefined) { + updateData.deviceType = deviceType || null; } - if (isreadonly !== undefined) { - updateData.isreadonly = isreadonly; + if (isReadOnly !== undefined) { + updateData.isReadOnly = isReadOnly; } // 更新配置 @@ -216,9 +216,9 @@ router.put( config: { id: updatedAuth.id, password: updatedAuth.password, // 返回明文密码 - devicetype: updatedAuth.devicetype, - isreadonly: updatedAuth.isreadonly, - updatedat: updatedAuth.updatedat, + deviceType: updatedAuth.deviceType, + isReadOnly: updatedAuth.isReadOnly, + updatedAt: updatedAuth.updatedAt, }, }); }) @@ -259,7 +259,7 @@ router.delete( } // 确保配置属于当前设备 - if (autoAuth.deviceid !== device.id) { + if (autoAuth.deviceId !== device.id) { return next(errors.createError(403, "无权操作此配置")); } @@ -334,7 +334,7 @@ router.put( uuid: updatedDevice.uuid, name: updatedDevice.name, namespace: updatedDevice.namespace, - updatedat: updatedDevice.updatedat, + updatedAt: updatedDevice.updatedAt, }, }); }) diff --git a/routes/device-auth.js b/routes/device-auth.js index f332151..35fda7c 100644 --- a/routes/device-auth.js +++ b/routes/device-auth.js @@ -1,7 +1,7 @@ import {Router} from "express"; import deviceCodeStore from "../utils/deviceCodeStore.js"; import errors from "../utils/errors.js"; -import {prisma} from "../utils/prisma.js"; +import { prisma } from "../utils/prisma.js"; const router = Router(); @@ -62,7 +62,7 @@ router.post( } // 验证token是否有效(检查数据库) - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: {token}, }); @@ -193,7 +193,7 @@ router.get( exists: true, has_token: status.hasToken, expires_in: Math.floor((status.expiresAt - Date.now()) / 1000), - created_at: status.createdat, + created_at: status.createdAt, }); }) ); diff --git a/routes/device.js b/routes/device.js index 64de961..2ebd4f6 100644 --- a/routes/device.js +++ b/routes/device.js @@ -1,25 +1,25 @@ import {Router} from "express"; import {extractDeviceInfo} from "../middleware/uuidAuth.js"; -import {prisma} from "../utils/prisma.js"; import errors from "../utils/errors.js"; import {getOnlineDevices} from "../utils/socket.js"; import {registeredDevicesTotal} from "../utils/metrics.js"; +import { prisma } from "../utils/prisma.js"; const router = Router(); /** * 为新设备创建默认的自动登录配置 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID */ -async function createDefaultAutoAuth(deviceid) { +async function createDefaultAutoAuth(deviceId) { try { // 创建默认的自动授权配置:不需要密码、类型是classroom(一体机) await prisma.autoAuth.create({ data: { - deviceid: deviceid, + deviceId: deviceId, password: null, // 无密码 - devicetype: "classroom", // 一体机类型 - isreadonly: false, // 非只读 + deviceType: "classroom", // 一体机类型 + isReadOnly: false, // 非只读 }, }); } catch (error) { @@ -90,7 +90,7 @@ router.post( uuid: device.uuid, name: device.name, namespace: device.namespace, - createdat: device.createdat, + createdAt: device.createdAt, }, }); } catch (error) { @@ -117,7 +117,7 @@ router.get( id: true, name: true, email: true, - avatarurl: true, + avatarUrl: true, }, }, }, @@ -132,13 +132,13 @@ router.get( uuid: device.uuid, name: device.name, hasPassword: !!device.password, - passwordhint: device.passwordhint, - createdat: device.createdat, + passwordHint: device.passwordHint, + createdAt: device.createdAt, account: device.account ? { id: device.account.id, name: device.account.name, email: device.account.email, - avatarurl: device.account.avatarurl, + avatarUrl: device.account.avatarUrl, } : null, isBoundToAccount: !!device.account, namespace: device.namespace, @@ -172,7 +172,7 @@ router.put( uuid: updatedDevice.uuid, name: updatedDevice.name, hasPassword: !!updatedDevice.password, - passwordhint: updatedDevice.passwordhint, + passwordHint: updatedDevice.passwordHint, }, }); }) diff --git a/routes/kv-token.js b/routes/kv-token.js index 2b5dce6..70c1d50 100644 --- a/routes/kv-token.js +++ b/routes/kv-token.js @@ -28,11 +28,11 @@ router.get( "/_info", tokenReadLimiter, errors.catchAsync(async (req, res, next) => { - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; // 获取设备信息,包含关联的账号 const device = await prisma.device.findUnique({ - where: { id: deviceid }, + where: { id: deviceId }, include: { account: true, }, @@ -47,8 +47,8 @@ router.get( device: { id: device.id, name: device.name, - createdat: device.createdat, - updatedat: device.updatedat, + createdAt: device.createdAt, + updatedAt: device.updatedAt, }, }; @@ -65,7 +65,7 @@ router.get( response.account = { id: device.account.id, name: device.account.name, - avatarurl: device.account.avatarurl, + avatarUrl: device.account.avatarUrl, }; } @@ -82,10 +82,10 @@ router.get( tokenReadLimiter, errors.catchAsync(async (req, res, next) => { const token = res.locals.token; - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; // 查找当前 token 对应的应用安装记录 - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: { token }, include: { device: { @@ -107,11 +107,11 @@ router.get( success: true, token: appInstall.token, appId: appInstall.appId, - devicetype: appInstall.devicetype, - isreadonly: appInstall.isreadonly, + deviceType: appInstall.deviceType, + isReadOnly: appInstall.isReadOnly, note: appInstall.note, installedAt: appInstall.installedAt, - updatedat: appInstall.updatedat, + updatedAt: appInstall.updatedAt, device: { id: appInstall.device.id, uuid: appInstall.device.uuid, @@ -130,7 +130,7 @@ router.get( "/_keys", tokenReadLimiter, errors.catchAsync(async (req, res) => { - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; const { sortBy, sortDir, limit, skip } = req.query; // 构建选项 @@ -141,7 +141,7 @@ router.get( skip: skip ? parseInt(skip) : 0, }; - const keys = await kvStore.listKeysOnly(deviceid, options); + const keys = await kvStore.listKeysOnly(deviceId, options); const totalRows = keys.length; // 构建响应对象 @@ -181,7 +181,7 @@ router.get( "/", tokenReadLimiter, errors.catchAsync(async (req, res) => { - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; const { sortBy, sortDir, limit, skip } = req.query; // 构建选项 @@ -192,8 +192,8 @@ router.get( skip: skip ? parseInt(skip) : 0, }; - const keys = await kvStore.list(deviceid, options); - const totalRows = await kvStore.count(deviceid); + const keys = await kvStore.list(deviceId, options); + const totalRows = await kvStore.count(deviceId); // 构建响应对象 const response = { @@ -227,10 +227,10 @@ router.get( "/:key", tokenReadLimiter, errors.catchAsync(async (req, res, next) => { - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; const { key } = req.params; - const value = await kvStore.get(deviceid, key); + const value = await kvStore.get(deviceId, key); if (value === null) { return next( @@ -250,10 +250,10 @@ router.get( "/:key/metadata", tokenReadLimiter, errors.catchAsync(async (req, res, next) => { - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; const { key } = req.params; - const metadata = await kvStore.getMetadata(deviceid, key); + const metadata = await kvStore.getMetadata(deviceId, key); if (!metadata) { return next( errors.createError(404, `未找到键名为 '${key}' 的记录`) @@ -272,11 +272,11 @@ router.post( tokenBatchLimiter, errors.catchAsync(async (req, res, next) => { // 检查token是否为只读 - if (res.locals.appInstall?.isreadonly) { + if (res.locals.appInstall?.isReadOnly) { return next(errors.createError(403, "当前token为只读模式,无法修改数据")); } - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; const data = req.body; if (!data || Object.keys(data).length === 0) { @@ -289,7 +289,7 @@ router.post( } // 获取客户端IP - const creatorip = + const creatorIp = req.headers["x-forwarded-for"] || req.connection.remoteAddress || req.socket.remoteAddress || @@ -297,13 +297,13 @@ router.post( ""; // 使用优化的批量upsert方法 - const { results, errors: errorList } = await kvStore.batchUpsert(deviceid, data, creatorip); + const { results, errors: errorList } = await kvStore.batchUpsert(deviceId, data, creatorIp); return res.status(200).json({ code: 200, message: "批量导入成功", data: { - deviceid, + deviceId, summary: { total: Object.keys(data).length, successful: results.length, @@ -328,11 +328,11 @@ router.post( tokenWriteLimiter, errors.catchAsync(async (req, res, next) => { // 检查token是否为只读 - if (res.locals.appInstall?.isreadonly) { + if (res.locals.appInstall?.isReadOnly) { return next(errors.createError(403, "当前token为只读模式,无法修改数据")); } - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; const { key } = req.params; let value = req.body; @@ -351,14 +351,14 @@ router.post( } // 获取客户端IP - const creatorip = + const creatorIp = req.headers["x-forwarded-for"] || req.connection.remoteAddress || req.socket.remoteAddress || req.connection.socket?.remoteAddress || ""; - const result = await kvStore.upsert(deviceid, key, value, creatorip); + const result = await kvStore.upsert(deviceId, key, value, creatorIp); // 广播单个键的变更 const uuid = res.locals.device?.uuid; @@ -366,16 +366,16 @@ router.post( broadcastKeyChanged(uuid, { key: result.key, action: "upsert", - created: result.createdat.getTime() === result.updatedat.getTime(), - updatedat: result.updatedat, + created: result.createdAt.getTime() === result.updatedAt.getTime(), + updatedAt: result.updatedAt, }); } return res.status(200).json({ - deviceid: result.deviceid, + deviceId: result.deviceId, key: result.key, - created: result.createdat.getTime() === result.updatedat.getTime(), - updatedat: result.updatedat, + created: result.createdAt.getTime() === result.updatedAt.getTime(), + updatedAt: result.updatedAt, }); }) ); @@ -389,14 +389,14 @@ router.delete( tokenDeleteLimiter, errors.catchAsync(async (req, res, next) => { // 检查token是否为只读 - if (res.locals.appInstall?.isreadonly) { + if (res.locals.appInstall?.isReadOnly) { return next(errors.createError(403, "当前token为只读模式,无法修改数据")); } - const deviceid = res.locals.deviceid; + const deviceId = res.locals.deviceId; const { key } = req.params; - const result = await kvStore.delete(deviceid, key); + const result = await kvStore.delete(deviceId, key); if (!result) { return next( diff --git a/utils/deviceCodeStore.js b/utils/deviceCodeStore.js index dd87fe1..5e5c173 100644 --- a/utils/deviceCodeStore.js +++ b/utils/deviceCodeStore.js @@ -7,7 +7,7 @@ class DeviceCodeStore { constructor() { - // 存储结构: { deviceCode: { token: string, expiresAt: number, createdat: number } } + // 存储结构: { deviceCode: { token: string, expiresAt: number, createdAt: number } } this.store = new Map(); // 默认过期时间: 15分钟 @@ -44,7 +44,7 @@ class DeviceCodeStore { this.store.set(deviceCode, { token: null, expiresAt: now + this.expirationTime, - createdat: now, + createdAt: now, }); return deviceCode; @@ -143,7 +143,7 @@ class DeviceCodeStore { return { hasToken: !!entry.token, expiresAt: entry.expiresAt, - createdat: entry.createdat, + createdAt: entry.createdAt, }; } diff --git a/utils/jwt.js b/utils/jwt.js index a671327..ed2da2e 100644 --- a/utils/jwt.js +++ b/utils/jwt.js @@ -61,7 +61,7 @@ export function generateAccountToken(account) { provider: account.provider, email: account.email, name: account.name, - avatarurl: account.avatarurl, + avatarUrl: account.avatarUrl, }); } diff --git a/utils/kvStore.js b/utils/kvStore.js index f9c594c..5e1e4bf 100644 --- a/utils/kvStore.js +++ b/utils/kvStore.js @@ -1,18 +1,18 @@ -import {prisma} from "./prisma.js"; import {keysTotal} from "./metrics.js"; +import { prisma } from "./prisma.js"; class KVStore { /** * 通过设备ID和键名获取值 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @param {string} key - 键名 * @returns {object|null} 键对应的值或null */ - async get(deviceid, key) { - const item = await prisma.kvstore.findUnique({ + async get(deviceId, key) { + const item = await prisma.kVStore.findUnique({ where: { - deviceid_key: { - deviceid: deviceid, + deviceId_key: { + deviceId: deviceId, key: key, }, }, @@ -22,24 +22,24 @@ class KVStore { /** * 获取键的完整信息(包括元数据) - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @param {string} key - 键名 * @returns {object|null} 键的完整信息或null */ - async getMetadata(deviceid, key) { - const item = await prisma.kvstore.findUnique({ + async getMetadata(deviceId, key) { + const item = await prisma.kVStore.findUnique({ where: { - deviceid_key: { - deviceid: deviceid, + deviceId_key: { + deviceId: deviceId, key: key, }, }, select: { key: true, - deviceid: true, - creatorip: true, - createdat: true, - updatedat: true, + deviceId: true, + creatorIp: true, + createdAt: true, + updatedAt: true, }, }); @@ -47,67 +47,67 @@ class KVStore { // 转换为更友好的格式 return { - deviceid: item.deviceid, + deviceId: item.deviceId, key: item.key, metadata: { - creatorip: item.creatorip, - createdat: item.createdat, - updatedat: item.updatedat, + creatorIp: item.creatorIp, + createdAt: item.createdAt, + updatedAt: item.updatedAt, }, }; } /** * 在指定设备下创建或更新键值 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @param {string} key - 键名 * @param {object} value - 键值 - * @param {string} creatorip - 创建者IP,可选 + * @param {string} creatorIp - 创建者IP,可选 * @returns {object} 创建或更新的记录 */ - async upsert(deviceid, key, value, creatorip = "") { - const item = await prisma.kvstore.upsert({ + async upsert(deviceId, key, value, creatorIp = "") { + const item = await prisma.kVStore.upsert({ where: { - deviceid_key: { - deviceid: deviceid, + deviceId_key: { + deviceId: deviceId, key: key, }, }, update: { value, - ...(creatorip && {creatorip}), + ...(creatorIp && {creatorIp}), }, create: { - deviceid: deviceid, + deviceId: deviceId, key: key, value, - creatorip: creatorip, + creatorIp, }, }); // 更新键总数指标 - const totalKeys = await prisma.kvstore.count(); + const totalKeys = await prisma.kVStore.count(); keysTotal.set(totalKeys); // 返回带有设备ID和原始键的结果 return { - deviceid, + deviceId, key, value: item.value, - creatorip: item.creatorip, - createdat: item.createdat, - updatedat: item.updatedat, + creatorIp: item.creatorIp, + createdAt: item.createdAt, + updatedAt: item.updatedAt, }; } /** * 批量创建或更新键值对(优化性能) - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @param {object} data - 键值对数据 {key1: value1, key2: value2, ...} - * @param {string} creatorip - 创建者IP,可选 + * @param {string} creatorIp - 创建者IP,可选 * @returns {object} {results: Array, errors: Array} */ - async batchUpsert(deviceid, data, creatorip = "") { + async batchUpsert(deviceId, data, creatorIp = "") { const results = []; const errors = []; @@ -115,30 +115,30 @@ class KVStore { await prisma.$transaction(async (tx) => { for (const [key, value] of Object.entries(data)) { try { - const item = await tx.kvstore.upsert({ + const item = await tx.kVStore.upsert({ where: { - deviceid_key: { - deviceid: deviceid, + deviceId_key: { + deviceId: deviceId, key: key, }, }, update: { value, - ...(creatorip && {creatorip: creatorip}), + ...(creatorIp && {creatorIp}), }, create: { - deviceid: deviceid, + deviceId: deviceId, key: key, value, - creatorip: creatorip, + creatorIp, }, }); results.push({ key: item.key, - created: item.createdat.getTime() === item.updatedat.getTime(), - createdat: item.createdat, - updatedat: item.updatedat, + created: item.createdAt.getTime() === item.updatedAt.getTime(), + createdAt: item.createdAt, + updatedAt: item.updatedAt, }); } catch (error) { errors.push({ @@ -150,7 +150,7 @@ class KVStore { }); // 在事务完成后,一次性更新指标 - const totalKeys = await prisma.kvstore.count(); + const totalKeys = await prisma.kVStore.count(); keysTotal.set(totalKeys); return { results, errors }; @@ -158,26 +158,26 @@ class KVStore { /** * 通过设备ID和键名删除 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @param {string} key - 键名 * @returns {object|null} 删除的记录或null */ - async delete(deviceid, key) { + async delete(deviceId, key) { try { - const item = await prisma.kvstore.delete({ + const item = await prisma.kVStore.delete({ where: { - deviceid_key: { - deviceid: deviceid, + deviceId_key: { + deviceId: deviceId, key: key, }, }, }); // 更新键总数指标 - const totalKeys = await prisma.kvstore.count(); + const totalKeys = await prisma.kVStore.count(); keysTotal.set(totalKeys); - return item ? {...item, deviceid, key} : null; + return item ? {...item, deviceId, key} : null; } catch (error) { // 忽略记录不存在的错误 if (error.code === "P2025") { @@ -189,11 +189,11 @@ class KVStore { /** * 列出指定设备下的所有键名及其元数据 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @param {object} options - 选项参数 * @returns {Array} 键名和元数据数组 */ - async list(deviceid, options = {}) { + async list(deviceId, options = {}) { const {sortBy = "key", sortDir = "asc", limit = 100, skip = 0} = options; // 构建排序条件 @@ -201,16 +201,16 @@ class KVStore { orderBy[sortBy] = sortDir.toLowerCase(); // 查询设备的所有键 - const items = await prisma.kvstore.findMany({ + const items = await prisma.kVStore.findMany({ where: { - deviceid: deviceid, + deviceId: deviceId, }, select: { - deviceid: true, + deviceId: true, key: true, - creatorip: true, - createdat: true, - updatedat: true, + creatorIp: true, + createdAt: true, + updatedAt: true, value: false, }, orderBy, @@ -220,23 +220,23 @@ class KVStore { // 处理结果 return items.map((item) => ({ - deviceid: item.deviceid, + deviceId: item.deviceId, key: item.key, metadata: { - creatorip: item.creatorip, - createdat: item.createdat, - updatedat: item.updatedat, + creatorIp: item.creatorIp, + createdAt: item.createdAt, + updatedAt: item.updatedAt, }, })); } /** * 获取指定设备下的键名列表(不包括内容) - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @param {object} options - 查询选项 * @returns {Array} 键名列表 */ - async listKeysOnly(deviceid, options = {}) { + async listKeysOnly(deviceId, options = {}) { const {sortBy = "key", sortDir = "asc", limit = 100, skip = 0} = options; // 构建排序条件 @@ -244,9 +244,9 @@ class KVStore { orderBy[sortBy] = sortDir.toLowerCase(); // 查询设备的所有键,只选择键名 - const items = await prisma.kvstore.findMany({ + const items = await prisma.kVStore.findMany({ where: { - deviceid: deviceid, + deviceId: deviceId, }, select: { key: true, @@ -262,13 +262,13 @@ class KVStore { /** * 统计指定设备下的键值对数量 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @returns {number} 键值对数量 */ - async count(deviceid) { - const count = await prisma.kvstore.count({ + async count(deviceId) { + const count = await prisma.kVStore.count({ where: { - deviceid: deviceid, + deviceId: deviceId, }, }); return count; @@ -276,32 +276,32 @@ class KVStore { /** * 获取指定设备的统计信息 - * @param {number} deviceid - 设备ID + * @param {number} deviceId - 设备ID * @returns {object} 统计信息 */ - async getStats(deviceid) { + async getStats(deviceId) { const [totalKeys, oldestKey, newestKey] = await Promise.all([ - prisma.kvstore.count({ - where: { deviceid }, + prisma.kVStore.count({ + where: { deviceId }, }), - prisma.kvstore.findFirst({ - where: { deviceid }, - orderBy: { createdat: "asc" }, - select: { createdat: true, key: true }, + prisma.kVStore.findFirst({ + where: { deviceId }, + orderBy: { createdAt: "asc" }, + select: { createdAt: true, key: true }, }), - prisma.kvstore.findFirst({ - where: { deviceid }, - orderBy: { updatedat: "desc" }, - select: { updatedat: true, key: true }, + prisma.kVStore.findFirst({ + where: { deviceId }, + orderBy: { updatedAt: "desc" }, + select: { updatedAt: true, key: true }, }), ]); return { totalKeys, oldestKey: oldestKey?.key, - oldestCreatedAt: oldestKey?.createdat, + oldestCreatedAt: oldestKey?.createdAt, newestKey: newestKey?.key, - newestUpdatedAt: newestKey?.updatedat, + newestUpdatedAt: newestKey?.updatedAt, }; } } diff --git a/utils/metrics.js b/utils/metrics.js index 416564d..ae2595e 100644 --- a/utils/metrics.js +++ b/utils/metrics.js @@ -33,9 +33,8 @@ export async function initializeMetrics() { registeredDevicesTotal.set(deviceCount); // 获取已创建键总数 - const keyCount = await prisma.kvstore.count(); + const keyCount = await prisma.kVStore.count(); keysTotal.set(keyCount); - console.log('Prometheus metrics initialized - Devices:', deviceCount, 'Keys:', keyCount); } catch (error) { console.error('Failed to initialize metrics:', error); diff --git a/utils/siteinfo.js b/utils/siteinfo.js index 3acf267..f480371 100644 --- a/utils/siteinfo.js +++ b/utils/siteinfo.js @@ -1,5 +1,5 @@ -import {prisma} from "./prisma.js"; import kvStore from "./kvStore.js"; +import { prisma } from "./prisma.js"; // 系统保留UUID用于存储站点信息 const SYSTEM_DEVICE_UUID = "00000000-0000-4000-8000-000000000000"; @@ -46,8 +46,8 @@ async function getSystemDeviceId() { */ export const initReadme = async () => { try { - const deviceid = await getSystemDeviceId(); - const storedValue = await kvStore.get(deviceid, "info"); + const deviceId = await getSystemDeviceId(); + const storedValue = await kvStore.get(deviceId, "info"); // 合并默认值与存储值,确保结构完整 readmeValue = { @@ -82,8 +82,8 @@ export const getReadmeValue = () => { */ export const updateReadmeValue = async (newValue) => { try { - const deviceid = await getSystemDeviceId(); - await kvStore.upsert(deviceid, "info", newValue); + const deviceId = await getSystemDeviceId(); + await kvStore.upsert(deviceId, "info", newValue); readmeValue = { ...defaultReadme, ...newValue, diff --git a/utils/socket.js b/utils/socket.js index b2161d5..e18fe6f 100644 --- a/utils/socket.js +++ b/utils/socket.js @@ -13,10 +13,10 @@ */ import { Server } from "socket.io"; -import { prisma } from "./prisma.js"; import { onlineDevicesGauge } from "./metrics.js"; import DeviceDetector from "node-device-detector"; import ClientHints from "node-device-detector/client-hints.js"; +import { prisma } from "./prisma.js"; // Socket.IO 单例实例 let io = null; @@ -33,7 +33,7 @@ const clientHints = new ClientHints(); const onlineMap = new Map(); // 在线 token 映射:token -> Set (用于指标统计) const onlineTokens = new Map(); -// 令牌信息缓存:token -> {appId, isreadonly, devicetype, note, deviceUuid, deviceName} +// 令牌信息缓存:token -> {appId, isReadOnly, deviceType, note, deviceUuid, deviceName} const tokenInfoCache = new Map(); // 事件历史记录:每个设备最多保存1000条事件记录 const eventHistory = new Map(); // uuid -> Array @@ -132,7 +132,7 @@ export function initSocket(server) { try { const token = payload?.token || payload?.apptoken; if (typeof token !== "string" || token.length === 0) return; - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: { token }, include: { device: { select: { uuid: true } } }, }); @@ -175,9 +175,9 @@ export function initSocket(server) { devices: historyData, timestamp: new Date().toISOString(), requestedBy: { - devicetype: socket.data.tokenInfo?.devicetype, + deviceType: socket.data.tokenInfo?.deviceType, deviceName: socket.data.tokenInfo?.deviceName, - isreadonly: socket.data.tokenInfo?.isreadonly + isReadOnly: socket.data.tokenInfo?.isReadOnly } }); @@ -219,7 +219,7 @@ export function initSocket(server) { // 检查只读权限 const tokenInfo = socket.data.tokenInfo; - if (tokenInfo?.isreadonly) { + if (tokenInfo?.isReadOnly) { socket.emit("event-error", { reason: "readonly_token_cannot_send_events" }); return; } @@ -243,9 +243,9 @@ export function initSocket(server) { senderId: socket.id, senderInfo: { appId: tokenInfo?.appId, - devicetype: tokenInfo?.devicetype, + deviceType: tokenInfo?.deviceType, deviceName: tokenInfo?.note, - isreadonly: tokenInfo?.isreadonly || false, + isReadOnly: tokenInfo?.isReadOnly || false, note: tokenInfo?.note } }; @@ -385,7 +385,7 @@ function removeTokenConnection(token, socketId) { /** * 广播某设备下 KV 键已变更 * @param {string} uuid 设备 uuid - * @param {object} payload { key, action: 'upsert'|'delete'|'batch', updatedat?, created? } + * @param {object} payload { key, action: 'upsert'|'delete'|'batch', updatedAt?, created? } */ export function broadcastKeyChanged(uuid, payload) { if (!io || !uuid) return; @@ -400,9 +400,9 @@ export function broadcastKeyChanged(uuid, payload) { senderId: "realtime", senderInfo: { appId: "5c2a54d553951a37b47066ead68c8642", - devicetype: "server", + deviceType: "server", deviceName: "realtime", - isreadonly: false, + isReadOnly: false, note: "Database realtime sync" } }; @@ -443,9 +443,9 @@ export function broadcastDeviceEvent(uuid, type, content = null, senderId = "sys senderId, senderInfo: { appId: "system", - devicetype: "system", + deviceType: "system", deviceName: "System", - isreadonly: false, + isReadOnly: false, note: "System broadcast" } }; @@ -549,7 +549,7 @@ export default { */ async function joinByToken(socket, token) { try { - const appInstall = await prisma.appinstall.findUnique({ + const appInstall = await prisma.appInstall.findUnique({ where: { token }, include: { device: { @@ -576,8 +576,8 @@ async function joinByToken(socket, token) { // 缓存令牌信息,使用拼接后的设备名称 const tokenInfo = { appId: appInstall.appId, - isreadonly: appInstall.isreadonly, - devicetype: appInstall.devicetype, + isReadOnly: appInstall.isReadOnly, + deviceType: appInstall.deviceType, note: appInstall.note, deviceUuid: uuid, deviceName: finalDeviceName, // 使用拼接后的设备名称 @@ -600,8 +600,8 @@ async function joinByToken(socket, token) { uuid, token, tokenInfo: { - isreadonly: tokenInfo.isreadonly, - devicetype: tokenInfo.devicetype, + isReadOnly: tokenInfo.isReadOnly, + deviceType: tokenInfo.deviceType, deviceName: tokenInfo.deviceName, userAgent: userAgent } diff --git a/utils/tokenManager.js b/utils/tokenManager.js index 12bcd45..c3e0d6c 100644 --- a/utils/tokenManager.js +++ b/utils/tokenManager.js @@ -1,6 +1,6 @@ import jwt from 'jsonwebtoken'; import crypto from 'crypto'; -import {prisma} from './prisma.js'; +import { prisma } from './prisma.js'; // Token 配置 const ACCESS_TOKEN_SECRET = process.env.JWT_SECRET || 'your-access-token-secret-change-this-in-production'; @@ -50,8 +50,8 @@ export function generateAccessToken(account) { provider: account.provider, email: account.email, name: account.name, - avatarurl: account.avatarurl, - tokenversion: account.tokenversion || 1, + avatarUrl: account.avatarUrl, + tokenVersion: account.tokenVersion || 1, }; return jwt.sign(payload, signKey, { @@ -71,7 +71,7 @@ export function generateRefreshToken(account) { const payload = { type: 'refresh', accountId: account.id, - tokenversion: account.tokenversion || 1, + tokenVersion: account.tokenVersion || 1, // 添加随机字符串增加安全性 jti: crypto.randomBytes(16).toString('hex'), }; @@ -134,39 +134,39 @@ export function verifyRefreshToken(token) { * 生成令牌对(访问令牌 + 刷新令牌) */ export async function generateTokenPair(account) { - const accesstoken = generateAccessToken(account); - const refreshtoken = generateRefreshToken(account); + const accessToken = generateAccessToken(account); + const refreshToken = generateRefreshToken(account); // 计算刷新令牌过期时间 - const refreshtokenExpiry = new Date(); + const refreshTokenExpiry = new Date(); const expiresInMs = parseExpirationToMs(REFRESH_TOKEN_EXPIRES_IN); - refreshtokenExpiry.setTime(refreshtokenExpiry.getTime() + expiresInMs); + refreshTokenExpiry.setTime(refreshTokenExpiry.getTime() + expiresInMs); // 更新数据库中的刷新令牌 await prisma.account.update({ where: {id: account.id}, data: { - refreshtoken, - refreshtokenExpiry, - updatedat: new Date(), + refreshToken, + refreshTokenExpiry, + updatedAt: new Date(), }, }); return { - accesstoken, - refreshtoken, - accesstokenExpiresIn: ACCESS_TOKEN_EXPIRES_IN, - refreshtokenExpiresIn: REFRESH_TOKEN_EXPIRES_IN, + accessToken, + refreshToken, + accessTokenExpiresIn: ACCESS_TOKEN_EXPIRES_IN, + refreshTokenExpiresIn: REFRESH_TOKEN_EXPIRES_IN, }; } /** * 刷新访问令牌 */ -export async function refreshAccessToken(refreshtoken) { +export async function refreshAccessToken(refreshToken) { try { // 验证刷新令牌 - const decoded = verifyRefreshToken(refreshtoken); + const decoded = verifyRefreshToken(refreshToken); // 从数据库获取账户信息 const account = await prisma.account.findUnique({ @@ -178,17 +178,17 @@ export async function refreshAccessToken(refreshtoken) { } // 验证刷新令牌是否匹配 - if (account.refreshtoken !== refreshtoken) { + if (account.refreshToken !== refreshToken) { throw new Error('Invalid refresh token'); } // 验证刷新令牌是否过期 - if (account.refreshtokenExpiry && account.refreshtokenExpiry < new Date()) { + if (account.refreshTokenExpiry && account.refreshTokenExpiry < new Date()) { throw new Error('Refresh token expired'); } // 验证令牌版本 - if (account.tokenversion !== decoded.tokenversion) { + if (account.tokenVersion !== decoded.tokenVersion) { throw new Error('Token version mismatch'); } @@ -196,14 +196,14 @@ export async function refreshAccessToken(refreshtoken) { const newAccessToken = generateAccessToken(account); return { - accesstoken: newAccessToken, - accesstokenExpiresIn: ACCESS_TOKEN_EXPIRES_IN, + accessToken: newAccessToken, + accessTokenExpiresIn: ACCESS_TOKEN_EXPIRES_IN, account: { id: account.id, provider: account.provider, email: account.email, name: account.name, - avatarurl: account.avatarurl, + avatarUrl: account.avatarUrl, }, }; } catch (error) { @@ -218,10 +218,10 @@ export async function revokeAllTokens(accountId) { await prisma.account.update({ where: {id: accountId}, data: { - tokenversion: {increment: 1}, - refreshtoken: null, - refreshtokenExpiry: null, - updatedat: new Date(), + tokenVersion: {increment: 1}, + refreshToken: null, + refreshTokenExpiry: null, + updatedAt: new Date(), }, }); } @@ -233,9 +233,9 @@ export async function revokeRefreshToken(accountId) { await prisma.account.update({ where: {id: accountId}, data: { - refreshtoken: null, - refreshtokenExpiry: null, - updatedat: new Date(), + refreshToken: null, + refreshTokenExpiry: null, + updatedAt: new Date(), }, }); } @@ -283,7 +283,7 @@ export async function validateAccountToken(decoded) { } // 验证令牌版本 - if (account.tokenversion !== decoded.tokenversion) { + if (account.tokenVersion !== decoded.tokenVersion) { throw new Error('Token version mismatch'); }