openapi: 3.0.0
info:
  title: NexusCRM API
  description: Strict API Schema generated from single source of truth.
  version: 1.0.0
components:
  schemas:
    AnalyticsQuery:
      type: object
      description: Aggregation query request
      properties:
        field:
          type: string
        filterExpr:
          type: string
        groupBy:
          type: string
        objectApiName:
          type: string
        operation:
          type: string
          description: count, sum, avg, etc.
      required:
        - objectApiName
        - operation
    LoginRequest:
      type: object
      description: Login credentials
      properties:
        Email:
          type: string
        Password:
          type: string
      required:
        - Email
        - Password
    LoginResponse:
      type: object
      description: Authentication success payload
      properties:
        ExpiresAt:
          type: string
        Success:
          type: boolean
        Token:
          type: string
        User:
          $ref: '#/components/schemas/UserDTO'
      required:
        - Success
        - Token
        - User
        - ExpiresAt
    PermissionSetDTO:
      type: object
      description: Effective user permissions
      properties:
        FieldPermissions:
          type: object
        ObjectPermissions:
          type: object
      required:
        - ObjectPermissions
        - FieldPermissions
    QueryCriterion:
      type: object
      description: Single filter condition
      properties:
        field:
          type: string
        op:
          type: string
          description: 'Operator: eq, neq, gt, lt, etc.'
        val:
          type: object
      required:
        - field
        - op
        - val
    QueryRequest:
      type: object
      description: Standard SOQL-compatible query request
      properties:
        criteria:
          type: array
          description: Structured criteria items
          items:
            $ref: '#/components/schemas/QueryCriterion'
        filterExpr:
          type: string
          description: Filter expression string (e.g. name = 'Acme')
        groupBy:
          type: string
          description: Group By clause
        having:
          type: string
          description: Having clause
        limit:
          type: integer
          description: Max records to return
          format: int32
        objectApiName:
          type: string
          description: The API name of the object to query
        offset:
          type: integer
          description: Offset for pagination
          format: int32
        orderBy:
          type: array
          description: Structured sorting items
          items:
            $ref: '#/components/schemas/SortCriterion'
        scanAll:
          type: boolean
          description: Include deleted records
        selectFields:
          type: array
          description: Specific fields to Select (REQUIRED - Salesforce SOQL requires explicit field list)
          items:
            type: string
        sortDirection:
          type: string
          description: ASC or DESC
        sortField:
          type: string
          description: Field to sort by
        subQueries:
          type: array
          description: Child relationship subqueries parsed from SOQL
          items:
            $ref: '#/components/schemas/SubQueryRequest'
      required:
        - objectApiName
        - selectFields
    SearchRequest:
      type: object
      description: Global search request
      properties:
        term:
          type: string
      required:
        - term
    SearchResult:
      type: object
      description: Global search result item
      properties:
        Icon:
          type: string
        Matches:
          type: array
          items:
            type: object
        ObjectApiName:
          type: string
        ObjectLabel:
          type: string
    SortCriterion:
      type: object
      description: Single sort condition
      properties:
        direction:
          type: string
        field:
          type: string
      required:
        - field
        - direction
    SubQueryRequest:
      type: object
      description: Child relationship subquery request
      properties:
        filterExpr:
          type: string
          description: WHERE clause for the child subquery
        limit:
          type: integer
          description: Maximum child rows to return
          format: int32
        orderBy:
          type: array
          description: ORDER BY clauses for the child subquery
          items:
            $ref: '#/components/schemas/SortCriterion'
        relationshipName:
          type: string
          description: Child relationship API name
        selectFields:
          type: array
          description: Fields selected in the child subquery
          items:
            type: string
      required:
        - relationshipName
        - selectFields
    UserDTO:
      type: object
      description: Public user profile data
      properties:
        Email:
          type: string
        Id:
          type: string
        Name:
          type: string
        ProfileId:
          type: string
        UserRoleId:
          type: string
      required:
        - Id
        - Name
        - Email
        - ProfileId
paths: {}
