basePath: /api
definitions:
  api.LoginRequest:
    properties:
      email:
        type: string
      password:
        type: string
    type: object
  api.LoginResponse:
    properties:
      expires_at:
        type: string
      success:
        type: boolean
      token:
        type: string
      user:
        $ref: '#/definitions/api.UserDTO'
    type: object
  api.QueryCriterion:
    properties:
      field:
        type: string
      op:
        type: string
      val: {}
    type: object
  api.QueryRequest:
    properties:
      criteria:
        items:
          $ref: '#/definitions/api.QueryCriterion'
        type: array
      filter: {}
      filter_expr:
        type: string
      group_by:
        type: string
      having:
        type: string
      limit:
        type: integer
      object_api_name:
        type: string
      offset:
        type: integer
      order_by:
        items:
          $ref: '#/definitions/api.SortCriterion'
        type: array
      scan_all:
        type: boolean
      select_fields:
        items:
          type: string
        type: array
      sort_direction:
        type: string
      sort_field:
        type: string
    type: object
  api.SortCriterion:
    properties:
      direction:
        type: string
      field:
        type: string
    type: object
  api.UserDTO:
    properties:
      email:
        type: string
      id:
        type: string
      name:
        type: string
      profile_id:
        type: string
      role_id:
        type: string
    type: object
  models.BulkConcurrencyMode:
    enum:
    - Parallel
    - Serial
    type: string
    x-enum-varnames:
    - ConcurrencyParallel
    - ConcurrencySerial
  models.BulkJob:
    properties:
      apexProcessingTime:
        type: integer
      apiActiveProcessingTime:
        type: integer
      concurrencyMode:
        $ref: '#/definitions/models.BulkConcurrencyMode'
      contentUrl:
        description: For query jobs, stores SOQL
        type: string
      createdById:
        type: string
      createdDate:
        type: string
      errorMessage:
        type: string
      externalIdFieldName:
        description: Extended Fields for Upsert and Stats
        type: string
      id:
        type: string
      jobType:
        description: Query job fields
        type: string
      numberRecordsFailed:
        type: integer
      numberRecordsProcessed:
        type: integer
      object:
        type: string
      operation:
        $ref: '#/definitions/models.BulkOperation'
      state:
        $ref: '#/definitions/models.BulkJobState'
      systemModstamp:
        type: string
      totalProcessingTime:
        description: Stats
        type: integer
    type: object
  models.BulkJobState:
    enum:
    - Open
    - UploadComplete
    - InProgress
    - JobComplete
    - Failed
    - Aborted
    type: string
    x-enum-varnames:
    - JobStateOpen
    - JobStateUploadComplete
    - JobStateInProgress
    - JobStateJobComplete
    - JobStateFailed
    - JobStateAborted
  models.BulkOperation:
    enum:
    - insert
    - update
    - upsert
    - delete
    - query
    type: string
    x-enum-varnames:
    - OperationInsert
    - OperationUpdate
    - OperationUpsert
    - OperationDelete
    - OperationQuery
  models.DeleteRule:
    enum:
    - Restrict
    - Cascade
    - SetNull
    type: string
    x-enum-varnames:
    - DeleteRuleRestrict
    - DeleteRuleCascade
    - DeleteRuleSetNull
  models.FieldMetadata:
    properties:
      api_name:
        type: string
      controlling_field:
        type: string
      default_value:
        type: string
      delete_rule:
        $ref: '#/definitions/models.DeleteRule'
      formula:
        type: string
      help_text:
        type: string
      id:
        type: string
      is_master_detail:
        type: boolean
      is_name_field:
        type: boolean
      is_polymorphic:
        description: True if len(ReferenceTo) > 1
        type: boolean
      is_system:
        type: boolean
      is_unique:
        type: boolean
      label:
        type: string
      max_length:
        type: integer
      max_value:
        type: number
      min_length:
        type: integer
      min_value:
        type: number
      options:
        items:
          type: string
        type: array
      picklist_dependency:
        additionalProperties:
          items:
            type: string
          type: array
        type: object
      precision:
        type: integer
      reference_to:
        description: Supports polymorphic (multiple objects)
        items:
          type: string
        type: array
      regex:
        type: string
      regex_message:
        type: string
      relationship_name:
        type: string
      required:
        type: boolean
      return_type:
        $ref: '#/definitions/models.FieldType'
      rollup_config:
        $ref: '#/definitions/models.RollupConfig'
      scale:
        type: integer
      track_history:
        type: boolean
      type:
        $ref: '#/definitions/models.FieldType'
      validator:
        type: string
      validator_config:
        description: JSON config for the validator
        type: string
    type: object
  models.FieldType:
    enum:
    - string
    - double
    - currency
    - date
    - datetime
    - boolean
    - picklist
    - email
    - phone
    - textarea
    - url
    - percent
    - reference
    - masterdetail
    - formula
    - rollupsummary
    - richtextarea
    - autonumber
    - multipicklist
    - encryptedstring
    - password
    - json
    type: string
    x-enum-comments:
      FieldTypeAutonumber: Auto-increment
      FieldTypeBoolean: Checkbox
      FieldTypeCurrency: Money field
      FieldTypeDate: Date only
      FieldTypeDatetime: Date + time
      FieldTypeDouble: Numeric field
      FieldTypeEmail: Email address
      FieldTypeEncryptedString: Encrypted text
      FieldTypeFormula: Calculated field
      FieldTypeJson: JSON data (custom extension)
      FieldTypeMasterDetail: Parent-child relationship
      FieldTypeMultiPicklist: Multi-select
      FieldTypePassword: Password field
      FieldTypePercent: Percentage
      FieldTypePhone: Phone number
      FieldTypePicklist: Dropdown
      FieldTypeReference: Lookup relationship
      FieldTypeRichtextarea: Rich text / HTML
      FieldTypeRollupSummary: Aggregate field
      FieldTypeString: Text field
      FieldTypeTextarea: Multi-line text
      FieldTypeUrl: Web URL
    x-enum-descriptions:
    - Text field
    - Numeric field
    - Money field
    - Date only
    - Date + time
    - Checkbox
    - Dropdown
    - Email address
    - Phone number
    - Multi-line text
    - Web URL
    - Percentage
    - Lookup relationship
    - Parent-child relationship
    - Calculated field
    - Aggregate field
    - Rich text / HTML
    - Auto-increment
    - Multi-select
    - Encrypted text
    - Password field
    - JSON data (custom extension)
    x-enum-varnames:
    - FieldTypeString
    - FieldTypeDouble
    - FieldTypeCurrency
    - FieldTypeDate
    - FieldTypeDatetime
    - FieldTypeBoolean
    - FieldTypePicklist
    - FieldTypeEmail
    - FieldTypePhone
    - FieldTypeTextarea
    - FieldTypeUrl
    - FieldTypePercent
    - FieldTypeReference
    - FieldTypeMasterDetail
    - FieldTypeFormula
    - FieldTypeRollupSummary
    - FieldTypeRichtextarea
    - FieldTypeAutonumber
    - FieldTypeMultiPicklist
    - FieldTypeEncryptedString
    - FieldTypePassword
    - FieldTypeJson
  models.ObjectMetadata:
    properties:
      api_name:
        type: string
      app_id:
        type: string
      default_list_view:
        type: string
      description:
        type: string
      enable_hierarchy_sharing:
        type: boolean
      fields:
        items:
          $ref: '#/definitions/models.FieldMetadata'
        type: array
      icon:
        type: string
      id:
        type: string
      is_custom:
        type: boolean
      is_system:
        type: boolean
      kanban_group_by:
        type: string
      kanban_summary_field:
        type: string
      label:
        type: string
      list_fields:
        items:
          type: string
        type: array
      path_field:
        description: Field to use for Path component (must be Picklist)
        type: string
      plural_label:
        type: string
      searchable:
        type: boolean
      sharing_model:
        $ref: '#/definitions/models.SharingModel'
      theme_color:
        type: string
    type: object
  models.QueryResult:
    properties:
      done:
        type: boolean
      nextRecordsUrl:
        type: string
      records:
        items:
          $ref: '#/definitions/models.SObject'
        type: array
      totalSize:
        type: integer
    type: object
  models.RollupConfig:
    properties:
      calc_type:
        description: COUNT, SUM, MIN, MAX, AVG
        type: string
      filter:
        type: string
      relationship_field:
        description: The lookup field on the child object
        type: string
      summary_field:
        type: string
      summary_object:
        type: string
    type: object
  models.SObject:
    additionalProperties: true
    type: object
  models.SharingModel:
    enum:
    - Private
    - PublicRead
    - PublicReadWrite
    type: string
    x-enum-varnames:
    - SharingModelPrivate
    - SharingModelPublicRead
    - SharingModelPublicReadWrite
  models.ValidationRule:
    properties:
      active:
        type: boolean
      condition:
        type: string
      error_message:
        type: string
      id:
        type: string
      name:
        type: string
      object_api_name:
        type: string
    type: object
host: localhost:3001
info:
  contact:
    email: support@nexuscrm.com
    name: API Support
    url: http://www.swagger.io/support
  description: Enterprise CRM API with Salesforce Compatibility.
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  termsOfService: http://swagger.io/terms/
  title: NexusCRM API
  version: 3.0.0
paths:
  /admin/recalculate-rollups/{object}:
    post:
      consumes:
      - application/json
      description: Trigger bulk recalculation of rollup fields for an object.
      parameters:
      - description: Object API Name
        in: path
        name: object
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Recalculate Rollups
      tags:
      - admin
  /admin/schema/validate:
    get:
      consumes:
      - application/json
      description: Run health check on schema definitions.
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Validate Schema Registry
      tags:
      - admin
  /admin/tables:
    get:
      consumes:
      - application/json
      description: Get list of all registered system tables.
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Get Table Registry
      tags:
      - admin
  /auth/login:
    post:
      consumes:
      - application/json
      description: Authenticate user and return JWT token.
      parameters:
      - description: Login Credentials
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/api.LoginRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/api.LoginResponse'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
        "401":
          description: Unauthorized
          schema:
            additionalProperties: true
            type: object
      summary: User Login
      tags:
      - auth
  /cometd/{version}/connect:
    post:
      consumes:
      - application/json
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              type: object
            type: array
      summary: CometD connect endpoint
      tags:
      - Streaming
  /cometd/{version}/disconnect:
    post:
      consumes:
      - application/json
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              type: object
            type: array
      summary: CometD disconnect endpoint
      tags:
      - Streaming
  /cometd/{version}/handshake:
    post:
      consumes:
      - application/json
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              type: object
            type: array
      summary: CometD handshake endpoint
      tags:
      - Streaming
  /cometd/{version}/subscribe:
    post:
      consumes:
      - application/json
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            items:
              type: object
            type: array
      summary: CometD subscribe endpoint
      tags:
      - Streaming
  /data/query:
    post:
      consumes:
      - application/json
      description: Execute a structured SOQL-like query against any object.
      parameters:
      - description: Query Request
        in: body
        name: request
        required: true
        schema:
          $ref: '#/definitions/api.QueryRequest'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.QueryResult'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
        "401":
          description: Unauthorized
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Query Data (SOQL)
      tags:
      - data
  /jobs/ingest:
    post:
      consumes:
      - application/json
      description: Create a new bulk ingest job.
      parameters:
      - description: Job Definition
        in: body
        name: job
        required: true
        schema:
          $ref: '#/definitions/models.BulkJob'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.BulkJob'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Create Bulk Job
      tags:
      - bulk
  /jobs/ingest/{jobId}:
    get:
      consumes:
      - application/json
      description: Get the status of a bulk job.
      parameters:
      - description: Job ID
        in: path
        name: jobId
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.BulkJob'
        "404":
          description: Not Found
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Get Job Status
      tags:
      - bulk
    patch:
      consumes:
      - application/json
      description: Close a bulk job to start processing.
      parameters:
      - description: Job ID
        in: path
        name: jobId
        required: true
        type: string
      - description: Job State (UploadComplete)
        in: body
        name: state
        required: true
        schema:
          additionalProperties:
            type: string
          type: object
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.BulkJob'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Close Job
      tags:
      - bulk
  /jobs/ingest/{jobId}/batches:
    put:
      consumes:
      - text/csv
      description: Upload CSV data for a bulk job.
      parameters:
      - description: Job ID
        in: path
        name: jobId
        required: true
        type: string
      - description: CSV Content
        in: formData
        name: file
        required: true
        type: file
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Upload Batch Data
      tags:
      - bulk
  /jobs/query:
    post:
      consumes:
      - application/json
      description: Create a new bulk query job for async SOQL execution
      parameters:
      - description: Query Job Definition
        in: body
        name: job
        required: true
        schema:
          type: object
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Create Bulk Query Job
      tags:
      - bulk
  /jobs/query/{jobId}:
    get:
      description: Get the status of a bulk query job
      parameters:
      - description: Job ID
        in: path
        name: jobId
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "404":
          description: Not Found
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Get Query Job Status
      tags:
      - bulk
  /jobs/query/{jobId}/results:
    get:
      description: Get the results of a completed bulk query job
      parameters:
      - description: Job ID
        in: path
        name: jobId
        required: true
        type: string
      - description: Max records to return
        in: query
        name: maxRecords
        type: integer
      - description: Pagination locator
        in: query
        name: locator
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "404":
          description: Not Found
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Get Query Results
      tags:
      - bulk
  /metadata/fieldtypes:
    get:
      consumes:
      - application/json
      description: List all available field types.
      produces:
      - application/json
      responses:
        "200":
          description: Wrapped list of field types
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Get Field Types
      tags:
      - metadata
  /metadata/objects:
    get:
      consumes:
      - application/json
      description: Get metadata for all registered objects.
      produces:
      - application/json
      responses:
        "200":
          description: Wrapped list of schemas
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: List Object Schemas
      tags:
      - metadata
    post:
      consumes:
      - application/json
      description: Create a new custom object definition.
      parameters:
      - description: Object Metadata
        in: body
        name: schema
        required: true
        schema:
          $ref: '#/definitions/models.ObjectMetadata'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/models.ObjectMetadata'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Create Object Schema
      tags:
      - metadata
  /metadata/objects/{apiName}:
    delete:
      consumes:
      - application/json
      description: Delete a custom object and all associated data.
      parameters:
      - description: Object API Name
        in: path
        name: apiName
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Delete Object Schema
      tags:
      - metadata
    get:
      consumes:
      - application/json
      description: Get metadata for a specific object by API Name.
      parameters:
      - description: Object API Name
        in: path
        name: apiName
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.ObjectMetadata'
        "404":
          description: Not Found
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Get Object Schema
      tags:
      - metadata
    patch:
      consumes:
      - application/json
      description: Update an existing object definition.
      parameters:
      - description: Object API Name
        in: path
        name: apiName
        required: true
        type: string
      - description: Schema Updates
        in: body
        name: updates
        required: true
        schema:
          $ref: '#/definitions/models.ObjectMetadata'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.ObjectMetadata'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Update Object Schema
      tags:
      - metadata
  /metadata/objects/{apiName}/fields:
    post:
      consumes:
      - application/json
      description: Add a new field to an object.
      parameters:
      - description: Object API Name
        in: path
        name: apiName
        required: true
        type: string
      - description: Field Definition
        in: body
        name: field
        required: true
        schema:
          $ref: '#/definitions/models.FieldMetadata'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/models.FieldMetadata'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Create Field
      tags:
      - metadata
  /metadata/objects/{apiName}/fields/{fieldApiName}:
    delete:
      consumes:
      - application/json
      description: Delete a field and its data.
      parameters:
      - description: Object API Name
        in: path
        name: apiName
        required: true
        type: string
      - description: Field API Name
        in: path
        name: fieldApiName
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Delete Field
      tags:
      - metadata
    patch:
      consumes:
      - application/json
      description: Update an existing field definition.
      parameters:
      - description: Object API Name
        in: path
        name: apiName
        required: true
        type: string
      - description: Field API Name
        in: path
        name: fieldApiName
        required: true
        type: string
      - description: Field Updates
        in: body
        name: updates
        required: true
        schema:
          $ref: '#/definitions/models.FieldMetadata'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.FieldMetadata'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Update Field
      tags:
      - metadata
  /metadata/objects/{apiName}/fields/batch:
    post:
      consumes:
      - application/json
      description: Create multiple fields for an object in one transaction.
      parameters:
      - description: Object API Name
        in: path
        name: apiName
        required: true
        type: string
      - description: List of Field Definitions
        in: body
        name: fields
        required: true
        schema:
          items:
            $ref: '#/definitions/models.FieldMetadata'
          type: array
      produces:
      - application/json
      responses:
        "201":
          description: Wrapped list of created fields
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Batch Create Fields
      tags:
      - metadata
  /metadata/validation-rules:
    get:
      consumes:
      - application/json
      description: List validation rules for an object.
      parameters:
      - description: Object API Name
        in: query
        name: objectApiName
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: Wrapped list of rules
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Get Validation Rules
      tags:
      - metadata
    post:
      consumes:
      - application/json
      description: Create a new validation rule for an object.
      parameters:
      - description: Validation Rule
        in: body
        name: rule
        required: true
        schema:
          $ref: '#/definitions/models.ValidationRule'
      produces:
      - application/json
      responses:
        "201":
          description: Created
          schema:
            $ref: '#/definitions/models.ValidationRule'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Create Validation Rule
      tags:
      - metadata
  /metadata/validation-rules/{id}:
    delete:
      consumes:
      - application/json
      description: Delete a validation rule.
      parameters:
      - description: Rule ID
        in: path
        name: id
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Delete Validation Rule
      tags:
      - metadata
    patch:
      consumes:
      - application/json
      description: Update an existing validation rule.
      parameters:
      - description: Rule ID
        in: path
        name: id
        required: true
        type: string
      - description: Rule Updates
        in: body
        name: updates
        required: true
        schema:
          $ref: '#/definitions/models.ValidationRule'
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            $ref: '#/definitions/models.ValidationRule'
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Update Validation Rule
      tags:
      - metadata
  /search:
    get:
      description: Execute a SOSL search query using FIND syntax
      parameters:
      - description: SOSL Query (e.g. FIND {term} IN ALL FIELDS RETURNING Account)
        in: query
        name: q
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: OK
          schema:
            additionalProperties: true
            type: object
        "400":
          description: Bad Request
          schema:
            additionalProperties: true
            type: object
      security:
      - BearerAuth: []
      summary: Execute SOSL Search
      tags:
      - sosl
  /ws:
    get:
      responses:
        "101":
          description: Switching Protocols
          schema:
            type: string
      summary: WebSocket connection endpoint
      tags:
      - Streaming
securityDefinitions:
  BearerAuth:
    in: header
    name: Authorization
    type: apiKey
swagger: "2.0"
