import { AutofixRun, AutofixRunState, ClientKey, ClientKeyList, Event, EventAttachment, EventAttachmentList, Issue, IssueList, OrganizationList, Project, ProjectList, ReleaseList, TagList, Team, TeamList, Trace, TraceMeta, User } from "./types-DoT0an28.js";

//#region src/api-client/client.d.ts

/**
 * Custom error class for Sentry API responses.
 *
 * Provides enhanced error messages for LLM consumption and handles
 * common API error scenarios with user-friendly messaging.
 *
 * @example
 * ```typescript
 * try {
 *   await apiService.listIssues({ organizationSlug: "invalid" });
 * } catch (error) {
 *   if (error instanceof ApiError) {
 *     console.log(`API Error ${error.status}: ${error.message}`);
 *   }
 * }
 * ```
 */
type RequestOptions = {
  host?: string;
};
/**
 * Sentry API client service for interacting with Sentry's REST API.
 *
 * This service provides a comprehensive interface to Sentry's API endpoints,
 * handling authentication, error processing, multi-region support, and
 * response validation through Zod schemas.
 *
 * Key Features:
 * - Multi-region support for Sentry SaaS and self-hosted instances
 * - Automatic schema validation with Zod
 * - Enhanced error handling with LLM-friendly messages
 * - URL generation for Sentry resources (issues, traces)
 * - Bearer token authentication
 * - Always uses HTTPS for secure connections
 *
 * @example Basic Usage
 * ```typescript
 * const apiService = new SentryApiService({
 *   accessToken: "your-token",
 *   host: "sentry.io"
 * });
 *
 * const orgs = await apiService.listOrganizations();
 * const issues = await apiService.listIssues({
 *   organizationSlug: "my-org",
 *   query: "is:unresolved"
 * });
 * ```
 *
 * @example Multi-Region Support
 * ```typescript
 * // Self-hosted instance with hostname
 * const selfHosted = new SentryApiService({
 *   accessToken: "token",
 *   host: "sentry.company.com"
 * });
 *
 * // Regional endpoint override
 * const issues = await apiService.listIssues(
 *   { organizationSlug: "org" },
 *   { host: "eu.sentry.io" }
 * );
 * ```
 */
declare class SentryApiService {
  private accessToken;
  protected host: string;
  protected apiPrefix: string;
  /**
   * Creates a new Sentry API service instance.
   *
   * Always uses HTTPS for secure connections.
   *
   * @param config Configuration object
   * @param config.accessToken OAuth access token for authentication (optional for some endpoints)
   * @param config.host Sentry hostname (e.g. "sentry.io", "sentry.example.com")
   */
  constructor({
    accessToken,
    host
  }: {
    accessToken?: string | null;
    host?: string;
  });
  /**
   * Updates the host for API requests.
   *
   * Used for multi-region support or switching between Sentry instances.
   * Always uses HTTPS protocol.
   *
   * @param host New hostname to use for API requests
   */
  setHost(host: string): void;
  /**
   * Checks if the current host is Sentry SaaS (sentry.io).
   *
   * Used to determine API endpoint availability and URL formats.
   * Self-hosted instances may not have all endpoints available.
   *
   * @returns True if using Sentry SaaS, false for self-hosted instances
   */
  private isSaas;
  /**
   * Internal method for making authenticated requests to Sentry API.
   *
   * Handles:
   * - Bearer token authentication
   * - Error response parsing and enhancement
   * - Multi-region host overrides
   * - Fetch availability validation
   *
   * @param path API endpoint path (without /api/0 prefix)
   * @param options Fetch options
   * @param requestOptions Additional request configuration
   * @returns Promise resolving to Response object
   * @throws {ApiError} Enhanced API errors with user-friendly messages
   * @throws {Error} Network or parsing errors
   */
  private request;
  /**
   * Safely parses a JSON response, checking Content-Type header first.
   *
   * @param response The Response object from fetch
   * @returns Promise resolving to the parsed JSON object
   * @throws {Error} If response is not JSON or parsing fails
   */
  private parseJsonResponse;
  /**
   * Makes a request to the Sentry API and parses the JSON response.
   *
   * This is the primary method for API calls that expect JSON responses.
   * It automatically validates Content-Type and provides helpful error messages
   * for common issues like authentication failures or server errors.
   *
   * @param path API endpoint path (without /api/0 prefix)
   * @param options Fetch options
   * @param requestOptions Additional request configuration
   * @returns Promise resolving to the parsed JSON response
   * @throws {ApiError} Enhanced API errors with user-friendly messages
   * @throws {Error} Network, parsing, or validation errors
   */
  private requestJSON;
  /**
   * Generates a Sentry issue URL for browser navigation.
   *
   * Handles both SaaS (subdomain-based) and self-hosted URL formats.
   * Always uses HTTPS protocol.
   *
   * @param organizationSlug Organization identifier
   * @param issueId Issue identifier (short ID or numeric ID)
   * @returns Full URL to the issue in Sentry UI
   *
   * @example
   * ```typescript
   * // SaaS: https://my-org.sentry.io/issues/PROJ-123
   * apiService.getIssueUrl("my-org", "PROJ-123")
   *
   * // Self-hosted: https://sentry.company.com/organizations/my-org/issues/PROJ-123
   * apiService.getIssueUrl("my-org", "PROJ-123")
   * ```
   */
  getIssueUrl(organizationSlug: string, issueId: string): string;
  /**
   * Generates a Sentry trace URL for performance investigation.
   *
   * Always uses HTTPS protocol.
   *
   * @param organizationSlug Organization identifier
   * @param traceId Trace identifier (hex string)
   * @returns Full HTTPS URL to the trace in Sentry UI
   *
   * @example
   * ```typescript
   * const traceUrl = apiService.getTraceUrl("my-org", "6a477f5b0f31ef7b6b9b5e1dea66c91d");
   * // https://my-org.sentry.io/explore/traces/trace/6a477f5b0f31ef7b6b9b5e1dea66c91d
   * ```
   */
  getTraceUrl(organizationSlug: string, traceId: string): string;
  /**
   * Builds a URL for the legacy Discover API (used by errors dataset).
   *
   * The Discover API is the older query interface that includes aggregate
   * functions directly in the field list.
   *
   * @example
   * // URL format: /explore/discover/homepage/?field=title&field=count_unique(user)
   * buildDiscoverUrl("my-org", "level:error", "123", ["title", "count_unique(user)"], "-timestamp")
   */
  private buildDiscoverUrl;
  /**
   * Builds a URL for the modern EAP (Event Analytics Platform) API used by spans/logs.
   *
   * The EAP API uses structured aggregate queries with separate aggregateField
   * parameters containing JSON objects for groupBy and yAxes.
   *
   * @example
   * // URL format: /explore/traces/?aggregateField={"groupBy":"span.op"}&aggregateField={"yAxes":["count()"]}
   * buildEapUrl("my-org", "span.op:db", "123", ["span.op", "count()"], "-count()", ["count()"], ["span.op"])
   */
  private buildEapUrl;
  /**
   * Generates a Sentry events explorer URL for viewing search results.
   *
   * Routes to the appropriate API based on dataset:
   * - Errors: Uses legacy Discover API
   * - Spans/Logs: Uses modern EAP (Event Analytics Platform) API
   *
   * @param organizationSlug Organization identifier
   * @param query Sentry search query
   * @param projectId Optional project filter
   * @param dataset Dataset type (spans, errors, or logs)
   * @param fields Array of fields to include in results
   * @param sort Sort parameter (e.g., "-timestamp", "-count()")
   * @param aggregateFunctions Array of aggregate functions (only used for EAP datasets)
   * @param groupByFields Array of fields to group by (only used for EAP datasets)
   * @param statsPeriod Relative time period (e.g., "24h", "7d")
   * @param start Absolute start time (ISO 8601)
   * @param end Absolute end time (ISO 8601)
   * @returns Full HTTPS URL to the events explorer in Sentry UI
   */
  getEventsExplorerUrl(organizationSlug: string, query: string, projectId?: string, dataset?: "spans" | "errors" | "logs", fields?: string[], sort?: string, aggregateFunctions?: string[], groupByFields?: string[], statsPeriod?: string, start?: string, end?: string): string;
  /**
   * Retrieves the authenticated user's profile information.
   *
   * @param opts Request options including host override
   * @returns User profile data
   * @throws {ApiError} If authentication fails or user not found
   */
  getAuthenticatedUser(opts?: RequestOptions): Promise<User>;
  /**
   * Lists all organizations accessible to the authenticated user.
   *
   * Automatically handles multi-region queries by fetching from all
   * available regions and combining results.
   *
   * @param params Query parameters
   * @param params.query Search query to filter organizations by name/slug
   * @param opts Request options
   * @returns Array of organizations across all accessible regions (limited to 25 results)
   *
   * @example
   * ```typescript
   * const orgs = await apiService.listOrganizations();
   * orgs.forEach(org => {
   *   // regionUrl present for Cloud Service, empty for self-hosted
   *   console.log(`${org.name} (${org.slug}) - ${org.links?.regionUrl || 'No region URL'}`);
   * });
   * ```
   */
  listOrganizations(params?: {
    query?: string;
  }, opts?: RequestOptions): Promise<OrganizationList>;
  /**
   * Gets a single organization by slug.
   *
   * @param organizationSlug Organization identifier
   * @param opts Request options including host override
   * @returns Organization data
   */
  getOrganization(organizationSlug: string, opts?: RequestOptions): Promise<{
    name: string;
    slug: string;
    id: string | number;
    links?: {
      organizationUrl: string;
      regionUrl?: string | undefined;
    } | undefined;
  }>;
  /**
   * Lists teams within an organization.
   *
   * @param organizationSlug Organization identifier
   * @param params Query parameters
   * @param params.query Search query to filter teams by name/slug
   * @param opts Request options including host override
   * @returns Array of teams in the organization (limited to 25 results)
   */
  listTeams(organizationSlug: string, params?: {
    query?: string;
  }, opts?: RequestOptions): Promise<TeamList>;
  /**
   * Creates a new team within an organization.
   *
   * @param params Team creation parameters
   * @param params.organizationSlug Organization identifier
   * @param params.name Team name
   * @param opts Request options
   * @returns Created team data
   * @throws {ApiError} If team creation fails (e.g., name conflicts)
   */
  createTeam({
    organizationSlug,
    name
  }: {
    organizationSlug: string;
    name: string;
  }, opts?: RequestOptions): Promise<Team>;
  /**
   * Lists projects within an organization.
   *
   * @param organizationSlug Organization identifier
   * @param params Query parameters
   * @param params.query Search query to filter projects by name/slug
   * @param opts Request options
   * @returns Array of projects in the organization (limited to 25 results)
   */
  listProjects(organizationSlug: string, params?: {
    query?: string;
  }, opts?: RequestOptions): Promise<ProjectList>;
  /**
   * Gets a single project by slug or ID.
   *
   * @param params Project fetch parameters
   * @param params.organizationSlug Organization identifier
   * @param params.projectSlugOrId Project slug or numeric ID
   * @param opts Request options
   * @returns Project data
   */
  getProject({
    organizationSlug,
    projectSlugOrId
  }: {
    organizationSlug: string;
    projectSlugOrId: string;
  }, opts?: RequestOptions): Promise<Project>;
  /**
   * Creates a new project within a team.
   *
   * @param params Project creation parameters
   * @param params.organizationSlug Organization identifier
   * @param params.teamSlug Team identifier
   * @param params.name Project name
   * @param params.platform Platform identifier (e.g., "javascript", "python")
   * @param opts Request options
   * @returns Created project data
   */
  createProject({
    organizationSlug,
    teamSlug,
    name,
    platform
  }: {
    organizationSlug: string;
    teamSlug: string;
    name: string;
    platform?: string;
  }, opts?: RequestOptions): Promise<Project>;
  /**
   * Updates an existing project's configuration.
   *
   * @param params Project update parameters
   * @param params.organizationSlug Organization identifier
   * @param params.projectSlug Current project identifier
   * @param params.name New project name (optional)
   * @param params.slug New project slug (optional)
   * @param params.platform New platform identifier (optional)
   * @param opts Request options
   * @returns Updated project data
   */
  updateProject({
    organizationSlug,
    projectSlug,
    name,
    slug,
    platform
  }: {
    organizationSlug: string;
    projectSlug: string;
    name?: string;
    slug?: string;
    platform?: string;
  }, opts?: RequestOptions): Promise<Project>;
  /**
   * Assigns a team to a project.
   *
   * @param params Assignment parameters
   * @param params.organizationSlug Organization identifier
   * @param params.projectSlug Project identifier
   * @param params.teamSlug Team identifier to assign
   * @param opts Request options
   */
  addTeamToProject({
    organizationSlug,
    projectSlug,
    teamSlug
  }: {
    organizationSlug: string;
    projectSlug: string;
    teamSlug: string;
  }, opts?: RequestOptions): Promise<void>;
  /**
   * Creates a new client key (DSN) for a project.
   *
   * Client keys are used to identify and authenticate SDK requests to Sentry.
   *
   * @param params Key creation parameters
   * @param params.organizationSlug Organization identifier
   * @param params.projectSlug Project identifier
   * @param params.name Human-readable name for the key (optional)
   * @param opts Request options
   * @returns Created client key with DSN information
   *
   * @example
   * ```typescript
   * const key = await apiService.createClientKey({
   *   organizationSlug: "my-org",
   *   projectSlug: "my-project",
   *   name: "Production"
   * });
   * console.log(`DSN: ${key.dsn.public}`);
   * ```
   */
  createClientKey({
    organizationSlug,
    projectSlug,
    name
  }: {
    organizationSlug: string;
    projectSlug: string;
    name?: string;
  }, opts?: RequestOptions): Promise<ClientKey>;
  /**
   * Lists all client keys (DSNs) for a project.
   *
   * @param params Query parameters
   * @param params.organizationSlug Organization identifier
   * @param params.projectSlug Project identifier
   * @param opts Request options
   * @returns Array of client keys with DSN information
   */
  listClientKeys({
    organizationSlug,
    projectSlug
  }: {
    organizationSlug: string;
    projectSlug: string;
  }, opts?: RequestOptions): Promise<ClientKeyList>;
  /**
   * Lists releases for an organization or specific project.
   *
   * @param params Query parameters
   * @param params.organizationSlug Organization identifier
   * @param params.projectSlug Project identifier (optional, scopes to specific project)
   * @param params.query Search query for filtering releases
   * @param opts Request options
   * @returns Array of releases with deployment and commit information
   *
   * @example
   * ```typescript
   * // All releases for organization
   * const releases = await apiService.listReleases({
   *   organizationSlug: "my-org"
   * });
   *
   * // Search for specific version
   * const filtered = await apiService.listReleases({
   *   organizationSlug: "my-org",
   *   query: "v1.2.3"
   * });
   * ```
   */
  listReleases({
    organizationSlug,
    projectSlug,
    query
  }: {
    organizationSlug: string;
    projectSlug?: string;
    query?: string;
  }, opts?: RequestOptions): Promise<ReleaseList>;
  /**
   * Lists available tags for search queries.
   *
   * Tags represent indexed fields that can be used in Sentry search queries.
   *
   * @param params Query parameters
   * @param params.organizationSlug Organization identifier
   * @param params.dataset Dataset to query tags for ("events", "errors" or "search_issues")
   * @param params.project Numeric project ID to filter tags
   * @param params.statsPeriod Time range for tag statistics (e.g., "24h", "7d")
   * @param params.useCache Whether to use cached results
   * @param params.useFlagsBackend Whether to use flags backend features
   * @param opts Request options
   * @returns Array of available tags with metadata
   *
   * @example
   * ```typescript
   * const tags = await apiService.listTags({
   *   organizationSlug: "my-org",
   *   dataset: "events",
   *   project: "123456",
   *   statsPeriod: "24h",
   *   useCache: true
   * });
   * tags.forEach(tag => console.log(`${tag.key}: ${tag.name}`));
   * ```
   */
  listTags({
    organizationSlug,
    dataset,
    project,
    statsPeriod,
    start,
    end,
    useCache,
    useFlagsBackend
  }: {
    organizationSlug: string;
    dataset?: "events" | "errors" | "search_issues";
    project?: string;
    statsPeriod?: string;
    start?: string;
    end?: string;
    useCache?: boolean;
    useFlagsBackend?: boolean;
  }, opts?: RequestOptions): Promise<TagList>;
  /**
   * Lists trace item attributes available for search queries.
   *
   * Returns all available fields/attributes that can be used in event searches,
   * including both built-in fields and custom tags.
   *
   * @param params Query parameters
   * @param params.organizationSlug Organization identifier
   * @param params.itemType Item type to query attributes for ("spans" or "logs")
   * @param params.project Numeric project ID to filter attributes
   * @param params.statsPeriod Time range for attribute statistics (e.g., "24h", "7d")
   * @param opts Request options
   * @returns Array of available attributes with metadata including type
   */
  listTraceItemAttributes({
    organizationSlug,
    itemType,
    project,
    statsPeriod,
    start,
    end
  }: {
    organizationSlug: string;
    itemType?: "spans" | "logs";
    project?: string;
    statsPeriod?: string;
    start?: string;
    end?: string;
  }, opts?: RequestOptions): Promise<Array<{
    key: string;
    name: string;
    type: "string" | "number";
  }>>;
  private fetchTraceItemAttributesByType;
  /**
   * Lists issues within an organization or project.
   *
   * Issues represent groups of similar errors or problems in your application.
   * Supports Sentry's powerful query syntax for filtering and sorting.
   *
   * @param params Query parameters
   * @param params.organizationSlug Organization identifier
   * @param params.projectSlug Project identifier (optional, scopes to specific project)
   * @param params.query Sentry search query (e.g., "is:unresolved browser:chrome")
   * @param params.sortBy Sort order ("user", "freq", "date", "new")
   * @param opts Request options
   * @returns Array of issues with metadata and statistics
   *
   * @example
   * ```typescript
   * // Recent unresolved issues
   * const issues = await apiService.listIssues({
   *   organizationSlug: "my-org",
   *   query: "is:unresolved",
   *   sortBy: "date"
   * });
   *
   * // High-frequency errors in specific project
   * const critical = await apiService.listIssues({
   *   organizationSlug: "my-org",
   *   projectSlug: "backend",
   *   query: "level:error",
   *   sortBy: "freq"
   * });
   * ```
   */
  listIssues({
    organizationSlug,
    projectSlug,
    query,
    sortBy,
    limit
  }: {
    organizationSlug: string;
    projectSlug?: string;
    query?: string | null;
    sortBy?: "user" | "freq" | "date" | "new";
    limit?: number;
  }, opts?: RequestOptions): Promise<IssueList>;
  getIssue({
    organizationSlug,
    issueId
  }: {
    organizationSlug: string;
    issueId: string;
  }, opts?: RequestOptions): Promise<Issue>;
  getEventForIssue({
    organizationSlug,
    issueId,
    eventId
  }: {
    organizationSlug: string;
    issueId: string;
    eventId: string;
  }, opts?: RequestOptions): Promise<Event>;
  getLatestEventForIssue({
    organizationSlug,
    issueId
  }: {
    organizationSlug: string;
    issueId: string;
  }, opts?: RequestOptions): Promise<Event>;
  listEventAttachments({
    organizationSlug,
    projectSlug,
    eventId
  }: {
    organizationSlug: string;
    projectSlug: string;
    eventId: string;
  }, opts?: RequestOptions): Promise<EventAttachmentList>;
  getEventAttachment({
    organizationSlug,
    projectSlug,
    eventId,
    attachmentId
  }: {
    organizationSlug: string;
    projectSlug: string;
    eventId: string;
    attachmentId: string;
  }, opts?: RequestOptions): Promise<{
    attachment: EventAttachment;
    downloadUrl: string;
    filename: string;
    blob: Blob;
  }>;
  updateIssue({
    organizationSlug,
    issueId,
    status,
    assignedTo
  }: {
    organizationSlug: string;
    issueId: string;
    status?: string;
    assignedTo?: string;
  }, opts?: RequestOptions): Promise<Issue>;
  searchErrors({
    organizationSlug,
    projectSlug,
    filename,
    transaction,
    query,
    sortBy
  }: {
    organizationSlug: string;
    projectSlug?: string;
    filename?: string;
    transaction?: string;
    query?: string;
    sortBy?: "last_seen" | "count";
  }, opts?: RequestOptions): Promise<{
    issue: string;
    "issue.id": string | number;
    project: string;
    title: string;
    "count()": number;
    "last_seen()": string;
  }[]>;
  searchSpans({
    organizationSlug,
    projectSlug,
    transaction,
    query,
    sortBy
  }: {
    organizationSlug: string;
    projectSlug?: string;
    transaction?: string;
    query?: string;
    sortBy?: "timestamp" | "duration";
  }, opts?: RequestOptions): Promise<{
    id: string;
    project: string;
    trace: string;
    "span.op": string;
    "span.description": string;
    "span.duration": number;
    transaction: string;
    timestamp: string;
  }[]>;
  /**
   * Builds query parameters for the legacy Discover API (primarily used by errors dataset).
   *
   * Note: While the API endpoint is the same for all datasets, we maintain separate
   * builders to make future divergence easier and to keep the code organized.
   */
  private buildDiscoverApiQuery;
  /**
   * Builds query parameters for the modern EAP API (used by spans/logs datasets).
   *
   * Includes dataset-specific parameters like sampling for spans.
   */
  private buildEapApiQuery;
  /**
   * Searches for events in Sentry using the unified events API.
   * This method is used by the search_events tool for semantic search.
   *
   * Routes to the appropriate query builder based on dataset, even though
   * the underlying API endpoint is the same. This separation makes the code
   * cleaner and allows for future API divergence.
   */
  searchEvents({
    organizationSlug,
    query,
    fields,
    limit,
    projectId,
    dataset,
    statsPeriod,
    start,
    end,
    sort
  }: {
    organizationSlug: string;
    query: string;
    fields: string[];
    limit?: number;
    projectId?: string;
    dataset?: "spans" | "errors" | "ourlogs";
    statsPeriod?: string;
    start?: string;
    end?: string;
    sort?: string;
  }, opts?: RequestOptions): Promise<unknown>;
  startAutofix({
    organizationSlug,
    issueId,
    eventId,
    instruction
  }: {
    organizationSlug: string;
    issueId: string;
    eventId?: string;
    instruction?: string;
  }, opts?: RequestOptions): Promise<AutofixRun>;
  getAutofixState({
    organizationSlug,
    issueId
  }: {
    organizationSlug: string;
    issueId: string;
  }, opts?: RequestOptions): Promise<AutofixRunState>;
  /**
   * Retrieves high-level metadata about a trace.
   *
   * Returns statistics including span counts, error counts, transaction
   * breakdown, and operation type distribution for the specified trace.
   *
   * @param params Query parameters
   * @param params.organizationSlug Organization identifier
   * @param params.traceId Trace identifier (32-character hex string)
   * @param params.statsPeriod Optional stats period (e.g., "14d", "7d")
   * @param opts Request options
   * @returns Trace metadata with statistics
   *
   * @example
   * ```typescript
   * const traceMeta = await apiService.getTraceMeta({
   *   organizationSlug: "my-org",
   *   traceId: "a4d1aae7216b47ff8117cf4e09ce9d0a"
   * });
   * console.log(`Trace has ${traceMeta.span_count} spans`);
   * ```
   */
  getTraceMeta({
    organizationSlug,
    traceId,
    statsPeriod
  }: {
    organizationSlug: string;
    traceId: string;
    statsPeriod?: string;
  }, opts?: RequestOptions): Promise<TraceMeta>;
  /**
   * Retrieves the complete trace structure with all spans.
   *
   * Returns the hierarchical trace data including all spans, their timing
   * information, operation details, and nested relationships.
   *
   * @param params Query parameters
   * @param params.organizationSlug Organization identifier
   * @param params.traceId Trace identifier (32-character hex string)
   * @param params.limit Maximum number of spans to return (default: 1000)
   * @param params.project Project filter (-1 for all projects)
   * @param params.statsPeriod Optional stats period (e.g., "14d", "7d")
   * @param opts Request options
   * @returns Complete trace tree structure
   *
   * @example
   * ```typescript
   * const trace = await apiService.getTrace({
   *   organizationSlug: "my-org",
   *   traceId: "a4d1aae7216b47ff8117cf4e09ce9d0a",
   *   limit: 1000
   * });
   * console.log(`Root spans: ${trace.length}`);
   * ```
   */
  getTrace({
    organizationSlug,
    traceId,
    limit,
    project,
    statsPeriod
  }: {
    organizationSlug: string;
    traceId: string;
    limit?: number;
    project?: string;
    statsPeriod?: string;
  }, opts?: RequestOptions): Promise<Trace>;
}
//#endregion
export { SentryApiService };
//# sourceMappingURL=client-njqQAP-R.d.ts.map