From cdae4d47a425788cfe340454032c4b38f97938dc Mon Sep 17 00:00:00 2001 From: Jackson Roberts Date: Sat, 14 Feb 2026 15:15:49 -0600 Subject: [PATCH] CREDENTIAL TYPE MANAGEMENT WORKS --- API_ROUTES.md | 981 ++++++++++ bun.lock | 5 + generated/prisma/browser.ts | 15 + generated/prisma/client.ts | 15 + generated/prisma/commonInputTypes.ts | 75 + generated/prisma/internal/class.ts | 34 +- generated/prisma/internal/prismaNamespace.ts | 301 ++- .../prisma/internal/prismaNamespaceBrowser.ts | 60 +- generated/prisma/models.ts | 3 + generated/prisma/models/Company.ts | 184 +- generated/prisma/models/Credential.ts | 1685 +++++++++++++++++ generated/prisma/models/CredentialType.ts | 1380 ++++++++++++++ generated/prisma/models/SecureValue.ts | 1410 ++++++++++++++ package.json | 1 + prisma/schema.prisma | 48 + src/api/credential-types/create.ts | 43 + src/api/credential-types/delete.ts | 23 + src/api/credential-types/fetch.ts | 25 + src/api/credential-types/fetchAll.ts | 25 + src/api/credential-types/fetchCredentials.ts | 26 + src/api/credential-types/index.ts | 15 + src/api/credential-types/update.ts | 46 + src/api/credentials/create.ts | 41 + src/api/credentials/delete.ts | 23 + src/api/credentials/fetch.ts | 23 + src/api/credentials/fetchByCompany.ts | 25 + src/api/credentials/fetchFields.ts | 26 + src/api/credentials/index.ts | 19 + src/api/credentials/readSecureValues.ts | 26 + src/api/credentials/update.ts | 33 + src/api/credentials/updateFields.ts | 41 + src/api/routers/credentialRouter.ts | 7 + src/api/routers/credentialTypeRouter.ts | 9 + src/api/server.ts | 2 + src/constants.ts | 20 +- src/controllers/CredentialController.ts | 322 ++++ src/controllers/CredentialTypeController.ts | 178 ++ src/managers/credentialTypes.ts | 111 ++ src/managers/credentials.ts | 158 ++ src/modules/credentials/credentialTypeDefs | 0 src/modules/credentials/credentialTypeDefs.ts | 18 + src/modules/credentials/fieldValidator.ts | 56 + .../credentials/generateSecureValue.ts | 24 + src/modules/credentials/readSecureValue.ts | 30 + src/modules/tools/Password.ts | 7 +- utils/genPrivateKeys.ts | 63 +- 46 files changed, 7621 insertions(+), 41 deletions(-) create mode 100644 API_ROUTES.md create mode 100644 generated/prisma/models/Credential.ts create mode 100644 generated/prisma/models/CredentialType.ts create mode 100644 generated/prisma/models/SecureValue.ts create mode 100644 src/api/credential-types/create.ts create mode 100644 src/api/credential-types/delete.ts create mode 100644 src/api/credential-types/fetch.ts create mode 100644 src/api/credential-types/fetchAll.ts create mode 100644 src/api/credential-types/fetchCredentials.ts create mode 100644 src/api/credential-types/index.ts create mode 100644 src/api/credential-types/update.ts create mode 100644 src/api/credentials/create.ts create mode 100644 src/api/credentials/delete.ts create mode 100644 src/api/credentials/fetch.ts create mode 100644 src/api/credentials/fetchByCompany.ts create mode 100644 src/api/credentials/fetchFields.ts create mode 100644 src/api/credentials/index.ts create mode 100644 src/api/credentials/readSecureValues.ts create mode 100644 src/api/credentials/update.ts create mode 100644 src/api/credentials/updateFields.ts create mode 100644 src/api/routers/credentialRouter.ts create mode 100644 src/api/routers/credentialTypeRouter.ts create mode 100644 src/controllers/CredentialController.ts create mode 100644 src/controllers/CredentialTypeController.ts create mode 100644 src/managers/credentialTypes.ts create mode 100644 src/managers/credentials.ts create mode 100644 src/modules/credentials/credentialTypeDefs create mode 100644 src/modules/credentials/credentialTypeDefs.ts create mode 100644 src/modules/credentials/fieldValidator.ts create mode 100644 src/modules/credentials/generateSecureValue.ts create mode 100644 src/modules/credentials/readSecureValue.ts diff --git a/API_ROUTES.md b/API_ROUTES.md new file mode 100644 index 0000000..ee8218c --- /dev/null +++ b/API_ROUTES.md @@ -0,0 +1,981 @@ +# TTSCM API Routes Documentation + +This document provides a comprehensive overview of all API routes available in the TTSCM API. + +## Base URL + +``` +http://localhost:3000/v1 +``` + +--- + +## Authentication Routes + +### Get Authentication URI + +**GET** `/auth/uri` + +Get the Microsoft OAuth authentication URI for user login. + +**Authentication Required:** No + +**Response:** + +```json +{ + "status": 200, + "message": "Successfully fetch Auth URI", + "data": { + "uri": "https://login.microsoftonline.com/...", + "callbackKey": "ck123..." + }, + "successful": true +} +``` + +--- + +### OAuth Redirect Handler + +**GET** `/auth/redirect` + +Handles the OAuth redirect callback from Microsoft. This endpoint processes the authorization code and creates a user session. + +**Authentication Required:** No + +**Query Parameters:** + +- `code` - Authorization code from Microsoft +- `state` - Callback key for WebSocket notification + +**Response:** +Closes the browser window and emits authentication tokens via WebSocket. + +--- + +### Refresh Access Token + +**POST** `/auth/refresh` + +Refresh an expired access token using a valid refresh token. + +**Authentication Required:** Yes (Refresh Token) + +**Headers:** + +- `x-refresh-token` - The refresh token + +**Response:** + +```json +{ + "status": 201, + "message": "Token refreshed successfully!", + "data": { + "accessToken": "eyJhbGc...", + "refreshToken": "eyJhbGc..." + }, + "successful": true +} +``` + +--- + +## User Routes + +### Get Current User + +**GET** `/user/@me` + +Fetch the currently authenticated user's information. + +**Authentication Required:** Yes + +**Required Scopes:** `user.read` + +**Response:** + +```json +{ + "status": 200, + "message": "Fetched user.", + "data": { + "id": "ckx...", + "name": "John Doe", + "email": "john.doe@example.com", + "login": "john.doe", + "image": "https://...", + "roles": ["admin"], + "createdAt": "2026-01-01T00:00:00.000Z", + "updatedAt": "2026-02-14T00:00:00.000Z" + }, + "successful": true +} +``` + +--- + +### Update Current User + +**PATCH** `/user/@me` + +Update the currently authenticated user's information. + +**Authentication Required:** Yes + +**Required Scopes:** `user.write` + +**Request Body:** + +```json +{ + "name": "Jane Doe", + "image": "https://example.com/avatar.jpg" +} +``` + +**Response:** + +```json +{ + "status": 200, + "message": "Successfully updated user.", + "data": { + "id": "ckx...", + "name": "Jane Doe", + "email": "jane.doe@example.com", + "image": "https://example.com/avatar.jpg" + }, + "successful": true +} +``` + +--- + +## Company Routes + +### Get All Companies + +**GET** `/company/companies` + +Fetch a paginated list of all companies with optional search functionality. + +**Authentication Required:** Yes + +**Required Permissions:** `company.fetch.many` + +**Query Parameters:** + +- `page` (optional) - Page number (default: 1) +- `rpp` (optional) - Records per page (default: 30) +- `search` (optional) - Search query to filter companies + +**Response:** + +```json +{ + "status": 200, + "message": "Companies Fetched Successfully!", + "data": [ + { + "id": "ckx...", + "name": "Acme Corp", + "cw_CompanyId": 12345, + "cw_Identifier": "AcmeCorp" + } + ], + "pagination": { + "previousPage": null, + "currentPage": 1, + "nextPage": 2, + "totalPages": 10, + "totalRecords": 300, + "listedRecords": 30 + }, + "successful": true +} +``` + +--- + +### Get Company by ID + +**GET** `/company/companies/:identifier` + +Fetch a single company by its ID. + +**Authentication Required:** Yes + +**Required Permissions:** `company.fetch` + +**URL Parameters:** + +- `identifier` - Company ID + +**Response:** + +```json +{ + "status": 200, + "message": "Company Fetched Successfully!", + "data": { + "id": "ckx...", + "name": "Acme Corp", + "cw_CompanyId": 12345, + "cw_Identifier": "AcmeCorp" + }, + "successful": true +} +``` + +--- + +### Get Company Configurations + +**GET** `/company/companies/:identifier/configurations` + +Fetch configurations for a specific company from ConnectWise. + +**Authentication Required:** Yes + +**Required Permissions:** `company.fetch`, `company.fetch.configurations` + +**URL Parameters:** + +- `identifier` - Company ID + +**Response:** + +```json +{ + "status": 200, + "message": "Company Configurations Fetched Successfully!", + "data": { + // ConnectWise configuration data + }, + "successful": true +} +``` + +--- + +## Credential Routes + +### Get Credential by ID + +**GET** `/credential/credentials/:id` + +Fetch a single credential by its ID. + +**Authentication Required:** Yes + +**Required Permissions:** `credential.fetch` + +**URL Parameters:** + +- `id` - Credential ID + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Fetched Successfully!", + "data": { + "id": "ckx...", + "name": "AWS Credentials", + "typeId": "cky...", + "companyId": "ckz...", + "fields": { + "accountId": "123456789" + }, + "type": { + "id": "cky...", + "name": "AWS", + "fields": [...], + "permissionScope": "aws.credentials" + }, + "company": { + "id": "ckz...", + "name": "Acme Corp" + }, + "createdAt": "2026-01-01T00:00:00.000Z", + "updatedAt": "2026-02-14T00:00:00.000Z" + }, + "successful": true +} +``` + +--- + +### Get Credentials by Company + +**GET** `/credential/credentials/company/:companyId` + +Fetch all credentials associated with a specific company. + +**Authentication Required:** Yes + +**Required Permissions:** `credential.fetch.many` + +**URL Parameters:** + +- `companyId` - Company ID + +**Response:** + +```json +{ + "status": 200, + "message": "Company Credentials Fetched Successfully!", + "data": [ + { + "id": "ckx...", + "name": "AWS Credentials", + "typeId": "cky...", + "companyId": "ckz...", + "fields": {...}, + "type": {...}, + "company": {...} + } + ], + "successful": true +} +``` + +--- + +### Create Credential + +**POST** `/credential/credentials` + +Create a new credential with validated and encrypted fields. + +**Authentication Required:** Yes + +**Required Permissions:** `credential.create` + +**Request Body:** + +```json +{ + "name": "Production AWS Credentials", + "typeId": "cky...", + "companyId": "ckz...", + "fields": [ + { + "id": "ckx1...", + "fieldId": "accessKeyId", + "value": "AKIAIOSFODNN7EXAMPLE" + }, + { + "id": "ckx2...", + "fieldId": "secretAccessKey", + "value": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" + } + ] +} +``` + +**Response:** + +```json +{ + "status": 201, + "message": "Credential Created Successfully!", + "data": { + "id": "ckx...", + "name": "Production AWS Credentials", + "typeId": "cky...", + "companyId": "ckz...", + "fields": {...} + }, + "successful": true +} +``` + +--- + +### Update Credential + +**PATCH** `/credential/credentials/:id` + +Update a credential's basic properties (name). + +**Authentication Required:** Yes + +**Required Permissions:** `credential.update` + +**URL Parameters:** + +- `id` - Credential ID + +**Request Body:** + +```json +{ + "name": "Updated Credential Name" +} +``` + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Updated Successfully!", + "data": { + "id": "ckx...", + "name": "Updated Credential Name", + ... + }, + "successful": true +} +``` + +--- + +### Update Credential Fields + +**PUT** `/credential/credentials/:id/fields` + +Validate and update credential field values. Secure fields are automatically encrypted. + +**Authentication Required:** Yes + +**Required Permissions:** `credential.update`, `credential.fields.update` + +**URL Parameters:** + +- `id` - Credential ID + +**Request Body:** + +```json +{ + "fields": [ + { + "id": "ckx1...", + "fieldId": "accessKeyId", + "value": "AKIAIOSFODNN7NEWVALUE" + }, + { + "id": "ckx2...", + "fieldId": "secretAccessKey", + "value": "newSecretKeyValue123" + } + ] +} +``` + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Fields Updated Successfully!", + "data": { + "id": "ckx...", + "name": "Production AWS Credentials", + "fields": {...} + }, + "successful": true +} +``` + +--- + +### Get Credential Fields + +**GET** `/credential/credentials/:id/fields` + +Fetch all field values for a credential (secure fields returned encrypted). + +**Authentication Required:** Yes + +**Required Permissions:** `credential.fetch`, `credential.fields.fetch` + +**URL Parameters:** + +- `id` - Credential ID + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Fields Fetched Successfully!", + "data": [ + { + "id": "ckx-accessKeyId", + "fieldId": "accessKeyId", + "value": "AKIAIOSFODNN7EXAMPLE" + }, + { + "id": "ckx1...", + "fieldId": "secretAccessKey", + "value": "base64EncryptedValue==" + } + ], + "successful": true +} +``` + +--- + +### Read Secure Values + +**GET** `/credential/credentials/:id/secure-values` + +Decrypt and return all secure field values for a credential. + +**Authentication Required:** Yes + +**Required Permissions:** `credential.fetch`, `credential.secure_values.read` + +**URL Parameters:** + +- `id` - Credential ID + +**Response:** + +```json +{ + "status": 200, + "message": "Secure Values Fetched Successfully!", + "data": { + "secretAccessKey": "wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY", + "apiKey": "sk_live_123456789abcdef" + }, + "successful": true +} +``` + +--- + +### Delete Credential + +**DELETE** `/credential/credentials/:id` + +Delete a credential and all associated secure values. + +**Authentication Required:** Yes + +**Required Permissions:** `credential.delete` + +**URL Parameters:** + +- `id` - Credential ID + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Deleted Successfully!", + "data": null, + "successful": true +} +``` + +--- + +## Credential Type Routes + +### Get Credential Type by ID or Name + +**GET** `/credential-type/credential-types/:identifier` + +Fetch a single credential type by its ID or name. + +**Authentication Required:** Yes + +**Required Permissions:** `credential_type.fetch` + +**URL Parameters:** + +- `identifier` - Credential Type ID or name + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Type Fetched Successfully!", + "data": { + "id": "cky...", + "name": "AWS", + "permissionScope": "aws.credentials", + "icon": "https://aws.amazon.com/favicon.ico", + "fields": [ + { + "id": "accessKeyId", + "name": "Access Key ID", + "required": true, + "secure": false, + "valueType": "plain_text" + }, + { + "id": "secretAccessKey", + "name": "Secret Access Key", + "required": true, + "secure": true, + "valueType": "password" + } + ], + "credentialCount": 5, + "createdAt": "2026-01-01T00:00:00.000Z", + "updatedAt": "2026-02-14T00:00:00.000Z" + }, + "successful": true +} +``` + +--- + +### Get All Credential Types + +**GET** `/credential-type/credential-types` + +Fetch all credential types in the system. + +**Authentication Required:** Yes + +**Required Permissions:** `credential_type.fetch.many` + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Types Fetched Successfully!", + "data": [ + { + "id": "cky...", + "name": "AWS", + "permissionScope": "aws.credentials", + "icon": "https://aws.amazon.com/favicon.ico", + "fields": [...], + "credentialCount": 5 + }, + { + "id": "ckz...", + "name": "Azure", + "permissionScope": "azure.credentials", + "icon": "https://azure.microsoft.com/favicon.ico", + "fields": [...], + "credentialCount": 3 + } + ], + "successful": true +} +``` + +--- + +### Create Credential Type + +**POST** `/credential-type/credential-types` + +Create a new credential type with field definitions. + +**Authentication Required:** Yes + +**Required Permissions:** `credential_type.create` + +**Request Body:** + +```json +{ + "name": "GitHub", + "permissionScope": "github.credentials", + "icon": "https://github.com/favicon.ico", + "fields": [ + { + "id": "username", + "name": "Username", + "required": true, + "secure": false, + "valueType": "plain_text" + }, + { + "id": "personalAccessToken", + "name": "Personal Access Token", + "required": true, + "secure": true, + "valueType": "password" + } + ] +} +``` + +**Response:** + +```json +{ + "status": 201, + "message": "Credential Type Created Successfully!", + "data": { + "id": "ck1...", + "name": "GitHub", + "permissionScope": "github.credentials", + "icon": "https://github.com/favicon.ico", + "fields": [...] + }, + "successful": true +} +``` + +--- + +### Update Credential Type + +**PATCH** `/credential-type/credential-types/:id` + +Update a credential type's properties or field definitions. + +**Authentication Required:** Yes + +**Required Permissions:** `credential_type.update` + +**URL Parameters:** + +- `id` - Credential Type ID + +**Request Body:** + +```json +{ + "name": "GitHub Enterprise", + "icon": "https://github.enterprise.com/favicon.ico", + "fields": [ + { + "id": "username", + "name": "Username", + "required": true, + "secure": false, + "valueType": "plain_text" + }, + { + "id": "personalAccessToken", + "name": "Personal Access Token", + "required": true, + "secure": true, + "valueType": "password" + }, + { + "id": "enterpriseUrl", + "name": "Enterprise URL", + "required": true, + "secure": false, + "valueType": "plain_text" + } + ] +} +``` + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Type Updated Successfully!", + "data": { + "id": "ck1...", + "name": "GitHub Enterprise", + "fields": [...] + }, + "successful": true +} +``` + +--- + +### Delete Credential Type + +**DELETE** `/credential-type/credential-types/:id` + +Delete a credential type. This will cascade delete all credentials of this type. + +**Authentication Required:** Yes + +**Required Permissions:** `credential_type.delete` + +**URL Parameters:** + +- `id` - Credential Type ID + +**Response:** + +```json +{ + "status": 200, + "message": "Credential Type Deleted Successfully!", + "data": null, + "successful": true +} +``` + +--- + +### Get Credentials by Type + +**GET** `/credential-type/credential-types/:id/credentials` + +Fetch all credentials that use a specific credential type. + +**Authentication Required:** Yes + +**Required Permissions:** `credential_type.fetch`, `credential.fetch.many` + +**URL Parameters:** + +- `id` - Credential Type ID + +**Response:** + +```json +{ + "status": 200, + "message": "Credentials Fetched Successfully!", + "data": [ + { + "id": "ckx...", + "name": "Production AWS", + "typeId": "cky...", + "companyId": "ckz...", + "fields": {...} + }, + { + "id": "ck2...", + "name": "Staging AWS", + "typeId": "cky...", + "companyId": "ckz...", + "fields": {...} + } + ], + "successful": true +} +``` + +--- + +## Utility Routes + +### Teapot + +**GET** `/teapot` + +A fun Easter egg endpoint that returns HTTP 418 (I'm a teapot). + +**Authentication Required:** No + +**Response:** + +```json +{ + "status": 418, + "message": "I'm a teapot", + "successful": false +} +``` + +--- + +## Error Responses + +All endpoints may return error responses in the following format: + +### 400 Bad Request + +```json +{ + "status": 400, + "message": "Validation error", + "errors": [ + { + "path": ["field"], + "message": "Field is required" + } + ], + "successful": false +} +``` + +### 401 Unauthorized + +```json +{ + "status": 401, + "message": "Unauthorized", + "successful": false +} +``` + +### 403 Forbidden + +```json +{ + "status": 403, + "message": "Insufficient permissions", + "successful": false +} +``` + +### 404 Not Found + +```json +{ + "status": 404, + "message": "Resource not found", + "successful": false +} +``` + +### 500 Internal Server Error + +```json +{ + "status": 500, + "message": "Internal server error", + "successful": false +} +``` + +--- + +## Authentication + +Most endpoints require authentication via an access token in the request headers: + +``` +Authorization: Bearer +``` + +Tokens are obtained through the Microsoft OAuth flow: + +1. Call `GET /auth/uri` to get the authentication URL +2. Redirect user to the Microsoft login page +3. User authenticates and is redirected to `/auth/redirect` +4. Access and refresh tokens are provided via WebSocket or response +5. Use the access token in subsequent API requests + +When the access token expires, use `POST /auth/refresh` with the refresh token to obtain a new access token. + +--- + +## Permission System + +The API uses a granular permission system. Each endpoint requires specific permissions that are checked via the `authMiddleware`. Permissions are granted through roles assigned to users. + +Common permission patterns: + +- `resource.fetch` - Read a single resource +- `resource.fetch.many` - Read multiple resources +- `resource.create` - Create a new resource +- `resource.update` - Update a resource +- `resource.delete` - Delete a resource +- `resource.field.action` - Perform specific field operations + +Users can have multiple roles, and permissions are accumulated from all assigned roles. diff --git a/bun.lock b/bun.lock index b57b2f7..092cebb 100644 --- a/bun.lock +++ b/bun.lock @@ -12,6 +12,7 @@ "@prisma/client": "^7.3.0", "@socket.io/bun-engine": "^0.1.0", "axios": "^1.13.3", + "blakets": "^0.1.12", "cors": "^2.8.6", "cuid": "^3.0.0", "hono": "^4.11.5", @@ -84,6 +85,8 @@ "@prisma/studio-core": ["@prisma/studio-core@0.13.1", "", { "peerDependencies": { "@types/react": "^18.0.0 || ^19.0.0", "react": "^18.0.0 || ^19.0.0", "react-dom": "^18.0.0 || ^19.0.0" } }, "sha512-agdqaPEePRHcQ7CexEfkX1RvSH9uWDb6pXrZnhCRykhDFAV0/0P3d07WtfiY8hZWb7oRU4v+NkT4cGFHkQJIPg=="], + "@prokopschield/argv": ["@prokopschield/argv@0.1.3", "", { "bin": { "argv": "lib/cli.js" } }, "sha512-4/yMUKdaFIKBUOOu5+qhC2kMuAECk7FaKamo5NSu4iAzuw36hj6E3UY3CYVKXPnA5dldwiwW60Ss5Ss5QdxVCw=="], + "@socket.io/bun-engine": ["@socket.io/bun-engine@0.1.0", "", { "peerDependencies": { "typescript": "^5" } }, "sha512-B1z6GuAxZlfvjgaa3BHZBOfqHJNfnpebTw15p+Un1HuBL4YM7wUxO9sJa7K4NDTe7XbUBeqLIwTDA5tOOjffog=="], "@socket.io/component-emitter": ["@socket.io/component-emitter@3.1.2", "", {}, "sha512-9BCxFwvbGg/RsZK9tjXd8s4UcwR0MWeFQ1XEKIQVVvAGJyINdrqKMcTRyLoK8Rse1GjzLV9cwjWV1olXRWEXVA=="], @@ -112,6 +115,8 @@ "base64id": ["base64id@2.0.0", "", {}, "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog=="], + "blakets": ["blakets@0.1.12", "", { "dependencies": { "@prokopschield/argv": "^0.1.0-2" }, "bin": { "blake": "lib/demo.js", "blake2b": "lib/cli.js", "blake2s": "lib/cli.js", "blakejs": "lib/demo.js", "blakets": "lib/demo.js" } }, "sha512-ReOnLTDRlbExlTXbJZoA2xkvhzauJ7ldpvhKnb1cUNw8gdAHWHWOWG8XMjwpxQmmEZCDAR7VZiM5BYTUSOLVrw=="], + "buffer-equal-constant-time": ["buffer-equal-constant-time@1.0.1", "", {}, "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA=="], "bun-types": ["bun-types@1.3.6", "", { "dependencies": { "@types/node": "*" } }, "sha512-OlFwHcnNV99r//9v5IIOgQ9Uk37gZqrNMCcqEaExdkVq3Avwqok1bJFmvGMCkCE0FqzdY8VMOZpfpR3lwI+CsQ=="], diff --git a/generated/prisma/browser.ts b/generated/prisma/browser.ts index 8c56a70..8fbda0f 100644 --- a/generated/prisma/browser.ts +++ b/generated/prisma/browser.ts @@ -37,3 +37,18 @@ export type Role = Prisma.RoleModel * */ export type Company = Prisma.CompanyModel +/** + * Model CredentialType + * + */ +export type CredentialType = Prisma.CredentialTypeModel +/** + * Model SecureValue + * + */ +export type SecureValue = Prisma.SecureValueModel +/** + * Model Credential + * + */ +export type Credential = Prisma.CredentialModel diff --git a/generated/prisma/client.ts b/generated/prisma/client.ts index 140ed38..76ad72c 100644 --- a/generated/prisma/client.ts +++ b/generated/prisma/client.ts @@ -59,3 +59,18 @@ export type Role = Prisma.RoleModel * */ export type Company = Prisma.CompanyModel +/** + * Model CredentialType + * + */ +export type CredentialType = Prisma.CredentialTypeModel +/** + * Model SecureValue + * + */ +export type SecureValue = Prisma.SecureValueModel +/** + * Model Credential + * + */ +export type Credential = Prisma.CredentialModel diff --git a/generated/prisma/commonInputTypes.ts b/generated/prisma/commonInputTypes.ts index 219894b..736f2a2 100644 --- a/generated/prisma/commonInputTypes.ts +++ b/generated/prisma/commonInputTypes.ts @@ -175,6 +175,57 @@ export type IntWithAggregatesFilter<$PrismaModel = never> = { _max?: Prisma.NestedIntFilter<$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> @@ -349,4 +400,28 @@ export type NestedFloatFilter<$PrismaModel = never> = { not?: Prisma.NestedFloatFilter<$PrismaModel> | number } +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/internal/class.ts b/generated/prisma/internal/class.ts index 2f5176c..556b006 100644 --- a/generated/prisma/internal/class.ts +++ b/generated/prisma/internal/class.ts @@ -20,7 +20,7 @@ const config: runtime.GetPrismaClientConfig = { "clientVersion": "7.3.0", "engineVersion": "9d6ad21cbbceab97458517b147a6a09ff43aa735", "activeProvider": "postgresql", - "inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\n// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?\n// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init\n\ngenerator client {\n provider = \"prisma-client\"\n output = \"../generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\nmodel Session {\n id String @id @default(uuid())\n sessionKey String @unique @default(cuid())\n userId String\n expires DateTime\n refreshTokenGenerated Boolean @default(false)\n refreshedAt DateTime?\n invalidatedAt DateTime?\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n}\n\nmodel User {\n id String @id @default(cuid())\n roles Role[]\n permissions String?\n login String @unique\n name String?\n email String @unique\n emailVerified DateTime?\n image String?\n\n userId String @unique\n token String?\n\n sessions Session[]\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Role {\n id String @id @default(uuid())\n title String\n moniker String @unique // e.g. admin, super_admin, moderator\n\n permissions String\n users User[]\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Company {\n id String @id @default(cuid())\n name String\n\n cw_CompanyId Int @unique\n cw_Identifier String @unique\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n", + "inlineSchema": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\n// Looking for ways to speed up your queries, or scale easily with your serverless or edge functions?\n// Try Prisma Accelerate: https://pris.ly/cli/accelerate-init\n\ngenerator client {\n provider = \"prisma-client\"\n output = \"../generated/prisma\"\n}\n\ndatasource db {\n provider = \"postgresql\"\n}\n\nmodel Session {\n id String @id @default(uuid())\n sessionKey String @unique @default(cuid())\n userId String\n expires DateTime\n refreshTokenGenerated Boolean @default(false)\n refreshedAt DateTime?\n invalidatedAt DateTime?\n user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n}\n\nmodel User {\n id String @id @default(cuid())\n roles Role[]\n permissions String?\n login String @unique\n name String?\n email String @unique\n emailVerified DateTime?\n image String?\n\n userId String @unique\n token String?\n\n sessions Session[]\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Role {\n id String @id @default(uuid())\n title String\n moniker String @unique // e.g. admin, super_admin, moderator\n\n permissions String\n users User[]\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Company {\n id String @id @default(cuid())\n name String\n\n cw_CompanyId Int @unique\n cw_Identifier String @unique\n\n credentials Credential[]\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel CredentialType {\n id String @id @default(cuid())\n name String @unique\n\n permissionScope String\n icon String?\n fields Json\n\n credentials Credential[]\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel SecureValue {\n id String @id @default(cuid())\n name String\n\n content String // Encrypted content\n hash String // Hash of the original content for integrity verification and Search\n\n credentialId String\n credential Credential @relation(fields: [credentialId], references: [id], onDelete: Cascade)\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n\nmodel Credential {\n id String @id @default(cuid())\n name String\n\n typeId String\n type CredentialType @relation(fields: [typeId], references: [id], onDelete: Cascade)\n\n fields Json\n\n companyId String\n company Company @relation(fields: [companyId], references: [id], onDelete: Cascade)\n\n securevalues SecureValue[]\n\n createdAt DateTime @default(now())\n updatedAt DateTime @updatedAt\n}\n", "runtimeDataModel": { "models": {}, "enums": {}, @@ -28,7 +28,7 @@ const config: runtime.GetPrismaClientConfig = { } } -config.runtimeDataModel = JSON.parse("{\"models\":{\"Session\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sessionKey\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expires\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"refreshTokenGenerated\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"refreshedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"invalidatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"SessionToUser\"}],\"dbName\":null},\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"roles\",\"kind\":\"object\",\"type\":\"Role\",\"relationName\":\"RoleToUser\"},{\"name\":\"permissions\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"login\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"emailVerified\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"image\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"token\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sessions\",\"kind\":\"object\",\"type\":\"Session\",\"relationName\":\"SessionToUser\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"Role\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"title\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"moniker\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"permissions\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"users\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"RoleToUser\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"Company\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"cw_CompanyId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"cw_Identifier\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}") +config.runtimeDataModel = JSON.parse("{\"models\":{\"Session\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sessionKey\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"expires\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"refreshTokenGenerated\",\"kind\":\"scalar\",\"type\":\"Boolean\"},{\"name\":\"refreshedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"invalidatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"user\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"SessionToUser\"}],\"dbName\":null},\"User\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"roles\",\"kind\":\"object\",\"type\":\"Role\",\"relationName\":\"RoleToUser\"},{\"name\":\"permissions\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"login\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"email\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"emailVerified\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"image\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"userId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"token\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"sessions\",\"kind\":\"object\",\"type\":\"Session\",\"relationName\":\"SessionToUser\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"Role\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"title\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"moniker\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"permissions\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"users\",\"kind\":\"object\",\"type\":\"User\",\"relationName\":\"RoleToUser\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"Company\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"cw_CompanyId\",\"kind\":\"scalar\",\"type\":\"Int\"},{\"name\":\"cw_Identifier\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"credentials\",\"kind\":\"object\",\"type\":\"Credential\",\"relationName\":\"CompanyToCredential\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"CredentialType\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"permissionScope\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"icon\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"fields\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"credentials\",\"kind\":\"object\",\"type\":\"Credential\",\"relationName\":\"CredentialToCredentialType\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"SecureValue\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"content\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"hash\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"credentialId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"credential\",\"kind\":\"object\",\"type\":\"Credential\",\"relationName\":\"CredentialToSecureValue\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null},\"Credential\":{\"fields\":[{\"name\":\"id\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"name\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"typeId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"type\",\"kind\":\"object\",\"type\":\"CredentialType\",\"relationName\":\"CredentialToCredentialType\"},{\"name\":\"fields\",\"kind\":\"scalar\",\"type\":\"Json\"},{\"name\":\"companyId\",\"kind\":\"scalar\",\"type\":\"String\"},{\"name\":\"company\",\"kind\":\"object\",\"type\":\"Company\",\"relationName\":\"CompanyToCredential\"},{\"name\":\"securevalues\",\"kind\":\"object\",\"type\":\"SecureValue\",\"relationName\":\"CredentialToSecureValue\"},{\"name\":\"createdAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"},{\"name\":\"updatedAt\",\"kind\":\"scalar\",\"type\":\"DateTime\"}],\"dbName\":null}},\"enums\":{},\"types\":{}}") async function decodeBase64AsWasm(wasmBase64: string): Promise { const { Buffer } = await import('node:buffer') @@ -215,6 +215,36 @@ export interface PrismaClient< * ``` */ get company(): Prisma.CompanyDelegate; + + /** + * `prisma.credentialType`: Exposes CRUD operations for the **CredentialType** model. + * Example usage: + * ```ts + * // Fetch zero or more CredentialTypes + * const credentialTypes = await prisma.credentialType.findMany() + * ``` + */ + get credentialType(): Prisma.CredentialTypeDelegate; + + /** + * `prisma.secureValue`: Exposes CRUD operations for the **SecureValue** model. + * Example usage: + * ```ts + * // Fetch zero or more SecureValues + * const secureValues = await prisma.secureValue.findMany() + * ``` + */ + get secureValue(): Prisma.SecureValueDelegate; + + /** + * `prisma.credential`: Exposes CRUD operations for the **Credential** model. + * Example usage: + * ```ts + * // Fetch zero or more Credentials + * const credentials = await prisma.credential.findMany() + * ``` + */ + get credential(): Prisma.CredentialDelegate; } export function getPrismaClientClass(): PrismaClientConstructor { diff --git a/generated/prisma/internal/prismaNamespace.ts b/generated/prisma/internal/prismaNamespace.ts index e55030e..d8155b2 100644 --- a/generated/prisma/internal/prismaNamespace.ts +++ b/generated/prisma/internal/prismaNamespace.ts @@ -387,7 +387,10 @@ export const ModelName = { Session: 'Session', User: 'User', Role: 'Role', - Company: 'Company' + Company: 'Company', + CredentialType: 'CredentialType', + SecureValue: 'SecureValue', + Credential: 'Credential' } as const export type ModelName = (typeof ModelName)[keyof typeof ModelName] @@ -403,7 +406,7 @@ export type TypeMap + fields: Prisma.CredentialTypeFieldRefs + operations: { + findUnique: { + args: Prisma.CredentialTypeFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.CredentialTypeFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.CredentialTypeFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.CredentialTypeFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.CredentialTypeFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.CredentialTypeCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.CredentialTypeCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.CredentialTypeCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.CredentialTypeDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.CredentialTypeUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.CredentialTypeDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.CredentialTypeUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.CredentialTypeUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.CredentialTypeUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.CredentialTypeAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.CredentialTypeGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.CredentialTypeCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } + SecureValue: { + payload: Prisma.$SecureValuePayload + fields: Prisma.SecureValueFieldRefs + operations: { + findUnique: { + args: Prisma.SecureValueFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.SecureValueFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.SecureValueFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.SecureValueFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.SecureValueFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.SecureValueCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.SecureValueCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.SecureValueCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.SecureValueDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.SecureValueUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.SecureValueDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.SecureValueUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.SecureValueUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.SecureValueUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.SecureValueAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.SecureValueGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.SecureValueCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } + Credential: { + payload: Prisma.$CredentialPayload + fields: Prisma.CredentialFieldRefs + operations: { + findUnique: { + args: Prisma.CredentialFindUniqueArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findUniqueOrThrow: { + args: Prisma.CredentialFindUniqueOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findFirst: { + args: Prisma.CredentialFindFirstArgs + result: runtime.Types.Utils.PayloadToResult | null + } + findFirstOrThrow: { + args: Prisma.CredentialFindFirstOrThrowArgs + result: runtime.Types.Utils.PayloadToResult + } + findMany: { + args: Prisma.CredentialFindManyArgs + result: runtime.Types.Utils.PayloadToResult[] + } + create: { + args: Prisma.CredentialCreateArgs + result: runtime.Types.Utils.PayloadToResult + } + createMany: { + args: Prisma.CredentialCreateManyArgs + result: BatchPayload + } + createManyAndReturn: { + args: Prisma.CredentialCreateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + delete: { + args: Prisma.CredentialDeleteArgs + result: runtime.Types.Utils.PayloadToResult + } + update: { + args: Prisma.CredentialUpdateArgs + result: runtime.Types.Utils.PayloadToResult + } + deleteMany: { + args: Prisma.CredentialDeleteManyArgs + result: BatchPayload + } + updateMany: { + args: Prisma.CredentialUpdateManyArgs + result: BatchPayload + } + updateManyAndReturn: { + args: Prisma.CredentialUpdateManyAndReturnArgs + result: runtime.Types.Utils.PayloadToResult[] + } + upsert: { + args: Prisma.CredentialUpsertArgs + result: runtime.Types.Utils.PayloadToResult + } + aggregate: { + args: Prisma.CredentialAggregateArgs + result: runtime.Types.Utils.Optional + } + groupBy: { + args: Prisma.CredentialGroupByArgs + result: runtime.Types.Utils.Optional[] + } + count: { + args: Prisma.CredentialCountArgs + result: runtime.Types.Utils.Optional | number + } + } + } } } & { other: { @@ -796,6 +1021,45 @@ export const CompanyScalarFieldEnum = { export type CompanyScalarFieldEnum = (typeof CompanyScalarFieldEnum)[keyof typeof CompanyScalarFieldEnum] +export const CredentialTypeScalarFieldEnum = { + id: 'id', + name: 'name', + permissionScope: 'permissionScope', + icon: 'icon', + fields: 'fields', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type CredentialTypeScalarFieldEnum = (typeof CredentialTypeScalarFieldEnum)[keyof typeof CredentialTypeScalarFieldEnum] + + +export const SecureValueScalarFieldEnum = { + id: 'id', + name: 'name', + content: 'content', + hash: 'hash', + credentialId: 'credentialId', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type SecureValueScalarFieldEnum = (typeof SecureValueScalarFieldEnum)[keyof typeof SecureValueScalarFieldEnum] + + +export const CredentialScalarFieldEnum = { + id: 'id', + name: 'name', + typeId: 'typeId', + fields: 'fields', + companyId: 'companyId', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type CredentialScalarFieldEnum = (typeof CredentialScalarFieldEnum)[keyof typeof CredentialScalarFieldEnum] + + export const SortOrder = { asc: 'asc', desc: 'desc' @@ -804,6 +1068,13 @@ export const SortOrder = { export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder] +export const JsonNullValueInput = { + JsonNull: JsonNull +} as const + +export type JsonNullValueInput = (typeof JsonNullValueInput)[keyof typeof JsonNullValueInput] + + export const QueryMode = { default: 'default', insensitive: 'insensitive' @@ -820,6 +1091,15 @@ export const NullsOrder = { export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder] +export const JsonNullValueFilter = { + DbNull: DbNull, + JsonNull: JsonNull, + AnyNull: AnyNull +} as const + +export type JsonNullValueFilter = (typeof JsonNullValueFilter)[keyof typeof JsonNullValueFilter] + + /** * Field references @@ -875,6 +1155,20 @@ export type ListIntFieldRefInput<$PrismaModel> = FieldRefInputType<$PrismaModel, +/** + * 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 'Float' */ @@ -987,6 +1281,9 @@ export type GlobalOmitConfig = { user?: Prisma.UserOmit role?: Prisma.RoleOmit company?: Prisma.CompanyOmit + credentialType?: Prisma.CredentialTypeOmit + secureValue?: Prisma.SecureValueOmit + credential?: Prisma.CredentialOmit } /* Types for Logging */ diff --git a/generated/prisma/internal/prismaNamespaceBrowser.ts b/generated/prisma/internal/prismaNamespaceBrowser.ts index b6b9521..f7dd699 100644 --- a/generated/prisma/internal/prismaNamespaceBrowser.ts +++ b/generated/prisma/internal/prismaNamespaceBrowser.ts @@ -54,7 +54,10 @@ export const ModelName = { Session: 'Session', User: 'User', Role: 'Role', - Company: 'Company' + Company: 'Company', + CredentialType: 'CredentialType', + SecureValue: 'SecureValue', + Credential: 'Credential' } as const export type ModelName = (typeof ModelName)[keyof typeof ModelName] @@ -127,6 +130,45 @@ export const CompanyScalarFieldEnum = { export type CompanyScalarFieldEnum = (typeof CompanyScalarFieldEnum)[keyof typeof CompanyScalarFieldEnum] +export const CredentialTypeScalarFieldEnum = { + id: 'id', + name: 'name', + permissionScope: 'permissionScope', + icon: 'icon', + fields: 'fields', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type CredentialTypeScalarFieldEnum = (typeof CredentialTypeScalarFieldEnum)[keyof typeof CredentialTypeScalarFieldEnum] + + +export const SecureValueScalarFieldEnum = { + id: 'id', + name: 'name', + content: 'content', + hash: 'hash', + credentialId: 'credentialId', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type SecureValueScalarFieldEnum = (typeof SecureValueScalarFieldEnum)[keyof typeof SecureValueScalarFieldEnum] + + +export const CredentialScalarFieldEnum = { + id: 'id', + name: 'name', + typeId: 'typeId', + fields: 'fields', + companyId: 'companyId', + createdAt: 'createdAt', + updatedAt: 'updatedAt' +} as const + +export type CredentialScalarFieldEnum = (typeof CredentialScalarFieldEnum)[keyof typeof CredentialScalarFieldEnum] + + export const SortOrder = { asc: 'asc', desc: 'desc' @@ -135,6 +177,13 @@ export const SortOrder = { export type SortOrder = (typeof SortOrder)[keyof typeof SortOrder] +export const JsonNullValueInput = { + JsonNull: JsonNull +} as const + +export type JsonNullValueInput = (typeof JsonNullValueInput)[keyof typeof JsonNullValueInput] + + export const QueryMode = { default: 'default', insensitive: 'insensitive' @@ -150,3 +199,12 @@ export const NullsOrder = { export type NullsOrder = (typeof NullsOrder)[keyof typeof NullsOrder] + +export const JsonNullValueFilter = { + DbNull: DbNull, + JsonNull: JsonNull, + AnyNull: AnyNull +} as const + +export type JsonNullValueFilter = (typeof JsonNullValueFilter)[keyof typeof JsonNullValueFilter] + diff --git a/generated/prisma/models.ts b/generated/prisma/models.ts index 99e7913..b33ceb9 100644 --- a/generated/prisma/models.ts +++ b/generated/prisma/models.ts @@ -12,4 +12,7 @@ export type * from './models/Session.ts' export type * from './models/User.ts' export type * from './models/Role.ts' export type * from './models/Company.ts' +export type * from './models/CredentialType.ts' +export type * from './models/SecureValue.ts' +export type * from './models/Credential.ts' export type * from './commonInputTypes.ts' \ No newline at end of file diff --git a/generated/prisma/models/Company.ts b/generated/prisma/models/Company.ts index 74664f9..170087b 100644 --- a/generated/prisma/models/Company.ts +++ b/generated/prisma/models/Company.ts @@ -224,6 +224,7 @@ export type CompanyWhereInput = { cw_Identifier?: Prisma.StringFilter<"Company"> | string createdAt?: Prisma.DateTimeFilter<"Company"> | Date | string updatedAt?: Prisma.DateTimeFilter<"Company"> | Date | string + credentials?: Prisma.CredentialListRelationFilter } export type CompanyOrderByWithRelationInput = { @@ -233,6 +234,7 @@ export type CompanyOrderByWithRelationInput = { cw_Identifier?: Prisma.SortOrder createdAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder + credentials?: Prisma.CredentialOrderByRelationAggregateInput } export type CompanyWhereUniqueInput = Prisma.AtLeast<{ @@ -245,6 +247,7 @@ export type CompanyWhereUniqueInput = Prisma.AtLeast<{ name?: Prisma.StringFilter<"Company"> | string createdAt?: Prisma.DateTimeFilter<"Company"> | Date | string updatedAt?: Prisma.DateTimeFilter<"Company"> | Date | string + credentials?: Prisma.CredentialListRelationFilter }, "id" | "cw_CompanyId" | "cw_Identifier"> export type CompanyOrderByWithAggregationInput = { @@ -280,6 +283,7 @@ export type CompanyCreateInput = { cw_Identifier: string createdAt?: Date | string updatedAt?: Date | string + credentials?: Prisma.CredentialCreateNestedManyWithoutCompanyInput } export type CompanyUncheckedCreateInput = { @@ -289,6 +293,7 @@ export type CompanyUncheckedCreateInput = { cw_Identifier: string createdAt?: Date | string updatedAt?: Date | string + credentials?: Prisma.CredentialUncheckedCreateNestedManyWithoutCompanyInput } export type CompanyUpdateInput = { @@ -298,6 +303,7 @@ export type CompanyUpdateInput = { cw_Identifier?: Prisma.StringFieldUpdateOperationsInput | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + credentials?: Prisma.CredentialUpdateManyWithoutCompanyNestedInput } export type CompanyUncheckedUpdateInput = { @@ -307,6 +313,7 @@ export type CompanyUncheckedUpdateInput = { cw_Identifier?: Prisma.StringFieldUpdateOperationsInput | string createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + credentials?: Prisma.CredentialUncheckedUpdateManyWithoutCompanyNestedInput } export type CompanyCreateManyInput = { @@ -371,6 +378,11 @@ export type CompanySumOrderByAggregateInput = { cw_CompanyId?: Prisma.SortOrder } +export type CompanyScalarRelationFilter = { + is?: Prisma.CompanyWhereInput + isNot?: Prisma.CompanyWhereInput +} + export type IntFieldUpdateOperationsInput = { set?: number increment?: number @@ -379,6 +391,101 @@ export type IntFieldUpdateOperationsInput = { divide?: number } +export type CompanyCreateNestedOneWithoutCredentialsInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.CompanyCreateOrConnectWithoutCredentialsInput + connect?: Prisma.CompanyWhereUniqueInput +} + +export type CompanyUpdateOneRequiredWithoutCredentialsNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.CompanyCreateOrConnectWithoutCredentialsInput + upsert?: Prisma.CompanyUpsertWithoutCredentialsInput + connect?: Prisma.CompanyWhereUniqueInput + update?: Prisma.XOR, Prisma.CompanyUncheckedUpdateWithoutCredentialsInput> +} + +export type CompanyCreateWithoutCredentialsInput = { + id?: string + name: string + cw_CompanyId: number + cw_Identifier: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CompanyUncheckedCreateWithoutCredentialsInput = { + id?: string + name: string + cw_CompanyId: number + cw_Identifier: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CompanyCreateOrConnectWithoutCredentialsInput = { + where: Prisma.CompanyWhereUniqueInput + create: Prisma.XOR +} + +export type CompanyUpsertWithoutCredentialsInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.CompanyWhereInput +} + +export type CompanyUpdateToOneWithWhereWithoutCredentialsInput = { + where?: Prisma.CompanyWhereInput + data: Prisma.XOR +} + +export type CompanyUpdateWithoutCredentialsInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + cw_CompanyId?: Prisma.IntFieldUpdateOperationsInput | number + cw_Identifier?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CompanyUncheckedUpdateWithoutCredentialsInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + cw_CompanyId?: Prisma.IntFieldUpdateOperationsInput | number + cw_Identifier?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + + +/** + * Count Type CompanyCountOutputType + */ + +export type CompanyCountOutputType = { + credentials: number +} + +export type CompanyCountOutputTypeSelect = { + credentials?: boolean | CompanyCountOutputTypeCountCredentialsArgs +} + +/** + * CompanyCountOutputType without action + */ +export type CompanyCountOutputTypeDefaultArgs = { + /** + * Select specific fields to fetch from the CompanyCountOutputType + */ + select?: Prisma.CompanyCountOutputTypeSelect | null +} + +/** + * CompanyCountOutputType without action + */ +export type CompanyCountOutputTypeCountCredentialsArgs = { + where?: Prisma.CredentialWhereInput +} export type CompanySelect = runtime.Types.Extensions.GetSelect<{ @@ -388,6 +495,8 @@ export type CompanySelect + _count?: boolean | Prisma.CompanyCountOutputTypeDefaultArgs }, ExtArgs["result"]["company"]> export type CompanySelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ @@ -418,10 +527,18 @@ export type CompanySelectScalar = { } export type CompanyOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "cw_CompanyId" | "cw_Identifier" | "createdAt" | "updatedAt", ExtArgs["result"]["company"]> +export type CompanyInclude = { + credentials?: boolean | Prisma.Company$credentialsArgs + _count?: boolean | Prisma.CompanyCountOutputTypeDefaultArgs +} +export type CompanyIncludeCreateManyAndReturn = {} +export type CompanyIncludeUpdateManyAndReturn = {} export type $CompanyPayload = { name: "Company" - objects: {} + objects: { + credentials: Prisma.$CredentialPayload[] + } scalars: runtime.Types.Extensions.GetPayloadResult<{ id: string name: string @@ -823,6 +940,7 @@ readonly fields: CompanyFieldRefs; */ export interface Prisma__CompanyClient extends Prisma.PrismaPromise { readonly [Symbol.toStringTag]: "PrismaPromise" + credentials = {}>(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. @@ -874,6 +992,10 @@ export type CompanyFindUniqueArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * Filter, which Company to fetch. */ @@ -892,6 +1014,10 @@ export type CompanyFindUniqueOrThrowArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * Filter, which Company to fetch. */ @@ -910,6 +1036,10 @@ export type CompanyFindFirstArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * Filter, which Company to fetch. */ @@ -958,6 +1088,10 @@ export type CompanyFindFirstOrThrowArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * Filter, which Company to fetch. */ @@ -1006,6 +1140,10 @@ export type CompanyFindManyArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * Filter, which Companies to fetch. */ @@ -1049,6 +1187,10 @@ export type CompanyCreateArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * The data needed to create a Company. */ @@ -1097,6 +1239,10 @@ export type CompanyUpdateArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * The data needed to update a Company. */ @@ -1163,6 +1309,10 @@ export type CompanyUpsertArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * The filter to search for the Company to update in case it exists. */ @@ -1189,6 +1339,10 @@ export type CompanyDeleteArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null /** * Filter which Company to delete. */ @@ -1209,6 +1363,30 @@ export type CompanyDeleteManyArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + where?: Prisma.CredentialWhereInput + orderBy?: Prisma.CredentialOrderByWithRelationInput | Prisma.CredentialOrderByWithRelationInput[] + cursor?: Prisma.CredentialWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.CredentialScalarFieldEnum | Prisma.CredentialScalarFieldEnum[] +} + /** * Company without action */ @@ -1221,4 +1399,8 @@ export type CompanyDefaultArgs | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CompanyInclude | null } diff --git a/generated/prisma/models/Credential.ts b/generated/prisma/models/Credential.ts new file mode 100644 index 0000000..40fe657 --- /dev/null +++ b/generated/prisma/models/Credential.ts @@ -0,0 +1,1685 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `Credential` 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 Credential + * + */ +export type CredentialModel = runtime.Types.Result.DefaultSelection + +export type AggregateCredential = { + _count: CredentialCountAggregateOutputType | null + _min: CredentialMinAggregateOutputType | null + _max: CredentialMaxAggregateOutputType | null +} + +export type CredentialMinAggregateOutputType = { + id: string | null + name: string | null + typeId: string | null + companyId: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type CredentialMaxAggregateOutputType = { + id: string | null + name: string | null + typeId: string | null + companyId: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type CredentialCountAggregateOutputType = { + id: number + name: number + typeId: number + fields: number + companyId: number + createdAt: number + updatedAt: number + _all: number +} + + +export type CredentialMinAggregateInputType = { + id?: true + name?: true + typeId?: true + companyId?: true + createdAt?: true + updatedAt?: true +} + +export type CredentialMaxAggregateInputType = { + id?: true + name?: true + typeId?: true + companyId?: true + createdAt?: true + updatedAt?: true +} + +export type CredentialCountAggregateInputType = { + id?: true + name?: true + typeId?: true + fields?: true + companyId?: true + createdAt?: true + updatedAt?: true + _all?: true +} + +export type CredentialAggregateArgs = { + /** + * Filter which Credential to aggregate. + */ + where?: Prisma.CredentialWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Credentials to fetch. + */ + orderBy?: Prisma.CredentialOrderByWithRelationInput | Prisma.CredentialOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.CredentialWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Credentials 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` Credentials. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned Credentials + **/ + _count?: true | CredentialCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: CredentialMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: CredentialMaxAggregateInputType +} + +export type GetCredentialAggregateType = { + [P in keyof T & keyof AggregateCredential]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type CredentialGroupByArgs = { + where?: Prisma.CredentialWhereInput + orderBy?: Prisma.CredentialOrderByWithAggregationInput | Prisma.CredentialOrderByWithAggregationInput[] + by: Prisma.CredentialScalarFieldEnum[] | Prisma.CredentialScalarFieldEnum + having?: Prisma.CredentialScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: CredentialCountAggregateInputType | true + _min?: CredentialMinAggregateInputType + _max?: CredentialMaxAggregateInputType +} + +export type CredentialGroupByOutputType = { + id: string + name: string + typeId: string + fields: runtime.JsonValue + companyId: string + createdAt: Date + updatedAt: Date + _count: CredentialCountAggregateOutputType | null + _min: CredentialMinAggregateOutputType | null + _max: CredentialMaxAggregateOutputType | null +} + +type GetCredentialGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof CredentialGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type CredentialWhereInput = { + AND?: Prisma.CredentialWhereInput | Prisma.CredentialWhereInput[] + OR?: Prisma.CredentialWhereInput[] + NOT?: Prisma.CredentialWhereInput | Prisma.CredentialWhereInput[] + id?: Prisma.StringFilter<"Credential"> | string + name?: Prisma.StringFilter<"Credential"> | string + typeId?: Prisma.StringFilter<"Credential"> | string + fields?: Prisma.JsonFilter<"Credential"> + companyId?: Prisma.StringFilter<"Credential"> | string + createdAt?: Prisma.DateTimeFilter<"Credential"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Credential"> | Date | string + type?: Prisma.XOR + company?: Prisma.XOR + securevalues?: Prisma.SecureValueListRelationFilter +} + +export type CredentialOrderByWithRelationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + typeId?: Prisma.SortOrder + fields?: Prisma.SortOrder + companyId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + type?: Prisma.CredentialTypeOrderByWithRelationInput + company?: Prisma.CompanyOrderByWithRelationInput + securevalues?: Prisma.SecureValueOrderByRelationAggregateInput +} + +export type CredentialWhereUniqueInput = Prisma.AtLeast<{ + id?: string + AND?: Prisma.CredentialWhereInput | Prisma.CredentialWhereInput[] + OR?: Prisma.CredentialWhereInput[] + NOT?: Prisma.CredentialWhereInput | Prisma.CredentialWhereInput[] + name?: Prisma.StringFilter<"Credential"> | string + typeId?: Prisma.StringFilter<"Credential"> | string + fields?: Prisma.JsonFilter<"Credential"> + companyId?: Prisma.StringFilter<"Credential"> | string + createdAt?: Prisma.DateTimeFilter<"Credential"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Credential"> | Date | string + type?: Prisma.XOR + company?: Prisma.XOR + securevalues?: Prisma.SecureValueListRelationFilter +}, "id"> + +export type CredentialOrderByWithAggregationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + typeId?: Prisma.SortOrder + fields?: Prisma.SortOrder + companyId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + _count?: Prisma.CredentialCountOrderByAggregateInput + _max?: Prisma.CredentialMaxOrderByAggregateInput + _min?: Prisma.CredentialMinOrderByAggregateInput +} + +export type CredentialScalarWhereWithAggregatesInput = { + AND?: Prisma.CredentialScalarWhereWithAggregatesInput | Prisma.CredentialScalarWhereWithAggregatesInput[] + OR?: Prisma.CredentialScalarWhereWithAggregatesInput[] + NOT?: Prisma.CredentialScalarWhereWithAggregatesInput | Prisma.CredentialScalarWhereWithAggregatesInput[] + id?: Prisma.StringWithAggregatesFilter<"Credential"> | string + name?: Prisma.StringWithAggregatesFilter<"Credential"> | string + typeId?: Prisma.StringWithAggregatesFilter<"Credential"> | string + fields?: Prisma.JsonWithAggregatesFilter<"Credential"> + companyId?: Prisma.StringWithAggregatesFilter<"Credential"> | string + createdAt?: Prisma.DateTimeWithAggregatesFilter<"Credential"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"Credential"> | Date | string +} + +export type CredentialCreateInput = { + id?: string + name: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string + type: Prisma.CredentialTypeCreateNestedOneWithoutCredentialsInput + company: Prisma.CompanyCreateNestedOneWithoutCredentialsInput + securevalues?: Prisma.SecureValueCreateNestedManyWithoutCredentialInput +} + +export type CredentialUncheckedCreateInput = { + id?: string + name: string + typeId: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId: string + createdAt?: Date | string + updatedAt?: Date | string + securevalues?: Prisma.SecureValueUncheckedCreateNestedManyWithoutCredentialInput +} + +export type CredentialUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + type?: Prisma.CredentialTypeUpdateOneRequiredWithoutCredentialsNestedInput + company?: Prisma.CompanyUpdateOneRequiredWithoutCredentialsNestedInput + securevalues?: Prisma.SecureValueUpdateManyWithoutCredentialNestedInput +} + +export type CredentialUncheckedUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + typeId?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + securevalues?: Prisma.SecureValueUncheckedUpdateManyWithoutCredentialNestedInput +} + +export type CredentialCreateManyInput = { + id?: string + name: string + typeId: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CredentialUpdateManyMutationInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CredentialUncheckedUpdateManyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + typeId?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CredentialListRelationFilter = { + every?: Prisma.CredentialWhereInput + some?: Prisma.CredentialWhereInput + none?: Prisma.CredentialWhereInput +} + +export type CredentialOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type CredentialScalarRelationFilter = { + is?: Prisma.CredentialWhereInput + isNot?: Prisma.CredentialWhereInput +} + +export type CredentialCountOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + typeId?: Prisma.SortOrder + fields?: Prisma.SortOrder + companyId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type CredentialMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + typeId?: Prisma.SortOrder + companyId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type CredentialMinOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + typeId?: Prisma.SortOrder + companyId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type CredentialCreateNestedManyWithoutCompanyInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutCompanyInput[] | Prisma.CredentialUncheckedCreateWithoutCompanyInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutCompanyInput | Prisma.CredentialCreateOrConnectWithoutCompanyInput[] + createMany?: Prisma.CredentialCreateManyCompanyInputEnvelope + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] +} + +export type CredentialUncheckedCreateNestedManyWithoutCompanyInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutCompanyInput[] | Prisma.CredentialUncheckedCreateWithoutCompanyInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutCompanyInput | Prisma.CredentialCreateOrConnectWithoutCompanyInput[] + createMany?: Prisma.CredentialCreateManyCompanyInputEnvelope + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] +} + +export type CredentialUpdateManyWithoutCompanyNestedInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutCompanyInput[] | Prisma.CredentialUncheckedCreateWithoutCompanyInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutCompanyInput | Prisma.CredentialCreateOrConnectWithoutCompanyInput[] + upsert?: Prisma.CredentialUpsertWithWhereUniqueWithoutCompanyInput | Prisma.CredentialUpsertWithWhereUniqueWithoutCompanyInput[] + createMany?: Prisma.CredentialCreateManyCompanyInputEnvelope + set?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + disconnect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + delete?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + update?: Prisma.CredentialUpdateWithWhereUniqueWithoutCompanyInput | Prisma.CredentialUpdateWithWhereUniqueWithoutCompanyInput[] + updateMany?: Prisma.CredentialUpdateManyWithWhereWithoutCompanyInput | Prisma.CredentialUpdateManyWithWhereWithoutCompanyInput[] + deleteMany?: Prisma.CredentialScalarWhereInput | Prisma.CredentialScalarWhereInput[] +} + +export type CredentialUncheckedUpdateManyWithoutCompanyNestedInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutCompanyInput[] | Prisma.CredentialUncheckedCreateWithoutCompanyInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutCompanyInput | Prisma.CredentialCreateOrConnectWithoutCompanyInput[] + upsert?: Prisma.CredentialUpsertWithWhereUniqueWithoutCompanyInput | Prisma.CredentialUpsertWithWhereUniqueWithoutCompanyInput[] + createMany?: Prisma.CredentialCreateManyCompanyInputEnvelope + set?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + disconnect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + delete?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + update?: Prisma.CredentialUpdateWithWhereUniqueWithoutCompanyInput | Prisma.CredentialUpdateWithWhereUniqueWithoutCompanyInput[] + updateMany?: Prisma.CredentialUpdateManyWithWhereWithoutCompanyInput | Prisma.CredentialUpdateManyWithWhereWithoutCompanyInput[] + deleteMany?: Prisma.CredentialScalarWhereInput | Prisma.CredentialScalarWhereInput[] +} + +export type CredentialCreateNestedManyWithoutTypeInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutTypeInput[] | Prisma.CredentialUncheckedCreateWithoutTypeInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutTypeInput | Prisma.CredentialCreateOrConnectWithoutTypeInput[] + createMany?: Prisma.CredentialCreateManyTypeInputEnvelope + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] +} + +export type CredentialUncheckedCreateNestedManyWithoutTypeInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutTypeInput[] | Prisma.CredentialUncheckedCreateWithoutTypeInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutTypeInput | Prisma.CredentialCreateOrConnectWithoutTypeInput[] + createMany?: Prisma.CredentialCreateManyTypeInputEnvelope + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] +} + +export type CredentialUpdateManyWithoutTypeNestedInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutTypeInput[] | Prisma.CredentialUncheckedCreateWithoutTypeInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutTypeInput | Prisma.CredentialCreateOrConnectWithoutTypeInput[] + upsert?: Prisma.CredentialUpsertWithWhereUniqueWithoutTypeInput | Prisma.CredentialUpsertWithWhereUniqueWithoutTypeInput[] + createMany?: Prisma.CredentialCreateManyTypeInputEnvelope + set?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + disconnect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + delete?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + update?: Prisma.CredentialUpdateWithWhereUniqueWithoutTypeInput | Prisma.CredentialUpdateWithWhereUniqueWithoutTypeInput[] + updateMany?: Prisma.CredentialUpdateManyWithWhereWithoutTypeInput | Prisma.CredentialUpdateManyWithWhereWithoutTypeInput[] + deleteMany?: Prisma.CredentialScalarWhereInput | Prisma.CredentialScalarWhereInput[] +} + +export type CredentialUncheckedUpdateManyWithoutTypeNestedInput = { + create?: Prisma.XOR | Prisma.CredentialCreateWithoutTypeInput[] | Prisma.CredentialUncheckedCreateWithoutTypeInput[] + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutTypeInput | Prisma.CredentialCreateOrConnectWithoutTypeInput[] + upsert?: Prisma.CredentialUpsertWithWhereUniqueWithoutTypeInput | Prisma.CredentialUpsertWithWhereUniqueWithoutTypeInput[] + createMany?: Prisma.CredentialCreateManyTypeInputEnvelope + set?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + disconnect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + delete?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + connect?: Prisma.CredentialWhereUniqueInput | Prisma.CredentialWhereUniqueInput[] + update?: Prisma.CredentialUpdateWithWhereUniqueWithoutTypeInput | Prisma.CredentialUpdateWithWhereUniqueWithoutTypeInput[] + updateMany?: Prisma.CredentialUpdateManyWithWhereWithoutTypeInput | Prisma.CredentialUpdateManyWithWhereWithoutTypeInput[] + deleteMany?: Prisma.CredentialScalarWhereInput | Prisma.CredentialScalarWhereInput[] +} + +export type CredentialCreateNestedOneWithoutSecurevaluesInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutSecurevaluesInput + connect?: Prisma.CredentialWhereUniqueInput +} + +export type CredentialUpdateOneRequiredWithoutSecurevaluesNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.CredentialCreateOrConnectWithoutSecurevaluesInput + upsert?: Prisma.CredentialUpsertWithoutSecurevaluesInput + connect?: Prisma.CredentialWhereUniqueInput + update?: Prisma.XOR, Prisma.CredentialUncheckedUpdateWithoutSecurevaluesInput> +} + +export type CredentialCreateWithoutCompanyInput = { + id?: string + name: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string + type: Prisma.CredentialTypeCreateNestedOneWithoutCredentialsInput + securevalues?: Prisma.SecureValueCreateNestedManyWithoutCredentialInput +} + +export type CredentialUncheckedCreateWithoutCompanyInput = { + id?: string + name: string + typeId: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string + securevalues?: Prisma.SecureValueUncheckedCreateNestedManyWithoutCredentialInput +} + +export type CredentialCreateOrConnectWithoutCompanyInput = { + where: Prisma.CredentialWhereUniqueInput + create: Prisma.XOR +} + +export type CredentialCreateManyCompanyInputEnvelope = { + data: Prisma.CredentialCreateManyCompanyInput | Prisma.CredentialCreateManyCompanyInput[] + skipDuplicates?: boolean +} + +export type CredentialUpsertWithWhereUniqueWithoutCompanyInput = { + where: Prisma.CredentialWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type CredentialUpdateWithWhereUniqueWithoutCompanyInput = { + where: Prisma.CredentialWhereUniqueInput + data: Prisma.XOR +} + +export type CredentialUpdateManyWithWhereWithoutCompanyInput = { + where: Prisma.CredentialScalarWhereInput + data: Prisma.XOR +} + +export type CredentialScalarWhereInput = { + AND?: Prisma.CredentialScalarWhereInput | Prisma.CredentialScalarWhereInput[] + OR?: Prisma.CredentialScalarWhereInput[] + NOT?: Prisma.CredentialScalarWhereInput | Prisma.CredentialScalarWhereInput[] + id?: Prisma.StringFilter<"Credential"> | string + name?: Prisma.StringFilter<"Credential"> | string + typeId?: Prisma.StringFilter<"Credential"> | string + fields?: Prisma.JsonFilter<"Credential"> + companyId?: Prisma.StringFilter<"Credential"> | string + createdAt?: Prisma.DateTimeFilter<"Credential"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"Credential"> | Date | string +} + +export type CredentialCreateWithoutTypeInput = { + id?: string + name: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string + company: Prisma.CompanyCreateNestedOneWithoutCredentialsInput + securevalues?: Prisma.SecureValueCreateNestedManyWithoutCredentialInput +} + +export type CredentialUncheckedCreateWithoutTypeInput = { + id?: string + name: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId: string + createdAt?: Date | string + updatedAt?: Date | string + securevalues?: Prisma.SecureValueUncheckedCreateNestedManyWithoutCredentialInput +} + +export type CredentialCreateOrConnectWithoutTypeInput = { + where: Prisma.CredentialWhereUniqueInput + create: Prisma.XOR +} + +export type CredentialCreateManyTypeInputEnvelope = { + data: Prisma.CredentialCreateManyTypeInput | Prisma.CredentialCreateManyTypeInput[] + skipDuplicates?: boolean +} + +export type CredentialUpsertWithWhereUniqueWithoutTypeInput = { + where: Prisma.CredentialWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type CredentialUpdateWithWhereUniqueWithoutTypeInput = { + where: Prisma.CredentialWhereUniqueInput + data: Prisma.XOR +} + +export type CredentialUpdateManyWithWhereWithoutTypeInput = { + where: Prisma.CredentialScalarWhereInput + data: Prisma.XOR +} + +export type CredentialCreateWithoutSecurevaluesInput = { + id?: string + name: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string + type: Prisma.CredentialTypeCreateNestedOneWithoutCredentialsInput + company: Prisma.CompanyCreateNestedOneWithoutCredentialsInput +} + +export type CredentialUncheckedCreateWithoutSecurevaluesInput = { + id?: string + name: string + typeId: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CredentialCreateOrConnectWithoutSecurevaluesInput = { + where: Prisma.CredentialWhereUniqueInput + create: Prisma.XOR +} + +export type CredentialUpsertWithoutSecurevaluesInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.CredentialWhereInput +} + +export type CredentialUpdateToOneWithWhereWithoutSecurevaluesInput = { + where?: Prisma.CredentialWhereInput + data: Prisma.XOR +} + +export type CredentialUpdateWithoutSecurevaluesInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + type?: Prisma.CredentialTypeUpdateOneRequiredWithoutCredentialsNestedInput + company?: Prisma.CompanyUpdateOneRequiredWithoutCredentialsNestedInput +} + +export type CredentialUncheckedUpdateWithoutSecurevaluesInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + typeId?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CredentialCreateManyCompanyInput = { + id?: string + name: string + typeId: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CredentialUpdateWithoutCompanyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + type?: Prisma.CredentialTypeUpdateOneRequiredWithoutCredentialsNestedInput + securevalues?: Prisma.SecureValueUpdateManyWithoutCredentialNestedInput +} + +export type CredentialUncheckedUpdateWithoutCompanyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + typeId?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + securevalues?: Prisma.SecureValueUncheckedUpdateManyWithoutCredentialNestedInput +} + +export type CredentialUncheckedUpdateManyWithoutCompanyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + typeId?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CredentialCreateManyTypeInput = { + id?: string + name: string + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CredentialUpdateWithoutTypeInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + company?: Prisma.CompanyUpdateOneRequiredWithoutCredentialsNestedInput + securevalues?: Prisma.SecureValueUpdateManyWithoutCredentialNestedInput +} + +export type CredentialUncheckedUpdateWithoutTypeInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + securevalues?: Prisma.SecureValueUncheckedUpdateManyWithoutCredentialNestedInput +} + +export type CredentialUncheckedUpdateManyWithoutTypeInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + companyId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + + +/** + * Count Type CredentialCountOutputType + */ + +export type CredentialCountOutputType = { + securevalues: number +} + +export type CredentialCountOutputTypeSelect = { + securevalues?: boolean | CredentialCountOutputTypeCountSecurevaluesArgs +} + +/** + * CredentialCountOutputType without action + */ +export type CredentialCountOutputTypeDefaultArgs = { + /** + * Select specific fields to fetch from the CredentialCountOutputType + */ + select?: Prisma.CredentialCountOutputTypeSelect | null +} + +/** + * CredentialCountOutputType without action + */ +export type CredentialCountOutputTypeCountSecurevaluesArgs = { + where?: Prisma.SecureValueWhereInput +} + + +export type CredentialSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + typeId?: boolean + fields?: boolean + companyId?: boolean + createdAt?: boolean + updatedAt?: boolean + type?: boolean | Prisma.CredentialTypeDefaultArgs + company?: boolean | Prisma.CompanyDefaultArgs + securevalues?: boolean | Prisma.Credential$securevaluesArgs + _count?: boolean | Prisma.CredentialCountOutputTypeDefaultArgs +}, ExtArgs["result"]["credential"]> + +export type CredentialSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + typeId?: boolean + fields?: boolean + companyId?: boolean + createdAt?: boolean + updatedAt?: boolean + type?: boolean | Prisma.CredentialTypeDefaultArgs + company?: boolean | Prisma.CompanyDefaultArgs +}, ExtArgs["result"]["credential"]> + +export type CredentialSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + typeId?: boolean + fields?: boolean + companyId?: boolean + createdAt?: boolean + updatedAt?: boolean + type?: boolean | Prisma.CredentialTypeDefaultArgs + company?: boolean | Prisma.CompanyDefaultArgs +}, ExtArgs["result"]["credential"]> + +export type CredentialSelectScalar = { + id?: boolean + name?: boolean + typeId?: boolean + fields?: boolean + companyId?: boolean + createdAt?: boolean + updatedAt?: boolean +} + +export type CredentialOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "typeId" | "fields" | "companyId" | "createdAt" | "updatedAt", ExtArgs["result"]["credential"]> +export type CredentialInclude = { + type?: boolean | Prisma.CredentialTypeDefaultArgs + company?: boolean | Prisma.CompanyDefaultArgs + securevalues?: boolean | Prisma.Credential$securevaluesArgs + _count?: boolean | Prisma.CredentialCountOutputTypeDefaultArgs +} +export type CredentialIncludeCreateManyAndReturn = { + type?: boolean | Prisma.CredentialTypeDefaultArgs + company?: boolean | Prisma.CompanyDefaultArgs +} +export type CredentialIncludeUpdateManyAndReturn = { + type?: boolean | Prisma.CredentialTypeDefaultArgs + company?: boolean | Prisma.CompanyDefaultArgs +} + +export type $CredentialPayload = { + name: "Credential" + objects: { + type: Prisma.$CredentialTypePayload + company: Prisma.$CompanyPayload + securevalues: Prisma.$SecureValuePayload[] + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: string + name: string + typeId: string + fields: runtime.JsonValue + companyId: string + createdAt: Date + updatedAt: Date + }, ExtArgs["result"]["credential"]> + composites: {} +} + +export type CredentialGetPayload = runtime.Types.Result.GetResult + +export type CredentialCountArgs = + Omit & { + select?: CredentialCountAggregateInputType | true + } + +export interface CredentialDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['Credential'], meta: { name: 'Credential' } } + /** + * Find zero or one Credential that matches the filter. + * @param {CredentialFindUniqueArgs} args - Arguments to find a Credential + * @example + * // Get one Credential + * const credential = await prisma.credential.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one Credential that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {CredentialFindUniqueOrThrowArgs} args - Arguments to find a Credential + * @example + * // Get one Credential + * const credential = await prisma.credential.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Credential 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 {CredentialFindFirstArgs} args - Arguments to find a Credential + * @example + * // Get one Credential + * const credential = await prisma.credential.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first Credential 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 {CredentialFindFirstOrThrowArgs} args - Arguments to find a Credential + * @example + * // Get one Credential + * const credential = await prisma.credential.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more Credentials 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 {CredentialFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all Credentials + * const credentials = await prisma.credential.findMany() + * + * // Get first 10 Credentials + * const credentials = await prisma.credential.findMany({ take: 10 }) + * + * // Only select the `id` + * const credentialWithIdOnly = await prisma.credential.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a Credential. + * @param {CredentialCreateArgs} args - Arguments to create a Credential. + * @example + * // Create one Credential + * const Credential = await prisma.credential.create({ + * data: { + * // ... data to create a Credential + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many Credentials. + * @param {CredentialCreateManyArgs} args - Arguments to create many Credentials. + * @example + * // Create many Credentials + * const credential = await prisma.credential.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many Credentials and returns the data saved in the database. + * @param {CredentialCreateManyAndReturnArgs} args - Arguments to create many Credentials. + * @example + * // Create many Credentials + * const credential = await prisma.credential.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many Credentials and only return the `id` + * const credentialWithIdOnly = await prisma.credential.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 Credential. + * @param {CredentialDeleteArgs} args - Arguments to delete one Credential. + * @example + * // Delete one Credential + * const Credential = await prisma.credential.delete({ + * where: { + * // ... filter to delete one Credential + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one Credential. + * @param {CredentialUpdateArgs} args - Arguments to update one Credential. + * @example + * // Update one Credential + * const credential = await prisma.credential.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more Credentials. + * @param {CredentialDeleteManyArgs} args - Arguments to filter Credentials to delete. + * @example + * // Delete a few Credentials + * const { count } = await prisma.credential.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Credentials. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many Credentials + * const credential = await prisma.credential.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more Credentials and returns the data updated in the database. + * @param {CredentialUpdateManyAndReturnArgs} args - Arguments to update many Credentials. + * @example + * // Update many Credentials + * const credential = await prisma.credential.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more Credentials and only return the `id` + * const credentialWithIdOnly = await prisma.credential.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 Credential. + * @param {CredentialUpsertArgs} args - Arguments to update or create a Credential. + * @example + * // Update or create a Credential + * const credential = await prisma.credential.upsert({ + * create: { + * // ... data to create a Credential + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the Credential we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of Credentials. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialCountArgs} args - Arguments to filter Credentials to count. + * @example + * // Count the number of Credentials + * const count = await prisma.credential.count({ + * where: { + * // ... the filter for the Credentials 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 Credential. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialAggregateArgs} 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 Credential. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialGroupByArgs} 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 CredentialGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: CredentialGroupByArgs['orderBy'] } + : { orderBy?: CredentialGroupByArgs['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 ? GetCredentialGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the Credential model + */ +readonly fields: CredentialFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for Credential. + * 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__CredentialClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + type = {}>(args?: Prisma.Subset>): Prisma.Prisma__CredentialTypeClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + company = {}>(args?: Prisma.Subset>): Prisma.Prisma__CompanyClient, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> + securevalues = {}>(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 Credential model + */ +export interface CredentialFieldRefs { + readonly id: Prisma.FieldRef<"Credential", 'String'> + readonly name: Prisma.FieldRef<"Credential", 'String'> + readonly typeId: Prisma.FieldRef<"Credential", 'String'> + readonly fields: Prisma.FieldRef<"Credential", 'Json'> + readonly companyId: Prisma.FieldRef<"Credential", 'String'> + readonly createdAt: Prisma.FieldRef<"Credential", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"Credential", 'DateTime'> +} + + +// Custom InputTypes +/** + * Credential findUnique + */ +export type CredentialFindUniqueArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * Filter, which Credential to fetch. + */ + where: Prisma.CredentialWhereUniqueInput +} + +/** + * Credential findUniqueOrThrow + */ +export type CredentialFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * Filter, which Credential to fetch. + */ + where: Prisma.CredentialWhereUniqueInput +} + +/** + * Credential findFirst + */ +export type CredentialFindFirstArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * Filter, which Credential to fetch. + */ + where?: Prisma.CredentialWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Credentials to fetch. + */ + orderBy?: Prisma.CredentialOrderByWithRelationInput | Prisma.CredentialOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Credentials. + */ + cursor?: Prisma.CredentialWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Credentials 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` Credentials. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Credentials. + */ + distinct?: Prisma.CredentialScalarFieldEnum | Prisma.CredentialScalarFieldEnum[] +} + +/** + * Credential findFirstOrThrow + */ +export type CredentialFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * Filter, which Credential to fetch. + */ + where?: Prisma.CredentialWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Credentials to fetch. + */ + orderBy?: Prisma.CredentialOrderByWithRelationInput | Prisma.CredentialOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for Credentials. + */ + cursor?: Prisma.CredentialWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Credentials 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` Credentials. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of Credentials. + */ + distinct?: Prisma.CredentialScalarFieldEnum | Prisma.CredentialScalarFieldEnum[] +} + +/** + * Credential findMany + */ +export type CredentialFindManyArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * Filter, which Credentials to fetch. + */ + where?: Prisma.CredentialWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of Credentials to fetch. + */ + orderBy?: Prisma.CredentialOrderByWithRelationInput | Prisma.CredentialOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing Credentials. + */ + cursor?: Prisma.CredentialWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` Credentials 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` Credentials. + */ + skip?: number + distinct?: Prisma.CredentialScalarFieldEnum | Prisma.CredentialScalarFieldEnum[] +} + +/** + * Credential create + */ +export type CredentialCreateArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * The data needed to create a Credential. + */ + data: Prisma.XOR +} + +/** + * Credential createMany + */ +export type CredentialCreateManyArgs = { + /** + * The data used to create many Credentials. + */ + data: Prisma.CredentialCreateManyInput | Prisma.CredentialCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * Credential createManyAndReturn + */ +export type CredentialCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelectCreateManyAndReturn | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * The data used to create many Credentials. + */ + data: Prisma.CredentialCreateManyInput | Prisma.CredentialCreateManyInput[] + skipDuplicates?: boolean + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialIncludeCreateManyAndReturn | null +} + +/** + * Credential update + */ +export type CredentialUpdateArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * The data needed to update a Credential. + */ + data: Prisma.XOR + /** + * Choose, which Credential to update. + */ + where: Prisma.CredentialWhereUniqueInput +} + +/** + * Credential updateMany + */ +export type CredentialUpdateManyArgs = { + /** + * The data used to update Credentials. + */ + data: Prisma.XOR + /** + * Filter which Credentials to update + */ + where?: Prisma.CredentialWhereInput + /** + * Limit how many Credentials to update. + */ + limit?: number +} + +/** + * Credential updateManyAndReturn + */ +export type CredentialUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * The data used to update Credentials. + */ + data: Prisma.XOR + /** + * Filter which Credentials to update + */ + where?: Prisma.CredentialWhereInput + /** + * Limit how many Credentials to update. + */ + limit?: number + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialIncludeUpdateManyAndReturn | null +} + +/** + * Credential upsert + */ +export type CredentialUpsertArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * The filter to search for the Credential to update in case it exists. + */ + where: Prisma.CredentialWhereUniqueInput + /** + * In case the Credential found by the `where` argument doesn't exist, create a new Credential with this data. + */ + create: Prisma.XOR + /** + * In case the Credential was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * Credential delete + */ +export type CredentialDeleteArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + /** + * Filter which Credential to delete. + */ + where: Prisma.CredentialWhereUniqueInput +} + +/** + * Credential deleteMany + */ +export type CredentialDeleteManyArgs = { + /** + * Filter which Credentials to delete + */ + where?: Prisma.CredentialWhereInput + /** + * Limit how many Credentials to delete. + */ + limit?: number +} + +/** + * Credential.securevalues + */ +export type Credential$securevaluesArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + where?: Prisma.SecureValueWhereInput + orderBy?: Prisma.SecureValueOrderByWithRelationInput | Prisma.SecureValueOrderByWithRelationInput[] + cursor?: Prisma.SecureValueWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.SecureValueScalarFieldEnum | Prisma.SecureValueScalarFieldEnum[] +} + +/** + * Credential without action + */ +export type CredentialDefaultArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null +} diff --git a/generated/prisma/models/CredentialType.ts b/generated/prisma/models/CredentialType.ts new file mode 100644 index 0000000..4ba7b98 --- /dev/null +++ b/generated/prisma/models/CredentialType.ts @@ -0,0 +1,1380 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `CredentialType` 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 CredentialType + * + */ +export type CredentialTypeModel = runtime.Types.Result.DefaultSelection + +export type AggregateCredentialType = { + _count: CredentialTypeCountAggregateOutputType | null + _min: CredentialTypeMinAggregateOutputType | null + _max: CredentialTypeMaxAggregateOutputType | null +} + +export type CredentialTypeMinAggregateOutputType = { + id: string | null + name: string | null + permissionScope: string | null + icon: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type CredentialTypeMaxAggregateOutputType = { + id: string | null + name: string | null + permissionScope: string | null + icon: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type CredentialTypeCountAggregateOutputType = { + id: number + name: number + permissionScope: number + icon: number + fields: number + createdAt: number + updatedAt: number + _all: number +} + + +export type CredentialTypeMinAggregateInputType = { + id?: true + name?: true + permissionScope?: true + icon?: true + createdAt?: true + updatedAt?: true +} + +export type CredentialTypeMaxAggregateInputType = { + id?: true + name?: true + permissionScope?: true + icon?: true + createdAt?: true + updatedAt?: true +} + +export type CredentialTypeCountAggregateInputType = { + id?: true + name?: true + permissionScope?: true + icon?: true + fields?: true + createdAt?: true + updatedAt?: true + _all?: true +} + +export type CredentialTypeAggregateArgs = { + /** + * Filter which CredentialType to aggregate. + */ + where?: Prisma.CredentialTypeWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of CredentialTypes to fetch. + */ + orderBy?: Prisma.CredentialTypeOrderByWithRelationInput | Prisma.CredentialTypeOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.CredentialTypeWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` CredentialTypes 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` CredentialTypes. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned CredentialTypes + **/ + _count?: true | CredentialTypeCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: CredentialTypeMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: CredentialTypeMaxAggregateInputType +} + +export type GetCredentialTypeAggregateType = { + [P in keyof T & keyof AggregateCredentialType]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type CredentialTypeGroupByArgs = { + where?: Prisma.CredentialTypeWhereInput + orderBy?: Prisma.CredentialTypeOrderByWithAggregationInput | Prisma.CredentialTypeOrderByWithAggregationInput[] + by: Prisma.CredentialTypeScalarFieldEnum[] | Prisma.CredentialTypeScalarFieldEnum + having?: Prisma.CredentialTypeScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: CredentialTypeCountAggregateInputType | true + _min?: CredentialTypeMinAggregateInputType + _max?: CredentialTypeMaxAggregateInputType +} + +export type CredentialTypeGroupByOutputType = { + id: string + name: string + permissionScope: string + icon: string | null + fields: runtime.JsonValue + createdAt: Date + updatedAt: Date + _count: CredentialTypeCountAggregateOutputType | null + _min: CredentialTypeMinAggregateOutputType | null + _max: CredentialTypeMaxAggregateOutputType | null +} + +type GetCredentialTypeGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof CredentialTypeGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type CredentialTypeWhereInput = { + AND?: Prisma.CredentialTypeWhereInput | Prisma.CredentialTypeWhereInput[] + OR?: Prisma.CredentialTypeWhereInput[] + NOT?: Prisma.CredentialTypeWhereInput | Prisma.CredentialTypeWhereInput[] + id?: Prisma.StringFilter<"CredentialType"> | string + name?: Prisma.StringFilter<"CredentialType"> | string + permissionScope?: Prisma.StringFilter<"CredentialType"> | string + icon?: Prisma.StringNullableFilter<"CredentialType"> | string | null + fields?: Prisma.JsonFilter<"CredentialType"> + createdAt?: Prisma.DateTimeFilter<"CredentialType"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"CredentialType"> | Date | string + credentials?: Prisma.CredentialListRelationFilter +} + +export type CredentialTypeOrderByWithRelationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + permissionScope?: Prisma.SortOrder + icon?: Prisma.SortOrderInput | Prisma.SortOrder + fields?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + credentials?: Prisma.CredentialOrderByRelationAggregateInput +} + +export type CredentialTypeWhereUniqueInput = Prisma.AtLeast<{ + id?: string + name?: string + AND?: Prisma.CredentialTypeWhereInput | Prisma.CredentialTypeWhereInput[] + OR?: Prisma.CredentialTypeWhereInput[] + NOT?: Prisma.CredentialTypeWhereInput | Prisma.CredentialTypeWhereInput[] + permissionScope?: Prisma.StringFilter<"CredentialType"> | string + icon?: Prisma.StringNullableFilter<"CredentialType"> | string | null + fields?: Prisma.JsonFilter<"CredentialType"> + createdAt?: Prisma.DateTimeFilter<"CredentialType"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"CredentialType"> | Date | string + credentials?: Prisma.CredentialListRelationFilter +}, "id" | "name"> + +export type CredentialTypeOrderByWithAggregationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + permissionScope?: Prisma.SortOrder + icon?: Prisma.SortOrderInput | Prisma.SortOrder + fields?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + _count?: Prisma.CredentialTypeCountOrderByAggregateInput + _max?: Prisma.CredentialTypeMaxOrderByAggregateInput + _min?: Prisma.CredentialTypeMinOrderByAggregateInput +} + +export type CredentialTypeScalarWhereWithAggregatesInput = { + AND?: Prisma.CredentialTypeScalarWhereWithAggregatesInput | Prisma.CredentialTypeScalarWhereWithAggregatesInput[] + OR?: Prisma.CredentialTypeScalarWhereWithAggregatesInput[] + NOT?: Prisma.CredentialTypeScalarWhereWithAggregatesInput | Prisma.CredentialTypeScalarWhereWithAggregatesInput[] + id?: Prisma.StringWithAggregatesFilter<"CredentialType"> | string + name?: Prisma.StringWithAggregatesFilter<"CredentialType"> | string + permissionScope?: Prisma.StringWithAggregatesFilter<"CredentialType"> | string + icon?: Prisma.StringNullableWithAggregatesFilter<"CredentialType"> | string | null + fields?: Prisma.JsonWithAggregatesFilter<"CredentialType"> + createdAt?: Prisma.DateTimeWithAggregatesFilter<"CredentialType"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"CredentialType"> | Date | string +} + +export type CredentialTypeCreateInput = { + id?: string + name: string + permissionScope: string + icon?: string | null + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string + credentials?: Prisma.CredentialCreateNestedManyWithoutTypeInput +} + +export type CredentialTypeUncheckedCreateInput = { + id?: string + name: string + permissionScope: string + icon?: string | null + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string + credentials?: Prisma.CredentialUncheckedCreateNestedManyWithoutTypeInput +} + +export type CredentialTypeUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + permissionScope?: Prisma.StringFieldUpdateOperationsInput | string + icon?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + credentials?: Prisma.CredentialUpdateManyWithoutTypeNestedInput +} + +export type CredentialTypeUncheckedUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + permissionScope?: Prisma.StringFieldUpdateOperationsInput | string + icon?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + credentials?: Prisma.CredentialUncheckedUpdateManyWithoutTypeNestedInput +} + +export type CredentialTypeCreateManyInput = { + id?: string + name: string + permissionScope: string + icon?: string | null + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CredentialTypeUpdateManyMutationInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + permissionScope?: Prisma.StringFieldUpdateOperationsInput | string + icon?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CredentialTypeUncheckedUpdateManyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + permissionScope?: Prisma.StringFieldUpdateOperationsInput | string + icon?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CredentialTypeCountOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + permissionScope?: Prisma.SortOrder + icon?: Prisma.SortOrder + fields?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type CredentialTypeMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + permissionScope?: Prisma.SortOrder + icon?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type CredentialTypeMinOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + permissionScope?: Prisma.SortOrder + icon?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type CredentialTypeScalarRelationFilter = { + is?: Prisma.CredentialTypeWhereInput + isNot?: Prisma.CredentialTypeWhereInput +} + +export type CredentialTypeCreateNestedOneWithoutCredentialsInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.CredentialTypeCreateOrConnectWithoutCredentialsInput + connect?: Prisma.CredentialTypeWhereUniqueInput +} + +export type CredentialTypeUpdateOneRequiredWithoutCredentialsNestedInput = { + create?: Prisma.XOR + connectOrCreate?: Prisma.CredentialTypeCreateOrConnectWithoutCredentialsInput + upsert?: Prisma.CredentialTypeUpsertWithoutCredentialsInput + connect?: Prisma.CredentialTypeWhereUniqueInput + update?: Prisma.XOR, Prisma.CredentialTypeUncheckedUpdateWithoutCredentialsInput> +} + +export type CredentialTypeCreateWithoutCredentialsInput = { + id?: string + name: string + permissionScope: string + icon?: string | null + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CredentialTypeUncheckedCreateWithoutCredentialsInput = { + id?: string + name: string + permissionScope: string + icon?: string | null + fields: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Date | string + updatedAt?: Date | string +} + +export type CredentialTypeCreateOrConnectWithoutCredentialsInput = { + where: Prisma.CredentialTypeWhereUniqueInput + create: Prisma.XOR +} + +export type CredentialTypeUpsertWithoutCredentialsInput = { + update: Prisma.XOR + create: Prisma.XOR + where?: Prisma.CredentialTypeWhereInput +} + +export type CredentialTypeUpdateToOneWithWhereWithoutCredentialsInput = { + where?: Prisma.CredentialTypeWhereInput + data: Prisma.XOR +} + +export type CredentialTypeUpdateWithoutCredentialsInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + permissionScope?: Prisma.StringFieldUpdateOperationsInput | string + icon?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type CredentialTypeUncheckedUpdateWithoutCredentialsInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + permissionScope?: Prisma.StringFieldUpdateOperationsInput | string + icon?: Prisma.NullableStringFieldUpdateOperationsInput | string | null + fields?: Prisma.JsonNullValueInput | runtime.InputJsonValue + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + + +/** + * Count Type CredentialTypeCountOutputType + */ + +export type CredentialTypeCountOutputType = { + credentials: number +} + +export type CredentialTypeCountOutputTypeSelect = { + credentials?: boolean | CredentialTypeCountOutputTypeCountCredentialsArgs +} + +/** + * CredentialTypeCountOutputType without action + */ +export type CredentialTypeCountOutputTypeDefaultArgs = { + /** + * Select specific fields to fetch from the CredentialTypeCountOutputType + */ + select?: Prisma.CredentialTypeCountOutputTypeSelect | null +} + +/** + * CredentialTypeCountOutputType without action + */ +export type CredentialTypeCountOutputTypeCountCredentialsArgs = { + where?: Prisma.CredentialWhereInput +} + + +export type CredentialTypeSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + permissionScope?: boolean + icon?: boolean + fields?: boolean + createdAt?: boolean + updatedAt?: boolean + credentials?: boolean | Prisma.CredentialType$credentialsArgs + _count?: boolean | Prisma.CredentialTypeCountOutputTypeDefaultArgs +}, ExtArgs["result"]["credentialType"]> + +export type CredentialTypeSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + permissionScope?: boolean + icon?: boolean + fields?: boolean + createdAt?: boolean + updatedAt?: boolean +}, ExtArgs["result"]["credentialType"]> + +export type CredentialTypeSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + permissionScope?: boolean + icon?: boolean + fields?: boolean + createdAt?: boolean + updatedAt?: boolean +}, ExtArgs["result"]["credentialType"]> + +export type CredentialTypeSelectScalar = { + id?: boolean + name?: boolean + permissionScope?: boolean + icon?: boolean + fields?: boolean + createdAt?: boolean + updatedAt?: boolean +} + +export type CredentialTypeOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "permissionScope" | "icon" | "fields" | "createdAt" | "updatedAt", ExtArgs["result"]["credentialType"]> +export type CredentialTypeInclude = { + credentials?: boolean | Prisma.CredentialType$credentialsArgs + _count?: boolean | Prisma.CredentialTypeCountOutputTypeDefaultArgs +} +export type CredentialTypeIncludeCreateManyAndReturn = {} +export type CredentialTypeIncludeUpdateManyAndReturn = {} + +export type $CredentialTypePayload = { + name: "CredentialType" + objects: { + credentials: Prisma.$CredentialPayload[] + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: string + name: string + permissionScope: string + icon: string | null + fields: runtime.JsonValue + createdAt: Date + updatedAt: Date + }, ExtArgs["result"]["credentialType"]> + composites: {} +} + +export type CredentialTypeGetPayload = runtime.Types.Result.GetResult + +export type CredentialTypeCountArgs = + Omit & { + select?: CredentialTypeCountAggregateInputType | true + } + +export interface CredentialTypeDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['CredentialType'], meta: { name: 'CredentialType' } } + /** + * Find zero or one CredentialType that matches the filter. + * @param {CredentialTypeFindUniqueArgs} args - Arguments to find a CredentialType + * @example + * // Get one CredentialType + * const credentialType = await prisma.credentialType.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one CredentialType that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {CredentialTypeFindUniqueOrThrowArgs} args - Arguments to find a CredentialType + * @example + * // Get one CredentialType + * const credentialType = await prisma.credentialType.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first CredentialType 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 {CredentialTypeFindFirstArgs} args - Arguments to find a CredentialType + * @example + * // Get one CredentialType + * const credentialType = await prisma.credentialType.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first CredentialType 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 {CredentialTypeFindFirstOrThrowArgs} args - Arguments to find a CredentialType + * @example + * // Get one CredentialType + * const credentialType = await prisma.credentialType.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more CredentialTypes 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 {CredentialTypeFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all CredentialTypes + * const credentialTypes = await prisma.credentialType.findMany() + * + * // Get first 10 CredentialTypes + * const credentialTypes = await prisma.credentialType.findMany({ take: 10 }) + * + * // Only select the `id` + * const credentialTypeWithIdOnly = await prisma.credentialType.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a CredentialType. + * @param {CredentialTypeCreateArgs} args - Arguments to create a CredentialType. + * @example + * // Create one CredentialType + * const CredentialType = await prisma.credentialType.create({ + * data: { + * // ... data to create a CredentialType + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many CredentialTypes. + * @param {CredentialTypeCreateManyArgs} args - Arguments to create many CredentialTypes. + * @example + * // Create many CredentialTypes + * const credentialType = await prisma.credentialType.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many CredentialTypes and returns the data saved in the database. + * @param {CredentialTypeCreateManyAndReturnArgs} args - Arguments to create many CredentialTypes. + * @example + * // Create many CredentialTypes + * const credentialType = await prisma.credentialType.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many CredentialTypes and only return the `id` + * const credentialTypeWithIdOnly = await prisma.credentialType.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 CredentialType. + * @param {CredentialTypeDeleteArgs} args - Arguments to delete one CredentialType. + * @example + * // Delete one CredentialType + * const CredentialType = await prisma.credentialType.delete({ + * where: { + * // ... filter to delete one CredentialType + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one CredentialType. + * @param {CredentialTypeUpdateArgs} args - Arguments to update one CredentialType. + * @example + * // Update one CredentialType + * const credentialType = await prisma.credentialType.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more CredentialTypes. + * @param {CredentialTypeDeleteManyArgs} args - Arguments to filter CredentialTypes to delete. + * @example + * // Delete a few CredentialTypes + * const { count } = await prisma.credentialType.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more CredentialTypes. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialTypeUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many CredentialTypes + * const credentialType = await prisma.credentialType.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more CredentialTypes and returns the data updated in the database. + * @param {CredentialTypeUpdateManyAndReturnArgs} args - Arguments to update many CredentialTypes. + * @example + * // Update many CredentialTypes + * const credentialType = await prisma.credentialType.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more CredentialTypes and only return the `id` + * const credentialTypeWithIdOnly = await prisma.credentialType.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 CredentialType. + * @param {CredentialTypeUpsertArgs} args - Arguments to update or create a CredentialType. + * @example + * // Update or create a CredentialType + * const credentialType = await prisma.credentialType.upsert({ + * create: { + * // ... data to create a CredentialType + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the CredentialType we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__CredentialTypeClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of CredentialTypes. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialTypeCountArgs} args - Arguments to filter CredentialTypes to count. + * @example + * // Count the number of CredentialTypes + * const count = await prisma.credentialType.count({ + * where: { + * // ... the filter for the CredentialTypes 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 CredentialType. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialTypeAggregateArgs} 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 CredentialType. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {CredentialTypeGroupByArgs} 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 CredentialTypeGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: CredentialTypeGroupByArgs['orderBy'] } + : { orderBy?: CredentialTypeGroupByArgs['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 ? GetCredentialTypeGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the CredentialType model + */ +readonly fields: CredentialTypeFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for CredentialType. + * 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__CredentialTypeClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + credentials = {}>(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 CredentialType model + */ +export interface CredentialTypeFieldRefs { + readonly id: Prisma.FieldRef<"CredentialType", 'String'> + readonly name: Prisma.FieldRef<"CredentialType", 'String'> + readonly permissionScope: Prisma.FieldRef<"CredentialType", 'String'> + readonly icon: Prisma.FieldRef<"CredentialType", 'String'> + readonly fields: Prisma.FieldRef<"CredentialType", 'Json'> + readonly createdAt: Prisma.FieldRef<"CredentialType", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"CredentialType", 'DateTime'> +} + + +// Custom InputTypes +/** + * CredentialType findUnique + */ +export type CredentialTypeFindUniqueArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * Filter, which CredentialType to fetch. + */ + where: Prisma.CredentialTypeWhereUniqueInput +} + +/** + * CredentialType findUniqueOrThrow + */ +export type CredentialTypeFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * Filter, which CredentialType to fetch. + */ + where: Prisma.CredentialTypeWhereUniqueInput +} + +/** + * CredentialType findFirst + */ +export type CredentialTypeFindFirstArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * Filter, which CredentialType to fetch. + */ + where?: Prisma.CredentialTypeWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of CredentialTypes to fetch. + */ + orderBy?: Prisma.CredentialTypeOrderByWithRelationInput | Prisma.CredentialTypeOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for CredentialTypes. + */ + cursor?: Prisma.CredentialTypeWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` CredentialTypes 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` CredentialTypes. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of CredentialTypes. + */ + distinct?: Prisma.CredentialTypeScalarFieldEnum | Prisma.CredentialTypeScalarFieldEnum[] +} + +/** + * CredentialType findFirstOrThrow + */ +export type CredentialTypeFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * Filter, which CredentialType to fetch. + */ + where?: Prisma.CredentialTypeWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of CredentialTypes to fetch. + */ + orderBy?: Prisma.CredentialTypeOrderByWithRelationInput | Prisma.CredentialTypeOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for CredentialTypes. + */ + cursor?: Prisma.CredentialTypeWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` CredentialTypes 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` CredentialTypes. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of CredentialTypes. + */ + distinct?: Prisma.CredentialTypeScalarFieldEnum | Prisma.CredentialTypeScalarFieldEnum[] +} + +/** + * CredentialType findMany + */ +export type CredentialTypeFindManyArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * Filter, which CredentialTypes to fetch. + */ + where?: Prisma.CredentialTypeWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of CredentialTypes to fetch. + */ + orderBy?: Prisma.CredentialTypeOrderByWithRelationInput | Prisma.CredentialTypeOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing CredentialTypes. + */ + cursor?: Prisma.CredentialTypeWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` CredentialTypes 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` CredentialTypes. + */ + skip?: number + distinct?: Prisma.CredentialTypeScalarFieldEnum | Prisma.CredentialTypeScalarFieldEnum[] +} + +/** + * CredentialType create + */ +export type CredentialTypeCreateArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * The data needed to create a CredentialType. + */ + data: Prisma.XOR +} + +/** + * CredentialType createMany + */ +export type CredentialTypeCreateManyArgs = { + /** + * The data used to create many CredentialTypes. + */ + data: Prisma.CredentialTypeCreateManyInput | Prisma.CredentialTypeCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * CredentialType createManyAndReturn + */ +export type CredentialTypeCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelectCreateManyAndReturn | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * The data used to create many CredentialTypes. + */ + data: Prisma.CredentialTypeCreateManyInput | Prisma.CredentialTypeCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * CredentialType update + */ +export type CredentialTypeUpdateArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * The data needed to update a CredentialType. + */ + data: Prisma.XOR + /** + * Choose, which CredentialType to update. + */ + where: Prisma.CredentialTypeWhereUniqueInput +} + +/** + * CredentialType updateMany + */ +export type CredentialTypeUpdateManyArgs = { + /** + * The data used to update CredentialTypes. + */ + data: Prisma.XOR + /** + * Filter which CredentialTypes to update + */ + where?: Prisma.CredentialTypeWhereInput + /** + * Limit how many CredentialTypes to update. + */ + limit?: number +} + +/** + * CredentialType updateManyAndReturn + */ +export type CredentialTypeUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * The data used to update CredentialTypes. + */ + data: Prisma.XOR + /** + * Filter which CredentialTypes to update + */ + where?: Prisma.CredentialTypeWhereInput + /** + * Limit how many CredentialTypes to update. + */ + limit?: number +} + +/** + * CredentialType upsert + */ +export type CredentialTypeUpsertArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * The filter to search for the CredentialType to update in case it exists. + */ + where: Prisma.CredentialTypeWhereUniqueInput + /** + * In case the CredentialType found by the `where` argument doesn't exist, create a new CredentialType with this data. + */ + create: Prisma.XOR + /** + * In case the CredentialType was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * CredentialType delete + */ +export type CredentialTypeDeleteArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null + /** + * Filter which CredentialType to delete. + */ + where: Prisma.CredentialTypeWhereUniqueInput +} + +/** + * CredentialType deleteMany + */ +export type CredentialTypeDeleteManyArgs = { + /** + * Filter which CredentialTypes to delete + */ + where?: Prisma.CredentialTypeWhereInput + /** + * Limit how many CredentialTypes to delete. + */ + limit?: number +} + +/** + * CredentialType.credentials + */ +export type CredentialType$credentialsArgs = { + /** + * Select specific fields to fetch from the Credential + */ + select?: Prisma.CredentialSelect | null + /** + * Omit specific fields from the Credential + */ + omit?: Prisma.CredentialOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialInclude | null + where?: Prisma.CredentialWhereInput + orderBy?: Prisma.CredentialOrderByWithRelationInput | Prisma.CredentialOrderByWithRelationInput[] + cursor?: Prisma.CredentialWhereUniqueInput + take?: number + skip?: number + distinct?: Prisma.CredentialScalarFieldEnum | Prisma.CredentialScalarFieldEnum[] +} + +/** + * CredentialType without action + */ +export type CredentialTypeDefaultArgs = { + /** + * Select specific fields to fetch from the CredentialType + */ + select?: Prisma.CredentialTypeSelect | null + /** + * Omit specific fields from the CredentialType + */ + omit?: Prisma.CredentialTypeOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.CredentialTypeInclude | null +} diff --git a/generated/prisma/models/SecureValue.ts b/generated/prisma/models/SecureValue.ts new file mode 100644 index 0000000..9a3ae23 --- /dev/null +++ b/generated/prisma/models/SecureValue.ts @@ -0,0 +1,1410 @@ + +/* !!! This is code generated by Prisma. Do not edit directly. !!! */ +/* eslint-disable */ +// biome-ignore-all lint: generated file +// @ts-nocheck +/* + * This file exports the `SecureValue` 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 SecureValue + * + */ +export type SecureValueModel = runtime.Types.Result.DefaultSelection + +export type AggregateSecureValue = { + _count: SecureValueCountAggregateOutputType | null + _min: SecureValueMinAggregateOutputType | null + _max: SecureValueMaxAggregateOutputType | null +} + +export type SecureValueMinAggregateOutputType = { + id: string | null + name: string | null + content: string | null + hash: string | null + credentialId: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type SecureValueMaxAggregateOutputType = { + id: string | null + name: string | null + content: string | null + hash: string | null + credentialId: string | null + createdAt: Date | null + updatedAt: Date | null +} + +export type SecureValueCountAggregateOutputType = { + id: number + name: number + content: number + hash: number + credentialId: number + createdAt: number + updatedAt: number + _all: number +} + + +export type SecureValueMinAggregateInputType = { + id?: true + name?: true + content?: true + hash?: true + credentialId?: true + createdAt?: true + updatedAt?: true +} + +export type SecureValueMaxAggregateInputType = { + id?: true + name?: true + content?: true + hash?: true + credentialId?: true + createdAt?: true + updatedAt?: true +} + +export type SecureValueCountAggregateInputType = { + id?: true + name?: true + content?: true + hash?: true + credentialId?: true + createdAt?: true + updatedAt?: true + _all?: true +} + +export type SecureValueAggregateArgs = { + /** + * Filter which SecureValue to aggregate. + */ + where?: Prisma.SecureValueWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of SecureValues to fetch. + */ + orderBy?: Prisma.SecureValueOrderByWithRelationInput | Prisma.SecureValueOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the start position + */ + cursor?: Prisma.SecureValueWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` SecureValues 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` SecureValues. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Count returned SecureValues + **/ + _count?: true | SecureValueCountAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the minimum value + **/ + _min?: SecureValueMinAggregateInputType + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/aggregations Aggregation Docs} + * + * Select which fields to find the maximum value + **/ + _max?: SecureValueMaxAggregateInputType +} + +export type GetSecureValueAggregateType = { + [P in keyof T & keyof AggregateSecureValue]: P extends '_count' | 'count' + ? T[P] extends true + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType +} + + + + +export type SecureValueGroupByArgs = { + where?: Prisma.SecureValueWhereInput + orderBy?: Prisma.SecureValueOrderByWithAggregationInput | Prisma.SecureValueOrderByWithAggregationInput[] + by: Prisma.SecureValueScalarFieldEnum[] | Prisma.SecureValueScalarFieldEnum + having?: Prisma.SecureValueScalarWhereWithAggregatesInput + take?: number + skip?: number + _count?: SecureValueCountAggregateInputType | true + _min?: SecureValueMinAggregateInputType + _max?: SecureValueMaxAggregateInputType +} + +export type SecureValueGroupByOutputType = { + id: string + name: string + content: string + hash: string + credentialId: string + createdAt: Date + updatedAt: Date + _count: SecureValueCountAggregateOutputType | null + _min: SecureValueMinAggregateOutputType | null + _max: SecureValueMaxAggregateOutputType | null +} + +type GetSecureValueGroupByPayload = Prisma.PrismaPromise< + Array< + Prisma.PickEnumerable & + { + [P in ((keyof T) & (keyof SecureValueGroupByOutputType))]: P extends '_count' + ? T[P] extends boolean + ? number + : Prisma.GetScalarType + : Prisma.GetScalarType + } + > + > + + + +export type SecureValueWhereInput = { + AND?: Prisma.SecureValueWhereInput | Prisma.SecureValueWhereInput[] + OR?: Prisma.SecureValueWhereInput[] + NOT?: Prisma.SecureValueWhereInput | Prisma.SecureValueWhereInput[] + id?: Prisma.StringFilter<"SecureValue"> | string + name?: Prisma.StringFilter<"SecureValue"> | string + content?: Prisma.StringFilter<"SecureValue"> | string + hash?: Prisma.StringFilter<"SecureValue"> | string + credentialId?: Prisma.StringFilter<"SecureValue"> | string + createdAt?: Prisma.DateTimeFilter<"SecureValue"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"SecureValue"> | Date | string + credential?: Prisma.XOR +} + +export type SecureValueOrderByWithRelationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + content?: Prisma.SortOrder + hash?: Prisma.SortOrder + credentialId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + credential?: Prisma.CredentialOrderByWithRelationInput +} + +export type SecureValueWhereUniqueInput = Prisma.AtLeast<{ + id?: string + AND?: Prisma.SecureValueWhereInput | Prisma.SecureValueWhereInput[] + OR?: Prisma.SecureValueWhereInput[] + NOT?: Prisma.SecureValueWhereInput | Prisma.SecureValueWhereInput[] + name?: Prisma.StringFilter<"SecureValue"> | string + content?: Prisma.StringFilter<"SecureValue"> | string + hash?: Prisma.StringFilter<"SecureValue"> | string + credentialId?: Prisma.StringFilter<"SecureValue"> | string + createdAt?: Prisma.DateTimeFilter<"SecureValue"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"SecureValue"> | Date | string + credential?: Prisma.XOR +}, "id"> + +export type SecureValueOrderByWithAggregationInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + content?: Prisma.SortOrder + hash?: Prisma.SortOrder + credentialId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder + _count?: Prisma.SecureValueCountOrderByAggregateInput + _max?: Prisma.SecureValueMaxOrderByAggregateInput + _min?: Prisma.SecureValueMinOrderByAggregateInput +} + +export type SecureValueScalarWhereWithAggregatesInput = { + AND?: Prisma.SecureValueScalarWhereWithAggregatesInput | Prisma.SecureValueScalarWhereWithAggregatesInput[] + OR?: Prisma.SecureValueScalarWhereWithAggregatesInput[] + NOT?: Prisma.SecureValueScalarWhereWithAggregatesInput | Prisma.SecureValueScalarWhereWithAggregatesInput[] + id?: Prisma.StringWithAggregatesFilter<"SecureValue"> | string + name?: Prisma.StringWithAggregatesFilter<"SecureValue"> | string + content?: Prisma.StringWithAggregatesFilter<"SecureValue"> | string + hash?: Prisma.StringWithAggregatesFilter<"SecureValue"> | string + credentialId?: Prisma.StringWithAggregatesFilter<"SecureValue"> | string + createdAt?: Prisma.DateTimeWithAggregatesFilter<"SecureValue"> | Date | string + updatedAt?: Prisma.DateTimeWithAggregatesFilter<"SecureValue"> | Date | string +} + +export type SecureValueCreateInput = { + id?: string + name: string + content: string + hash: string + createdAt?: Date | string + updatedAt?: Date | string + credential: Prisma.CredentialCreateNestedOneWithoutSecurevaluesInput +} + +export type SecureValueUncheckedCreateInput = { + id?: string + name: string + content: string + hash: string + credentialId: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type SecureValueUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + content?: Prisma.StringFieldUpdateOperationsInput | string + hash?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + credential?: Prisma.CredentialUpdateOneRequiredWithoutSecurevaluesNestedInput +} + +export type SecureValueUncheckedUpdateInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + content?: Prisma.StringFieldUpdateOperationsInput | string + hash?: Prisma.StringFieldUpdateOperationsInput | string + credentialId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type SecureValueCreateManyInput = { + id?: string + name: string + content: string + hash: string + credentialId: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type SecureValueUpdateManyMutationInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + content?: Prisma.StringFieldUpdateOperationsInput | string + hash?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type SecureValueUncheckedUpdateManyInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + content?: Prisma.StringFieldUpdateOperationsInput | string + hash?: Prisma.StringFieldUpdateOperationsInput | string + credentialId?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type SecureValueCountOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + content?: Prisma.SortOrder + hash?: Prisma.SortOrder + credentialId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type SecureValueMaxOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + content?: Prisma.SortOrder + hash?: Prisma.SortOrder + credentialId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type SecureValueMinOrderByAggregateInput = { + id?: Prisma.SortOrder + name?: Prisma.SortOrder + content?: Prisma.SortOrder + hash?: Prisma.SortOrder + credentialId?: Prisma.SortOrder + createdAt?: Prisma.SortOrder + updatedAt?: Prisma.SortOrder +} + +export type SecureValueListRelationFilter = { + every?: Prisma.SecureValueWhereInput + some?: Prisma.SecureValueWhereInput + none?: Prisma.SecureValueWhereInput +} + +export type SecureValueOrderByRelationAggregateInput = { + _count?: Prisma.SortOrder +} + +export type SecureValueCreateNestedManyWithoutCredentialInput = { + create?: Prisma.XOR | Prisma.SecureValueCreateWithoutCredentialInput[] | Prisma.SecureValueUncheckedCreateWithoutCredentialInput[] + connectOrCreate?: Prisma.SecureValueCreateOrConnectWithoutCredentialInput | Prisma.SecureValueCreateOrConnectWithoutCredentialInput[] + createMany?: Prisma.SecureValueCreateManyCredentialInputEnvelope + connect?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] +} + +export type SecureValueUncheckedCreateNestedManyWithoutCredentialInput = { + create?: Prisma.XOR | Prisma.SecureValueCreateWithoutCredentialInput[] | Prisma.SecureValueUncheckedCreateWithoutCredentialInput[] + connectOrCreate?: Prisma.SecureValueCreateOrConnectWithoutCredentialInput | Prisma.SecureValueCreateOrConnectWithoutCredentialInput[] + createMany?: Prisma.SecureValueCreateManyCredentialInputEnvelope + connect?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] +} + +export type SecureValueUpdateManyWithoutCredentialNestedInput = { + create?: Prisma.XOR | Prisma.SecureValueCreateWithoutCredentialInput[] | Prisma.SecureValueUncheckedCreateWithoutCredentialInput[] + connectOrCreate?: Prisma.SecureValueCreateOrConnectWithoutCredentialInput | Prisma.SecureValueCreateOrConnectWithoutCredentialInput[] + upsert?: Prisma.SecureValueUpsertWithWhereUniqueWithoutCredentialInput | Prisma.SecureValueUpsertWithWhereUniqueWithoutCredentialInput[] + createMany?: Prisma.SecureValueCreateManyCredentialInputEnvelope + set?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + disconnect?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + delete?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + connect?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + update?: Prisma.SecureValueUpdateWithWhereUniqueWithoutCredentialInput | Prisma.SecureValueUpdateWithWhereUniqueWithoutCredentialInput[] + updateMany?: Prisma.SecureValueUpdateManyWithWhereWithoutCredentialInput | Prisma.SecureValueUpdateManyWithWhereWithoutCredentialInput[] + deleteMany?: Prisma.SecureValueScalarWhereInput | Prisma.SecureValueScalarWhereInput[] +} + +export type SecureValueUncheckedUpdateManyWithoutCredentialNestedInput = { + create?: Prisma.XOR | Prisma.SecureValueCreateWithoutCredentialInput[] | Prisma.SecureValueUncheckedCreateWithoutCredentialInput[] + connectOrCreate?: Prisma.SecureValueCreateOrConnectWithoutCredentialInput | Prisma.SecureValueCreateOrConnectWithoutCredentialInput[] + upsert?: Prisma.SecureValueUpsertWithWhereUniqueWithoutCredentialInput | Prisma.SecureValueUpsertWithWhereUniqueWithoutCredentialInput[] + createMany?: Prisma.SecureValueCreateManyCredentialInputEnvelope + set?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + disconnect?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + delete?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + connect?: Prisma.SecureValueWhereUniqueInput | Prisma.SecureValueWhereUniqueInput[] + update?: Prisma.SecureValueUpdateWithWhereUniqueWithoutCredentialInput | Prisma.SecureValueUpdateWithWhereUniqueWithoutCredentialInput[] + updateMany?: Prisma.SecureValueUpdateManyWithWhereWithoutCredentialInput | Prisma.SecureValueUpdateManyWithWhereWithoutCredentialInput[] + deleteMany?: Prisma.SecureValueScalarWhereInput | Prisma.SecureValueScalarWhereInput[] +} + +export type SecureValueCreateWithoutCredentialInput = { + id?: string + name: string + content: string + hash: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type SecureValueUncheckedCreateWithoutCredentialInput = { + id?: string + name: string + content: string + hash: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type SecureValueCreateOrConnectWithoutCredentialInput = { + where: Prisma.SecureValueWhereUniqueInput + create: Prisma.XOR +} + +export type SecureValueCreateManyCredentialInputEnvelope = { + data: Prisma.SecureValueCreateManyCredentialInput | Prisma.SecureValueCreateManyCredentialInput[] + skipDuplicates?: boolean +} + +export type SecureValueUpsertWithWhereUniqueWithoutCredentialInput = { + where: Prisma.SecureValueWhereUniqueInput + update: Prisma.XOR + create: Prisma.XOR +} + +export type SecureValueUpdateWithWhereUniqueWithoutCredentialInput = { + where: Prisma.SecureValueWhereUniqueInput + data: Prisma.XOR +} + +export type SecureValueUpdateManyWithWhereWithoutCredentialInput = { + where: Prisma.SecureValueScalarWhereInput + data: Prisma.XOR +} + +export type SecureValueScalarWhereInput = { + AND?: Prisma.SecureValueScalarWhereInput | Prisma.SecureValueScalarWhereInput[] + OR?: Prisma.SecureValueScalarWhereInput[] + NOT?: Prisma.SecureValueScalarWhereInput | Prisma.SecureValueScalarWhereInput[] + id?: Prisma.StringFilter<"SecureValue"> | string + name?: Prisma.StringFilter<"SecureValue"> | string + content?: Prisma.StringFilter<"SecureValue"> | string + hash?: Prisma.StringFilter<"SecureValue"> | string + credentialId?: Prisma.StringFilter<"SecureValue"> | string + createdAt?: Prisma.DateTimeFilter<"SecureValue"> | Date | string + updatedAt?: Prisma.DateTimeFilter<"SecureValue"> | Date | string +} + +export type SecureValueCreateManyCredentialInput = { + id?: string + name: string + content: string + hash: string + createdAt?: Date | string + updatedAt?: Date | string +} + +export type SecureValueUpdateWithoutCredentialInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + content?: Prisma.StringFieldUpdateOperationsInput | string + hash?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type SecureValueUncheckedUpdateWithoutCredentialInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + content?: Prisma.StringFieldUpdateOperationsInput | string + hash?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + +export type SecureValueUncheckedUpdateManyWithoutCredentialInput = { + id?: Prisma.StringFieldUpdateOperationsInput | string + name?: Prisma.StringFieldUpdateOperationsInput | string + content?: Prisma.StringFieldUpdateOperationsInput | string + hash?: Prisma.StringFieldUpdateOperationsInput | string + createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string + updatedAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string +} + + + +export type SecureValueSelect = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + content?: boolean + hash?: boolean + credentialId?: boolean + createdAt?: boolean + updatedAt?: boolean + credential?: boolean | Prisma.CredentialDefaultArgs +}, ExtArgs["result"]["secureValue"]> + +export type SecureValueSelectCreateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + content?: boolean + hash?: boolean + credentialId?: boolean + createdAt?: boolean + updatedAt?: boolean + credential?: boolean | Prisma.CredentialDefaultArgs +}, ExtArgs["result"]["secureValue"]> + +export type SecureValueSelectUpdateManyAndReturn = runtime.Types.Extensions.GetSelect<{ + id?: boolean + name?: boolean + content?: boolean + hash?: boolean + credentialId?: boolean + createdAt?: boolean + updatedAt?: boolean + credential?: boolean | Prisma.CredentialDefaultArgs +}, ExtArgs["result"]["secureValue"]> + +export type SecureValueSelectScalar = { + id?: boolean + name?: boolean + content?: boolean + hash?: boolean + credentialId?: boolean + createdAt?: boolean + updatedAt?: boolean +} + +export type SecureValueOmit = runtime.Types.Extensions.GetOmit<"id" | "name" | "content" | "hash" | "credentialId" | "createdAt" | "updatedAt", ExtArgs["result"]["secureValue"]> +export type SecureValueInclude = { + credential?: boolean | Prisma.CredentialDefaultArgs +} +export type SecureValueIncludeCreateManyAndReturn = { + credential?: boolean | Prisma.CredentialDefaultArgs +} +export type SecureValueIncludeUpdateManyAndReturn = { + credential?: boolean | Prisma.CredentialDefaultArgs +} + +export type $SecureValuePayload = { + name: "SecureValue" + objects: { + credential: Prisma.$CredentialPayload + } + scalars: runtime.Types.Extensions.GetPayloadResult<{ + id: string + name: string + content: string + hash: string + credentialId: string + createdAt: Date + updatedAt: Date + }, ExtArgs["result"]["secureValue"]> + composites: {} +} + +export type SecureValueGetPayload = runtime.Types.Result.GetResult + +export type SecureValueCountArgs = + Omit & { + select?: SecureValueCountAggregateInputType | true + } + +export interface SecureValueDelegate { + [K: symbol]: { types: Prisma.TypeMap['model']['SecureValue'], meta: { name: 'SecureValue' } } + /** + * Find zero or one SecureValue that matches the filter. + * @param {SecureValueFindUniqueArgs} args - Arguments to find a SecureValue + * @example + * // Get one SecureValue + * const secureValue = await prisma.secureValue.findUnique({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUnique(args: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "findUnique", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find one SecureValue that matches the filter or throw an error with `error.code='P2025'` + * if no matches were found. + * @param {SecureValueFindUniqueOrThrowArgs} args - Arguments to find a SecureValue + * @example + * // Get one SecureValue + * const secureValue = await prisma.secureValue.findUniqueOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findUniqueOrThrow(args: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "findUniqueOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find the first SecureValue 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 {SecureValueFindFirstArgs} args - Arguments to find a SecureValue + * @example + * // Get one SecureValue + * const secureValue = await prisma.secureValue.findFirst({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirst(args?: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "findFirst", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions> + + /** + * Find the first SecureValue 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 {SecureValueFindFirstOrThrowArgs} args - Arguments to find a SecureValue + * @example + * // Get one SecureValue + * const secureValue = await prisma.secureValue.findFirstOrThrow({ + * where: { + * // ... provide filter here + * } + * }) + */ + findFirstOrThrow(args?: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "findFirstOrThrow", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Find zero or more SecureValues 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 {SecureValueFindManyArgs} args - Arguments to filter and select certain fields only. + * @example + * // Get all SecureValues + * const secureValues = await prisma.secureValue.findMany() + * + * // Get first 10 SecureValues + * const secureValues = await prisma.secureValue.findMany({ take: 10 }) + * + * // Only select the `id` + * const secureValueWithIdOnly = await prisma.secureValue.findMany({ select: { id: true } }) + * + */ + findMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise, T, "findMany", GlobalOmitOptions>> + + /** + * Create a SecureValue. + * @param {SecureValueCreateArgs} args - Arguments to create a SecureValue. + * @example + * // Create one SecureValue + * const SecureValue = await prisma.secureValue.create({ + * data: { + * // ... data to create a SecureValue + * } + * }) + * + */ + create(args: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "create", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Create many SecureValues. + * @param {SecureValueCreateManyArgs} args - Arguments to create many SecureValues. + * @example + * // Create many SecureValues + * const secureValue = await prisma.secureValue.createMany({ + * data: [ + * // ... provide data here + * ] + * }) + * + */ + createMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Create many SecureValues and returns the data saved in the database. + * @param {SecureValueCreateManyAndReturnArgs} args - Arguments to create many SecureValues. + * @example + * // Create many SecureValues + * const secureValue = await prisma.secureValue.createManyAndReturn({ + * data: [ + * // ... provide data here + * ] + * }) + * + * // Create many SecureValues and only return the `id` + * const secureValueWithIdOnly = await prisma.secureValue.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 SecureValue. + * @param {SecureValueDeleteArgs} args - Arguments to delete one SecureValue. + * @example + * // Delete one SecureValue + * const SecureValue = await prisma.secureValue.delete({ + * where: { + * // ... filter to delete one SecureValue + * } + * }) + * + */ + delete(args: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "delete", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Update one SecureValue. + * @param {SecureValueUpdateArgs} args - Arguments to update one SecureValue. + * @example + * // Update one SecureValue + * const secureValue = await prisma.secureValue.update({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + update(args: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "update", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + /** + * Delete zero or more SecureValues. + * @param {SecureValueDeleteManyArgs} args - Arguments to filter SecureValues to delete. + * @example + * // Delete a few SecureValues + * const { count } = await prisma.secureValue.deleteMany({ + * where: { + * // ... provide filter here + * } + * }) + * + */ + deleteMany(args?: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more SecureValues. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {SecureValueUpdateManyArgs} args - Arguments to update one or more rows. + * @example + * // Update many SecureValues + * const secureValue = await prisma.secureValue.updateMany({ + * where: { + * // ... provide filter here + * }, + * data: { + * // ... provide data here + * } + * }) + * + */ + updateMany(args: Prisma.SelectSubset>): Prisma.PrismaPromise + + /** + * Update zero or more SecureValues and returns the data updated in the database. + * @param {SecureValueUpdateManyAndReturnArgs} args - Arguments to update many SecureValues. + * @example + * // Update many SecureValues + * const secureValue = await prisma.secureValue.updateManyAndReturn({ + * where: { + * // ... provide filter here + * }, + * data: [ + * // ... provide data here + * ] + * }) + * + * // Update zero or more SecureValues and only return the `id` + * const secureValueWithIdOnly = await prisma.secureValue.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 SecureValue. + * @param {SecureValueUpsertArgs} args - Arguments to update or create a SecureValue. + * @example + * // Update or create a SecureValue + * const secureValue = await prisma.secureValue.upsert({ + * create: { + * // ... data to create a SecureValue + * }, + * update: { + * // ... in case it already exists, update + * }, + * where: { + * // ... the filter for the SecureValue we want to update + * } + * }) + */ + upsert(args: Prisma.SelectSubset>): Prisma.Prisma__SecureValueClient, T, "upsert", GlobalOmitOptions>, never, ExtArgs, GlobalOmitOptions> + + + /** + * Count the number of SecureValues. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {SecureValueCountArgs} args - Arguments to filter SecureValues to count. + * @example + * // Count the number of SecureValues + * const count = await prisma.secureValue.count({ + * where: { + * // ... the filter for the SecureValues 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 SecureValue. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {SecureValueAggregateArgs} 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 SecureValue. + * Note, that providing `undefined` is treated as the value not being there. + * Read more here: https://pris.ly/d/null-undefined + * @param {SecureValueGroupByArgs} 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 SecureValueGroupByArgs, + HasSelectOrTake extends Prisma.Or< + Prisma.Extends<'skip', Prisma.Keys>, + Prisma.Extends<'take', Prisma.Keys> + >, + OrderByArg extends Prisma.True extends HasSelectOrTake + ? { orderBy: SecureValueGroupByArgs['orderBy'] } + : { orderBy?: SecureValueGroupByArgs['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 ? GetSecureValueGroupByPayload : Prisma.PrismaPromise +/** + * Fields of the SecureValue model + */ +readonly fields: SecureValueFieldRefs; +} + +/** + * The delegate class that acts as a "Promise-like" for SecureValue. + * 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__SecureValueClient extends Prisma.PrismaPromise { + readonly [Symbol.toStringTag]: "PrismaPromise" + credential = {}>(args?: Prisma.Subset>): Prisma.Prisma__CredentialClient, 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 SecureValue model + */ +export interface SecureValueFieldRefs { + readonly id: Prisma.FieldRef<"SecureValue", 'String'> + readonly name: Prisma.FieldRef<"SecureValue", 'String'> + readonly content: Prisma.FieldRef<"SecureValue", 'String'> + readonly hash: Prisma.FieldRef<"SecureValue", 'String'> + readonly credentialId: Prisma.FieldRef<"SecureValue", 'String'> + readonly createdAt: Prisma.FieldRef<"SecureValue", 'DateTime'> + readonly updatedAt: Prisma.FieldRef<"SecureValue", 'DateTime'> +} + + +// Custom InputTypes +/** + * SecureValue findUnique + */ +export type SecureValueFindUniqueArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * Filter, which SecureValue to fetch. + */ + where: Prisma.SecureValueWhereUniqueInput +} + +/** + * SecureValue findUniqueOrThrow + */ +export type SecureValueFindUniqueOrThrowArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * Filter, which SecureValue to fetch. + */ + where: Prisma.SecureValueWhereUniqueInput +} + +/** + * SecureValue findFirst + */ +export type SecureValueFindFirstArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * Filter, which SecureValue to fetch. + */ + where?: Prisma.SecureValueWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of SecureValues to fetch. + */ + orderBy?: Prisma.SecureValueOrderByWithRelationInput | Prisma.SecureValueOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for SecureValues. + */ + cursor?: Prisma.SecureValueWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` SecureValues 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` SecureValues. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of SecureValues. + */ + distinct?: Prisma.SecureValueScalarFieldEnum | Prisma.SecureValueScalarFieldEnum[] +} + +/** + * SecureValue findFirstOrThrow + */ +export type SecureValueFindFirstOrThrowArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * Filter, which SecureValue to fetch. + */ + where?: Prisma.SecureValueWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of SecureValues to fetch. + */ + orderBy?: Prisma.SecureValueOrderByWithRelationInput | Prisma.SecureValueOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for searching for SecureValues. + */ + cursor?: Prisma.SecureValueWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` SecureValues 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` SecureValues. + */ + skip?: number + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/distinct Distinct Docs} + * + * Filter by unique combinations of SecureValues. + */ + distinct?: Prisma.SecureValueScalarFieldEnum | Prisma.SecureValueScalarFieldEnum[] +} + +/** + * SecureValue findMany + */ +export type SecureValueFindManyArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * Filter, which SecureValues to fetch. + */ + where?: Prisma.SecureValueWhereInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/sorting Sorting Docs} + * + * Determine the order of SecureValues to fetch. + */ + orderBy?: Prisma.SecureValueOrderByWithRelationInput | Prisma.SecureValueOrderByWithRelationInput[] + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs} + * + * Sets the position for listing SecureValues. + */ + cursor?: Prisma.SecureValueWhereUniqueInput + /** + * {@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs} + * + * Take `±n` SecureValues 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` SecureValues. + */ + skip?: number + distinct?: Prisma.SecureValueScalarFieldEnum | Prisma.SecureValueScalarFieldEnum[] +} + +/** + * SecureValue create + */ +export type SecureValueCreateArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * The data needed to create a SecureValue. + */ + data: Prisma.XOR +} + +/** + * SecureValue createMany + */ +export type SecureValueCreateManyArgs = { + /** + * The data used to create many SecureValues. + */ + data: Prisma.SecureValueCreateManyInput | Prisma.SecureValueCreateManyInput[] + skipDuplicates?: boolean +} + +/** + * SecureValue createManyAndReturn + */ +export type SecureValueCreateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelectCreateManyAndReturn | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * The data used to create many SecureValues. + */ + data: Prisma.SecureValueCreateManyInput | Prisma.SecureValueCreateManyInput[] + skipDuplicates?: boolean + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueIncludeCreateManyAndReturn | null +} + +/** + * SecureValue update + */ +export type SecureValueUpdateArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * The data needed to update a SecureValue. + */ + data: Prisma.XOR + /** + * Choose, which SecureValue to update. + */ + where: Prisma.SecureValueWhereUniqueInput +} + +/** + * SecureValue updateMany + */ +export type SecureValueUpdateManyArgs = { + /** + * The data used to update SecureValues. + */ + data: Prisma.XOR + /** + * Filter which SecureValues to update + */ + where?: Prisma.SecureValueWhereInput + /** + * Limit how many SecureValues to update. + */ + limit?: number +} + +/** + * SecureValue updateManyAndReturn + */ +export type SecureValueUpdateManyAndReturnArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelectUpdateManyAndReturn | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * The data used to update SecureValues. + */ + data: Prisma.XOR + /** + * Filter which SecureValues to update + */ + where?: Prisma.SecureValueWhereInput + /** + * Limit how many SecureValues to update. + */ + limit?: number + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueIncludeUpdateManyAndReturn | null +} + +/** + * SecureValue upsert + */ +export type SecureValueUpsertArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * The filter to search for the SecureValue to update in case it exists. + */ + where: Prisma.SecureValueWhereUniqueInput + /** + * In case the SecureValue found by the `where` argument doesn't exist, create a new SecureValue with this data. + */ + create: Prisma.XOR + /** + * In case the SecureValue was found with the provided `where` argument, update it with this data. + */ + update: Prisma.XOR +} + +/** + * SecureValue delete + */ +export type SecureValueDeleteArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null + /** + * Filter which SecureValue to delete. + */ + where: Prisma.SecureValueWhereUniqueInput +} + +/** + * SecureValue deleteMany + */ +export type SecureValueDeleteManyArgs = { + /** + * Filter which SecureValues to delete + */ + where?: Prisma.SecureValueWhereInput + /** + * Limit how many SecureValues to delete. + */ + limit?: number +} + +/** + * SecureValue without action + */ +export type SecureValueDefaultArgs = { + /** + * Select specific fields to fetch from the SecureValue + */ + select?: Prisma.SecureValueSelect | null + /** + * Omit specific fields from the SecureValue + */ + omit?: Prisma.SecureValueOmit | null + /** + * Choose, which related nodes to fetch as well + */ + include?: Prisma.SecureValueInclude | null +} diff --git a/package.json b/package.json index 19c5acb..dc13047 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "@prisma/client": "^7.3.0", "@socket.io/bun-engine": "^0.1.0", "axios": "^1.13.3", + "blakets": "^0.1.12", "cors": "^2.8.6", "cuid": "^3.0.0", "hono": "^4.11.5", diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 38460c5..1ccad4e 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -62,6 +62,54 @@ model Company { cw_CompanyId Int @unique cw_Identifier String @unique + credentials Credential[] + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model CredentialType { + id String @id @default(cuid()) + name String @unique + + permissionScope String + icon String? + fields Json + + credentials Credential[] + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model SecureValue { + id String @id @default(cuid()) + name String + + content String // Encrypted content + hash String // Hash of the original content for integrity verification and Search + + credentialId String + credential Credential @relation(fields: [credentialId], references: [id], onDelete: Cascade) + + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt +} + +model Credential { + id String @id @default(cuid()) + name String + + typeId String + type CredentialType @relation(fields: [typeId], references: [id], onDelete: Cascade) + + fields Json + + companyId String + company Company @relation(fields: [companyId], references: [id], onDelete: Cascade) + + securevalues SecureValue[] + createdAt DateTime @default(now()) updatedAt DateTime @updatedAt } diff --git a/src/api/credential-types/create.ts b/src/api/credential-types/create.ts new file mode 100644 index 0000000..c34ab49 --- /dev/null +++ b/src/api/credential-types/create.ts @@ -0,0 +1,43 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentialTypes } from "../../managers/credentialTypes"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; +import { z } from "zod"; + +/* /v1/credential-type */ +export default createRoute( + "post", + ["/"], + + async (c) => { + const body = await c.req.json(); + + const schema = z.object({ + name: z.string().min(1, "Name is required"), + permissionScope: z.string().min(1, "Permission scope is required"), + icon: z.string().optional(), + fields: z.array( + z.object({ + id: z.string(), + name: z.string(), + required: z.boolean(), + secure: z.boolean(), + valueType: z.enum(["plain_text", "password"]), + }), + ), + }); + + const data = schema.parse(body); + + const credentialType = await credentialTypes.create(data as any); + + const response = apiResponse.created( + "Credential Type Created Successfully!", + credentialType.toJson(), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential_type.create"] }), +); diff --git a/src/api/credential-types/delete.ts b/src/api/credential-types/delete.ts new file mode 100644 index 0000000..fe4881a --- /dev/null +++ b/src/api/credential-types/delete.ts @@ -0,0 +1,23 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentialTypes } from "../../managers/credentialTypes"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential-type/:id */ +export default createRoute( + "delete", + ["/:id"], + + async (c) => { + await credentialTypes.delete(c.req.param("id")); + + const response = apiResponse.successful( + "Credential Type Deleted Successfully!", + null, + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential_type.delete"] }), +); diff --git a/src/api/credential-types/fetch.ts b/src/api/credential-types/fetch.ts new file mode 100644 index 0000000..706691b --- /dev/null +++ b/src/api/credential-types/fetch.ts @@ -0,0 +1,25 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentialTypes } from "../../managers/credentialTypes"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential-type/:identifier */ +export default createRoute( + "get", + ["/:identifier"], + + async (c) => { + const credentialType = await credentialTypes.fetch( + c.req.param("identifier"), + ); + + const response = apiResponse.successful( + "Credential Type Fetched Successfully!", + credentialType.toJson({ includeCredentialCount: true }), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential_type.fetch"] }), +); diff --git a/src/api/credential-types/fetchAll.ts b/src/api/credential-types/fetchAll.ts new file mode 100644 index 0000000..eb1d29d --- /dev/null +++ b/src/api/credential-types/fetchAll.ts @@ -0,0 +1,25 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentialTypes } from "../../managers/credentialTypes"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential-type */ +export default createRoute( + "get", + ["/"], + + async (c) => { + const allCredentialTypes = await credentialTypes.fetchAll(); + + const response = apiResponse.successful( + "Credential Types Fetched Successfully!", + allCredentialTypes.map((ct) => + ct.toJson({ includeCredentialCount: true }), + ), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential_type.fetch.many"] }), +); diff --git a/src/api/credential-types/fetchCredentials.ts b/src/api/credential-types/fetchCredentials.ts new file mode 100644 index 0000000..a1c8b2e --- /dev/null +++ b/src/api/credential-types/fetchCredentials.ts @@ -0,0 +1,26 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentialTypes } from "../../managers/credentialTypes"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential-type/:id/credentials */ +export default createRoute( + "get", + ["/:id/credentials"], + + async (c) => { + const credentialType = await credentialTypes.fetch(c.req.param("id")); + const credentials = await credentialType.fetchCredentials(); + + const response = apiResponse.successful( + "Credentials Fetched Successfully!", + credentials.map((cred) => cred.toJson()), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ + permissions: ["credential_type.fetch", "credential.fetch.many"], + }), +); diff --git a/src/api/credential-types/index.ts b/src/api/credential-types/index.ts new file mode 100644 index 0000000..8bd7f28 --- /dev/null +++ b/src/api/credential-types/index.ts @@ -0,0 +1,15 @@ +import { default as fetch } from "./fetch"; +import { default as fetchAll } from "./fetchAll"; +import { default as create } from "./create"; +import { default as update } from "./update"; +import { default as deleteCredentialType } from "./delete"; +import { default as fetchCredentials } from "./fetchCredentials"; + +export { + fetch, + fetchAll, + create, + update, + deleteCredentialType as delete, + fetchCredentials, +}; diff --git a/src/api/credential-types/update.ts b/src/api/credential-types/update.ts new file mode 100644 index 0000000..64092f6 --- /dev/null +++ b/src/api/credential-types/update.ts @@ -0,0 +1,46 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentialTypes } from "../../managers/credentialTypes"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; +import { z } from "zod"; + +/* /v1/credential-type/:id */ +export default createRoute( + "patch", + ["/:id"], + + async (c) => { + const body = await c.req.json(); + const credentialType = await credentialTypes.fetch(c.req.param("id")); + + const schema = z.object({ + name: z.string().optional(), + permissionScope: z.string().optional(), + icon: z.string().optional(), + fields: z + .array( + z.object({ + id: z.string(), + name: z.string(), + required: z.boolean(), + secure: z.boolean(), + valueType: z.enum(["plain_text", "password"]), + }), + ) + .optional(), + }); + + const data = schema.parse(body); + + await credentialType.update(data as any); + + const response = apiResponse.successful( + "Credential Type Updated Successfully!", + credentialType.toJson(), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential_type.update"] }), +); diff --git a/src/api/credentials/create.ts b/src/api/credentials/create.ts new file mode 100644 index 0000000..3be7fea --- /dev/null +++ b/src/api/credentials/create.ts @@ -0,0 +1,41 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; +import { z } from "zod"; + +/* /v1/credential/create */ +export default createRoute( + "post", + ["/credentials"], + + async (c) => { + const body = await c.req.json(); + + const schema = z.object({ + name: z.string().min(1, "Name is required"), + typeId: z.string().min(1, "Type ID is required"), + companyId: z.string().min(1, "Company ID is required"), + fields: z.array( + z.object({ + id: z.string(), + fieldId: z.string(), + value: z.string(), + }), + ), + }); + + const data = schema.parse(body); + + const credential = await credentials.create(data); + + const response = apiResponse.created( + "Credential Created Successfully!", + credential.toJson(), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential.create"] }), +); diff --git a/src/api/credentials/delete.ts b/src/api/credentials/delete.ts new file mode 100644 index 0000000..2a9ed84 --- /dev/null +++ b/src/api/credentials/delete.ts @@ -0,0 +1,23 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential/:id */ +export default createRoute( + "delete", + ["/credentials/:id"], + + async (c) => { + await credentials.delete(c.req.param("id")); + + const response = apiResponse.successful( + "Credential Deleted Successfully!", + null, + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential.delete"] }), +); diff --git a/src/api/credentials/fetch.ts b/src/api/credentials/fetch.ts new file mode 100644 index 0000000..9d5281d --- /dev/null +++ b/src/api/credentials/fetch.ts @@ -0,0 +1,23 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential/:id */ +export default createRoute( + "get", + ["/credentials/:id"], + + async (c) => { + const credential = await credentials.fetch(c.req.param("id")); + + const response = apiResponse.successful( + "Credential Fetched Successfully!", + credential.toJson(), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential.fetch"] }), +); diff --git a/src/api/credentials/fetchByCompany.ts b/src/api/credentials/fetchByCompany.ts new file mode 100644 index 0000000..e8c8625 --- /dev/null +++ b/src/api/credentials/fetchByCompany.ts @@ -0,0 +1,25 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential/company/:companyId */ +export default createRoute( + "get", + ["/credentials/company/:companyId"], + + async (c) => { + const companyCredentials = await credentials.fetchByCompany( + c.req.param("companyId"), + ); + + const response = apiResponse.successful( + "Company Credentials Fetched Successfully!", + companyCredentials.map((cred) => cred.toJson()), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential.fetch.many"] }), +); diff --git a/src/api/credentials/fetchFields.ts b/src/api/credentials/fetchFields.ts new file mode 100644 index 0000000..30ed6ab --- /dev/null +++ b/src/api/credentials/fetchFields.ts @@ -0,0 +1,26 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential/:id/fields */ +export default createRoute( + "get", + ["/credentials/:id/fields"], + + async (c) => { + const credential = await credentials.fetch(c.req.param("id")); + const fields = await credential.fetchAllFieldValues(); + + const response = apiResponse.successful( + "Credential Fields Fetched Successfully!", + fields, + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ + permissions: ["credential.fetch", "credential.fields.fetch"], + }), +); diff --git a/src/api/credentials/index.ts b/src/api/credentials/index.ts new file mode 100644 index 0000000..7b6f2b0 --- /dev/null +++ b/src/api/credentials/index.ts @@ -0,0 +1,19 @@ +import { default as fetch } from "./fetch"; +import { default as fetchByCompany } from "./fetchByCompany"; +import { default as create } from "./create"; +import { default as update } from "./update"; +import { default as updateFields } from "./updateFields"; +import { default as fetchFields } from "./fetchFields"; +import { default as readSecureValues } from "./readSecureValues"; +import { default as deleteCredential } from "./delete"; + +export { + fetch, + fetchByCompany, + create, + update, + updateFields, + fetchFields, + readSecureValues, + deleteCredential as delete, +}; diff --git a/src/api/credentials/readSecureValues.ts b/src/api/credentials/readSecureValues.ts new file mode 100644 index 0000000..d4c2242 --- /dev/null +++ b/src/api/credentials/readSecureValues.ts @@ -0,0 +1,26 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; + +/* /v1/credential/:id/secure-values */ +export default createRoute( + "get", + ["/credentials/:id/secure-values"], + + async (c) => { + const credential = await credentials.fetch(c.req.param("id")); + const secureValues = await credential.readAllSecureValues(); + + const response = apiResponse.successful( + "Secure Values Fetched Successfully!", + secureValues, + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ + permissions: ["credential.fetch", "credential.secure_values.read"], + }), +); diff --git a/src/api/credentials/update.ts b/src/api/credentials/update.ts new file mode 100644 index 0000000..49a51ab --- /dev/null +++ b/src/api/credentials/update.ts @@ -0,0 +1,33 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; +import { z } from "zod"; + +/* /v1/credential/:id */ +export default createRoute( + "patch", + ["/credentials/:id"], + + async (c) => { + const body = await c.req.json(); + const credential = await credentials.fetch(c.req.param("id")); + + const schema = z.object({ + name: z.string().optional(), + }); + + const data = schema.parse(body); + + await credential.update(data); + + const response = apiResponse.successful( + "Credential Updated Successfully!", + credential.toJson(), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ permissions: ["credential.update"] }), +); diff --git a/src/api/credentials/updateFields.ts b/src/api/credentials/updateFields.ts new file mode 100644 index 0000000..41cc246 --- /dev/null +++ b/src/api/credentials/updateFields.ts @@ -0,0 +1,41 @@ +import { Hono } from "hono/tiny"; +import { createRoute } from "../../modules/api-utils/createRoute"; +import { credentials } from "../../managers/credentials"; +import { apiResponse } from "../../modules/api-utils/apiResponse"; +import { ContentfulStatusCode } from "hono/utils/http-status"; +import { authMiddleware } from "../middleware/authorization"; +import { z } from "zod"; + +/* /v1/credential/:id/fields */ +export default createRoute( + "put", + ["/credentials/:id/fields"], + + async (c) => { + const body = await c.req.json(); + const credential = await credentials.fetch(c.req.param("id")); + + const schema = z.object({ + fields: z.array( + z.object({ + id: z.string(), + fieldId: z.string(), + value: z.string(), + }), + ), + }); + + const data = schema.parse(body); + + await credential.validateAndUpdateFields(data.fields); + + const response = apiResponse.successful( + "Credential Fields Updated Successfully!", + credential.toJson(), + ); + return c.json(response, response.status as ContentfulStatusCode); + }, + authMiddleware({ + permissions: ["credential.update", "credential.fields.update"], + }), +); diff --git a/src/api/routers/credentialRouter.ts b/src/api/routers/credentialRouter.ts new file mode 100644 index 0000000..378694d --- /dev/null +++ b/src/api/routers/credentialRouter.ts @@ -0,0 +1,7 @@ +import { Hono } from "hono"; +import * as credentialRoutes from "../credentials"; + +const credentialRouter = new Hono(); +Object.values(credentialRoutes).map((r) => credentialRouter.route("/", r)); + +export default credentialRouter; diff --git a/src/api/routers/credentialTypeRouter.ts b/src/api/routers/credentialTypeRouter.ts new file mode 100644 index 0000000..98333a1 --- /dev/null +++ b/src/api/routers/credentialTypeRouter.ts @@ -0,0 +1,9 @@ +import { Hono } from "hono"; +import * as credentialTypeRoutes from "../credential-types"; + +const credentialTypeRouter = new Hono(); +Object.values(credentialTypeRoutes).map((r) => + credentialTypeRouter.route("/", r), +); + +export default credentialTypeRouter; diff --git a/src/api/server.ts b/src/api/server.ts index c236d34..57aa83e 100644 --- a/src/api/server.ts +++ b/src/api/server.ts @@ -50,6 +50,8 @@ v1.route("/teapot", teapot); v1.route("/auth", require("./routers/authRouter").default); v1.route("/user", require("./routers/user").default); v1.route("/company", require("./routers/companyRouter").default); +v1.route("/credential", require("./routers/credentialRouter").default); +v1.route("/credential-type", require("./routers/credentialTypeRouter").default); app.route("/v1", v1); export default app; diff --git a/src/constants.ts b/src/constants.ts index 7613d58..5133001 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -23,18 +23,16 @@ export const sessionDuration = 30 * 24 * 60 * 60000; export const accessTokenDuration = "10min"; export const refreshTokenDuration = "30d"; -export const accessTokenPrivateKey = readFileSync( - `${import.meta.dir}/../.accessToken.key`, +export const accessTokenPrivateKey = + readFileSync(`.accessToken.key`).toString(); +export const refreshTokenPrivateKey = + readFileSync(`.refreshToken.key`).toString(); +export const permissionsPrivateKey = readFileSync(`.permissions.key`); +export const secureValuesPrivateKey = + readFileSync(`.secureValues.key`).toString(); +export const secureValuesPublicKey = readFileSync( + `public-keys/.secureValues.pub`, ).toString(); -export const refreshTokenPrivateKey = readFileSync( - `${import.meta.dir}/../.refreshToken.key`, -).toString(); -export const permissionsPrivateKey = readFileSync( - `${import.meta.dir}/../.permissions.key`, -); -export const apiKeyTokenPrivateKey = readFileSync( - `${import.meta.dir}/../.apiKeyToken.key`, -); // Microsoft Auth Constants const msalConfig: msal.Configuration = { diff --git a/src/controllers/CredentialController.ts b/src/controllers/CredentialController.ts new file mode 100644 index 0000000..9046eb8 --- /dev/null +++ b/src/controllers/CredentialController.ts @@ -0,0 +1,322 @@ +import { z } from "zod"; +import { + Credential, + CredentialType, + Company, + SecureValue, +} from "../../generated/prisma/client"; +import { prisma } from "../constants"; +import { fieldValidator } from "../modules/credentials/fieldValidator"; +import { + CredentialField, + CredentialTypeField, +} from "../modules/credentials/credentialTypeDefs"; +import { generateSecureValue } from "../modules/credentials/generateSecureValue"; +import { readSecureValue } from "../modules/credentials/readSecureValue"; +import GenericError from "../Errors/GenericError"; + +/** + * Credential Controller + * + * This class manages credential data, including field validation, + * secure value storage/retrieval, and credential updates. + */ +export class CredentialController { + public readonly id: string; + public name: string; + public readonly typeId: string; + public readonly companyId: string; + public fields: any; + + private _type: CredentialType; + private _company: Company; + private _secureValues: SecureValue[]; + + public readonly createdAt: Date; + public updatedAt: Date; + + constructor( + credentialData: Credential & { + type: CredentialType; + company: Company; + securevalues: SecureValue[]; + }, + ) { + this.id = credentialData.id; + this.name = credentialData.name; + this.typeId = credentialData.typeId; + this.companyId = credentialData.companyId; + this.fields = credentialData.fields; + this._type = credentialData.type; + this._company = credentialData.company; + this._secureValues = credentialData.securevalues; + this.createdAt = credentialData.createdAt; + this.updatedAt = credentialData.updatedAt; + } + + /** + * Update Internal Values + * + * Internal method to update all internal values when we query the database. + * This keeps everything up-to-date even when we pass around the credential controller. + * + * @param credentialData - Credential object from Prisma + */ + private _updateInternalValues(credentialData: Credential) { + this.name = credentialData.name; + this.fields = credentialData.fields; + this.updatedAt = credentialData.updatedAt; + } + + /** + * Validate and Update Fields + * + * This method validates the submitted fields against the credential type's + * acceptable fields, then updates the credential in the database. + * Secure fields are encrypted and stored in the SecureValue table. + * + * @param fields - The fields to validate and update + * @returns {Promise} - The updated credential controller + */ + async validateAndUpdateFields( + fields: CredentialField[], + ): Promise { + // Get acceptable fields from the credential type + const acceptableFields = this._type.fields as any as CredentialTypeField[]; + // Validate the fields + const validatedFields = await fieldValidator(fields, acceptableFields); + + // Separate secure and non-secure fields + const secureFields = validatedFields.filter((f) => f.secure); + const nonSecureFields = validatedFields.filter((f) => !f.secure); + + // Process secure fields - encrypt and store in SecureValue table + await Promise.all( + secureFields.map(async (field) => { + const { encrypted, hash } = generateSecureValue(field.value); + + // Check if a secure value already exists for this field + const existingSecureValue = await prisma.secureValue.findFirst({ + where: { + credentialId: this.id, + name: field.fieldId, + }, + }); + + if (existingSecureValue) { + // Update existing secure value + await prisma.secureValue.update({ + where: { id: existingSecureValue.id }, + data: { + content: encrypted, + hash, + }, + }); + } else { + // Create new secure value + await prisma.secureValue.create({ + data: { + name: field.fieldId, + content: encrypted, + hash, + credentialId: this.id, + }, + }); + } + }), + ); + + // Build fields object for non-secure fields + const fieldsObject: Record = {}; + nonSecureFields.forEach((field) => { + fieldsObject[field.fieldId] = field.value; + }); + + // Update the credential with non-secure fields + const updatedCredential = await prisma.credential.update({ + where: { id: this.id }, + data: { + fields: fieldsObject, + }, + }); + + this._updateInternalValues(updatedCredential); + + // Refresh secure values + const secureValues = await prisma.secureValue.findMany({ + where: { credentialId: this.id }, + }); + this._secureValues = secureValues; + + return this; + } + + /** + * Fetch All Field Values + * + * Returns all field values (both secure and non-secure) for this credential. + * Secure field values are NOT decrypted - use `readSecureFieldValue` for that. + * + * @returns {Promise} - Array of all fields with their encrypted values + */ + async fetchAllFieldValues(): Promise { + const fields: CredentialField[] = []; + + // Add non-secure fields from the fields JSON + const nonSecureFields = this.fields as Record; + Object.entries(nonSecureFields || {}).forEach(([fieldId, value]) => { + fields.push({ + id: `${this.id}-${fieldId}`, // Generate a consistent ID + fieldId, + value: value as string, + }); + }); + + // Add secure fields from SecureValue table (encrypted) + this._secureValues.forEach((secureValue) => { + fields.push({ + id: secureValue.id, + fieldId: secureValue.name, + value: secureValue.content, // Encrypted value + }); + }); + + return fields; + } + + /** + * Read Secure Field Value + * + * Decrypts and returns the value of a specific secure field. + * + * @param fieldId - The field ID to read + * @returns {Promise} - The decrypted field value + */ + async readSecureFieldValue(fieldId: string): Promise { + const secureValue = this._secureValues.find((sv) => sv.name === fieldId); + + if (!secureValue) { + throw new GenericError({ + message: `Secure field not found: ${fieldId}`, + name: "SecureFieldNotFound", + cause: `No secure value exists for field '${fieldId}' in credential '${this.id}'`, + status: 404, + }); + } + + // Decrypt the value + const decryptedValue = readSecureValue( + secureValue.content, + secureValue.hash, + ); + + return decryptedValue; + } + + /** + * Read All Secure Values + * + * Decrypts and returns all secure field values for this credential. + * + * @returns {Promise>} - Object mapping field IDs to decrypted values + */ + async readAllSecureValues(): Promise> { + const secureValues: Record = {}; + + await Promise.all( + this._secureValues.map(async (secureValue) => { + const decryptedValue = readSecureValue( + secureValue.content, + secureValue.hash, + ); + secureValues[secureValue.name] = decryptedValue; + }), + ); + + return secureValues; + } + + /** + * Update Credential + * + * Update the credential name or other basic properties. + * + * @param data - Partial credential data to update + * @returns {Promise} - The updated credential controller + */ + async update( + data: Partial>, + ): Promise { + const pData = z + .object({ + name: z.string().optional(), + }) + .strict() + .parse(data); + + const updatedCredential = await prisma.credential.update({ + where: { id: this.id }, + data: pData, + }); + + this._updateInternalValues(updatedCredential); + + return this; + } + + /** + * Get Credential Type + * + * Returns the credential type information. + * + * @returns {CredentialType} - The credential type + */ + getType(): CredentialType { + return this._type; + } + + /** + * Get Company + * + * Returns the company this credential belongs to. + * + * @returns {Company} - The company + */ + getCompany(): Company { + return this._company; + } + + /** + * To JSON + * + * Create an object that can be safely returned to the user. + * Secure values are not included by default. + * + * @param opts - Options to change the output + * @returns - An object that is JSON friendly + */ + toJson(opts?: { includeSecureValues?: boolean }) { + return { + id: this.id, + name: this.name, + typeId: this.typeId, + companyId: this.companyId, + fields: this.fields, + type: { + id: this._type.id, + name: this._type.name, + fields: this._type.fields, + permissionScope: this._type.permissionScope, + }, + company: { + id: this._company.id, + name: this._company.name, + }, + secureFieldIds: opts?.includeSecureValues + ? this._secureValues.map((sv) => sv.name) + : undefined, + createdAt: this.createdAt, + updatedAt: this.updatedAt, + }; + } +} diff --git a/src/controllers/CredentialTypeController.ts b/src/controllers/CredentialTypeController.ts new file mode 100644 index 0000000..be86b68 --- /dev/null +++ b/src/controllers/CredentialTypeController.ts @@ -0,0 +1,178 @@ +import { z } from "zod"; +import { CredentialType, Credential } from "../../generated/prisma/client"; +import { prisma } from "../constants"; +import { CredentialTypeField } from "../modules/credentials/credentialTypeDefs"; +import { CredentialController } from "./CredentialController"; + +/** + * Credential Type Controller + * + * This class manages credential type data, including field definitions, + * permission scopes, and associated credentials. + */ +export class CredentialTypeController { + public readonly id: string; + public name: string; + public permissionScope: string; + public icon: string | null; + public fields: CredentialTypeField[]; + + private _credentials: Credential[]; + + public readonly createdAt: Date; + public updatedAt: Date; + + constructor( + credentialTypeData: CredentialType & { + credentials: Credential[]; + }, + ) { + this.id = credentialTypeData.id; + this.name = credentialTypeData.name; + this.permissionScope = credentialTypeData.permissionScope; + this.icon = credentialTypeData.icon; + this.fields = credentialTypeData.fields! as any as CredentialTypeField[]; + this._credentials = credentialTypeData.credentials; + this.createdAt = credentialTypeData.createdAt; + this.updatedAt = credentialTypeData.updatedAt; + } + + /** + * Update Internal Values + * + * Internal method to update all internal values when we query the database. + * This keeps everything up-to-date even when we pass around the credential type controller. + * + * @param credentialTypeData - CredentialType object from Prisma + */ + private _updateInternalValues(credentialTypeData: CredentialType) { + this.name = credentialTypeData.name; + this.permissionScope = credentialTypeData.permissionScope; + this.icon = credentialTypeData.icon; + this.fields = credentialTypeData.fields! as any as CredentialTypeField[]; + this.updatedAt = credentialTypeData.updatedAt; + } + + /** + * Update Credential Type + * + * Update the credential type's name, permission scope, icon, or fields. + * + * @param data - Partial credential type data to update + * @returns {Promise} - The updated credential type controller + */ + async update( + data: Partial< + Pick & { + fields: CredentialTypeField[]; + } + >, + ): Promise { + const pData = z + .object({ + name: z.string().optional(), + permissionScope: z.string().optional(), + icon: z.string().optional(), + fields: z.array(z.any()).optional(), + }) + .strict() + .parse(data); + + const updatedCredentialType = await prisma.credentialType.update({ + where: { id: this.id }, + data: pData, + }); + + this._updateInternalValues(updatedCredentialType); + + return this; + } + + /** + * Get Field Definition + * + * Get the definition for a specific field by its ID. + * + * @param fieldId - The field ID to look up + * @returns {CredentialTypeField | undefined} - The field definition or undefined + */ + getFieldDefinition(fieldId: string): CredentialTypeField | undefined { + return this.fields.find((f) => f.id === fieldId); + } + + /** + * Get Required Fields + * + * Returns all fields that are marked as required. + * + * @returns {CredentialTypeField[]} - Array of required fields + */ + getRequiredFields(): CredentialTypeField[] { + return this.fields.filter((f) => f.required); + } + + /** + * Get Secure Fields + * + * Returns all fields that should be stored securely (encrypted). + * + * @returns {CredentialTypeField[]} - Array of secure fields + */ + getSecureFields(): CredentialTypeField[] { + return this.fields.filter((f) => f.secure); + } + + /** + * Fetch Credentials + * + * Fetch all credentials that use this credential type. + * + * @returns {Promise} - Array of credential controllers + */ + async fetchCredentials(): Promise { + const credentials = await prisma.credential.findMany({ + where: { typeId: this.id }, + include: { + type: true, + company: true, + securevalues: true, + }, + }); + + return credentials.map((cred) => new CredentialController(cred)); + } + + /** + * Count Credentials + * + * Count how many credentials use this credential type. + * + * @returns {number} - Number of credentials using this type + */ + countCredentials(): number { + return this._credentials.length; + } + + /** + * To JSON + * + * Create an object that can be safely returned to the user. + * + * @param opts - Options to change the output + * @returns - An object that is JSON friendly + */ + toJson(opts?: { includeCredentialCount?: boolean }) { + return { + id: this.id, + name: this.name, + permissionScope: this.permissionScope, + icon: this.icon, + fields: this.fields, + credentialCount: opts?.includeCredentialCount + ? this._credentials.length + : undefined, + createdAt: this.createdAt, + updatedAt: this.updatedAt, + }; + } +} diff --git a/src/managers/credentialTypes.ts b/src/managers/credentialTypes.ts new file mode 100644 index 0000000..821bd6d --- /dev/null +++ b/src/managers/credentialTypes.ts @@ -0,0 +1,111 @@ +import { prisma } from "../constants"; +import { CredentialTypeController } from "../controllers/CredentialTypeController"; +import { CredentialTypeField } from "../modules/credentials/credentialTypeDefs"; +import GenericError from "../Errors/GenericError"; + +export const credentialTypes = { + /** + * Fetch Credential Type + * + * Fetch a credential type by its ID or name and return a CredentialTypeController instance. + * + * @param identifier - The credential type ID or name to fetch + * @returns {Promise} - The credential type controller + */ + async fetch(identifier: string): Promise { + const credentialType = await prisma.credentialType.findFirst({ + where: { + OR: [{ id: identifier }, { name: identifier }], + }, + include: { + credentials: true, + }, + }); + + if (!credentialType) { + throw new GenericError({ + message: "Credential type not found", + name: "CredentialTypeNotFound", + cause: `No credential type exists with identifier '${identifier}'`, + status: 404, + }); + } + + return new CredentialTypeController(credentialType); + }, + + /** + * Fetch All Credential Types + * + * Fetch all credential types in the system. + * + * @returns {Promise} - Array of credential type controllers + */ + async fetchAll(): Promise { + const credentialTypesList = await prisma.credentialType.findMany({ + include: { + credentials: true, + }, + }); + + return credentialTypesList.map((ct) => new CredentialTypeController(ct)); + }, + + /** + * Create Credential Type + * + * Create a new credential type with its field definitions. + * + * @param data - The credential type data to create + * @returns {Promise} - The created credential type controller + */ + async create(data: { + name: string; + permissionScope: string; + fields: CredentialTypeField[]; + icon?: string; + }): Promise { + // Check if a credential type with this name already exists + const existing = await prisma.credentialType.findFirst({ + where: { name: data.name }, + }); + + if (existing) { + throw new GenericError({ + message: "Credential type name already exists", + name: "CredentialTypeAlreadyExists", + cause: `A credential type with name '${data.name}' already exists`, + status: 400, + }); + } + + const credentialType = await prisma.credentialType.create({ + data: { + name: data.name, + permissionScope: data.permissionScope, + fields: data.fields as any, + icon: data.icon, + }, + include: { + credentials: true, + }, + }); + + return new CredentialTypeController(credentialType); + }, + + /** + * Delete Credential Type + * + * Delete a credential type by its ID. + * This will cascade delete all credentials of this type. + * + * @param id - The credential type ID to delete + * @returns {Promise} + */ + async delete(id: string): Promise { + await prisma.credentialType.delete({ + where: { id }, + }); + }, +}; diff --git a/src/managers/credentials.ts b/src/managers/credentials.ts new file mode 100644 index 0000000..d9bbcb7 --- /dev/null +++ b/src/managers/credentials.ts @@ -0,0 +1,158 @@ +import { prisma } from "../constants"; +import { CredentialController } from "../controllers/CredentialController"; +import { fieldValidator } from "../modules/credentials/fieldValidator"; +import { + CredentialField, + CredentialTypeField, +} from "../modules/credentials/credentialTypeDefs"; +import { generateSecureValue } from "../modules/credentials/generateSecureValue"; +import GenericError from "../Errors/GenericError"; + +export const credentials = { + /** + * Fetch Credential + * + * Fetch a credential by its ID and return a CredentialController instance. + * + * @param id - The credential ID to fetch + * @returns {Promise} - The credential controller + */ + async fetch(id: string): Promise { + const credential = await prisma.credential.findFirst({ + where: { id }, + include: { + type: true, + company: true, + securevalues: true, + }, + }); + + if (!credential) { + throw new GenericError({ + message: "Credential not found", + name: "CredentialNotFound", + cause: `No credential exists with ID '${id}'`, + status: 404, + }); + } + + return new CredentialController(credential); + }, + + /** + * Fetch Credentials by Company + * + * Fetch all credentials associated with a specific company. + * + * @param companyId - The company ID to fetch credentials for + * @returns {Promise} - Array of credential controllers + */ + async fetchByCompany(companyId: string): Promise { + const credentialsList = await prisma.credential.findMany({ + where: { companyId }, + include: { + type: true, + company: true, + securevalues: true, + }, + }); + + return credentialsList.map((cred) => new CredentialController(cred)); + }, + + /** + * Create Credential + * + * Create a new credential with validated fields. + * This method processes all incoming field values, validating them against + * the credential type, encrypting secure fields, and inserting everything + * into the database atomically. + * + * @param data - The credential data to create + * @returns {Promise} - The created credential controller + */ + async create(data: { + name: string; + typeId: string; + companyId: string; + fields: CredentialField[]; + }): Promise { + // Fetch the credential type to get acceptable fields + const credentialType = await prisma.credentialType.findFirst({ + where: { id: data.typeId }, + }); + + if (!credentialType) { + throw new GenericError({ + message: "Credential type not found", + name: "CredentialTypeNotFound", + cause: `No credential type exists with ID '${data.typeId}'`, + status: 404, + }); + } + + // Validate the fields against acceptable fields + const acceptableFields = JSON.parse(credentialType.fields! as string).map( + (f: { id: string; name: string; secure: boolean }) => ({ + id: f.id, + name: f.name, + secure: f.secure, + }), + ) as CredentialTypeField[]; + const validatedFields = await fieldValidator(data.fields, acceptableFields); + + // Separate secure and non-secure fields + const secureFields = validatedFields.filter((f) => f.secure); + const nonSecureFields = validatedFields.filter((f) => !f.secure); + + // Build fields object for non-secure fields + const fieldsObject: Record = {}; + nonSecureFields.forEach((field) => { + fieldsObject[field.fieldId] = field.value; + }); + + // Encrypt secure field values + const secureValueData = secureFields.map((field) => { + const { encrypted, hash } = generateSecureValue(field.value); + return { + name: field.fieldId, + content: encrypted, + hash, + }; + }); + + // Create credential and all secure values in a transaction + const credential = await prisma.credential.create({ + data: { + name: data.name, + typeId: data.typeId, + companyId: data.companyId, + fields: fieldsObject, + securevalues: { + create: secureValueData, + }, + }, + include: { + type: true, + company: true, + securevalues: true, + }, + }); + + return new CredentialController(credential); + }, + + /** + * Delete Credential + * + * Delete a credential by its ID. + * + * @param id - The credential ID to delete + * @returns {Promise} + */ + async delete(id: string): Promise { + await prisma.credential.delete({ + where: { id }, + }); + }, +}; diff --git a/src/modules/credentials/credentialTypeDefs b/src/modules/credentials/credentialTypeDefs new file mode 100644 index 0000000..e69de29 diff --git a/src/modules/credentials/credentialTypeDefs.ts b/src/modules/credentials/credentialTypeDefs.ts new file mode 100644 index 0000000..622e6ee --- /dev/null +++ b/src/modules/credentials/credentialTypeDefs.ts @@ -0,0 +1,18 @@ +export enum ValueType { + PLAIN_TEXT = "plain_text", + PASSWORD = "password", +} + +export interface CredentialTypeField { + id: string; // I.e. "clientId", "clientSecret", etc. + name: string; // I.e. "Client ID", "Client Secret", etc. + required: boolean; + secure: boolean; // Whether this field should be stored encrypted in the database + valueType: ValueType; // For future extensibility, currently all fields are strings +} + +export interface CredentialField { + id: string; // CUID + fieldId: string; // I.e. "clientId", "clientSecret", etc. + value: string; // Encrypted value stored in the database +} diff --git a/src/modules/credentials/fieldValidator.ts b/src/modules/credentials/fieldValidator.ts new file mode 100644 index 0000000..981b56c --- /dev/null +++ b/src/modules/credentials/fieldValidator.ts @@ -0,0 +1,56 @@ +import { Collection } from "@discordjs/collection"; +import { CredentialField, CredentialTypeField } from "./credentialTypeDefs"; +import GenericError from "../../Errors/GenericError"; + +/** + * Field Validator + * + * This method will take a record of the fields being submitted and compare them against a record of the acceptable fields + * for a credential type. If any of the submitted fields do not match an acceptable field, an error will be thrown. + * + * If all the credentials pass, it will return a processed version of the submitted fields including fields that need to be + * stored securely (encrypted) and fields that do not. + * + * @param fields - The fields in object form that are being submitted. + * @param acceptableFields - The acceptable field to be compared against. + */ +export const fieldValidator = async ( + fields: CredentialField[], + acceptableFields: CredentialTypeField[], +): Promise< + { + id: string; + fieldId: string; + value: string; + secure: boolean; + }[] +> => { + const afCollection = new Collection(acceptableFields.map((f) => [f.id, f])); + + await Promise.all( + fields.map(async (field) => { + const matchingField = afCollection.get(field.fieldId); + if (!matchingField) { + throw new GenericError({ + message: `Invalid field ID: ${field.fieldId}`, + name: "InvalidCredentialField", + cause: `No acceptable field with ID '${field.fieldId}' found.`, + status: 400, + }); + } + + return; + }), + ); + + return fields.map((field) => { + const matchingField = afCollection.get(field.fieldId)!; + + return { + id: field.id, + fieldId: field.fieldId, + value: field.value, + secure: matchingField.secure, + }; + }); +}; diff --git a/src/modules/credentials/generateSecureValue.ts b/src/modules/credentials/generateSecureValue.ts new file mode 100644 index 0000000..40e333a --- /dev/null +++ b/src/modules/credentials/generateSecureValue.ts @@ -0,0 +1,24 @@ +import Password from "../tools/Password"; +import crypto from "crypto"; +import { secureValuesPublicKey } from "../../constants"; + +export const generateSecureValue = (content: string) => { + // Generate a hash of the content + const hash = Password.hash(content); + + // Encrypt the content using the .secureValues.pub public key + const encrypted = crypto.publicEncrypt( + { + key: secureValuesPublicKey, + padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, + oaepHash: "sha256", + }, + Buffer.from(content, "utf-8"), + ); + + // Return the encrypted content and the hash for storage + return { + encrypted: encrypted.toString("base64"), + hash, + }; +}; diff --git a/src/modules/credentials/readSecureValue.ts b/src/modules/credentials/readSecureValue.ts new file mode 100644 index 0000000..5909aaa --- /dev/null +++ b/src/modules/credentials/readSecureValue.ts @@ -0,0 +1,30 @@ +import Password from "../tools/Password"; +import crypto from "crypto"; +import { secureValuesPrivateKey } from "../../constants"; + +export const readSecureValue = ( + encryptedContent: string, + hash?: string, +): string => { + // Decrypt the content using the .secureValues.key private key + const decrypted = crypto.privateDecrypt( + { + key: secureValuesPrivateKey, + padding: crypto.constants.RSA_PKCS1_OAEP_PADDING, + oaepHash: "sha256", + }, + Buffer.from(encryptedContent, "base64"), + ); + + const content = decrypted.toString("utf-8"); + + // Optionally validate the hash if provided + if (hash) { + const isValid = Password.validate(content, hash); + if (!isValid) { + throw new Error("Secure value hash validation failed"); + } + } + + return content; +}; diff --git a/src/modules/tools/Password.ts b/src/modules/tools/Password.ts index 50e91d0..d68a604 100644 --- a/src/modules/tools/Password.ts +++ b/src/modules/tools/Password.ts @@ -10,7 +10,10 @@ export default class Password { public static hash(password: string, options?: HashPasswordOptions): string { const salt = - options?.overrideSalt ?? Password.generateSalt(options?.saltOpts); + options?.overrideSalt ?? + (options?.saltOpts?.length + ? Password.generateSalt(options?.saltOpts) + : ""); const hash = blake2sHex(`$BLAKE2s$${password}$${salt}`); return `BLAKE2s$${hash}$${salt}`; } @@ -19,7 +22,7 @@ export default class Password { const [algo, oldHash, salt] = hashed.split(/\$/g); return crypto.timingSafeEqual( Buffer.from(hashed), - Buffer.from(Password.hash(newPass, { overrideSalt: salt })) + Buffer.from(Password.hash(newPass, { overrideSalt: salt })), ); } } diff --git a/utils/genPrivateKeys.ts b/utils/genPrivateKeys.ts index aa1b559..ebfb29b 100644 --- a/utils/genPrivateKeys.ts +++ b/utils/genPrivateKeys.ts @@ -7,31 +7,50 @@ This script will go through and genrate all the keys necessary for running the C This process might take several minutes. -----------------`); -await Promise.all( - [ - ".accessToken.key", - ".refreshToken.key", - ".permissions.key", - ".apiKeyToken.key", - ].map(async (v) => { - if ( - await Bun.file(v) - .exists() - .then((bool) => { - if (bool) { - console.log(`'${v}' already exists`); - return false; - } - return true; - }) - ) { - console.log(`Generating '${v}'...`); - const keys = keypair({ bits: 4096 }); +const keyFiles = [ + ".accessToken.key", + ".refreshToken.key", + ".permissions.key", + ".secureValues.key", +]; - await Bun.write(v, keys.private); +const publicDir = "public-keys"; + +await Promise.all( + keyFiles.map(async (v) => { + const privExists = await Bun.file(v) + .exists() + .then((bool) => { + if (bool) { + console.log(`'${v}' already exists`); + return true; + } + return false; + }); + + const pubPath = `${publicDir}/${v.replace(/\.key$/, ".pub")}`; + const pubExists = await Bun.file(pubPath) + .exists() + .then((bool) => { + if (bool) { + console.log(`'${pubPath}' already exists`); + return true; + } + return false; + }); + + if (!privExists || !pubExists) { + console.log(`Generating '${v}' and '${pubPath}'...`); + const keys = keypair({ bits: 4096 }); + if (!privExists) { + await Bun.write(v, keys.private); + } + if (!pubExists) { + await Bun.write(pubPath, keys.public); + } } return; - }) + }), ); console.log("\nGenerated All Keys Successfully!");