From 335008d6aada1344f724cc8cbe22d9cc4f1aebd9 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Tue, 15 Jul 2025 06:14:03 -0700 Subject: [PATCH 1/5] feat: Support ESM build and tree-shaking (box/box-codegen#762) --- .codegen.json | 2 +- .gitignore | 3 +- docs/authentication.md | 52 ++-- migration-guide.md | 81 +++--- package-lock.json | 190 ++++++------ package.json | 22 +- test-browser/init.ts | 22 ++ test-browser/package-lock.json | 491 ++++++++++++++++++++++++++++++++ test-browser/package.json | 6 +- test-browser/pages/api/tests.ts | 33 --- test-browser/src/app/page.tsx | 51 +--- tsconfig.esm.json | 17 ++ 12 files changed, 728 insertions(+), 242 deletions(-) create mode 100644 test-browser/init.ts delete mode 100644 test-browser/pages/api/tests.ts create mode 100644 tsconfig.esm.json diff --git a/.codegen.json b/.codegen.json index 72a983c9..1004a0b3 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "ba4dd3b", "specHash": "8402463", "version": "1.16.0" } +{ "engineHash": "7d973e2", "specHash": "8402463", "version": "1.16.0" } diff --git a/.gitignore b/.gitignore index 0d0aabc6..a1ee7087 100644 --- a/.gitignore +++ b/.gitignore @@ -130,4 +130,5 @@ dist .pnp.* # box-gen-sdk -lib/ \ No newline at end of file +lib/ +lib-esm/ \ No newline at end of file diff --git a/docs/authentication.md b/docs/authentication.md index 1ecdd932..98f7b340 100644 --- a/docs/authentication.md +++ b/docs/authentication.md @@ -42,10 +42,8 @@ object with the `token` set to the developer token and construct the client with ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { - BoxDeveloperTokenAuth, -} = require('box-typescript-sdk-gen/lib/box/developerTokenAuth.generated.js'); +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxDeveloperTokenAuth } from 'box-typescript-sdk-gen/box/developerTokenAuth.generated'; const auth = new BoxDeveloperTokenAuth({ token: 'DEVELOPER_TOKEN_GOES_HERE' }); const client = new BoxClient({ auth }); @@ -78,11 +76,11 @@ Service Account. Call one of static `BoxJwtAuth` method: or `JwtConfig.fromConfigJsonString(configJsonString)` and pass JSON config file content as string. ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxJwtAuth, JwtConfig, -} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js'); +} from 'box-typescript-sdk-gen/box/jwtAuth.generated'; const jwtConfig = JwtConfig.fromConfigFile('/path/to/settings.json'); const jwtAuth = new BoxJwtAuth({ config: jwtConfig }); @@ -95,11 +93,11 @@ console.log(`My user ID is ${me.id}`); Otherwise, you'll need to provide the necessary configuration fields directly to the `JwtConfig` constructor: ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxJwtAuth, JwtConfig, -} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js'); +} from 'box-typescript-sdk-gen/box/jwtAuth.generated'; const jwtConfig = new JwtConfig({ clientId: 'YOUR_CLIENT_ID', @@ -127,11 +125,11 @@ Clients for making calls as an App User can be created with the same JSON JWT co which is authenticated as the user with provided id, leaving the original object unchanged. ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxJwtAuth, JwtConfig, -} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js'); +} from 'box-typescript-sdk-gen/box/jwtAuth.generated'; const jwtConfig = JwtConfig.fromConfigFile('/path/to/settings.json'); const jwtAuth = new BoxJwtAuth({ config: jwtConfig }); @@ -144,11 +142,11 @@ constructor as in the above examples, similarly to creating a Service Account cl `userId` instead of `enterpriseId` when constructing the auth config instance: ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxJwtAuth, JwtConfig, -} = require('box-typescript-sdk-gen/lib/box/jwtAuth.generated.js'); +} from 'box-typescript-sdk-gen/box/jwtAuth.generated'; const jwtConfig = new JwtConfig({ clientId: 'YOUR_CLIENT_ID', @@ -177,11 +175,11 @@ and secret with enterprise or user ID, which allows you to work using service or You can use `CCGAuth` to initialize a client object the same way as for other authentication types: ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxCcgAuth, CcgConfig, -} = require('box-typescript-sdk-gen/lib/box/ccgAuth.generated.js'); +} from 'box-typescript-sdk-gen/box/ccgAuth.generated'; const ccgConfig = new CcgConfig({ userId: 'YOUR_USER_ID', @@ -206,11 +204,11 @@ are not accessible in any other account by default, and vice versa. To obtain service account you will have to provide enterprise ID with client id and secret: ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxCcgAuth, CcgConfig, -} = require('box-typescript-sdk-gen/lib/box/ccgAuth.generated.js'); +} from 'box-typescript-sdk-gen/box/ccgAuth.generated'; const ccgConfig = new CcgConfig({ enterpriseId: 'YOUR_ENTERPRISE_ID', @@ -230,11 +228,11 @@ select `Generate user access tokens`. Do not forget to re-authorize application To obtain user account you will have to provide user ID with client id and secret. ```js -const { BoxClient } = require('box-typescript-sdk-gen/lib/client.generated.js'); -const { +import { BoxClient } from 'box-typescript-sdk-gen/client.generated'; +import { BoxCcgAuth, CcgConfig, -} = require('box-typescript-sdk-gen/lib/box/ccgAuth.generated.js'); +} from 'box-typescript-sdk-gen/box/ccgAuth.generated'; const ccgConfig = new CcgConfig({ userId: 'YOUR_USER_ID', @@ -284,10 +282,10 @@ browser or web view) in order to obtain an auth code. ```js -const { +import { BoxOAuth, OAuthConfig, -} = require('box-typescript-sdk-gen/lib/box/oauth.generated.js'); +} from 'box-typescript-sdk-gen/box/oauth.generated'; const config = new OAuthConfig({ clientId: 'OAUTH_CLIENT_ID', diff --git a/migration-guide.md b/migration-guide.md index ca8ca5c4..f6916da3 100644 --- a/migration-guide.md +++ b/migration-guide.md @@ -3,34 +3,35 @@ -- [Introduction](#introduction) -- [Installation](#installation) -- [Highlighting the Key Differences](#highlighting-the-key-differences) - - [Native support for async-await and Promises](#native-support-for-async-await-and-promises) - - [Embracing Explicitly Defined Schemas](#embracing-explicitly-defined-schemas) - - [Immutable design](#immutable-design) -- [Diving into Authentication](#diving-into-authentication) - - [Developer Token](#developer-token) - - [JWT Authentication](#jwt-authentication) - - [Leveraging the JWT Configuration File](#leveraging-the-jwt-configuration-file) - - [Manually Providing JWT Configuration](#manually-providing-jwt-configuration) - - [User Authentication Simplified](#user-authentication-simplified) - - [Client Credentials Grant](#client-credentials-grant) - - [Service Account Token Acquisition](#service-account-token-acquisition) - - [User Token Acquisition](#user-token-acquisition) - - [Smooth Switching between Service Account and User](#smooth-switching-between-service-account-and-user) - - [OAuth 2.0 Authentication](#oauth-20-authentication) - - [Fetching the Authorization URL](#fetching-the-authorization-url) - - [Seamless Authentication](#seamless-authentication) - - [Customizable Token Storage and Retrieval Callbacks](#customizable-token-storage-and-retrieval-callbacks) - - [Downscope token](#downscope-token) - - [Revoke token](#revoke-token) -- [Configuration](#configuration) - - [As-User header](#as-user-header) - - [Custom Base URLs](#custom-base-urls) -- [Convenience methods](#convenience-methods) - - [Webhook validation](#webhook-validation) - - [Chunked upload of big files](#chunked-upload-of-big-files) +- [Migration Guide: From `Box Node SDK` to `Box TypeScript SDK`](#migration-guide-from-box-node-sdk-to-box-typescript-sdk) + - [Introduction](#introduction) + - [Installation](#installation) + - [Highlighting the Key Differences](#highlighting-the-key-differences) + - [Native support for async-await and Promises](#native-support-for-async-await-and-promises) + - [Embracing Explicitly Defined Schemas](#embracing-explicitly-defined-schemas) + - [Immutable design](#immutable-design) + - [Diving into Authentication](#diving-into-authentication) + - [Developer Token](#developer-token) + - [JWT Authentication](#jwt-authentication) + - [Leveraging the JWT Configuration File](#leveraging-the-jwt-configuration-file) + - [Manually Providing JWT Configuration](#manually-providing-jwt-configuration) + - [User Authentication Simplified](#user-authentication-simplified) + - [Client Credentials Grant](#client-credentials-grant) + - [Service Account Token Acquisition](#service-account-token-acquisition) + - [User Token Acquisition](#user-token-acquisition) + - [Smooth Switching between Service Account and User](#smooth-switching-between-service-account-and-user) + - [OAuth 2.0 Authentication](#oauth-20-authentication) + - [Fetching the Authorization URL](#fetching-the-authorization-url) + - [Seamless Authentication](#seamless-authentication) + - [Customizable Token Storage and Retrieval Callbacks](#customizable-token-storage-and-retrieval-callbacks) + - [Downscope token](#downscope-token) + - [Revoke token](#revoke-token) + - [Configuration](#configuration) + - [As-User header](#as-user-header) + - [Custom Base URLs](#custom-base-urls) + - [Convenience methods](#convenience-methods) + - [Webhook validation](#webhook-validation) + - [Chunked upload of big files](#chunked-upload-of-big-files) @@ -144,7 +145,7 @@ var client = sdk.getBasicClient('YOUR-DEVELOPER-TOKEN'); The new SDK offers a more streamlined approach: ```typescript -const { BoxClient, BoxDeveloperTokenAuth } = require('box-typescript-sdk-gen'); +import { BoxClient, BoxDeveloperTokenAuth } from 'box-typescript-sdk-gen'; const auth = new BoxDeveloperTokenAuth({ token: 'DEVELOPER_TOKEN_GOES_HERE' }); const client = new BoxClient({ auth }); @@ -171,7 +172,7 @@ var serviceAccountClient = sdk.getAppAuthClient('enterprise'); The new SDK provides a more organized approach: ```typescript -const { BoxClient, BoxJwtAuth, JwtConfig } = require('box-typescript-sdk-gen'); +import { BoxClient, BoxJwtAuth, JwtConfig } from 'box-typescript-sdk-gen'; const jwtConfig = JwtConfig.fromConfigFile('/path/to/config.json'); const auth = new BoxJwtAuth({ config: jwtConfig }); @@ -207,7 +208,7 @@ var serviceAccountClient = sdk.getAppAuthClient( The new SDK introduces a more structured approach: ```typescript -const { BoxJwtAuth, JwtConfig } = require('box-typescript-sdk-gen'); +import { BoxJwtAuth, JwtConfig } from 'box-typescript-sdk-gen'; const jwtConfig = new JwtConfig({ clientId: 'YOUR_CLIENT_ID', @@ -269,7 +270,7 @@ const client = sdk.getAnonymousClient(); The new SDK offers a more organized structure: ```typescript -const { CcgConfig, BoxCcgAuth, BoxClient } = require('box-typescript-sdk-gen'); +import { CcgConfig, BoxCcgAuth, BoxClient } from 'box-typescript-sdk-gen'; const ccgConfig = new CcgConfig({ clientId: 'YOUR_CLIENT_ID', @@ -303,7 +304,7 @@ const client = sdk.getCCGClientForUser('USER_ID'); The new SDK streamlines the process: ```typescript -const { CcgConfig, BoxCcgAuth, BoxClient } = require('box-typescript-sdk-gen'); +import { CcgConfig, BoxCcgAuth, BoxClient } from 'box-typescript-sdk-gen'; const ccgConfig = new CcgConfig({ clientId: 'YOUR_CLIENT_ID', @@ -369,7 +370,7 @@ var authorize_url = sdk.getAuthorizeURL({ The new SDK provides more flexibility: ```typescript -const { BoxOAuth, OAuthConfig } = require('box-typescript-sdk-gen'); +import { BoxOAuth, OAuthConfig } from 'box-typescript-sdk-gen'; const config = new OAuthConfig({ clientId: 'OAUTH_CLIENT_ID', @@ -452,13 +453,9 @@ TokenStore.prototype.clear = function (callback) { The new SDK allows developers to define custom classes for token storage: ```typescript -const { BoxOAuth } = require('box-typescript-sdk-gen'); -const { - TokenStorage, -} = require('box-typescript-sdk-gen/lib/box/tokenStorage.generated.js'); -const { - AccessToken, -} = require('box-typescript-sdk-gen/lib/schemas/accessToken.generated.js'); +import { BoxOAuth } from 'box-typescript-sdk-gen'; +import { TokenStorage } from 'box-typescript-sdk-gen/box/tokenStorage.generated'; +import { AccessToken } from 'box-typescript-sdk-gen/schemas/accessToken.generated'; class CustomTokenStorage extends TokenStorage { async store(token: AccessToken): Promise { @@ -647,7 +644,7 @@ as the `file` parameter, and the `fileName` and `fileSize` parameters are now pa The `parentFolderId` parameter is also required to specify the folder where the file will be uploaded. ```typescript -import { File } from 'box-typescript-sdk-gen/lib/schemas/file.generated.js'; +import { File } from 'box-typescript-sdk-gen/schemas/file.generated'; var fileByteStream = fs.createReadStream('/path/to/file.txt'); var fileName = 'new_name.txt'; diff --git a/package-lock.json b/package-lock.json index a9816aa9..94c661b6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -527,9 +527,9 @@ } }, "node_modules/@babel/types": { - "version": "7.28.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.0.tgz", - "integrity": "sha512-jYnje+JyZG5YThjHiF28oT4SIZLnYOcSBb6+SDaFIyzDVSkXQmQQYclJ2R+YxcdmK0AX6x1E5OQNtuh3jHDrUg==", + "version": "7.28.1", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.28.1.tgz", + "integrity": "sha512-x0LvFTekgSX+83TI28Y9wYPUfzrnl2aT5+5QLnO6v7mSJYtEEevuDRN0F0uSHRk1G1IWZC43o00Y0xDDrpBGPQ==", "dev": true, "license": "MIT", "dependencies": { @@ -1086,9 +1086,9 @@ } }, "node_modules/@rollup/rollup-android-arm-eabi": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.44.2.tgz", - "integrity": "sha512-g0dF8P1e2QYPOj1gu7s/3LVP6kze9A7m6x0BZ9iTdXK8N5c2V7cpBKHV3/9A4Zd8xxavdhK0t4PnqjkqVmUc9Q==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.45.1.tgz", + "integrity": "sha512-NEySIFvMY0ZQO+utJkgoMiCAjMrGvnbDLHvcmlA33UXJpYBCvlBEbMMtV837uCkS+plG2umfhn0T5mMAxGrlRA==", "cpu": [ "arm" ], @@ -1100,9 +1100,9 @@ ] }, "node_modules/@rollup/rollup-android-arm64": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.44.2.tgz", - "integrity": "sha512-Yt5MKrOosSbSaAK5Y4J+vSiID57sOvpBNBR6K7xAaQvk3MkcNVV0f9fE20T+41WYN8hDn6SGFlFrKudtx4EoxA==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.45.1.tgz", + "integrity": "sha512-ujQ+sMXJkg4LRJaYreaVx7Z/VMgBBd89wGS4qMrdtfUFZ+TSY5Rs9asgjitLwzeIbhwdEhyj29zhst3L1lKsRQ==", "cpu": [ "arm64" ], @@ -1114,9 +1114,9 @@ ] }, "node_modules/@rollup/rollup-darwin-arm64": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.44.2.tgz", - "integrity": "sha512-EsnFot9ZieM35YNA26nhbLTJBHD0jTwWpPwmRVDzjylQT6gkar+zenfb8mHxWpRrbn+WytRRjE0WKsfaxBkVUA==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.45.1.tgz", + "integrity": "sha512-FSncqHvqTm3lC6Y13xncsdOYfxGSLnP+73k815EfNmpewPs+EyM49haPS105Rh4aF5mJKywk9X0ogzLXZzN9lA==", "cpu": [ "arm64" ], @@ -1128,9 +1128,9 @@ ] }, "node_modules/@rollup/rollup-darwin-x64": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.44.2.tgz", - "integrity": "sha512-dv/t1t1RkCvJdWWxQ2lWOO+b7cMsVw5YFaS04oHpZRWehI1h0fV1gF4wgGCTyQHHjJDfbNpwOi6PXEafRBBezw==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.45.1.tgz", + "integrity": "sha512-2/vVn/husP5XI7Fsf/RlhDaQJ7x9zjvC81anIVbr4b/f0xtSmXQTFcGIQ/B1cXIYM6h2nAhJkdMHTnD7OtQ9Og==", "cpu": [ "x64" ], @@ -1142,9 +1142,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-arm64": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.44.2.tgz", - "integrity": "sha512-W4tt4BLorKND4qeHElxDoim0+BsprFTwb+vriVQnFFtT/P6v/xO5I99xvYnVzKWrK6j7Hb0yp3x7V5LUbaeOMg==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.45.1.tgz", + "integrity": "sha512-4g1kaDxQItZsrkVTdYQ0bxu4ZIQ32cotoQbmsAnW1jAE4XCMbcBPDirX5fyUzdhVCKgPcrwWuucI8yrVRBw2+g==", "cpu": [ "arm64" ], @@ -1156,9 +1156,9 @@ ] }, "node_modules/@rollup/rollup-freebsd-x64": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.44.2.tgz", - "integrity": "sha512-tdT1PHopokkuBVyHjvYehnIe20fxibxFCEhQP/96MDSOcyjM/shlTkZZLOufV3qO6/FQOSiJTBebhVc12JyPTA==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.45.1.tgz", + "integrity": "sha512-L/6JsfiL74i3uK1Ti2ZFSNsp5NMiM4/kbbGEcOCps99aZx3g8SJMO1/9Y0n/qKlWZfn6sScf98lEOUe2mBvW9A==", "cpu": [ "x64" ], @@ -1170,9 +1170,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-gnueabihf": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.44.2.tgz", - "integrity": "sha512-+xmiDGGaSfIIOXMzkhJ++Oa0Gwvl9oXUeIiwarsdRXSe27HUIvjbSIpPxvnNsRebsNdUo7uAiQVgBD1hVriwSQ==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.45.1.tgz", + "integrity": "sha512-RkdOTu2jK7brlu+ZwjMIZfdV2sSYHK2qR08FUWcIoqJC2eywHbXr0L8T/pONFwkGukQqERDheaGTeedG+rra6Q==", "cpu": [ "arm" ], @@ -1184,9 +1184,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm-musleabihf": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.44.2.tgz", - "integrity": "sha512-bDHvhzOfORk3wt8yxIra8N4k/N0MnKInCW5OGZaeDYa/hMrdPaJzo7CSkjKZqX4JFUWjUGm88lI6QJLCM7lDrA==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.45.1.tgz", + "integrity": "sha512-3kJ8pgfBt6CIIr1o+HQA7OZ9mp/zDk3ctekGl9qn/pRBgrRgfwiffaUmqioUGN9hv0OHv2gxmvdKOkARCtRb8Q==", "cpu": [ "arm" ], @@ -1198,9 +1198,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-gnu": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.44.2.tgz", - "integrity": "sha512-NMsDEsDiYghTbeZWEGnNi4F0hSbGnsuOG+VnNvxkKg0IGDvFh7UVpM/14mnMwxRxUf9AdAVJgHPvKXf6FpMB7A==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.45.1.tgz", + "integrity": "sha512-k3dOKCfIVixWjG7OXTCOmDfJj3vbdhN0QYEqB+OuGArOChek22hn7Uy5A/gTDNAcCy5v2YcXRJ/Qcnm4/ma1xw==", "cpu": [ "arm64" ], @@ -1212,9 +1212,9 @@ ] }, "node_modules/@rollup/rollup-linux-arm64-musl": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.44.2.tgz", - "integrity": "sha512-lb5bxXnxXglVq+7imxykIp5xMq+idehfl+wOgiiix0191av84OqbjUED+PRC5OA8eFJYj5xAGcpAZ0pF2MnW+A==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.45.1.tgz", + "integrity": "sha512-PmI1vxQetnM58ZmDFl9/Uk2lpBBby6B6rF4muJc65uZbxCs0EA7hhKCk2PKlmZKuyVSHAyIw3+/SiuMLxKxWog==", "cpu": [ "arm64" ], @@ -1226,9 +1226,9 @@ ] }, "node_modules/@rollup/rollup-linux-loongarch64-gnu": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.44.2.tgz", - "integrity": "sha512-Yl5Rdpf9pIc4GW1PmkUGHdMtbx0fBLE1//SxDmuf3X0dUC57+zMepow2LK0V21661cjXdTn8hO2tXDdAWAqE5g==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.45.1.tgz", + "integrity": "sha512-9UmI0VzGmNJ28ibHW2GpE2nF0PBQqsyiS4kcJ5vK+wuwGnV5RlqdczVocDSUfGX/Na7/XINRVoUgJyFIgipoRg==", "cpu": [ "loong64" ], @@ -1240,9 +1240,9 @@ ] }, "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.44.2.tgz", - "integrity": "sha512-03vUDH+w55s680YYryyr78jsO1RWU9ocRMaeV2vMniJJW/6HhoTBwyyiiTPVHNWLnhsnwcQ0oH3S9JSBEKuyqw==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.45.1.tgz", + "integrity": "sha512-7nR2KY8oEOUTD3pBAxIBBbZr0U7U+R9HDTPNy+5nVVHDXI4ikYniH1oxQz9VoB5PbBU1CZuDGHkLJkd3zLMWsg==", "cpu": [ "ppc64" ], @@ -1254,9 +1254,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-gnu": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.44.2.tgz", - "integrity": "sha512-iYtAqBg5eEMG4dEfVlkqo05xMOk6y/JXIToRca2bAWuqjrJYJlx/I7+Z+4hSrsWU8GdJDFPL4ktV3dy4yBSrzg==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.45.1.tgz", + "integrity": "sha512-nlcl3jgUultKROfZijKjRQLUu9Ma0PeNv/VFHkZiKbXTBQXhpytS8CIj5/NfBeECZtY2FJQubm6ltIxm/ftxpw==", "cpu": [ "riscv64" ], @@ -1268,9 +1268,9 @@ ] }, "node_modules/@rollup/rollup-linux-riscv64-musl": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.44.2.tgz", - "integrity": "sha512-e6vEbgaaqz2yEHqtkPXa28fFuBGmUJ0N2dOJK8YUfijejInt9gfCSA7YDdJ4nYlv67JfP3+PSWFX4IVw/xRIPg==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-musl/-/rollup-linux-riscv64-musl-4.45.1.tgz", + "integrity": "sha512-HJV65KLS51rW0VY6rvZkiieiBnurSzpzore1bMKAhunQiECPuxsROvyeaot/tcK3A3aGnI+qTHqisrpSgQrpgA==", "cpu": [ "riscv64" ], @@ -1282,9 +1282,9 @@ ] }, "node_modules/@rollup/rollup-linux-s390x-gnu": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.44.2.tgz", - "integrity": "sha512-evFOtkmVdY3udE+0QKrV5wBx7bKI0iHz5yEVx5WqDJkxp9YQefy4Mpx3RajIVcM6o7jxTvVd/qpC1IXUhGc1Mw==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.45.1.tgz", + "integrity": "sha512-NITBOCv3Qqc6hhwFt7jLV78VEO/il4YcBzoMGGNxznLgRQf43VQDae0aAzKiBeEPIxnDrACiMgbqjuihx08OOw==", "cpu": [ "s390x" ], @@ -1296,9 +1296,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.44.2.tgz", - "integrity": "sha512-/bXb0bEsWMyEkIsUL2Yt5nFB5naLAwyOWMEviQfQY1x3l5WsLKgvZf66TM7UTfED6erckUVUJQ/jJ1FSpm3pRQ==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.45.1.tgz", + "integrity": "sha512-+E/lYl6qu1zqgPEnTrs4WysQtvc/Sh4fC2nByfFExqgYrqkKWp1tWIbe+ELhixnenSpBbLXNi6vbEEJ8M7fiHw==", "cpu": [ "x64" ], @@ -1310,9 +1310,9 @@ ] }, "node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.44.2.tgz", - "integrity": "sha512-3D3OB1vSSBXmkGEZR27uiMRNiwN08/RVAcBKwhUYPaiZ8bcvdeEwWPvbnXvvXHY+A/7xluzcN+kaiOFNiOZwWg==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.45.1.tgz", + "integrity": "sha512-a6WIAp89p3kpNoYStITT9RbTbTnqarU7D8N8F2CV+4Cl9fwCOZraLVuVFvlpsW0SbIiYtEnhCZBPLoNdRkjQFw==", "cpu": [ "x64" ], @@ -1324,9 +1324,9 @@ ] }, "node_modules/@rollup/rollup-win32-arm64-msvc": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.44.2.tgz", - "integrity": "sha512-VfU0fsMK+rwdK8mwODqYeM2hDrF2WiHaSmCBrS7gColkQft95/8tphyzv2EupVxn3iE0FI78wzffoULH1G+dkw==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.45.1.tgz", + "integrity": "sha512-T5Bi/NS3fQiJeYdGvRpTAP5P02kqSOpqiopwhj0uaXB6nzs5JVi2XMJb18JUSKhCOX8+UE1UKQufyD6Or48dJg==", "cpu": [ "arm64" ], @@ -1338,9 +1338,9 @@ ] }, "node_modules/@rollup/rollup-win32-ia32-msvc": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.44.2.tgz", - "integrity": "sha512-+qMUrkbUurpE6DVRjiJCNGZBGo9xM4Y0FXU5cjgudWqIBWbcLkjE3XprJUsOFgC6xjBClwVa9k6O3A7K3vxb5Q==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.45.1.tgz", + "integrity": "sha512-lxV2Pako3ujjuUe9jiU3/s7KSrDfH6IgTSQOnDWr9aJ92YsFd7EurmClK0ly/t8dzMkDtd04g60WX6yl0sGfdw==", "cpu": [ "ia32" ], @@ -1352,9 +1352,9 @@ ] }, "node_modules/@rollup/rollup-win32-x64-msvc": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.44.2.tgz", - "integrity": "sha512-3+QZROYfJ25PDcxFF66UEk8jGWigHJeecZILvkPkyQN7oc5BvFo4YEXFkOs154j3FTMp9mn9Ky8RCOwastduEA==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.45.1.tgz", + "integrity": "sha512-M/fKi4sasCdM8i0aWJjCSFm2qEnYRR8AMLG2kxp6wD13+tMGA4Z1tVAuHkNRjud5SW2EM3naLuK35w9twvf6aA==", "cpu": [ "x64" ], @@ -1531,9 +1531,9 @@ "peer": true }, "node_modules/@types/node": { - "version": "24.0.13", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.13.tgz", - "integrity": "sha512-Qm9OYVOFHFYg3wJoTSrz80hoec5Lia/dPp84do3X7dZvLikQvM1YpmvTBEdIr/e+U8HTkFjLHLnl78K/qjf+jQ==", + "version": "24.0.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-24.0.14.tgz", + "integrity": "sha512-4zXMWD91vBLGRtHK3YbIoFMia+1nqEz72coM42C5ETjnNCa/heoj7NT1G67iAfOqMmcfhuCZ4uNpyz8EjlAejw==", "dev": true, "license": "MIT", "dependencies": { @@ -1812,9 +1812,9 @@ } }, "node_modules/acorn-import-phases": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/acorn-import-phases/-/acorn-import-phases-1.0.3.tgz", - "integrity": "sha512-jtKLnfoOzm28PazuQ4dVBcE9Jeo6ha1GAJvq3N0LlNOszmTfx+wSycBehn+FN0RnyeR77IBxN/qVYMw0Rlj0Xw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/acorn-import-phases/-/acorn-import-phases-1.0.4.tgz", + "integrity": "sha512-wKmbr/DDiIXzEOiWrTTUcDm24kQ2vGfZQvM2fwg2vXqR5uW6aapr7ObPtj1th32b9u90/Pf4AItvdTh42fBmVQ==", "dev": true, "license": "MIT", "peer": true, @@ -2622,9 +2622,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.182", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.182.tgz", - "integrity": "sha512-Lv65Btwv9W4J9pyODI6EWpdnhfvrve/us5h1WspW8B2Fb0366REPtY3hX7ounk1CkV/TBjWCEvCBBbYbmV0qCA==", + "version": "1.5.183", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.183.tgz", + "integrity": "sha512-vCrDBYjQCAEefWGjlK3EpoSKfKbT10pR4XXPdn65q7snuNOZnthoVpBfZPykmDapOKfoD+MMIPG8ZjKyyc9oHA==", "dev": true, "license": "ISC" }, @@ -5052,9 +5052,9 @@ } }, "node_modules/rollup": { - "version": "4.44.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.44.2.tgz", - "integrity": "sha512-PVoapzTwSEcelaWGth3uR66u7ZRo6qhPHc0f2uRO9fX6XDVNrIiGYS0Pj9+R8yIIYSD/mCx2b16Ws9itljKSPg==", + "version": "4.45.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.45.1.tgz", + "integrity": "sha512-4iya7Jb76fVpQyLoiVpzUrsjQ12r3dM7fIVz+4NwoYvZOShknRmiv+iu9CClZml5ZLGb0XMcYLutK6w9tgxHDw==", "dev": true, "license": "MIT", "dependencies": { @@ -5068,26 +5068,26 @@ "npm": ">=8.0.0" }, "optionalDependencies": { - "@rollup/rollup-android-arm-eabi": "4.44.2", - "@rollup/rollup-android-arm64": "4.44.2", - "@rollup/rollup-darwin-arm64": "4.44.2", - "@rollup/rollup-darwin-x64": "4.44.2", - "@rollup/rollup-freebsd-arm64": "4.44.2", - "@rollup/rollup-freebsd-x64": "4.44.2", - "@rollup/rollup-linux-arm-gnueabihf": "4.44.2", - "@rollup/rollup-linux-arm-musleabihf": "4.44.2", - "@rollup/rollup-linux-arm64-gnu": "4.44.2", - "@rollup/rollup-linux-arm64-musl": "4.44.2", - "@rollup/rollup-linux-loongarch64-gnu": "4.44.2", - "@rollup/rollup-linux-powerpc64le-gnu": "4.44.2", - "@rollup/rollup-linux-riscv64-gnu": "4.44.2", - "@rollup/rollup-linux-riscv64-musl": "4.44.2", - "@rollup/rollup-linux-s390x-gnu": "4.44.2", - "@rollup/rollup-linux-x64-gnu": "4.44.2", - "@rollup/rollup-linux-x64-musl": "4.44.2", - "@rollup/rollup-win32-arm64-msvc": "4.44.2", - "@rollup/rollup-win32-ia32-msvc": "4.44.2", - "@rollup/rollup-win32-x64-msvc": "4.44.2", + "@rollup/rollup-android-arm-eabi": "4.45.1", + "@rollup/rollup-android-arm64": "4.45.1", + "@rollup/rollup-darwin-arm64": "4.45.1", + "@rollup/rollup-darwin-x64": "4.45.1", + "@rollup/rollup-freebsd-arm64": "4.45.1", + "@rollup/rollup-freebsd-x64": "4.45.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.45.1", + "@rollup/rollup-linux-arm-musleabihf": "4.45.1", + "@rollup/rollup-linux-arm64-gnu": "4.45.1", + "@rollup/rollup-linux-arm64-musl": "4.45.1", + "@rollup/rollup-linux-loongarch64-gnu": "4.45.1", + "@rollup/rollup-linux-powerpc64le-gnu": "4.45.1", + "@rollup/rollup-linux-riscv64-gnu": "4.45.1", + "@rollup/rollup-linux-riscv64-musl": "4.45.1", + "@rollup/rollup-linux-s390x-gnu": "4.45.1", + "@rollup/rollup-linux-x64-gnu": "4.45.1", + "@rollup/rollup-linux-x64-musl": "4.45.1", + "@rollup/rollup-win32-arm64-msvc": "4.45.1", + "@rollup/rollup-win32-ia32-msvc": "4.45.1", + "@rollup/rollup-win32-x64-msvc": "4.45.1", "fsevents": "~2.3.2" } }, diff --git a/package.json b/package.json index 18c2ad3e..4e101cde 100644 --- a/package.json +++ b/package.json @@ -17,10 +17,27 @@ "types": "./lib/index.d.ts", "browser": { "./src/internal/utilsNode.ts": "./src/internal/utilsBrowser.ts", - "./lib/internal/utilsNode.js": "./lib/internal/utilsBrowser.js" + "./lib/internal/utilsNode.js": "./lib/internal/utilsBrowser.js", + "./lib-esm/internal/utilsNode.js": "./lib-esm/internal/utilsBrowser.js" }, + "module": "./lib-esm/index.js", + "exports": { + ".": { + "import": "./lib-esm/index.js", + "require": "./lib/index.js", + "types": "./lib/index.d.ts" + }, + "./*": { + "import": "./lib-esm/*.js", + "require": "./lib/*.js", + "types": "./lib/*.d.ts" + } + }, + "sideEffects": false, "scripts": { - "build": "tsc", + "build": "npm run build:cjs && npm run build:esm", + "build:cjs": "tsc --project tsconfig.json", + "build:esm": "tsc --project tsconfig.esm.json", "postbuild": "rollup -c", "start": "echo \"Error: no start specified\" && exit 1", "test": "jest" @@ -57,6 +74,7 @@ }, "files": [ "lib", + "lib-esm", "src", "README.md", "LICENSE" diff --git a/test-browser/init.ts b/test-browser/init.ts new file mode 100644 index 00000000..70052776 --- /dev/null +++ b/test-browser/init.ts @@ -0,0 +1,22 @@ +import path from 'path'; +import fs from 'fs'; + +const testDir = path.resolve( + process.cwd(), + 'node_modules/box-typescript-sdk-gen/lib-esm/test', +); +const files = fs.readdirSync(testDir); + +const importStatements = files + .filter((file) => file.endsWith('.test.js')) + .map((file) => file.replace('.js', '')) + .map((file) => `import('box-typescript-sdk-gen/test/${file}');`) + .join('\n'); + +const outputPath = path.resolve(process.cwd(), 'src/utils/importTests.ts'); +const outputContent = `${importStatements} +export default function f() { + // This function is intentionally left empty. +} +`; +fs.writeFileSync(outputPath, outputContent, 'utf8'); diff --git a/test-browser/package-lock.json b/test-browser/package-lock.json index 36f4e6fb..ab88137e 100644 --- a/test-browser/package-lock.json +++ b/test-browser/package-lock.json @@ -21,6 +21,7 @@ "eslint": "^9", "eslint-config-next": "15.2.3", "start-server-and-test": "^2.0.11", + "tsx": "^4.20.3", "typescript": "^5" } }, @@ -113,6 +114,422 @@ "tslib": "^2.4.0" } }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.6.tgz", + "integrity": "sha512-ShbM/3XxwuxjFiuVBHA+d3j5dyac0aEVVq1oluIDf71hUw0aRF59dV/efUsIwFnR6m8JNM2FjZOzmaZ8yG61kw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.6.tgz", + "integrity": "sha512-S8ToEOVfg++AU/bHwdksHNnyLyVM+eMVAOf6yRKFitnwnbwwPNqKr3srzFRe7nzV69RQKb5DgchIX5pt3L53xg==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.6.tgz", + "integrity": "sha512-hd5zdUarsK6strW+3Wxi5qWws+rJhCCbMiC9QZyzoxfk5uHRIE8T287giQxzVpEvCwuJ9Qjg6bEjcRJcgfLqoA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.6.tgz", + "integrity": "sha512-0Z7KpHSr3VBIO9A/1wcT3NTy7EB4oNC4upJ5ye3R7taCc2GUdeynSLArnon5G8scPwaU866d3H4BCrE5xLW25A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.6.tgz", + "integrity": "sha512-FFCssz3XBavjxcFxKsGy2DYK5VSvJqa6y5HXljKzhRZ87LvEi13brPrf/wdyl/BbpbMKJNOr1Sd0jtW4Ge1pAA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.6.tgz", + "integrity": "sha512-GfXs5kry/TkGM2vKqK2oyiLFygJRqKVhawu3+DOCk7OxLy/6jYkWXhlHwOoTb0WqGnWGAS7sooxbZowy+pK9Yg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.6.tgz", + "integrity": "sha512-aoLF2c3OvDn2XDTRvn8hN6DRzVVpDlj2B/F66clWd/FHLiHaG3aVZjxQX2DYphA5y/evbdGvC6Us13tvyt4pWg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.6.tgz", + "integrity": "sha512-2SkqTjTSo2dYi/jzFbU9Plt1vk0+nNg8YC8rOXXea+iA3hfNJWebKYPs3xnOUf9+ZWhKAaxnQNUf2X9LOpeiMQ==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.6.tgz", + "integrity": "sha512-SZHQlzvqv4Du5PrKE2faN0qlbsaW/3QQfUUc6yO2EjFcA83xnwm91UbEEVx4ApZ9Z5oG8Bxz4qPE+HFwtVcfyw==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.6.tgz", + "integrity": "sha512-b967hU0gqKd9Drsh/UuAm21Khpoh6mPBSgz8mKRq4P5mVK8bpA+hQzmm/ZwGVULSNBzKdZPQBRT3+WuVavcWsQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.6.tgz", + "integrity": "sha512-aHWdQ2AAltRkLPOsKdi3xv0mZ8fUGPdlKEjIEhxCPm5yKEThcUjHpWB1idN74lfXGnZ5SULQSgtr5Qos5B0bPw==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.6.tgz", + "integrity": "sha512-VgKCsHdXRSQ7E1+QXGdRPlQ/e08bN6WMQb27/TMfV+vPjjTImuT9PmLXupRlC90S1JeNNW5lzkAEO/McKeJ2yg==", + "cpu": [ + "loong64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.6.tgz", + "integrity": "sha512-WViNlpivRKT9/py3kCmkHnn44GkGXVdXfdc4drNmRl15zVQ2+D2uFwdlGh6IuK5AAnGTo2qPB1Djppj+t78rzw==", + "cpu": [ + "mips64el" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.6.tgz", + "integrity": "sha512-wyYKZ9NTdmAMb5730I38lBqVu6cKl4ZfYXIs31Baf8aoOtB4xSGi3THmDYt4BTFHk7/EcVixkOV2uZfwU3Q2Jw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.6.tgz", + "integrity": "sha512-KZh7bAGGcrinEj4qzilJ4hqTY3Dg2U82c8bv+e1xqNqZCrCyc+TL9AUEn5WGKDzm3CfC5RODE/qc96OcbIe33w==", + "cpu": [ + "riscv64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.6.tgz", + "integrity": "sha512-9N1LsTwAuE9oj6lHMyyAM+ucxGiVnEqUdp4v7IaMmrwb06ZTEVCIs3oPPplVsnjPfyjmxwHxHMF8b6vzUVAUGw==", + "cpu": [ + "s390x" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.6.tgz", + "integrity": "sha512-A6bJB41b4lKFWRKNrWoP2LHsjVzNiaurf7wyj/XtFNTsnPuxwEBWHLty+ZE0dWBKuSK1fvKgrKaNjBS7qbFKig==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.6.tgz", + "integrity": "sha512-IjA+DcwoVpjEvyxZddDqBY+uJ2Snc6duLpjmkXm/v4xuS3H+3FkLZlDm9ZsAbF9rsfP3zeA0/ArNDORZgrxR/Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.6.tgz", + "integrity": "sha512-dUXuZr5WenIDlMHdMkvDc1FAu4xdWixTCRgP7RQLBOkkGgwuuzaGSYcOpW4jFxzpzL1ejb8yF620UxAqnBrR9g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.6.tgz", + "integrity": "sha512-l8ZCvXP0tbTJ3iaqdNf3pjaOSd5ex/e6/omLIQCVBLmHTlfXW3zAxQ4fnDmPLOB1x9xrcSi/xtCWFwCZRIaEwg==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.6.tgz", + "integrity": "sha512-hKrmDa0aOFOr71KQ/19JC7az1P0GWtCN1t2ahYAf4O007DHZt/dW8ym5+CUdJhQ/qkZmI1HAF8KkJbEFtCL7gw==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openharmony-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.6.tgz", + "integrity": "sha512-+SqBcAWoB1fYKmpWoQP4pGtx+pUUC//RNYhFdbcSA16617cchuryuhOCRpPsjCblKukAckWsV+aQ3UKT/RMPcA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "openharmony" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.6.tgz", + "integrity": "sha512-dyCGxv1/Br7MiSC42qinGL8KkG4kX0pEsdb0+TKhmJZgCUDBGmyo1/ArCjNGiOLiIAgdbWgmWgib4HoCi5t7kA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.6.tgz", + "integrity": "sha512-42QOgcZeZOvXfsCBJF5Afw73t4veOId//XD3i+/9gSkhSV6Gk3VPlWncctI+JcOyERv85FUo7RxuxGy+z8A43Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.6.tgz", + "integrity": "sha512-4AWhgXmDuYN7rJI6ORB+uU9DHLq/erBbuMoAuB4VWJTu5KtCgcKYPynF0YI1VkBNuEfjNlLrFr9KZPJzrtLkrQ==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.6.tgz", + "integrity": "sha512-NgJPHHbEpLQgDH2MjQu90pzW/5vvXIZ7KOnPyNBm92A6WgZ/7b6fJyUBjoumLqeOQQGqY2QjQxRo97ah4Sj0cA==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, "node_modules/@eslint-community/eslint-utils": { "version": "4.5.1", "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.5.1.tgz", @@ -2692,6 +3109,47 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/esbuild": { + "version": "0.25.6", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.6.tgz", + "integrity": "sha512-GVuzuUwtdsghE3ocJ9Bs8PNoF13HNQ5TXbEi2AhvVb8xU1Iwt9Fos9FEamfoee+u/TOsn7GUWc04lz46n2bbTg==", + "dev": true, + "hasInstallScript": true, + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.6", + "@esbuild/android-arm": "0.25.6", + "@esbuild/android-arm64": "0.25.6", + "@esbuild/android-x64": "0.25.6", + "@esbuild/darwin-arm64": "0.25.6", + "@esbuild/darwin-x64": "0.25.6", + "@esbuild/freebsd-arm64": "0.25.6", + "@esbuild/freebsd-x64": "0.25.6", + "@esbuild/linux-arm": "0.25.6", + "@esbuild/linux-arm64": "0.25.6", + "@esbuild/linux-ia32": "0.25.6", + "@esbuild/linux-loong64": "0.25.6", + "@esbuild/linux-mips64el": "0.25.6", + "@esbuild/linux-ppc64": "0.25.6", + "@esbuild/linux-riscv64": "0.25.6", + "@esbuild/linux-s390x": "0.25.6", + "@esbuild/linux-x64": "0.25.6", + "@esbuild/netbsd-arm64": "0.25.6", + "@esbuild/netbsd-x64": "0.25.6", + "@esbuild/openbsd-arm64": "0.25.6", + "@esbuild/openbsd-x64": "0.25.6", + "@esbuild/openharmony-arm64": "0.25.6", + "@esbuild/sunos-x64": "0.25.6", + "@esbuild/win32-arm64": "0.25.6", + "@esbuild/win32-ia32": "0.25.6", + "@esbuild/win32-x64": "0.25.6" + } + }, "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", @@ -3426,6 +3884,20 @@ "node": ">=10" } }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, "node_modules/function-bind": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", @@ -6237,6 +6709,25 @@ "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==" }, + "node_modules/tsx": { + "version": "4.20.3", + "resolved": "https://registry.npmjs.org/tsx/-/tsx-4.20.3.tgz", + "integrity": "sha512-qjbnuR9Tr+FJOMBqJCW5ehvIo/buZq7vH7qD7JziU98h6l3qGy0a/yPFjwO+y0/T7GFpNgNAvEcPPVfyT8rrPQ==", + "dev": true, + "dependencies": { + "esbuild": "~0.25.0", + "get-tsconfig": "^4.7.5" + }, + "bin": { + "tsx": "dist/cli.mjs" + }, + "engines": { + "node": ">=18.0.0" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + } + }, "node_modules/tunnel-agent": { "version": "0.6.0", "resolved": "https://registry.npmjs.org/tunnel-agent/-/tunnel-agent-0.6.0.tgz", diff --git a/test-browser/package.json b/test-browser/package.json index acd96469..edbd2c83 100644 --- a/test-browser/package.json +++ b/test-browser/package.json @@ -3,7 +3,8 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "next dev --turbopack", + "dev": "npm run prebuild && next dev --turbopack", + "prebuild": "tsx init.ts", "build": "next build", "build:dev": "NODE_ENV=development next build", "build-run": "npm run build && npm run start", @@ -29,6 +30,7 @@ "eslint": "^9", "eslint-config-next": "15.2.3", "start-server-and-test": "^2.0.11", - "typescript": "^5" + "typescript": "^5", + "tsx": "^4.20.3" } } diff --git a/test-browser/pages/api/tests.ts b/test-browser/pages/api/tests.ts deleted file mode 100644 index 8c72ab84..00000000 --- a/test-browser/pages/api/tests.ts +++ /dev/null @@ -1,33 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next'; -import fs from 'fs'; -import path from 'path'; - -type ResponseData = { - testFiles: string[]; - error?: string; -}; - -export default function handler( - req: NextApiRequest, - res: NextApiResponse, -) { - try { - const testDir = path.resolve( - process.cwd(), - 'node_modules/box-typescript-sdk-gen/lib/test', - ); - const files = fs.readdirSync(testDir); - - // Filter for .generated.test.js files and remove the .js extension - const testFiles = files - .filter((file) => file.endsWith('.generated.test.js')) - .map((file) => file.replace('.js', '')); - - res.status(200).json({ testFiles }); - } catch (error) { - res.status(500).json({ - testFiles: [], - error: error instanceof Error ? error.message : 'Unknown error', - }); - } -} diff --git a/test-browser/src/app/page.tsx b/test-browser/src/app/page.tsx index 654529c2..68e01ac5 100644 --- a/test-browser/src/app/page.tsx +++ b/test-browser/src/app/page.tsx @@ -2,7 +2,7 @@ import styles from './page.module.css'; import { useEffect, useState } from 'react'; -import { setEnvVar } from 'box-typescript-sdk-gen/lib/internal/utils'; +import { setEnvVar } from 'box-typescript-sdk-gen/internal/utils'; import { setupExpect } from '@/utils/expect'; import { TestResult, createTestRegistry } from '@/utils/testRegistry'; import { testConfig } from '@/../sdkTest.config.mjs'; @@ -16,7 +16,6 @@ declare global { export default function Home() { const [testResults, setTestResults] = useState([]); - const [testFiles, setTestFiles] = useState([]); const [error, setError] = useState(); const registerTestMethod = () => { @@ -43,49 +42,23 @@ export default function Home() { }); }; - const fetchTestFiles = async () => { - try { - const response = await fetch('/api/tests'); - const data = await response.json(); - if (data.error) { - setError(data.error); - return; - } - setTestFiles(data.testFiles); - } catch (e) { - setError(e instanceof Error ? e.message : 'Failed to fetch test files'); - } - }; - useEffect(() => { registerTestMethod(); setupExpect(); - setupEnvironment().then(() => { - fetchTestFiles(); + setupEnvironment().then(async () => { + try { + await import('../utils/importTests'); + setTimeout(() => { + window.testRegistry.runAll(); + }, 3000); + } catch (e) { + setError( + e instanceof Error ? e.message : 'Failed to import test files', + ); + } }); }, []); - useEffect(() => { - if (testFiles.length === 0) { - setError('No test files available'); - return; - } - - setError(''); - try { - Promise.all( - testFiles.map( - (file) => import(`box-typescript-sdk-gen/lib/test/${file}.js`), - ), - ).then(() => { - // Run all tests after importing them - window.testRegistry.runAll(); - }); - } catch (e) { - setError(e instanceof Error ? e.message : 'Failed to import test files'); - } - }, [testFiles]); - // Add new useEffect to update test results label useEffect(() => { const passed = testResults.filter((r) => r.status === 'passed').length; diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 00000000..ab2c69a4 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2020", + "module": "ES2020", + "moduleResolution": "node", + "declaration": true, + "sourceMap": true, + "outDir": "lib-esm", + "isolatedModules": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "skipLibCheck": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "src/__tests__"] +} From c03557eb0222fd36360c377e0f56b42e9f6cee69 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Wed, 16 Jul 2025 03:42:41 -0700 Subject: [PATCH 2/5] test: Rerun failed tests on Swift (box/box-codegen#764) --- .codegen.json | 2 +- package-lock.json | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/.codegen.json b/.codegen.json index 1004a0b3..5135984f 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "7d973e2", "specHash": "8402463", "version": "1.16.0" } +{ "engineHash": "fe7a2b2", "specHash": "8402463", "version": "1.16.0" } diff --git a/package-lock.json b/package-lock.json index 94c661b6..f0e05b17 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2622,9 +2622,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.183", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.183.tgz", - "integrity": "sha512-vCrDBYjQCAEefWGjlK3EpoSKfKbT10pR4XXPdn65q7snuNOZnthoVpBfZPykmDapOKfoD+MMIPG8ZjKyyc9oHA==", + "version": "1.5.185", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.185.tgz", + "integrity": "sha512-dYOZfUk57hSMPePoIQ1fZWl1Fkj+OshhEVuPacNKWzC1efe56OsHY3l/jCfiAgIICOU3VgOIdoq7ahg7r7n6MQ==", "dev": true, "license": "ISC" }, @@ -4830,9 +4830,9 @@ "license": "ISC" }, "node_modules/picomatch": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", - "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", + "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", "dev": true, "license": "MIT", "engines": { @@ -5844,9 +5844,9 @@ "license": "BSD-2-Clause" }, "node_modules/webpack": { - "version": "5.100.1", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.100.1.tgz", - "integrity": "sha512-YJB/ESPUe2Locd0NKXmw72Dx8fZQk1gTzI6rc9TAT4+Sypbnhl8jd8RywB1bDsDF9Dy1RUR7gn3q/ZJTd0OZZg==", + "version": "5.100.2", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.100.2.tgz", + "integrity": "sha512-QaNKAvGCDRh3wW1dsDjeMdDXwZm2vqq3zn6Pvq4rHOEOGSaUMgOOjG2Y9ZbIGzpfkJk9ZYTHpDqgDfeBDcnLaw==", "dev": true, "license": "MIT", "peer": true, From 98db4e890511a45446aeafc21060df2107d93bdf Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 17 Jul 2025 02:08:45 -0700 Subject: [PATCH 3/5] fix: specify events next_stream_position property format as int64 (box/box-openapi#535) --- .codegen.json | 2 +- package-lock.json | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/.codegen.json b/.codegen.json index 5135984f..659ecc38 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fe7a2b2", "specHash": "8402463", "version": "1.16.0" } +{ "engineHash": "fe7a2b2", "specHash": "719cda2", "version": "1.16.0" } diff --git a/package-lock.json b/package-lock.json index f0e05b17..bed86aba 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1552,15 +1552,16 @@ } }, "node_modules/@types/node-fetch/node_modules/form-data": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.3.tgz", - "integrity": "sha512-q5YBMeWy6E2Un0nMGWMgI65MAKtaylxfNJGJxpGh45YDciZB4epbWpaAfImil6CPAPTYB4sh0URQNDRIZG5F2w==", + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.4.tgz", + "integrity": "sha512-f0cRzm6dkyVYV3nPoooP8XlccPQukegwhAnpoLcXy+X+A8KfpGOoXwDr9FLZd3wzgLaBGQBE3lY93Zm/i1JvIQ==", "dev": true, "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", + "hasown": "^2.0.2", "mime-types": "^2.1.35" }, "engines": { @@ -2622,9 +2623,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.185", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.185.tgz", - "integrity": "sha512-dYOZfUk57hSMPePoIQ1fZWl1Fkj+OshhEVuPacNKWzC1efe56OsHY3l/jCfiAgIICOU3VgOIdoq7ahg7r7n6MQ==", + "version": "1.5.186", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.186.tgz", + "integrity": "sha512-lur7L4BFklgepaJxj4DqPk7vKbTEl0pajNlg2QjE5shefmlmBLm2HvQ7PMf1R/GvlevT/581cop33/quQcfX3A==", "dev": true, "license": "ISC" }, @@ -2986,9 +2987,9 @@ } }, "node_modules/form-data": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz", - "integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==", + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", + "integrity": "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow==", "license": "MIT", "dependencies": { "asynckit": "^0.4.0", From 2a04be316d067ec798ef3eb5b1e4d684eb70c2b7 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 17 Jul 2025 03:12:58 -0700 Subject: [PATCH 4/5] feat: Hub items API (box/box-openapi#538) --- .codegen.json | 2 +- docs/README.md | 1 + docs/hubItems.md | 52 +++ docs/hubs.md | 81 +++++ src/client.generated.ts | 7 + src/managers/hubItems.generated.ts | 306 ++++++++++++++++ src/managers/hubs.generated.ts | 340 ++++++++++++++++++ ...enceOrWeblinkReferenceV2025R0.generated.ts | 58 +++ .../folderReferenceV2025R0.generated.ts | 132 +++++++ .../v2025R0/hubActionV2025R0.generated.ts | 28 ++ .../hubCopyRequestV2025R0.generated.ts | 49 +++ .../hubCreateRequestV2025R0.generated.ts | 55 +++ ...hubItemOperationResultV2025R0.generated.ts | 84 +++++ .../hubItemOperationV2025R0.generated.ts | 89 +++++ .../hubItemReferenceV2025R0.generated.ts | 54 +++ .../v2025R0/hubItemV2025R0.generated.ts | 85 +++++ .../hubItemsManageRequestV2025R0.generated.ts | 57 +++ ...hubItemsManageResponseV2025R0.generated.ts | 59 +++ .../v2025R0/hubItemsV2025R0.generated.ts | 75 ++++ .../hubUpdateRequestV2025R0.generated.ts | 119 ++++++ .../weblinkReferenceV2025R0.generated.ts | 132 +++++++ 21 files changed, 1864 insertions(+), 1 deletion(-) create mode 100644 docs/hubItems.md create mode 100644 src/managers/hubItems.generated.ts create mode 100644 src/schemas/v2025R0/fileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/folderReferenceV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubActionV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubCopyRequestV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubCreateRequestV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubItemOperationResultV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubItemOperationV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubItemReferenceV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubItemV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubItemsManageRequestV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubItemsManageResponseV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubItemsV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/hubUpdateRequestV2025R0.generated.ts create mode 100644 src/schemas/v2025R0/weblinkReferenceV2025R0.generated.ts diff --git a/.codegen.json b/.codegen.json index 659ecc38..47f6122d 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fe7a2b2", "specHash": "719cda2", "version": "1.16.0" } +{ "engineHash": "fe7a2b2", "specHash": "7871ded", "version": "1.16.0" } diff --git a/docs/README.md b/docs/README.md index 0d6d90a6..8684e73c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -37,6 +37,7 @@ the SDK are available by topic: - [Folders](folders.md) - [Groups](groups.md) - [Hub collaborations](hubCollaborations.md) +- [Hub items](hubItems.md) - [Hubs](hubs.md) - [Integration mappings](integrationMappings.md) - [Invites](invites.md) diff --git a/docs/hubItems.md b/docs/hubItems.md new file mode 100644 index 00000000..012ec016 --- /dev/null +++ b/docs/hubItems.md @@ -0,0 +1,52 @@ +# HubItemsManager + +- [Get hub items](#get-hub-items) +- [Manage hub items](#manage-hub-items) + +## Get hub items + +Retrieves all items associated with a Hub. + +This operation is performed by calling function `getHubItemsV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/get-hub-items/). + +_Currently we don't have an example for calling `getHubItemsV2025R0` in integration tests_ + +### Arguments + +- queryParams `GetHubItemsV2025R0QueryParams` + - Query parameters of getHubItemsV2025R0 method +- optionalsInput `GetHubItemsV2025R0OptionalsInput` + - + +### Returns + +This function returns a value of type `HubItemsV2025R0`. + +Retrieves the items associated with the specified Hub. + +## Manage hub items + +Adds and/or removes Hub items from a Hub. + +This operation is performed by calling function `createHubManageItemV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/post-hubs-id-manage-items/). + +_Currently we don't have an example for calling `createHubManageItemV2025R0` in integration tests_ + +### Arguments + +- hubId `string` + - The unique identifier that represent a hub. The ID for any hub can be determined by visiting this hub in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is `123`. Example: "12345" +- requestBody `HubItemsManageRequestV2025R0` + - Request body of createHubManageItemV2025R0 method +- optionalsInput `CreateHubManageItemV2025R0OptionalsInput` + - + +### Returns + +This function returns a value of type `HubItemsManageResponseV2025R0`. diff --git a/docs/hubs.md b/docs/hubs.md index 222b5d24..ac25fda6 100644 --- a/docs/hubs.md +++ b/docs/hubs.md @@ -1,9 +1,12 @@ # HubsManager - [List all hubs](#list-all-hubs) +- [Create hub](#create-hub) - [List all hubs for requesting enterprise](#list-all-hubs-for-requesting-enterprise) - [Get hub information by ID](#get-hub-information-by-id) +- [Update hub information by ID](#update-hub-information-by-id) - [Delete hub](#delete-hub) +- [Copy hub](#copy-hub) ## List all hubs @@ -39,6 +42,30 @@ This function returns a value of type `HubsV2025R0`. Returns all hubs for the given user or enterprise. +## Create hub + +Creates a new Hub. + +This operation is performed by calling function `createHubV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/post-hubs/). + +_Currently we don't have an example for calling `createHubV2025R0` in integration tests_ + +### Arguments + +- requestBody `HubCreateRequestV2025R0` + - Request body of createHubV2025R0 method +- optionalsInput `CreateHubV2025R0OptionalsInput` + - + +### Returns + +This function returns a value of type `HubV2025R0`. + +Returns a new Hub object. + ## List all hubs for requesting enterprise Retrieves all hubs for a given enterprise. @@ -103,6 +130,32 @@ This function returns a value of type `HubV2025R0`. Returns a hub object. +## Update hub information by ID + +Updates a Hub. Can be used to change title, description, or Hub settings. + +This operation is performed by calling function `updateHubByIdV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/put-hubs-id/). + +_Currently we don't have an example for calling `updateHubByIdV2025R0` in integration tests_ + +### Arguments + +- hubId `string` + - The unique identifier that represent a hub. The ID for any hub can be determined by visiting this hub in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is `123`. Example: "12345" +- requestBody `HubUpdateRequestV2025R0` + - Request body of updateHubByIdV2025R0 method +- optionalsInput `UpdateHubByIdV2025R0OptionalsInput` + - + +### Returns + +This function returns a value of type `HubV2025R0`. + +Returns a Hub object. + ## Delete hub Deletes a single hub. @@ -131,3 +184,31 @@ This function returns a value of type `undefined`. A blank response is returned if the hub was successfully deleted. + +## Copy hub + +Creates a copy of a Hub. + +The original Hub will not be modified. + +This operation is performed by calling function `createHubCopyV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/post-hubs-id-copy/). + +_Currently we don't have an example for calling `createHubCopyV2025R0` in integration tests_ + +### Arguments + +- hubId `string` + - The unique identifier that represent a hub. The ID for any hub can be determined by visiting this hub in the web application and copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the `hub_id` is `123`. Example: "12345" +- requestBody `HubCopyRequestV2025R0` + - Request body of createHubCopyV2025R0 method +- optionalsInput `CreateHubCopyV2025R0OptionalsInput` + - + +### Returns + +This function returns a value of type `HubV2025R0`. + +Returns a new Hub object. diff --git a/src/client.generated.ts b/src/client.generated.ts index a5f4876f..618654c0 100644 --- a/src/client.generated.ts +++ b/src/client.generated.ts @@ -78,6 +78,7 @@ import { DocgenTemplateManager } from './managers/docgenTemplate.generated.js'; import { DocgenManager } from './managers/docgen.generated.js'; import { HubsManager } from './managers/hubs.generated.js'; import { HubCollaborationsManager } from './managers/hubCollaborations.generated.js'; +import { HubItemsManager } from './managers/hubItems.generated.js'; import { ShieldListsManager } from './managers/shieldLists.generated.js'; import { Authentication } from './networking/auth.generated.js'; import { NetworkSession } from './networking/network.generated.js'; @@ -176,6 +177,7 @@ export class BoxClient { readonly docgen: DocgenManager; readonly hubs: HubsManager; readonly hubCollaborations: HubCollaborationsManager; + readonly hubItems: HubItemsManager; readonly shieldLists: ShieldListsManager; constructor( fields: Omit< @@ -256,6 +258,7 @@ export class BoxClient { | 'docgen' | 'hubs' | 'hubCollaborations' + | 'hubItems' | 'shieldLists' | 'networkSession' | 'makeRequest' @@ -585,6 +588,10 @@ export class BoxClient { auth: this.auth, networkSession: this.networkSession, }); + this.hubItems = new HubItemsManager({ + auth: this.auth, + networkSession: this.networkSession, + }); this.shieldLists = new ShieldListsManager({ auth: this.auth, networkSession: this.networkSession, diff --git a/src/managers/hubItems.generated.ts b/src/managers/hubItems.generated.ts new file mode 100644 index 00000000..7716d8c7 --- /dev/null +++ b/src/managers/hubItems.generated.ts @@ -0,0 +1,306 @@ +import { serializeHubItemsV2025R0 } from '../schemas/v2025R0/hubItemsV2025R0.generated.js'; +import { deserializeHubItemsV2025R0 } from '../schemas/v2025R0/hubItemsV2025R0.generated.js'; +import { serializeClientErrorV2025R0 } from '../schemas/v2025R0/clientErrorV2025R0.generated.js'; +import { deserializeClientErrorV2025R0 } from '../schemas/v2025R0/clientErrorV2025R0.generated.js'; +import { serializeBoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0.generated.js'; +import { deserializeBoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0.generated.js'; +import { serializeHubItemsManageResponseV2025R0 } from '../schemas/v2025R0/hubItemsManageResponseV2025R0.generated.js'; +import { deserializeHubItemsManageResponseV2025R0 } from '../schemas/v2025R0/hubItemsManageResponseV2025R0.generated.js'; +import { serializeHubItemsManageRequestV2025R0 } from '../schemas/v2025R0/hubItemsManageRequestV2025R0.generated.js'; +import { deserializeHubItemsManageRequestV2025R0 } from '../schemas/v2025R0/hubItemsManageRequestV2025R0.generated.js'; +import { ResponseFormat } from '../networking/fetchOptions.generated.js'; +import { HubItemsV2025R0 } from '../schemas/v2025R0/hubItemsV2025R0.generated.js'; +import { ClientErrorV2025R0 } from '../schemas/v2025R0/clientErrorV2025R0.generated.js'; +import { BoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0.generated.js'; +import { HubItemsManageResponseV2025R0 } from '../schemas/v2025R0/hubItemsManageResponseV2025R0.generated.js'; +import { HubItemsManageRequestV2025R0 } from '../schemas/v2025R0/hubItemsManageRequestV2025R0.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 { sdToJson } from '../serialization/json.js'; +import { SerializedData } from '../serialization/json.js'; +import { sdIsEmpty } from '../serialization/json.js'; +import { sdIsBoolean } from '../serialization/json.js'; +import { sdIsNumber } from '../serialization/json.js'; +import { sdIsString } from '../serialization/json.js'; +import { sdIsList } from '../serialization/json.js'; +import { sdIsMap } from '../serialization/json.js'; +export class GetHubItemsV2025R0Optionals { + readonly headers: GetHubItemsV2025R0Headers = new GetHubItemsV2025R0Headers( + {}, + ); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit & + Partial< + Pick + >, + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface GetHubItemsV2025R0OptionalsInput { + readonly headers?: GetHubItemsV2025R0Headers; + readonly cancellationToken?: undefined | CancellationToken; +} +export class CreateHubManageItemV2025R0Optionals { + readonly headers: CreateHubManageItemV2025R0Headers = + new CreateHubManageItemV2025R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit< + CreateHubManageItemV2025R0Optionals, + 'headers' | 'cancellationToken' + > & + Partial< + Pick< + CreateHubManageItemV2025R0Optionals, + 'headers' | 'cancellationToken' + > + >, + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface CreateHubManageItemV2025R0OptionalsInput { + readonly headers?: CreateHubManageItemV2025R0Headers; + readonly cancellationToken?: undefined | CancellationToken; +} +export interface GetHubItemsV2025R0QueryParams { + /** + * The unique identifier that represent a hub. + * + * The ID for any hub can be determined + * by visiting this hub in the web application + * and copying the ID from the URL. For example, + * for the URL `https://*.app.box.com/hubs/123` + * the `hub_id` is `123`. */ + readonly hubId: string; + /** + * Defines the position marker at which to begin returning results. This is + * used when paginating using marker-based pagination. + * + * This requires `usemarker` to be set to `true`. */ + readonly marker?: string; + /** + * The maximum number of items to return per page. */ + readonly limit?: number; +} +export class GetHubItemsV2025R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2025R0 = + '2025.0' as BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface GetHubItemsV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: + | undefined + | { + readonly [key: string]: undefined | string; + }; +} +export class CreateHubManageItemV2025R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2025R0 = + '2025.0' as BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit< + CreateHubManageItemV2025R0Headers, + 'boxVersion' | 'extraHeaders' + > & + Partial< + Pick + >, + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface CreateHubManageItemV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: + | undefined + | { + readonly [key: string]: undefined | string; + }; +} +export class HubItemsManager { + readonly auth?: Authentication; + readonly networkSession: NetworkSession = new NetworkSession({}); + constructor( + fields: Omit< + HubItemsManager, + 'networkSession' | 'getHubItemsV2025R0' | 'createHubManageItemV2025R0' + > & + Partial>, + ) { + if (fields.auth !== undefined) { + this.auth = fields.auth; + } + if (fields.networkSession !== undefined) { + this.networkSession = fields.networkSession; + } + } + /** + * Retrieves all items associated with a Hub. + * @param {GetHubItemsV2025R0QueryParams} queryParams Query parameters of getHubItemsV2025R0 method + * @param {GetHubItemsV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async getHubItemsV2025R0( + queryParams: GetHubItemsV2025R0QueryParams, + optionalsInput: GetHubItemsV2025R0OptionalsInput = {}, + ): Promise { + const optionals: GetHubItemsV2025R0Optionals = + new GetHubItemsV2025R0Optionals({ + headers: optionalsInput.headers, + cancellationToken: optionalsInput.cancellationToken, + }); + const headers: any = optionals.headers; + const cancellationToken: any = optionals.cancellationToken; + const queryParamsMap: { + readonly [key: string]: string; + } = prepareParams({ + ['hub_id']: toString(queryParams.hubId) as string, + ['marker']: toString(queryParams.marker) as string, + ['limit']: toString(queryParams.limit) as string, + }); + const headersMap: { + readonly [key: string]: string; + } = prepareParams({ + ...{ ['box-version']: toString(headers.boxVersion) as string }, + ...headers.extraHeaders, + }); + const response: FetchResponse = + await this.networkSession.networkClient.fetch( + new FetchOptions({ + url: ''.concat( + this.networkSession.baseUrls.baseUrl, + '/2.0/hub_items', + ) as string, + method: 'GET', + params: queryParamsMap, + headers: headersMap, + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeHubItemsV2025R0(response.data!), + rawData: response.data!, + }; + } + /** + * Adds and/or removes Hub items from a Hub. + * @param {string} hubId The unique identifier that represent a hub. + + The ID for any hub can be determined + by visiting this hub in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/hubs/123` + the `hub_id` is `123`. + Example: "12345" + * @param {HubItemsManageRequestV2025R0} requestBody Request body of createHubManageItemV2025R0 method + * @param {CreateHubManageItemV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async createHubManageItemV2025R0( + hubId: string, + requestBody: HubItemsManageRequestV2025R0, + optionalsInput: CreateHubManageItemV2025R0OptionalsInput = {}, + ): Promise { + const optionals: CreateHubManageItemV2025R0Optionals = + new CreateHubManageItemV2025R0Optionals({ + headers: optionalsInput.headers, + cancellationToken: optionalsInput.cancellationToken, + }); + const headers: any = optionals.headers; + const cancellationToken: any = optionals.cancellationToken; + const headersMap: { + readonly [key: string]: string; + } = prepareParams({ + ...{ ['box-version']: toString(headers.boxVersion) as string }, + ...headers.extraHeaders, + }); + const response: FetchResponse = + await this.networkSession.networkClient.fetch( + new FetchOptions({ + url: ''.concat( + this.networkSession.baseUrls.baseUrl, + '/2.0/hubs/', + toString(hubId) as string, + '/manage_items', + ) as string, + method: 'POST', + headers: headersMap, + data: serializeHubItemsManageRequestV2025R0(requestBody), + contentType: 'application/json', + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeHubItemsManageResponseV2025R0(response.data!), + rawData: response.data!, + }; + } +} +export interface HubItemsManagerInput { + readonly auth?: Authentication; + readonly networkSession?: NetworkSession; +} diff --git a/src/managers/hubs.generated.ts b/src/managers/hubs.generated.ts index 21525169..994b5eab 100644 --- a/src/managers/hubs.generated.ts +++ b/src/managers/hubs.generated.ts @@ -6,11 +6,20 @@ import { serializeBoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersi import { deserializeBoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0.generated.js'; import { serializeHubV2025R0 } from '../schemas/v2025R0/hubV2025R0.generated.js'; import { deserializeHubV2025R0 } from '../schemas/v2025R0/hubV2025R0.generated.js'; +import { serializeHubCreateRequestV2025R0 } from '../schemas/v2025R0/hubCreateRequestV2025R0.generated.js'; +import { deserializeHubCreateRequestV2025R0 } from '../schemas/v2025R0/hubCreateRequestV2025R0.generated.js'; +import { serializeHubUpdateRequestV2025R0 } from '../schemas/v2025R0/hubUpdateRequestV2025R0.generated.js'; +import { deserializeHubUpdateRequestV2025R0 } from '../schemas/v2025R0/hubUpdateRequestV2025R0.generated.js'; +import { serializeHubCopyRequestV2025R0 } from '../schemas/v2025R0/hubCopyRequestV2025R0.generated.js'; +import { deserializeHubCopyRequestV2025R0 } from '../schemas/v2025R0/hubCopyRequestV2025R0.generated.js'; import { ResponseFormat } from '../networking/fetchOptions.generated.js'; import { HubsV2025R0 } from '../schemas/v2025R0/hubsV2025R0.generated.js'; import { ClientErrorV2025R0 } from '../schemas/v2025R0/clientErrorV2025R0.generated.js'; import { BoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0.generated.js'; import { HubV2025R0 } from '../schemas/v2025R0/hubV2025R0.generated.js'; +import { HubCreateRequestV2025R0 } from '../schemas/v2025R0/hubCreateRequestV2025R0.generated.js'; +import { HubUpdateRequestV2025R0 } from '../schemas/v2025R0/hubUpdateRequestV2025R0.generated.js'; +import { HubCopyRequestV2025R0 } from '../schemas/v2025R0/hubCopyRequestV2025R0.generated.js'; import { BoxSdkError } from '../box/errors.js'; import { Authentication } from '../networking/auth.generated.js'; import { NetworkSession } from '../networking/network.generated.js'; @@ -28,6 +37,25 @@ import { sdIsNumber } from '../serialization/json.js'; import { sdIsString } from '../serialization/json.js'; import { sdIsList } from '../serialization/json.js'; import { sdIsMap } from '../serialization/json.js'; +export class CreateHubV2025R0Optionals { + readonly headers: CreateHubV2025R0Headers = new CreateHubV2025R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface CreateHubV2025R0OptionalsInput { + readonly headers?: CreateHubV2025R0Headers; + readonly cancellationToken?: undefined | CancellationToken; +} export class GetHubByIdV2025R0Optionals { readonly headers: GetHubByIdV2025R0Headers = new GetHubByIdV2025R0Headers({}); readonly cancellationToken?: CancellationToken = void 0; @@ -49,6 +77,31 @@ export interface GetHubByIdV2025R0OptionalsInput { readonly headers?: GetHubByIdV2025R0Headers; readonly cancellationToken?: undefined | CancellationToken; } +export class UpdateHubByIdV2025R0Optionals { + readonly headers: UpdateHubByIdV2025R0Headers = + new UpdateHubByIdV2025R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit< + UpdateHubByIdV2025R0Optionals, + 'headers' | 'cancellationToken' + > & + Partial< + Pick + >, + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface UpdateHubByIdV2025R0OptionalsInput { + readonly headers?: UpdateHubByIdV2025R0Headers; + readonly cancellationToken?: undefined | CancellationToken; +} export class DeleteHubByIdV2025R0Optionals { readonly headers: DeleteHubByIdV2025R0Headers = new DeleteHubByIdV2025R0Headers({}); @@ -74,6 +127,31 @@ export interface DeleteHubByIdV2025R0OptionalsInput { readonly headers?: DeleteHubByIdV2025R0Headers; readonly cancellationToken?: undefined | CancellationToken; } +export class CreateHubCopyV2025R0Optionals { + readonly headers: CreateHubCopyV2025R0Headers = + new CreateHubCopyV2025R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit< + CreateHubCopyV2025R0Optionals, + 'headers' | 'cancellationToken' + > & + Partial< + Pick + >, + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface CreateHubCopyV2025R0OptionalsInput { + readonly headers?: CreateHubCopyV2025R0Headers; + readonly cancellationToken?: undefined | CancellationToken; +} export type GetHubsV2025R0QueryParamsDirectionField = 'ASC' | 'DESC' | string; export interface GetHubsV2025R0QueryParams { /** @@ -135,6 +213,40 @@ export interface GetHubsV2025R0HeadersInput { readonly [key: string]: undefined | string; }; } +export class CreateHubV2025R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2025R0 = + '2025.0' as BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface CreateHubV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: + | undefined + | { + readonly [key: string]: undefined | string; + }; +} export type GetEnterpriseHubsV2025R0QueryParamsDirectionField = | 'ASC' | 'DESC' @@ -234,6 +346,40 @@ export interface GetHubByIdV2025R0HeadersInput { readonly [key: string]: undefined | string; }; } +export class UpdateHubByIdV2025R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2025R0 = + '2025.0' as BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface UpdateHubByIdV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: + | undefined + | { + readonly [key: string]: undefined | string; + }; +} export class DeleteHubByIdV2025R0Headers { /** * Version header. */ @@ -268,6 +414,40 @@ export interface DeleteHubByIdV2025R0HeadersInput { readonly [key: string]: undefined | string; }; } +export class CreateHubCopyV2025R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2025R0 = + '2025.0' as BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface CreateHubCopyV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: + | undefined + | { + readonly [key: string]: undefined | string; + }; +} export class HubsManager { readonly auth?: Authentication; readonly networkSession: NetworkSession = new NetworkSession({}); @@ -276,9 +456,12 @@ export class HubsManager { HubsManager, | 'networkSession' | 'getHubsV2025R0' + | 'createHubV2025R0' | 'getEnterpriseHubsV2025R0' | 'getHubByIdV2025R0' + | 'updateHubByIdV2025R0' | 'deleteHubByIdV2025R0' + | 'createHubCopyV2025R0' > & Partial>, ) { @@ -342,6 +525,50 @@ export class HubsManager { rawData: response.data!, }; } + /** + * Creates a new Hub. + * @param {HubCreateRequestV2025R0} requestBody Request body of createHubV2025R0 method + * @param {CreateHubV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async createHubV2025R0( + requestBody: HubCreateRequestV2025R0, + optionalsInput: CreateHubV2025R0OptionalsInput = {}, + ): Promise { + const optionals: CreateHubV2025R0Optionals = new CreateHubV2025R0Optionals({ + headers: optionalsInput.headers, + cancellationToken: optionalsInput.cancellationToken, + }); + const headers: any = optionals.headers; + const cancellationToken: any = optionals.cancellationToken; + const headersMap: { + readonly [key: string]: string; + } = prepareParams({ + ...{ ['box-version']: toString(headers.boxVersion) as string }, + ...headers.extraHeaders, + }); + const response: FetchResponse = + await this.networkSession.networkClient.fetch( + new FetchOptions({ + url: ''.concat( + this.networkSession.baseUrls.baseUrl, + '/2.0/hubs', + ) as string, + method: 'POST', + headers: headersMap, + data: serializeHubCreateRequestV2025R0(requestBody), + contentType: 'application/json', + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeHubV2025R0(response.data!), + rawData: response.data!, + }; + } /** * Retrieves all hubs for a given enterprise. * @@ -451,6 +678,61 @@ export class HubsManager { rawData: response.data!, }; } + /** + * Updates a Hub. Can be used to change title, description, or Hub settings. + * @param {string} hubId The unique identifier that represent a hub. + + The ID for any hub can be determined + by visiting this hub in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/hubs/123` + the `hub_id` is `123`. + Example: "12345" + * @param {HubUpdateRequestV2025R0} requestBody Request body of updateHubByIdV2025R0 method + * @param {UpdateHubByIdV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async updateHubByIdV2025R0( + hubId: string, + requestBody: HubUpdateRequestV2025R0, + optionalsInput: UpdateHubByIdV2025R0OptionalsInput = {}, + ): Promise { + const optionals: UpdateHubByIdV2025R0Optionals = + new UpdateHubByIdV2025R0Optionals({ + headers: optionalsInput.headers, + cancellationToken: optionalsInput.cancellationToken, + }); + const headers: any = optionals.headers; + const cancellationToken: any = optionals.cancellationToken; + const headersMap: { + readonly [key: string]: string; + } = prepareParams({ + ...{ ['box-version']: toString(headers.boxVersion) as string }, + ...headers.extraHeaders, + }); + const response: FetchResponse = + await this.networkSession.networkClient.fetch( + new FetchOptions({ + url: ''.concat( + this.networkSession.baseUrls.baseUrl, + '/2.0/hubs/', + toString(hubId) as string, + ) as string, + method: 'PUT', + headers: headersMap, + data: serializeHubUpdateRequestV2025R0(requestBody), + contentType: 'application/json', + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeHubV2025R0(response.data!), + rawData: response.data!, + }; + } /** * Deletes a single hub. * @param {string} hubId The unique identifier that represent a hub. @@ -499,6 +781,64 @@ export class HubsManager { ); return void 0; } + /** + * Creates a copy of a Hub. + * + * The original Hub will not be modified. + * @param {string} hubId The unique identifier that represent a hub. + + The ID for any hub can be determined + by visiting this hub in the web application + and copying the ID from the URL. For example, + for the URL `https://*.app.box.com/hubs/123` + the `hub_id` is `123`. + Example: "12345" + * @param {HubCopyRequestV2025R0} requestBody Request body of createHubCopyV2025R0 method + * @param {CreateHubCopyV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async createHubCopyV2025R0( + hubId: string, + requestBody: HubCopyRequestV2025R0, + optionalsInput: CreateHubCopyV2025R0OptionalsInput = {}, + ): Promise { + const optionals: CreateHubCopyV2025R0Optionals = + new CreateHubCopyV2025R0Optionals({ + headers: optionalsInput.headers, + cancellationToken: optionalsInput.cancellationToken, + }); + const headers: any = optionals.headers; + const cancellationToken: any = optionals.cancellationToken; + const headersMap: { + readonly [key: string]: string; + } = prepareParams({ + ...{ ['box-version']: toString(headers.boxVersion) as string }, + ...headers.extraHeaders, + }); + const response: FetchResponse = + await this.networkSession.networkClient.fetch( + new FetchOptions({ + url: ''.concat( + this.networkSession.baseUrls.baseUrl, + '/2.0/hubs/', + toString(hubId) as string, + '/copy', + ) as string, + method: 'POST', + headers: headersMap, + data: serializeHubCopyRequestV2025R0(requestBody), + contentType: 'application/json', + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeHubV2025R0(response.data!), + rawData: response.data!, + }; + } } export interface HubsManagerInput { readonly auth?: Authentication; diff --git a/src/schemas/v2025R0/fileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0.generated.ts b/src/schemas/v2025R0/fileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0.generated.ts new file mode 100644 index 00000000..f8c8f86b --- /dev/null +++ b/src/schemas/v2025R0/fileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0.generated.ts @@ -0,0 +1,58 @@ +import { serializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { deserializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { serializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { deserializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { serializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { deserializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { FileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { FolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { WeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export type FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0 = + | FileReferenceV2025R0 + | FolderReferenceV2025R0 + | WeblinkReferenceV2025R0; +export function serializeFileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0( + val: any, +): SerializedData { + if (val.type == 'file') { + return serializeFileReferenceV2025R0(val); + } + if (val.type == 'folder') { + return serializeFolderReferenceV2025R0(val); + } + if (val.type == 'weblink') { + return serializeWeblinkReferenceV2025R0(val); + } + throw new BoxSdkError({ message: 'unknown type' }); +} +export function deserializeFileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0( + val: SerializedData, +): FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: + 'Expecting a map for "FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0"', + }); + } + if (val.type == 'file') { + return deserializeFileReferenceV2025R0(val); + } + if (val.type == 'folder') { + return deserializeFolderReferenceV2025R0(val); + } + if (val.type == 'weblink') { + return deserializeWeblinkReferenceV2025R0(val); + } + throw new BoxSdkError({ + message: + "Can't deserialize FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0", + }); +} diff --git a/src/schemas/v2025R0/folderReferenceV2025R0.generated.ts b/src/schemas/v2025R0/folderReferenceV2025R0.generated.ts new file mode 100644 index 00000000..1684c3dd --- /dev/null +++ b/src/schemas/v2025R0/folderReferenceV2025R0.generated.ts @@ -0,0 +1,132 @@ +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export type FolderReferenceV2025R0TypeField = 'folder'; +export class FolderReferenceV2025R0 { + /** + * The value will always be `folder`. */ + readonly type: FolderReferenceV2025R0TypeField = + 'folder' as FolderReferenceV2025R0TypeField; + /** + * ID of the folder. */ + readonly id!: string; + readonly rawData?: SerializedData; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.type !== undefined) { + this.type = fields.type; + } + if (fields.id !== undefined) { + this.id = fields.id; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + } +} +export interface FolderReferenceV2025R0Input { + /** + * The value will always be `folder`. */ + readonly type?: FolderReferenceV2025R0TypeField; + /** + * ID of the folder. */ + readonly id: string; + readonly rawData?: SerializedData; +} +export function serializeFolderReferenceV2025R0TypeField( + val: FolderReferenceV2025R0TypeField, +): SerializedData { + return val; +} +export function deserializeFolderReferenceV2025R0TypeField( + val: SerializedData, +): FolderReferenceV2025R0TypeField { + if (val == 'folder') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize FolderReferenceV2025R0TypeField", + }); +} +export function serializeFolderReferenceV2025R0( + val: FolderReferenceV2025R0, +): SerializedData { + return { + ['type']: serializeFolderReferenceV2025R0TypeField(val.type), + ['id']: val.id, + }; +} +export function deserializeFolderReferenceV2025R0( + val: SerializedData, +): FolderReferenceV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "FolderReferenceV2025R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "FolderReferenceV2025R0" to be defined', + }); + } + const type: FolderReferenceV2025R0TypeField = + deserializeFolderReferenceV2025R0TypeField(val.type); + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "FolderReferenceV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "FolderReferenceV2025R0"', + }); + } + const id: string = val.id; + return { type: type, id: id } satisfies FolderReferenceV2025R0; +} +export function serializeFolderReferenceV2025R0Input( + val: FolderReferenceV2025R0Input, +): SerializedData { + return { + ['type']: + val.type == void 0 + ? val.type + : serializeFolderReferenceV2025R0TypeField(val.type), + ['id']: val.id, + }; +} +export function deserializeFolderReferenceV2025R0Input( + val: SerializedData, +): FolderReferenceV2025R0Input { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "FolderReferenceV2025R0Input"', + }); + } + const type: undefined | FolderReferenceV2025R0TypeField = + val.type == void 0 + ? void 0 + : deserializeFolderReferenceV2025R0TypeField(val.type); + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "FolderReferenceV2025R0Input" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "id" of type "FolderReferenceV2025R0Input"', + }); + } + const id: string = val.id; + return { type: type, id: id } satisfies FolderReferenceV2025R0Input; +} diff --git a/src/schemas/v2025R0/hubActionV2025R0.generated.ts b/src/schemas/v2025R0/hubActionV2025R0.generated.ts new file mode 100644 index 00000000..5c2c1df5 --- /dev/null +++ b/src/schemas/v2025R0/hubActionV2025R0.generated.ts @@ -0,0 +1,28 @@ +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export type HubActionV2025R0 = 'add' | 'remove' | string; +export function serializeHubActionV2025R0( + val: HubActionV2025R0, +): SerializedData { + return val; +} +export function deserializeHubActionV2025R0( + val: SerializedData, +): HubActionV2025R0 { + if (val == 'add') { + return val; + } + if (val == 'remove') { + return val; + } + if (sdIsString(val)) { + return val; + } + throw new BoxSdkError({ message: "Can't deserialize HubActionV2025R0" }); +} diff --git a/src/schemas/v2025R0/hubCopyRequestV2025R0.generated.ts b/src/schemas/v2025R0/hubCopyRequestV2025R0.generated.ts new file mode 100644 index 00000000..7f360eba --- /dev/null +++ b/src/schemas/v2025R0/hubCopyRequestV2025R0.generated.ts @@ -0,0 +1,49 @@ +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export interface HubCopyRequestV2025R0 { + /** + * Title of the Hub. It cannot be empty and should be less than 50 characters. */ + readonly title?: string; + /** + * Description of the Hub. */ + readonly description?: string; + readonly rawData?: SerializedData; +} +export function serializeHubCopyRequestV2025R0( + val: HubCopyRequestV2025R0, +): SerializedData { + return { ['title']: val.title, ['description']: val.description }; +} +export function deserializeHubCopyRequestV2025R0( + val: SerializedData, +): HubCopyRequestV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubCopyRequestV2025R0"', + }); + } + if (!(val.title == void 0) && !sdIsString(val.title)) { + throw new BoxSdkError({ + message: 'Expecting string for "title" of type "HubCopyRequestV2025R0"', + }); + } + const title: undefined | string = val.title == void 0 ? void 0 : val.title; + if (!(val.description == void 0) && !sdIsString(val.description)) { + throw new BoxSdkError({ + message: + 'Expecting string for "description" of type "HubCopyRequestV2025R0"', + }); + } + const description: undefined | string = + val.description == void 0 ? void 0 : val.description; + return { + title: title, + description: description, + } satisfies HubCopyRequestV2025R0; +} diff --git a/src/schemas/v2025R0/hubCreateRequestV2025R0.generated.ts b/src/schemas/v2025R0/hubCreateRequestV2025R0.generated.ts new file mode 100644 index 00000000..6a4d2665 --- /dev/null +++ b/src/schemas/v2025R0/hubCreateRequestV2025R0.generated.ts @@ -0,0 +1,55 @@ +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export interface HubCreateRequestV2025R0 { + /** + * Title of the Hub. It cannot be empty and should be less than 50 characters. */ + readonly title: string; + /** + * Description of the Hub. */ + readonly description?: string; + readonly rawData?: SerializedData; +} +export function serializeHubCreateRequestV2025R0( + val: HubCreateRequestV2025R0, +): SerializedData { + return { ['title']: val.title, ['description']: val.description }; +} +export function deserializeHubCreateRequestV2025R0( + val: SerializedData, +): HubCreateRequestV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubCreateRequestV2025R0"', + }); + } + if (val.title == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "title" of type "HubCreateRequestV2025R0" to be defined', + }); + } + if (!sdIsString(val.title)) { + throw new BoxSdkError({ + message: 'Expecting string for "title" of type "HubCreateRequestV2025R0"', + }); + } + const title: string = val.title; + if (!(val.description == void 0) && !sdIsString(val.description)) { + throw new BoxSdkError({ + message: + 'Expecting string for "description" of type "HubCreateRequestV2025R0"', + }); + } + const description: undefined | string = + val.description == void 0 ? void 0 : val.description; + return { + title: title, + description: description, + } satisfies HubCreateRequestV2025R0; +} diff --git a/src/schemas/v2025R0/hubItemOperationResultV2025R0.generated.ts b/src/schemas/v2025R0/hubItemOperationResultV2025R0.generated.ts new file mode 100644 index 00000000..72f5f231 --- /dev/null +++ b/src/schemas/v2025R0/hubItemOperationResultV2025R0.generated.ts @@ -0,0 +1,84 @@ +import { serializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { deserializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { serializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { deserializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { serializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { deserializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { serializeHubItemReferenceV2025R0 } from './hubItemReferenceV2025R0.generated.js'; +import { deserializeHubItemReferenceV2025R0 } from './hubItemReferenceV2025R0.generated.js'; +import { FileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { FolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { WeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { HubItemReferenceV2025R0 } from './hubItemReferenceV2025R0.generated.js'; +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export interface HubItemOperationResultV2025R0 { + /** + * The action performed on the item. */ + readonly action?: string; + readonly item?: HubItemReferenceV2025R0; + /** + * The HTTP status code of the operation. */ + readonly status?: number; + /** + * Error message if the operation failed. */ + readonly error?: string; + readonly rawData?: SerializedData; +} +export function serializeHubItemOperationResultV2025R0( + val: HubItemOperationResultV2025R0, +): SerializedData { + return { + ['action']: val.action, + ['item']: + val.item == void 0 + ? val.item + : serializeHubItemReferenceV2025R0(val.item), + ['status']: val.status, + ['error']: val.error, + }; +} +export function deserializeHubItemOperationResultV2025R0( + val: SerializedData, +): HubItemOperationResultV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubItemOperationResultV2025R0"', + }); + } + if (!(val.action == void 0) && !sdIsString(val.action)) { + throw new BoxSdkError({ + message: + 'Expecting string for "action" of type "HubItemOperationResultV2025R0"', + }); + } + const action: undefined | string = val.action == void 0 ? void 0 : val.action; + const item: undefined | HubItemReferenceV2025R0 = + val.item == void 0 ? void 0 : deserializeHubItemReferenceV2025R0(val.item); + if (!(val.status == void 0) && !sdIsNumber(val.status)) { + throw new BoxSdkError({ + message: + 'Expecting number for "status" of type "HubItemOperationResultV2025R0"', + }); + } + const status: undefined | number = val.status == void 0 ? void 0 : val.status; + if (!(val.error == void 0) && !sdIsString(val.error)) { + throw new BoxSdkError({ + message: + 'Expecting string for "error" of type "HubItemOperationResultV2025R0"', + }); + } + const error: undefined | string = val.error == void 0 ? void 0 : val.error; + return { + action: action, + item: item, + status: status, + error: error, + } satisfies HubItemOperationResultV2025R0; +} diff --git a/src/schemas/v2025R0/hubItemOperationV2025R0.generated.ts b/src/schemas/v2025R0/hubItemOperationV2025R0.generated.ts new file mode 100644 index 00000000..b568d155 --- /dev/null +++ b/src/schemas/v2025R0/hubItemOperationV2025R0.generated.ts @@ -0,0 +1,89 @@ +import { serializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { deserializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { serializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { deserializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { serializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { deserializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { serializeFileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0 } from './fileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0.generated.js'; +import { deserializeFileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0 } from './fileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0.generated.js'; +import { FileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { FolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { WeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0 } from './fileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0.generated.js'; +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export type HubItemOperationV2025R0ActionField = 'add' | 'remove' | string; +export interface HubItemOperationV2025R0 { + /** + * The action to perform on a Hub item. */ + readonly action: HubItemOperationV2025R0ActionField; + /** + * Reference to an item that can be added to a Hub. */ + readonly item: FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0; + readonly rawData?: SerializedData; +} +export function serializeHubItemOperationV2025R0ActionField( + val: HubItemOperationV2025R0ActionField, +): SerializedData { + return val; +} +export function deserializeHubItemOperationV2025R0ActionField( + val: SerializedData, +): HubItemOperationV2025R0ActionField { + if (val == 'add') { + return val; + } + if (val == 'remove') { + return val; + } + if (sdIsString(val)) { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubItemOperationV2025R0ActionField", + }); +} +export function serializeHubItemOperationV2025R0( + val: HubItemOperationV2025R0, +): SerializedData { + return { + ['action']: serializeHubItemOperationV2025R0ActionField(val.action), + ['item']: serializeFileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0( + val.item, + ), + }; +} +export function deserializeHubItemOperationV2025R0( + val: SerializedData, +): HubItemOperationV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubItemOperationV2025R0"', + }); + } + if (val.action == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "action" of type "HubItemOperationV2025R0" to be defined', + }); + } + const action: HubItemOperationV2025R0ActionField = + deserializeHubItemOperationV2025R0ActionField(val.action); + if (val.item == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "item" of type "HubItemOperationV2025R0" to be defined', + }); + } + const item: FileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0 = + deserializeFileReferenceOrFolderReferenceOrWeblinkReferenceV2025R0( + val.item, + ); + return { action: action, item: item } satisfies HubItemOperationV2025R0; +} diff --git a/src/schemas/v2025R0/hubItemReferenceV2025R0.generated.ts b/src/schemas/v2025R0/hubItemReferenceV2025R0.generated.ts new file mode 100644 index 00000000..4f370fee --- /dev/null +++ b/src/schemas/v2025R0/hubItemReferenceV2025R0.generated.ts @@ -0,0 +1,54 @@ +import { serializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { deserializeFileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { serializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { deserializeFolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { serializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { deserializeWeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { FileReferenceV2025R0 } from './fileReferenceV2025R0.generated.js'; +import { FolderReferenceV2025R0 } from './folderReferenceV2025R0.generated.js'; +import { WeblinkReferenceV2025R0 } from './weblinkReferenceV2025R0.generated.js'; +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export type HubItemReferenceV2025R0 = + | FileReferenceV2025R0 + | FolderReferenceV2025R0 + | WeblinkReferenceV2025R0; +export function serializeHubItemReferenceV2025R0(val: any): SerializedData { + if (val.type == 'file') { + return serializeFileReferenceV2025R0(val); + } + if (val.type == 'folder') { + return serializeFolderReferenceV2025R0(val); + } + if (val.type == 'weblink') { + return serializeWeblinkReferenceV2025R0(val); + } + throw new BoxSdkError({ message: 'unknown type' }); +} +export function deserializeHubItemReferenceV2025R0( + val: SerializedData, +): HubItemReferenceV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubItemReferenceV2025R0"', + }); + } + if (val.type == 'file') { + return deserializeFileReferenceV2025R0(val); + } + if (val.type == 'folder') { + return deserializeFolderReferenceV2025R0(val); + } + if (val.type == 'weblink') { + return deserializeWeblinkReferenceV2025R0(val); + } + throw new BoxSdkError({ + message: "Can't deserialize HubItemReferenceV2025R0", + }); +} diff --git a/src/schemas/v2025R0/hubItemV2025R0.generated.ts b/src/schemas/v2025R0/hubItemV2025R0.generated.ts new file mode 100644 index 00000000..d231ded9 --- /dev/null +++ b/src/schemas/v2025R0/hubItemV2025R0.generated.ts @@ -0,0 +1,85 @@ +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export type HubItemV2025R0TypeField = 'file' | 'folder' | 'web_link'; +export interface HubItemV2025R0 { + /** + * The unique identifier for this item. */ + readonly id: string; + /** + * The type of the item. */ + readonly type: HubItemV2025R0TypeField; + /** + * The name of the item. */ + readonly name: string; + readonly rawData?: SerializedData; +} +export function serializeHubItemV2025R0TypeField( + val: HubItemV2025R0TypeField, +): SerializedData { + return val; +} +export function deserializeHubItemV2025R0TypeField( + val: SerializedData, +): HubItemV2025R0TypeField { + if (val == 'file') { + return val; + } + if (val == 'folder') { + return val; + } + if (val == 'web_link') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubItemV2025R0TypeField", + }); +} +export function serializeHubItemV2025R0(val: HubItemV2025R0): SerializedData { + return { + ['id']: val.id, + ['type']: serializeHubItemV2025R0TypeField(val.type), + ['name']: val.name, + }; +} +export function deserializeHubItemV2025R0(val: SerializedData): HubItemV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ message: 'Expecting a map for "HubItemV2025R0"' }); + } + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "HubItemV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "HubItemV2025R0"', + }); + } + const id: string = val.id; + if (val.type == void 0) { + throw new BoxSdkError({ + message: 'Expecting "type" of type "HubItemV2025R0" to be defined', + }); + } + const type: HubItemV2025R0TypeField = deserializeHubItemV2025R0TypeField( + val.type, + ); + if (val.name == void 0) { + throw new BoxSdkError({ + message: 'Expecting "name" of type "HubItemV2025R0" to be defined', + }); + } + if (!sdIsString(val.name)) { + throw new BoxSdkError({ + message: 'Expecting string for "name" of type "HubItemV2025R0"', + }); + } + const name: string = val.name; + return { id: id, type: type, name: name } satisfies HubItemV2025R0; +} diff --git a/src/schemas/v2025R0/hubItemsManageRequestV2025R0.generated.ts b/src/schemas/v2025R0/hubItemsManageRequestV2025R0.generated.ts new file mode 100644 index 00000000..84f0dea0 --- /dev/null +++ b/src/schemas/v2025R0/hubItemsManageRequestV2025R0.generated.ts @@ -0,0 +1,57 @@ +import { serializeHubItemOperationV2025R0 } from './hubItemOperationV2025R0.generated.js'; +import { deserializeHubItemOperationV2025R0 } from './hubItemOperationV2025R0.generated.js'; +import { HubItemOperationV2025R0 } from './hubItemOperationV2025R0.generated.js'; +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export interface HubItemsManageRequestV2025R0 { + /** + * List of operations to perform on Hub items. */ + readonly operations?: readonly HubItemOperationV2025R0[]; + readonly rawData?: SerializedData; +} +export function serializeHubItemsManageRequestV2025R0( + val: HubItemsManageRequestV2025R0, +): SerializedData { + return { + ['operations']: + val.operations == void 0 + ? val.operations + : (val.operations.map(function ( + item: HubItemOperationV2025R0, + ): SerializedData { + return serializeHubItemOperationV2025R0(item); + }) as readonly any[]), + }; +} +export function deserializeHubItemsManageRequestV2025R0( + val: SerializedData, +): HubItemsManageRequestV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubItemsManageRequestV2025R0"', + }); + } + if (!(val.operations == void 0) && !sdIsList(val.operations)) { + throw new BoxSdkError({ + message: + 'Expecting array for "operations" of type "HubItemsManageRequestV2025R0"', + }); + } + const operations: undefined | readonly HubItemOperationV2025R0[] = + val.operations == void 0 + ? void 0 + : sdIsList(val.operations) + ? (val.operations.map(function ( + itm: SerializedData, + ): HubItemOperationV2025R0 { + return deserializeHubItemOperationV2025R0(itm); + }) as readonly any[]) + : []; + return { operations: operations } satisfies HubItemsManageRequestV2025R0; +} diff --git a/src/schemas/v2025R0/hubItemsManageResponseV2025R0.generated.ts b/src/schemas/v2025R0/hubItemsManageResponseV2025R0.generated.ts new file mode 100644 index 00000000..a2fe2a38 --- /dev/null +++ b/src/schemas/v2025R0/hubItemsManageResponseV2025R0.generated.ts @@ -0,0 +1,59 @@ +import { serializeHubItemOperationResultV2025R0 } from './hubItemOperationResultV2025R0.generated.js'; +import { deserializeHubItemOperationResultV2025R0 } from './hubItemOperationResultV2025R0.generated.js'; +import { HubItemOperationResultV2025R0 } from './hubItemOperationResultV2025R0.generated.js'; +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export interface HubItemsManageResponseV2025R0 { + /** + * List of operations performed on Hub items. */ + readonly operations: readonly HubItemOperationResultV2025R0[]; + readonly rawData?: SerializedData; +} +export function serializeHubItemsManageResponseV2025R0( + val: HubItemsManageResponseV2025R0, +): SerializedData { + return { + ['operations']: val.operations.map(function ( + item: HubItemOperationResultV2025R0, + ): SerializedData { + return serializeHubItemOperationResultV2025R0(item); + }) as readonly any[], + }; +} +export function deserializeHubItemsManageResponseV2025R0( + val: SerializedData, +): HubItemsManageResponseV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubItemsManageResponseV2025R0"', + }); + } + if (val.operations == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "operations" of type "HubItemsManageResponseV2025R0" to be defined', + }); + } + if (!sdIsList(val.operations)) { + throw new BoxSdkError({ + message: + 'Expecting array for "operations" of type "HubItemsManageResponseV2025R0"', + }); + } + const operations: readonly HubItemOperationResultV2025R0[] = sdIsList( + val.operations, + ) + ? (val.operations.map(function ( + itm: SerializedData, + ): HubItemOperationResultV2025R0 { + return deserializeHubItemOperationResultV2025R0(itm); + }) as readonly any[]) + : []; + return { operations: operations } satisfies HubItemsManageResponseV2025R0; +} diff --git a/src/schemas/v2025R0/hubItemsV2025R0.generated.ts b/src/schemas/v2025R0/hubItemsV2025R0.generated.ts new file mode 100644 index 00000000..f2fa5ae6 --- /dev/null +++ b/src/schemas/v2025R0/hubItemsV2025R0.generated.ts @@ -0,0 +1,75 @@ +import { serializeHubItemV2025R0 } from './hubItemV2025R0.generated.js'; +import { deserializeHubItemV2025R0 } from './hubItemV2025R0.generated.js'; +import { HubItemV2025R0 } from './hubItemV2025R0.generated.js'; +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export interface HubItemsV2025R0 { + /** + * A list of Hub items. */ + readonly entries?: readonly HubItemV2025R0[]; + /** + * The limit that was used for these entries. This will be the same as the + * `limit` query parameter unless that value exceeded the maximum value + * allowed. The maximum value varies by API. */ + readonly limit?: number; + /** + * The marker for the start of the next page of results. */ + readonly nextMarker?: string | null; + readonly rawData?: SerializedData; +} +export function serializeHubItemsV2025R0(val: HubItemsV2025R0): SerializedData { + return { + ['entries']: + val.entries == void 0 + ? val.entries + : (val.entries.map(function (item: HubItemV2025R0): SerializedData { + return serializeHubItemV2025R0(item); + }) as readonly any[]), + ['limit']: val.limit, + ['next_marker']: val.nextMarker, + }; +} +export function deserializeHubItemsV2025R0( + val: SerializedData, +): HubItemsV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ message: 'Expecting a map for "HubItemsV2025R0"' }); + } + if (!(val.entries == void 0) && !sdIsList(val.entries)) { + throw new BoxSdkError({ + message: 'Expecting array for "entries" of type "HubItemsV2025R0"', + }); + } + const entries: undefined | readonly HubItemV2025R0[] = + val.entries == void 0 + ? void 0 + : sdIsList(val.entries) + ? (val.entries.map(function (itm: SerializedData): HubItemV2025R0 { + return deserializeHubItemV2025R0(itm); + }) as readonly any[]) + : []; + if (!(val.limit == void 0) && !sdIsNumber(val.limit)) { + throw new BoxSdkError({ + message: 'Expecting number for "limit" of type "HubItemsV2025R0"', + }); + } + const limit: undefined | number = val.limit == void 0 ? void 0 : val.limit; + if (!(val.next_marker == void 0) && !sdIsString(val.next_marker)) { + throw new BoxSdkError({ + message: 'Expecting string for "next_marker" of type "HubItemsV2025R0"', + }); + } + const nextMarker: undefined | string = + val.next_marker == void 0 ? void 0 : val.next_marker; + return { + entries: entries, + limit: limit, + nextMarker: nextMarker, + } satisfies HubItemsV2025R0; +} diff --git a/src/schemas/v2025R0/hubUpdateRequestV2025R0.generated.ts b/src/schemas/v2025R0/hubUpdateRequestV2025R0.generated.ts new file mode 100644 index 00000000..c583c988 --- /dev/null +++ b/src/schemas/v2025R0/hubUpdateRequestV2025R0.generated.ts @@ -0,0 +1,119 @@ +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export interface HubUpdateRequestV2025R0 { + /** + * Title of the Hub. It cannot be empty and should be less than 50 characters. */ + readonly title?: string; + /** + * Description of the Hub. */ + readonly description?: string; + /** + * Indicates if AI features are enabled for the Hub. */ + readonly isAiEnabled?: boolean; + /** + * Indicates if collaboration is restricted to the enterprise. */ + readonly isCollaborationRestrictedToEnterprise?: boolean; + /** + * Indicates if non-owners can invite others to the Hub. */ + readonly canNonOwnersInvite?: boolean; + /** + * Indicates if a shared link can be created for the Hub. */ + readonly canSharedLinkBeCreated?: boolean; + readonly rawData?: SerializedData; +} +export function serializeHubUpdateRequestV2025R0( + val: HubUpdateRequestV2025R0, +): SerializedData { + return { + ['title']: val.title, + ['description']: val.description, + ['is_ai_enabled']: val.isAiEnabled, + ['is_collaboration_restricted_to_enterprise']: + val.isCollaborationRestrictedToEnterprise, + ['can_non_owners_invite']: val.canNonOwnersInvite, + ['can_shared_link_be_created']: val.canSharedLinkBeCreated, + }; +} +export function deserializeHubUpdateRequestV2025R0( + val: SerializedData, +): HubUpdateRequestV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubUpdateRequestV2025R0"', + }); + } + if (!(val.title == void 0) && !sdIsString(val.title)) { + throw new BoxSdkError({ + message: 'Expecting string for "title" of type "HubUpdateRequestV2025R0"', + }); + } + const title: undefined | string = val.title == void 0 ? void 0 : val.title; + if (!(val.description == void 0) && !sdIsString(val.description)) { + throw new BoxSdkError({ + message: + 'Expecting string for "description" of type "HubUpdateRequestV2025R0"', + }); + } + const description: undefined | string = + val.description == void 0 ? void 0 : val.description; + if (!(val.is_ai_enabled == void 0) && !sdIsBoolean(val.is_ai_enabled)) { + throw new BoxSdkError({ + message: + 'Expecting boolean for "is_ai_enabled" of type "HubUpdateRequestV2025R0"', + }); + } + const isAiEnabled: undefined | boolean = + val.is_ai_enabled == void 0 ? void 0 : val.is_ai_enabled; + if ( + !(val.is_collaboration_restricted_to_enterprise == void 0) && + !sdIsBoolean(val.is_collaboration_restricted_to_enterprise) + ) { + throw new BoxSdkError({ + message: + 'Expecting boolean for "is_collaboration_restricted_to_enterprise" of type "HubUpdateRequestV2025R0"', + }); + } + const isCollaborationRestrictedToEnterprise: undefined | boolean = + val.is_collaboration_restricted_to_enterprise == void 0 + ? void 0 + : val.is_collaboration_restricted_to_enterprise; + if ( + !(val.can_non_owners_invite == void 0) && + !sdIsBoolean(val.can_non_owners_invite) + ) { + throw new BoxSdkError({ + message: + 'Expecting boolean for "can_non_owners_invite" of type "HubUpdateRequestV2025R0"', + }); + } + const canNonOwnersInvite: undefined | boolean = + val.can_non_owners_invite == void 0 ? void 0 : val.can_non_owners_invite; + if ( + !(val.can_shared_link_be_created == void 0) && + !sdIsBoolean(val.can_shared_link_be_created) + ) { + throw new BoxSdkError({ + message: + 'Expecting boolean for "can_shared_link_be_created" of type "HubUpdateRequestV2025R0"', + }); + } + const canSharedLinkBeCreated: undefined | boolean = + val.can_shared_link_be_created == void 0 + ? void 0 + : val.can_shared_link_be_created; + return { + title: title, + description: description, + isAiEnabled: isAiEnabled, + isCollaborationRestrictedToEnterprise: + isCollaborationRestrictedToEnterprise, + canNonOwnersInvite: canNonOwnersInvite, + canSharedLinkBeCreated: canSharedLinkBeCreated, + } satisfies HubUpdateRequestV2025R0; +} diff --git a/src/schemas/v2025R0/weblinkReferenceV2025R0.generated.ts b/src/schemas/v2025R0/weblinkReferenceV2025R0.generated.ts new file mode 100644 index 00000000..b39a615c --- /dev/null +++ b/src/schemas/v2025R0/weblinkReferenceV2025R0.generated.ts @@ -0,0 +1,132 @@ +import { BoxSdkError } from '../../box/errors.js'; +import { SerializedData } from '../../serialization/json.js'; +import { sdIsEmpty } from '../../serialization/json.js'; +import { sdIsBoolean } from '../../serialization/json.js'; +import { sdIsNumber } from '../../serialization/json.js'; +import { sdIsString } from '../../serialization/json.js'; +import { sdIsList } from '../../serialization/json.js'; +import { sdIsMap } from '../../serialization/json.js'; +export type WeblinkReferenceV2025R0TypeField = 'weblink'; +export class WeblinkReferenceV2025R0 { + /** + * The value will always be `weblink`. */ + readonly type: WeblinkReferenceV2025R0TypeField = + 'weblink' as WeblinkReferenceV2025R0TypeField; + /** + * ID of the weblink. */ + readonly id!: string; + readonly rawData?: SerializedData; + constructor( + fields: Omit & + Partial>, + ) { + if (fields.type !== undefined) { + this.type = fields.type; + } + if (fields.id !== undefined) { + this.id = fields.id; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + } +} +export interface WeblinkReferenceV2025R0Input { + /** + * The value will always be `weblink`. */ + readonly type?: WeblinkReferenceV2025R0TypeField; + /** + * ID of the weblink. */ + readonly id: string; + readonly rawData?: SerializedData; +} +export function serializeWeblinkReferenceV2025R0TypeField( + val: WeblinkReferenceV2025R0TypeField, +): SerializedData { + return val; +} +export function deserializeWeblinkReferenceV2025R0TypeField( + val: SerializedData, +): WeblinkReferenceV2025R0TypeField { + if (val == 'weblink') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize WeblinkReferenceV2025R0TypeField", + }); +} +export function serializeWeblinkReferenceV2025R0( + val: WeblinkReferenceV2025R0, +): SerializedData { + return { + ['type']: serializeWeblinkReferenceV2025R0TypeField(val.type), + ['id']: val.id, + }; +} +export function deserializeWeblinkReferenceV2025R0( + val: SerializedData, +): WeblinkReferenceV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "WeblinkReferenceV2025R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "WeblinkReferenceV2025R0" to be defined', + }); + } + const type: WeblinkReferenceV2025R0TypeField = + deserializeWeblinkReferenceV2025R0TypeField(val.type); + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "WeblinkReferenceV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "WeblinkReferenceV2025R0"', + }); + } + const id: string = val.id; + return { type: type, id: id } satisfies WeblinkReferenceV2025R0; +} +export function serializeWeblinkReferenceV2025R0Input( + val: WeblinkReferenceV2025R0Input, +): SerializedData { + return { + ['type']: + val.type == void 0 + ? val.type + : serializeWeblinkReferenceV2025R0TypeField(val.type), + ['id']: val.id, + }; +} +export function deserializeWeblinkReferenceV2025R0Input( + val: SerializedData, +): WeblinkReferenceV2025R0Input { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "WeblinkReferenceV2025R0Input"', + }); + } + const type: undefined | WeblinkReferenceV2025R0TypeField = + val.type == void 0 + ? void 0 + : deserializeWeblinkReferenceV2025R0TypeField(val.type); + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "WeblinkReferenceV2025R0Input" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "id" of type "WeblinkReferenceV2025R0Input"', + }); + } + const id: string = val.id; + return { type: type, id: id } satisfies WeblinkReferenceV2025R0Input; +} From 8a8c322874b7383b8ab5f44e81c53e146c0caedc Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 17 Jul 2025 06:38:58 -0700 Subject: [PATCH 5/5] fix: Error at 'Create metadata instance on file' box/box-openapi#393 (box/box-openapi#539) --- .codegen.json | 2 +- src/managers/fileMetadata.generated.ts | 3 ++ src/managers/folderMetadata.generated.ts | 3 ++ src/schemas/metadataError.generated.ts | 58 ++++++++++++++++++++++++ 4 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 src/schemas/metadataError.generated.ts diff --git a/.codegen.json b/.codegen.json index 47f6122d..f09c6d9c 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "fe7a2b2", "specHash": "7871ded", "version": "1.16.0" } +{ "engineHash": "fe7a2b2", "specHash": "eaa9cf0", "version": "1.16.0" } diff --git a/src/managers/fileMetadata.generated.ts b/src/managers/fileMetadata.generated.ts index 2e19bd8e..bce25fd0 100644 --- a/src/managers/fileMetadata.generated.ts +++ b/src/managers/fileMetadata.generated.ts @@ -4,12 +4,15 @@ import { serializeClientError } from '../schemas/clientError.generated.js'; import { deserializeClientError } from '../schemas/clientError.generated.js'; import { serializeMetadataFull } from '../schemas/metadataFull.generated.js'; import { deserializeMetadataFull } from '../schemas/metadataFull.generated.js'; +import { serializeMetadataError } from '../schemas/metadataError.generated.js'; +import { deserializeMetadataError } from '../schemas/metadataError.generated.js'; import { serializeMetadataInstanceValue } from '../schemas/metadataInstanceValue.generated.js'; import { deserializeMetadataInstanceValue } from '../schemas/metadataInstanceValue.generated.js'; import { ResponseFormat } from '../networking/fetchOptions.generated.js'; import { Metadatas } from '../schemas/metadatas.generated.js'; import { ClientError } from '../schemas/clientError.generated.js'; import { MetadataFull } from '../schemas/metadataFull.generated.js'; +import { MetadataError } from '../schemas/metadataError.generated.js'; import { MetadataInstanceValue } from '../schemas/metadataInstanceValue.generated.js'; import { BoxSdkError } from '../box/errors.js'; import { Authentication } from '../networking/auth.generated.js'; diff --git a/src/managers/folderMetadata.generated.ts b/src/managers/folderMetadata.generated.ts index 0804f469..68419144 100644 --- a/src/managers/folderMetadata.generated.ts +++ b/src/managers/folderMetadata.generated.ts @@ -4,12 +4,15 @@ import { serializeClientError } from '../schemas/clientError.generated.js'; import { deserializeClientError } from '../schemas/clientError.generated.js'; import { serializeMetadataFull } from '../schemas/metadataFull.generated.js'; import { deserializeMetadataFull } from '../schemas/metadataFull.generated.js'; +import { serializeMetadataError } from '../schemas/metadataError.generated.js'; +import { deserializeMetadataError } from '../schemas/metadataError.generated.js'; import { serializeMetadataInstanceValue } from '../schemas/metadataInstanceValue.generated.js'; import { deserializeMetadataInstanceValue } from '../schemas/metadataInstanceValue.generated.js'; import { ResponseFormat } from '../networking/fetchOptions.generated.js'; import { Metadatas } from '../schemas/metadatas.generated.js'; import { ClientError } from '../schemas/clientError.generated.js'; import { MetadataFull } from '../schemas/metadataFull.generated.js'; +import { MetadataError } from '../schemas/metadataError.generated.js'; import { MetadataInstanceValue } from '../schemas/metadataInstanceValue.generated.js'; import { BoxSdkError } from '../box/errors.js'; import { Authentication } from '../networking/auth.generated.js'; diff --git a/src/schemas/metadataError.generated.ts b/src/schemas/metadataError.generated.ts new file mode 100644 index 00000000..69b3e3e6 --- /dev/null +++ b/src/schemas/metadataError.generated.ts @@ -0,0 +1,58 @@ +import { BoxSdkError } from '../box/errors.js'; +import { SerializedData } from '../serialization/json.js'; +import { sdIsEmpty } from '../serialization/json.js'; +import { sdIsBoolean } from '../serialization/json.js'; +import { sdIsNumber } from '../serialization/json.js'; +import { sdIsString } from '../serialization/json.js'; +import { sdIsList } from '../serialization/json.js'; +import { sdIsMap } from '../serialization/json.js'; +export interface MetadataError { + /** + * A Box-specific error code. */ + readonly code?: string; + /** + * A short message describing the error. */ + readonly message?: string; + /** + * A unique identifier for this response, which can be used + * when contacting Box support. */ + readonly requestId?: string; + readonly rawData?: SerializedData; +} +export function serializeMetadataError(val: MetadataError): SerializedData { + return { + ['code']: val.code, + ['message']: val.message, + ['request_id']: val.requestId, + }; +} +export function deserializeMetadataError(val: SerializedData): MetadataError { + if (!sdIsMap(val)) { + throw new BoxSdkError({ message: 'Expecting a map for "MetadataError"' }); + } + if (!(val.code == void 0) && !sdIsString(val.code)) { + throw new BoxSdkError({ + message: 'Expecting string for "code" of type "MetadataError"', + }); + } + const code: undefined | string = val.code == void 0 ? void 0 : val.code; + if (!(val.message == void 0) && !sdIsString(val.message)) { + throw new BoxSdkError({ + message: 'Expecting string for "message" of type "MetadataError"', + }); + } + const message: undefined | string = + val.message == void 0 ? void 0 : val.message; + if (!(val.request_id == void 0) && !sdIsString(val.request_id)) { + throw new BoxSdkError({ + message: 'Expecting string for "request_id" of type "MetadataError"', + }); + } + const requestId: undefined | string = + val.request_id == void 0 ? void 0 : val.request_id; + return { + code: code, + message: message, + requestId: requestId, + } satisfies MetadataError; +}