import {
  PlatformApiError,
  PlatformApiTimeoutError,
  UnprocessableEntityError,
  api_exports
} from "./chunk-D4YFFTPH.js";
import {
  ApiKey,
  ApiKeyCreate,
  ApiKeyUpdate,
  CheckoutSessionCreatePayload,
  CustomerPortalSessionCreatePayload,
  DataSink,
  DataSinkCreate,
  DataSinkUpdate,
  DataSource,
  DataSourceCreate,
  DataSourceLoadJobRecord,
  DataSourceManagedIngestionJobRecord,
  DataSourceUpdate,
  EvalDataset,
  EvalDatasetCreate,
  EvalDatasetJobRecord,
  EvalDatasetUpdate,
  EvalExecutionCreate,
  EvalQuestion,
  EvalQuestionCreate,
  HttpValidationError,
  LoadedFilePayload,
  LocalEvalSetCreate,
  ParsingJob,
  ParsingJobMarkdownResult,
  ParsingJobTextResult,
  ParsingUsage,
  Pipeline,
  PipelineCreate,
  PipelineManagedIngestionJobRecord,
  PipelineUpdate,
  PlaygroundJobRecord,
  Project,
  ProjectCreate,
  ProjectUpdate,
  PromptMixinPrompts,
  RawFile,
  RawFileManagedIngestionJobRecord,
  RetrievalParams,
  RetrieveResults,
  Supplier,
  apiKey_exports,
  billing_exports,
  componentDefinition_exports,
  dataSource_exports,
  eval_exports,
  fetcher,
  health_exports,
  parsing_exports,
  pipeline_exports,
  project_exports
} from "./chunk-7TLFVFAT.js";
import "./chunk-UURD7IY7.js";

// ../../node_modules/.pnpm/url-join@5.0.0/node_modules/url-join/lib/url-join.js
function normalize(strArray) {
  var resultArray = [];
  if (strArray.length === 0) {
    return "";
  }
  if (typeof strArray[0] !== "string") {
    throw new TypeError("Url must be a string. Received " + strArray[0]);
  }
  if (strArray[0].match(/^[^/:]+:\/*$/) && strArray.length > 1) {
    var first = strArray.shift();
    strArray[0] = first + strArray[0];
  }
  if (strArray[0].match(/^file:\/\/\//)) {
    strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1:///");
  } else {
    strArray[0] = strArray[0].replace(/^([^/:]+):\/*/, "$1://");
  }
  for (var i = 0; i < strArray.length; i++) {
    var component = strArray[i];
    if (typeof component !== "string") {
      throw new TypeError("Url must be a string. Received " + component);
    }
    if (component === "") {
      continue;
    }
    if (i > 0) {
      component = component.replace(/^[\/]+/, "");
    }
    if (i < strArray.length - 1) {
      component = component.replace(/[\/]+$/, "");
    } else {
      component = component.replace(/[\/]+$/, "/");
    }
    resultArray.push(component);
  }
  var str = resultArray.join("/");
  str = str.replace(/\/(\?|&|#[^!])/g, "$1");
  var parts = str.split("?");
  str = parts.shift() + (parts.length > 0 ? "?" : "") + parts.join("&");
  return str;
}
function urlJoin() {
  var input;
  if (typeof arguments[0] === "object") {
    input = arguments[0];
  } else {
    input = [].slice.call(arguments);
  }
  return normalize(input);
}

// src/api/resources/health/client/Client.ts
var Health = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Health check endpoint.
   *
   * @example
   *     await platformApi.health.health()
   */
  async health(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/health"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await health_exports.health.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      throw new PlatformApiError({
        statusCode: _response.error.statusCode,
        body: _response.error.body
      });
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/apiKey/client/Client.ts
var ApiKey2 = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Get all API Keys for a user.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.apiKey.getKeys()
   */
  async getKeys(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/api_key"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await apiKey_exports.getKeys.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Generate a new API Key.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.apiKey.generateKey({})
   */
  async generateKey(request = {}, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/api_key"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await ApiKeyCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await ApiKey.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Update name of an existing API Key.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.apiKey.updateExistingApiKey("string", {})
   */
  async updateExistingApiKey(apiKeyId, request = {}, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/api_key/${apiKeyId}`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await ApiKeyUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await ApiKey.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete an API Key by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.apiKey.deleteApiKey("string")
   */
  async deleteApiKey(apiKeyId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/api_key/${apiKeyId}`),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/dataSink/client/Client.ts
var DataSink2 = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Create a new data sink.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSink.createDataSink({
   *         name: "string",
   *         sinkType: PlatformApi.ConfigurableDataSinkNames.Chroma
   *     })
   */
  async createDataSink(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/data_sink"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await DataSinkCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSink.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Upserts a data sink.
   * Updates if a data sink with the same name and user_id already exists. Otherwise, creates a new data sink.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSink.upsertDataSink({
   *         name: "string",
   *         sinkType: PlatformApi.ConfigurableDataSinkNames.Chroma
   *     })
   */
  async upsertDataSink(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/data_sink"),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await DataSinkCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSink.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a data sink by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSink.getDataSink("string")
   */
  async getDataSink(dataSinkId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/data_sink/${dataSinkId}`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSink.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Update a data sink by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSink.updateDataSink("string", {
   *         sinkType: PlatformApi.ConfigurableDataSinkNames.Chroma
   *     })
   */
  async updateDataSink(dataSinkId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/data_sink/${dataSinkId}`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await DataSinkUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSink.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete a data sink by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSink.deleteDataSink("string")
   */
  async deleteDataSink(dataSinkId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/data_sink/${dataSinkId}`),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/dataSource/client/Client.ts
var DataSource2 = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Create a new data source.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.createDataSource({
   *         name: "string",
   *         sourceType: PlatformApi.ConfigurableDataSourceNames.Discord
   *     })
   */
  async createDataSource(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/data_source"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await DataSourceCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSource.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Upserts a data source.
   * Updates if a data source with the same name and user_id already exists.Otherwise, creates a new data source.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.upsertDataSource({
   *         name: "string",
   *         sourceType: PlatformApi.ConfigurableDataSourceNames.Discord
   *     })
   */
  async upsertDataSource(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/data_source"),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await DataSourceCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSource.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a data source by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.getDataSource("string")
   */
  async getDataSource(dataSourceId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/data_source/${dataSourceId}`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSource.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Update a data source by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.updateDataSource("string", {
   *         sourceType: PlatformApi.ConfigurableDataSourceNames.Discord
   *     })
   */
  async updateDataSource(dataSourceId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/data_source/${dataSourceId}`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await DataSourceUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSource.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete a data source by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.deleteDataSource("string")
   */
  async deleteDataSource(dataSourceId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/data_source/${dataSourceId}`),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all data source executions for a given data source.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.getDataSourceExecutions("string")
   */
  async getDataSourceExecutions(dataSourceId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/data_source/${dataSourceId}/execution`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await dataSource_exports.getDataSourceExecutions.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new data source execution.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.createDataSourceExecution("string")
   */
  async createDataSourceExecution(dataSourceId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/data_source/${dataSourceId}/execution`
      ),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSourceLoadJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a data source execution by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.dataSource.getDataSourceExecution("string", "string")
   */
  async getDataSourceExecution(dataSourceId, dataSourceLoadExecutionId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/data_source/${dataSourceId}/execution/${dataSourceLoadExecutionId}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSourceLoadJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/project/client/Client.ts
var Project2 = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * List projects or get one by name
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.listProjects({})
   */
  async listProjects(request = {}, requestOptions) {
    const { projectName } = request;
    const _queryParams = {};
    if (projectName != null) {
      _queryParams["project_name"] = projectName;
    }
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/project"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      queryParameters: _queryParams,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await project_exports.listProjects.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.createProject({
   *         name: "string"
   *     })
   */
  async createProject(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/project"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await ProjectCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Project.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Upsert a project.
   * Updates if a project with the same name already exists. Otherwise, creates a new project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.upsertProject({
   *         name: "string"
   *     })
   */
  async upsertProject(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/project"),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await ProjectCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Project.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a project by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.getProject("string")
   */
  async getProject(projectId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Project.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Update an existing project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.updateExistingProject("string", {
   *         name: "string"
   *     })
   */
  async updateExistingProject(projectId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await ProjectUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Project.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new pipeline for a project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.createPipelineForProject("string", {
   *         presetRetrievalParameters: {},
   *         evalParameters: {
   *             llmModel: PlatformApi.SupportedEvalLlmModelNames.Gpt35Turbo
   *         },
   *         name: "string",
   *         pipelineType: PlatformApi.PipelineType.Playground
   *     })
   */
  async createPipelineForProject(projectId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/pipeline`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await PipelineCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Pipeline.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Upsert a pipeline for a project.
   * Updates if a pipeline with the same name and project_id already exists. Otherwise, creates a new pipeline.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.upsertPipelineForProject("string", {
   *         presetRetrievalParameters: {},
   *         evalParameters: {
   *             llmModel: PlatformApi.SupportedEvalLlmModelNames.Gpt35Turbo
   *         },
   *         name: "string",
   *         pipelineType: PlatformApi.PipelineType.Playground
   *     })
   */
  async upsertPipelineForProject(projectId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/pipeline`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await PipelineCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Pipeline.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all eval datasets for a project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.getDatasetsForProject("string")
   */
  async getDatasetsForProject(projectId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/eval/dataset`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await project_exports.getDatasetsForProject.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new eval dataset for a project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.createEvalDatasetForProject("string", {
   *         name: "string"
   *     })
   */
  async createEvalDatasetForProject(projectId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/eval/dataset`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await EvalDatasetCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalDataset.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new local eval set.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.createLocalEvalSetForProject("string", {
   *         appName: "string",
   *         results: {
   *             "string": []
   *         }
   *     })
   */
  async createLocalEvalSetForProject(projectId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/localevalset`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await LocalEvalSetCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await project_exports.createLocalEvalSetForProject.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all local eval results for a project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.getLocalEvalsForProject("string")
   */
  async getLocalEvalsForProject(projectId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/localeval`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await project_exports.getLocalEvalsForProject.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all local eval sets for a project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.getLocalEvalSetsForProject("string")
   */
  async getLocalEvalSetsForProject(projectId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/localevalsets`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await project_exports.getLocalEvalSetsForProject.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete a local eval set.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.deleteLocalEvalSet("string", "string")
   */
  async deleteLocalEvalSet(projectId, localEvalSetId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/project/${projectId}/localevalset/${localEvalSetId}`
      ),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return _response.body;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all PromptMixin prompt sets for a project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.getPromptmixinPrompts("string")
   */
  async getPromptmixinPrompts(projectId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/prompts`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await project_exports.getPromptmixinPrompts.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new PromptMixin prompt set.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.createPromptMixinPrompts("string", {
   *         projectId: "string",
   *         name: "string",
   *         prompts: []
   *     })
   */
  async createPromptMixinPrompts(projectId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/project/${projectId}/prompts`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await PromptMixinPrompts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await PromptMixinPrompts.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Update a PromptMixin prompt set.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.updatePromptmixinPrompts("string", "string", {
   *         projectId: "string",
   *         name: "string",
   *         prompts: []
   *     })
   */
  async updatePromptmixinPrompts(projectId, promptSetId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/project/${projectId}/prompts/${promptSetId}`
      ),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await PromptMixinPrompts.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await PromptMixinPrompts.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete a PromptMixin prompt set.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.project.deletePromptMixinPrompts("string", "string")
   */
  async deletePromptMixinPrompts(projectId, promptSetId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/project/${projectId}/prompts/${promptSetId}`
      ),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return _response.body;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/pipeline/client/Client.ts
import { default as FormData } from "form-data";
var Pipeline2 = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Search for pipelines by various parameters.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.searchPipelines({
   *         projectName: "string",
   *         pipelineType: PlatformApi.PipelineType.Playground
   *     })
   */
  async searchPipelines(request, requestOptions) {
    const { projectName, pipelineName, pipelineType } = request;
    const _queryParams = {};
    _queryParams["project_name"] = projectName;
    if (pipelineName != null) {
      _queryParams["pipeline_name"] = pipelineName;
    }
    if (pipelineType != null) {
      _queryParams["pipeline_type"] = pipelineType;
    }
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/pipeline"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      queryParameters: _queryParams,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.searchPipelines.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a pipeline by ID for a given project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getPipelineForProject("string", {})
   */
  async getPipelineForProject(pipelineId, request = {}, requestOptions) {
    const { withManagedIngestionStatus } = request;
    const _queryParams = {};
    if (withManagedIngestionStatus != null) {
      _queryParams["with_managed_ingestion_status"] = withManagedIngestionStatus.toString();
    }
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      queryParameters: _queryParams,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Pipeline.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Update an existing pipeline for a project.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.updateExistingPipeline("string", {
   *         presetRetrievalParameters: {},
   *         evalParameters: {
   *             llmModel: PlatformApi.SupportedEvalLlmModelNames.Gpt35Turbo
   *         }
   *     })
   */
  async updateExistingPipeline(pipelineId, request = {}, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await PipelineUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Pipeline.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete a pipeline by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.deletePipeline("string")
   */
  async deletePipeline(pipelineId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}`),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get loaded files for a pipeline by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getLoadedFilesForPipeline("string")
   */
  async getLoadedFilesForPipeline(pipelineId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}/loaded_file`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getLoadedFilesForPipeline.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get loaded files for a data source by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getLoadedFileContent("string", "string")
   */
  async getLoadedFileContent(pipelineId, loadedFileId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/loaded_file/${loadedFileId}/content`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await LoadedFilePayload.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Deploy a playground pipeline to a managed pipeline.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.deployPlaygroundPipeline("string", {})
   */
  async deployPlaygroundPipeline(pipelineId, request = {}, requestOptions) {
    const { managedPipelineName } = request;
    const _queryParams = {};
    if (managedPipelineName != null) {
      _queryParams["managed_pipeline_name"] = managedPipelineName;
    }
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}/deploy`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      queryParameters: _queryParams,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Pipeline.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Deploy a playground pipeline to the managed pipeline it is already associated with.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.deployPlaygroundPipelineWithExistingManagedPipeline("string")
   */
  async deployPlaygroundPipelineWithExistingManagedPipeline(pipelineId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}/deploy`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Pipeline.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a playground pipeline from a managed pipeline.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.createPlaygroundPipeline("string", {})
   */
  async createPlaygroundPipeline(pipelineId, request = {}, requestOptions) {
    const { playgroundPipelineName } = request;
    const _queryParams = {};
    if (playgroundPipelineName != null) {
      _queryParams["playground_pipeline_name"] = playgroundPipelineName;
    }
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}/playground`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      queryParameters: _queryParams,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await Pipeline.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all PlaygroundJobRecords for a given pipeline.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getAllPlaygroundJobs("string")
   */
  async getAllPlaygroundJobs(pipelineId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/playground_job`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getAllPlaygroundJobs.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Kick off a new Playground execution.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.createPlaygroundJob("string", {})
   */
  async createPlaygroundJob(pipelineId, request = {}, requestOptions) {
    const { loadedFileIds } = request;
    const _queryParams = {};
    if (loadedFileIds != null) {
      if (Array.isArray(loadedFileIds)) {
        _queryParams["loaded_file_ids"] = loadedFileIds.map((item) => item);
      } else {
        _queryParams["loaded_file_ids"] = loadedFileIds;
      }
    }
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/playground_job`
      ),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      queryParameters: _queryParams,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await PlaygroundJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get the result of the latest Playground job.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getPlaygroundJobResult("string", {})
   */
  async getPlaygroundJobResult(pipelineId, request = {}, requestOptions) {
    const { configuredTransformationId, loadedFileId, offset, limit } = request;
    const _queryParams = {};
    if (configuredTransformationId != null) {
      _queryParams["configured_transformation_id"] = configuredTransformationId;
    }
    if (loadedFileId != null) {
      _queryParams["loaded_file_id"] = loadedFileId;
    }
    if (offset != null) {
      _queryParams["offset"] = offset.toString();
    }
    if (limit != null) {
      _queryParams["limit"] = limit.toString();
    }
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/playground_job/result`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      queryParameters: _queryParams,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getPlaygroundJobResult.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get status of a single pipeline PlaygroundJob for a given pipeline.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getPlaygroundJob("string", "string")
   */
  async getPlaygroundJob(pipelineId, playgroundJobId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/playground_job/${playgroundJobId}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await PlaygroundJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get the status of an EvalDatasetExecution.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getEvalDatasetExecutions("string", "string")
   */
  async getEvalDatasetExecutions(pipelineId, evalDatasetId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/eval_dataset/${evalDatasetId}/execute`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getEvalDatasetExecutions.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Execute a dataset.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.executeEvalDataset("string", "string", {
   *         evalQuestionIds: [],
   *         params: {
   *             llmModel: PlatformApi.SupportedEvalLlmModelNames.Gpt35Turbo
   *         }
   *     })
   */
  async executeEvalDataset(pipelineId, evalDatasetId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/eval_dataset/${evalDatasetId}/execute`
      ),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await EvalExecutionCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalDatasetJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get the result of an EvalDatasetExecution.
   * If eval_question_ids is specified, only the results for the specified
   * questions will be returned.
   * If any of the specified questions do not have a result, they will be ignored.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getEvalDatasetExecutionResult("string", "string")
   */
  async getEvalDatasetExecutionResult(pipelineId, evalDatasetId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/eval_dataset/${evalDatasetId}/execute/result`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getEvalDatasetExecutionResult.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get the status of an EvalDatasetExecution.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getEvalDatasetExecution("string", "string", "string")
   */
  async getEvalDatasetExecution(pipelineId, evalDatasetId, evalDatasetExecutionId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/eval_dataset/${evalDatasetId}/execute/${evalDatasetExecutionId}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalDatasetJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all ManagedRawFileIngestionExecution for a given pipeline and raw file.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getRawFileManagedIngestionExecutions("string", "string")
   */
  async getRawFileManagedIngestionExecutions(pipelineId, rawFileName, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/raw_file/${rawFileName}/managed_ingest`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getRawFileManagedIngestionExecutions.Response.parseOrThrow(
        _response.body,
        {
          unrecognizedObjectKeys: "passthrough",
          allowUnrecognizedUnionMembers: true,
          allowUnrecognizedEnumValues: true,
          breadcrumbsPrefix: ["response"]
        }
      );
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Execute a ManagedRawFileIngestion.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.runRawFileManagedIngestion("string", "string")
   */
  async runRawFileManagedIngestion(pipelineId, rawFileName, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/raw_file/${rawFileName}/managed_ingest`
      ),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await RawFileManagedIngestionJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a single ManagedRawFileIngestionExecution for a given pipeline and raw file.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getRawFileManagedIngestionExecution("string", "string", "string")
   */
  async getRawFileManagedIngestionExecution(pipelineId, rawFileName, managedRawFileIngestionId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/raw_file/${rawFileName}/managed_ingest/${managedRawFileIngestionId}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await RawFileManagedIngestionJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all ManagedDataSourceIngestionExecution for a given pipeline and data source.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getManagedDataSourceIngestionExecutions("string", "string")
   */
  async getManagedDataSourceIngestionExecutions(pipelineId, dataSourceId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/data_source/${dataSourceId}/managed_ingest`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getManagedDataSourceIngestionExecutions.Response.parseOrThrow(
        _response.body,
        {
          unrecognizedObjectKeys: "passthrough",
          allowUnrecognizedUnionMembers: true,
          allowUnrecognizedEnumValues: true,
          breadcrumbsPrefix: ["response"]
        }
      );
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Execute a ManagedDataSourceIngestion.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.runManagedDataSourceIngestion("string", "string")
   */
  async runManagedDataSourceIngestion(pipelineId, dataSourceId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/data_source/${dataSourceId}/managed_ingest`
      ),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSourceManagedIngestionJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a single ManagedDataSourceIngestionExecution for a given pipeline and data source.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getManagedDataSourceIngestionExecution("string", "string", "string")
   */
  async getManagedDataSourceIngestionExecution(pipelineId, dataSourceId, managedDataSourceIngestionId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/data_source/${dataSourceId}/managed_ingest/${managedDataSourceIngestionId}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await DataSourceManagedIngestionJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all ManagedPipelineIngestionExecution for a given pipeline.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getManagedPipelineIngestionExecutions("string")
   */
  async getManagedPipelineIngestionExecutions(pipelineId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/managed_ingest`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.getManagedPipelineIngestionExecutions.Response.parseOrThrow(
        _response.body,
        {
          unrecognizedObjectKeys: "passthrough",
          allowUnrecognizedUnionMembers: true,
          allowUnrecognizedEnumValues: true,
          breadcrumbsPrefix: ["response"]
        }
      );
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Execute a ManagedPipelineIngestion.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.runManagedPipelineIngestion("string")
   */
  async runManagedPipelineIngestion(pipelineId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/managed_ingest`
      ),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await PipelineManagedIngestionJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.getManagedIngestionExecution("string", "string")
   */
  async getManagedIngestionExecution(pipelineId, managedPipelineIngestionId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/managed_ingest/${managedPipelineIngestionId}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await PipelineManagedIngestionJobRecord.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get retrieval results for a managed pipeline and a query
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.runSearch("string", {
   *         query: "string"
   *     })
   */
  async runSearch(pipelineId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}/retrieve`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await RetrievalParams.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await RetrieveResults.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Read RawFile metadata objects.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.readRawFiles("string")
   */
  async readRawFiles(pipelineId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}/raw_file`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await pipeline_exports.readRawFiles.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Uploads a raw file to S3 and returns the RawFile metadata object.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   */
  async upsertRawFile(file, pipelineId, requestOptions) {
    const _request = new FormData();
    _request.append("file", file);
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/pipeline/${pipelineId}/raw_file`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
      body: _request,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await RawFile.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Redirects to a presigned url to read the raw file content.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.readRawFileContent("string", "string")
   */
  async readRawFileContent(pipelineId, name, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/raw_file/${name}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete the raw file from S3.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.pipeline.deleteRawFile("string", "string")
   */
  async deleteRawFile(pipelineId, name, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/pipeline/${pipelineId}/raw_file/${name}`
      ),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/eval/client/Client.ts
var Eval = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Get a dataset by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.getDataset("string")
   */
  async getDataset(datasetId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/dataset/${datasetId}`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalDataset.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Update a dataset.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.updateDataset("string", {
   *         name: "string"
   *     })
   */
  async updateDataset(datasetId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/dataset/${datasetId}`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await EvalDatasetUpdate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalDataset.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete a dataset.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.deleteDataset("string")
   */
  async deleteDataset(datasetId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/dataset/${datasetId}`),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all questions for a dataset.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.getQuestions("string")
   */
  async getQuestions(datasetId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/dataset/${datasetId}/question`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await eval_exports.getQuestions.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new question.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.createQuestion("string", {
   *         content: "string"
   *     })
   */
  async createQuestion(datasetId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/dataset/${datasetId}/question`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await EvalQuestionCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalQuestion.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new question.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.createQuestions("string", [])
   */
  async createQuestions(datasetId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/dataset/${datasetId}/questions`),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await eval_exports.createQuestions.Request.jsonOrThrow(request, {
        unrecognizedObjectKeys: "strip"
      }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await eval_exports.createQuestions.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a question by ID.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.getQuestion("string")
   */
  async getQuestion(questionId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/question/${questionId}`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalQuestion.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Replace a question.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.replaceQuestion("string", {
   *         content: "string"
   *     })
   */
  async replaceQuestion(questionId, request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/question/${questionId}`),
      method: "PUT",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await EvalQuestionCreate.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await EvalQuestion.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Delete a question.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.deleteQuestion("string")
   */
  async deleteQuestion(questionId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/eval/question/${questionId}`),
      method: "DELETE",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all supported models.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.eval.getSupportedModels()
   */
  async getSupportedModels(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/eval/models"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await eval_exports.getSupportedModels.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/parsing/client/Client.ts
import { default as FormData2 } from "form-data";
var Parsing = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Get a job by id
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.parsing.getJobImageResult("string", "string")
   */
  async getJobImageResult(jobId, name, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/parsing/job/${jobId}/result/image/${name}`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a list of supported file extensions
   *
   * @example
   *     await platformApi.parsing.getSupportedFileExtensions()
   */
  async getSupportedFileExtensions(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/parsing/supported_file_extensions"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await parsing_exports.getSupportedFileExtensions.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      throw new PlatformApiError({
        statusCode: _response.error.statusCode,
        body: _response.error.body
      });
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Upload a file to s3 and create a job. return a job id
   * @throws {@link PlatformApi.UnprocessableEntityError}
   */
  async uploadFile(file, request, requestOptions) {
    const _request = new FormData2();
    for (const _item of request.language) {
      _request.append("language", _item);
    }
    _request.append("parsing_instruction", request.parsingInstruction);
    _request.append("file", file);
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/parsing/upload"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "multipart/form-data; boundary=" + _request.getBoundary(),
      body: _request,
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await ParsingJob.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get parsing usage for user
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.parsing.usage()
   */
  async usage(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/parsing/usage"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await ParsingUsage.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a job by id
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.parsing.getJob("string")
   */
  async getJob(jobId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/parsing/job/${jobId}`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await ParsingJob.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a job by id
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.parsing.getJobTextResult("string")
   */
  async getJobTextResult(jobId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/parsing/job/${jobId}/result/text`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await ParsingJobTextResult.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a job by id
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.parsing.getJobResult("string")
   */
  async getJobResult(jobId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        `api/parsing/job/${jobId}/result/markdown`
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await ParsingJobMarkdownResult.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get a job by id
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.parsing.getJobJsonResult("string")
   */
  async getJobJsonResult(jobId, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), `api/parsing/job/${jobId}/result/json`),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return _response.body;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/componentDefinition/client/Client.ts
var ComponentDefinition = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Get all configurable transformation component definitions.
   *
   * @example
   *     await platformApi.componentDefinition.getAllTransformationDefinitions()
   */
  async getAllTransformationDefinitions(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(
        await Supplier.get(this._options.environment),
        "api/component_definition/configurable_transformation"
      ),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await componentDefinition_exports.getAllTransformationDefinitions.Response.parseOrThrow(
        _response.body,
        {
          unrecognizedObjectKeys: "passthrough",
          allowUnrecognizedUnionMembers: true,
          allowUnrecognizedEnumValues: true,
          breadcrumbsPrefix: ["response"]
        }
      );
    }
    if (_response.error.reason === "status-code") {
      throw new PlatformApiError({
        statusCode: _response.error.statusCode,
        body: _response.error.body
      });
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all data source component definitions.
   *
   * @example
   *     await platformApi.componentDefinition.getAllDataSourceDefinitions()
   */
  async getAllDataSourceDefinitions(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/component_definition/data_source"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await componentDefinition_exports.getAllDataSourceDefinitions.Response.parseOrThrow(
        _response.body,
        {
          unrecognizedObjectKeys: "passthrough",
          allowUnrecognizedUnionMembers: true,
          allowUnrecognizedEnumValues: true,
          breadcrumbsPrefix: ["response"]
        }
      );
    }
    if (_response.error.reason === "status-code") {
      throw new PlatformApiError({
        statusCode: _response.error.statusCode,
        body: _response.error.body
      });
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Get all data sink component definitions.
   *
   * @example
   *     await platformApi.componentDefinition.getAllDataSinkDefinitions()
   */
  async getAllDataSinkDefinitions(requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/component_definition/data_sink"),
      method: "GET",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await componentDefinition_exports.getAllDataSinkDefinitions.Response.parseOrThrow(
        _response.body,
        {
          unrecognizedObjectKeys: "passthrough",
          allowUnrecognizedUnionMembers: true,
          allowUnrecognizedEnumValues: true,
          breadcrumbsPrefix: ["response"]
        }
      );
    }
    if (_response.error.reason === "status-code") {
      throw new PlatformApiError({
        statusCode: _response.error.statusCode,
        body: _response.error.body
      });
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/api/resources/billing/client/Client.ts
var Billing = class {
  constructor(_options) {
    this._options = _options;
  }
  /**
   * Create a new checkout session.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.billing.createCheckoutSession({
   *         successUrl: "string",
   *         cancelUrl: "string"
   *     })
   */
  async createCheckoutSession(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/billing/checkout-session"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await CheckoutSessionCreatePayload.jsonOrThrow(request, {
        unrecognizedObjectKeys: "strip"
      }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await billing_exports.createCheckoutSession.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Create a new customer portal session.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.billing.createCustomerPortalSession({
   *         returnUrl: "string"
   *     })
   */
  async createCustomerPortalSession(request, requestOptions) {
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/billing/customer-portal-session"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript"
      },
      contentType: "application/json",
      body: await CustomerPortalSessionCreatePayload.jsonOrThrow(request, {
        unrecognizedObjectKeys: "strip"
      }),
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return await billing_exports.createCustomerPortalSession.Response.parseOrThrow(_response.body, {
        unrecognizedObjectKeys: "passthrough",
        allowUnrecognizedUnionMembers: true,
        allowUnrecognizedEnumValues: true,
        breadcrumbsPrefix: ["response"]
      });
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  /**
   * Stripe webhook endpoint.
   * @throws {@link PlatformApi.UnprocessableEntityError}
   *
   * @example
   *     await platformApi.billing.stripeWebhook({})
   */
  async stripeWebhook(request = {}, requestOptions) {
    const { stripeSignature } = request;
    const _response = await fetcher({
      url: urlJoin(await Supplier.get(this._options.environment), "api/billing/webhook"),
      method: "POST",
      headers: {
        Authorization: await this._getAuthorizationHeader(),
        "X-Fern-Language": "JavaScript",
        "stripe-signature": stripeSignature != null ? stripeSignature : void 0
      },
      contentType: "application/json",
      timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1e3 : 6e4,
      maxRetries: requestOptions?.maxRetries,
      withCredentials: true
    });
    if (_response.ok) {
      return _response.body;
    }
    if (_response.error.reason === "status-code") {
      switch (_response.error.statusCode) {
        case 422:
          throw new UnprocessableEntityError(
            await HttpValidationError.parseOrThrow(_response.error.body, {
              unrecognizedObjectKeys: "passthrough",
              allowUnrecognizedUnionMembers: true,
              allowUnrecognizedEnumValues: true,
              breadcrumbsPrefix: ["response"]
            })
          );
        default:
          throw new PlatformApiError({
            statusCode: _response.error.statusCode,
            body: _response.error.body
          });
      }
    }
    switch (_response.error.reason) {
      case "non-json":
        throw new PlatformApiError({
          statusCode: _response.error.statusCode,
          body: _response.error.rawBody
        });
      case "timeout":
        throw new PlatformApiTimeoutError();
      case "unknown":
        throw new PlatformApiError({
          message: _response.error.errorMessage
        });
    }
  }
  async _getAuthorizationHeader() {
    const bearer = await Supplier.get(this._options.token);
    if (bearer != null) {
      return `Bearer ${bearer}`;
    }
    return void 0;
  }
};

// src/Client.ts
var PlatformApiClient = class {
  constructor(_options) {
    this._options = _options;
  }
  _health;
  get health() {
    return this._health ??= new Health(this._options);
  }
  _apiKey;
  get apiKey() {
    return this._apiKey ??= new ApiKey2(this._options);
  }
  _dataSink;
  get dataSink() {
    return this._dataSink ??= new DataSink2(this._options);
  }
  _dataSource;
  get dataSource() {
    return this._dataSource ??= new DataSource2(this._options);
  }
  _project;
  get project() {
    return this._project ??= new Project2(this._options);
  }
  _pipeline;
  get pipeline() {
    return this._pipeline ??= new Pipeline2(this._options);
  }
  _eval;
  get eval() {
    return this._eval ??= new Eval(this._options);
  }
  _parsing;
  get parsing() {
    return this._parsing ??= new Parsing(this._options);
  }
  _componentDefinition;
  get componentDefinition() {
    return this._componentDefinition ??= new ComponentDefinition(this._options);
  }
  _billing;
  get billing() {
    return this._billing ??= new Billing(this._options);
  }
};
export {
  api_exports as PlatformApi,
  PlatformApiClient,
  PlatformApiError,
  PlatformApiTimeoutError
};
//# sourceMappingURL=index.js.map