Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
988cfb4
SDK regeneration
fern-api[bot] Apr 13, 2026
e8936dc
SDK regeneration
fern-api[bot] Apr 14, 2026
1d5a4fd
SDK regeneration
fern-api[bot] Apr 14, 2026
b434585
SDK regeneration
fern-api[bot] Apr 14, 2026
11d3541
SDK regeneration
fern-api[bot] Apr 14, 2026
9cb68db
SDK regeneration
fern-api[bot] Apr 15, 2026
ecfbe76
SDK regeneration
fern-api[bot] Apr 15, 2026
80c5562
SDK regeneration
fern-api[bot] Apr 15, 2026
736e819
SDK regeneration
fern-api[bot] Apr 15, 2026
470d8b3
SDK regeneration
fern-api[bot] Apr 15, 2026
449c6f0
SDK regeneration
fern-api[bot] Apr 16, 2026
66d099e
SDK regeneration
fern-api[bot] Apr 23, 2026
ac11ac6
SDK regeneration
fern-api[bot] Apr 23, 2026
e97ccfe
SDK regeneration
fern-api[bot] Apr 23, 2026
8fab2ef
SDK regeneration
fern-api[bot] Apr 28, 2026
aa8306d
SDK regeneration
fern-api[bot] Apr 28, 2026
51fa448
Merge branch 'master' into new-new-templates-n-sections
tve-corti Apr 28, 2026
f083cbb
fix: add default tenant
tve-corti Apr 28, 2026
a6dc04c
SDK regeneration
fern-api[bot] Apr 28, 2026
222f74e
SDK regeneration
fern-api[bot] Apr 28, 2026
006a9ec
SDK regeneration
fern-api[bot] Apr 28, 2026
5e57d7d
SDK regeneration
fern-api[bot] Apr 28, 2026
63d60dc
SDK regeneration
fern-api[bot] Apr 28, 2026
00c5a82
SDK regeneration
fern-api[bot] May 5, 2026
1b6b665
Merge branch 'master' into new-new-templates-n-sections
tve-corti May 5, 2026
636367a
SDK regeneration
fern-api[bot] May 5, 2026
941413f
SDK regeneration
fern-api[bot] May 5, 2026
53f4146
SDK regeneration
fern-api[bot] May 6, 2026
30d0943
SDK regeneration
fern-api[bot] May 6, 2026
55dba97
SDK regeneration
fern-api[bot] May 6, 2026
da07604
SDK regeneration
fern-api[bot] May 6, 2026
3827ac8
SDK regeneration
fern-api[bot] May 6, 2026
e4216c2
SDK regeneration
fern-api[bot] May 6, 2026
12a4ee4
SDK regeneration
fern-api[bot] May 11, 2026
d7d09c5
SDK regeneration
fern-api[bot] May 12, 2026
b461a86
SDK regeneration
fern-api[bot] May 12, 2026
2f9a8c3
SDK regeneration
fern-api[bot] May 12, 2026
0876fbc
SDK regeneration
fern-api[bot] May 12, 2026
3496247
SDK regeneration
fern-api[bot] May 13, 2026
600498b
SDK regeneration
fern-api[bot] May 13, 2026
88e69ef
SDK regeneration
fern-api[bot] May 13, 2026
b5d3282
SDK regeneration
fern-api[bot] May 13, 2026
afe66ea
SDK regeneration
fern-api[bot] May 13, 2026
526e4ee
SDK regeneration
fern-api[bot] May 13, 2026
ac0e2a1
SDK regeneration
fern-api[bot] May 13, 2026
4624ac1
SDK regeneration
fern-api[bot] May 13, 2026
cb12adf
SDK regeneration
fern-api[bot] May 18, 2026
0de79fe
SDK regeneration
fern-api[bot] May 18, 2026
e09efc4
SDK regeneration
fern-api[bot] May 18, 2026
909dc67
SDK regeneration
fern-api[bot] May 18, 2026
461557e
SDK regeneration
fern-api[bot] May 18, 2026
5b6ce1e
SDK regeneration
fern-api[bot] May 18, 2026
b497f78
SDK regeneration
fern-api[bot] May 18, 2026
bdb3a41
SDK regeneration
fern-api[bot] May 18, 2026
9b19d94
SDK regeneration
fern-api[bot] May 19, 2026
90f1735
SDK regeneration
fern-api[bot] May 20, 2026
0d7ea50
SDK regeneration
fern-api[bot] May 20, 2026
2b6ced9
SDK regeneration
fern-api[bot] May 20, 2026
300744c
SDK regeneration
fern-api[bot] May 20, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions .fern/metadata.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"cliVersion": "4.86.1",
"cliVersion": "5.23.3",
"generatorName": "fernapi/fern-typescript-node-sdk",
"generatorVersion": "3.54.0",
"generatorConfig": {
Expand All @@ -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": {
Expand All @@ -32,6 +34,6 @@
}
}
},
"originGitCommit": "23bce53307f0836f2dcd50e82ef0aba136e7ec2f",
"originGitCommit": "9fb3309768e7f09a22bb6b9464f15c6091659d0f",
"sdkVersion": "0.0.0-dev"
}
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions src/api/errors/UnprocessableEntityError.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
44 changes: 4 additions & 40 deletions src/api/resources/agents/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
126 changes: 126 additions & 0 deletions src/api/resources/documents/client/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCode
import * as errors from "../../../../errors/index.js";
import * as serializers from "../../../../serialization/index.js";
import * as Corti from "../../../index.js";
import { SectionsClient } from "../resources/sections/client/Client.js";
import { TemplatesClient } from "../resources/templates/client/Client.js";

export declare namespace DocumentsClient {
export type Options = BaseClientOptions;
Expand All @@ -17,12 +19,24 @@ export declare namespace DocumentsClient {

export class DocumentsClient {
protected readonly _options: NormalizedClientOptionsWithAuth<DocumentsClient.Options>;
protected _templates: TemplatesClient | undefined;
protected _sections: SectionsClient | undefined;

constructor(options: DocumentsClient.Options) {
this._options = normalizeClientOptionsWithAuth(options);
}

public get templates(): TemplatesClient {
return (this._templates ??= new TemplatesClient(this._options));
}

public get sections(): SectionsClient {
return (this._sections ??= new SectionsClient(this._options));
}

/**
* @deprecated
*
* List Documents
*
* @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
Expand Down Expand Up @@ -123,6 +137,8 @@ export class DocumentsClient {
}

/**
* @deprecated
*
* This endpoint offers different ways to generate a document. Find guides to document generation [here](/textgen/documents-standard).
*
* @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
Expand Down Expand Up @@ -246,6 +262,8 @@ export class DocumentsClient {
}

/**
* @deprecated
*
* Get Document.
*
* @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
Expand Down Expand Up @@ -354,6 +372,8 @@ export class DocumentsClient {
}

/**
* @deprecated
*
* @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
* @param {Corti.Uuid} documentId - The document ID representing the context for the request. Must be a valid UUID.
* @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
Expand Down Expand Up @@ -451,6 +471,8 @@ export class DocumentsClient {
}

/**
* @deprecated
*
* @param {Corti.Uuid} id - The unique identifier of the interaction. Must be a valid UUID.
* @param {Corti.Uuid} documentId - The document ID representing the context for the request. Must be a valid UUID.
* @param {Corti.DocumentsUpdateRequest} request
Expand Down Expand Up @@ -564,4 +586,108 @@ export class DocumentsClient {
"/interactions/{id}/documents/{documentId}",
);
}

/**
* Generates a structured document using one of three template-supply paths: a stored template reference (optionally with runtime overrides), an ad-hoc assembly of stored sections, or a fully inline dynamic template. Exactly one of `templateRef`, `assemblyTemplate`, or `dynamicTemplate` must be provided.
*
* With the exception of the plain `templateRef` path (no overrides), every call persists a new auto-generated template aggregate that snapshots the resolved content. The snapshot is drift-proof: subsequent edits to base templates or sections do not affect previously generated documents.
*
* @param {Corti.GuidedDocumentRequest} request
* @param {DocumentsClient.RequestOptions} requestOptions - Request-specific configuration.
*
* @throws {@link Corti.BadRequestError}
* @throws {@link Corti.NotFoundError}
* @throws {@link Corti.UnprocessableEntityError}
* @throws {@link Corti.InternalServerError}
*
* @example
* await client.documents.generate({
* outputLanguage: "outputLanguage",
* templateRef: {
* templateId: "templateId"
* }
* })
*/
public generate(
request: Corti.GuidedDocumentRequest,
requestOptions?: DocumentsClient.RequestOptions,
): core.HttpResponsePromise<Corti.CreateEphemeralDocumentResponse> {
return core.HttpResponsePromise.fromPromise(this.__generate(request, requestOptions));
}

private async __generate(
request: Corti.GuidedDocumentRequest,
requestOptions?: DocumentsClient.RequestOptions,
): Promise<core.WithRawResponse<Corti.CreateEphemeralDocumentResponse>> {
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,
"documents/",
),
method: "POST",
headers: _headers,
contentType: "application/json",
queryParameters: requestOptions?.queryParams,
requestType: "json",
body: serializers.GuidedDocumentRequest.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.CreateEphemeralDocumentResponse.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);
case 422:
throw new Corti.UnprocessableEntityError(_response.error.body, _response.rawResponse);
case 500:
throw new Corti.InternalServerError(
serializers.ErrorResponse.parseOrThrow(_response.error.body, {
unrecognizedObjectKeys: "passthrough",
allowUnrecognizedUnionMembers: true,
allowUnrecognizedEnumValues: true,
skipValidation: true,
breadcrumbsPrefix: ["response"],
}),
_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", "/documents/");
}
}
1 change: 1 addition & 0 deletions src/api/resources/documents/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from "./client/index.js";
export * from "./resources/index.js";
4 changes: 4 additions & 0 deletions src/api/resources/documents/resources/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./sections/client/requests/index.js";
export * as sections from "./sections/index.js";
export * from "./templates/client/requests/index.js";
export * as templates from "./templates/index.js";
Loading
Loading