From 227db85b103953f8bda660fb73708594f5f0d6a4 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 5 Dec 2023 19:17:25 +0000 Subject: [PATCH] Release 7.5.0 --- package.json | 2 +- src/Client.ts | 27 +- src/api/client/requests/GenerateRequest.ts | 2 +- src/api/client/requests/RerankRequest.ts | 3 + src/api/errors/ForbiddenError.ts | 16 + src/api/errors/NotFoundError.ts | 16 + src/api/errors/index.ts | 2 + src/api/index.ts | 1 + src/api/resources/connectors/client/Client.ts | 447 ++++++++++++++++++ src/api/resources/connectors/client/index.ts | 1 + .../client/requests/CreateRequest.ts | 24 + .../connectors/client/requests/ListRequest.ts | 14 + .../client/requests/UpdateRequest.ts | 20 + .../connectors/client/requests/index.ts | 3 + src/api/resources/connectors/index.ts | 1 + src/api/resources/index.ts | 2 + src/api/types/ApiMetaApiVersion.ts | 3 + src/api/types/ApiMetaApiVersionBilledUnits.ts | 26 + .../ClassifyResponseClassificationsItem.ts | 4 +- src/api/types/Connector.ts | 44 ++ src/api/types/ConnectorAuthStatus.ts | 13 + src/api/types/ConnectorOAuth.ts | 12 + src/api/types/CreateConnectorOAuth.ts | 16 + src/api/types/CreateConnectorServiceAuth.ts | 10 + src/api/types/CreateResponse.ts | 9 + src/api/types/DeleteResponse.ts | 5 + src/api/types/GetResponse.ts | 9 + src/api/types/ListResponse.ts | 9 + src/api/types/OAuthAuthorizeResponse.ts | 8 + src/api/types/UpdateResponse.ts | 9 + src/api/types/index.ts | 12 + src/serialization/index.ts | 1 + .../resources/connectors/client/index.ts | 1 + .../client/requests/CreateRequest.ts | 34 ++ .../client/requests/UpdateRequest.ts | 32 ++ .../connectors/client/requests/index.ts | 2 + .../resources/connectors/index.ts | 1 + src/serialization/resources/index.ts | 2 + src/serialization/types/ApiMetaApiVersion.ts | 5 + .../types/ApiMetaApiVersionBilledUnits.ts | 26 + src/serialization/types/Connector.ts | 42 ++ .../types/ConnectorAuthStatus.ts | 16 + src/serialization/types/ConnectorOAuth.ts | 22 + .../types/CreateConnectorOAuth.ts | 28 ++ .../types/CreateConnectorServiceAuth.ts | 22 + src/serialization/types/CreateResponse.ts | 18 + src/serialization/types/DeleteResponse.ts | 14 + src/serialization/types/GetResponse.ts | 18 + src/serialization/types/ListResponse.ts | 18 + .../types/OAuthAuthorizeResponse.ts | 20 + src/serialization/types/UpdateResponse.ts | 18 + src/serialization/types/index.ts | 12 + 52 files changed, 1108 insertions(+), 14 deletions(-) create mode 100644 src/api/errors/ForbiddenError.ts create mode 100644 src/api/errors/NotFoundError.ts create mode 100644 src/api/resources/connectors/client/Client.ts create mode 100644 src/api/resources/connectors/client/index.ts create mode 100644 src/api/resources/connectors/client/requests/CreateRequest.ts create mode 100644 src/api/resources/connectors/client/requests/ListRequest.ts create mode 100644 src/api/resources/connectors/client/requests/UpdateRequest.ts create mode 100644 src/api/resources/connectors/client/requests/index.ts create mode 100644 src/api/resources/connectors/index.ts create mode 100644 src/api/resources/index.ts create mode 100644 src/api/types/ApiMetaApiVersionBilledUnits.ts create mode 100644 src/api/types/Connector.ts create mode 100644 src/api/types/ConnectorAuthStatus.ts create mode 100644 src/api/types/ConnectorOAuth.ts create mode 100644 src/api/types/CreateConnectorOAuth.ts create mode 100644 src/api/types/CreateConnectorServiceAuth.ts create mode 100644 src/api/types/CreateResponse.ts create mode 100644 src/api/types/DeleteResponse.ts create mode 100644 src/api/types/GetResponse.ts create mode 100644 src/api/types/ListResponse.ts create mode 100644 src/api/types/OAuthAuthorizeResponse.ts create mode 100644 src/api/types/UpdateResponse.ts create mode 100644 src/serialization/resources/connectors/client/index.ts create mode 100644 src/serialization/resources/connectors/client/requests/CreateRequest.ts create mode 100644 src/serialization/resources/connectors/client/requests/UpdateRequest.ts create mode 100644 src/serialization/resources/connectors/client/requests/index.ts create mode 100644 src/serialization/resources/connectors/index.ts create mode 100644 src/serialization/resources/index.ts create mode 100644 src/serialization/types/ApiMetaApiVersionBilledUnits.ts create mode 100644 src/serialization/types/Connector.ts create mode 100644 src/serialization/types/ConnectorAuthStatus.ts create mode 100644 src/serialization/types/ConnectorOAuth.ts create mode 100644 src/serialization/types/CreateConnectorOAuth.ts create mode 100644 src/serialization/types/CreateConnectorServiceAuth.ts create mode 100644 src/serialization/types/CreateResponse.ts create mode 100644 src/serialization/types/DeleteResponse.ts create mode 100644 src/serialization/types/GetResponse.ts create mode 100644 src/serialization/types/ListResponse.ts create mode 100644 src/serialization/types/OAuthAuthorizeResponse.ts create mode 100644 src/serialization/types/UpdateResponse.ts diff --git a/package.json b/package.json index 98fbe49..3ac227a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cohere-ai", - "version": "7.4.3", + "version": "7.5.0", "private": false, "repository": "https://github.com/cohere-ai/cohere-typescript", "main": "./index.js", diff --git a/src/Client.ts b/src/Client.ts index 51e6f7f..68a486e 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -8,6 +8,7 @@ import * as Cohere from "./api"; import * as serializers from "./serialization"; import urlJoin from "url-join"; import * as errors from "./errors"; +import { Connectors } from "./api/resources/connectors/client/Client"; export declare namespace CohereClient { interface Options { @@ -44,7 +45,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, body: { ...(await serializers.ChatStreamRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" })), @@ -87,7 +88,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: { @@ -148,7 +149,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.GenerateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -217,7 +218,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.EmbedRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -280,7 +281,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.RerankRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -339,7 +340,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.ClassifyRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -402,7 +403,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.DetectLanguageRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -458,7 +459,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.SummarizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -516,7 +517,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.TokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -579,7 +580,7 @@ export class CohereClient { Authorization: await this._getAuthorizationHeader(), "X-Fern-Language": "JavaScript", "X-Fern-SDK-Name": "cohere-ai", - "X-Fern-SDK-Version": "7.4.3", + "X-Fern-SDK-Version": "7.5.0", }, contentType: "application/json", body: await serializers.DetokenizeRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), @@ -618,6 +619,12 @@ export class CohereClient { } } + protected _connectors: Connectors | undefined; + + public get connectors(): Connectors { + return (this._connectors ??= new Connectors(this._options)); + } + protected async _getAuthorizationHeader() { return `Bearer ${await core.Supplier.get(this._options.token)}`; } diff --git a/src/api/client/requests/GenerateRequest.ts b/src/api/client/requests/GenerateRequest.ts index 69b732a..a78e837 100644 --- a/src/api/client/requests/GenerateRequest.ts +++ b/src/api/client/requests/GenerateRequest.ts @@ -73,7 +73,7 @@ export interface GenerateRequest { k?: number; /** * Ensures that only the most likely tokens, with total probability mass of `p`, are considered for generation at each step. If both `k` and `p` are enabled, `p` acts after `k`. - * Defaults to `0`. min value of `0.01`, max value of `0.99`. + * Defaults to `0.75`. min value of `0.01`, max value of `0.99`. * */ p?: number; diff --git a/src/api/client/requests/RerankRequest.ts b/src/api/client/requests/RerankRequest.ts index 799085a..816dc89 100644 --- a/src/api/client/requests/RerankRequest.ts +++ b/src/api/client/requests/RerankRequest.ts @@ -12,7 +12,10 @@ export interface RerankRequest { /** * A list of document objects or strings to rerank. * If a document is provided the text fields is required and all other fields will be preserved in the response. + * * The total max chunks (length of documents * max_chunks_per_doc) must be less than 10000. + * + * We recommend a maximum of 1,000 documents for optimal endpoint performance. */ documents: Cohere.RerankRequestDocumentsItem[]; /** The number of most relevant documents or indices to return, defaults to the length of the documents */ diff --git a/src/api/errors/ForbiddenError.ts b/src/api/errors/ForbiddenError.ts new file mode 100644 index 0000000..d1e0360 --- /dev/null +++ b/src/api/errors/ForbiddenError.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors"; + +export class ForbiddenError extends errors.CohereError { + constructor(body?: unknown) { + super({ + message: "ForbiddenError", + statusCode: 403, + body: body, + }); + Object.setPrototypeOf(this, ForbiddenError.prototype); + } +} diff --git a/src/api/errors/NotFoundError.ts b/src/api/errors/NotFoundError.ts new file mode 100644 index 0000000..dbf39a0 --- /dev/null +++ b/src/api/errors/NotFoundError.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../errors"; + +export class NotFoundError extends errors.CohereError { + constructor(body?: unknown) { + super({ + message: "NotFoundError", + statusCode: 404, + body: body, + }); + Object.setPrototypeOf(this, NotFoundError.prototype); + } +} diff --git a/src/api/errors/index.ts b/src/api/errors/index.ts index ae53904..e007dcc 100644 --- a/src/api/errors/index.ts +++ b/src/api/errors/index.ts @@ -1,2 +1,4 @@ export * from "./BadRequestError"; +export * from "./ForbiddenError"; +export * from "./NotFoundError"; export * from "./InternalServerError"; diff --git a/src/api/index.ts b/src/api/index.ts index 9dc8224..dba65ab 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,3 +1,4 @@ export * from "./types"; export * from "./errors"; +export * from "./resources"; export * from "./client"; diff --git a/src/api/resources/connectors/client/Client.ts b/src/api/resources/connectors/client/Client.ts new file mode 100644 index 0000000..3bf08da --- /dev/null +++ b/src/api/resources/connectors/client/Client.ts @@ -0,0 +1,447 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import * as Cohere from "../../.."; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Connectors { + interface Options { + environment?: core.Supplier; + token: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; + maxRetries?: number; + } +} + +/** + * Connectors API + */ +export class Connectors { + constructor(protected readonly _options: Connectors.Options) {} + + /** + * Returns a list of connectors ordered by descending creation date (newer first). + * @throws {@link Cohere.BadRequestError} + * @throws {@link Cohere.InternalServerError} + */ + public async list( + request: Cohere.ListRequest = {}, + requestOptions?: Connectors.RequestOptions + ): Promise { + const { limit, offset } = request; + const _queryParams: Record = {}; + if (limit != null) { + _queryParams["limit"] = limit.toString(); + } + + if (offset != null) { + _queryParams["offset"] = offset.toString(); + } + + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, + "v1/connectors" + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "cohere-ai", + "X-Fern-SDK-Version": "7.5.0", + }, + contentType: "application/json", + queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.ListResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Cohere.BadRequestError(_response.error.body); + case 500: + throw new Cohere.InternalServerError(_response.error.body); + default: + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.CohereTimeoutError(); + case "unknown": + throw new errors.CohereError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Creates a new connector. The connector is tested during registration + * and will cancel registration when the test is unsuccessful. + * @throws {@link Cohere.BadRequestError} + * @throws {@link Cohere.ForbiddenError} + * @throws {@link Cohere.InternalServerError} + */ + public async create( + request: Cohere.CreateRequest, + requestOptions?: Connectors.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, + "v1/connectors" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "cohere-ai", + "X-Fern-SDK-Version": "7.5.0", + }, + contentType: "application/json", + body: await serializers.CreateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.CreateResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Cohere.BadRequestError(_response.error.body); + case 403: + throw new Cohere.ForbiddenError(_response.error.body); + case 500: + throw new Cohere.InternalServerError(_response.error.body); + default: + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.CohereTimeoutError(); + case "unknown": + throw new errors.CohereError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Retrieve a connector by ID. + * @throws {@link Cohere.BadRequestError} + * @throws {@link Cohere.NotFoundError} + * @throws {@link Cohere.InternalServerError} + */ + public async get(id: string, requestOptions?: Connectors.RequestOptions): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, + `v1/connectors/${id}` + ), + method: "GET", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "cohere-ai", + "X-Fern-SDK-Version": "7.5.0", + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.GetResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Cohere.BadRequestError(_response.error.body); + case 404: + throw new Cohere.NotFoundError(_response.error.body); + case 500: + throw new Cohere.InternalServerError(_response.error.body); + default: + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.CohereTimeoutError(); + case "unknown": + throw new errors.CohereError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete a connector by ID. + * @throws {@link Cohere.BadRequestError} + * @throws {@link Cohere.ForbiddenError} + * @throws {@link Cohere.NotFoundError} + * @throws {@link Cohere.InternalServerError} + */ + public async delete(id: string, requestOptions?: Connectors.RequestOptions): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, + `v1/connectors/${id}` + ), + method: "DELETE", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "cohere-ai", + "X-Fern-SDK-Version": "7.5.0", + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.DeleteResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Cohere.BadRequestError(_response.error.body); + case 403: + throw new Cohere.ForbiddenError(_response.error.body); + case 404: + throw new Cohere.NotFoundError(_response.error.body); + case 500: + throw new Cohere.InternalServerError(_response.error.body); + default: + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.CohereTimeoutError(); + case "unknown": + throw new errors.CohereError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update a connector by ID. Omitted fields will not be updated. + * @throws {@link Cohere.BadRequestError} + * @throws {@link Cohere.ForbiddenError} + * @throws {@link Cohere.NotFoundError} + * @throws {@link Cohere.InternalServerError} + */ + public async update( + id: string, + request: Cohere.UpdateRequest = {}, + requestOptions?: Connectors.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, + `v1/connectors/${id}` + ), + method: "PATCH", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "cohere-ai", + "X-Fern-SDK-Version": "7.5.0", + }, + contentType: "application/json", + body: await serializers.UpdateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.UpdateResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Cohere.BadRequestError(_response.error.body); + case 403: + throw new Cohere.ForbiddenError(_response.error.body); + case 404: + throw new Cohere.NotFoundError(_response.error.body); + case 500: + throw new Cohere.InternalServerError(_response.error.body); + default: + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.CohereTimeoutError(); + case "unknown": + throw new errors.CohereError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Authorize the connector with the given ID for the connector oauth app. + * @throws {@link Cohere.BadRequestError} + * @throws {@link Cohere.NotFoundError} + * @throws {@link Cohere.InternalServerError} + */ + public async oAuthAuthorize( + id: string, + requestOptions?: Connectors.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CohereEnvironment.Production, + `v1/connectors/${id}/oauth/authorize` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "cohere-ai", + "X-Fern-SDK-Version": "7.5.0", + }, + contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + maxRetries: requestOptions?.maxRetries, + }); + if (_response.ok) { + return await serializers.OAuthAuthorizeResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Cohere.BadRequestError(_response.error.body); + case 404: + throw new Cohere.NotFoundError(_response.error.body); + case 500: + throw new Cohere.InternalServerError(_response.error.body); + default: + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.CohereError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.CohereTimeoutError(); + case "unknown": + throw new errors.CohereError({ + message: _response.error.errorMessage, + }); + } + } + + protected async _getAuthorizationHeader() { + return `Bearer ${await core.Supplier.get(this._options.token)}`; + } +} diff --git a/src/api/resources/connectors/client/index.ts b/src/api/resources/connectors/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/connectors/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/connectors/client/requests/CreateRequest.ts b/src/api/resources/connectors/client/requests/CreateRequest.ts new file mode 100644 index 0000000..a1c3ff3 --- /dev/null +++ b/src/api/resources/connectors/client/requests/CreateRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Cohere from "../../../.."; + +export interface CreateRequest { + /** A human-readable name for the connector. */ + name: string; + /** A description of the connector. */ + description?: string; + /** The URL of the connector that will be used to search for documents. */ + url: string; + /** A list of fields to exclude from the prompt (fields remain in the document). */ + excludes?: string[]; + /** The OAuth 2.0 configuration for the connector. Cannot be specified if serviceAuth is specified. */ + oauth?: Cohere.CreateConnectorOAuth; + /** Whether the connector is active or not. */ + active?: boolean; + /** Whether a chat request should continue or not if the request to this connector fails. */ + continueOnFailure?: boolean; + /** The service to service authentication configuration for the connector. Cannot be specified if oauth is specified. */ + serviceAuth?: Cohere.CreateConnectorServiceAuth; +} diff --git a/src/api/resources/connectors/client/requests/ListRequest.ts b/src/api/resources/connectors/client/requests/ListRequest.ts new file mode 100644 index 0000000..a4a5170 --- /dev/null +++ b/src/api/resources/connectors/client/requests/ListRequest.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ListRequest { + /** + * Maximum number of connectors to return [0, 100]. + */ + limit?: number; + /** + * Number of connectors to skip before returning results [0, inf]. + */ + offset?: number; +} diff --git a/src/api/resources/connectors/client/requests/UpdateRequest.ts b/src/api/resources/connectors/client/requests/UpdateRequest.ts new file mode 100644 index 0000000..6ef0f63 --- /dev/null +++ b/src/api/resources/connectors/client/requests/UpdateRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Cohere from "../../../.."; + +export interface UpdateRequest { + /** A human-readable name for the connector. */ + name?: string; + /** The URL of the connector that will be used to search for documents. */ + url?: string; + /** A list of fields to exclude from the prompt (fields remain in the document). */ + excludes?: string[]; + /** The OAuth 2.0 configuration for the connector. Cannot be specified if serviceAuth is specified. */ + oauth?: Cohere.CreateConnectorOAuth; + active?: boolean; + continueOnFailure?: boolean; + /** The service to service authentication configuration for the connector. Cannot be specified if oauth is specified. */ + serviceAuth?: Cohere.CreateConnectorServiceAuth; +} diff --git a/src/api/resources/connectors/client/requests/index.ts b/src/api/resources/connectors/client/requests/index.ts new file mode 100644 index 0000000..7206d12 --- /dev/null +++ b/src/api/resources/connectors/client/requests/index.ts @@ -0,0 +1,3 @@ +export { ListRequest } from "./ListRequest"; +export { CreateRequest } from "./CreateRequest"; +export { UpdateRequest } from "./UpdateRequest"; diff --git a/src/api/resources/connectors/index.ts b/src/api/resources/connectors/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/api/resources/connectors/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts new file mode 100644 index 0000000..6efb964 --- /dev/null +++ b/src/api/resources/index.ts @@ -0,0 +1,2 @@ +export * as connectors from "./connectors"; +export * from "./connectors/client/requests"; diff --git a/src/api/types/ApiMetaApiVersion.ts b/src/api/types/ApiMetaApiVersion.ts index 44f1591..6d44941 100644 --- a/src/api/types/ApiMetaApiVersion.ts +++ b/src/api/types/ApiMetaApiVersion.ts @@ -2,8 +2,11 @@ * This file was auto-generated by Fern from our API Definition. */ +import * as Cohere from ".."; + export interface ApiMetaApiVersion { version: string; isDeprecated?: boolean; isExperimental?: boolean; + billedUnits?: Cohere.ApiMetaApiVersionBilledUnits; } diff --git a/src/api/types/ApiMetaApiVersionBilledUnits.ts b/src/api/types/ApiMetaApiVersionBilledUnits.ts new file mode 100644 index 0000000..9328bd9 --- /dev/null +++ b/src/api/types/ApiMetaApiVersionBilledUnits.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ApiMetaApiVersionBilledUnits { + /** + * The number of billed input tokens. + * + */ + inputTokens?: number; + /** + * The number of billed output tokens. + * + */ + outputTokens?: number; + /** + * The number of billed search units. + * + */ + searchUnits?: number; + /** + * The number of billed classifications units. + * + */ + classifications?: number; +} diff --git a/src/api/types/ClassifyResponseClassificationsItem.ts b/src/api/types/ClassifyResponseClassificationsItem.ts index 11fd953..06bb328 100644 --- a/src/api/types/ClassifyResponseClassificationsItem.ts +++ b/src/api/types/ClassifyResponseClassificationsItem.ts @@ -10,13 +10,13 @@ export interface ClassifyResponseClassificationsItem { input?: string; /** The predicted label for the associated query (only filled for single-label models) */ prediction?: string; - /** An array containing the predicted labels for the associated query */ + /** An array containing the predicted labels for the associated query (only filled for single-label classification) */ predictions: string[]; /** The confidence score for the top predicted class (only filled for single-label classification) */ confidence?: number; /** An array containing the confidence scores of all the predictions in the same order */ confidences: number[]; - /** A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1. */ + /** A map containing each label and its confidence score according to the classifier. All the confidence scores add up to 1 for single-label classification. For multi-label classification the label confidences are independent of each other, so they don't have to sum up to 1. */ labels: Record; /** The type of classification performed */ classificationType: Cohere.ClassifyResponseClassificationsItemClassificationType; diff --git a/src/api/types/Connector.ts b/src/api/types/Connector.ts new file mode 100644 index 0000000..4da9387 --- /dev/null +++ b/src/api/types/Connector.ts @@ -0,0 +1,44 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Cohere from ".."; + +/** + * A connector allows you to integrate data sources with the '/chat' endpoint to create grounded generations with citations to the data source. + * documents to help answer users. + */ +export interface Connector { + /** + * The unique identifier of the connector (used in both `/connectors` & `/chat` endpoints). + * This is automatically created from the name of the connector upon registration. + */ + id: string; + /** + * The organization to which this connector belongs. This is automatically set to + * the organization of the user who created the connector. + */ + organizationId?: string; + /** A human-readable name for the connector. */ + name: string; + /** A description of the connector. */ + description?: string; + /** The URL of the connector that will be used to search for documents. */ + url?: string; + /** The UTC time at which the connector was created. */ + createdAt: Date; + /** The UTC time at which the connector was last updated. */ + updatedAt: Date; + /** A list of fields to exclude from the prompt (fields remain in the document). */ + excludes?: string[]; + /** The type of authentication/authorization used by the connector. Possible values: [oauth, service_auth] */ + authType?: string; + /** The OAuth 2.0 configuration for the connector. */ + oauth?: Cohere.ConnectorOAuth; + /** The OAuth status for the user making the request. One of ["valid", "expired", ""]. Empty string (field is omitted) means the user has not authorized the connector yet. */ + authStatus?: Cohere.ConnectorAuthStatus; + /** Whether the connector is active or not. */ + active?: boolean; + /** Whether a chat request should continue or not if the request to this connector fails. */ + continueOnFailure?: boolean; +} diff --git a/src/api/types/ConnectorAuthStatus.ts b/src/api/types/ConnectorAuthStatus.ts new file mode 100644 index 0000000..a63100d --- /dev/null +++ b/src/api/types/ConnectorAuthStatus.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * The OAuth status for the user making the request. One of ["valid", "expired", ""]. Empty string (field is omitted) means the user has not authorized the connector yet. + */ +export type ConnectorAuthStatus = "valid" | "expired"; + +export const ConnectorAuthStatus = { + Valid: "valid", + Expired: "expired", +} as const; diff --git a/src/api/types/ConnectorOAuth.ts b/src/api/types/ConnectorOAuth.ts new file mode 100644 index 0000000..880ff59 --- /dev/null +++ b/src/api/types/ConnectorOAuth.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ConnectorOAuth { + /** The OAuth 2.0 /authorize endpoint to use when users authorize the connector. */ + authorizeUrl?: string; + /** The OAuth 2.0 /token endpoint to use when users authorize the connector. */ + tokenUrl?: string; + /** The OAuth scopes to request when users authorize the connector. */ + scope?: string; +} diff --git a/src/api/types/CreateConnectorOAuth.ts b/src/api/types/CreateConnectorOAuth.ts new file mode 100644 index 0000000..f4b782f --- /dev/null +++ b/src/api/types/CreateConnectorOAuth.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CreateConnectorOAuth { + /** The OAuth 2.0 client ID. This fields is encrypted at rest. */ + clientId: string; + /** The OAuth 2.0 client Secret. This field is encrypted at rest and never returned in a response. */ + clientSecret: string; + /** The OAuth 2.0 /authorize endpoint to use when users authorize the connector. */ + authorizeUrl: string; + /** The OAuth 2.0 /token endpoint to use when users authorize the connector. */ + tokenUrl: string; + /** The OAuth scopes to request when users authorize the connector. */ + scope?: string; +} diff --git a/src/api/types/CreateConnectorServiceAuth.ts b/src/api/types/CreateConnectorServiceAuth.ts new file mode 100644 index 0000000..367edd3 --- /dev/null +++ b/src/api/types/CreateConnectorServiceAuth.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface CreateConnectorServiceAuth { + /** The token_type specifies the way the token is passed in the Authorization header. Valid values are "bearer", "basic", and "noscheme". */ + type: string; + /** The token that will be used in the HTTP Authorization header when making requests to the connector. This field is encrypted at rest and never returned in a response. */ + token: string; +} diff --git a/src/api/types/CreateResponse.ts b/src/api/types/CreateResponse.ts new file mode 100644 index 0000000..de27281 --- /dev/null +++ b/src/api/types/CreateResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Cohere from ".."; + +export interface CreateResponse { + connector: Cohere.Connector; +} diff --git a/src/api/types/DeleteResponse.ts b/src/api/types/DeleteResponse.ts new file mode 100644 index 0000000..0b26181 --- /dev/null +++ b/src/api/types/DeleteResponse.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DeleteResponse = Record; diff --git a/src/api/types/GetResponse.ts b/src/api/types/GetResponse.ts new file mode 100644 index 0000000..0d8cd4b --- /dev/null +++ b/src/api/types/GetResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Cohere from ".."; + +export interface GetResponse { + connector: Cohere.Connector; +} diff --git a/src/api/types/ListResponse.ts b/src/api/types/ListResponse.ts new file mode 100644 index 0000000..4fe8439 --- /dev/null +++ b/src/api/types/ListResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Cohere from ".."; + +export interface ListResponse { + connectors: Cohere.Connector[]; +} diff --git a/src/api/types/OAuthAuthorizeResponse.ts b/src/api/types/OAuthAuthorizeResponse.ts new file mode 100644 index 0000000..c9cd885 --- /dev/null +++ b/src/api/types/OAuthAuthorizeResponse.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface OAuthAuthorizeResponse { + /** The OAuth 2.0 redirect url. Redirect the user to this url to authorize the connector. */ + redirectUrl?: string; +} diff --git a/src/api/types/UpdateResponse.ts b/src/api/types/UpdateResponse.ts new file mode 100644 index 0000000..5aa1291 --- /dev/null +++ b/src/api/types/UpdateResponse.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as Cohere from ".."; + +export interface UpdateResponse { + connector: Cohere.Connector; +} diff --git a/src/api/types/index.ts b/src/api/types/index.ts index a7a4d3b..6db9091 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -48,4 +48,16 @@ export * from "./SingleGeneration"; export * from "./SingleGenerationTokenLikelihoodsItem"; export * from "./ApiMeta"; export * from "./ApiMetaApiVersion"; +export * from "./ApiMetaApiVersionBilledUnits"; export * from "./Generation"; +export * from "./ConnectorOAuth"; +export * from "./Connector"; +export * from "./ConnectorAuthStatus"; +export * from "./ListResponse"; +export * from "./CreateConnectorOAuth"; +export * from "./CreateConnectorServiceAuth"; +export * from "./CreateResponse"; +export * from "./GetResponse"; +export * from "./DeleteResponse"; +export * from "./UpdateResponse"; +export * from "./OAuthAuthorizeResponse"; diff --git a/src/serialization/index.ts b/src/serialization/index.ts index c9240f8..848e75a 100644 --- a/src/serialization/index.ts +++ b/src/serialization/index.ts @@ -1,2 +1,3 @@ export * from "./types"; export * from "./client"; +export * from "./resources"; diff --git a/src/serialization/resources/connectors/client/index.ts b/src/serialization/resources/connectors/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/connectors/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/resources/connectors/client/requests/CreateRequest.ts b/src/serialization/resources/connectors/client/requests/CreateRequest.ts new file mode 100644 index 0000000..3370006 --- /dev/null +++ b/src/serialization/resources/connectors/client/requests/CreateRequest.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as Cohere from "../../../../../api"; +import * as core from "../../../../../core"; + +export const CreateRequest: core.serialization.Schema = + core.serialization.object({ + name: core.serialization.string(), + description: core.serialization.string().optional(), + url: core.serialization.string(), + excludes: core.serialization.list(core.serialization.string()).optional(), + oauth: core.serialization.lazyObject(async () => (await import("../../../..")).CreateConnectorOAuth).optional(), + active: core.serialization.boolean().optional(), + continueOnFailure: core.serialization.boolean().optional(), + serviceAuth: core.serialization + .lazyObject(async () => (await import("../../../..")).CreateConnectorServiceAuth) + .optional(), + }); + +export declare namespace CreateRequest { + interface Raw { + name: string; + description?: string | null; + url: string; + excludes?: string[] | null; + oauth?: serializers.CreateConnectorOAuth.Raw | null; + active?: boolean | null; + continueOnFailure?: boolean | null; + serviceAuth?: serializers.CreateConnectorServiceAuth.Raw | null; + } +} diff --git a/src/serialization/resources/connectors/client/requests/UpdateRequest.ts b/src/serialization/resources/connectors/client/requests/UpdateRequest.ts new file mode 100644 index 0000000..a4269ca --- /dev/null +++ b/src/serialization/resources/connectors/client/requests/UpdateRequest.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as Cohere from "../../../../../api"; +import * as core from "../../../../../core"; + +export const UpdateRequest: core.serialization.Schema = + core.serialization.object({ + name: core.serialization.string().optional(), + url: core.serialization.string().optional(), + excludes: core.serialization.list(core.serialization.string()).optional(), + oauth: core.serialization.lazyObject(async () => (await import("../../../..")).CreateConnectorOAuth).optional(), + active: core.serialization.boolean().optional(), + continueOnFailure: core.serialization.boolean().optional(), + serviceAuth: core.serialization + .lazyObject(async () => (await import("../../../..")).CreateConnectorServiceAuth) + .optional(), + }); + +export declare namespace UpdateRequest { + interface Raw { + name?: string | null; + url?: string | null; + excludes?: string[] | null; + oauth?: serializers.CreateConnectorOAuth.Raw | null; + active?: boolean | null; + continueOnFailure?: boolean | null; + serviceAuth?: serializers.CreateConnectorServiceAuth.Raw | null; + } +} diff --git a/src/serialization/resources/connectors/client/requests/index.ts b/src/serialization/resources/connectors/client/requests/index.ts new file mode 100644 index 0000000..64340bf --- /dev/null +++ b/src/serialization/resources/connectors/client/requests/index.ts @@ -0,0 +1,2 @@ +export { CreateRequest } from "./CreateRequest"; +export { UpdateRequest } from "./UpdateRequest"; diff --git a/src/serialization/resources/connectors/index.ts b/src/serialization/resources/connectors/index.ts new file mode 100644 index 0000000..5ec7692 --- /dev/null +++ b/src/serialization/resources/connectors/index.ts @@ -0,0 +1 @@ +export * from "./client"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts new file mode 100644 index 0000000..6efb964 --- /dev/null +++ b/src/serialization/resources/index.ts @@ -0,0 +1,2 @@ +export * as connectors from "./connectors"; +export * from "./connectors/client/requests"; diff --git a/src/serialization/types/ApiMetaApiVersion.ts b/src/serialization/types/ApiMetaApiVersion.ts index 986e8a1..257b257 100644 --- a/src/serialization/types/ApiMetaApiVersion.ts +++ b/src/serialization/types/ApiMetaApiVersion.ts @@ -13,6 +13,10 @@ export const ApiMetaApiVersion: core.serialization.ObjectSchema< version: core.serialization.string(), isDeprecated: core.serialization.property("is_deprecated", core.serialization.boolean().optional()), isExperimental: core.serialization.property("is_experimental", core.serialization.boolean().optional()), + billedUnits: core.serialization.property( + "billed_units", + core.serialization.lazyObject(async () => (await import("..")).ApiMetaApiVersionBilledUnits).optional() + ), }); export declare namespace ApiMetaApiVersion { @@ -20,5 +24,6 @@ export declare namespace ApiMetaApiVersion { version: string; is_deprecated?: boolean | null; is_experimental?: boolean | null; + billed_units?: serializers.ApiMetaApiVersionBilledUnits.Raw | null; } } diff --git a/src/serialization/types/ApiMetaApiVersionBilledUnits.ts b/src/serialization/types/ApiMetaApiVersionBilledUnits.ts new file mode 100644 index 0000000..b75d580 --- /dev/null +++ b/src/serialization/types/ApiMetaApiVersionBilledUnits.ts @@ -0,0 +1,26 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ApiMetaApiVersionBilledUnits: core.serialization.ObjectSchema< + serializers.ApiMetaApiVersionBilledUnits.Raw, + Cohere.ApiMetaApiVersionBilledUnits +> = core.serialization.object({ + inputTokens: core.serialization.property("input_tokens", core.serialization.number().optional()), + outputTokens: core.serialization.property("output_tokens", core.serialization.number().optional()), + searchUnits: core.serialization.property("search_units", core.serialization.number().optional()), + classifications: core.serialization.number().optional(), +}); + +export declare namespace ApiMetaApiVersionBilledUnits { + interface Raw { + input_tokens?: number | null; + output_tokens?: number | null; + search_units?: number | null; + classifications?: number | null; + } +} diff --git a/src/serialization/types/Connector.ts b/src/serialization/types/Connector.ts new file mode 100644 index 0000000..84f72d8 --- /dev/null +++ b/src/serialization/types/Connector.ts @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const Connector: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + organizationId: core.serialization.string().optional(), + name: core.serialization.string(), + description: core.serialization.string().optional(), + url: core.serialization.string().optional(), + createdAt: core.serialization.date(), + updatedAt: core.serialization.date(), + excludes: core.serialization.list(core.serialization.string()).optional(), + authType: core.serialization.string().optional(), + oauth: core.serialization.lazyObject(async () => (await import("..")).ConnectorOAuth).optional(), + authStatus: core.serialization.lazy(async () => (await import("..")).ConnectorAuthStatus).optional(), + active: core.serialization.boolean().optional(), + continueOnFailure: core.serialization.boolean().optional(), + }); + +export declare namespace Connector { + interface Raw { + id: string; + organizationId?: string | null; + name: string; + description?: string | null; + url?: string | null; + createdAt: string; + updatedAt: string; + excludes?: string[] | null; + authType?: string | null; + oauth?: serializers.ConnectorOAuth.Raw | null; + authStatus?: serializers.ConnectorAuthStatus.Raw | null; + active?: boolean | null; + continueOnFailure?: boolean | null; + } +} diff --git a/src/serialization/types/ConnectorAuthStatus.ts b/src/serialization/types/ConnectorAuthStatus.ts new file mode 100644 index 0000000..dea9f15 --- /dev/null +++ b/src/serialization/types/ConnectorAuthStatus.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ConnectorAuthStatus: core.serialization.Schema< + serializers.ConnectorAuthStatus.Raw, + Cohere.ConnectorAuthStatus +> = core.serialization.enum_(["valid", "expired"]); + +export declare namespace ConnectorAuthStatus { + type Raw = "valid" | "expired"; +} diff --git a/src/serialization/types/ConnectorOAuth.ts b/src/serialization/types/ConnectorOAuth.ts new file mode 100644 index 0000000..a5b8460 --- /dev/null +++ b/src/serialization/types/ConnectorOAuth.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ConnectorOAuth: core.serialization.ObjectSchema = + core.serialization.object({ + authorizeUrl: core.serialization.string().optional(), + tokenUrl: core.serialization.string().optional(), + scope: core.serialization.string().optional(), + }); + +export declare namespace ConnectorOAuth { + interface Raw { + authorizeUrl?: string | null; + tokenUrl?: string | null; + scope?: string | null; + } +} diff --git a/src/serialization/types/CreateConnectorOAuth.ts b/src/serialization/types/CreateConnectorOAuth.ts new file mode 100644 index 0000000..2468540 --- /dev/null +++ b/src/serialization/types/CreateConnectorOAuth.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const CreateConnectorOAuth: core.serialization.ObjectSchema< + serializers.CreateConnectorOAuth.Raw, + Cohere.CreateConnectorOAuth +> = core.serialization.object({ + clientId: core.serialization.string(), + clientSecret: core.serialization.string(), + authorizeUrl: core.serialization.string(), + tokenUrl: core.serialization.string(), + scope: core.serialization.string().optional(), +}); + +export declare namespace CreateConnectorOAuth { + interface Raw { + clientId: string; + clientSecret: string; + authorizeUrl: string; + tokenUrl: string; + scope?: string | null; + } +} diff --git a/src/serialization/types/CreateConnectorServiceAuth.ts b/src/serialization/types/CreateConnectorServiceAuth.ts new file mode 100644 index 0000000..851f7ac --- /dev/null +++ b/src/serialization/types/CreateConnectorServiceAuth.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const CreateConnectorServiceAuth: core.serialization.ObjectSchema< + serializers.CreateConnectorServiceAuth.Raw, + Cohere.CreateConnectorServiceAuth +> = core.serialization.object({ + type: core.serialization.string(), + token: core.serialization.string(), +}); + +export declare namespace CreateConnectorServiceAuth { + interface Raw { + type: string; + token: string; + } +} diff --git a/src/serialization/types/CreateResponse.ts b/src/serialization/types/CreateResponse.ts new file mode 100644 index 0000000..653986f --- /dev/null +++ b/src/serialization/types/CreateResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const CreateResponse: core.serialization.ObjectSchema = + core.serialization.object({ + connector: core.serialization.lazyObject(async () => (await import("..")).Connector), + }); + +export declare namespace CreateResponse { + interface Raw { + connector: serializers.Connector.Raw; + } +} diff --git a/src/serialization/types/DeleteResponse.ts b/src/serialization/types/DeleteResponse.ts new file mode 100644 index 0000000..49c1ff2 --- /dev/null +++ b/src/serialization/types/DeleteResponse.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const DeleteResponse: core.serialization.Schema = + core.serialization.record(core.serialization.string(), core.serialization.unknown()); + +export declare namespace DeleteResponse { + type Raw = Record; +} diff --git a/src/serialization/types/GetResponse.ts b/src/serialization/types/GetResponse.ts new file mode 100644 index 0000000..690b2ad --- /dev/null +++ b/src/serialization/types/GetResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const GetResponse: core.serialization.ObjectSchema = + core.serialization.object({ + connector: core.serialization.lazyObject(async () => (await import("..")).Connector), + }); + +export declare namespace GetResponse { + interface Raw { + connector: serializers.Connector.Raw; + } +} diff --git a/src/serialization/types/ListResponse.ts b/src/serialization/types/ListResponse.ts new file mode 100644 index 0000000..a7d1d6e --- /dev/null +++ b/src/serialization/types/ListResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const ListResponse: core.serialization.ObjectSchema = + core.serialization.object({ + connectors: core.serialization.list(core.serialization.lazyObject(async () => (await import("..")).Connector)), + }); + +export declare namespace ListResponse { + interface Raw { + connectors: serializers.Connector.Raw[]; + } +} diff --git a/src/serialization/types/OAuthAuthorizeResponse.ts b/src/serialization/types/OAuthAuthorizeResponse.ts new file mode 100644 index 0000000..d14685b --- /dev/null +++ b/src/serialization/types/OAuthAuthorizeResponse.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const OAuthAuthorizeResponse: core.serialization.ObjectSchema< + serializers.OAuthAuthorizeResponse.Raw, + Cohere.OAuthAuthorizeResponse +> = core.serialization.object({ + redirectUrl: core.serialization.property("redirect_url", core.serialization.string().optional()), +}); + +export declare namespace OAuthAuthorizeResponse { + interface Raw { + redirect_url?: string | null; + } +} diff --git a/src/serialization/types/UpdateResponse.ts b/src/serialization/types/UpdateResponse.ts new file mode 100644 index 0000000..0abb480 --- /dev/null +++ b/src/serialization/types/UpdateResponse.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as Cohere from "../../api"; +import * as core from "../../core"; + +export const UpdateResponse: core.serialization.ObjectSchema = + core.serialization.object({ + connector: core.serialization.lazyObject(async () => (await import("..")).Connector), + }); + +export declare namespace UpdateResponse { + interface Raw { + connector: serializers.Connector.Raw; + } +} diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts index a7a4d3b..6db9091 100644 --- a/src/serialization/types/index.ts +++ b/src/serialization/types/index.ts @@ -48,4 +48,16 @@ export * from "./SingleGeneration"; export * from "./SingleGenerationTokenLikelihoodsItem"; export * from "./ApiMeta"; export * from "./ApiMetaApiVersion"; +export * from "./ApiMetaApiVersionBilledUnits"; export * from "./Generation"; +export * from "./ConnectorOAuth"; +export * from "./Connector"; +export * from "./ConnectorAuthStatus"; +export * from "./ListResponse"; +export * from "./CreateConnectorOAuth"; +export * from "./CreateConnectorServiceAuth"; +export * from "./CreateResponse"; +export * from "./GetResponse"; +export * from "./DeleteResponse"; +export * from "./UpdateResponse"; +export * from "./OAuthAuthorizeResponse";