Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .codegen.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "engineHash": "264bdc9", "specHash": "6886603", "version": "1.9.0" }
{ "engineHash": "ce7ab17", "specHash": "6886603", "version": "1.9.0" }
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ Embrace the new generation of Box SDKs and unlock the full potential of the Box
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Box TypeScript SDK GENERATED](#box-typescript-sdk-generated)
- [Table of contents](#table-of-contents)
- [Installing](#installing)
- [Getting Started](#getting-started)
- [Documentation](#documentation)
- [Upgrades](#upgrades)
- [Integration Tests](#integration-tests)
- [Running integration tests locally](#running-integration-tests-locally)
- [Create Custom Application](#create-custom-application)
- [Create Platform Application](#create-platform-application)
- [Export configuration](#export-configuration)
- [Questions, Bugs, and Feature Requests?](#questions-bugs-and-feature-requests)
- [Copyright and License](#copyright-and-license)
Expand Down Expand Up @@ -107,7 +109,7 @@ Upgrading from our legacy SDKs to the new generation SDKs is a straightforward p

## Running integration tests locally

### Create Custom Application
### Create Platform Application

To run integration tests locally you will need a `Custom App` created in the [Box Developer
Console](https://app.box.com/developers/console) with `Server Authentication (with JWT)` selected as authentication method.
Expand Down
5 changes: 3 additions & 2 deletions docs/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->

- [Authentication](#authentication)
- [Authentication methods](#authentication-methods)
- [Developer Token](#developer-token)
- [JWT Auth](#jwt-auth)
Expand Down Expand Up @@ -54,7 +55,7 @@ console.log(`My user ID is ${me.id}`);

## JWT Auth

Before using JWT Auth make sure you set up correctly your Box App.
Before using JWT Auth make sure you set up correctly your Box platform app.
The guide with all required steps can be found here: [Setup with JWT][jwt_guide]

### Authenticate Enterprise
Expand Down Expand Up @@ -164,7 +165,7 @@ const userClient = new BoxClient({ auth: jwtAuth });

## Client Credentials Grant

Before using Client Credentials Grant Auth make sure you set up correctly your Box App.
Before using Client Credentials Grant Auth make sure you set up correctly your Box platform app.
The guide with all required steps can be found here: [Setup with Client Credentials Grant][ccg_guide]

Client Credentials Grant Auth method allows you to obtain an access token by having client credentials
Expand Down
185 changes: 94 additions & 91 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/box/oauth.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export class BoxOAuth implements Authentication {
return token!;
}
/**
* Get a new access token for the app user.
* Get a new access token for the platform app user.
* @param {NetworkSession} networkSession An object to keep network session state
* @returns {Promise<AccessToken>}
*/
Expand Down
8 changes: 4 additions & 4 deletions src/client.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ import { IntegrationMappingsManager } from './managers/integrationMappings.gener
import { AiManager } from './managers/ai.generated.js';
import { Authentication } from './networking/auth.generated.js';
import { NetworkSession } from './networking/network.generated.js';
import { BoxSdkError } from './box/errors.js';
import { FetchOptions } from './networking/fetchOptions.generated.js';
import { FetchResponse } from './networking/fetchResponse.generated.js';
import { BaseUrls } from './networking/baseUrls.generated.js';
import { ProxyConfig } from './networking/proxyConfig.generated.js';
import { AgentOptions } from './internal/utils.js';
import { Interceptor } from './networking/interceptors.generated.js';
import { FetchOptions } from './networking/fetchOptions.generated.js';
import { FetchResponse } from './networking/fetchResponse.generated.js';
import { fetch } from './networking/fetch.js';
import { SerializedData } from './serialization/json.js';
import { sdIsEmpty } from './serialization/json.js';
import { sdIsBoolean } from './serialization/json.js';
Expand Down Expand Up @@ -584,7 +584,7 @@ export class BoxClient {
responseFormat: fetchOptions.responseFormat,
followRedirects: fetchOptions.followRedirects,
});
return (await fetch(enrichedFetchOptions)) as FetchResponse;
return await networkSession.networkClient.fetch(enrichedFetchOptions);
}
/**
* Create a new client to impersonate user with the provided ID. All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified.
Expand Down
170 changes: 87 additions & 83 deletions src/managers/ai.generated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ import { ResponseFormat } from '../networking/fetchOptions.generated.js';
import { AiResponseFull } from '../schemas/aiResponseFull.generated.js';
import { ClientError } from '../schemas/clientError.generated.js';
import { AiAsk } from '../schemas/aiAsk.generated.js';
import { BoxSdkError } from '../box/errors.js';
import { AiResponse } from '../schemas/aiResponse.generated.js';
import { AiTextGen } from '../schemas/aiTextGen.generated.js';
import { AiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen } from '../schemas/aiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen.generated.js';
import { AiExtract } from '../schemas/aiExtract.generated.js';
import { AiExtractResponse } from '../schemas/aiExtractResponse.generated.js';
import { AiExtractStructured } from '../schemas/aiExtractStructured.generated.js';
import { BoxSdkError } from '../box/errors.js';
import { Authentication } from '../networking/auth.generated.js';
import { NetworkSession } from '../networking/network.generated.js';
import { FetchOptions } from '../networking/fetchOptions.generated.js';
import { FetchResponse } from '../networking/fetchResponse.generated.js';
import { prepareParams } from '../internal/utils.js';
import { toString } from '../internal/utils.js';
import { ByteStream } from '../internal/utils.js';
import { CancellationToken } from '../internal/utils.js';
import { FetchOptions } from '../networking/fetchOptions.generated.js';
import { FetchResponse } from '../networking/fetchResponse.generated.js';
import { fetch } from '../networking/fetch.js';
import { SerializedData } from '../serialization/json.js';
import { sdToJson } from '../serialization/json.js';
import { sdIsEmpty } from '../serialization/json.js';
Expand Down Expand Up @@ -332,22 +331,23 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/ask',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiAsk(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
)) as FetchResponse;
const response: FetchResponse =
await this.networkSession.networkClient.fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/ask',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiAsk(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
);
return {
...deserializeAiResponseFull(response.data!),
rawData: response.data!,
Expand All @@ -372,22 +372,23 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/text_gen',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiTextGen(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
)) as FetchResponse;
const response: FetchResponse =
await this.networkSession.networkClient.fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/text_gen',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiTextGen(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
);
return {
...deserializeAiResponse(response.data!),
rawData: response.data!,
Expand Down Expand Up @@ -420,21 +421,22 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai_agent_default',
) as string,
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
)) as FetchResponse;
const response: FetchResponse =
await this.networkSession.networkClient.fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai_agent_default',
) as string,
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
);
return {
...deserializeAiAgentAskOrAiAgentExtractOrAiAgentExtractStructuredOrAiAgentTextGen(
response.data!,
Expand Down Expand Up @@ -463,22 +465,23 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/extract',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiExtract(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
)) as FetchResponse;
const response: FetchResponse =
await this.networkSession.networkClient.fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/extract',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiExtract(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
);
return {
...deserializeAiResponse(response.data!),
rawData: response.data!,
Expand Down Expand Up @@ -508,22 +511,23 @@ export class AiManager {
const headersMap: {
readonly [key: string]: string;
} = prepareParams({ ...{}, ...headers.extraHeaders });
const response: FetchResponse = (await fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/extract_structured',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiExtractStructured(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
)) as FetchResponse;
const response: FetchResponse =
await this.networkSession.networkClient.fetch(
new FetchOptions({
url: ''.concat(
this.networkSession.baseUrls.baseUrl,
'/2.0/ai/extract_structured',
) as string,
method: 'POST',
headers: headersMap,
data: serializeAiExtractStructured(requestBody),
contentType: 'application/json',
responseFormat: 'json' as ResponseFormat,
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}),
);
return {
...deserializeAiExtractResponse(response.data!),
rawData: response.data!,
Expand Down
Loading
Loading