phonic
Version:
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2FPhonic-Co%2Fphonic-node) [ • 7.28 kB
JavaScript
"use strict";
// Maintained manually (listed in .fernignore). Fern does not overwrite this file.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PhonicClient = void 0;
const Client_js_1 = require("./api/resources/agents/client/Client.js");
const Client_js_2 = require("./api/resources/apiKeys/client/Client.js");
const Client_js_3 = require("./api/resources/auth/client/Client.js");
const Client_js_4 = require("./api/resources/conversationItems/client/Client.js");
const Client_js_5 = require("./api/resources/conversations/client/Client.js");
const Client_js_6 = require("./api/resources/extractionSchemas/client/Client.js");
const Client_js_7 = require("./api/resources/projects/client/Client.js");
const Client_js_8 = require("./api/resources/tools/client/Client.js");
const Client_js_9 = require("./api/resources/tts/client/Client.js");
const Client_js_10 = require("./api/resources/voices/client/Client.js");
const Client_js_11 = require("./api/resources/workspace/client/Client.js");
const BaseClient_js_1 = require("./BaseClient.js");
const core = __importStar(require("./core/index.js"));
const environments = __importStar(require("./environments.js"));
class PhonicClient {
constructor(options = {}) {
this._options = (0, BaseClient_js_1.normalizeClientOptionsWithAuth)(options);
}
get agents() {
var _a;
return ((_a = this._agents) !== null && _a !== void 0 ? _a : (this._agents = new Client_js_1.AgentsClient(this._options)));
}
get apiKeys() {
var _a;
return ((_a = this._apiKeys) !== null && _a !== void 0 ? _a : (this._apiKeys = new Client_js_2.ApiKeysClient(this._options)));
}
get tools() {
var _a;
return ((_a = this._tools) !== null && _a !== void 0 ? _a : (this._tools = new Client_js_8.ToolsClient(this._options)));
}
get extractionSchemas() {
var _a;
return ((_a = this._extractionSchemas) !== null && _a !== void 0 ? _a : (this._extractionSchemas = new Client_js_6.ExtractionSchemasClient(this._options)));
}
get tts() {
var _a;
return ((_a = this._tts) !== null && _a !== void 0 ? _a : (this._tts = new Client_js_9.TtsClient(this._options)));
}
get voices() {
var _a;
return ((_a = this._voices) !== null && _a !== void 0 ? _a : (this._voices = new Client_js_10.VoicesClient(this._options)));
}
get conversations() {
var _a;
return ((_a = this._conversations) !== null && _a !== void 0 ? _a : (this._conversations = new Client_js_5.ConversationsClient(this._options)));
}
get conversationItems() {
var _a;
return ((_a = this._conversationItems) !== null && _a !== void 0 ? _a : (this._conversationItems = new Client_js_4.ConversationItemsClient(this._options)));
}
get auth() {
var _a;
return ((_a = this._auth) !== null && _a !== void 0 ? _a : (this._auth = new Client_js_3.AuthClient(this._options)));
}
get projects() {
var _a;
return ((_a = this._projects) !== null && _a !== void 0 ? _a : (this._projects = new Client_js_7.ProjectsClient(this._options)));
}
get workspace() {
var _a;
return ((_a = this._workspace) !== null && _a !== void 0 ? _a : (this._workspace = new Client_js_11.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);
});
}
}
exports.PhonicClient = PhonicClient;