Home / Class/ SupermodelClient Class — typescript-sdk Architecture

SupermodelClient Class — typescript-sdk Architecture

Architecture documentation for the SupermodelClient class in async.ts from the typescript-sdk codebase.

Entity Profile

Relationship Graph

Source Code

src/async.ts lines 274–376

export class SupermodelClient {
  private api: DefaultApi;
  private options: AsyncClientOptions;
  private generateIdempotencyKey: () => string;

  constructor(api: DefaultApi, options: AsyncClientOptions = {}) {
    this.api = api;
    this.options = options;
    this.generateIdempotencyKey = options.generateIdempotencyKey || defaultGenerateIdempotencyKey;
  }

  /**
   * Generate a dependency graph from a zip file.
   * Automatically handles polling until the job completes.
   * 
   * @param file - Zip file containing the repository
   * @param options - Optional request options
   * @returns The dependency graph result
   */
  async generateDependencyGraph(
    file: Blob,
    options?: GraphRequestOptions
  ): Promise<CodeGraphEnvelope> {
    const key = options?.idempotencyKey || this.generateIdempotencyKey();
    const pollOptions = options?.signal ? { ...this.options, signal: options.signal } : this.options;
    return pollUntilComplete<CodeGraphEnvelope, CodeGraphEnvelopeAsync>(
      () => this.api.generateDependencyGraph({ idempotencyKey: key, file }, options?.initOverrides),
      pollOptions
    );
  }

  /**
   * Generate a call graph from a zip file.
   * Automatically handles polling until the job completes.
   */
  async generateCallGraph(
    file: Blob,
    options?: GraphRequestOptions
  ): Promise<CodeGraphEnvelope> {
    const key = options?.idempotencyKey || this.generateIdempotencyKey();
    const pollOptions = options?.signal ? { ...this.options, signal: options.signal } : this.options;
    return pollUntilComplete<CodeGraphEnvelope, CodeGraphEnvelopeAsync>(
      () => this.api.generateCallGraph({ idempotencyKey: key, file }, options?.initOverrides),
      pollOptions
    );
  }

  /**
   * Generate a domain graph from a zip file.
   * Automatically handles polling until the job completes.
   */
  async generateDomainGraph(
    file: Blob,
    options?: GraphRequestOptions
  ): Promise<DomainClassificationResponse> {
    const key = options?.idempotencyKey || this.generateIdempotencyKey();
    const pollOptions = options?.signal ? { ...this.options, signal: options.signal } : this.options;
    return pollUntilComplete<DomainClassificationResponse, DomainClassificationResponseAsync>(
      () => this.api.generateDomainGraph({ idempotencyKey: key, file }, options?.initOverrides),
      pollOptions
    );
  }

  /**
   * Generate a parse graph from a zip file.
   * Automatically handles polling until the job completes.
   */
  async generateParseGraph(
    file: Blob,
    options?: GraphRequestOptions
  ): Promise<CodeGraphEnvelope> {
    const key = options?.idempotencyKey || this.generateIdempotencyKey();
    const pollOptions = options?.signal ? { ...this.options, signal: options.signal } : this.options;
    return pollUntilComplete<CodeGraphEnvelope, CodeGraphEnvelopeAsync>(
      () => this.api.generateParseGraph({ idempotencyKey: key, file }, options?.initOverrides),
      pollOptions
    );
  }

  /**
   * Generate a Supermodel IR from a zip file.
   * Automatically handles polling until the job completes.
   */
  async generateSupermodelGraph(
    file: Blob,
    options?: GraphRequestOptions
  ): Promise<SupermodelIR> {
    const key = options?.idempotencyKey || this.generateIdempotencyKey();
    const pollOptions = options?.signal ? { ...this.options, signal: options.signal } : this.options;
    return pollUntilComplete<SupermodelIR, SupermodelIRAsync>(
      () => this.api.generateSupermodelGraph({ idempotencyKey: key, file }, options?.initOverrides),
      pollOptions
    );
  }

  /**
   * Access the underlying raw API for methods that don't need polling
   * or when you want direct control over the async envelope responses.
   */
  get rawApi(): DefaultApi {
    return this.api;
  }
}

Domain

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free