diff --git a/.codegen.json b/.codegen.json index bdafad515..842e7b2f7 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "7c01dda", "specHash": "2bd751f", "version": "4.5.0" } +{ "engineHash": "e77f966", "specHash": "c8e3a85", "version": "4.5.0" } diff --git a/docs/sdk-gen/README.md b/docs/sdk-gen/README.md index 0925a2d7f..ff271aae2 100644 --- a/docs/sdk-gen/README.md +++ b/docs/sdk-gen/README.md @@ -48,6 +48,7 @@ the SDK are available by topic: * [Folders](folders.md) * [Groups](groups.md) * [Hub collaborations](hubCollaborations.md) +* [Hub document](hubDocument.md) * [Hub items](hubItems.md) * [Hubs](hubs.md) * [Integration mappings](integrationMappings.md) diff --git a/docs/sdk-gen/hubDocument.md b/docs/sdk-gen/hubDocument.md new file mode 100644 index 000000000..6c3422128 --- /dev/null +++ b/docs/sdk-gen/hubDocument.md @@ -0,0 +1,69 @@ +# HubDocumentManager + + +- [List Hub Document Pages](#list-hub-document-pages) +- [List Hub Document blocks for page](#list-hub-document-blocks-for-page) + +## List Hub Document Pages + +Retrieves a list of Hub Document Pages for the specified hub. +Includes both root-level pages and sub pages. + +This operation is performed by calling function `getHubDocumentPagesV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/get-hub-document-pages/). + + +```ts +await client.hubDocument.getHubDocumentPagesV2025R0({ hubId: hubId } satisfies GetHubDocumentPagesV2025R0QueryParams) +``` + +### Arguments + +- queryParams `GetHubDocumentPagesV2025R0QueryParams` + - Query parameters of getHubDocumentPagesV2025R0 method +- optionalsInput `GetHubDocumentPagesV2025R0OptionalsInput` + + + +### Returns + +This function returns a value of type `HubDocumentPagesV2025R0`. + +Returns a Hub Document Pages response whose `entries` array contains root-level pages and sub pages. Includes pagination when more results are available. + + +## List Hub Document blocks for page + +Retrieves a sorted list of all Hub Document Blocks on a specified page in the hub document, excluding items. +Blocks are hierarchically organized by their `parent_id`. +Blocks are sorted in order based on user specification in the user interface. +The response will only include content blocks that belong to the specified page. This will not include sub pages or sub page content blocks. + +This operation is performed by calling function `getHubDocumentBlocksV2025R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2025.0/get-hub-document-blocks/). + + +```ts +await client.hubDocument.getHubDocumentBlocksV2025R0({ hubId: hubId, pageId: pageId } satisfies GetHubDocumentBlocksV2025R0QueryParams) +``` + +### Arguments + +- queryParams `GetHubDocumentBlocksV2025R0QueryParams` + - Query parameters of getHubDocumentBlocksV2025R0 method +- optionalsInput `GetHubDocumentBlocksV2025R0OptionalsInput` + + + +### Returns + +This function returns a value of type `HubDocumentBlocksV2025R0`. + +Returns a Hub Document Blocks response whose `entries` array contains all content blocks of the specified page, except for items. +To retrieve items, use the `GET /hub_items` endpoint. + + diff --git a/docs/sdk-gen/trashedItems.md b/docs/sdk-gen/trashedItems.md index bfc38809d..affac7041 100644 --- a/docs/sdk-gen/trashedItems.md +++ b/docs/sdk-gen/trashedItems.md @@ -13,7 +13,9 @@ in with the `fields` parameter to retrieve those specific attributes that are not returned by default. This endpoint defaults to use offset-based pagination, yet also supports -marker-based pagination using the `marker` parameter. +marker-based pagination using the `marker` parameter. + +The number of entries returned may be less than `total_count`. For example, if a user deletes items from a shared folder and is later removed as a collaborator, those deleted items will no longer appear in this endpoint’s results, even though they are still included in `total_count`. This operation is performed by calling function `getTrashedItems`. diff --git a/src/sdk-gen/client.ts b/src/sdk-gen/client.ts index 0515f54e0..f83edf58c 100644 --- a/src/sdk-gen/client.ts +++ b/src/sdk-gen/client.ts @@ -81,6 +81,7 @@ import { EnterpriseConfigurationsManager } from './managers/enterpriseConfigurat import { HubsManager } from './managers/hubs'; import { HubCollaborationsManager } from './managers/hubCollaborations'; import { HubItemsManager } from './managers/hubItems'; +import { HubDocumentManager } from './managers/hubDocument'; import { ShieldListsManager } from './managers/shieldLists'; import { ArchivesManager } from './managers/archives'; import { ExternalUsersManager } from './managers/externalUsers'; @@ -185,6 +186,7 @@ export class BoxClient { readonly hubs: HubsManager; readonly hubCollaborations: HubCollaborationsManager; readonly hubItems: HubItemsManager; + readonly hubDocument: HubDocumentManager; readonly shieldLists: ShieldListsManager; readonly archives: ArchivesManager; readonly externalUsers: ExternalUsersManager; @@ -270,6 +272,7 @@ export class BoxClient { | 'hubs' | 'hubCollaborations' | 'hubItems' + | 'hubDocument' | 'shieldLists' | 'archives' | 'externalUsers' @@ -614,6 +617,10 @@ export class BoxClient { auth: this.auth, networkSession: this.networkSession, }); + this.hubDocument = new HubDocumentManager({ + auth: this.auth, + networkSession: this.networkSession, + }); this.shieldLists = new ShieldListsManager({ auth: this.auth, networkSession: this.networkSession, diff --git a/src/sdk-gen/managers/hubDocument.ts b/src/sdk-gen/managers/hubDocument.ts new file mode 100644 index 000000000..088c27ecb --- /dev/null +++ b/src/sdk-gen/managers/hubDocument.ts @@ -0,0 +1,330 @@ +import { serializeHubDocumentPagesV2025R0 } from '../schemas/v2025R0/hubDocumentPagesV2025R0'; +import { deserializeHubDocumentPagesV2025R0 } from '../schemas/v2025R0/hubDocumentPagesV2025R0'; +import { serializeClientErrorV2025R0 } from '../schemas/v2025R0/clientErrorV2025R0'; +import { deserializeClientErrorV2025R0 } from '../schemas/v2025R0/clientErrorV2025R0'; +import { serializeBoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0'; +import { deserializeBoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0'; +import { serializeHubDocumentBlocksV2025R0 } from '../schemas/v2025R0/hubDocumentBlocksV2025R0'; +import { deserializeHubDocumentBlocksV2025R0 } from '../schemas/v2025R0/hubDocumentBlocksV2025R0'; +import { ResponseFormat } from '../networking/fetchOptions'; +import { HubDocumentPagesV2025R0 } from '../schemas/v2025R0/hubDocumentPagesV2025R0'; +import { ClientErrorV2025R0 } from '../schemas/v2025R0/clientErrorV2025R0'; +import { BoxVersionHeaderV2025R0 } from '../parameters/v2025R0/boxVersionHeaderV2025R0'; +import { HubDocumentBlocksV2025R0 } from '../schemas/v2025R0/hubDocumentBlocksV2025R0'; +import { BoxSdkError } from '../box/errors'; +import { Authentication } from '../networking/auth'; +import { NetworkSession } from '../networking/network'; +import { FetchOptions } from '../networking/fetchOptions'; +import { FetchResponse } from '../networking/fetchResponse'; +import { prepareParams } from '../internal/utils'; +import { toString } from '../internal/utils'; +import { ByteStream } from '../internal/utils'; +import { CancellationToken } from '../internal/utils'; +import { sdToJson } from '../serialization/json'; +import { SerializedData } from '../serialization/json'; +import { sdIsEmpty } from '../serialization/json'; +import { sdIsBoolean } from '../serialization/json'; +import { sdIsNumber } from '../serialization/json'; +import { sdIsString } from '../serialization/json'; +import { sdIsList } from '../serialization/json'; +import { sdIsMap } from '../serialization/json'; +export class GetHubDocumentPagesV2025R0Optionals { + readonly headers: GetHubDocumentPagesV2025R0Headers = + new GetHubDocumentPagesV2025R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit< + GetHubDocumentPagesV2025R0Optionals, + 'headers' | 'cancellationToken' + > & + Partial< + Pick< + GetHubDocumentPagesV2025R0Optionals, + 'headers' | 'cancellationToken' + > + > + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface GetHubDocumentPagesV2025R0OptionalsInput { + readonly headers?: GetHubDocumentPagesV2025R0Headers; + readonly cancellationToken?: CancellationToken; +} +export class GetHubDocumentBlocksV2025R0Optionals { + readonly headers: GetHubDocumentBlocksV2025R0Headers = + new GetHubDocumentBlocksV2025R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit< + GetHubDocumentBlocksV2025R0Optionals, + 'headers' | 'cancellationToken' + > & + Partial< + Pick< + GetHubDocumentBlocksV2025R0Optionals, + 'headers' | 'cancellationToken' + > + > + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface GetHubDocumentBlocksV2025R0OptionalsInput { + readonly headers?: GetHubDocumentBlocksV2025R0Headers; + readonly cancellationToken?: CancellationToken; +} +export interface GetHubDocumentPagesV2025R0QueryParams { + /** + * 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. */ + readonly marker?: string; + /** + * The maximum number of items to return per page. */ + readonly limit?: number; +} +export class GetHubDocumentPagesV2025R0Headers { + /** + * 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< + GetHubDocumentPagesV2025R0Headers, + 'boxVersion' | 'extraHeaders' + > & + Partial< + Pick + > + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface GetHubDocumentPagesV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + }; +} +export interface GetHubDocumentBlocksV2025R0QueryParams { + /** + * 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; + /** + * The unique identifier of a page within the Box Hub. */ + readonly pageId: string; + /** + * Defines the position marker at which to begin returning results. This is + * used when paginating using marker-based pagination. */ + readonly marker?: string; + /** + * The maximum number of items to return per page. */ + readonly limit?: number; +} +export class GetHubDocumentBlocksV2025R0Headers { + /** + * 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< + GetHubDocumentBlocksV2025R0Headers, + 'boxVersion' | 'extraHeaders' + > & + Partial< + Pick + > + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface GetHubDocumentBlocksV2025R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2025R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + }; +} +export class HubDocumentManager { + readonly auth?: Authentication; + readonly networkSession: NetworkSession = new NetworkSession({}); + constructor( + fields: Omit< + HubDocumentManager, + | 'networkSession' + | 'getHubDocumentPagesV2025R0' + | 'getHubDocumentBlocksV2025R0' + > & + Partial> + ) { + if (fields.auth !== undefined) { + this.auth = fields.auth; + } + if (fields.networkSession !== undefined) { + this.networkSession = fields.networkSession; + } + } + /** + * Retrieves a list of Hub Document Pages for the specified hub. + * Includes both root-level pages and sub pages. + * @param {GetHubDocumentPagesV2025R0QueryParams} queryParams Query parameters of getHubDocumentPagesV2025R0 method + * @param {GetHubDocumentPagesV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async getHubDocumentPagesV2025R0( + queryParams: GetHubDocumentPagesV2025R0QueryParams, + optionalsInput: GetHubDocumentPagesV2025R0OptionalsInput = {} + ): Promise { + const optionals: GetHubDocumentPagesV2025R0Optionals = + new GetHubDocumentPagesV2025R0Optionals({ + 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_document_pages' + ) as string, + method: 'GET', + params: queryParamsMap, + headers: headersMap, + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }) + ); + return { + ...deserializeHubDocumentPagesV2025R0(response.data!), + rawData: response.data!, + }; + } + /** + * Retrieves a sorted list of all Hub Document Blocks on a specified page in the hub document, excluding items. + * Blocks are hierarchically organized by their `parent_id`. + * Blocks are sorted in order based on user specification in the user interface. + * The response will only include content blocks that belong to the specified page. This will not include sub pages or sub page content blocks. + * @param {GetHubDocumentBlocksV2025R0QueryParams} queryParams Query parameters of getHubDocumentBlocksV2025R0 method + * @param {GetHubDocumentBlocksV2025R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async getHubDocumentBlocksV2025R0( + queryParams: GetHubDocumentBlocksV2025R0QueryParams, + optionalsInput: GetHubDocumentBlocksV2025R0OptionalsInput = {} + ): Promise { + const optionals: GetHubDocumentBlocksV2025R0Optionals = + new GetHubDocumentBlocksV2025R0Optionals({ + 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, + ['page_id']: toString(queryParams.pageId) 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_document_blocks' + ) as string, + method: 'GET', + params: queryParamsMap, + headers: headersMap, + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }) + ); + return { + ...deserializeHubDocumentBlocksV2025R0(response.data!), + rawData: response.data!, + }; + } +} +export interface HubDocumentManagerInput { + readonly auth?: Authentication; + readonly networkSession?: NetworkSession; +} diff --git a/src/sdk-gen/managers/index.ts b/src/sdk-gen/managers/index.ts index 391de29b7..5eed9cd09 100644 --- a/src/sdk-gen/managers/index.ts +++ b/src/sdk-gen/managers/index.ts @@ -77,6 +77,7 @@ export * from './enterpriseConfigurations'; export * from './hubs'; export * from './hubCollaborations'; export * from './hubItems'; +export * from './hubDocument'; export * from './shieldLists'; export * from './archives'; export * from './externalUsers'; diff --git a/src/sdk-gen/managers/search.ts b/src/sdk-gen/managers/search.ts index c3f650fa1..67ae8ef1b 100644 --- a/src/sdk-gen/managers/search.ts +++ b/src/sdk-gen/managers/search.ts @@ -93,7 +93,7 @@ export type SearchForContentQueryParamsContentTypesField = | 'description' | 'file_content' | 'comments' - | 'tag' + | 'tags' | string; export type SearchForContentQueryParamsTypeField = | 'file' @@ -595,7 +595,7 @@ export function deserializeSearchForContentQueryParamsContentTypesField( if (val == 'comments') { return val; } - if (val == 'tag') { + if (val == 'tags') { return val; } if (sdIsString(val)) { diff --git a/src/sdk-gen/managers/trashedItems.ts b/src/sdk-gen/managers/trashedItems.ts index 3e0abfc6f..8603bc81c 100644 --- a/src/sdk-gen/managers/trashedItems.ts +++ b/src/sdk-gen/managers/trashedItems.ts @@ -126,6 +126,8 @@ export class TrashedItemsManager { * * This endpoint defaults to use offset-based pagination, yet also supports * marker-based pagination using the `marker` parameter. + * + * The number of entries returned may be less than `total_count`. For example, if a user deletes items from a shared folder and is later removed as a collaborator, those deleted items will no longer appear in this endpoint’s results, even though they are still included in `total_count`. * @param {GetTrashedItemsQueryParams} queryParams Query parameters of getTrashedItems method * @param {GetTrashedItemsHeadersInput} headersInput Headers of getTrashedItems method * @param {CancellationToken} cancellationToken Token used for request cancellation. diff --git a/src/sdk-gen/schemas/index.ts b/src/sdk-gen/schemas/index.ts index a8847c9cb..3ca7e9645 100644 --- a/src/sdk-gen/schemas/index.ts +++ b/src/sdk-gen/schemas/index.ts @@ -95,6 +95,7 @@ export * from './integrationMappingSlackOptions'; export * from './integrationMappingSlackCreateRequest'; export * from './keywordSkillCard'; export * from './legalHoldPolicyMini'; +export * from './legalHoldPolicyAssignedItem'; export * from './legalHoldPolicyAssignmentBase'; export * from './metadataBase'; export * from './metadata'; @@ -208,6 +209,10 @@ export * from './retentionPolicyAssignment'; export * from './retentionPolicyAssignments'; export * from './retentionPolicy'; export * from './retentionPolicies'; +export * from './legalHoldPolicyAssignment'; +export * from './legalHoldPolicyAssignments'; +export * from './fileVersionLegalHold'; +export * from './fileVersionLegalHolds'; export * from './legalHoldPolicy'; export * from './legalHoldPolicies'; export * from './invite'; @@ -261,11 +266,6 @@ export * from './item'; export * from './itemsOffsetPaginated'; export * from './items'; export * from './folder'; -export * from './legalHoldPolicyAssignedItem'; -export * from './legalHoldPolicyAssignment'; -export * from './legalHoldPolicyAssignments'; -export * from './fileVersionLegalHold'; -export * from './fileVersionLegalHolds'; export * from './folderFull'; export * from './searchResultWithSharedLinkItem'; export * from './searchResultWithSharedLink'; diff --git a/src/sdk-gen/schemas/legalHoldPolicyAssignedItem.ts b/src/sdk-gen/schemas/legalHoldPolicyAssignedItem.ts index 05b6031a3..bf789d72f 100644 --- a/src/sdk-gen/schemas/legalHoldPolicyAssignedItem.ts +++ b/src/sdk-gen/schemas/legalHoldPolicyAssignedItem.ts @@ -1,12 +1,3 @@ -import { serializeFile } from './file'; -import { deserializeFile } from './file'; -import { serializeFolder } from './folder'; -import { deserializeFolder } from './folder'; -import { serializeWebLink } from './webLink'; -import { deserializeWebLink } from './webLink'; -import { File } from './file'; -import { Folder } from './folder'; -import { WebLink } from './webLink'; import { BoxSdkError } from '../box/errors'; import { SerializedData } from '../serialization/json'; import { sdIsEmpty } from '../serialization/json'; @@ -15,18 +6,59 @@ import { sdIsNumber } from '../serialization/json'; import { sdIsString } from '../serialization/json'; import { sdIsList } from '../serialization/json'; import { sdIsMap } from '../serialization/json'; -export type LegalHoldPolicyAssignedItem = File | Folder | WebLink; -export function serializeLegalHoldPolicyAssignedItem(val: any): SerializedData { - if (val.type == 'file') { - return serializeFile(val); +export type LegalHoldPolicyAssignedItemTypeField = + | 'file' + | 'file_version' + | 'folder' + | 'user' + | 'ownership' + | 'interactions'; +export interface LegalHoldPolicyAssignedItem { + /** + * The type of item the policy is assigned to. */ + readonly type: LegalHoldPolicyAssignedItemTypeField; + /** + * The ID of the item the policy is assigned to. */ + readonly id: string; + readonly rawData?: SerializedData; +} +export function serializeLegalHoldPolicyAssignedItemTypeField( + val: LegalHoldPolicyAssignedItemTypeField +): SerializedData { + return val; +} +export function deserializeLegalHoldPolicyAssignedItemTypeField( + val: SerializedData +): LegalHoldPolicyAssignedItemTypeField { + if (val == 'file') { + return val; + } + if (val == 'file_version') { + return val; + } + if (val == 'folder') { + return val; } - if (val.type == 'folder') { - return serializeFolder(val); + if (val == 'user') { + return val; } - if (val.type == 'web_link') { - return serializeWebLink(val); + if (val == 'ownership') { + return val; } - throw new BoxSdkError({ message: 'unknown type' }); + if (val == 'interactions') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize LegalHoldPolicyAssignedItemTypeField", + }); +} +export function serializeLegalHoldPolicyAssignedItem( + val: LegalHoldPolicyAssignedItem +): SerializedData { + return { + ['type']: serializeLegalHoldPolicyAssignedItemTypeField(val.type), + ['id']: val.id, + }; } export function deserializeLegalHoldPolicyAssignedItem( val: SerializedData @@ -36,16 +68,26 @@ export function deserializeLegalHoldPolicyAssignedItem( message: 'Expecting a map for "LegalHoldPolicyAssignedItem"', }); } - if (val.type == 'file') { - return deserializeFile(val); + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "LegalHoldPolicyAssignedItem" to be defined', + }); } - if (val.type == 'folder') { - return deserializeFolder(val); + const type: LegalHoldPolicyAssignedItemTypeField = + deserializeLegalHoldPolicyAssignedItemTypeField(val.type); + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "LegalHoldPolicyAssignedItem" to be defined', + }); } - if (val.type == 'web_link') { - return deserializeWebLink(val); + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "id" of type "LegalHoldPolicyAssignedItem"', + }); } - throw new BoxSdkError({ - message: "Can't deserialize LegalHoldPolicyAssignedItem", - }); + const id: string = val.id; + return { type: type, id: id } satisfies LegalHoldPolicyAssignedItem; } diff --git a/src/sdk-gen/schemas/legalHoldPolicyAssignment.ts b/src/sdk-gen/schemas/legalHoldPolicyAssignment.ts index fb0861d01..7e8c40648 100644 --- a/src/sdk-gen/schemas/legalHoldPolicyAssignment.ts +++ b/src/sdk-gen/schemas/legalHoldPolicyAssignment.ts @@ -1,11 +1,5 @@ import { serializeLegalHoldPolicyAssignmentBaseTypeField } from './legalHoldPolicyAssignmentBase'; import { deserializeLegalHoldPolicyAssignmentBaseTypeField } from './legalHoldPolicyAssignmentBase'; -import { serializeFile } from './file'; -import { deserializeFile } from './file'; -import { serializeFolder } from './folder'; -import { deserializeFolder } from './folder'; -import { serializeWebLink } from './webLink'; -import { deserializeWebLink } from './webLink'; import { serializeLegalHoldPolicyAssignmentBase } from './legalHoldPolicyAssignmentBase'; import { deserializeLegalHoldPolicyAssignmentBase } from './legalHoldPolicyAssignmentBase'; import { serializeLegalHoldPolicyMini } from './legalHoldPolicyMini'; @@ -17,9 +11,6 @@ import { deserializeUserMini } from './userMini'; import { serializeDateTime } from '../internal/utils'; import { deserializeDateTime } from '../internal/utils'; import { LegalHoldPolicyAssignmentBaseTypeField } from './legalHoldPolicyAssignmentBase'; -import { File } from './file'; -import { Folder } from './folder'; -import { WebLink } from './webLink'; import { LegalHoldPolicyAssignmentBase } from './legalHoldPolicyAssignmentBase'; import { LegalHoldPolicyMini } from './legalHoldPolicyMini'; import { LegalHoldPolicyAssignedItem } from './legalHoldPolicyAssignedItem'; diff --git a/src/sdk-gen/schemas/v2025R0/hubCalloutBoxTextBlockV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubCalloutBoxTextBlockV2025R0.ts new file mode 100644 index 000000000..4c538d74f --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubCalloutBoxTextBlockV2025R0.ts @@ -0,0 +1,133 @@ +import { serializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { deserializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { HubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubCalloutBoxTextBlockV2025R0TypeField = 'callout_box'; +export class HubCalloutBoxTextBlockV2025R0 implements HubDocumentBlockV2025R0 { + readonly id!: string; + readonly parentId?: string | null; + readonly rawData?: SerializedData; + /** + * The type of this block. The value is always `callout_box`. */ + readonly type: HubCalloutBoxTextBlockV2025R0TypeField = + 'callout_box' as HubCalloutBoxTextBlockV2025R0TypeField; + /** + * Text content of the block. Includes rich text formatting. */ + readonly fragment!: string; + constructor( + fields: Omit & + Partial> + ) { + if (fields.id !== undefined) { + this.id = fields.id; + } + if (fields.parentId !== undefined) { + this.parentId = fields.parentId; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + if (fields.type !== undefined) { + this.type = fields.type; + } + if (fields.fragment !== undefined) { + this.fragment = fields.fragment; + } + } +} +export function serializeHubCalloutBoxTextBlockV2025R0TypeField( + val: HubCalloutBoxTextBlockV2025R0TypeField +): SerializedData { + return val; +} +export function deserializeHubCalloutBoxTextBlockV2025R0TypeField( + val: SerializedData +): HubCalloutBoxTextBlockV2025R0TypeField { + if (val == 'callout_box') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubCalloutBoxTextBlockV2025R0TypeField", + }); +} +export function serializeHubCalloutBoxTextBlockV2025R0( + val: HubCalloutBoxTextBlockV2025R0 +): SerializedData { + const base: any = serializeHubDocumentBlockV2025R0(val); + if (!sdIsMap(base)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubCalloutBoxTextBlockV2025R0"', + }); + } + return { + ...base, + ...{ + ['type']: serializeHubCalloutBoxTextBlockV2025R0TypeField(val.type), + ['fragment']: val.fragment, + }, + }; +} +export function deserializeHubCalloutBoxTextBlockV2025R0( + val: SerializedData +): HubCalloutBoxTextBlockV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubCalloutBoxTextBlockV2025R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubCalloutBoxTextBlockV2025R0" to be defined', + }); + } + const type: HubCalloutBoxTextBlockV2025R0TypeField = + deserializeHubCalloutBoxTextBlockV2025R0TypeField(val.type); + if (val.fragment == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "fragment" of type "HubCalloutBoxTextBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.fragment)) { + throw new BoxSdkError({ + message: + 'Expecting string for "fragment" of type "HubCalloutBoxTextBlockV2025R0"', + }); + } + const fragment: string = val.fragment; + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "HubCalloutBoxTextBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "id" of type "HubCalloutBoxTextBlockV2025R0"', + }); + } + const id: string = val.id; + if (!(val.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubCalloutBoxTextBlockV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; + return { + type: type, + fragment: fragment, + id: id, + parentId: parentId, + } satisfies HubCalloutBoxTextBlockV2025R0; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubDividerBlockV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubDividerBlockV2025R0.ts new file mode 100644 index 000000000..886478570 --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubDividerBlockV2025R0.ts @@ -0,0 +1,108 @@ +import { serializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { deserializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { HubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubDividerBlockV2025R0TypeField = 'divider'; +export class HubDividerBlockV2025R0 implements HubDocumentBlockV2025R0 { + readonly id!: string; + readonly parentId?: string | null; + readonly rawData?: SerializedData; + /** + * The type of this block. The value is always `divider`. */ + readonly type: HubDividerBlockV2025R0TypeField = + 'divider' as HubDividerBlockV2025R0TypeField; + constructor( + fields: Omit & + Partial> + ) { + if (fields.id !== undefined) { + this.id = fields.id; + } + if (fields.parentId !== undefined) { + this.parentId = fields.parentId; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + if (fields.type !== undefined) { + this.type = fields.type; + } + } +} +export function serializeHubDividerBlockV2025R0TypeField( + val: HubDividerBlockV2025R0TypeField +): SerializedData { + return val; +} +export function deserializeHubDividerBlockV2025R0TypeField( + val: SerializedData +): HubDividerBlockV2025R0TypeField { + if (val == 'divider') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubDividerBlockV2025R0TypeField", + }); +} +export function serializeHubDividerBlockV2025R0( + val: HubDividerBlockV2025R0 +): SerializedData { + const base: any = serializeHubDocumentBlockV2025R0(val); + if (!sdIsMap(base)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDividerBlockV2025R0"', + }); + } + return { + ...base, + ...{ ['type']: serializeHubDividerBlockV2025R0TypeField(val.type) }, + }; +} +export function deserializeHubDividerBlockV2025R0( + val: SerializedData +): HubDividerBlockV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDividerBlockV2025R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubDividerBlockV2025R0" to be defined', + }); + } + const type: HubDividerBlockV2025R0TypeField = + deserializeHubDividerBlockV2025R0TypeField(val.type); + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "HubDividerBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "HubDividerBlockV2025R0"', + }); + } + const id: string = val.id; + if (!(val.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubDividerBlockV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; + return { + type: type, + id: id, + parentId: parentId, + } satisfies HubDividerBlockV2025R0; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubDocumentBlockEntryV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubDocumentBlockEntryV2025R0.ts new file mode 100644 index 000000000..0d7db5762 --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubDocumentBlockEntryV2025R0.ts @@ -0,0 +1,76 @@ +import { serializeHubParagraphTextBlockV2025R0 } from './hubParagraphTextBlockV2025R0'; +import { deserializeHubParagraphTextBlockV2025R0 } from './hubParagraphTextBlockV2025R0'; +import { serializeHubSectionTitleTextBlockV2025R0 } from './hubSectionTitleTextBlockV2025R0'; +import { deserializeHubSectionTitleTextBlockV2025R0 } from './hubSectionTitleTextBlockV2025R0'; +import { serializeHubCalloutBoxTextBlockV2025R0 } from './hubCalloutBoxTextBlockV2025R0'; +import { deserializeHubCalloutBoxTextBlockV2025R0 } from './hubCalloutBoxTextBlockV2025R0'; +import { serializeHubItemListBlockV2025R0 } from './hubItemListBlockV2025R0'; +import { deserializeHubItemListBlockV2025R0 } from './hubItemListBlockV2025R0'; +import { serializeHubDividerBlockV2025R0 } from './hubDividerBlockV2025R0'; +import { deserializeHubDividerBlockV2025R0 } from './hubDividerBlockV2025R0'; +import { HubParagraphTextBlockV2025R0 } from './hubParagraphTextBlockV2025R0'; +import { HubSectionTitleTextBlockV2025R0 } from './hubSectionTitleTextBlockV2025R0'; +import { HubCalloutBoxTextBlockV2025R0 } from './hubCalloutBoxTextBlockV2025R0'; +import { HubItemListBlockV2025R0 } from './hubItemListBlockV2025R0'; +import { HubDividerBlockV2025R0 } from './hubDividerBlockV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubDocumentBlockEntryV2025R0 = + | HubParagraphTextBlockV2025R0 + | HubSectionTitleTextBlockV2025R0 + | HubCalloutBoxTextBlockV2025R0 + | HubItemListBlockV2025R0 + | HubDividerBlockV2025R0; +export function serializeHubDocumentBlockEntryV2025R0( + val: any +): SerializedData { + if (val.type == 'paragraph') { + return serializeHubParagraphTextBlockV2025R0(val); + } + if (val.type == 'section_title') { + return serializeHubSectionTitleTextBlockV2025R0(val); + } + if (val.type == 'callout_box') { + return serializeHubCalloutBoxTextBlockV2025R0(val); + } + if (val.type == 'item_list') { + return serializeHubItemListBlockV2025R0(val); + } + if (val.type == 'divider') { + return serializeHubDividerBlockV2025R0(val); + } + throw new BoxSdkError({ message: 'unknown type' }); +} +export function deserializeHubDocumentBlockEntryV2025R0( + val: SerializedData +): HubDocumentBlockEntryV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDocumentBlockEntryV2025R0"', + }); + } + if (val.type == 'paragraph') { + return deserializeHubParagraphTextBlockV2025R0(val); + } + if (val.type == 'section_title') { + return deserializeHubSectionTitleTextBlockV2025R0(val); + } + if (val.type == 'callout_box') { + return deserializeHubCalloutBoxTextBlockV2025R0(val); + } + if (val.type == 'item_list') { + return deserializeHubItemListBlockV2025R0(val); + } + if (val.type == 'divider') { + return deserializeHubDividerBlockV2025R0(val); + } + throw new BoxSdkError({ + message: "Can't deserialize HubDocumentBlockEntryV2025R0", + }); +} diff --git a/src/sdk-gen/schemas/v2025R0/hubDocumentBlockV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubDocumentBlockV2025R0.ts new file mode 100644 index 000000000..2b8f7d2b1 --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubDocumentBlockV2025R0.ts @@ -0,0 +1,51 @@ +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export interface HubDocumentBlockV2025R0 { + /** + * The unique identifier for this block. */ + readonly id: string; + /** + * The unique identifier of the parent block. Null for direct children of the page. */ + readonly parentId?: string | null; + readonly rawData?: SerializedData; +} +export function serializeHubDocumentBlockV2025R0( + val: HubDocumentBlockV2025R0 +): SerializedData { + return { ['id']: val.id, ['parent_id']: val.parentId }; +} +export function deserializeHubDocumentBlockV2025R0( + val: SerializedData +): HubDocumentBlockV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDocumentBlockV2025R0"', + }); + } + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "HubDocumentBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "HubDocumentBlockV2025R0"', + }); + } + const id: string = val.id; + if (!(val.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubDocumentBlockV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; + return { id: id, parentId: parentId } satisfies HubDocumentBlockV2025R0; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubDocumentBlocksV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubDocumentBlocksV2025R0.ts new file mode 100644 index 000000000..9a8a031e5 --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubDocumentBlocksV2025R0.ts @@ -0,0 +1,238 @@ +import { serializeHubParagraphTextBlockV2025R0 } from './hubParagraphTextBlockV2025R0'; +import { deserializeHubParagraphTextBlockV2025R0 } from './hubParagraphTextBlockV2025R0'; +import { serializeHubSectionTitleTextBlockV2025R0 } from './hubSectionTitleTextBlockV2025R0'; +import { deserializeHubSectionTitleTextBlockV2025R0 } from './hubSectionTitleTextBlockV2025R0'; +import { serializeHubCalloutBoxTextBlockV2025R0 } from './hubCalloutBoxTextBlockV2025R0'; +import { deserializeHubCalloutBoxTextBlockV2025R0 } from './hubCalloutBoxTextBlockV2025R0'; +import { serializeHubItemListBlockV2025R0 } from './hubItemListBlockV2025R0'; +import { deserializeHubItemListBlockV2025R0 } from './hubItemListBlockV2025R0'; +import { serializeHubDividerBlockV2025R0 } from './hubDividerBlockV2025R0'; +import { deserializeHubDividerBlockV2025R0 } from './hubDividerBlockV2025R0'; +import { serializeHubDocumentBlockEntryV2025R0 } from './hubDocumentBlockEntryV2025R0'; +import { deserializeHubDocumentBlockEntryV2025R0 } from './hubDocumentBlockEntryV2025R0'; +import { HubParagraphTextBlockV2025R0 } from './hubParagraphTextBlockV2025R0'; +import { HubSectionTitleTextBlockV2025R0 } from './hubSectionTitleTextBlockV2025R0'; +import { HubCalloutBoxTextBlockV2025R0 } from './hubCalloutBoxTextBlockV2025R0'; +import { HubItemListBlockV2025R0 } from './hubItemListBlockV2025R0'; +import { HubDividerBlockV2025R0 } from './hubDividerBlockV2025R0'; +import { HubDocumentBlockEntryV2025R0 } from './hubDocumentBlockEntryV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubDocumentBlocksV2025R0TypeField = 'document_blocks'; +export class HubDocumentBlocksV2025R0 { + /** + * Ordered list of blocks. */ + readonly entries!: readonly HubDocumentBlockEntryV2025R0[]; + /** + * The value will always be `document_blocks`. */ + readonly type: HubDocumentBlocksV2025R0TypeField = + 'document_blocks' as HubDocumentBlocksV2025R0TypeField; + /** + * 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; + constructor( + fields: Omit & + Partial> + ) { + if (fields.entries !== undefined) { + this.entries = fields.entries; + } + if (fields.type !== undefined) { + this.type = fields.type; + } + if (fields.limit !== undefined) { + this.limit = fields.limit; + } + if (fields.nextMarker !== undefined) { + this.nextMarker = fields.nextMarker; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + } +} +export interface HubDocumentBlocksV2025R0Input { + /** + * Ordered list of blocks. */ + readonly entries: readonly HubDocumentBlockEntryV2025R0[]; + /** + * The value will always be `document_blocks`. */ + readonly type?: HubDocumentBlocksV2025R0TypeField; + /** + * 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 serializeHubDocumentBlocksV2025R0TypeField( + val: HubDocumentBlocksV2025R0TypeField +): SerializedData { + return val; +} +export function deserializeHubDocumentBlocksV2025R0TypeField( + val: SerializedData +): HubDocumentBlocksV2025R0TypeField { + if (val == 'document_blocks') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubDocumentBlocksV2025R0TypeField", + }); +} +export function serializeHubDocumentBlocksV2025R0( + val: HubDocumentBlocksV2025R0 +): SerializedData { + return { + ['entries']: val.entries.map(function ( + item: HubDocumentBlockEntryV2025R0 + ): SerializedData { + return serializeHubDocumentBlockEntryV2025R0(item); + }) as readonly any[], + ['type']: serializeHubDocumentBlocksV2025R0TypeField(val.type), + ['limit']: val.limit, + ['next_marker']: val.nextMarker, + }; +} +export function deserializeHubDocumentBlocksV2025R0( + val: SerializedData +): HubDocumentBlocksV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDocumentBlocksV2025R0"', + }); + } + if (val.entries == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "entries" of type "HubDocumentBlocksV2025R0" to be defined', + }); + } + if (!sdIsList(val.entries)) { + throw new BoxSdkError({ + message: + 'Expecting array for "entries" of type "HubDocumentBlocksV2025R0"', + }); + } + const entries: readonly HubDocumentBlockEntryV2025R0[] = sdIsList(val.entries) + ? (val.entries.map(function ( + itm: SerializedData + ): HubDocumentBlockEntryV2025R0 { + return deserializeHubDocumentBlockEntryV2025R0(itm); + }) as readonly any[]) + : []; + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubDocumentBlocksV2025R0" to be defined', + }); + } + const type: HubDocumentBlocksV2025R0TypeField = + deserializeHubDocumentBlocksV2025R0TypeField(val.type); + if (!(val.limit == void 0) && !sdIsNumber(val.limit)) { + throw new BoxSdkError({ + message: + 'Expecting number for "limit" of type "HubDocumentBlocksV2025R0"', + }); + } + 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 "HubDocumentBlocksV2025R0"', + }); + } + const nextMarker: undefined | string = + val.next_marker == void 0 ? void 0 : val.next_marker; + return { + entries: entries, + type: type, + limit: limit, + nextMarker: nextMarker, + } satisfies HubDocumentBlocksV2025R0; +} +export function serializeHubDocumentBlocksV2025R0Input( + val: HubDocumentBlocksV2025R0Input +): SerializedData { + return { + ['entries']: val.entries.map(function ( + item: HubDocumentBlockEntryV2025R0 + ): SerializedData { + return serializeHubDocumentBlockEntryV2025R0(item); + }) as readonly any[], + ['type']: + val.type == void 0 + ? val.type + : serializeHubDocumentBlocksV2025R0TypeField(val.type), + ['limit']: val.limit, + ['next_marker']: val.nextMarker, + }; +} +export function deserializeHubDocumentBlocksV2025R0Input( + val: SerializedData +): HubDocumentBlocksV2025R0Input { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDocumentBlocksV2025R0Input"', + }); + } + if (val.entries == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "entries" of type "HubDocumentBlocksV2025R0Input" to be defined', + }); + } + if (!sdIsList(val.entries)) { + throw new BoxSdkError({ + message: + 'Expecting array for "entries" of type "HubDocumentBlocksV2025R0Input"', + }); + } + const entries: readonly HubDocumentBlockEntryV2025R0[] = sdIsList(val.entries) + ? (val.entries.map(function ( + itm: SerializedData + ): HubDocumentBlockEntryV2025R0 { + return deserializeHubDocumentBlockEntryV2025R0(itm); + }) as readonly any[]) + : []; + const type: undefined | HubDocumentBlocksV2025R0TypeField = + val.type == void 0 + ? void 0 + : deserializeHubDocumentBlocksV2025R0TypeField(val.type); + if (!(val.limit == void 0) && !sdIsNumber(val.limit)) { + throw new BoxSdkError({ + message: + 'Expecting number for "limit" of type "HubDocumentBlocksV2025R0Input"', + }); + } + 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 "HubDocumentBlocksV2025R0Input"', + }); + } + const nextMarker: undefined | string = + val.next_marker == void 0 ? void 0 : val.next_marker; + return { + entries: entries, + type: type, + limit: limit, + nextMarker: nextMarker, + } satisfies HubDocumentBlocksV2025R0Input; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubDocumentPageV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubDocumentPageV2025R0.ts new file mode 100644 index 000000000..0adca0b9c --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubDocumentPageV2025R0.ts @@ -0,0 +1,92 @@ +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export interface HubDocumentPageV2025R0 { + /** + * The unique identifier for this page. */ + readonly id: string; + /** + * The type of this resource. The value is always `page`. */ + readonly type: string; + /** + * The unique identifier of the parent page. Null for root-level pages. */ + readonly parentId?: string | null; + /** + * The title text of the page. Includes rich text formatting. */ + readonly titleFragment: string; + readonly rawData?: SerializedData; +} +export function serializeHubDocumentPageV2025R0( + val: HubDocumentPageV2025R0 +): SerializedData { + return { + ['id']: val.id, + ['type']: val.type, + ['parent_id']: val.parentId, + ['title_fragment']: val.titleFragment, + }; +} +export function deserializeHubDocumentPageV2025R0( + val: SerializedData +): HubDocumentPageV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDocumentPageV2025R0"', + }); + } + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "HubDocumentPageV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "HubDocumentPageV2025R0"', + }); + } + const id: string = val.id; + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubDocumentPageV2025R0" to be defined', + }); + } + if (!sdIsString(val.type)) { + throw new BoxSdkError({ + message: 'Expecting string for "type" of type "HubDocumentPageV2025R0"', + }); + } + const type: string = val.type; + if (!(val.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubDocumentPageV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; + if (val.title_fragment == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "title_fragment" of type "HubDocumentPageV2025R0" to be defined', + }); + } + if (!sdIsString(val.title_fragment)) { + throw new BoxSdkError({ + message: + 'Expecting string for "title_fragment" of type "HubDocumentPageV2025R0"', + }); + } + const titleFragment: string = val.title_fragment; + return { + id: id, + type: type, + parentId: parentId, + titleFragment: titleFragment, + } satisfies HubDocumentPageV2025R0; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubDocumentPagesV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubDocumentPagesV2025R0.ts new file mode 100644 index 000000000..e85b7f72e --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubDocumentPagesV2025R0.ts @@ -0,0 +1,218 @@ +import { serializeHubDocumentPageV2025R0 } from './hubDocumentPageV2025R0'; +import { deserializeHubDocumentPageV2025R0 } from './hubDocumentPageV2025R0'; +import { HubDocumentPageV2025R0 } from './hubDocumentPageV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubDocumentPagesV2025R0TypeField = 'document_pages'; +export class HubDocumentPagesV2025R0 { + /** + * Ordered list of pages. */ + readonly entries!: readonly HubDocumentPageV2025R0[]; + /** + * The value will always be `document_pages`. */ + readonly type: HubDocumentPagesV2025R0TypeField = + 'document_pages' as HubDocumentPagesV2025R0TypeField; + /** + * 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; + constructor( + fields: Omit & + Partial> + ) { + if (fields.entries !== undefined) { + this.entries = fields.entries; + } + if (fields.type !== undefined) { + this.type = fields.type; + } + if (fields.limit !== undefined) { + this.limit = fields.limit; + } + if (fields.nextMarker !== undefined) { + this.nextMarker = fields.nextMarker; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + } +} +export interface HubDocumentPagesV2025R0Input { + /** + * Ordered list of pages. */ + readonly entries: readonly HubDocumentPageV2025R0[]; + /** + * The value will always be `document_pages`. */ + readonly type?: HubDocumentPagesV2025R0TypeField; + /** + * 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 serializeHubDocumentPagesV2025R0TypeField( + val: HubDocumentPagesV2025R0TypeField +): SerializedData { + return val; +} +export function deserializeHubDocumentPagesV2025R0TypeField( + val: SerializedData +): HubDocumentPagesV2025R0TypeField { + if (val == 'document_pages') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubDocumentPagesV2025R0TypeField", + }); +} +export function serializeHubDocumentPagesV2025R0( + val: HubDocumentPagesV2025R0 +): SerializedData { + return { + ['entries']: val.entries.map(function ( + item: HubDocumentPageV2025R0 + ): SerializedData { + return serializeHubDocumentPageV2025R0(item); + }) as readonly any[], + ['type']: serializeHubDocumentPagesV2025R0TypeField(val.type), + ['limit']: val.limit, + ['next_marker']: val.nextMarker, + }; +} +export function deserializeHubDocumentPagesV2025R0( + val: SerializedData +): HubDocumentPagesV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDocumentPagesV2025R0"', + }); + } + if (val.entries == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "entries" of type "HubDocumentPagesV2025R0" to be defined', + }); + } + if (!sdIsList(val.entries)) { + throw new BoxSdkError({ + message: + 'Expecting array for "entries" of type "HubDocumentPagesV2025R0"', + }); + } + const entries: readonly HubDocumentPageV2025R0[] = sdIsList(val.entries) + ? (val.entries.map(function (itm: SerializedData): HubDocumentPageV2025R0 { + return deserializeHubDocumentPageV2025R0(itm); + }) as readonly any[]) + : []; + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubDocumentPagesV2025R0" to be defined', + }); + } + const type: HubDocumentPagesV2025R0TypeField = + deserializeHubDocumentPagesV2025R0TypeField(val.type); + if (!(val.limit == void 0) && !sdIsNumber(val.limit)) { + throw new BoxSdkError({ + message: 'Expecting number for "limit" of type "HubDocumentPagesV2025R0"', + }); + } + 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 "HubDocumentPagesV2025R0"', + }); + } + const nextMarker: undefined | string = + val.next_marker == void 0 ? void 0 : val.next_marker; + return { + entries: entries, + type: type, + limit: limit, + nextMarker: nextMarker, + } satisfies HubDocumentPagesV2025R0; +} +export function serializeHubDocumentPagesV2025R0Input( + val: HubDocumentPagesV2025R0Input +): SerializedData { + return { + ['entries']: val.entries.map(function ( + item: HubDocumentPageV2025R0 + ): SerializedData { + return serializeHubDocumentPageV2025R0(item); + }) as readonly any[], + ['type']: + val.type == void 0 + ? val.type + : serializeHubDocumentPagesV2025R0TypeField(val.type), + ['limit']: val.limit, + ['next_marker']: val.nextMarker, + }; +} +export function deserializeHubDocumentPagesV2025R0Input( + val: SerializedData +): HubDocumentPagesV2025R0Input { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubDocumentPagesV2025R0Input"', + }); + } + if (val.entries == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "entries" of type "HubDocumentPagesV2025R0Input" to be defined', + }); + } + if (!sdIsList(val.entries)) { + throw new BoxSdkError({ + message: + 'Expecting array for "entries" of type "HubDocumentPagesV2025R0Input"', + }); + } + const entries: readonly HubDocumentPageV2025R0[] = sdIsList(val.entries) + ? (val.entries.map(function (itm: SerializedData): HubDocumentPageV2025R0 { + return deserializeHubDocumentPageV2025R0(itm); + }) as readonly any[]) + : []; + const type: undefined | HubDocumentPagesV2025R0TypeField = + val.type == void 0 + ? void 0 + : deserializeHubDocumentPagesV2025R0TypeField(val.type); + if (!(val.limit == void 0) && !sdIsNumber(val.limit)) { + throw new BoxSdkError({ + message: + 'Expecting number for "limit" of type "HubDocumentPagesV2025R0Input"', + }); + } + 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 "HubDocumentPagesV2025R0Input"', + }); + } + const nextMarker: undefined | string = + val.next_marker == void 0 ? void 0 : val.next_marker; + return { + entries: entries, + type: type, + limit: limit, + nextMarker: nextMarker, + } satisfies HubDocumentPagesV2025R0Input; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubItemListBlockV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubItemListBlockV2025R0.ts new file mode 100644 index 000000000..ee1b0e2ed --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubItemListBlockV2025R0.ts @@ -0,0 +1,108 @@ +import { serializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { deserializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { HubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubItemListBlockV2025R0TypeField = 'item_list'; +export class HubItemListBlockV2025R0 implements HubDocumentBlockV2025R0 { + readonly id!: string; + readonly parentId?: string | null; + readonly rawData?: SerializedData; + /** + * The type of this block. The value is always `item_list`. */ + readonly type: HubItemListBlockV2025R0TypeField = + 'item_list' as HubItemListBlockV2025R0TypeField; + constructor( + fields: Omit & + Partial> + ) { + if (fields.id !== undefined) { + this.id = fields.id; + } + if (fields.parentId !== undefined) { + this.parentId = fields.parentId; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + if (fields.type !== undefined) { + this.type = fields.type; + } + } +} +export function serializeHubItemListBlockV2025R0TypeField( + val: HubItemListBlockV2025R0TypeField +): SerializedData { + return val; +} +export function deserializeHubItemListBlockV2025R0TypeField( + val: SerializedData +): HubItemListBlockV2025R0TypeField { + if (val == 'item_list') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubItemListBlockV2025R0TypeField", + }); +} +export function serializeHubItemListBlockV2025R0( + val: HubItemListBlockV2025R0 +): SerializedData { + const base: any = serializeHubDocumentBlockV2025R0(val); + if (!sdIsMap(base)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubItemListBlockV2025R0"', + }); + } + return { + ...base, + ...{ ['type']: serializeHubItemListBlockV2025R0TypeField(val.type) }, + }; +} +export function deserializeHubItemListBlockV2025R0( + val: SerializedData +): HubItemListBlockV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubItemListBlockV2025R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubItemListBlockV2025R0" to be defined', + }); + } + const type: HubItemListBlockV2025R0TypeField = + deserializeHubItemListBlockV2025R0TypeField(val.type); + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "HubItemListBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "HubItemListBlockV2025R0"', + }); + } + const id: string = val.id; + if (!(val.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubItemListBlockV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; + return { + type: type, + id: id, + parentId: parentId, + } satisfies HubItemListBlockV2025R0; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubItemOperationResultV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubItemOperationResultV2025R0.ts index b9916ac7d..de563be07 100644 --- a/src/sdk-gen/schemas/v2025R0/hubItemOperationResultV2025R0.ts +++ b/src/sdk-gen/schemas/v2025R0/hubItemOperationResultV2025R0.ts @@ -23,6 +23,9 @@ export interface HubItemOperationResultV2025R0 { * The action performed on the item. */ readonly action?: string; readonly item?: HubItemReferenceV2025R0; + /** + * The ID of the parent block the item was added to. */ + readonly parentId?: string; /** * The HTTP status code of the operation. */ readonly status?: number; @@ -40,6 +43,7 @@ export function serializeHubItemOperationResultV2025R0( val.item == void 0 ? val.item : serializeHubItemReferenceV2025R0(val.item), + ['parent_id']: val.parentId, ['status']: val.status, ['error']: val.error, }; @@ -61,6 +65,14 @@ export function deserializeHubItemOperationResultV2025R0( 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.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubItemOperationResultV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; if (!(val.status == void 0) && !sdIsNumber(val.status)) { throw new BoxSdkError({ message: @@ -78,6 +90,7 @@ export function deserializeHubItemOperationResultV2025R0( return { action: action, item: item, + parentId: parentId, status: status, error: error, } satisfies HubItemOperationResultV2025R0; diff --git a/src/sdk-gen/schemas/v2025R0/hubParagraphTextBlockV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubParagraphTextBlockV2025R0.ts new file mode 100644 index 000000000..4bc5e01df --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubParagraphTextBlockV2025R0.ts @@ -0,0 +1,133 @@ +import { serializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { deserializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { HubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubParagraphTextBlockV2025R0TypeField = 'paragraph'; +export class HubParagraphTextBlockV2025R0 implements HubDocumentBlockV2025R0 { + readonly id!: string; + readonly parentId?: string | null; + readonly rawData?: SerializedData; + /** + * The type of this block. The value is always `paragraph`. */ + readonly type: HubParagraphTextBlockV2025R0TypeField = + 'paragraph' as HubParagraphTextBlockV2025R0TypeField; + /** + * Text content of the block. Includes rich text formatting. */ + readonly fragment!: string; + constructor( + fields: Omit & + Partial> + ) { + if (fields.id !== undefined) { + this.id = fields.id; + } + if (fields.parentId !== undefined) { + this.parentId = fields.parentId; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + if (fields.type !== undefined) { + this.type = fields.type; + } + if (fields.fragment !== undefined) { + this.fragment = fields.fragment; + } + } +} +export function serializeHubParagraphTextBlockV2025R0TypeField( + val: HubParagraphTextBlockV2025R0TypeField +): SerializedData { + return val; +} +export function deserializeHubParagraphTextBlockV2025R0TypeField( + val: SerializedData +): HubParagraphTextBlockV2025R0TypeField { + if (val == 'paragraph') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubParagraphTextBlockV2025R0TypeField", + }); +} +export function serializeHubParagraphTextBlockV2025R0( + val: HubParagraphTextBlockV2025R0 +): SerializedData { + const base: any = serializeHubDocumentBlockV2025R0(val); + if (!sdIsMap(base)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubParagraphTextBlockV2025R0"', + }); + } + return { + ...base, + ...{ + ['type']: serializeHubParagraphTextBlockV2025R0TypeField(val.type), + ['fragment']: val.fragment, + }, + }; +} +export function deserializeHubParagraphTextBlockV2025R0( + val: SerializedData +): HubParagraphTextBlockV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubParagraphTextBlockV2025R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubParagraphTextBlockV2025R0" to be defined', + }); + } + const type: HubParagraphTextBlockV2025R0TypeField = + deserializeHubParagraphTextBlockV2025R0TypeField(val.type); + if (val.fragment == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "fragment" of type "HubParagraphTextBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.fragment)) { + throw new BoxSdkError({ + message: + 'Expecting string for "fragment" of type "HubParagraphTextBlockV2025R0"', + }); + } + const fragment: string = val.fragment; + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "HubParagraphTextBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "id" of type "HubParagraphTextBlockV2025R0"', + }); + } + const id: string = val.id; + if (!(val.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubParagraphTextBlockV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; + return { + type: type, + fragment: fragment, + id: id, + parentId: parentId, + } satisfies HubParagraphTextBlockV2025R0; +} diff --git a/src/sdk-gen/schemas/v2025R0/hubSectionTitleTextBlockV2025R0.ts b/src/sdk-gen/schemas/v2025R0/hubSectionTitleTextBlockV2025R0.ts new file mode 100644 index 000000000..f837cbcc6 --- /dev/null +++ b/src/sdk-gen/schemas/v2025R0/hubSectionTitleTextBlockV2025R0.ts @@ -0,0 +1,133 @@ +import { serializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { deserializeHubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { HubDocumentBlockV2025R0 } from './hubDocumentBlockV2025R0'; +import { BoxSdkError } from '../../box/errors'; +import { SerializedData } from '../../serialization/json'; +import { sdIsEmpty } from '../../serialization/json'; +import { sdIsBoolean } from '../../serialization/json'; +import { sdIsNumber } from '../../serialization/json'; +import { sdIsString } from '../../serialization/json'; +import { sdIsList } from '../../serialization/json'; +import { sdIsMap } from '../../serialization/json'; +export type HubSectionTitleTextBlockV2025R0TypeField = 'section_title'; +export class HubSectionTitleTextBlockV2025R0 implements HubDocumentBlockV2025R0 { + readonly id!: string; + readonly parentId?: string | null; + readonly rawData?: SerializedData; + /** + * The type of this block. The value is always `section_title`. */ + readonly type: HubSectionTitleTextBlockV2025R0TypeField = + 'section_title' as HubSectionTitleTextBlockV2025R0TypeField; + /** + * Text content of the block. Includes rich text formatting. */ + readonly fragment!: string; + constructor( + fields: Omit & + Partial> + ) { + if (fields.id !== undefined) { + this.id = fields.id; + } + if (fields.parentId !== undefined) { + this.parentId = fields.parentId; + } + if (fields.rawData !== undefined) { + this.rawData = fields.rawData; + } + if (fields.type !== undefined) { + this.type = fields.type; + } + if (fields.fragment !== undefined) { + this.fragment = fields.fragment; + } + } +} +export function serializeHubSectionTitleTextBlockV2025R0TypeField( + val: HubSectionTitleTextBlockV2025R0TypeField +): SerializedData { + return val; +} +export function deserializeHubSectionTitleTextBlockV2025R0TypeField( + val: SerializedData +): HubSectionTitleTextBlockV2025R0TypeField { + if (val == 'section_title') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize HubSectionTitleTextBlockV2025R0TypeField", + }); +} +export function serializeHubSectionTitleTextBlockV2025R0( + val: HubSectionTitleTextBlockV2025R0 +): SerializedData { + const base: any = serializeHubDocumentBlockV2025R0(val); + if (!sdIsMap(base)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubSectionTitleTextBlockV2025R0"', + }); + } + return { + ...base, + ...{ + ['type']: serializeHubSectionTitleTextBlockV2025R0TypeField(val.type), + ['fragment']: val.fragment, + }, + }; +} +export function deserializeHubSectionTitleTextBlockV2025R0( + val: SerializedData +): HubSectionTitleTextBlockV2025R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "HubSectionTitleTextBlockV2025R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "HubSectionTitleTextBlockV2025R0" to be defined', + }); + } + const type: HubSectionTitleTextBlockV2025R0TypeField = + deserializeHubSectionTitleTextBlockV2025R0TypeField(val.type); + if (val.fragment == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "fragment" of type "HubSectionTitleTextBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.fragment)) { + throw new BoxSdkError({ + message: + 'Expecting string for "fragment" of type "HubSectionTitleTextBlockV2025R0"', + }); + } + const fragment: string = val.fragment; + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "HubSectionTitleTextBlockV2025R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "id" of type "HubSectionTitleTextBlockV2025R0"', + }); + } + const id: string = val.id; + if (!(val.parent_id == void 0) && !sdIsString(val.parent_id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "parent_id" of type "HubSectionTitleTextBlockV2025R0"', + }); + } + const parentId: undefined | string = + val.parent_id == void 0 ? void 0 : val.parent_id; + return { + type: type, + fragment: fragment, + id: id, + parentId: parentId, + } satisfies HubSectionTitleTextBlockV2025R0; +} diff --git a/src/sdk-gen/schemas/v2025R0/index.ts b/src/sdk-gen/schemas/v2025R0/index.ts index c38fb782f..8675f75a4 100644 --- a/src/sdk-gen/schemas/v2025R0/index.ts +++ b/src/sdk-gen/schemas/v2025R0/index.ts @@ -34,6 +34,16 @@ export * from './hubCollaborationCreateRequestV2025R0'; export * from './hubCollaborationUpdateRequestV2025R0'; export * from './hubCopyRequestV2025R0'; export * from './hubCreateRequestV2025R0'; +export * from './hubDocumentBlockV2025R0'; +export * from './hubSectionTitleTextBlockV2025R0'; +export * from './hubParagraphTextBlockV2025R0'; +export * from './hubItemListBlockV2025R0'; +export * from './hubDividerBlockV2025R0'; +export * from './hubCalloutBoxTextBlockV2025R0'; +export * from './hubDocumentBlockEntryV2025R0'; +export * from './hubDocumentBlocksV2025R0'; +export * from './hubDocumentPageV2025R0'; +export * from './hubDocumentPagesV2025R0'; export * from './hubItemV2025R0'; export * from './hubItemsV2025R0'; export * from './hubUpdateRequestV2025R0'; diff --git a/tests/sdk-gen/hubDocument.test.ts b/tests/sdk-gen/hubDocument.test.ts new file mode 100644 index 000000000..b27c9dc40 --- /dev/null +++ b/tests/sdk-gen/hubDocument.test.ts @@ -0,0 +1,91 @@ +import { serializeHubV2025R0 } from '@/schemas/v2025R0/hubV2025R0'; +import { deserializeHubV2025R0 } from '@/schemas/v2025R0/hubV2025R0'; +import { serializeHubCreateRequestV2025R0 } from '@/schemas/v2025R0/hubCreateRequestV2025R0'; +import { deserializeHubCreateRequestV2025R0 } from '@/schemas/v2025R0/hubCreateRequestV2025R0'; +import { serializeHubDocumentPagesV2025R0 } from '@/schemas/v2025R0/hubDocumentPagesV2025R0'; +import { deserializeHubDocumentPagesV2025R0 } from '@/schemas/v2025R0/hubDocumentPagesV2025R0'; +import { serializeHubDocumentPageV2025R0 } from '@/schemas/v2025R0/hubDocumentPageV2025R0'; +import { deserializeHubDocumentPageV2025R0 } from '@/schemas/v2025R0/hubDocumentPageV2025R0'; +import { serializeHubDocumentBlocksV2025R0 } from '@/schemas/v2025R0/hubDocumentBlocksV2025R0'; +import { deserializeHubDocumentBlocksV2025R0 } from '@/schemas/v2025R0/hubDocumentBlocksV2025R0'; +import { serializeHubParagraphTextBlockV2025R0 } from '@/schemas/v2025R0/hubParagraphTextBlockV2025R0'; +import { deserializeHubParagraphTextBlockV2025R0 } from '@/schemas/v2025R0/hubParagraphTextBlockV2025R0'; +import { serializeHubSectionTitleTextBlockV2025R0 } from '@/schemas/v2025R0/hubSectionTitleTextBlockV2025R0'; +import { deserializeHubSectionTitleTextBlockV2025R0 } from '@/schemas/v2025R0/hubSectionTitleTextBlockV2025R0'; +import { serializeHubCalloutBoxTextBlockV2025R0 } from '@/schemas/v2025R0/hubCalloutBoxTextBlockV2025R0'; +import { deserializeHubCalloutBoxTextBlockV2025R0 } from '@/schemas/v2025R0/hubCalloutBoxTextBlockV2025R0'; +import { serializeHubItemListBlockV2025R0 } from '@/schemas/v2025R0/hubItemListBlockV2025R0'; +import { deserializeHubItemListBlockV2025R0 } from '@/schemas/v2025R0/hubItemListBlockV2025R0'; +import { serializeHubDividerBlockV2025R0 } from '@/schemas/v2025R0/hubDividerBlockV2025R0'; +import { deserializeHubDividerBlockV2025R0 } from '@/schemas/v2025R0/hubDividerBlockV2025R0'; +import { serializeHubDocumentBlockEntryV2025R0 } from '@/schemas/v2025R0/hubDocumentBlockEntryV2025R0'; +import { deserializeHubDocumentBlockEntryV2025R0 } from '@/schemas/v2025R0/hubDocumentBlockEntryV2025R0'; +import { BoxClient } from '@/client'; +import { HubV2025R0 } from '@/schemas/v2025R0/hubV2025R0'; +import { HubCreateRequestV2025R0 } from '@/schemas/v2025R0/hubCreateRequestV2025R0'; +import { HubDocumentPagesV2025R0 } from '@/schemas/v2025R0/hubDocumentPagesV2025R0'; +import { GetHubDocumentPagesV2025R0QueryParams } from '@/managers/hubDocument'; +import { HubDocumentPageV2025R0 } from '@/schemas/v2025R0/hubDocumentPageV2025R0'; +import { HubDocumentBlocksV2025R0 } from '@/schemas/v2025R0/hubDocumentBlocksV2025R0'; +import { GetHubDocumentBlocksV2025R0QueryParams } from '@/managers/hubDocument'; +import { HubParagraphTextBlockV2025R0 } from '@/schemas/v2025R0/hubParagraphTextBlockV2025R0'; +import { HubSectionTitleTextBlockV2025R0 } from '@/schemas/v2025R0/hubSectionTitleTextBlockV2025R0'; +import { HubCalloutBoxTextBlockV2025R0 } from '@/schemas/v2025R0/hubCalloutBoxTextBlockV2025R0'; +import { HubItemListBlockV2025R0 } from '@/schemas/v2025R0/hubItemListBlockV2025R0'; +import { HubDividerBlockV2025R0 } from '@/schemas/v2025R0/hubDividerBlockV2025R0'; +import { HubDocumentBlockEntryV2025R0 } from '@/schemas/v2025R0/hubDocumentBlockEntryV2025R0'; +import { getDefaultClientWithUserSubject } from './commons'; +import { getEnvVar } from '@/internal/utils'; +import { getUuid } from '@/internal/utils'; +import { toString } from '@/internal/utils'; +import { sdToJson } from '@/serialization/json'; +import { SerializedData } from '@/serialization/json'; +import { sdIsEmpty } from '@/serialization/json'; +import { sdIsBoolean } from '@/serialization/json'; +import { sdIsNumber } from '@/serialization/json'; +import { sdIsString } from '@/serialization/json'; +import { sdIsList } from '@/serialization/json'; +import { sdIsMap } from '@/serialization/json'; +export const client: BoxClient = getDefaultClientWithUserSubject( + getEnvVar('USER_ID') +); +test('testGetHubDocumentPagesAndBlocks', async function testGetHubDocumentPagesAndBlocks(): Promise { + const hubTitle: string = getUuid(); + const createdHub: HubV2025R0 = await client.hubs.createHubV2025R0({ + title: hubTitle, + } satisfies HubCreateRequestV2025R0); + const hubId: string = createdHub.id; + const pages: HubDocumentPagesV2025R0 = + await client.hubDocument.getHubDocumentPagesV2025R0({ + hubId: hubId, + } satisfies GetHubDocumentPagesV2025R0QueryParams); + if (!(pages.entries.length > 0)) { + throw new Error('Assertion failed'); + } + if (!((toString(pages.type) as string) == 'document_pages')) { + throw new Error('Assertion failed'); + } + const firstPage: HubDocumentPageV2025R0 = pages.entries[0]; + if (!((toString(firstPage.type) as string) == 'page')) { + throw new Error('Assertion failed'); + } + const pageId: string = firstPage.id; + const blocks: HubDocumentBlocksV2025R0 = + await client.hubDocument.getHubDocumentBlocksV2025R0({ + hubId: hubId, + pageId: pageId, + } satisfies GetHubDocumentBlocksV2025R0QueryParams); + if (!((toString(blocks.type) as string) == 'document_blocks')) { + throw new Error('Assertion failed'); + } + if (!(blocks.entries.length > 0)) { + throw new Error('Assertion failed'); + } + const firstBlock: HubDocumentBlockEntryV2025R0 = blocks + .entries![0] as HubDocumentBlockEntryV2025R0; + if (!((toString(firstBlock.type!) as string) == 'item_list')) { + throw new Error('Assertion failed'); + } + await client.hubs.deleteHubByIdV2025R0(hubId); +}); +export {};