diff --git a/.fern/metadata.json b/.fern/metadata.json index 72e5ce8b..c3346184 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,5 +1,5 @@ { - "cliVersion": "4.86.1", + "cliVersion": "5.15.3", "generatorName": "fernapi/fern-typescript-node-sdk", "generatorVersion": "3.54.0", "generatorConfig": { @@ -15,7 +15,9 @@ }, "packageJson": { "scripts": { - "test:integration": "vitest --config vitest.integration.config.mts" + "test:integration": "pnpm test:integration:main && pnpm test:integration:empty-state", + "test:integration:main": "vitest run --config vitest.integration.config.mts --project integration", + "test:integration:empty-state": "vitest run --config vitest.integration.config.mts --project integration-empty-state" }, "exports": { "./utils": { @@ -32,6 +34,6 @@ } } }, - "originGitCommit": "23bce53307f0836f2dcd50e82ef0aba136e7ec2f", + "originGitCommit": "d2d0dc77f42a7e837cee698d1a16ce6b3416bda9", "sdkVersion": "0.0.0-dev" } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index afca55cf..5ee8b97c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -10,7 +10,7 @@ importers: dependencies: ws: specifier: ^8.16.0 - version: 8.20.0 + version: 8.20.1 devDependencies: '@biomejs/biome': specifier: 2.4.3 @@ -1146,8 +1146,8 @@ packages: resolution: {integrity: sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==} engines: {node: '>=10'} - ws@8.20.0: - resolution: {integrity: sha512-sAt8BhgNbzCtgGbt2OxmpuryO63ZoDk/sqaB/znQm94T4fCEsy/yV+7CdC1kJhOU9lboAEU7R3kquuycDoibVA==} + ws@8.20.1: + resolution: {integrity: sha512-It4dO0K5v//JtTXuPkfEOaI3uUN87iYPnqo/ZzqCoG3g8uhA66QUMs/SrM0YK7/NAu+r4LMh/9dq2A7k+rHs+w==} engines: {node: '>=10.0.0'} peerDependencies: bufferutil: ^4.0.1 @@ -2163,7 +2163,7 @@ snapshots: string-width: 4.2.3 strip-ansi: 6.0.1 - ws@8.20.0: {} + ws@8.20.1: {} y18n@5.0.8: {} diff --git a/src/BaseClient.ts b/src/BaseClient.ts index 1b76cbaa..27d389e5 100644 --- a/src/BaseClient.ts +++ b/src/BaseClient.ts @@ -10,7 +10,7 @@ export type BaseClientOptions = { /** Specify a custom URL to connect the client to. */ baseUrl?: core.Supplier; /** Override the Tenant-Name header */ - tenantName: core.Supplier; + tenantName?: core.Supplier; /** Additional headers to include in requests. */ headers?: Record | null | undefined>; /** The default maximum time to wait for a response in seconds. */ @@ -31,7 +31,7 @@ export interface BaseRequestOptions { /** A hook to abort the request. */ abortSignal?: AbortSignal; /** Override the Tenant-Name header */ - tenantName?: string; + tenantName?: string | undefined; /** Additional query string parameters to include in the request. */ queryParams?: Record; /** Additional headers to include in the request. */ diff --git a/src/Client.ts b/src/Client.ts index 7aa94bd7..ec9df172 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -1,6 +1,11 @@ // This file was auto-generated by Fern from our API Definition. import { AgentsClient } from "./api/resources/agents/client/Client.js"; +import { AlphaDocumentsClient } from "./api/resources/alphaDocuments/client/Client.js"; +import { AlphaSectionsClient } from "./api/resources/alphaSections/client/Client.js"; +import { AlphaSectionVersionsClient } from "./api/resources/alphaSectionVersions/client/Client.js"; +import { AlphaTemplatesClient } from "./api/resources/alphaTemplates/client/Client.js"; +import { AlphaTemplateVersionsClient } from "./api/resources/alphaTemplateVersions/client/Client.js"; import { AuthClient } from "./api/resources/auth/client/Client.js"; import { CodesClient } from "./api/resources/codes/client/Client.js"; import { DocumentsClient } from "./api/resources/documents/client/Client.js"; @@ -30,6 +35,11 @@ export class CortiClient { protected _documents: DocumentsClient | undefined; protected _templates: TemplatesClient | undefined; protected _codes: CodesClient | undefined; + protected _alphaTemplates: AlphaTemplatesClient | undefined; + protected _alphaTemplateVersions: AlphaTemplateVersionsClient | undefined; + protected _alphaSections: AlphaSectionsClient | undefined; + protected _alphaSectionVersions: AlphaSectionVersionsClient | undefined; + protected _alphaDocuments: AlphaDocumentsClient | undefined; protected _agents: AgentsClient | undefined; protected _stream: StreamClient | undefined; protected _transcribe: TranscribeClient | undefined; @@ -70,6 +80,26 @@ export class CortiClient { return (this._codes ??= new CodesClient(this._options)); } + public get alphaTemplates(): AlphaTemplatesClient { + return (this._alphaTemplates ??= new AlphaTemplatesClient(this._options)); + } + + public get alphaTemplateVersions(): AlphaTemplateVersionsClient { + return (this._alphaTemplateVersions ??= new AlphaTemplateVersionsClient(this._options)); + } + + public get alphaSections(): AlphaSectionsClient { + return (this._alphaSections ??= new AlphaSectionsClient(this._options)); + } + + public get alphaSectionVersions(): AlphaSectionVersionsClient { + return (this._alphaSectionVersions ??= new AlphaSectionVersionsClient(this._options)); + } + + public get alphaDocuments(): AlphaDocumentsClient { + return (this._alphaDocuments ??= new AlphaDocumentsClient(this._options)); + } + public get agents(): AgentsClient { return (this._agents ??= new AgentsClient(this._options)); } diff --git a/src/api/errors/UnprocessableEntityError.ts b/src/api/errors/UnprocessableEntityError.ts index bc71fc87..53d1ef21 100644 --- a/src/api/errors/UnprocessableEntityError.ts +++ b/src/api/errors/UnprocessableEntityError.ts @@ -2,10 +2,9 @@ import type * as core from "../../core/index.js"; import * as errors from "../../errors/index.js"; -import type * as Corti from "../index.js"; export class UnprocessableEntityError extends errors.CortiError { - constructor(body: Corti.AgentsValidationErrorResponse, rawResponse?: core.RawResponse) { + constructor(body?: unknown, rawResponse?: core.RawResponse) { super({ message: "UnprocessableEntityError", statusCode: 422, diff --git a/src/api/resources/agents/client/Client.ts b/src/api/resources/agents/client/Client.ts index 0ac4113a..0136af74 100644 --- a/src/api/resources/agents/client/Client.ts +++ b/src/api/resources/agents/client/Client.ts @@ -183,16 +183,7 @@ export class AgentsClient { case 401: throw new Corti.UnauthorizedError(_response.error.body, _response.rawResponse); case 422: - throw new Corti.UnprocessableEntityError( - serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); + throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse); default: throw new errors.CortiError({ statusCode: _response.error.statusCode, @@ -429,16 +420,7 @@ export class AgentsClient { case 404: throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); case 422: - throw new Corti.UnprocessableEntityError( - serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); + throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse); default: throw new errors.CortiError({ statusCode: _response.error.statusCode, @@ -621,16 +603,7 @@ export class AgentsClient { case 404: throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); case 422: - throw new Corti.UnprocessableEntityError( - serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); + throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse); default: throw new errors.CortiError({ statusCode: _response.error.statusCode, @@ -909,16 +882,7 @@ export class AgentsClient { case 401: throw new Corti.UnauthorizedError(_response.error.body, _response.rawResponse); case 422: - throw new Corti.UnprocessableEntityError( - serializers.AgentsValidationErrorResponse.parseOrThrow(_response.error.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - skipValidation: true, - breadcrumbsPrefix: ["response"], - }), - _response.rawResponse, - ); + throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse); default: throw new errors.CortiError({ statusCode: _response.error.statusCode, diff --git a/src/api/resources/alphaDocuments/client/Client.ts b/src/api/resources/alphaDocuments/client/Client.ts new file mode 100644 index 00000000..305974df --- /dev/null +++ b/src/api/resources/alphaDocuments/client/Client.ts @@ -0,0 +1,72 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; + +export declare namespace AlphaDocumentsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class AlphaDocumentsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: AlphaDocumentsClient.Options) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * @param {AlphaDocumentsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.alphaDocuments.generate() + */ + public generate(requestOptions?: AlphaDocumentsClient.RequestOptions): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__generate(requestOptions)); + } + + private async __generate( + requestOptions?: AlphaDocumentsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + "alpha/documents", + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/alpha/documents"); + } +} diff --git a/src/api/resources/alphaDocuments/client/index.ts b/src/api/resources/alphaDocuments/client/index.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/src/api/resources/alphaDocuments/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/alphaDocuments/index.ts b/src/api/resources/alphaDocuments/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/alphaDocuments/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/alphaSectionVersions/client/Client.ts b/src/api/resources/alphaSectionVersions/client/Client.ts new file mode 100644 index 00000000..a0bd2ac6 --- /dev/null +++ b/src/api/resources/alphaSectionVersions/client/Client.ts @@ -0,0 +1,428 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as serializers from "../../../../serialization/index.js"; +import * as Corti from "../../../index.js"; + +export declare namespace AlphaSectionVersionsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class AlphaSectionVersionsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: AlphaSectionVersionsClient.Options) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * @param {string} sectionID + * @param {AlphaSectionVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSectionVersions.list("sectionID") + */ + public list( + sectionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(sectionID, requestOptions)); + } + + private async __list( + sectionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}/versions/`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.alphaSectionVersions.list.Response.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/alpha/sections/{sectionID}/versions/", + ); + } + + /** + * @param {string} sectionID + * @param {Corti.SectionGeneration} request + * @param {AlphaSectionVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.BadRequestError} + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSectionVersions.create("sectionID", { + * heading: "heading", + * instructions: { + * contentPrompt: "contentPrompt" + * }, + * outputSchema: { + * type: "string" + * } + * }) + */ + public create( + sectionID: string, + request: Corti.SectionGeneration, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(sectionID, request, requestOptions)); + } + + private async __create( + sectionID: string, + request: Corti.SectionGeneration, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}/versions/`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: serializers.SectionGeneration.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + omitUndefined: true, + }), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.SectionVersion.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Corti.BadRequestError(_response.error.body, _response.rawResponse); + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/alpha/sections/{sectionID}/versions/", + ); + } + + /** + * @param {string} sectionID + * @param {string} versionID + * @param {AlphaSectionVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSectionVersions.get("sectionID", "versionID") + */ + public get( + sectionID: string, + versionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(sectionID, versionID, requestOptions)); + } + + private async __get( + sectionID: string, + versionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}/versions/${core.url.encodePathParam(versionID)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.SectionVersion.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/alpha/sections/{sectionID}/versions/{versionID}", + ); + } + + /** + * Currently published version cannot be deleted. Last remaining version can be deleted, simply create a new section version again if needed. + * + * @param {string} sectionID + * @param {string} versionID + * @param {AlphaSectionVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSectionVersions.delete("sectionID", "versionID") + */ + public delete( + sectionID: string, + versionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(sectionID, versionID, requestOptions)); + } + + private async __delete( + sectionID: string, + versionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}/versions/${core.url.encodePathParam(versionID)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/alpha/sections/{sectionID}/versions/{versionID}", + ); + } + + /** + * Sets this version as the published version of the section. + * + * @param {string} sectionID + * @param {string} versionID + * @param {AlphaSectionVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSectionVersions.publish("sectionID", "versionID") + */ + public publish( + sectionID: string, + versionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__publish(sectionID, versionID, requestOptions)); + } + + private async __publish( + sectionID: string, + versionID: string, + requestOptions?: AlphaSectionVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}/versions/${core.url.encodePathParam(versionID)}/publish`, + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.StatusResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/alpha/sections/{sectionID}/versions/{versionID}/publish", + ); + } +} diff --git a/src/api/resources/alphaSectionVersions/client/index.ts b/src/api/resources/alphaSectionVersions/client/index.ts new file mode 100644 index 00000000..cb0ff5c3 --- /dev/null +++ b/src/api/resources/alphaSectionVersions/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/api/resources/alphaSectionVersions/index.ts b/src/api/resources/alphaSectionVersions/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/alphaSectionVersions/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/alphaSections/client/Client.ts b/src/api/resources/alphaSections/client/Client.ts new file mode 100644 index 00000000..105668da --- /dev/null +++ b/src/api/resources/alphaSections/client/Client.ts @@ -0,0 +1,406 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as serializers from "../../../../serialization/index.js"; +import * as Corti from "../../../index.js"; + +export declare namespace AlphaSectionsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class AlphaSectionsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: AlphaSectionsClient.Options) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * @param {Corti.ListAlphaSectionsRequest} request + * @param {AlphaSectionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.alphaSections.list() + */ + public list( + request: Corti.ListAlphaSectionsRequest = {}, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); + } + + private async __list( + request: Corti.ListAlphaSectionsRequest = {}, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): Promise> { + const { lang, label, published } = request; + const _queryParams: Record = { + lang, + label, + published, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + "alpha/sections/", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.alphaSections.list.Response.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/alpha/sections/"); + } + + /** + * @param {Corti.CreateSectionRequest} request + * @param {AlphaSectionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.BadRequestError} + * + * @example + * await client.alphaSections.create({ + * name: "name", + * language: "language", + * generation: { + * heading: "heading", + * instructions: { + * contentPrompt: "contentPrompt" + * }, + * outputSchema: { + * type: "string" + * } + * } + * }) + */ + public create( + request: Corti.CreateSectionRequest, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Corti.CreateSectionRequest, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + "alpha/sections/", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: serializers.CreateSectionRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + omitUndefined: true, + }), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.Section.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Corti.BadRequestError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/alpha/sections/"); + } + + /** + * @param {string} sectionID + * @param {AlphaSectionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSections.get("sectionID") + */ + public get( + sectionID: string, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(sectionID, requestOptions)); + } + + private async __get( + sectionID: string, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.Section.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/alpha/sections/{sectionID}"); + } + + /** + * Delete section + * + * @param {string} sectionID + * @param {AlphaSectionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSections.delete("sectionID") + */ + public delete( + sectionID: string, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(sectionID, requestOptions)); + } + + private async __delete( + sectionID: string, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/alpha/sections/{sectionID}", + ); + } + + /** + * @param {string} sectionID + * @param {Corti.UpdateSectionRequest} request + * @param {AlphaSectionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.BadRequestError} + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaSections.update("sectionID") + */ + public update( + sectionID: string, + request: Corti.UpdateSectionRequest = {}, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(sectionID, request, requestOptions)); + } + + private async __update( + sectionID: string, + request: Corti.UpdateSectionRequest = {}, + requestOptions?: AlphaSectionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/sections/${core.url.encodePathParam(sectionID)}`, + ), + method: "PATCH", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: serializers.UpdateSectionRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + omitUndefined: true, + }), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.Section.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Corti.BadRequestError(_response.error.body, _response.rawResponse); + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "PATCH", "/alpha/sections/{sectionID}"); + } +} diff --git a/src/api/resources/alphaSections/client/index.ts b/src/api/resources/alphaSections/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/alphaSections/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/alphaSections/client/requests/ListAlphaSectionsRequest.ts b/src/api/resources/alphaSections/client/requests/ListAlphaSectionsRequest.ts new file mode 100644 index 00000000..5e85cfb2 --- /dev/null +++ b/src/api/resources/alphaSections/client/requests/ListAlphaSectionsRequest.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface ListAlphaSectionsRequest { + /** Filter sections by language (BCP 47 tag). Repeatable. */ + lang?: string | string[]; + /** Filter sections by label. Repeatable; matches sections that have any of the given labels. */ + label?: string | string[]; + /** Filter by publish status. Omit to return both published and unpublished items; set to `true` for published only, `false` for unpublished only. */ + published?: boolean; +} diff --git a/src/api/resources/alphaSections/client/requests/UpdateSectionRequest.ts b/src/api/resources/alphaSections/client/requests/UpdateSectionRequest.ts new file mode 100644 index 00000000..9e5d0e59 --- /dev/null +++ b/src/api/resources/alphaSections/client/requests/UpdateSectionRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface UpdateSectionRequest { + name?: string; + language?: string; + description?: string; + labels?: string[]; +} diff --git a/src/api/resources/alphaSections/client/requests/index.ts b/src/api/resources/alphaSections/client/requests/index.ts new file mode 100644 index 00000000..6b22aa06 --- /dev/null +++ b/src/api/resources/alphaSections/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { ListAlphaSectionsRequest } from "./ListAlphaSectionsRequest.js"; +export type { UpdateSectionRequest } from "./UpdateSectionRequest.js"; diff --git a/src/api/resources/alphaSections/index.ts b/src/api/resources/alphaSections/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/alphaSections/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/alphaTemplateVersions/client/Client.ts b/src/api/resources/alphaTemplateVersions/client/Client.ts new file mode 100644 index 00000000..e7522771 --- /dev/null +++ b/src/api/resources/alphaTemplateVersions/client/Client.ts @@ -0,0 +1,426 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as serializers from "../../../../serialization/index.js"; +import * as Corti from "../../../index.js"; + +export declare namespace AlphaTemplateVersionsClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class AlphaTemplateVersionsClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: AlphaTemplateVersionsClient.Options) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * @param {string} templateID + * @param {AlphaTemplateVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplateVersions.list("templateID") + */ + public list( + templateID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(templateID, requestOptions)); + } + + private async __list( + templateID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}/versions/`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.alphaTemplateVersions.list.Response.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/alpha/templates/{templateID}/versions/", + ); + } + + /** + * @param {string} templateID + * @param {Corti.CreateTemplateVersionRequest} request + * @param {AlphaTemplateVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.BadRequestError} + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplateVersions.create("templateID", { + * generation: { + * instructions: { + * prompt: "prompt" + * } + * } + * }) + */ + public create( + templateID: string, + request: Corti.CreateTemplateVersionRequest, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(templateID, request, requestOptions)); + } + + private async __create( + templateID: string, + request: Corti.CreateTemplateVersionRequest, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}/versions/`, + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: serializers.CreateTemplateVersionRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + omitUndefined: true, + }), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.TemplateVersion.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Corti.BadRequestError(_response.error.body, _response.rawResponse); + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/alpha/templates/{templateID}/versions/", + ); + } + + /** + * @param {string} templateID + * @param {string} versionID + * @param {AlphaTemplateVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplateVersions.get("templateID", "versionID") + */ + public get( + templateID: string, + versionID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(templateID, versionID, requestOptions)); + } + + private async __get( + templateID: string, + versionID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}/versions/${core.url.encodePathParam(versionID)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.TemplateVersion.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "GET", + "/alpha/templates/{templateID}/versions/{versionID}", + ); + } + + /** + * A published version cannot be deleted. When deleting a last remaining version of a template, simply create a new version again if needed. + * + * @param {string} templateID + * @param {string} versionID + * @param {AlphaTemplateVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplateVersions.delete("templateID", "versionID") + */ + public delete( + templateID: string, + versionID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(templateID, versionID, requestOptions)); + } + + private async __delete( + templateID: string, + versionID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}/versions/${core.url.encodePathParam(versionID)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/alpha/templates/{templateID}/versions/{versionID}", + ); + } + + /** + * Sets this version as the published version of the template. + * + * @param {string} templateID + * @param {string} versionID + * @param {AlphaTemplateVersionsClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplateVersions.publish("templateID", "versionID") + */ + public publish( + templateID: string, + versionID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__publish(templateID, versionID, requestOptions)); + } + + private async __publish( + templateID: string, + versionID: string, + requestOptions?: AlphaTemplateVersionsClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}/versions/${core.url.encodePathParam(versionID)}/publish`, + ), + method: "POST", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.StatusResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "POST", + "/alpha/templates/{templateID}/versions/{versionID}/publish", + ); + } +} diff --git a/src/api/resources/alphaTemplateVersions/client/index.ts b/src/api/resources/alphaTemplateVersions/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/alphaTemplateVersions/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/alphaTemplateVersions/client/requests/CreateTemplateVersionRequest.ts b/src/api/resources/alphaTemplateVersions/client/requests/CreateTemplateVersionRequest.ts new file mode 100644 index 00000000..66255820 --- /dev/null +++ b/src/api/resources/alphaTemplateVersions/client/requests/CreateTemplateVersionRequest.ts @@ -0,0 +1,17 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../index.js"; + +/** + * @example + * { + * generation: { + * instructions: { + * prompt: "prompt" + * } + * } + * } + */ +export interface CreateTemplateVersionRequest { + generation: Corti.CreateTemplateVersionRequestGeneration; +} diff --git a/src/api/resources/alphaTemplateVersions/client/requests/index.ts b/src/api/resources/alphaTemplateVersions/client/requests/index.ts new file mode 100644 index 00000000..3d35d2f7 --- /dev/null +++ b/src/api/resources/alphaTemplateVersions/client/requests/index.ts @@ -0,0 +1 @@ +export type { CreateTemplateVersionRequest } from "./CreateTemplateVersionRequest.js"; diff --git a/src/api/resources/alphaTemplateVersions/index.ts b/src/api/resources/alphaTemplateVersions/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/api/resources/alphaTemplateVersions/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/api/resources/alphaTemplateVersions/types/CreateTemplateVersionRequestGeneration.ts b/src/api/resources/alphaTemplateVersions/types/CreateTemplateVersionRequestGeneration.ts new file mode 100644 index 00000000..ae309433 --- /dev/null +++ b/src/api/resources/alphaTemplateVersions/types/CreateTemplateVersionRequestGeneration.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../index.js"; + +export interface CreateTemplateVersionRequestGeneration { + instructions: Corti.TemplateInstructions; + sections?: Corti.TemplateVersionSectionRequest[]; +} diff --git a/src/api/resources/alphaTemplateVersions/types/index.ts b/src/api/resources/alphaTemplateVersions/types/index.ts new file mode 100644 index 00000000..78af3000 --- /dev/null +++ b/src/api/resources/alphaTemplateVersions/types/index.ts @@ -0,0 +1 @@ +export * from "./CreateTemplateVersionRequestGeneration.js"; diff --git a/src/api/resources/alphaTemplates/client/Client.ts b/src/api/resources/alphaTemplates/client/Client.ts new file mode 100644 index 00000000..e2dc8271 --- /dev/null +++ b/src/api/resources/alphaTemplates/client/Client.ts @@ -0,0 +1,407 @@ +// This file was auto-generated by Fern from our API Definition. + +import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js"; +import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "../../../../BaseClient.js"; +import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.js"; +import * as core from "../../../../core/index.js"; +import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js"; +import * as errors from "../../../../errors/index.js"; +import * as serializers from "../../../../serialization/index.js"; +import * as Corti from "../../../index.js"; + +export declare namespace AlphaTemplatesClient { + export type Options = BaseClientOptions; + + export interface RequestOptions extends BaseRequestOptions {} +} + +export class AlphaTemplatesClient { + protected readonly _options: NormalizedClientOptionsWithAuth; + + constructor(options: AlphaTemplatesClient.Options) { + this._options = normalizeClientOptionsWithAuth(options); + } + + /** + * @param {Corti.ListAlphaTemplatesRequest} request + * @param {AlphaTemplatesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @example + * await client.alphaTemplates.list() + */ + public list( + request: Corti.ListAlphaTemplatesRequest = {}, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__list(request, requestOptions)); + } + + private async __list( + request: Corti.ListAlphaTemplatesRequest = {}, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): Promise> { + const { lang, label, published } = request; + const _queryParams: Record = { + lang, + label, + published, + }; + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + "alpha/templates/", + ), + method: "GET", + headers: _headers, + queryParameters: { ..._queryParams, ...requestOptions?.queryParams }, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.alphaTemplates.list.Response.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/alpha/templates/"); + } + + /** + * @param {Corti.CreateTemplateRequest} request + * @param {AlphaTemplatesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.BadRequestError} + * + * @example + * await client.alphaTemplates.create({ + * name: "name", + * language: "language", + * generation: { + * instructions: { + * prompt: "prompt" + * } + * } + * }) + */ + public create( + request: Corti.CreateTemplateRequest, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions)); + } + + private async __create( + request: Corti.CreateTemplateRequest, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + "alpha/templates/", + ), + method: "POST", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: serializers.CreateTemplateRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + omitUndefined: true, + }), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.Template.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Corti.BadRequestError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/alpha/templates/"); + } + + /** + * @param {string} templateID + * @param {AlphaTemplatesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplates.get("templateID") + */ + public get( + templateID: string, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__get(templateID, requestOptions)); + } + + private async __get( + templateID: string, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}`, + ), + method: "GET", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.Template.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/alpha/templates/{templateID}"); + } + + /** + * Deletes a template and its versions. + * + * @param {string} templateID + * @param {AlphaTemplatesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplates.delete("templateID") + */ + public delete( + templateID: string, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__delete(templateID, requestOptions)); + } + + private async __delete( + templateID: string, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}`, + ), + method: "DELETE", + headers: _headers, + queryParameters: requestOptions?.queryParams, + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { data: undefined, rawResponse: _response.rawResponse }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "DELETE", + "/alpha/templates/{templateID}", + ); + } + + /** + * @param {string} templateID + * @param {Corti.UpdateTemplateRequest} request + * @param {AlphaTemplatesClient.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link Corti.BadRequestError} + * @throws {@link Corti.NotFoundError} + * + * @example + * await client.alphaTemplates.update("templateID") + */ + public update( + templateID: string, + request: Corti.UpdateTemplateRequest = {}, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): core.HttpResponsePromise { + return core.HttpResponsePromise.fromPromise(this.__update(templateID, request, requestOptions)); + } + + private async __update( + templateID: string, + request: Corti.UpdateTemplateRequest = {}, + requestOptions?: AlphaTemplatesClient.RequestOptions, + ): Promise> { + const _authRequest: core.AuthRequest = await this._options.authProvider.getAuthRequest(); + const _headers: core.Fetcher.Args["headers"] = mergeHeaders( + _authRequest.headers, + this._options?.headers, + mergeOnlyDefinedHeaders({ "Tenant-Name": requestOptions?.tenantName ?? this._options?.tenantName }), + requestOptions?.headers, + ); + const _response = await core.fetcher({ + url: core.url.join( + (await core.Supplier.get(this._options.baseUrl)) ?? + (await core.Supplier.get(this._options.environment)).base, + `alpha/templates/${core.url.encodePathParam(templateID)}`, + ), + method: "PATCH", + headers: _headers, + contentType: "application/json", + queryParameters: requestOptions?.queryParams, + requestType: "json", + body: serializers.UpdateTemplateRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + omitUndefined: true, + }), + timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000, + maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries, + abortSignal: requestOptions?.abortSignal, + fetchFn: this._options?.fetch, + logging: this._options.logging, + }); + if (_response.ok) { + return { + data: serializers.Template.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }), + rawResponse: _response.rawResponse, + }; + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 400: + throw new Corti.BadRequestError(_response.error.body, _response.rawResponse); + case 404: + throw new Corti.NotFoundError(_response.error.body, _response.rawResponse); + default: + throw new errors.CortiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + rawResponse: _response.rawResponse, + }); + } + } + + return handleNonStatusCodeError( + _response.error, + _response.rawResponse, + "PATCH", + "/alpha/templates/{templateID}", + ); + } +} diff --git a/src/api/resources/alphaTemplates/client/index.ts b/src/api/resources/alphaTemplates/client/index.ts new file mode 100644 index 00000000..195f9aa8 --- /dev/null +++ b/src/api/resources/alphaTemplates/client/index.ts @@ -0,0 +1 @@ +export * from "./requests/index.js"; diff --git a/src/api/resources/alphaTemplates/client/requests/ListAlphaTemplatesRequest.ts b/src/api/resources/alphaTemplates/client/requests/ListAlphaTemplatesRequest.ts new file mode 100644 index 00000000..dc955c4e --- /dev/null +++ b/src/api/resources/alphaTemplates/client/requests/ListAlphaTemplatesRequest.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface ListAlphaTemplatesRequest { + /** Filter templates by language (BCP 47 tag). Repeatable. */ + lang?: string | string[]; + /** Filter templates by label. Repeatable; matches templates that have any of the given labels. */ + label?: string | string[]; + /** Filter by publish status. Omit to return both published and unpublished items; set to `true` for published only, `false` for unpublished only. */ + published?: boolean; +} diff --git a/src/api/resources/alphaTemplates/client/requests/UpdateTemplateRequest.ts b/src/api/resources/alphaTemplates/client/requests/UpdateTemplateRequest.ts new file mode 100644 index 00000000..0ab19a77 --- /dev/null +++ b/src/api/resources/alphaTemplates/client/requests/UpdateTemplateRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * @example + * {} + */ +export interface UpdateTemplateRequest { + name?: string; + description?: string; + language?: string; + labels?: string[]; +} diff --git a/src/api/resources/alphaTemplates/client/requests/index.ts b/src/api/resources/alphaTemplates/client/requests/index.ts new file mode 100644 index 00000000..010e202a --- /dev/null +++ b/src/api/resources/alphaTemplates/client/requests/index.ts @@ -0,0 +1,2 @@ +export type { ListAlphaTemplatesRequest } from "./ListAlphaTemplatesRequest.js"; +export type { UpdateTemplateRequest } from "./UpdateTemplateRequest.js"; diff --git a/src/api/resources/alphaTemplates/index.ts b/src/api/resources/alphaTemplates/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/api/resources/alphaTemplates/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 018dfdfd..945f42fe 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -1,6 +1,15 @@ export * from "./agents/client/requests/index.js"; export * as agents from "./agents/index.js"; export * from "./agents/types/index.js"; +export * as alphaDocuments from "./alphaDocuments/index.js"; +export * from "./alphaSections/client/requests/index.js"; +export * as alphaSections from "./alphaSections/index.js"; +export * as alphaSectionVersions from "./alphaSectionVersions/index.js"; +export * from "./alphaTemplates/client/requests/index.js"; +export * as alphaTemplates from "./alphaTemplates/index.js"; +export * from "./alphaTemplateVersions/client/requests/index.js"; +export * as alphaTemplateVersions from "./alphaTemplateVersions/index.js"; +export * from "./alphaTemplateVersions/types/index.js"; export * as auth from "./auth/index.js"; export * from "./auth/types/index.js"; export * from "./codes/client/requests/index.js"; diff --git a/src/api/types/AgentsCreateExpertReference.ts b/src/api/types/AgentsCreateExpertReference.ts index 733a6184..faa939f2 100644 --- a/src/api/types/AgentsCreateExpertReference.ts +++ b/src/api/types/AgentsCreateExpertReference.ts @@ -13,4 +13,6 @@ export interface AgentsCreateExpertReference { name?: string; /** Optional. Additional system instructions appended to the default system prompt when creating an expert from the registry, extending the expert's behavior. */ systemPrompt?: string; + /** Optional configuration override for the registry expert. Values provided here are deep-merged with the schema defaults declared on the registry expert and validated against its `configSchema`. Ignored when the registry expert has no schema. */ + config?: Record; } diff --git a/src/api/types/AgentsErrorResponse.ts b/src/api/types/AgentsErrorResponse.ts deleted file mode 100644 index f75ff873..00000000 --- a/src/api/types/AgentsErrorResponse.ts +++ /dev/null @@ -1,14 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface AgentsErrorResponse { - /** A machine-readable error code that identifies the type of error. */ - code: string; - /** A human-readable description of the error, providing more context about what went wrong. */ - description: string; - /** A human-readable message describing how to fix the issue. */ - howToFix?: string; - /** An optional object containing additional details about the error. */ - details?: Record; - /** An optional object containing the cause of the error, following the same structure as the parent error response. */ - cause?: Record; -} diff --git a/src/api/types/AgentsExpertReference.ts b/src/api/types/AgentsExpertReference.ts index c5d5dd72..09c21b14 100644 --- a/src/api/types/AgentsExpertReference.ts +++ b/src/api/types/AgentsExpertReference.ts @@ -13,4 +13,6 @@ export interface AgentsExpertReference { name: string; /** Optional. Additional system instructions appended to the default system prompt when creating an expert from the registry, extending the expert's behavior. */ systemPrompt?: string; + /** The fully resolved configuration for this expert: schema defaults from the registry expert deep-merged with any `config` override supplied at creation. Present only when the source registry expert defined a `configSchema`. */ + resolvedConfig?: Record; } diff --git a/src/api/types/AgentsRegistryExpert.ts b/src/api/types/AgentsRegistryExpert.ts index ef98affa..6bb800f1 100644 --- a/src/api/types/AgentsRegistryExpert.ts +++ b/src/api/types/AgentsRegistryExpert.ts @@ -13,4 +13,6 @@ export interface AgentsRegistryExpert { description: string; /** A list of MCP servers the expert can call, including their authorization types. */ mcpServers?: Corti.AgentsRegistryMcpServer[]; + /** Optional JSON Schema describing the configuration this expert accepts. When present, callers may supply a matching `config` object on `AgentsCreateExpertReference`; values are deep-merged with schema defaults and validated against this schema. */ + configSchema?: Record; } diff --git a/src/api/types/AgentsValidationError.ts b/src/api/types/AgentsValidationError.ts deleted file mode 100644 index 615b2225..00000000 --- a/src/api/types/AgentsValidationError.ts +++ /dev/null @@ -1,11 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Corti from "../index.js"; - -export interface AgentsValidationError { - msg: string; - type: string; - reason: string; - howToFix: string; - errors?: Corti.AgentsValidationErrorErrorsItem[]; -} diff --git a/src/api/types/AgentsValidationErrorErrorsItem.ts b/src/api/types/AgentsValidationErrorErrorsItem.ts deleted file mode 100644 index cd20e80c..00000000 --- a/src/api/types/AgentsValidationErrorErrorsItem.ts +++ /dev/null @@ -1,6 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -export interface AgentsValidationErrorErrorsItem { - location?: string; - reason?: string; -} diff --git a/src/api/types/AgentsValidationErrorResponse.ts b/src/api/types/AgentsValidationErrorResponse.ts deleted file mode 100644 index b7c94f27..00000000 --- a/src/api/types/AgentsValidationErrorResponse.ts +++ /dev/null @@ -1,7 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Corti from "../index.js"; - -export interface AgentsValidationErrorResponse extends Corti.AgentsErrorResponse { - detail?: Corti.AgentsValidationError[]; -} diff --git a/src/api/types/ArrayNode.ts b/src/api/types/ArrayNode.ts new file mode 100644 index 00000000..cddff8a6 --- /dev/null +++ b/src/api/types/ArrayNode.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface ArrayNode { + type: "array"; + /** Can be used to prompt the LLM with more guidance in addition to the section.instructions */ + description?: string; + items: Corti.OutputSchema; + /** Controls how each array item is rendered in the generated output. Use `bullet` (default), `numbered`, or `plain`, or provide a custom format string containing the `{item}` placeholder. */ + itemFormat?: string; + /** Minimum number of array items to generate. */ + minItems?: number | null; + /** Maximum number of array items to generate. */ + maxItems?: number | null; +} diff --git a/src/api/types/BoolNode.ts b/src/api/types/BoolNode.ts new file mode 100644 index 00000000..9d9d69eb --- /dev/null +++ b/src/api/types/BoolNode.ts @@ -0,0 +1,9 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface BoolNode { + type: "boolean"; + /** Can be used to prompt the LLM with more guidance in addition to the section.instructions */ + description?: string; + /** The default to output if nothing to output. */ + default?: boolean | null; +} diff --git a/src/api/types/CreateSectionBase.ts b/src/api/types/CreateSectionBase.ts new file mode 100644 index 00000000..42104bbf --- /dev/null +++ b/src/api/types/CreateSectionBase.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface CreateSectionBase { + /** A human-readable identifier for this section. Not passed to the LLM. */ + name: string; + /** The intended language for outputs as BCP 47 tag. Informational metadata only. The final output language is determined by outputLanguage in the POST /documents request. */ + language: string; + /** A description for this section. Not passed to the LLM. */ + description?: string; + /** Labels work as query param filter in the LIST /sections endpoint. */ + labels?: string[]; + /** Defaults to true when omitted. Set this to false if you do not want the section to automatically show up in LIST /sections. */ + publish?: boolean; +} diff --git a/src/api/types/CreateSectionFromInheritanceRequest.ts b/src/api/types/CreateSectionFromInheritanceRequest.ts new file mode 100644 index 00000000..1a5e0e71 --- /dev/null +++ b/src/api/types/CreateSectionFromInheritanceRequest.ts @@ -0,0 +1,12 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +/** + * Creates a section that inherits from another section. Any fields omitted in `generation` are inherited from the referenced section's published version; any fields provided override the inherited values. + */ +export interface CreateSectionFromInheritanceRequest extends Corti.CreateSectionBase { + /** Reference to the section to inherit generation configuration from. Inherits from the published version of the referenced section. */ + inheritFromId: string; + generation: Corti.SectionGenerationPartial; +} diff --git a/src/api/types/CreateSectionFromScratchRequest.ts b/src/api/types/CreateSectionFromScratchRequest.ts new file mode 100644 index 00000000..dcc2c5f2 --- /dev/null +++ b/src/api/types/CreateSectionFromScratchRequest.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +/** + * Creates a section from scratch with an explicit generation configuration. All required fields on `generation` apply. + */ +export interface CreateSectionFromScratchRequest extends Corti.CreateSectionBase { + generation: Corti.SectionGeneration; +} diff --git a/src/api/types/CreateSectionRequest.ts b/src/api/types/CreateSectionRequest.ts new file mode 100644 index 00000000..456c3459 --- /dev/null +++ b/src/api/types/CreateSectionRequest.ts @@ -0,0 +1,5 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export type CreateSectionRequest = Corti.CreateSectionFromScratchRequest | Corti.CreateSectionFromInheritanceRequest; diff --git a/src/api/types/CreateTemplateBase.ts b/src/api/types/CreateTemplateBase.ts new file mode 100644 index 00000000..40c32884 --- /dev/null +++ b/src/api/types/CreateTemplateBase.ts @@ -0,0 +1,14 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface CreateTemplateBase { + /** The name of this template. Not passed to the LLM. */ + name: string; + /** A description for this template. Not passed to the LLM. */ + description?: string; + /** The intended language for outputs as BCP 47 tag. Informational metadata only. The final output language is determined by outputLanguage in the POST /documents request. */ + language: string; + /** Labels work as query param filter in the LIST /templates endpoint. */ + labels?: string[]; + /** Defaults to true when omitted. Set this to false if you do not want the template to automatically show up in LIST templates. */ + publish?: boolean; +} diff --git a/src/api/types/CreateTemplateFromInheritanceRequest.ts b/src/api/types/CreateTemplateFromInheritanceRequest.ts new file mode 100644 index 00000000..24cfafa0 --- /dev/null +++ b/src/api/types/CreateTemplateFromInheritanceRequest.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +/** + * Creates a template that inherits from another template. Any fields omitted in `generation` are inherited from the referenced template's published version; any fields provided override the inherited values. + */ +export interface CreateTemplateFromInheritanceRequest extends Corti.CreateTemplateBase { + /** Reference to the template to inherit template instructions and sections from. Inherits from the published version of the referenced template. */ + inheritFromId: string; + /** Partial overrides applied on top of the inherited template. All inner fields are optional. Any field omitted is inherited from the referenced template. */ + generation: Corti.CreateTemplateFromInheritanceRequestGeneration; +} diff --git a/src/api/types/CreateTemplateFromInheritanceRequestGeneration.ts b/src/api/types/CreateTemplateFromInheritanceRequestGeneration.ts new file mode 100644 index 00000000..dea4c1b7 --- /dev/null +++ b/src/api/types/CreateTemplateFromInheritanceRequestGeneration.ts @@ -0,0 +1,11 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +/** + * Partial overrides applied on top of the inherited template. All inner fields are optional. Any field omitted is inherited from the referenced template. + */ +export interface CreateTemplateFromInheritanceRequestGeneration { + instructions?: Corti.TemplateInstructionsPartial; + sections?: Corti.TemplateVersionSectionRequest[]; +} diff --git a/src/api/types/CreateTemplateFromScratchRequest.ts b/src/api/types/CreateTemplateFromScratchRequest.ts new file mode 100644 index 00000000..d50ab930 --- /dev/null +++ b/src/api/types/CreateTemplateFromScratchRequest.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +/** + * Creates a template from scratch. `generation.instructions` is required and the template fully specifies its own instructions and sections. + */ +export interface CreateTemplateFromScratchRequest extends Corti.CreateTemplateBase { + generation: Corti.CreateTemplateFromScratchRequestGeneration; +} diff --git a/src/api/types/CreateTemplateFromScratchRequestGeneration.ts b/src/api/types/CreateTemplateFromScratchRequestGeneration.ts new file mode 100644 index 00000000..bf84ccbd --- /dev/null +++ b/src/api/types/CreateTemplateFromScratchRequestGeneration.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface CreateTemplateFromScratchRequestGeneration { + instructions: Corti.TemplateInstructions; + sections?: Corti.TemplateVersionSectionRequest[]; +} diff --git a/src/api/types/CreateTemplateRequest.ts b/src/api/types/CreateTemplateRequest.ts new file mode 100644 index 00000000..7d709365 --- /dev/null +++ b/src/api/types/CreateTemplateRequest.ts @@ -0,0 +1,5 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export type CreateTemplateRequest = Corti.CreateTemplateFromScratchRequest | Corti.CreateTemplateFromInheritanceRequest; diff --git a/src/api/types/FieldDefinition.ts b/src/api/types/FieldDefinition.ts new file mode 100644 index 00000000..0bf1e301 --- /dev/null +++ b/src/api/types/FieldDefinition.ts @@ -0,0 +1,11 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface FieldDefinition { + /** Use to set a key to reference. */ + key: string; + /** Can be used to prompt the LLM with more guidance in addition to the section.instructions */ + description: string; + value: Corti.OutputSchema; +} diff --git a/src/api/types/NumberNode.ts b/src/api/types/NumberNode.ts new file mode 100644 index 00000000..553e4038 --- /dev/null +++ b/src/api/types/NumberNode.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface NumberNode { + type: "number"; + /** Can be used to prompt the LLM with more guidance in addition to the section.instructions */ + description?: string; + /** The default to output if nothing to output. */ + default?: number | null; + /** Can be used to prompt the LLM for specifically allowed numeric values to output. */ + enum?: number[]; + /** Use if a minimum value applies. */ + minimum?: number | null; + /** Use if a maximum value applies. */ + maximum?: number | null; +} diff --git a/src/api/types/ObjectNode.ts b/src/api/types/ObjectNode.ts new file mode 100644 index 00000000..99d070f9 --- /dev/null +++ b/src/api/types/ObjectNode.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface ObjectNode { + type: "object"; + /** Can be used to prompt the LLM with more guidance in addition to the section.instructions */ + description?: string; + /** Controls how subheadings are rendered in the generated output. Use `inline` (default) for `{key}: {value}\n` or `block` for `{key}\n{value}\n`, or provide a custom format string containing both `{key}` and `{value}` placeholders. Mutually exclusive with `objectFormat`. */ + subheadingFormat?: string; + /** A format string referencing field keys as placeholders (e.g. `{fieldKey}`). All placeholders must correspond to defined field keys. Mutually exclusive with `subheadingFormat`. */ + objectFormat?: string; + /** Define what fields are possible to return in the object. */ + fields?: Corti.FieldDefinition[]; +} diff --git a/src/api/types/OutputSchema.ts b/src/api/types/OutputSchema.ts new file mode 100644 index 00000000..57e6832d --- /dev/null +++ b/src/api/types/OutputSchema.ts @@ -0,0 +1,5 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export type OutputSchema = Corti.StringNode | Corti.NumberNode | Corti.BoolNode | Corti.ObjectNode | Corti.ArrayNode; diff --git a/src/api/types/Section.ts b/src/api/types/Section.ts new file mode 100644 index 00000000..842d201b --- /dev/null +++ b/src/api/types/Section.ts @@ -0,0 +1,26 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface Section { + /** The UUID of the section. */ + id: string; + /** Reference to the section to inherit generation configuration from. Inherits from published version by default. */ + inheritedFromId?: string | null; + /** True if the section was auto-generated as part of an inline section-composed POST /documents request. */ + autoGenerated?: boolean; + /** The name of the section. */ + name: string; + /** The intended language for outputs as BCP 47 tag. */ + language: string; + /** The description for the section. */ + description?: string; + /** The labels available to use as query param filter in the LIST /sections endpoint. */ + labels: string[]; + /** Shows the currently published version of this section. */ + publishedVersion?: Corti.SectionVersion; + /** The original timestamp when the section was created. */ + createdAt: Date; + /** The original timestamp when the section was last updated. */ + updatedAt: Date; +} diff --git a/src/api/types/SectionGeneration.ts b/src/api/types/SectionGeneration.ts new file mode 100644 index 00000000..54a16083 --- /dev/null +++ b/src/api/types/SectionGeneration.ts @@ -0,0 +1,11 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface SectionGeneration { + /** The heading of this section. Passed to the LLM. */ + heading: string; + /** The prompt instructions for this section. */ + instructions: Corti.SectionInstructions; + outputSchema: Corti.OutputSchema; +} diff --git a/src/api/types/SectionGenerationPartial.ts b/src/api/types/SectionGenerationPartial.ts new file mode 100644 index 00000000..968c6f0c --- /dev/null +++ b/src/api/types/SectionGenerationPartial.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +/** + * Partial form of SectionGeneration used when inheriting from another section. Any field omitted is inherited from the referenced section. + */ +export interface SectionGenerationPartial { + /** Override the inherited section title. Passed to the LLM. */ + heading?: string; + /** Override the inherited prompt instructions for this section. Any field omitted is inherited. */ + instructions?: Corti.SectionInstructionsPartial; + /** Override the inherited output schema. */ + outputSchema?: Corti.OutputSchema; +} diff --git a/src/api/types/SectionInstructions.ts b/src/api/types/SectionInstructions.ts new file mode 100644 index 00000000..2ce814e5 --- /dev/null +++ b/src/api/types/SectionInstructions.ts @@ -0,0 +1,10 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface SectionInstructions { + /** The content prompt instructs the model what to include for synthesis. For `documentationMode: routed_parallel` this impacts what facts to route to this section. */ + contentPrompt: string; + /** The writingStyle prompt instructs the model in what tone and style to output. */ + writingStylePrompt?: string; + /** Optional free-form prompt for any instructions that don't fit contentPrompt or writingStylePrompt. */ + miscPrompt?: string; +} diff --git a/src/api/types/SectionInstructionsPartial.ts b/src/api/types/SectionInstructionsPartial.ts new file mode 100644 index 00000000..e4809f70 --- /dev/null +++ b/src/api/types/SectionInstructionsPartial.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Partial form of SectionInstructions used when inheriting from another section. Any field omitted is inherited. + */ +export interface SectionInstructionsPartial { + /** Override the inherited content prompt. */ + contentPrompt?: string; + /** Override the inherited writing style prompt. */ + writingStylePrompt?: string; + /** Override the inherited misc prompt. */ + miscPrompt?: string; +} diff --git a/src/api/types/SectionVersion.ts b/src/api/types/SectionVersion.ts new file mode 100644 index 00000000..fe3c6b68 --- /dev/null +++ b/src/api/types/SectionVersion.ts @@ -0,0 +1,11 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface SectionVersion { + /** The UUID of the section version. */ + id: string; + /** Starts at 0 and auto-increments. */ + versionNumber: number; + generation: Corti.SectionGeneration; +} diff --git a/src/api/types/StatusResponse.ts b/src/api/types/StatusResponse.ts new file mode 100644 index 00000000..15ca5217 --- /dev/null +++ b/src/api/types/StatusResponse.ts @@ -0,0 +1,5 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface StatusResponse { + status: string; +} diff --git a/src/api/types/StringNode.ts b/src/api/types/StringNode.ts new file mode 100644 index 00000000..5571866e --- /dev/null +++ b/src/api/types/StringNode.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface StringNode { + type: "string"; + /** Can be used to prompt the LLM with more guidance in addition to the section.instructions */ + description?: string; + /** The default to output if nothing to output. */ + default?: string | null; + /** Can be used to prompt the LLM with specific values to output. */ + enum?: string[]; + /** Can be used to prompt the LLM for a specific output pattern. */ + pattern?: string | null; +} diff --git a/src/api/types/Template.ts b/src/api/types/Template.ts new file mode 100644 index 00000000..515ea47d --- /dev/null +++ b/src/api/types/Template.ts @@ -0,0 +1,25 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface Template { + /** The UUID of the template. */ + id: string; + /** Reference to the template to inherit template instructions and sections from. Inherits from published version by default. */ + inheritedFromId?: string | null; + /** True if the template was auto-generated based on the section-composed POST /documents request. */ + autoGenerated?: boolean; + /** The name of this template. Not passed to the LLM. */ + name: string; + /** A description for this template. Not passed to the LLM. */ + description?: string; + /** The intended language as BCP 47 tag. Informational metadata only. The final output language is determined by outputLanguage in the POST /documents request. */ + language: string; + /** The available labels to use as query param filter in the LIST /templates endpoint. */ + labels: string[]; + publishedVersion?: Corti.TemplateVersion; + /** The original timestamp when the template was created. */ + createdAt: Date; + /** The original timestamp when the template was last updated. */ + updatedAt: Date; +} diff --git a/src/api/types/TemplateGeneration.ts b/src/api/types/TemplateGeneration.ts new file mode 100644 index 00000000..ab962c41 --- /dev/null +++ b/src/api/types/TemplateGeneration.ts @@ -0,0 +1,9 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface TemplateGeneration { + instructions: Corti.TemplateInstructions; + /** Populated only on GET /alpha/templates/{templateID}/versions/{versionID}; omitted from list responses. */ + sections?: Corti.Section[]; +} diff --git a/src/api/types/TemplateInstructions.ts b/src/api/types/TemplateInstructions.ts new file mode 100644 index 00000000..c72499a1 --- /dev/null +++ b/src/api/types/TemplateInstructions.ts @@ -0,0 +1,6 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface TemplateInstructions { + /** Template-level prompt instructions that apply generally to all sections. */ + prompt: string; +} diff --git a/src/api/types/TemplateInstructionsPartial.ts b/src/api/types/TemplateInstructionsPartial.ts new file mode 100644 index 00000000..4335cb78 --- /dev/null +++ b/src/api/types/TemplateInstructionsPartial.ts @@ -0,0 +1,9 @@ +// This file was auto-generated by Fern from our API Definition. + +/** + * Partial form of TemplateInstructions used when inheriting from another template. Any field omitted is inherited. + */ +export interface TemplateInstructionsPartial { + /** Override the inherited template-level prompt instructions. */ + prompt?: string; +} diff --git a/src/api/types/TemplateVersion.ts b/src/api/types/TemplateVersion.ts new file mode 100644 index 00000000..94e72fb7 --- /dev/null +++ b/src/api/types/TemplateVersion.ts @@ -0,0 +1,11 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../index.js"; + +export interface TemplateVersion { + /** The UUID of the version. */ + id: string; + /** Starts at 0 and auto-increments. */ + versionNumber: number; + generation: Corti.TemplateGeneration; +} diff --git a/src/api/types/TemplateVersionSectionRequest.ts b/src/api/types/TemplateVersionSectionRequest.ts new file mode 100644 index 00000000..ac0d2ba0 --- /dev/null +++ b/src/api/types/TemplateVersionSectionRequest.ts @@ -0,0 +1,8 @@ +// This file was auto-generated by Fern from our API Definition. + +export interface TemplateVersionSectionRequest { + /** The UUID of the section to include in the template version. */ + sectionId: string; + /** Sets the order of this section within this template. Starts at 0. */ + orderIndex?: number; +} diff --git a/src/api/types/index.ts b/src/api/types/index.ts index 66b9b853..7770f431 100644 --- a/src/api/types/index.ts +++ b/src/api/types/index.ts @@ -22,7 +22,6 @@ export * from "./AgentsCreateMcpServerAuthorizationType.js"; export * from "./AgentsCreateMcpServerTransportType.js"; export * from "./AgentsDataPart.js"; export * from "./AgentsDataPartKind.js"; -export * from "./AgentsErrorResponse.js"; export * from "./AgentsExpert.js"; export * from "./AgentsExpertReference.js"; export * from "./AgentsExpertReferenceType.js"; @@ -53,15 +52,14 @@ export * from "./AgentsTaskStatusState.js"; export * from "./AgentsTextPart.js"; export * from "./AgentsTextPartKind.js"; export * from "./AgentsUpdateExpertReference.js"; -export * from "./AgentsValidationError.js"; -export * from "./AgentsValidationErrorErrorsItem.js"; -export * from "./AgentsValidationErrorResponse.js"; +export * from "./ArrayNode.js"; export * from "./AuthTokenRequestAuthorizationCode.js"; export * from "./AuthTokenRequestAuthorizationPkce.js"; export * from "./AuthTokenRequestClientCredentials.js"; export * from "./AuthTokenRequestRefresh.js"; export * from "./AuthTokenRequestRopc.js"; export * from "./AuthTokenResponse.js"; +export * from "./BoolNode.js"; export * from "./CodesFilter.js"; export * from "./CodesGeneralReadResponse.js"; export * from "./CodesGeneralReadResponseAlternativesItem.js"; @@ -78,6 +76,16 @@ export * from "./CommonTextContextType.js"; export * from "./CommonTranscriptRequest.js"; export * from "./CommonTranscriptResponse.js"; export * from "./CommonUsageInfo.js"; +export * from "./CreateSectionBase.js"; +export * from "./CreateSectionFromInheritanceRequest.js"; +export * from "./CreateSectionFromScratchRequest.js"; +export * from "./CreateSectionRequest.js"; +export * from "./CreateTemplateBase.js"; +export * from "./CreateTemplateFromInheritanceRequest.js"; +export * from "./CreateTemplateFromInheritanceRequestGeneration.js"; +export * from "./CreateTemplateFromScratchRequest.js"; +export * from "./CreateTemplateFromScratchRequestGeneration.js"; +export * from "./CreateTemplateRequest.js"; export * from "./DocumentsContext.js"; export * from "./DocumentsContextWithFacts.js"; export * from "./DocumentsContextWithFactsType.js"; @@ -113,6 +121,7 @@ export * from "./FactsFactGroupsListResponse.js"; export * from "./FactsListItem.js"; export * from "./FactsListResponse.js"; export * from "./FactsUpdateResponse.js"; +export * from "./FieldDefinition.js"; export * from "./InteractionsCreateResponse.js"; export * from "./InteractionsEncounterCreateRequest.js"; export * from "./InteractionsEncounterPeriod.js"; @@ -124,9 +133,19 @@ export * from "./InteractionsGenderEnum.js"; export * from "./InteractionsGetResponse.js"; export * from "./InteractionsListResponse.js"; export * from "./InteractionsPatient.js"; +export * from "./NumberNode.js"; export * from "./OAuthTokenRequest.js"; +export * from "./ObjectNode.js"; +export * from "./OutputSchema.js"; export * from "./RecordingsCreateResponse.js"; export * from "./RecordingsListResponse.js"; +export * from "./Section.js"; +export * from "./SectionGeneration.js"; +export * from "./SectionGenerationPartial.js"; +export * from "./SectionInstructions.js"; +export * from "./SectionInstructionsPartial.js"; +export * from "./SectionVersion.js"; +export * from "./StatusResponse.js"; export * from "./StreamConfig.js"; export * from "./StreamConfigMessage.js"; export * from "./StreamConfigMode.js"; @@ -152,6 +171,11 @@ export * from "./StreamTranscript.js"; export * from "./StreamTranscriptMessage.js"; export * from "./StreamTranscriptTime.js"; export * from "./StreamUsageMessage.js"; +export * from "./StringNode.js"; +export * from "./Template.js"; +export * from "./TemplateGeneration.js"; +export * from "./TemplateInstructions.js"; +export * from "./TemplateInstructionsPartial.js"; export * from "./TemplatesDocumentationModeEnum.js"; export * from "./TemplatesFormatRule.js"; export * from "./TemplatesItem.js"; @@ -162,6 +186,8 @@ export * from "./TemplatesSectionSorted.js"; export * from "./TemplatesSectionTranslation.js"; export * from "./TemplatesTranslation.js"; export * from "./TemplatesWritingStyle.js"; +export * from "./TemplateVersion.js"; +export * from "./TemplateVersionSectionRequest.js"; export * from "./TranscribeCommand.js"; export * from "./TranscribeCommandData.js"; export * from "./TranscribeCommandMessage.js"; diff --git a/src/custom/CortiClient.ts b/src/custom/CortiClient.ts index 31ab24bf..6ba6646c 100644 --- a/src/custom/CortiClient.ts +++ b/src/custom/CortiClient.ts @@ -112,7 +112,7 @@ export class CortiClient extends BaseCortiClient { return new Headers({ ...(req.headers ?? {}), - "Tenant-Name": await core.Supplier.get(this._options.tenantName), + "Tenant-Name": (await core.Supplier.get(this._options.tenantName)) ?? "", }); }; } diff --git a/src/custom/auth/CortiAuth.ts b/src/custom/auth/CortiAuth.ts index 84cf945a..8d610a0f 100644 --- a/src/custom/auth/CortiAuth.ts +++ b/src/custom/auth/CortiAuth.ts @@ -106,7 +106,7 @@ export declare namespace CortiAuth { } export class CortiAuth extends AuthClient { - private readonly _tenantName: core.Supplier; + private readonly _tenantName: core.Supplier; /** No-op auth provider so super.token() does not trigger OAuth refresh. When auth is omitted, a dummy token is passed so the base constructor does not throw. */ constructor(options: CortiAuth.Options) { @@ -162,7 +162,7 @@ export class CortiAuth extends AuthClient { const authRequest = buildTokenRequestBody(request); const tenantName = await core.Supplier.get(this._tenantName); - return this.token(tenantName, authRequest, requestOptions).withRawResponse(); + return this.token(tenantName ?? "base", authRequest, requestOptions).withRawResponse(); } /** Exchange username/password for access token via ROPC (resource owner password credentials). */ @@ -265,7 +265,7 @@ export class CortiAuth extends AuthClient { const envUrls = await core.Supplier.get(this._options.environment); const tenantName = await core.Supplier.get(this._tenantName); - const authUrl = new URL(core.url.join(envUrls.login, tenantName, "protocol/openid-connect/auth")); + const authUrl = new URL(core.url.join(envUrls.login, tenantName ?? "", "protocol/openid-connect/auth")); authUrl.searchParams.set("response_type", "code"); diff --git a/src/custom/stream/CustomStream.ts b/src/custom/stream/CustomStream.ts index 62e5c1f1..9b12d17c 100644 --- a/src/custom/stream/CustomStream.ts +++ b/src/custom/stream/CustomStream.ts @@ -63,7 +63,7 @@ export class CustomStream extends StreamClient { await super.connect({ ...rest, token: (await this._options.authProvider?.getAuthRequest())?.headers.Authorization || "", - tenantName: await core.Supplier.get(this._options.tenantName), + tenantName: (await core.Supplier.get(this._options.tenantName)) ?? "base", }) ).socket; diff --git a/src/custom/transcribe/CustomTranscribe.ts b/src/custom/transcribe/CustomTranscribe.ts index ce6d7909..69df2a3d 100644 --- a/src/custom/transcribe/CustomTranscribe.ts +++ b/src/custom/transcribe/CustomTranscribe.ts @@ -62,7 +62,7 @@ export class CustomTranscribe extends TranscribeClient { await super.connect({ ...rest, token: (await this._options.authProvider?.getAuthRequest())?.headers.Authorization || "", - tenantName: await core.Supplier.get(this._options.tenantName), + tenantName: (await core.Supplier.get(this._options.tenantName)) ?? "base", }) ).socket; diff --git a/src/serialization/resources/alphaSectionVersions/client/index.ts b/src/serialization/resources/alphaSectionVersions/client/index.ts new file mode 100644 index 00000000..b64f754c --- /dev/null +++ b/src/serialization/resources/alphaSectionVersions/client/index.ts @@ -0,0 +1 @@ +export * as list from "./list.js"; diff --git a/src/serialization/resources/alphaSectionVersions/client/list.ts b/src/serialization/resources/alphaSectionVersions/client/list.ts new file mode 100644 index 00000000..58ef6401 --- /dev/null +++ b/src/serialization/resources/alphaSectionVersions/client/list.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../api/index.js"; +import * as core from "../../../../core/index.js"; +import type * as serializers from "../../../index.js"; +import { SectionVersion } from "../../../types/SectionVersion.js"; + +export const Response: core.serialization.Schema< + serializers.alphaSectionVersions.list.Response.Raw, + Corti.SectionVersion[] +> = core.serialization.list(SectionVersion); + +export declare namespace Response { + export type Raw = SectionVersion.Raw[]; +} diff --git a/src/serialization/resources/alphaSectionVersions/index.ts b/src/serialization/resources/alphaSectionVersions/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/serialization/resources/alphaSectionVersions/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/serialization/resources/alphaSections/client/index.ts b/src/serialization/resources/alphaSections/client/index.ts new file mode 100644 index 00000000..cd155427 --- /dev/null +++ b/src/serialization/resources/alphaSections/client/index.ts @@ -0,0 +1,2 @@ +export * as list from "./list.js"; +export * from "./requests/index.js"; diff --git a/src/serialization/resources/alphaSections/client/list.ts b/src/serialization/resources/alphaSections/client/list.ts new file mode 100644 index 00000000..d1f360b6 --- /dev/null +++ b/src/serialization/resources/alphaSections/client/list.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../api/index.js"; +import * as core from "../../../../core/index.js"; +import type * as serializers from "../../../index.js"; +import { Section } from "../../../types/Section.js"; + +export const Response: core.serialization.Schema = + core.serialization.list(Section); + +export declare namespace Response { + export type Raw = Section.Raw[]; +} diff --git a/src/serialization/resources/alphaSections/client/requests/UpdateSectionRequest.ts b/src/serialization/resources/alphaSections/client/requests/UpdateSectionRequest.ts new file mode 100644 index 00000000..2eb7957e --- /dev/null +++ b/src/serialization/resources/alphaSections/client/requests/UpdateSectionRequest.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../../api/index.js"; +import * as core from "../../../../../core/index.js"; +import type * as serializers from "../../../../index.js"; + +export const UpdateSectionRequest: core.serialization.Schema< + serializers.UpdateSectionRequest.Raw, + Corti.UpdateSectionRequest +> = core.serialization.object({ + name: core.serialization.string().optional(), + language: core.serialization.string().optional(), + description: core.serialization.string().optional(), + labels: core.serialization.list(core.serialization.string()).optional(), +}); + +export declare namespace UpdateSectionRequest { + export interface Raw { + name?: string | null; + language?: string | null; + description?: string | null; + labels?: string[] | null; + } +} diff --git a/src/serialization/resources/alphaSections/client/requests/index.ts b/src/serialization/resources/alphaSections/client/requests/index.ts new file mode 100644 index 00000000..a36d62ad --- /dev/null +++ b/src/serialization/resources/alphaSections/client/requests/index.ts @@ -0,0 +1 @@ +export { UpdateSectionRequest } from "./UpdateSectionRequest.js"; diff --git a/src/serialization/resources/alphaSections/index.ts b/src/serialization/resources/alphaSections/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/serialization/resources/alphaSections/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/serialization/resources/alphaTemplateVersions/client/index.ts b/src/serialization/resources/alphaTemplateVersions/client/index.ts new file mode 100644 index 00000000..cd155427 --- /dev/null +++ b/src/serialization/resources/alphaTemplateVersions/client/index.ts @@ -0,0 +1,2 @@ +export * as list from "./list.js"; +export * from "./requests/index.js"; diff --git a/src/serialization/resources/alphaTemplateVersions/client/list.ts b/src/serialization/resources/alphaTemplateVersions/client/list.ts new file mode 100644 index 00000000..a2924d99 --- /dev/null +++ b/src/serialization/resources/alphaTemplateVersions/client/list.ts @@ -0,0 +1,15 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../api/index.js"; +import * as core from "../../../../core/index.js"; +import type * as serializers from "../../../index.js"; +import { TemplateVersion } from "../../../types/TemplateVersion.js"; + +export const Response: core.serialization.Schema< + serializers.alphaTemplateVersions.list.Response.Raw, + Corti.TemplateVersion[] +> = core.serialization.list(TemplateVersion); + +export declare namespace Response { + export type Raw = TemplateVersion.Raw[]; +} diff --git a/src/serialization/resources/alphaTemplateVersions/client/requests/CreateTemplateVersionRequest.ts b/src/serialization/resources/alphaTemplateVersions/client/requests/CreateTemplateVersionRequest.ts new file mode 100644 index 00000000..4c52846a --- /dev/null +++ b/src/serialization/resources/alphaTemplateVersions/client/requests/CreateTemplateVersionRequest.ts @@ -0,0 +1,19 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../../api/index.js"; +import * as core from "../../../../../core/index.js"; +import type * as serializers from "../../../../index.js"; +import { CreateTemplateVersionRequestGeneration } from "../../types/CreateTemplateVersionRequestGeneration.js"; + +export const CreateTemplateVersionRequest: core.serialization.Schema< + serializers.CreateTemplateVersionRequest.Raw, + Corti.CreateTemplateVersionRequest +> = core.serialization.object({ + generation: CreateTemplateVersionRequestGeneration, +}); + +export declare namespace CreateTemplateVersionRequest { + export interface Raw { + generation: CreateTemplateVersionRequestGeneration.Raw; + } +} diff --git a/src/serialization/resources/alphaTemplateVersions/client/requests/index.ts b/src/serialization/resources/alphaTemplateVersions/client/requests/index.ts new file mode 100644 index 00000000..bea03b68 --- /dev/null +++ b/src/serialization/resources/alphaTemplateVersions/client/requests/index.ts @@ -0,0 +1 @@ +export { CreateTemplateVersionRequest } from "./CreateTemplateVersionRequest.js"; diff --git a/src/serialization/resources/alphaTemplateVersions/index.ts b/src/serialization/resources/alphaTemplateVersions/index.ts new file mode 100644 index 00000000..d9adb1af --- /dev/null +++ b/src/serialization/resources/alphaTemplateVersions/index.ts @@ -0,0 +1,2 @@ +export * from "./client/index.js"; +export * from "./types/index.js"; diff --git a/src/serialization/resources/alphaTemplateVersions/types/CreateTemplateVersionRequestGeneration.ts b/src/serialization/resources/alphaTemplateVersions/types/CreateTemplateVersionRequestGeneration.ts new file mode 100644 index 00000000..97667c51 --- /dev/null +++ b/src/serialization/resources/alphaTemplateVersions/types/CreateTemplateVersionRequestGeneration.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../api/index.js"; +import * as core from "../../../../core/index.js"; +import type * as serializers from "../../../index.js"; +import { TemplateInstructions } from "../../../types/TemplateInstructions.js"; +import { TemplateVersionSectionRequest } from "../../../types/TemplateVersionSectionRequest.js"; + +export const CreateTemplateVersionRequestGeneration: core.serialization.ObjectSchema< + serializers.CreateTemplateVersionRequestGeneration.Raw, + Corti.CreateTemplateVersionRequestGeneration +> = core.serialization.object({ + instructions: TemplateInstructions, + sections: core.serialization.list(TemplateVersionSectionRequest).optional(), +}); + +export declare namespace CreateTemplateVersionRequestGeneration { + export interface Raw { + instructions: TemplateInstructions.Raw; + sections?: TemplateVersionSectionRequest.Raw[] | null; + } +} diff --git a/src/serialization/resources/alphaTemplateVersions/types/index.ts b/src/serialization/resources/alphaTemplateVersions/types/index.ts new file mode 100644 index 00000000..78af3000 --- /dev/null +++ b/src/serialization/resources/alphaTemplateVersions/types/index.ts @@ -0,0 +1 @@ +export * from "./CreateTemplateVersionRequestGeneration.js"; diff --git a/src/serialization/resources/alphaTemplates/client/index.ts b/src/serialization/resources/alphaTemplates/client/index.ts new file mode 100644 index 00000000..cd155427 --- /dev/null +++ b/src/serialization/resources/alphaTemplates/client/index.ts @@ -0,0 +1,2 @@ +export * as list from "./list.js"; +export * from "./requests/index.js"; diff --git a/src/serialization/resources/alphaTemplates/client/list.ts b/src/serialization/resources/alphaTemplates/client/list.ts new file mode 100644 index 00000000..70443729 --- /dev/null +++ b/src/serialization/resources/alphaTemplates/client/list.ts @@ -0,0 +1,13 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../api/index.js"; +import * as core from "../../../../core/index.js"; +import type * as serializers from "../../../index.js"; +import { Template } from "../../../types/Template.js"; + +export const Response: core.serialization.Schema = + core.serialization.list(Template); + +export declare namespace Response { + export type Raw = Template.Raw[]; +} diff --git a/src/serialization/resources/alphaTemplates/client/requests/UpdateTemplateRequest.ts b/src/serialization/resources/alphaTemplates/client/requests/UpdateTemplateRequest.ts new file mode 100644 index 00000000..a4d65a3a --- /dev/null +++ b/src/serialization/resources/alphaTemplates/client/requests/UpdateTemplateRequest.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../../../../api/index.js"; +import * as core from "../../../../../core/index.js"; +import type * as serializers from "../../../../index.js"; + +export const UpdateTemplateRequest: core.serialization.Schema< + serializers.UpdateTemplateRequest.Raw, + Corti.UpdateTemplateRequest +> = core.serialization.object({ + name: core.serialization.string().optional(), + description: core.serialization.string().optional(), + language: core.serialization.string().optional(), + labels: core.serialization.list(core.serialization.string()).optional(), +}); + +export declare namespace UpdateTemplateRequest { + export interface Raw { + name?: string | null; + description?: string | null; + language?: string | null; + labels?: string[] | null; + } +} diff --git a/src/serialization/resources/alphaTemplates/client/requests/index.ts b/src/serialization/resources/alphaTemplates/client/requests/index.ts new file mode 100644 index 00000000..aa555e1b --- /dev/null +++ b/src/serialization/resources/alphaTemplates/client/requests/index.ts @@ -0,0 +1 @@ +export { UpdateTemplateRequest } from "./UpdateTemplateRequest.js"; diff --git a/src/serialization/resources/alphaTemplates/index.ts b/src/serialization/resources/alphaTemplates/index.ts new file mode 100644 index 00000000..914b8c3c --- /dev/null +++ b/src/serialization/resources/alphaTemplates/index.ts @@ -0,0 +1 @@ +export * from "./client/index.js"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts index 58cf7e90..90fd2e0b 100644 --- a/src/serialization/resources/index.ts +++ b/src/serialization/resources/index.ts @@ -1,6 +1,14 @@ export * from "./agents/client/requests/index.js"; export * as agents from "./agents/index.js"; export * from "./agents/types/index.js"; +export * from "./alphaSections/client/requests/index.js"; +export * as alphaSections from "./alphaSections/index.js"; +export * as alphaSectionVersions from "./alphaSectionVersions/index.js"; +export * from "./alphaTemplates/client/requests/index.js"; +export * as alphaTemplates from "./alphaTemplates/index.js"; +export * from "./alphaTemplateVersions/client/requests/index.js"; +export * as alphaTemplateVersions from "./alphaTemplateVersions/index.js"; +export * from "./alphaTemplateVersions/types/index.js"; export * as auth from "./auth/index.js"; export * from "./auth/types/index.js"; export * from "./codes/client/requests/index.js"; diff --git a/src/serialization/types/AgentsCreateExpertReference.ts b/src/serialization/types/AgentsCreateExpertReference.ts index 535bdd16..db40af90 100644 --- a/src/serialization/types/AgentsCreateExpertReference.ts +++ b/src/serialization/types/AgentsCreateExpertReference.ts @@ -13,6 +13,7 @@ export const AgentsCreateExpertReference: core.serialization.ObjectSchema< id: core.serialization.string().optional(), name: core.serialization.string().optional(), systemPrompt: core.serialization.string().optional(), + config: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), }); export declare namespace AgentsCreateExpertReference { @@ -21,5 +22,6 @@ export declare namespace AgentsCreateExpertReference { id?: string | null; name?: string | null; systemPrompt?: string | null; + config?: Record | null; } } diff --git a/src/serialization/types/AgentsErrorResponse.ts b/src/serialization/types/AgentsErrorResponse.ts deleted file mode 100644 index 06424ccf..00000000 --- a/src/serialization/types/AgentsErrorResponse.ts +++ /dev/null @@ -1,26 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Corti from "../../api/index.js"; -import * as core from "../../core/index.js"; -import type * as serializers from "../index.js"; - -export const AgentsErrorResponse: core.serialization.ObjectSchema< - serializers.AgentsErrorResponse.Raw, - Corti.AgentsErrorResponse -> = core.serialization.object({ - code: core.serialization.string(), - description: core.serialization.string(), - howToFix: core.serialization.string().optional(), - details: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), - cause: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), -}); - -export declare namespace AgentsErrorResponse { - export interface Raw { - code: string; - description: string; - howToFix?: string | null; - details?: Record | null; - cause?: Record | null; - } -} diff --git a/src/serialization/types/AgentsExpertReference.ts b/src/serialization/types/AgentsExpertReference.ts index 1dbdbf71..00a6167b 100644 --- a/src/serialization/types/AgentsExpertReference.ts +++ b/src/serialization/types/AgentsExpertReference.ts @@ -13,6 +13,7 @@ export const AgentsExpertReference: core.serialization.ObjectSchema< id: core.serialization.string(), name: core.serialization.string(), systemPrompt: core.serialization.string().optional(), + resolvedConfig: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), }); export declare namespace AgentsExpertReference { @@ -21,5 +22,6 @@ export declare namespace AgentsExpertReference { id: string; name: string; systemPrompt?: string | null; + resolvedConfig?: Record | null; } } diff --git a/src/serialization/types/AgentsRegistryExpert.ts b/src/serialization/types/AgentsRegistryExpert.ts index c29b3a23..674c9ced 100644 --- a/src/serialization/types/AgentsRegistryExpert.ts +++ b/src/serialization/types/AgentsRegistryExpert.ts @@ -14,6 +14,7 @@ export const AgentsRegistryExpert: core.serialization.ObjectSchema< displayDescription: core.serialization.string().optional(), description: core.serialization.string(), mcpServers: core.serialization.list(AgentsRegistryMcpServer).optional(), + configSchema: core.serialization.record(core.serialization.string(), core.serialization.unknown()).optional(), }); export declare namespace AgentsRegistryExpert { @@ -23,5 +24,6 @@ export declare namespace AgentsRegistryExpert { displayDescription?: string | null; description: string; mcpServers?: AgentsRegistryMcpServer.Raw[] | null; + configSchema?: Record | null; } } diff --git a/src/serialization/types/AgentsValidationError.ts b/src/serialization/types/AgentsValidationError.ts deleted file mode 100644 index bab2cb33..00000000 --- a/src/serialization/types/AgentsValidationError.ts +++ /dev/null @@ -1,27 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Corti from "../../api/index.js"; -import * as core from "../../core/index.js"; -import type * as serializers from "../index.js"; -import { AgentsValidationErrorErrorsItem } from "./AgentsValidationErrorErrorsItem.js"; - -export const AgentsValidationError: core.serialization.ObjectSchema< - serializers.AgentsValidationError.Raw, - Corti.AgentsValidationError -> = core.serialization.object({ - msg: core.serialization.string(), - type: core.serialization.string(), - reason: core.serialization.string(), - howToFix: core.serialization.string(), - errors: core.serialization.list(AgentsValidationErrorErrorsItem).optional(), -}); - -export declare namespace AgentsValidationError { - export interface Raw { - msg: string; - type: string; - reason: string; - howToFix: string; - errors?: AgentsValidationErrorErrorsItem.Raw[] | null; - } -} diff --git a/src/serialization/types/AgentsValidationErrorErrorsItem.ts b/src/serialization/types/AgentsValidationErrorErrorsItem.ts deleted file mode 100644 index a1fb44b3..00000000 --- a/src/serialization/types/AgentsValidationErrorErrorsItem.ts +++ /dev/null @@ -1,20 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Corti from "../../api/index.js"; -import * as core from "../../core/index.js"; -import type * as serializers from "../index.js"; - -export const AgentsValidationErrorErrorsItem: core.serialization.ObjectSchema< - serializers.AgentsValidationErrorErrorsItem.Raw, - Corti.AgentsValidationErrorErrorsItem -> = core.serialization.object({ - location: core.serialization.string().optional(), - reason: core.serialization.string().optional(), -}); - -export declare namespace AgentsValidationErrorErrorsItem { - export interface Raw { - location?: string | null; - reason?: string | null; - } -} diff --git a/src/serialization/types/AgentsValidationErrorResponse.ts b/src/serialization/types/AgentsValidationErrorResponse.ts deleted file mode 100644 index 46415c5d..00000000 --- a/src/serialization/types/AgentsValidationErrorResponse.ts +++ /dev/null @@ -1,22 +0,0 @@ -// This file was auto-generated by Fern from our API Definition. - -import type * as Corti from "../../api/index.js"; -import * as core from "../../core/index.js"; -import type * as serializers from "../index.js"; -import { AgentsErrorResponse } from "./AgentsErrorResponse.js"; -import { AgentsValidationError } from "./AgentsValidationError.js"; - -export const AgentsValidationErrorResponse: core.serialization.ObjectSchema< - serializers.AgentsValidationErrorResponse.Raw, - Corti.AgentsValidationErrorResponse -> = core.serialization - .object({ - detail: core.serialization.list(AgentsValidationError).optional(), - }) - .extend(AgentsErrorResponse); - -export declare namespace AgentsValidationErrorResponse { - export interface Raw extends AgentsErrorResponse.Raw { - detail?: AgentsValidationError.Raw[] | null; - } -} diff --git a/src/serialization/types/ArrayNode.ts b/src/serialization/types/ArrayNode.ts new file mode 100644 index 00000000..363d8b79 --- /dev/null +++ b/src/serialization/types/ArrayNode.ts @@ -0,0 +1,26 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import * as serializers from "../index.js"; + +export const ArrayNode: core.serialization.ObjectSchema = + core.serialization.object({ + type: core.serialization.stringLiteral("array"), + description: core.serialization.string().optional(), + items: core.serialization.lazy(() => serializers.OutputSchema), + itemFormat: core.serialization.string().optional(), + minItems: core.serialization.number().optionalNullable(), + maxItems: core.serialization.number().optionalNullable(), + }); + +export declare namespace ArrayNode { + export interface Raw { + type: "array"; + description?: string | null; + items: serializers.OutputSchema.Raw; + itemFormat?: string | null; + minItems?: (number | null | undefined) | null; + maxItems?: (number | null | undefined) | null; + } +} diff --git a/src/serialization/types/BoolNode.ts b/src/serialization/types/BoolNode.ts new file mode 100644 index 00000000..38a73c89 --- /dev/null +++ b/src/serialization/types/BoolNode.ts @@ -0,0 +1,20 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const BoolNode: core.serialization.ObjectSchema = + core.serialization.object({ + type: core.serialization.stringLiteral("boolean"), + description: core.serialization.string().optional(), + default: core.serialization.boolean().optionalNullable(), + }); + +export declare namespace BoolNode { + export interface Raw { + type: "boolean"; + description?: string | null; + default?: (boolean | null | undefined) | null; + } +} diff --git a/src/serialization/types/CreateSectionBase.ts b/src/serialization/types/CreateSectionBase.ts new file mode 100644 index 00000000..7b039e00 --- /dev/null +++ b/src/serialization/types/CreateSectionBase.ts @@ -0,0 +1,26 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const CreateSectionBase: core.serialization.ObjectSchema< + serializers.CreateSectionBase.Raw, + Corti.CreateSectionBase +> = core.serialization.object({ + name: core.serialization.string(), + language: core.serialization.string(), + description: core.serialization.string().optional(), + labels: core.serialization.list(core.serialization.string()).optional(), + publish: core.serialization.boolean().optional(), +}); + +export declare namespace CreateSectionBase { + export interface Raw { + name: string; + language: string; + description?: string | null; + labels?: string[] | null; + publish?: boolean | null; + } +} diff --git a/src/serialization/types/CreateSectionFromInheritanceRequest.ts b/src/serialization/types/CreateSectionFromInheritanceRequest.ts new file mode 100644 index 00000000..f29f279c --- /dev/null +++ b/src/serialization/types/CreateSectionFromInheritanceRequest.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { CreateSectionBase } from "./CreateSectionBase.js"; +import { SectionGenerationPartial } from "./SectionGenerationPartial.js"; + +export const CreateSectionFromInheritanceRequest: core.serialization.ObjectSchema< + serializers.CreateSectionFromInheritanceRequest.Raw, + Corti.CreateSectionFromInheritanceRequest +> = core.serialization + .object({ + inheritFromId: core.serialization.string(), + generation: SectionGenerationPartial, + }) + .extend(CreateSectionBase); + +export declare namespace CreateSectionFromInheritanceRequest { + export interface Raw extends CreateSectionBase.Raw { + inheritFromId: string; + generation: SectionGenerationPartial.Raw; + } +} diff --git a/src/serialization/types/CreateSectionFromScratchRequest.ts b/src/serialization/types/CreateSectionFromScratchRequest.ts new file mode 100644 index 00000000..25cc9c7d --- /dev/null +++ b/src/serialization/types/CreateSectionFromScratchRequest.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { CreateSectionBase } from "./CreateSectionBase.js"; +import { SectionGeneration } from "./SectionGeneration.js"; + +export const CreateSectionFromScratchRequest: core.serialization.ObjectSchema< + serializers.CreateSectionFromScratchRequest.Raw, + Corti.CreateSectionFromScratchRequest +> = core.serialization + .object({ + generation: SectionGeneration, + }) + .extend(CreateSectionBase); + +export declare namespace CreateSectionFromScratchRequest { + export interface Raw extends CreateSectionBase.Raw { + generation: SectionGeneration.Raw; + } +} diff --git a/src/serialization/types/CreateSectionRequest.ts b/src/serialization/types/CreateSectionRequest.ts new file mode 100644 index 00000000..f62c46f6 --- /dev/null +++ b/src/serialization/types/CreateSectionRequest.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { CreateSectionFromInheritanceRequest } from "./CreateSectionFromInheritanceRequest.js"; +import { CreateSectionFromScratchRequest } from "./CreateSectionFromScratchRequest.js"; + +export const CreateSectionRequest: core.serialization.Schema< + serializers.CreateSectionRequest.Raw, + Corti.CreateSectionRequest +> = core.serialization.undiscriminatedUnion([CreateSectionFromScratchRequest, CreateSectionFromInheritanceRequest]); + +export declare namespace CreateSectionRequest { + export type Raw = CreateSectionFromScratchRequest.Raw | CreateSectionFromInheritanceRequest.Raw; +} diff --git a/src/serialization/types/CreateTemplateBase.ts b/src/serialization/types/CreateTemplateBase.ts new file mode 100644 index 00000000..ae04a00a --- /dev/null +++ b/src/serialization/types/CreateTemplateBase.ts @@ -0,0 +1,26 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const CreateTemplateBase: core.serialization.ObjectSchema< + serializers.CreateTemplateBase.Raw, + Corti.CreateTemplateBase +> = core.serialization.object({ + name: core.serialization.string(), + description: core.serialization.string().optional(), + language: core.serialization.string(), + labels: core.serialization.list(core.serialization.string()).optional(), + publish: core.serialization.boolean().optional(), +}); + +export declare namespace CreateTemplateBase { + export interface Raw { + name: string; + description?: string | null; + language: string; + labels?: string[] | null; + publish?: boolean | null; + } +} diff --git a/src/serialization/types/CreateTemplateFromInheritanceRequest.ts b/src/serialization/types/CreateTemplateFromInheritanceRequest.ts new file mode 100644 index 00000000..a4254957 --- /dev/null +++ b/src/serialization/types/CreateTemplateFromInheritanceRequest.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { CreateTemplateBase } from "./CreateTemplateBase.js"; +import { CreateTemplateFromInheritanceRequestGeneration } from "./CreateTemplateFromInheritanceRequestGeneration.js"; + +export const CreateTemplateFromInheritanceRequest: core.serialization.ObjectSchema< + serializers.CreateTemplateFromInheritanceRequest.Raw, + Corti.CreateTemplateFromInheritanceRequest +> = core.serialization + .object({ + inheritFromId: core.serialization.string(), + generation: CreateTemplateFromInheritanceRequestGeneration, + }) + .extend(CreateTemplateBase); + +export declare namespace CreateTemplateFromInheritanceRequest { + export interface Raw extends CreateTemplateBase.Raw { + inheritFromId: string; + generation: CreateTemplateFromInheritanceRequestGeneration.Raw; + } +} diff --git a/src/serialization/types/CreateTemplateFromInheritanceRequestGeneration.ts b/src/serialization/types/CreateTemplateFromInheritanceRequestGeneration.ts new file mode 100644 index 00000000..5d9f7039 --- /dev/null +++ b/src/serialization/types/CreateTemplateFromInheritanceRequestGeneration.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { TemplateInstructionsPartial } from "./TemplateInstructionsPartial.js"; +import { TemplateVersionSectionRequest } from "./TemplateVersionSectionRequest.js"; + +export const CreateTemplateFromInheritanceRequestGeneration: core.serialization.ObjectSchema< + serializers.CreateTemplateFromInheritanceRequestGeneration.Raw, + Corti.CreateTemplateFromInheritanceRequestGeneration +> = core.serialization.object({ + instructions: TemplateInstructionsPartial.optional(), + sections: core.serialization.list(TemplateVersionSectionRequest).optional(), +}); + +export declare namespace CreateTemplateFromInheritanceRequestGeneration { + export interface Raw { + instructions?: TemplateInstructionsPartial.Raw | null; + sections?: TemplateVersionSectionRequest.Raw[] | null; + } +} diff --git a/src/serialization/types/CreateTemplateFromScratchRequest.ts b/src/serialization/types/CreateTemplateFromScratchRequest.ts new file mode 100644 index 00000000..7d067925 --- /dev/null +++ b/src/serialization/types/CreateTemplateFromScratchRequest.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { CreateTemplateBase } from "./CreateTemplateBase.js"; +import { CreateTemplateFromScratchRequestGeneration } from "./CreateTemplateFromScratchRequestGeneration.js"; + +export const CreateTemplateFromScratchRequest: core.serialization.ObjectSchema< + serializers.CreateTemplateFromScratchRequest.Raw, + Corti.CreateTemplateFromScratchRequest +> = core.serialization + .object({ + generation: CreateTemplateFromScratchRequestGeneration, + }) + .extend(CreateTemplateBase); + +export declare namespace CreateTemplateFromScratchRequest { + export interface Raw extends CreateTemplateBase.Raw { + generation: CreateTemplateFromScratchRequestGeneration.Raw; + } +} diff --git a/src/serialization/types/CreateTemplateFromScratchRequestGeneration.ts b/src/serialization/types/CreateTemplateFromScratchRequestGeneration.ts new file mode 100644 index 00000000..b3433cc7 --- /dev/null +++ b/src/serialization/types/CreateTemplateFromScratchRequestGeneration.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { TemplateInstructions } from "./TemplateInstructions.js"; +import { TemplateVersionSectionRequest } from "./TemplateVersionSectionRequest.js"; + +export const CreateTemplateFromScratchRequestGeneration: core.serialization.ObjectSchema< + serializers.CreateTemplateFromScratchRequestGeneration.Raw, + Corti.CreateTemplateFromScratchRequestGeneration +> = core.serialization.object({ + instructions: TemplateInstructions, + sections: core.serialization.list(TemplateVersionSectionRequest).optional(), +}); + +export declare namespace CreateTemplateFromScratchRequestGeneration { + export interface Raw { + instructions: TemplateInstructions.Raw; + sections?: TemplateVersionSectionRequest.Raw[] | null; + } +} diff --git a/src/serialization/types/CreateTemplateRequest.ts b/src/serialization/types/CreateTemplateRequest.ts new file mode 100644 index 00000000..d042bbca --- /dev/null +++ b/src/serialization/types/CreateTemplateRequest.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { CreateTemplateFromInheritanceRequest } from "./CreateTemplateFromInheritanceRequest.js"; +import { CreateTemplateFromScratchRequest } from "./CreateTemplateFromScratchRequest.js"; + +export const CreateTemplateRequest: core.serialization.Schema< + serializers.CreateTemplateRequest.Raw, + Corti.CreateTemplateRequest +> = core.serialization.undiscriminatedUnion([CreateTemplateFromScratchRequest, CreateTemplateFromInheritanceRequest]); + +export declare namespace CreateTemplateRequest { + export type Raw = CreateTemplateFromScratchRequest.Raw | CreateTemplateFromInheritanceRequest.Raw; +} diff --git a/src/serialization/types/FieldDefinition.ts b/src/serialization/types/FieldDefinition.ts new file mode 100644 index 00000000..169d1073 --- /dev/null +++ b/src/serialization/types/FieldDefinition.ts @@ -0,0 +1,20 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import * as serializers from "../index.js"; + +export const FieldDefinition: core.serialization.ObjectSchema = + core.serialization.object({ + key: core.serialization.string(), + description: core.serialization.string(), + value: core.serialization.lazy(() => serializers.OutputSchema), + }); + +export declare namespace FieldDefinition { + export interface Raw { + key: string; + description: string; + value: serializers.OutputSchema.Raw; + } +} diff --git a/src/serialization/types/NumberNode.ts b/src/serialization/types/NumberNode.ts new file mode 100644 index 00000000..10474663 --- /dev/null +++ b/src/serialization/types/NumberNode.ts @@ -0,0 +1,26 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const NumberNode: core.serialization.ObjectSchema = + core.serialization.object({ + type: core.serialization.stringLiteral("number"), + description: core.serialization.string().optional(), + default: core.serialization.number().optionalNullable(), + enum: core.serialization.list(core.serialization.number()).optional(), + minimum: core.serialization.number().optionalNullable(), + maximum: core.serialization.number().optionalNullable(), + }); + +export declare namespace NumberNode { + export interface Raw { + type: "number"; + description?: string | null; + default?: (number | null | undefined) | null; + enum?: number[] | null; + minimum?: (number | null | undefined) | null; + maximum?: (number | null | undefined) | null; + } +} diff --git a/src/serialization/types/ObjectNode.ts b/src/serialization/types/ObjectNode.ts new file mode 100644 index 00000000..ee8a6e62 --- /dev/null +++ b/src/serialization/types/ObjectNode.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import * as serializers from "../index.js"; + +export const ObjectNode: core.serialization.ObjectSchema = + core.serialization.object({ + type: core.serialization.stringLiteral("object"), + description: core.serialization.string().optional(), + subheadingFormat: core.serialization.string().optional(), + objectFormat: core.serialization.string().optional(), + fields: core.serialization.list(core.serialization.lazyObject(() => serializers.FieldDefinition)).optional(), + }); + +export declare namespace ObjectNode { + export interface Raw { + type: "object"; + description?: string | null; + subheadingFormat?: string | null; + objectFormat?: string | null; + fields?: serializers.FieldDefinition.Raw[] | null; + } +} diff --git a/src/serialization/types/OutputSchema.ts b/src/serialization/types/OutputSchema.ts new file mode 100644 index 00000000..02f2e117 --- /dev/null +++ b/src/serialization/types/OutputSchema.ts @@ -0,0 +1,26 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import * as serializers from "../index.js"; +import { BoolNode } from "./BoolNode.js"; +import { NumberNode } from "./NumberNode.js"; +import { StringNode } from "./StringNode.js"; + +export const OutputSchema: core.serialization.Schema = + core.serialization.undiscriminatedUnion([ + StringNode, + NumberNode, + BoolNode, + core.serialization.lazyObject(() => serializers.ObjectNode), + core.serialization.lazyObject(() => serializers.ArrayNode), + ]); + +export declare namespace OutputSchema { + export type Raw = + | StringNode.Raw + | NumberNode.Raw + | BoolNode.Raw + | serializers.ObjectNode.Raw + | serializers.ArrayNode.Raw; +} diff --git a/src/serialization/types/Section.ts b/src/serialization/types/Section.ts new file mode 100644 index 00000000..fe070ce9 --- /dev/null +++ b/src/serialization/types/Section.ts @@ -0,0 +1,35 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { SectionVersion } from "./SectionVersion.js"; + +export const Section: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + inheritedFromId: core.serialization.string().optionalNullable(), + autoGenerated: core.serialization.boolean().optional(), + name: core.serialization.string(), + language: core.serialization.string(), + description: core.serialization.string().optional(), + labels: core.serialization.list(core.serialization.string()), + publishedVersion: SectionVersion.optional(), + createdAt: core.serialization.date(), + updatedAt: core.serialization.date(), + }); + +export declare namespace Section { + export interface Raw { + id: string; + inheritedFromId?: (string | null | undefined) | null; + autoGenerated?: boolean | null; + name: string; + language: string; + description?: string | null; + labels: string[]; + publishedVersion?: SectionVersion.Raw | null; + createdAt: string; + updatedAt: string; + } +} diff --git a/src/serialization/types/SectionGeneration.ts b/src/serialization/types/SectionGeneration.ts new file mode 100644 index 00000000..bb0a909a --- /dev/null +++ b/src/serialization/types/SectionGeneration.ts @@ -0,0 +1,23 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import * as serializers from "../index.js"; +import { SectionInstructions } from "./SectionInstructions.js"; + +export const SectionGeneration: core.serialization.ObjectSchema< + serializers.SectionGeneration.Raw, + Corti.SectionGeneration +> = core.serialization.object({ + heading: core.serialization.string(), + instructions: SectionInstructions, + outputSchema: core.serialization.lazy(() => serializers.OutputSchema), +}); + +export declare namespace SectionGeneration { + export interface Raw { + heading: string; + instructions: SectionInstructions.Raw; + outputSchema: serializers.OutputSchema.Raw; + } +} diff --git a/src/serialization/types/SectionGenerationPartial.ts b/src/serialization/types/SectionGenerationPartial.ts new file mode 100644 index 00000000..1e16a7be --- /dev/null +++ b/src/serialization/types/SectionGenerationPartial.ts @@ -0,0 +1,23 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import * as serializers from "../index.js"; +import { SectionInstructionsPartial } from "./SectionInstructionsPartial.js"; + +export const SectionGenerationPartial: core.serialization.ObjectSchema< + serializers.SectionGenerationPartial.Raw, + Corti.SectionGenerationPartial +> = core.serialization.object({ + heading: core.serialization.string().optional(), + instructions: SectionInstructionsPartial.optional(), + outputSchema: core.serialization.lazy(() => serializers.OutputSchema).optional(), +}); + +export declare namespace SectionGenerationPartial { + export interface Raw { + heading?: string | null; + instructions?: SectionInstructionsPartial.Raw | null; + outputSchema?: serializers.OutputSchema.Raw | null; + } +} diff --git a/src/serialization/types/SectionInstructions.ts b/src/serialization/types/SectionInstructions.ts new file mode 100644 index 00000000..a1e097a4 --- /dev/null +++ b/src/serialization/types/SectionInstructions.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const SectionInstructions: core.serialization.ObjectSchema< + serializers.SectionInstructions.Raw, + Corti.SectionInstructions +> = core.serialization.object({ + contentPrompt: core.serialization.string(), + writingStylePrompt: core.serialization.string().optional(), + miscPrompt: core.serialization.string().optional(), +}); + +export declare namespace SectionInstructions { + export interface Raw { + contentPrompt: string; + writingStylePrompt?: string | null; + miscPrompt?: string | null; + } +} diff --git a/src/serialization/types/SectionInstructionsPartial.ts b/src/serialization/types/SectionInstructionsPartial.ts new file mode 100644 index 00000000..50833a45 --- /dev/null +++ b/src/serialization/types/SectionInstructionsPartial.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const SectionInstructionsPartial: core.serialization.ObjectSchema< + serializers.SectionInstructionsPartial.Raw, + Corti.SectionInstructionsPartial +> = core.serialization.object({ + contentPrompt: core.serialization.string().optional(), + writingStylePrompt: core.serialization.string().optional(), + miscPrompt: core.serialization.string().optional(), +}); + +export declare namespace SectionInstructionsPartial { + export interface Raw { + contentPrompt?: string | null; + writingStylePrompt?: string | null; + miscPrompt?: string | null; + } +} diff --git a/src/serialization/types/SectionVersion.ts b/src/serialization/types/SectionVersion.ts new file mode 100644 index 00000000..8809bb35 --- /dev/null +++ b/src/serialization/types/SectionVersion.ts @@ -0,0 +1,21 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { SectionGeneration } from "./SectionGeneration.js"; + +export const SectionVersion: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + versionNumber: core.serialization.number(), + generation: SectionGeneration, + }); + +export declare namespace SectionVersion { + export interface Raw { + id: string; + versionNumber: number; + generation: SectionGeneration.Raw; + } +} diff --git a/src/serialization/types/StatusResponse.ts b/src/serialization/types/StatusResponse.ts new file mode 100644 index 00000000..e3d3dbe6 --- /dev/null +++ b/src/serialization/types/StatusResponse.ts @@ -0,0 +1,16 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const StatusResponse: core.serialization.ObjectSchema = + core.serialization.object({ + status: core.serialization.string(), + }); + +export declare namespace StatusResponse { + export interface Raw { + status: string; + } +} diff --git a/src/serialization/types/StringNode.ts b/src/serialization/types/StringNode.ts new file mode 100644 index 00000000..3bd5d85a --- /dev/null +++ b/src/serialization/types/StringNode.ts @@ -0,0 +1,24 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const StringNode: core.serialization.ObjectSchema = + core.serialization.object({ + type: core.serialization.stringLiteral("string"), + description: core.serialization.string().optional(), + default: core.serialization.string().optionalNullable(), + enum: core.serialization.list(core.serialization.string()).optional(), + pattern: core.serialization.string().optionalNullable(), + }); + +export declare namespace StringNode { + export interface Raw { + type: "string"; + description?: string | null; + default?: (string | null | undefined) | null; + enum?: string[] | null; + pattern?: (string | null | undefined) | null; + } +} diff --git a/src/serialization/types/Template.ts b/src/serialization/types/Template.ts new file mode 100644 index 00000000..b3814a1a --- /dev/null +++ b/src/serialization/types/Template.ts @@ -0,0 +1,35 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { TemplateVersion } from "./TemplateVersion.js"; + +export const Template: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + inheritedFromId: core.serialization.string().optionalNullable(), + autoGenerated: core.serialization.boolean().optional(), + name: core.serialization.string(), + description: core.serialization.string().optional(), + language: core.serialization.string(), + labels: core.serialization.list(core.serialization.string()), + publishedVersion: TemplateVersion.optional(), + createdAt: core.serialization.date(), + updatedAt: core.serialization.date(), + }); + +export declare namespace Template { + export interface Raw { + id: string; + inheritedFromId?: (string | null | undefined) | null; + autoGenerated?: boolean | null; + name: string; + description?: string | null; + language: string; + labels: string[]; + publishedVersion?: TemplateVersion.Raw | null; + createdAt: string; + updatedAt: string; + } +} diff --git a/src/serialization/types/TemplateGeneration.ts b/src/serialization/types/TemplateGeneration.ts new file mode 100644 index 00000000..d7d02886 --- /dev/null +++ b/src/serialization/types/TemplateGeneration.ts @@ -0,0 +1,22 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { Section } from "./Section.js"; +import { TemplateInstructions } from "./TemplateInstructions.js"; + +export const TemplateGeneration: core.serialization.ObjectSchema< + serializers.TemplateGeneration.Raw, + Corti.TemplateGeneration +> = core.serialization.object({ + instructions: TemplateInstructions, + sections: core.serialization.list(Section).optional(), +}); + +export declare namespace TemplateGeneration { + export interface Raw { + instructions: TemplateInstructions.Raw; + sections?: Section.Raw[] | null; + } +} diff --git a/src/serialization/types/TemplateInstructions.ts b/src/serialization/types/TemplateInstructions.ts new file mode 100644 index 00000000..ac302df9 --- /dev/null +++ b/src/serialization/types/TemplateInstructions.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const TemplateInstructions: core.serialization.ObjectSchema< + serializers.TemplateInstructions.Raw, + Corti.TemplateInstructions +> = core.serialization.object({ + prompt: core.serialization.string(), +}); + +export declare namespace TemplateInstructions { + export interface Raw { + prompt: string; + } +} diff --git a/src/serialization/types/TemplateInstructionsPartial.ts b/src/serialization/types/TemplateInstructionsPartial.ts new file mode 100644 index 00000000..fe069434 --- /dev/null +++ b/src/serialization/types/TemplateInstructionsPartial.ts @@ -0,0 +1,18 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const TemplateInstructionsPartial: core.serialization.ObjectSchema< + serializers.TemplateInstructionsPartial.Raw, + Corti.TemplateInstructionsPartial +> = core.serialization.object({ + prompt: core.serialization.string().optional(), +}); + +export declare namespace TemplateInstructionsPartial { + export interface Raw { + prompt?: string | null; + } +} diff --git a/src/serialization/types/TemplateVersion.ts b/src/serialization/types/TemplateVersion.ts new file mode 100644 index 00000000..cabcb3cd --- /dev/null +++ b/src/serialization/types/TemplateVersion.ts @@ -0,0 +1,21 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; +import { TemplateGeneration } from "./TemplateGeneration.js"; + +export const TemplateVersion: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string(), + versionNumber: core.serialization.number(), + generation: TemplateGeneration, + }); + +export declare namespace TemplateVersion { + export interface Raw { + id: string; + versionNumber: number; + generation: TemplateGeneration.Raw; + } +} diff --git a/src/serialization/types/TemplateVersionSectionRequest.ts b/src/serialization/types/TemplateVersionSectionRequest.ts new file mode 100644 index 00000000..25a818c3 --- /dev/null +++ b/src/serialization/types/TemplateVersionSectionRequest.ts @@ -0,0 +1,20 @@ +// This file was auto-generated by Fern from our API Definition. + +import type * as Corti from "../../api/index.js"; +import * as core from "../../core/index.js"; +import type * as serializers from "../index.js"; + +export const TemplateVersionSectionRequest: core.serialization.ObjectSchema< + serializers.TemplateVersionSectionRequest.Raw, + Corti.TemplateVersionSectionRequest +> = core.serialization.object({ + sectionId: core.serialization.string(), + orderIndex: core.serialization.number().optional(), +}); + +export declare namespace TemplateVersionSectionRequest { + export interface Raw { + sectionId: string; + orderIndex?: number | null; + } +} diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts index 66b9b853..7770f431 100644 --- a/src/serialization/types/index.ts +++ b/src/serialization/types/index.ts @@ -22,7 +22,6 @@ export * from "./AgentsCreateMcpServerAuthorizationType.js"; export * from "./AgentsCreateMcpServerTransportType.js"; export * from "./AgentsDataPart.js"; export * from "./AgentsDataPartKind.js"; -export * from "./AgentsErrorResponse.js"; export * from "./AgentsExpert.js"; export * from "./AgentsExpertReference.js"; export * from "./AgentsExpertReferenceType.js"; @@ -53,15 +52,14 @@ export * from "./AgentsTaskStatusState.js"; export * from "./AgentsTextPart.js"; export * from "./AgentsTextPartKind.js"; export * from "./AgentsUpdateExpertReference.js"; -export * from "./AgentsValidationError.js"; -export * from "./AgentsValidationErrorErrorsItem.js"; -export * from "./AgentsValidationErrorResponse.js"; +export * from "./ArrayNode.js"; export * from "./AuthTokenRequestAuthorizationCode.js"; export * from "./AuthTokenRequestAuthorizationPkce.js"; export * from "./AuthTokenRequestClientCredentials.js"; export * from "./AuthTokenRequestRefresh.js"; export * from "./AuthTokenRequestRopc.js"; export * from "./AuthTokenResponse.js"; +export * from "./BoolNode.js"; export * from "./CodesFilter.js"; export * from "./CodesGeneralReadResponse.js"; export * from "./CodesGeneralReadResponseAlternativesItem.js"; @@ -78,6 +76,16 @@ export * from "./CommonTextContextType.js"; export * from "./CommonTranscriptRequest.js"; export * from "./CommonTranscriptResponse.js"; export * from "./CommonUsageInfo.js"; +export * from "./CreateSectionBase.js"; +export * from "./CreateSectionFromInheritanceRequest.js"; +export * from "./CreateSectionFromScratchRequest.js"; +export * from "./CreateSectionRequest.js"; +export * from "./CreateTemplateBase.js"; +export * from "./CreateTemplateFromInheritanceRequest.js"; +export * from "./CreateTemplateFromInheritanceRequestGeneration.js"; +export * from "./CreateTemplateFromScratchRequest.js"; +export * from "./CreateTemplateFromScratchRequestGeneration.js"; +export * from "./CreateTemplateRequest.js"; export * from "./DocumentsContext.js"; export * from "./DocumentsContextWithFacts.js"; export * from "./DocumentsContextWithFactsType.js"; @@ -113,6 +121,7 @@ export * from "./FactsFactGroupsListResponse.js"; export * from "./FactsListItem.js"; export * from "./FactsListResponse.js"; export * from "./FactsUpdateResponse.js"; +export * from "./FieldDefinition.js"; export * from "./InteractionsCreateResponse.js"; export * from "./InteractionsEncounterCreateRequest.js"; export * from "./InteractionsEncounterPeriod.js"; @@ -124,9 +133,19 @@ export * from "./InteractionsGenderEnum.js"; export * from "./InteractionsGetResponse.js"; export * from "./InteractionsListResponse.js"; export * from "./InteractionsPatient.js"; +export * from "./NumberNode.js"; export * from "./OAuthTokenRequest.js"; +export * from "./ObjectNode.js"; +export * from "./OutputSchema.js"; export * from "./RecordingsCreateResponse.js"; export * from "./RecordingsListResponse.js"; +export * from "./Section.js"; +export * from "./SectionGeneration.js"; +export * from "./SectionGenerationPartial.js"; +export * from "./SectionInstructions.js"; +export * from "./SectionInstructionsPartial.js"; +export * from "./SectionVersion.js"; +export * from "./StatusResponse.js"; export * from "./StreamConfig.js"; export * from "./StreamConfigMessage.js"; export * from "./StreamConfigMode.js"; @@ -152,6 +171,11 @@ export * from "./StreamTranscript.js"; export * from "./StreamTranscriptMessage.js"; export * from "./StreamTranscriptTime.js"; export * from "./StreamUsageMessage.js"; +export * from "./StringNode.js"; +export * from "./Template.js"; +export * from "./TemplateGeneration.js"; +export * from "./TemplateInstructions.js"; +export * from "./TemplateInstructionsPartial.js"; export * from "./TemplatesDocumentationModeEnum.js"; export * from "./TemplatesFormatRule.js"; export * from "./TemplatesItem.js"; @@ -162,6 +186,8 @@ export * from "./TemplatesSectionSorted.js"; export * from "./TemplatesSectionTranslation.js"; export * from "./TemplatesTranslation.js"; export * from "./TemplatesWritingStyle.js"; +export * from "./TemplateVersion.js"; +export * from "./TemplateVersionSectionRequest.js"; export * from "./TranscribeCommand.js"; export * from "./TranscribeCommandData.js"; export * from "./TranscribeCommandMessage.js"; diff --git a/tests/wire/agents.test.ts b/tests/wire/agents.test.ts index acd362e9..a041e8c1 100644 --- a/tests/wire/agents.test.ts +++ b/tests/wire/agents.test.ts @@ -276,7 +276,7 @@ describe("AgentsClient", () => { environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, }); const rawRequestBody = { name: "name", description: "description" }; - const rawResponseBody = { code: "code", description: "description" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint() @@ -717,7 +717,7 @@ describe("AgentsClient", () => { environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, }); const rawRequestBody = {}; - const rawResponseBody = { code: "code", description: "description" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint() @@ -1332,7 +1332,7 @@ describe("AgentsClient", () => { kind: "message", }, }; - const rawResponseBody = { code: "code", description: "description" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint() @@ -1793,6 +1793,7 @@ describe("AgentsClient", () => { displayDescription: "displayDescription", description: "description", mcpServers: [{ name: "name", authorizationType: "none" }], + configSchema: { key: "value" }, }, ], }; @@ -1822,6 +1823,9 @@ describe("AgentsClient", () => { authorizationType: "none", }, ], + configSchema: { + key: "value", + }, }, ], }); @@ -1893,7 +1897,7 @@ describe("AgentsClient", () => { environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, }); - const rawResponseBody = { code: "code", description: "description" }; + const rawResponseBody = { key: "value" }; server .mockEndpoint() diff --git a/tests/wire/alphaDocuments.test.ts b/tests/wire/alphaDocuments.test.ts new file mode 100644 index 00000000..de9072e4 --- /dev/null +++ b/tests/wire/alphaDocuments.test.ts @@ -0,0 +1,25 @@ +// This file was auto-generated by Fern from our API Definition. + +import { CortiClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; +import { mockOAuth } from "./mockAuth"; + +describe("AlphaDocumentsClient", () => { + test("generate", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + server.mockEndpoint().post("/alpha/documents").respondWith().statusCode(200).build(); + + const response = await client.alphaDocuments.generate(); + expect(response).toEqual(undefined); + }); +}); diff --git a/tests/wire/alphaSectionVersions.test.ts b/tests/wire/alphaSectionVersions.test.ts new file mode 100644 index 00000000..4bd19c5a --- /dev/null +++ b/tests/wire/alphaSectionVersions.test.ts @@ -0,0 +1,434 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Corti from "../../src/api/index"; +import { CortiClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; +import { mockOAuth } from "./mockAuth"; + +describe("AlphaSectionVersionsClient", () => { + test("list (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = [ + { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + ]; + + server + .mockEndpoint() + .get("/alpha/sections/sectionID/versions/") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaSectionVersions.list("sectionID"); + expect(response).toEqual([ + { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + ]); + }); + + test("list (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/alpha/sections/sectionID/versions/") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSectionVersions.list("sectionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }; + const rawResponseBody = { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + writingStylePrompt: "writingStylePrompt", + miscPrompt: "miscPrompt", + }, + outputSchema: { + type: "string", + description: "description", + default: "default", + enum: ["enum"], + pattern: "pattern", + }, + }, + }; + + server + .mockEndpoint() + .post("/alpha/sections/sectionID/versions/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaSectionVersions.create("sectionID", { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }); + expect(response).toEqual({ + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + writingStylePrompt: "writingStylePrompt", + miscPrompt: "miscPrompt", + }, + outputSchema: { + type: "string", + description: "description", + default: "default", + enum: ["enum"], + pattern: "pattern", + }, + }, + }); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/sections/sectionID/versions/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSectionVersions.create("sectionID", { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }); + }).rejects.toThrow(Corti.BadRequestError); + }); + + test("create (3)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/sections/sectionID/versions/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSectionVersions.create("sectionID", { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + writingStylePrompt: "writingStylePrompt", + miscPrompt: "miscPrompt", + }, + outputSchema: { + type: "string", + description: "description", + default: "default", + enum: ["enum"], + pattern: "pattern", + }, + }, + }; + + server + .mockEndpoint() + .get("/alpha/sections/sectionID/versions/versionID") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaSectionVersions.get("sectionID", "versionID"); + expect(response).toEqual({ + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + writingStylePrompt: "writingStylePrompt", + miscPrompt: "miscPrompt", + }, + outputSchema: { + type: "string", + description: "description", + default: "default", + enum: ["enum"], + pattern: "pattern", + }, + }, + }); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/alpha/sections/sectionID/versions/versionID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSectionVersions.get("sectionID", "versionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + server + .mockEndpoint() + .delete("/alpha/sections/sectionID/versions/versionID") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.alphaSectionVersions.delete("sectionID", "versionID"); + expect(response).toEqual(undefined); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/alpha/sections/sectionID/versions/versionID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSectionVersions.delete("sectionID", "versionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("publish (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { status: "published" }; + + server + .mockEndpoint() + .post("/alpha/sections/sectionID/versions/versionID/publish") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaSectionVersions.publish("sectionID", "versionID"); + expect(response).toEqual({ + status: "published", + }); + }); + + test("publish (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/sections/sectionID/versions/versionID/publish") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSectionVersions.publish("sectionID", "versionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); +}); diff --git a/tests/wire/alphaSections.test.ts b/tests/wire/alphaSections.test.ts new file mode 100644 index 00000000..260e4b26 --- /dev/null +++ b/tests/wire/alphaSections.test.ts @@ -0,0 +1,476 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Corti from "../../src/api/index"; +import { CortiClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; +import { mockOAuth } from "./mockAuth"; + +describe("AlphaSectionsClient", () => { + test("list", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = [ + { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ]; + + server.mockEndpoint().get("/alpha/sections/").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.alphaSections.list(); + expect(response).toEqual([ + { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ]); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { + name: "name", + language: "language", + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }; + const rawResponseBody = { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }; + + server + .mockEndpoint() + .post("/alpha/sections/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaSections.create({ + name: "name", + language: "language", + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }); + expect(response).toEqual({ + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + name: "name", + language: "language", + }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/sections/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSections.create({ + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + name: "name", + language: "language", + }); + }).rejects.toThrow(Corti.BadRequestError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }; + + server + .mockEndpoint() + .get("/alpha/sections/sectionID") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaSections.get("sectionID"); + expect(response).toEqual({ + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/alpha/sections/sectionID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSections.get("sectionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + server.mockEndpoint().delete("/alpha/sections/sectionID").respondWith().statusCode(200).build(); + + const response = await client.alphaSections.delete("sectionID"); + expect(response).toEqual(undefined); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/alpha/sections/sectionID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSections.delete("sectionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("update (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }; + + server + .mockEndpoint() + .patch("/alpha/sections/sectionID") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaSections.update("sectionID"); + expect(response).toEqual({ + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + language: "language", + description: "description", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }); + }); + + test("update (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/alpha/sections/sectionID") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSections.update("sectionID"); + }).rejects.toThrow(Corti.BadRequestError); + }); + + test("update (3)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/alpha/sections/sectionID") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaSections.update("sectionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); +}); diff --git a/tests/wire/alphaTemplateVersions.test.ts b/tests/wire/alphaTemplateVersions.test.ts new file mode 100644 index 00000000..68c04339 --- /dev/null +++ b/tests/wire/alphaTemplateVersions.test.ts @@ -0,0 +1,492 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Corti from "../../src/api/index"; +import { CortiClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; +import { mockOAuth } from "./mockAuth"; + +describe("AlphaTemplateVersionsClient", () => { + test("list (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = [ + { + id: "id", + versionNumber: 1, + generation: { + instructions: { prompt: "prompt" }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ], + }, + }, + ]; + + server + .mockEndpoint() + .get("/alpha/templates/templateID/versions/") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaTemplateVersions.list("templateID"); + expect(response).toEqual([ + { + id: "id", + versionNumber: 1, + generation: { + instructions: { + prompt: "prompt", + }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + }, + }, + ]); + }); + + test("list (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/alpha/templates/templateID/versions/") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplateVersions.list("templateID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { generation: { instructions: { prompt: "prompt" } } }; + const rawResponseBody = { + id: "id", + versionNumber: 1, + generation: { + instructions: { prompt: "prompt" }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ], + }, + }; + + server + .mockEndpoint() + .post("/alpha/templates/templateID/versions/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaTemplateVersions.create("templateID", { + generation: { + instructions: { + prompt: "prompt", + }, + }, + }); + expect(response).toEqual({ + id: "id", + versionNumber: 1, + generation: { + instructions: { + prompt: "prompt", + }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + }, + }); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { generation: { instructions: { prompt: "prompt" } } }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/templates/templateID/versions/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplateVersions.create("templateID", { + generation: { + instructions: { + prompt: "prompt", + }, + }, + }); + }).rejects.toThrow(Corti.BadRequestError); + }); + + test("create (3)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { generation: { instructions: { prompt: "prompt" } } }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/templates/templateID/versions/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplateVersions.create("templateID", { + generation: { + instructions: { + prompt: "prompt", + }, + }, + }); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { + id: "id", + versionNumber: 1, + generation: { + instructions: { prompt: "prompt" }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ], + }, + }; + + server + .mockEndpoint() + .get("/alpha/templates/templateID/versions/versionID") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaTemplateVersions.get("templateID", "versionID"); + expect(response).toEqual({ + id: "id", + versionNumber: 1, + generation: { + instructions: { + prompt: "prompt", + }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + }, + }); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/alpha/templates/templateID/versions/versionID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplateVersions.get("templateID", "versionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + server + .mockEndpoint() + .delete("/alpha/templates/templateID/versions/versionID") + .respondWith() + .statusCode(200) + .build(); + + const response = await client.alphaTemplateVersions.delete("templateID", "versionID"); + expect(response).toEqual(undefined); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/alpha/templates/templateID/versions/versionID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplateVersions.delete("templateID", "versionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("publish (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { status: "published" }; + + server + .mockEndpoint() + .post("/alpha/templates/templateID/versions/versionID/publish") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaTemplateVersions.publish("templateID", "versionID"); + expect(response).toEqual({ + status: "published", + }); + }); + + test("publish (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/templates/templateID/versions/versionID/publish") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplateVersions.publish("templateID", "versionID"); + }).rejects.toThrow(Corti.NotFoundError); + }); +}); diff --git a/tests/wire/alphaTemplates.test.ts b/tests/wire/alphaTemplates.test.ts new file mode 100644 index 00000000..e041a0f6 --- /dev/null +++ b/tests/wire/alphaTemplates.test.ts @@ -0,0 +1,604 @@ +// This file was auto-generated by Fern from our API Definition. + +import * as Corti from "../../src/api/index"; +import { CortiClient } from "../../src/Client"; +import { mockServerPool } from "../mock-server/MockServerPool"; +import { mockOAuth } from "./mockAuth"; + +describe("AlphaTemplatesClient", () => { + test("list", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = [ + { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { prompt: "prompt" }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ], + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ]; + + server.mockEndpoint().get("/alpha/templates/").respondWith().statusCode(200).jsonBody(rawResponseBody).build(); + + const response = await client.alphaTemplates.list(); + expect(response).toEqual([ + { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { + prompt: "prompt", + }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ]); + }); + + test("create (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { + name: "name", + language: "language", + generation: { instructions: { prompt: "prompt" } }, + }; + const rawResponseBody = { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { prompt: "prompt" }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ], + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }; + + server + .mockEndpoint() + .post("/alpha/templates/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaTemplates.create({ + name: "name", + language: "language", + generation: { + instructions: { + prompt: "prompt", + }, + }, + }); + expect(response).toEqual({ + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { + prompt: "prompt", + }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }); + }); + + test("create (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = { + generation: { instructions: { prompt: "prompt" } }, + name: "name", + language: "language", + }; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .post("/alpha/templates/") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplates.create({ + generation: { + instructions: { + prompt: "prompt", + }, + }, + name: "name", + language: "language", + }); + }).rejects.toThrow(Corti.BadRequestError); + }); + + test("get (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { prompt: "prompt" }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ], + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }; + + server + .mockEndpoint() + .get("/alpha/templates/templateID") + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaTemplates.get("templateID"); + expect(response).toEqual({ + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { + prompt: "prompt", + }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }); + }); + + test("get (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .get("/alpha/templates/templateID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplates.get("templateID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("delete (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + server.mockEndpoint().delete("/alpha/templates/templateID").respondWith().statusCode(200).build(); + + const response = await client.alphaTemplates.delete("templateID"); + expect(response).toEqual(undefined); + }); + + test("delete (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .delete("/alpha/templates/templateID") + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplates.delete("templateID"); + }).rejects.toThrow(Corti.NotFoundError); + }); + + test("update (1)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { prompt: "prompt" }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { contentPrompt: "contentPrompt" }, + outputSchema: { type: "string" }, + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }, + ], + }, + }, + createdAt: "2024-01-15T09:30:00Z", + updatedAt: "2024-01-15T09:30:00Z", + }; + + server + .mockEndpoint() + .patch("/alpha/templates/templateID") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(200) + .jsonBody(rawResponseBody) + .build(); + + const response = await client.alphaTemplates.update("templateID"); + expect(response).toEqual({ + id: "id", + inheritedFromId: "inheritedFromId", + autoGenerated: true, + name: "name", + description: "description", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + instructions: { + prompt: "prompt", + }, + sections: [ + { + id: "id", + name: "name", + language: "language", + labels: ["labels"], + publishedVersion: { + id: "id", + versionNumber: 1, + generation: { + heading: "heading", + instructions: { + contentPrompt: "contentPrompt", + }, + outputSchema: { + type: "string", + }, + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }, + ], + }, + }, + createdAt: new Date("2024-01-15T09:30:00.000Z"), + updatedAt: new Date("2024-01-15T09:30:00.000Z"), + }); + }); + + test("update (2)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/alpha/templates/templateID") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(400) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplates.update("templateID"); + }).rejects.toThrow(Corti.BadRequestError); + }); + + test("update (3)", async () => { + const server = mockServerPool.createServer(); + mockOAuth(server); + + const client = new CortiClient({ + maxRetries: 0, + clientId: "client_id", + clientSecret: "client_secret", + tenantName: "test", + environment: { base: server.baseUrl, wss: server.baseUrl, login: server.baseUrl, agents: server.baseUrl }, + }); + const rawRequestBody = {}; + const rawResponseBody = { key: "value" }; + + server + .mockEndpoint() + .patch("/alpha/templates/templateID") + .jsonBody(rawRequestBody) + .respondWith() + .statusCode(404) + .jsonBody(rawResponseBody) + .build(); + + await expect(async () => { + return await client.alphaTemplates.update("templateID"); + }).rejects.toThrow(Corti.NotFoundError); + }); +});