{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/damdafa-com/json-schema/damdafa-com-user-profile-in-db-schema.json",
  "title": "UserProfileInDB",
  "x-generated": "2026-10-29",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mockupper-damdafa-com-openapi.json#/components/schemas/UserProfileInDB",
  "properties": {
    "providerId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Providerid",
      "description": "Authentication provider ID"
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Id",
      "description": "User's unique identifier"
    },
    "uid": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Uid",
      "description": "Firebase user ID"
    },
    "email": {
      "anyOf": [
        {
          "type": "string",
          "format": "email"
        },
        {
          "type": "null"
        }
      ],
      "title": "Email",
      "description": "User's email address"
    },
    "displayName": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ],
      "title": "Displayname",
      "description": "Display name (auto-derived from firstName or email if not provided)"
    },
    "name": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ],
      "title": "Name",
      "description": "User's first name"
    },
    "familyName": {
      "anyOf": [
        {
          "type": "string",
          "maxLength": 100
        },
        {
          "type": "null"
        }
      ],
      "title": "Familyname",
      "description": "User's last name"
    },
    "gender": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Gender",
      "description": "User's gender"
    },
    "emailVerified": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Emailverified",
      "description": "Indicates if the user's email is verified"
    },
    "profilePhoto": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Profilephoto",
      "description": "User's profile photo URL"
    },
    "avatar": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Avatar",
      "description": "Avatar seed or string identifier"
    },
    "authAccessToken": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Authaccesstoken",
      "description": "Authentication access token"
    },
    "authRefreshToken": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Authrefreshtoken",
      "description": "Authentication refresh token"
    },
    "credits": {
      "anyOf": [
        {
          "additionalProperties": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "number"
              }
            ]
          },
          "type": "object"
        },
        {
          "type": "null"
        }
      ],
      "title": "Credits",
      "description": "User's credit balance map by feature (e.g., {chat: 100, default: 50})"
    },
    "isFirstVisit": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Isfirstvisit",
      "description": "Indicates if this is the user's first visit",
      "default": false
    },
    "createdAt": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Createdat",
      "description": "Timestamp when the user was created (set automatically)"
    },
    "updatedAt": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Updatedat",
      "description": "Timestamp when the user was last updated (set automatically)"
    },
    "fcmTokens": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Fcmtokens",
      "description": "FCM tokens for push notifications"
    },
    "subscriptions": {
      "items": {
        "$ref": "#/$defs/UserSubscriptionSchema"
      },
      "type": "array",
      "title": "Subscriptions",
      "description": "User's subscriptions"
    },
    "isPremium": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Ispremium",
      "description": "Indicates if the user has any active subscriptions (computed field, not stored in DB)",
      "default": false
    },
    "hasTriggeredSalesNotification": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Hastriggeredsalesnotification",
      "description": "Whether the user has triggered a sales notification on first launch",
      "default": false
    },
    "appLanguage": {
      "type": "string",
      "title": "Applanguage",
      "default": "en"
    },
    "projectsLimit": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Projectslimit",
      "description": "Maximum number of projects allowed"
    },
    "projectsCount": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Projectscount",
      "description": "Current number of projects"
    },
    "notificationsEnabled": {
      "type": "boolean",
      "title": "Notificationsenabled",
      "description": "Whether notifications are enabled",
      "default": true
    },
    "preferences": {
      "anyOf": [
        {
          "$ref": "#/$defs/UserPreferences"
        },
        {
          "type": "null"
        }
      ],
      "description": "User preferences (optional)"
    }
  },
  "type": "object",
  "$defs": {
    "UserPreferences": {
      "properties": {
        "hasConfirmedThirdPartyAI": {
          "type": "boolean",
          "title": "Hasconfirmedthirdpartyai",
          "description": "Whether the user has confirmed understanding of third-party AI usage",
          "default": false
        }
      },
      "type": "object",
      "title": "UserPreferences"
    },
    "UserSubscriptionSchema": {
      "properties": {
        "isActive": {
          "type": "boolean",
          "title": "Isactive"
        },
        "expiresAt": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Expiresat"
        },
        "productId": {
          "type": "string",
          "title": "Productid"
        },
        "transactionId": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Transactionid"
        },
        "createdAt": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Createdat"
        },
        "updatedAt": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "number"
            },
            {
              "type": "string"
            },
            {
              "type": "string",
              "format": "date-time"
            },
            {
              "type": "null"
            }
          ],
          "title": "Updatedat"
        }
      },
      "type": "object",
      "required": [
        "isActive",
        "productId"
      ],
      "title": "UserSubscriptionSchema",
      "description": "Schema for current and legacy user subscription objects in Firestore."
    }
  }
}