UNPKG

phonic

Version:

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [![npm shield](htt

104 lines (103 loc) 5.66 kB
// Maintained manually (listed in .fernignore). Fern does not overwrite this file. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { AgentsClient } from "./api/resources/agents/client/Client.mjs"; import { ApiKeysClient } from "./api/resources/apiKeys/client/Client.mjs"; import { AuthClient } from "./api/resources/auth/client/Client.mjs"; import { ConversationItemsClient } from "./api/resources/conversationItems/client/Client.mjs"; import { ConversationsClient } from "./api/resources/conversations/client/Client.mjs"; import { ExtractionSchemasClient } from "./api/resources/extractionSchemas/client/Client.mjs"; import { ProjectsClient } from "./api/resources/projects/client/Client.mjs"; import { ToolsClient } from "./api/resources/tools/client/Client.mjs"; import { TtsClient } from "./api/resources/tts/client/Client.mjs"; import { VoicesClient } from "./api/resources/voices/client/Client.mjs"; import { WorkspaceClient } from "./api/resources/workspace/client/Client.mjs"; import { normalizeClientOptionsWithAuth } from "./BaseClient.mjs"; import * as core from "./core/index.mjs"; import * as environments from "./environments.mjs"; export class PhonicClient { constructor(options = {}) { this._options = normalizeClientOptionsWithAuth(options); } get agents() { var _a; return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new AgentsClient(this._options))); } get apiKeys() { var _a; return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new ApiKeysClient(this._options))); } get tools() { var _a; return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new ToolsClient(this._options))); } get extractionSchemas() { var _a; return ((_a = this._extractionSchemas) !== null && _a !== void 0 ? _a : (this._extractionSchemas = new ExtractionSchemasClient(this._options))); } get tts() { var _a; return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new TtsClient(this._options))); } get voices() { var _a; return ((_a = this._voices) !== null && _a !== void 0 ? _a : (this._voices = new VoicesClient(this._options))); } get conversations() { var _a; return ((_a = this._conversations) !== null && _a !== void 0 ? _a : (this._conversations = new ConversationsClient(this._options))); } get conversationItems() { var _a; return ((_a = this._conversationItems) !== null && _a !== void 0 ? _a : (this._conversationItems = new ConversationItemsClient(this._options))); } get auth() { var _a; return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new AuthClient(this._options))); } get projects() { var _a; return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new ProjectsClient(this._options))); } get workspace() { var _a; return ((_a = this._workspace) !== null && _a !== void 0 ? _a : (this._workspace = new WorkspaceClient(this._options))); } /** * Make a passthrough request using the SDK's configured auth, retry, logging, etc. * This is useful for making requests to endpoints not yet supported in the SDK. * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL. * * @param {Request | string | URL} input - The URL, path, or Request object. * @param {RequestInit} init - Standard fetch RequestInit options. * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal). * @returns {Promise<Response>} A standard Response object. */ fetch(input, init, requestOptions) { return __awaiter(this, void 0, void 0, function* () { var _a; return core.makePassthroughRequest(input, init, { baseUrl: (_a = this._options.baseUrl) !== null && _a !== void 0 ? _a : (() => __awaiter(this, void 0, void 0, function* () { var _a; const env = yield core.Supplier.get(this._options.environment); return typeof env === "string" ? env : ((_a = env === null || env === void 0 ? void 0 : env.base) !== null && _a !== void 0 ? _a : environments.PhonicEnvironment.Default.base); })), headers: this._options.headers, timeoutInSeconds: this._options.timeoutInSeconds, maxRetries: this._options.maxRetries, fetch: this._options.fetch, logging: this._options.logging, getAuthHeaders: () => __awaiter(this, void 0, void 0, function* () { return (yield this._options.authProvider.getAuthRequest()).headers; }), }, requestOptions); }); } }