3
3
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
4
4
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5
5
6
- - [ Introduction] ( #introduction )
7
- - [ Installation] ( #installation )
8
- - [ Highlighting the Key Differences] ( #highlighting-the-key-differences )
9
- - [ Native support for async-await and Promises] ( #native-support-for-async-await-and-promises )
10
- - [ Embracing Explicitly Defined Schemas] ( #embracing-explicitly-defined-schemas )
11
- - [ Immutable design] ( #immutable-design )
12
- - [ Diving into Authentication] ( #diving-into-authentication )
13
- - [ Developer Token] ( #developer-token )
14
- - [ JWT Authentication] ( #jwt-authentication )
15
- - [ Leveraging the JWT Configuration File] ( #leveraging-the-jwt-configuration-file )
16
- - [ Manually Providing JWT Configuration] ( #manually-providing-jwt-configuration )
17
- - [ User Authentication Simplified] ( #user-authentication-simplified )
18
- - [ Client Credentials Grant] ( #client-credentials-grant )
19
- - [ Service Account Token Acquisition] ( #service-account-token-acquisition )
20
- - [ User Token Acquisition] ( #user-token-acquisition )
21
- - [ Smooth Switching between Service Account and User] ( #smooth-switching-between-service-account-and-user )
22
- - [ OAuth 2.0 Authentication] ( #oauth-20-authentication )
23
- - [ Fetching the Authorization URL] ( #fetching-the-authorization-url )
24
- - [ Seamless Authentication] ( #seamless-authentication )
25
- - [ Customizable Token Storage and Retrieval Callbacks] ( #customizable-token-storage-and-retrieval-callbacks )
26
- - [ Downscope token] ( #downscope-token )
27
- - [ Revoke token] ( #revoke-token )
28
- - [ Configuration] ( #configuration )
29
- - [ As-User header] ( #as-user-header )
30
- - [ Custom Base URLs] ( #custom-base-urls )
31
- - [ Convenience methods] ( #convenience-methods )
32
- - [ Webhook validation] ( #webhook-validation )
33
- - [ Chunked upload of big files] ( #chunked-upload-of-big-files )
6
+ - [ Migration Guide: From ` Box Node SDK ` to ` Box TypeScript SDK ` ] ( #migration-guide-from-box-node-sdk-to-box-typescript-sdk )
7
+ - [ Introduction] ( #introduction )
8
+ - [ Installation] ( #installation )
9
+ - [ Highlighting the Key Differences] ( #highlighting-the-key-differences )
10
+ - [ Native support for async-await and Promises] ( #native-support-for-async-await-and-promises )
11
+ - [ Embracing Explicitly Defined Schemas] ( #embracing-explicitly-defined-schemas )
12
+ - [ Immutable design] ( #immutable-design )
13
+ - [ Diving into Authentication] ( #diving-into-authentication )
14
+ - [ Developer Token] ( #developer-token )
15
+ - [ JWT Authentication] ( #jwt-authentication )
16
+ - [ Leveraging the JWT Configuration File] ( #leveraging-the-jwt-configuration-file )
17
+ - [ Manually Providing JWT Configuration] ( #manually-providing-jwt-configuration )
18
+ - [ User Authentication Simplified] ( #user-authentication-simplified )
19
+ - [ Client Credentials Grant] ( #client-credentials-grant )
20
+ - [ Service Account Token Acquisition] ( #service-account-token-acquisition )
21
+ - [ User Token Acquisition] ( #user-token-acquisition )
22
+ - [ Smooth Switching between Service Account and User] ( #smooth-switching-between-service-account-and-user )
23
+ - [ OAuth 2.0 Authentication] ( #oauth-20-authentication )
24
+ - [ Fetching the Authorization URL] ( #fetching-the-authorization-url )
25
+ - [ Seamless Authentication] ( #seamless-authentication )
26
+ - [ Customizable Token Storage and Retrieval Callbacks] ( #customizable-token-storage-and-retrieval-callbacks )
27
+ - [ Downscope token] ( #downscope-token )
28
+ - [ Revoke token] ( #revoke-token )
29
+ - [ Configuration] ( #configuration )
30
+ - [ As-User header] ( #as-user-header )
31
+ - [ Custom Base URLs] ( #custom-base-urls )
32
+ - [ Convenience methods] ( #convenience-methods )
33
+ - [ Webhook validation] ( #webhook-validation )
34
+ - [ Chunked upload of big files] ( #chunked-upload-of-big-files )
34
35
35
36
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
36
37
@@ -144,7 +145,7 @@ var client = sdk.getBasicClient('YOUR-DEVELOPER-TOKEN');
144
145
The new SDK offers a more streamlined approach:
145
146
146
147
``` typescript
147
- const { BoxClient, BoxDeveloperTokenAuth } = require ( ' box-typescript-sdk-gen' ) ;
148
+ import { BoxClient , BoxDeveloperTokenAuth } from ' box-typescript-sdk-gen' ;
148
149
149
150
const auth = new BoxDeveloperTokenAuth ({ token: ' DEVELOPER_TOKEN_GOES_HERE' });
150
151
const client = new BoxClient ({ auth });
@@ -171,7 +172,7 @@ var serviceAccountClient = sdk.getAppAuthClient('enterprise');
171
172
The new SDK provides a more organized approach:
172
173
173
174
``` typescript
174
- const { BoxClient, BoxJwtAuth, JwtConfig } = require ( ' box-typescript-sdk-gen' ) ;
175
+ import { BoxClient , BoxJwtAuth , JwtConfig } from ' box-typescript-sdk-gen' ;
175
176
176
177
const jwtConfig = JwtConfig .fromConfigFile (' /path/to/config.json' );
177
178
const auth = new BoxJwtAuth ({ config: jwtConfig });
@@ -207,7 +208,7 @@ var serviceAccountClient = sdk.getAppAuthClient(
207
208
The new SDK introduces a more structured approach:
208
209
209
210
``` typescript
210
- const { BoxJwtAuth, JwtConfig } = require ( ' box-typescript-sdk-gen' ) ;
211
+ import { BoxJwtAuth , JwtConfig } from ' box-typescript-sdk-gen' ;
211
212
212
213
const jwtConfig = new JwtConfig ({
213
214
clientId: ' YOUR_CLIENT_ID' ,
@@ -269,7 +270,7 @@ const client = sdk.getAnonymousClient();
269
270
The new SDK offers a more organized structure:
270
271
271
272
``` typescript
272
- const { CcgConfig, BoxCcgAuth, BoxClient } = require ( ' box-typescript-sdk-gen' ) ;
273
+ import { CcgConfig , BoxCcgAuth , BoxClient } from ' box-typescript-sdk-gen' ;
273
274
274
275
const ccgConfig = new CcgConfig ({
275
276
clientId: ' YOUR_CLIENT_ID' ,
@@ -303,7 +304,7 @@ const client = sdk.getCCGClientForUser('USER_ID');
303
304
The new SDK streamlines the process:
304
305
305
306
``` typescript
306
- const { CcgConfig, BoxCcgAuth, BoxClient } = require ( ' box-typescript-sdk-gen' ) ;
307
+ import { CcgConfig , BoxCcgAuth , BoxClient } from ' box-typescript-sdk-gen' ;
307
308
308
309
const ccgConfig = new CcgConfig ({
309
310
clientId: ' YOUR_CLIENT_ID' ,
@@ -369,7 +370,7 @@ var authorize_url = sdk.getAuthorizeURL({
369
370
The new SDK provides more flexibility:
370
371
371
372
``` typescript
372
- const { BoxOAuth, OAuthConfig } = require ( ' box-typescript-sdk-gen' ) ;
373
+ import { BoxOAuth , OAuthConfig } from ' box-typescript-sdk-gen' ;
373
374
374
375
const config = new OAuthConfig ({
375
376
clientId: ' OAUTH_CLIENT_ID' ,
@@ -452,13 +453,9 @@ TokenStore.prototype.clear = function (callback) {
452
453
The new SDK allows developers to define custom classes for token storage:
453
454
454
455
``` typescript
455
- const { BoxOAuth } = require (' box-typescript-sdk-gen' );
456
- const {
457
- TokenStorage,
458
- } = require (' box-typescript-sdk-gen/lib/box/tokenStorage.generated.js' );
459
- const {
460
- AccessToken,
461
- } = require (' box-typescript-sdk-gen/lib/schemas/accessToken.generated.js' );
456
+ import { BoxOAuth } from ' box-typescript-sdk-gen' ;
457
+ import { TokenStorage } from ' box-typescript-sdk-gen/box/tokenStorage.generated' ;
458
+ import { AccessToken } from ' box-typescript-sdk-gen/schemas/accessToken.generated' ;
462
459
463
460
class CustomTokenStorage extends TokenStorage {
464
461
async store(token : AccessToken ): Promise <undefined > {
@@ -647,7 +644,7 @@ as the `file` parameter, and the `fileName` and `fileSize` parameters are now pa
647
644
The ` parentFolderId ` parameter is also required to specify the folder where the file will be uploaded.
648
645
649
646
``` typescript
650
- import { File } from ' box-typescript-sdk-gen/lib/ schemas/file.generated.js ' ;
647
+ import { File } from ' box-typescript-sdk-gen/schemas/file.generated' ;
651
648
652
649
var fileByteStream = fs .createReadStream (' /path/to/file.txt' );
653
650
var fileName = ' new_name.txt' ;
0 commit comments