From 538d3349895e6f4ac3694e53555499049d94f7ee Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 23 Jul 2026 07:50:40 -0700 Subject: [PATCH 1/2] fix: add auth header description (box/box-openapi#609) --- .codegen.json | 2 +- package-lock.json | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/.codegen.json b/.codegen.json index fa02a685..6128cf77 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "2cee311", "specHash": "54953fe", "version": "10.13.0" } +{ "engineHash": "2cee311", "specHash": "50e6d8a", "version": "10.13.0" } diff --git a/package-lock.json b/package-lock.json index 13003b53..a44c79de 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2202,9 +2202,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.10.43", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.43.tgz", - "integrity": "sha512-AjYpR78kDWAY3Efj+cDTFH9t9SCoL7OoTp1BOb0mQV7S+6CiLwnWM3FyxhJtdPufDFKzmCSFoUncKjWgJEZTCQ==", + "version": "2.11.1", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.11.1.tgz", + "integrity": "sha512-HYXq73DDpCtNzOmrFsm9eSwCvWCql0RzqjpDzXN9EadiLJ4DNat0nsZ/Bzmy+Ud12mb4/zKDY0cQ805ZzN+i0A==", "dev": true, "license": "Apache-2.0", "bin": { @@ -2260,9 +2260,9 @@ } }, "node_modules/browserslist": { - "version": "4.28.6", - "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.6.tgz", - "integrity": "sha512-FQBYNK15VMslhLHpA7+n+n1GOlF1kId2xcCg7/j95f24AOF6VDYMNH4mFxF7KuaTdv627faazpOAjFzMrfJOUw==", + "version": "4.28.7", + "resolved": "https://registry.npmjs.org/browserslist/-/browserslist-4.28.7.tgz", + "integrity": "sha512-JxV13hNrFxqjOc8alRbq9dK1MM79NEXYpma2B2J4wAtpWS5zIEIKqWPGCl7N4o7Uc7B7itylh7SuDujATRyyTw==", "dev": true, "funding": [ { @@ -2280,9 +2280,9 @@ ], "license": "MIT", "dependencies": { - "baseline-browser-mapping": "^2.10.42", - "caniuse-lite": "^1.0.30001803", - "electron-to-chromium": "^1.5.389", + "baseline-browser-mapping": "^2.10.44", + "caniuse-lite": "^1.0.30001806", + "electron-to-chromium": "^1.5.393", "node-releases": "^2.0.51", "update-browserslist-db": "^1.2.3" }, @@ -2742,9 +2742,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.393", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.393.tgz", - "integrity": "sha512-kiDJdIUawuEIcp9XoICKp1iTYDEbgguIPq526N1Q7jIQDeQ3CqoMx71025PI/7E48Ddtw2HuWsVjY7afEgNxmg==", + "version": "1.5.395", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.395.tgz", + "integrity": "sha512-7zt9Aw+SrmxLWLN0zhaTWZQiCdryLVrYTq5R7iZakLvi2UQPYMMsROYV/2qVCzMeCiSXHwKOU+sZ4zOVVlrtKA==", "dev": true, "license": "ISC" }, @@ -2769,9 +2769,9 @@ "license": "MIT" }, "node_modules/enhanced-resolve": { - "version": "5.24.2", - "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.2.tgz", - "integrity": "sha512-rpsZEGT1jFuve6QlpyRp9ckQ+kN61hvF9BzCPyMdaKTm8UJce96KBn3sorXOFXlzjPrs3Vc4T1NsSroZ3PxlFw==", + "version": "5.24.3", + "resolved": "https://registry.npmjs.org/enhanced-resolve/-/enhanced-resolve-5.24.3.tgz", + "integrity": "sha512-PwKooW9JUzh5chmYfHM3IQl5OkK2u2Nm011MgeZrss3JmFraUx/fqrf78kk8GUMYoibx/14MdwTl/1WKkG7TpQ==", "dev": true, "license": "MIT", "peer": true, @@ -3059,9 +3059,9 @@ "license": "MIT" }, "node_modules/fast-uri": { - "version": "3.1.3", - "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz", - "integrity": "sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.4.tgz", + "integrity": "sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==", "dev": true, "funding": [ { @@ -5933,9 +5933,9 @@ "license": "MIT" }, "node_modules/ts-jest": { - "version": "29.4.11", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.11.tgz", - "integrity": "sha512-IrFl7l9AuB/qrNw5quqvAv/hmKMb8dhWOH4jQOGo0Oq8tCeo1O86/iTFG1FaRimgUkF13l4PcepO8ATFT6Ns4g==", + "version": "29.4.12", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.12.tgz", + "integrity": "sha512-Ov6ClY53Fflh6BGAnY2DlTq1hYDrTycz2PVTXBWFW2CU+9zrEqAp9fWdGXl42EXO5RLSFAcAZ2JFKbP+zBTFfw==", "dev": true, "license": "MIT", "dependencies": { @@ -5945,7 +5945,7 @@ "json5": "^2.2.3", "lodash.memoize": "^4.1.2", "make-error": "^1.3.6", - "semver": "^7.8.0", + "semver": "^7.8.5", "type-fest": "^4.41.0", "yargs-parser": "^21.1.1" }, From c54fc6279c620c53f72c19132ec2a4e31b8e6efd Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 23 Jul 2026 13:50:42 -0700 Subject: [PATCH 2/2] docs: Query insights API (box/box-openapi#610) --- .codegen.json | 2 +- docs/README.md | 1 + docs/query.md | 55 ++++ package-lock.json | 41 +-- src/client.ts | 7 + src/managers/index.ts | 1 + src/managers/query.ts | 273 ++++++++++++++++++ src/schemas/fileFull.ts | 135 +++++++++ src/schemas/folderFull.ts | 27 ++ src/schemas/v2026R0/index.ts | 11 + .../v2026R0/queryAncestorReferenceV2026R0.ts | 58 ++++ .../v2026R0/queryInsightEntryV2026R0.ts | 136 +++++++++ .../queryInsightMetricResultV2026R0.ts | 83 ++++++ .../v2026R0/queryInsightsGroupByV2026R0.ts | 57 ++++ .../queryInsightsMetricDefinitionV2026R0.ts | 88 ++++++ .../queryInsightsRequestBodyV2026R0.ts | 239 +++++++++++++++ src/schemas/v2026R0/queryInsightsV2026R0.ts | 57 ++++ src/schemas/v2026R0/queryOrderByV2026R0.ts | 80 +++++ .../v2026R0/queryRequestBodyV2026R0.ts | 253 ++++++++++++++++ .../v2026R0/queryResultEntryV2026R0.ts | 87 ++++++ src/schemas/v2026R0/queryResultsV2026R0.ts | 87 ++++++ src/schemas/webLink.ts | 86 ++++++ 22 files changed, 1827 insertions(+), 37 deletions(-) create mode 100644 docs/query.md create mode 100644 src/managers/query.ts create mode 100644 src/schemas/v2026R0/queryAncestorReferenceV2026R0.ts create mode 100644 src/schemas/v2026R0/queryInsightEntryV2026R0.ts create mode 100644 src/schemas/v2026R0/queryInsightMetricResultV2026R0.ts create mode 100644 src/schemas/v2026R0/queryInsightsGroupByV2026R0.ts create mode 100644 src/schemas/v2026R0/queryInsightsMetricDefinitionV2026R0.ts create mode 100644 src/schemas/v2026R0/queryInsightsRequestBodyV2026R0.ts create mode 100644 src/schemas/v2026R0/queryInsightsV2026R0.ts create mode 100644 src/schemas/v2026R0/queryOrderByV2026R0.ts create mode 100644 src/schemas/v2026R0/queryRequestBodyV2026R0.ts create mode 100644 src/schemas/v2026R0/queryResultEntryV2026R0.ts create mode 100644 src/schemas/v2026R0/queryResultsV2026R0.ts diff --git a/.codegen.json b/.codegen.json index 6128cf77..d018b340 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "2cee311", "specHash": "50e6d8a", "version": "10.13.0" } +{ "engineHash": "2cee311", "specHash": "cc375ad", "version": "10.13.0" } diff --git a/docs/README.md b/docs/README.md index 47380abd..7577a645 100644 --- a/docs/README.md +++ b/docs/README.md @@ -62,6 +62,7 @@ the SDK are available by topic: - [Metadata taxonomies](metadataTaxonomies.md) - [Metadata templates](metadataTemplates.md) - [Notes](notes.md) +- [Query](query.md) - [Recent items](recentItems.md) - [Retention policies](retentionPolicies.md) - [Retention policy assignments](retentionPolicyAssignments.md) diff --git a/docs/query.md b/docs/query.md new file mode 100644 index 00000000..5241cf38 --- /dev/null +++ b/docs/query.md @@ -0,0 +1,55 @@ +# QueryManager + +- [Query for Box items](#query-for-box-items) +- [Create insights for Box items](#create-insights-for-box-items) + +## Query for Box items + +Runs a query to discover Box items using a logical predicate that can filter +across item fields and metadata templates. Results can be sorted, paginated, +and shaped to include additional item or metadata fields. + +This operation is performed by calling function `createQueryV2026R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2026.0/post-query/). + +_Currently we don't have an example for calling `createQueryV2026R0` in integration tests_ + +### Arguments + +- requestBody `QueryRequestBodyV2026R0` + - Request body of createQueryV2026R0 method +- optionalsInput `CreateQueryV2026R0OptionalsInput` + +### Returns + +This function returns a value of type `QueryResultsV2026R0`. + +Returns a paginated list of items matching the query. + +## Create insights for Box items + +Computes aggregated metrics over Box items matching a query predicate. +Filters are applied first, followed by optional grouping, after which the +requested metrics (such as `sum`, `avg`, `min`, `max`, and `count`) are +computed for each resulting group or over the entire filtered dataset. + +This operation is performed by calling function `createQueryInsightV2026R0`. + +See the endpoint docs at +[API Reference](https://developer.box.com/reference/v2026.0/post-query-insights/). + +_Currently we don't have an example for calling `createQueryInsightV2026R0` in integration tests_ + +### Arguments + +- requestBody `QueryInsightsRequestBodyV2026R0` + - Request body of createQueryInsightV2026R0 method +- optionalsInput `CreateQueryInsightV2026R0OptionalsInput` + +### Returns + +This function returns a value of type `QueryInsightsV2026R0`. + +Returns the computed insight entries. diff --git a/package-lock.json b/package-lock.json index a44c79de..80170293 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1877,20 +1877,6 @@ "node": ">=0.4.0" } }, - "node_modules/acorn-import-phases": { - "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, - "engines": { - "node": ">=10.13.0" - }, - "peerDependencies": { - "acorn": "^8.14.0" - } - }, "node_modules/agent-base": { "version": "7.1.4", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.4.tgz", @@ -4568,21 +4554,6 @@ "dev": true, "license": "MIT" }, - "node_modules/loader-runner": { - "version": "4.3.2", - "resolved": "https://registry.npmjs.org/loader-runner/-/loader-runner-4.3.2.tgz", - "integrity": "sha512-DFEqQ3ihfS9blba08cLfYf1NRAIEm+dDjic073DRDc3/JspI/8wYmtDsHwd3+4hwvdxSK7PGaElfTmm0awWJ4w==", - "dev": true, - "license": "MIT", - "peer": true, - "engines": { - "node": ">=6.11.5" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/webpack" - } - }, "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -6222,9 +6193,9 @@ "license": "BSD-2-Clause" }, "node_modules/webpack": { - "version": "5.108.4", - "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.108.4.tgz", - "integrity": "sha512-yur8LyJoeiWh47dErD+Ok7vlbmDsJ3UbbRPAoxbGJ54WpE2y5yVo5G/inUzujnYgw3tPmBRdn+G7PoxXaYC33w==", + "version": "5.109.0", + "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.109.0.tgz", + "integrity": "sha512-vomrngskVVXEZF9sMZfYAd4pXZUnfaWdJGlF+BTNF+gJBCKYCQBnOeVPlrh39Ewl7nlCsirDplMy6o5g9xJHBg==", "dev": true, "license": "MIT", "peer": true, @@ -6235,22 +6206,20 @@ "@webassemblyjs/wasm-edit": "^1.14.1", "@webassemblyjs/wasm-parser": "^1.14.1", "acorn": "^8.16.0", - "acorn-import-phases": "^1.0.3", "browserslist": "^4.28.1", "chrome-trace-event": "^1.0.2", - "enhanced-resolve": "^5.22.2", + "enhanced-resolve": "^5.24.2", "es-module-lexer": "^2.1.0", "eslint-scope": "5.1.1", "events": "^3.2.0", "graceful-fs": "^4.2.11", - "loader-runner": "^4.3.2", "mime-db": "^1.54.0", "minimizer-webpack-plugin": "^5.6.1", "neo-async": "^2.6.2", "schema-utils": "^4.3.3", "tapable": "^2.3.0", "watchpack": "^2.5.2", - "webpack-sources": "^3.5.0" + "webpack-sources": "^3.5.1" }, "bin": { "webpack": "bin/webpack.js" diff --git a/src/client.ts b/src/client.ts index 069fc696..31104e1e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -87,6 +87,7 @@ import { ArchivesManager } from './managers/archives'; import { ExternalUsersManager } from './managers/externalUsers'; import { AutomateWorkflowsManager } from './managers/automateWorkflows'; import { NotesManager } from './managers/notes'; +import { QueryManager } from './managers/query'; import { Authentication } from './networking/auth'; import { NetworkSession } from './networking/network'; import { BoxSdkError } from './box/errors'; @@ -194,6 +195,7 @@ export class BoxClient { readonly externalUsers: ExternalUsersManager; readonly automateWorkflows: AutomateWorkflowsManager; readonly notes: NotesManager; + readonly query: QueryManager; constructor( fields: Omit< BoxClient, @@ -282,6 +284,7 @@ export class BoxClient { | 'externalUsers' | 'automateWorkflows' | 'notes' + | 'query' | 'networkSession' | 'makeRequest' | 'withAsUserHeader' @@ -647,6 +650,10 @@ export class BoxClient { auth: this.auth, networkSession: this.networkSession, }); + this.query = new QueryManager({ + auth: this.auth, + networkSession: this.networkSession, + }); } /** * Make a custom http request using the client authentication and network session. diff --git a/src/managers/index.ts b/src/managers/index.ts index dd10eb83..01c94c9c 100644 --- a/src/managers/index.ts +++ b/src/managers/index.ts @@ -83,3 +83,4 @@ export * from './archives'; export * from './externalUsers'; export * from './automateWorkflows'; export * from './notes'; +export * from './query'; diff --git a/src/managers/query.ts b/src/managers/query.ts new file mode 100644 index 00000000..dd40b349 --- /dev/null +++ b/src/managers/query.ts @@ -0,0 +1,273 @@ +import { serializeQueryResultsV2026R0 } from '../schemas/v2026R0/queryResultsV2026R0'; +import { deserializeQueryResultsV2026R0 } from '../schemas/v2026R0/queryResultsV2026R0'; +import { serializeClientErrorV2026R0 } from '../schemas/v2026R0/clientErrorV2026R0'; +import { deserializeClientErrorV2026R0 } from '../schemas/v2026R0/clientErrorV2026R0'; +import { serializeBoxVersionHeaderV2026R0 } from '../parameters/v2026R0/boxVersionHeaderV2026R0'; +import { deserializeBoxVersionHeaderV2026R0 } from '../parameters/v2026R0/boxVersionHeaderV2026R0'; +import { serializeQueryRequestBodyV2026R0 } from '../schemas/v2026R0/queryRequestBodyV2026R0'; +import { deserializeQueryRequestBodyV2026R0 } from '../schemas/v2026R0/queryRequestBodyV2026R0'; +import { serializeQueryInsightsV2026R0 } from '../schemas/v2026R0/queryInsightsV2026R0'; +import { deserializeQueryInsightsV2026R0 } from '../schemas/v2026R0/queryInsightsV2026R0'; +import { serializeQueryInsightsRequestBodyV2026R0 } from '../schemas/v2026R0/queryInsightsRequestBodyV2026R0'; +import { deserializeQueryInsightsRequestBodyV2026R0 } from '../schemas/v2026R0/queryInsightsRequestBodyV2026R0'; +import { ResponseFormat } from '../networking/fetchOptions'; +import { QueryResultsV2026R0 } from '../schemas/v2026R0/queryResultsV2026R0'; +import { ClientErrorV2026R0 } from '../schemas/v2026R0/clientErrorV2026R0'; +import { BoxVersionHeaderV2026R0 } from '../parameters/v2026R0/boxVersionHeaderV2026R0'; +import { QueryRequestBodyV2026R0 } from '../schemas/v2026R0/queryRequestBodyV2026R0'; +import { QueryInsightsV2026R0 } from '../schemas/v2026R0/queryInsightsV2026R0'; +import { QueryInsightsRequestBodyV2026R0 } from '../schemas/v2026R0/queryInsightsRequestBodyV2026R0'; +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 CreateQueryV2026R0Optionals { + readonly headers: CreateQueryV2026R0Headers = new CreateQueryV2026R0Headers( + {}, + ); + 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 CreateQueryV2026R0OptionalsInput { + readonly headers?: CreateQueryV2026R0Headers; + readonly cancellationToken?: CancellationToken; +} +export class CreateQueryInsightV2026R0Optionals { + readonly headers: CreateQueryInsightV2026R0Headers = + new CreateQueryInsightV2026R0Headers({}); + readonly cancellationToken?: CancellationToken = void 0; + constructor( + fields: Omit< + CreateQueryInsightV2026R0Optionals, + 'headers' | 'cancellationToken' + > & + Partial< + Pick< + CreateQueryInsightV2026R0Optionals, + 'headers' | 'cancellationToken' + > + >, + ) { + if (fields.headers !== undefined) { + this.headers = fields.headers; + } + if (fields.cancellationToken !== undefined) { + this.cancellationToken = fields.cancellationToken; + } + } +} +export interface CreateQueryInsightV2026R0OptionalsInput { + readonly headers?: CreateQueryInsightV2026R0Headers; + readonly cancellationToken?: CancellationToken; +} +export class CreateQueryV2026R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2026R0 = + '2026.0' as BoxVersionHeaderV2026R0; + /** + * 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 CreateQueryV2026R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2026R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + }; +} +export class CreateQueryInsightV2026R0Headers { + /** + * Version header. */ + readonly boxVersion: BoxVersionHeaderV2026R0 = + '2026.0' as BoxVersionHeaderV2026R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + } = {}; + constructor( + fields: Omit< + CreateQueryInsightV2026R0Headers, + 'boxVersion' | 'extraHeaders' + > & + Partial< + Pick + >, + ) { + if (fields.boxVersion !== undefined) { + this.boxVersion = fields.boxVersion; + } + if (fields.extraHeaders !== undefined) { + this.extraHeaders = fields.extraHeaders; + } + } +} +export interface CreateQueryInsightV2026R0HeadersInput { + /** + * Version header. */ + readonly boxVersion?: BoxVersionHeaderV2026R0; + /** + * Extra headers that will be included in the HTTP request. */ + readonly extraHeaders?: { + readonly [key: string]: undefined | string; + }; +} +export class QueryManager { + readonly auth?: Authentication; + readonly networkSession: NetworkSession = new NetworkSession({}); + constructor( + fields: Omit< + QueryManager, + 'networkSession' | 'createQueryV2026R0' | 'createQueryInsightV2026R0' + > & + Partial>, + ) { + if (fields.auth !== undefined) { + this.auth = fields.auth; + } + if (fields.networkSession !== undefined) { + this.networkSession = fields.networkSession; + } + } + /** + * Runs a query to discover Box items using a logical predicate that can filter + * across item fields and metadata templates. Results can be sorted, paginated, + * and shaped to include additional item or metadata fields. + * @param {QueryRequestBodyV2026R0} requestBody Request body of createQueryV2026R0 method + * @param {CreateQueryV2026R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async createQueryV2026R0( + requestBody: QueryRequestBodyV2026R0, + optionalsInput: CreateQueryV2026R0OptionalsInput = {}, + ): Promise { + const optionals: CreateQueryV2026R0Optionals = + new CreateQueryV2026R0Optionals({ + 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/query', + ) as string, + method: 'POST', + headers: headersMap, + data: serializeQueryRequestBodyV2026R0(requestBody), + contentType: 'application/json', + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeQueryResultsV2026R0(response.data!), + rawData: response.data!, + }; + } + /** + * Computes aggregated metrics over Box items matching a query predicate. + * Filters are applied first, followed by optional grouping, after which the + * requested metrics (such as `sum`, `avg`, `min`, `max`, and `count`) are + * computed for each resulting group or over the entire filtered dataset. + * @param {QueryInsightsRequestBodyV2026R0} requestBody Request body of createQueryInsightV2026R0 method + * @param {CreateQueryInsightV2026R0OptionalsInput} optionalsInput + * @returns {Promise} + */ + async createQueryInsightV2026R0( + requestBody: QueryInsightsRequestBodyV2026R0, + optionalsInput: CreateQueryInsightV2026R0OptionalsInput = {}, + ): Promise { + const optionals: CreateQueryInsightV2026R0Optionals = + new CreateQueryInsightV2026R0Optionals({ + 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/query_insights', + ) as string, + method: 'POST', + headers: headersMap, + data: serializeQueryInsightsRequestBodyV2026R0(requestBody), + contentType: 'application/json', + responseFormat: 'json' as ResponseFormat, + auth: this.auth, + networkSession: this.networkSession, + cancellationToken: cancellationToken, + }), + ); + return { + ...deserializeQueryInsightsV2026R0(response.data!), + rawData: response.data!, + }; + } +} +export interface QueryManagerInput { + readonly auth?: Authentication; + readonly networkSession?: NetworkSession; +} diff --git a/src/schemas/fileFull.ts b/src/schemas/fileFull.ts index 242469b5..bd44b38e 100644 --- a/src/schemas/fileFull.ts +++ b/src/schemas/fileFull.ts @@ -22,6 +22,8 @@ import { serializeResourceScope } from './resourceScope'; import { deserializeResourceScope } from './resourceScope'; import { serializeMetadataFull } from './metadataFull'; import { deserializeMetadataFull } from './metadataFull'; +import { serializeCollection } from './collection'; +import { deserializeCollection } from './collection'; import { serializeDateTime } from '../internal/utils'; import { deserializeDateTime } from '../internal/utils'; import { FileBaseTypeField } from './fileBase'; @@ -36,6 +38,7 @@ import { File } from './file'; import { UserMini } from './userMini'; import { ResourceScope } from './resourceScope'; import { MetadataFull } from './metadataFull'; +import { Collection } from './collection'; import { BoxSdkError } from '../box/errors'; import { DateTime } from '../internal/utils'; import { SerializedData } from '../serialization/json'; @@ -281,6 +284,8 @@ export interface FileFullClassificationField { } export type FileFullSharedLinkPermissionOptionsField = 'can_preview' | 'can_download' | 'can_edit' | string; +export type FileFullAllowedSharedLinkAccessLevelsField = + 'open' | 'company' | 'collaborators' | string; export class FileFull extends File { readonly versionNumber?: string; readonly commentCount?: number; @@ -304,6 +309,11 @@ export class FileFull extends File { readonly sharedLinkPermissionOptions?: readonly FileFullSharedLinkPermissionOptionsField[] | null; readonly isAssociatedWithAppItem?: boolean; + readonly collections?: readonly Collection[]; + readonly isDownloadAvailable?: boolean; + readonly downloadUrl?: string; + readonly authenticatedDownloadUrl?: string; + readonly allowedSharedLinkAccessLevels?: readonly FileFullAllowedSharedLinkAccessLevelsField[]; constructor(fields: FileFull) { super(fields); if (fields.versionNumber !== undefined) { @@ -369,6 +379,21 @@ export class FileFull extends File { if (fields.isAssociatedWithAppItem !== undefined) { this.isAssociatedWithAppItem = fields.isAssociatedWithAppItem; } + if (fields.collections !== undefined) { + this.collections = fields.collections; + } + if (fields.isDownloadAvailable !== undefined) { + this.isDownloadAvailable = fields.isDownloadAvailable; + } + if (fields.downloadUrl !== undefined) { + this.downloadUrl = fields.downloadUrl; + } + if (fields.authenticatedDownloadUrl !== undefined) { + this.authenticatedDownloadUrl = fields.authenticatedDownloadUrl; + } + if (fields.allowedSharedLinkAccessLevels !== undefined) { + this.allowedSharedLinkAccessLevels = fields.allowedSharedLinkAccessLevels; + } } } export function serializeFileFullPermissionsField( @@ -1262,6 +1287,30 @@ export function deserializeFileFullSharedLinkPermissionOptionsField( message: "Can't deserialize FileFullSharedLinkPermissionOptionsField", }); } +export function serializeFileFullAllowedSharedLinkAccessLevelsField( + val: FileFullAllowedSharedLinkAccessLevelsField, +): SerializedData { + return val; +} +export function deserializeFileFullAllowedSharedLinkAccessLevelsField( + val: SerializedData, +): FileFullAllowedSharedLinkAccessLevelsField { + if (val == 'open') { + return val; + } + if (val == 'company') { + return val; + } + if (val == 'collaborators') { + return val; + } + if (sdIsString(val)) { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize FileFullAllowedSharedLinkAccessLevelsField", + }); +} export function serializeFileFull(val: FileFull): SerializedData { const base: any = serializeFile(val); if (!sdIsMap(base)) { @@ -1335,6 +1384,23 @@ export function serializeFileFull(val: FileFull): SerializedData { return serializeFileFullSharedLinkPermissionOptionsField(item); }) as readonly any[]), ['is_associated_with_app_item']: val.isAssociatedWithAppItem, + ['collections']: + val.collections == void 0 + ? val.collections + : (val.collections.map(function (item: Collection): SerializedData { + return serializeCollection(item); + }) as readonly any[]), + ['is_download_available']: val.isDownloadAvailable, + ['download_url']: val.downloadUrl, + ['authenticated_download_url']: val.authenticatedDownloadUrl, + ['allowed_shared_link_access_levels']: + val.allowedSharedLinkAccessLevels == void 0 + ? val.allowedSharedLinkAccessLevels + : (val.allowedSharedLinkAccessLevels.map(function ( + item: FileFullAllowedSharedLinkAccessLevelsField, + ): SerializedData { + return serializeFileFullAllowedSharedLinkAccessLevelsField(item); + }) as readonly any[]), }, }; } @@ -1526,6 +1592,70 @@ export function deserializeFileFull(val: SerializedData): FileFull { val.is_associated_with_app_item == void 0 ? void 0 : val.is_associated_with_app_item; + if (!(val.collections == void 0) && !sdIsList(val.collections)) { + throw new BoxSdkError({ + message: 'Expecting array for "collections" of type "FileFull"', + }); + } + const collections: undefined | readonly Collection[] = + val.collections == void 0 + ? void 0 + : sdIsList(val.collections) + ? (val.collections.map(function (itm: SerializedData): Collection { + return deserializeCollection(itm); + }) as readonly any[]) + : []; + if ( + !(val.is_download_available == void 0) && + !sdIsBoolean(val.is_download_available) + ) { + throw new BoxSdkError({ + message: + 'Expecting boolean for "is_download_available" of type "FileFull"', + }); + } + const isDownloadAvailable: undefined | boolean = + val.is_download_available == void 0 ? void 0 : val.is_download_available; + if (!(val.download_url == void 0) && !sdIsString(val.download_url)) { + throw new BoxSdkError({ + message: 'Expecting string for "download_url" of type "FileFull"', + }); + } + const downloadUrl: undefined | string = + val.download_url == void 0 ? void 0 : val.download_url; + if ( + !(val.authenticated_download_url == void 0) && + !sdIsString(val.authenticated_download_url) + ) { + throw new BoxSdkError({ + message: + 'Expecting string for "authenticated_download_url" of type "FileFull"', + }); + } + const authenticatedDownloadUrl: undefined | string = + val.authenticated_download_url == void 0 + ? void 0 + : val.authenticated_download_url; + if ( + !(val.allowed_shared_link_access_levels == void 0) && + !sdIsList(val.allowed_shared_link_access_levels) + ) { + throw new BoxSdkError({ + message: + 'Expecting array for "allowed_shared_link_access_levels" of type "FileFull"', + }); + } + const allowedSharedLinkAccessLevels: + undefined | readonly FileFullAllowedSharedLinkAccessLevelsField[] = + val.allowed_shared_link_access_levels == void 0 + ? void 0 + : sdIsList(val.allowed_shared_link_access_levels) + ? (val.allowed_shared_link_access_levels.map(function ( + itm: SerializedData, + ): FileFullAllowedSharedLinkAccessLevelsField { + return deserializeFileFullAllowedSharedLinkAccessLevelsField(itm); + }) as readonly any[]) + : []; if (!(val.description == void 0) && !sdIsString(val.description)) { throw new BoxSdkError({ message: 'Expecting string for "description" of type "FileFull"', @@ -1679,6 +1809,11 @@ export function deserializeFileFull(val: SerializedData): FileFull { dispositionAt: dispositionAt, sharedLinkPermissionOptions: sharedLinkPermissionOptions, isAssociatedWithAppItem: isAssociatedWithAppItem, + collections: collections, + isDownloadAvailable: isDownloadAvailable, + downloadUrl: downloadUrl, + authenticatedDownloadUrl: authenticatedDownloadUrl, + allowedSharedLinkAccessLevels: allowedSharedLinkAccessLevels, description: description, size: size, pathCollection: pathCollection, diff --git a/src/schemas/folderFull.ts b/src/schemas/folderFull.ts index 923fef67..c0bfd470 100644 --- a/src/schemas/folderFull.ts +++ b/src/schemas/folderFull.ts @@ -22,6 +22,8 @@ import { serializeFolder } from './folder'; import { deserializeFolder } from './folder'; import { serializeMetadataFull } from './metadataFull'; import { deserializeMetadataFull } from './metadataFull'; +import { serializeCollection } from './collection'; +import { deserializeCollection } from './collection'; import { FolderBaseTypeField } from './folderBase'; import { FolderBase } from './folderBase'; import { FolderMini } from './folderMini'; @@ -34,6 +36,7 @@ import { FolderItemStatusField } from './folder'; import { Items } from './items'; import { Folder } from './folder'; import { MetadataFull } from './metadataFull'; +import { Collection } from './collection'; import { BoxSdkError } from '../box/errors'; import { SerializedData } from '../serialization/json'; import { sdIsEmpty } from '../serialization/json'; @@ -136,6 +139,7 @@ export class FolderFull extends Folder { readonly canNonOwnersViewCollaborators?: boolean; readonly classification?: FolderFullClassificationField; readonly isAssociatedWithAppItem?: boolean; + readonly collections?: readonly Collection[]; constructor(fields: FolderFull) { super(fields); if (fields.syncState !== undefined) { @@ -184,6 +188,9 @@ export class FolderFull extends Folder { if (fields.isAssociatedWithAppItem !== undefined) { this.isAssociatedWithAppItem = fields.isAssociatedWithAppItem; } + if (fields.collections !== undefined) { + this.collections = fields.collections; + } } } export function serializeFolderFullSyncStateField( @@ -616,6 +623,12 @@ export function serializeFolderFull(val: FolderFull): SerializedData { ? val.classification : serializeFolderFullClassificationField(val.classification), ['is_associated_with_app_item']: val.isAssociatedWithAppItem, + ['collections']: + val.collections == void 0 + ? val.collections + : (val.collections.map(function (item: Collection): SerializedData { + return serializeCollection(item); + }) as readonly any[]), }, }; } @@ -786,6 +799,19 @@ export function deserializeFolderFull(val: SerializedData): FolderFull { val.is_associated_with_app_item == void 0 ? void 0 : val.is_associated_with_app_item; + if (!(val.collections == void 0) && !sdIsList(val.collections)) { + throw new BoxSdkError({ + message: 'Expecting array for "collections" of type "FolderFull"', + }); + } + const collections: undefined | readonly Collection[] = + val.collections == void 0 + ? void 0 + : sdIsList(val.collections) + ? (val.collections.map(function (itm: SerializedData): Collection { + return deserializeCollection(itm); + }) as readonly any[]) + : []; if (!(val.created_at == void 0) && !sdIsString(val.created_at)) { throw new BoxSdkError({ message: 'Expecting string for "created_at" of type "FolderFull"', @@ -933,6 +959,7 @@ export function deserializeFolderFull(val: SerializedData): FolderFull { canNonOwnersViewCollaborators: canNonOwnersViewCollaborators, classification: classification, isAssociatedWithAppItem: isAssociatedWithAppItem, + collections: collections, createdAt: createdAt, modifiedAt: modifiedAt, description: description, diff --git a/src/schemas/v2026R0/index.ts b/src/schemas/v2026R0/index.ts index 64d753c2..feafb66c 100644 --- a/src/schemas/v2026R0/index.ts +++ b/src/schemas/v2026R0/index.ts @@ -4,6 +4,17 @@ export * from './clientErrorV2026R0'; export * from './folderReferenceV2026R0'; export * from './notesConvertRequestBodyV2026R0'; export * from './notesConvertResponseV2026R0'; +export * from './queryAncestorReferenceV2026R0'; +export * from './queryInsightMetricResultV2026R0'; +export * from './queryInsightEntryV2026R0'; +export * from './queryInsightsV2026R0'; +export * from './queryInsightsGroupByV2026R0'; +export * from './queryInsightsMetricDefinitionV2026R0'; +export * from './queryInsightsRequestBodyV2026R0'; +export * from './queryOrderByV2026R0'; +export * from './queryRequestBodyV2026R0'; +export * from './queryResultEntryV2026R0'; +export * from './queryResultsV2026R0'; export * from './userBaseV2026R0'; export * from './userMiniV2026R0'; export * from './automateWorkflowActionV2026R0'; diff --git a/src/schemas/v2026R0/queryAncestorReferenceV2026R0.ts b/src/schemas/v2026R0/queryAncestorReferenceV2026R0.ts new file mode 100644 index 00000000..a2eef0c5 --- /dev/null +++ b/src/schemas/v2026R0/queryAncestorReferenceV2026R0.ts @@ -0,0 +1,58 @@ +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 QueryAncestorReferenceV2026R0 { + /** + * The unique identifier of the ancestor entity. */ + readonly id: string; + /** + * The type of the ancestor entity. Possible value: folder. */ + readonly type: string; + readonly rawData?: SerializedData; +} +export function serializeQueryAncestorReferenceV2026R0( + val: QueryAncestorReferenceV2026R0, +): SerializedData { + return { ['id']: val.id, ['type']: val.type }; +} +export function deserializeQueryAncestorReferenceV2026R0( + val: SerializedData, +): QueryAncestorReferenceV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryAncestorReferenceV2026R0"', + }); + } + if (val.id == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "id" of type "QueryAncestorReferenceV2026R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: + 'Expecting string for "id" of type "QueryAncestorReferenceV2026R0"', + }); + } + const id: string = val.id; + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "QueryAncestorReferenceV2026R0" to be defined', + }); + } + if (!sdIsString(val.type)) { + throw new BoxSdkError({ + message: + 'Expecting string for "type" of type "QueryAncestorReferenceV2026R0"', + }); + } + const type: string = val.type; + return { id: id, type: type } satisfies QueryAncestorReferenceV2026R0; +} diff --git a/src/schemas/v2026R0/queryInsightEntryV2026R0.ts b/src/schemas/v2026R0/queryInsightEntryV2026R0.ts new file mode 100644 index 00000000..d87ccbeb --- /dev/null +++ b/src/schemas/v2026R0/queryInsightEntryV2026R0.ts @@ -0,0 +1,136 @@ +import { serializeQueryInsightMetricResultV2026R0 } from './queryInsightMetricResultV2026R0'; +import { deserializeQueryInsightMetricResultV2026R0 } from './queryInsightMetricResultV2026R0'; +import { QueryInsightMetricResultV2026R0 } from './queryInsightMetricResultV2026R0'; +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 QueryInsightEntryV2026R0TypeField = 'group' | 'overall' | 'other'; +export interface QueryInsightEntryV2026R0 { + /** + * The grouping key values associated with the entry. Contains one value per + * `group_by` field for `group` entries, and is empty for `overall` and + * `other` entries. */ + readonly key: readonly string[]; + /** + * The type of insight entry, indicating how the associated metrics are + * aggregated. */ + readonly type: QueryInsightEntryV2026R0TypeField; + /** + * A map of metric aliases to their computed results. For `other` entries, the + * count is reported under the `totalCountBeyondTopGroups` key. */ + readonly metrics: { + readonly [key: string]: QueryInsightMetricResultV2026R0; + }; + readonly rawData?: SerializedData; +} +export function serializeQueryInsightEntryV2026R0TypeField( + val: QueryInsightEntryV2026R0TypeField, +): SerializedData { + return val; +} +export function deserializeQueryInsightEntryV2026R0TypeField( + val: SerializedData, +): QueryInsightEntryV2026R0TypeField { + if (val == 'group') { + return val; + } + if (val == 'overall') { + return val; + } + if (val == 'other') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize QueryInsightEntryV2026R0TypeField", + }); +} +export function serializeQueryInsightEntryV2026R0( + val: QueryInsightEntryV2026R0, +): SerializedData { + return { + ['key']: val.key.map(function (item: string): SerializedData { + return item; + }) as readonly any[], + ['type']: serializeQueryInsightEntryV2026R0TypeField(val.type), + ['metrics']: Object.fromEntries( + Object.entries(val.metrics).map(([k, v]: [string, any]) => [ + k, + serializeQueryInsightMetricResultV2026R0(v), + ]), + ) as { + readonly [key: string]: any; + }, + }; +} +export function deserializeQueryInsightEntryV2026R0( + val: SerializedData, +): QueryInsightEntryV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryInsightEntryV2026R0"', + }); + } + if (val.key == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "key" of type "QueryInsightEntryV2026R0" to be defined', + }); + } + if (!sdIsList(val.key)) { + throw new BoxSdkError({ + message: 'Expecting array for "key" of type "QueryInsightEntryV2026R0"', + }); + } + const key: readonly string[] = sdIsList(val.key) + ? (val.key.map(function (itm: SerializedData): string { + if (!sdIsString(itm)) { + throw new BoxSdkError({ + message: 'Expecting string for "QueryInsightEntryV2026R0"', + }); + } + return itm; + }) as readonly any[]) + : []; + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "QueryInsightEntryV2026R0" to be defined', + }); + } + const type: QueryInsightEntryV2026R0TypeField = + deserializeQueryInsightEntryV2026R0TypeField(val.type); + if (val.metrics == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "metrics" of type "QueryInsightEntryV2026R0" to be defined', + }); + } + if (!sdIsMap(val.metrics)) { + throw new BoxSdkError({ + message: + 'Expecting object for "metrics" of type "QueryInsightEntryV2026R0"', + }); + } + const metrics: { + readonly [key: string]: QueryInsightMetricResultV2026R0; + } = sdIsMap(val.metrics) + ? (Object.fromEntries( + Object.entries(val.metrics).map(([k, v]: [string, any]) => [ + k, + deserializeQueryInsightMetricResultV2026R0(v), + ]), + ) as { + readonly [key: string]: any; + }) + : {}; + return { + key: key, + type: type, + metrics: metrics, + } satisfies QueryInsightEntryV2026R0; +} diff --git a/src/schemas/v2026R0/queryInsightMetricResultV2026R0.ts b/src/schemas/v2026R0/queryInsightMetricResultV2026R0.ts new file mode 100644 index 00000000..45af23d5 --- /dev/null +++ b/src/schemas/v2026R0/queryInsightMetricResultV2026R0.ts @@ -0,0 +1,83 @@ +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 QueryInsightMetricResultV2026R0 { + /** + * The metric type that was computed. */ + readonly type: string; + /** + * The computed metric result(s), keyed by the metric function (for example + * `sum`, `avg`, `min`, `max`, or `count`). */ + readonly values: { + readonly [key: string]: number; + }; + readonly rawData?: SerializedData; +} +export function serializeQueryInsightMetricResultV2026R0( + val: QueryInsightMetricResultV2026R0, +): SerializedData { + return { ['type']: val.type, ['values']: val.values }; +} +export function deserializeQueryInsightMetricResultV2026R0( + val: SerializedData, +): QueryInsightMetricResultV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryInsightMetricResultV2026R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "QueryInsightMetricResultV2026R0" to be defined', + }); + } + if (!sdIsString(val.type)) { + throw new BoxSdkError({ + message: + 'Expecting string for "type" of type "QueryInsightMetricResultV2026R0"', + }); + } + const type: string = val.type; + if (val.values == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "values" of type "QueryInsightMetricResultV2026R0" to be defined', + }); + } + if (!sdIsMap(val.values)) { + throw new BoxSdkError({ + message: + 'Expecting object for "values" of type "QueryInsightMetricResultV2026R0"', + }); + } + const values: { + readonly [key: string]: number; + } = sdIsMap(val.values) + ? (Object.fromEntries( + Object.entries(val.values).map(([k, v]: [string, any]) => [ + k, + (function (v: any): any { + if (!sdIsNumber(v)) { + throw new BoxSdkError({ + message: + 'Expecting number for "QueryInsightMetricResultV2026R0"', + }); + } + return v; + })(v), + ]), + ) as { + readonly [key: string]: any; + }) + : {}; + return { + type: type, + values: values, + } satisfies QueryInsightMetricResultV2026R0; +} diff --git a/src/schemas/v2026R0/queryInsightsGroupByV2026R0.ts b/src/schemas/v2026R0/queryInsightsGroupByV2026R0.ts new file mode 100644 index 00000000..2e27847c --- /dev/null +++ b/src/schemas/v2026R0/queryInsightsGroupByV2026R0.ts @@ -0,0 +1,57 @@ +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 QueryInsightsGroupByV2026R0 { + /** + * The fully qualified field name to group by. Supports metadata and item + * properties. */ + readonly field: string; + /** + * The maximum number of buckets to return for the grouping. Defaults to `5`. */ + readonly bucketLimit?: number; + readonly rawData?: SerializedData; +} +export function serializeQueryInsightsGroupByV2026R0( + val: QueryInsightsGroupByV2026R0, +): SerializedData { + return { ['field']: val.field, ['bucket_limit']: val.bucketLimit }; +} +export function deserializeQueryInsightsGroupByV2026R0( + val: SerializedData, +): QueryInsightsGroupByV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryInsightsGroupByV2026R0"', + }); + } + if (val.field == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "field" of type "QueryInsightsGroupByV2026R0" to be defined', + }); + } + if (!sdIsString(val.field)) { + throw new BoxSdkError({ + message: + 'Expecting string for "field" of type "QueryInsightsGroupByV2026R0"', + }); + } + const field: string = val.field; + if (!(val.bucket_limit == void 0) && !sdIsNumber(val.bucket_limit)) { + throw new BoxSdkError({ + message: + 'Expecting number for "bucket_limit" of type "QueryInsightsGroupByV2026R0"', + }); + } + const bucketLimit: undefined | number = + val.bucket_limit == void 0 ? void 0 : val.bucket_limit; + return { + field: field, + bucketLimit: bucketLimit, + } satisfies QueryInsightsGroupByV2026R0; +} diff --git a/src/schemas/v2026R0/queryInsightsMetricDefinitionV2026R0.ts b/src/schemas/v2026R0/queryInsightsMetricDefinitionV2026R0.ts new file mode 100644 index 00000000..8c07d835 --- /dev/null +++ b/src/schemas/v2026R0/queryInsightsMetricDefinitionV2026R0.ts @@ -0,0 +1,88 @@ +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 QueryInsightsMetricDefinitionV2026R0TypeField = + 'sum' | 'avg' | 'min' | 'max' | 'count'; +export interface QueryInsightsMetricDefinitionV2026R0 { + /** + * The aggregation function to apply. */ + readonly type: QueryInsightsMetricDefinitionV2026R0TypeField; + /** + * The fully qualified field name on which the metric is computed. */ + readonly field: string; + readonly rawData?: SerializedData; +} +export function serializeQueryInsightsMetricDefinitionV2026R0TypeField( + val: QueryInsightsMetricDefinitionV2026R0TypeField, +): SerializedData { + return val; +} +export function deserializeQueryInsightsMetricDefinitionV2026R0TypeField( + val: SerializedData, +): QueryInsightsMetricDefinitionV2026R0TypeField { + if (val == 'sum') { + return val; + } + if (val == 'avg') { + return val; + } + if (val == 'min') { + return val; + } + if (val == 'max') { + return val; + } + if (val == 'count') { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize QueryInsightsMetricDefinitionV2026R0TypeField", + }); +} +export function serializeQueryInsightsMetricDefinitionV2026R0( + val: QueryInsightsMetricDefinitionV2026R0, +): SerializedData { + return { + ['type']: serializeQueryInsightsMetricDefinitionV2026R0TypeField(val.type), + ['field']: val.field, + }; +} +export function deserializeQueryInsightsMetricDefinitionV2026R0( + val: SerializedData, +): QueryInsightsMetricDefinitionV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryInsightsMetricDefinitionV2026R0"', + }); + } + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "QueryInsightsMetricDefinitionV2026R0" to be defined', + }); + } + const type: QueryInsightsMetricDefinitionV2026R0TypeField = + deserializeQueryInsightsMetricDefinitionV2026R0TypeField(val.type); + if (val.field == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "field" of type "QueryInsightsMetricDefinitionV2026R0" to be defined', + }); + } + if (!sdIsString(val.field)) { + throw new BoxSdkError({ + message: + 'Expecting string for "field" of type "QueryInsightsMetricDefinitionV2026R0"', + }); + } + const field: string = val.field; + return { + type: type, + field: field, + } satisfies QueryInsightsMetricDefinitionV2026R0; +} diff --git a/src/schemas/v2026R0/queryInsightsRequestBodyV2026R0.ts b/src/schemas/v2026R0/queryInsightsRequestBodyV2026R0.ts new file mode 100644 index 00000000..06cbecd4 --- /dev/null +++ b/src/schemas/v2026R0/queryInsightsRequestBodyV2026R0.ts @@ -0,0 +1,239 @@ +import { serializeQueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0'; +import { deserializeQueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0'; +import { serializeQueryInsightsGroupByV2026R0 } from './queryInsightsGroupByV2026R0'; +import { deserializeQueryInsightsGroupByV2026R0 } from './queryInsightsGroupByV2026R0'; +import { serializeQueryInsightsMetricDefinitionV2026R0 } from './queryInsightsMetricDefinitionV2026R0'; +import { deserializeQueryInsightsMetricDefinitionV2026R0 } from './queryInsightsMetricDefinitionV2026R0'; +import { QueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0'; +import { QueryInsightsGroupByV2026R0 } from './queryInsightsGroupByV2026R0'; +import { QueryInsightsMetricDefinitionV2026R0 } from './queryInsightsMetricDefinitionV2026R0'; +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 QueryInsightsRequestBodyV2026R0QueryField { + /** + * A logical expression used to filter the dataset prior to metric + * computation, similar to an SQL `WHERE` clause. May include + * named parameters referenced as `:placeholder`. */ + readonly predicate: string; + /** + * A map of placeholder names (without the `:` prefix) to their values. + * Required only when the predicate contains parameter placeholders. The + * type of each value must match the type of the field it is compared to. */ + readonly params?: { + readonly [key: string]: any; + }; + /** + * Restricts results to items contained within any of the specified + * ancestors. The user must have access to every listed ancestor. When + * omitted, insights are computed across all accessible items. */ + readonly ancestors?: readonly QueryAncestorReferenceV2026R0[]; + /** + * Defines how data is grouped for insights computation. Currently only a + * single grouping field is supported. */ + readonly groupBy?: readonly QueryInsightsGroupByV2026R0[]; + readonly rawData?: SerializedData; +} +export interface QueryInsightsRequestBodyV2026R0 { + /** + * The filtering and grouping definition. Filters are applied first, followed + * by grouping, before metrics are computed. */ + readonly query: QueryInsightsRequestBodyV2026R0QueryField; + /** + * A map of user-defined metric aliases to their definitions. A maximum of 10 + * metrics may be defined. Each alias must be a unique, non-empty string of up + * to 256 characters, containing only letters, digits, `_`, `-`, or `.`, and + * must not start with a digit, `_`, `-`, or `.`. May be empty to request + * only a total count. */ + readonly metrics: { + readonly [key: string]: QueryInsightsMetricDefinitionV2026R0; + }; + readonly rawData?: SerializedData; +} +export function serializeQueryInsightsRequestBodyV2026R0QueryField( + val: QueryInsightsRequestBodyV2026R0QueryField, +): SerializedData { + return { + ['predicate']: val.predicate, + ['params']: + val.params == void 0 + ? val.params + : (Object.fromEntries( + Object.entries(val.params).map(([k, v]: [string, any]) => [ + k, + (function (v: any): any { + return v; + })(v), + ]), + ) as { + readonly [key: string]: any; + }), + ['ancestors']: + val.ancestors == void 0 + ? val.ancestors + : (val.ancestors.map(function ( + item: QueryAncestorReferenceV2026R0, + ): SerializedData { + return serializeQueryAncestorReferenceV2026R0(item); + }) as readonly any[]), + ['group_by']: + val.groupBy == void 0 + ? val.groupBy + : (val.groupBy.map(function ( + item: QueryInsightsGroupByV2026R0, + ): SerializedData { + return serializeQueryInsightsGroupByV2026R0(item); + }) as readonly any[]), + }; +} +export function deserializeQueryInsightsRequestBodyV2026R0QueryField( + val: SerializedData, +): QueryInsightsRequestBodyV2026R0QueryField { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: + 'Expecting a map for "QueryInsightsRequestBodyV2026R0QueryField"', + }); + } + if (val.predicate == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "predicate" of type "QueryInsightsRequestBodyV2026R0QueryField" to be defined', + }); + } + if (!sdIsString(val.predicate)) { + throw new BoxSdkError({ + message: + 'Expecting string for "predicate" of type "QueryInsightsRequestBodyV2026R0QueryField"', + }); + } + const predicate: string = val.predicate; + if (!(val.params == void 0) && !sdIsMap(val.params)) { + throw new BoxSdkError({ + message: + 'Expecting object for "params" of type "QueryInsightsRequestBodyV2026R0QueryField"', + }); + } + const params: + | undefined + | { + readonly [key: string]: any; + } = + val.params == void 0 + ? void 0 + : sdIsMap(val.params) + ? (Object.fromEntries( + Object.entries(val.params).map(([k, v]: [string, any]) => [ + k, + (function (v: any): any { + return v; + })(v), + ]), + ) as { + readonly [key: string]: any; + }) + : {}; + if (!(val.ancestors == void 0) && !sdIsList(val.ancestors)) { + throw new BoxSdkError({ + message: + 'Expecting array for "ancestors" of type "QueryInsightsRequestBodyV2026R0QueryField"', + }); + } + const ancestors: undefined | readonly QueryAncestorReferenceV2026R0[] = + val.ancestors == void 0 + ? void 0 + : sdIsList(val.ancestors) + ? (val.ancestors.map(function ( + itm: SerializedData, + ): QueryAncestorReferenceV2026R0 { + return deserializeQueryAncestorReferenceV2026R0(itm); + }) as readonly any[]) + : []; + if (!(val.group_by == void 0) && !sdIsList(val.group_by)) { + throw new BoxSdkError({ + message: + 'Expecting array for "group_by" of type "QueryInsightsRequestBodyV2026R0QueryField"', + }); + } + const groupBy: undefined | readonly QueryInsightsGroupByV2026R0[] = + val.group_by == void 0 + ? void 0 + : sdIsList(val.group_by) + ? (val.group_by.map(function ( + itm: SerializedData, + ): QueryInsightsGroupByV2026R0 { + return deserializeQueryInsightsGroupByV2026R0(itm); + }) as readonly any[]) + : []; + return { + predicate: predicate, + params: params, + ancestors: ancestors, + groupBy: groupBy, + } satisfies QueryInsightsRequestBodyV2026R0QueryField; +} +export function serializeQueryInsightsRequestBodyV2026R0( + val: QueryInsightsRequestBodyV2026R0, +): SerializedData { + return { + ['query']: serializeQueryInsightsRequestBodyV2026R0QueryField(val.query), + ['metrics']: Object.fromEntries( + Object.entries(val.metrics).map(([k, v]: [string, any]) => [ + k, + serializeQueryInsightsMetricDefinitionV2026R0(v), + ]), + ) as { + readonly [key: string]: any; + }, + }; +} +export function deserializeQueryInsightsRequestBodyV2026R0( + val: SerializedData, +): QueryInsightsRequestBodyV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryInsightsRequestBodyV2026R0"', + }); + } + if (val.query == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "query" of type "QueryInsightsRequestBodyV2026R0" to be defined', + }); + } + const query: QueryInsightsRequestBodyV2026R0QueryField = + deserializeQueryInsightsRequestBodyV2026R0QueryField(val.query); + if (val.metrics == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "metrics" of type "QueryInsightsRequestBodyV2026R0" to be defined', + }); + } + if (!sdIsMap(val.metrics)) { + throw new BoxSdkError({ + message: + 'Expecting object for "metrics" of type "QueryInsightsRequestBodyV2026R0"', + }); + } + const metrics: { + readonly [key: string]: QueryInsightsMetricDefinitionV2026R0; + } = sdIsMap(val.metrics) + ? (Object.fromEntries( + Object.entries(val.metrics).map(([k, v]: [string, any]) => [ + k, + deserializeQueryInsightsMetricDefinitionV2026R0(v), + ]), + ) as { + readonly [key: string]: any; + }) + : {}; + return { + query: query, + metrics: metrics, + } satisfies QueryInsightsRequestBodyV2026R0; +} diff --git a/src/schemas/v2026R0/queryInsightsV2026R0.ts b/src/schemas/v2026R0/queryInsightsV2026R0.ts new file mode 100644 index 00000000..ce6b2c5a --- /dev/null +++ b/src/schemas/v2026R0/queryInsightsV2026R0.ts @@ -0,0 +1,57 @@ +import { serializeQueryInsightEntryV2026R0 } from './queryInsightEntryV2026R0'; +import { deserializeQueryInsightEntryV2026R0 } from './queryInsightEntryV2026R0'; +import { QueryInsightEntryV2026R0 } from './queryInsightEntryV2026R0'; +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 QueryInsightsV2026R0 { + /** + * The list of computed insight entries. Each entry corresponds to a group, + * the overall dataset, or the aggregate of groups outside the top results. */ + readonly insights: readonly QueryInsightEntryV2026R0[]; + readonly rawData?: SerializedData; +} +export function serializeQueryInsightsV2026R0( + val: QueryInsightsV2026R0, +): SerializedData { + return { + ['insights']: val.insights.map(function ( + item: QueryInsightEntryV2026R0, + ): SerializedData { + return serializeQueryInsightEntryV2026R0(item); + }) as readonly any[], + }; +} +export function deserializeQueryInsightsV2026R0( + val: SerializedData, +): QueryInsightsV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryInsightsV2026R0"', + }); + } + if (val.insights == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "insights" of type "QueryInsightsV2026R0" to be defined', + }); + } + if (!sdIsList(val.insights)) { + throw new BoxSdkError({ + message: 'Expecting array for "insights" of type "QueryInsightsV2026R0"', + }); + } + const insights: readonly QueryInsightEntryV2026R0[] = sdIsList(val.insights) + ? (val.insights.map(function ( + itm: SerializedData, + ): QueryInsightEntryV2026R0 { + return deserializeQueryInsightEntryV2026R0(itm); + }) as readonly any[]) + : []; + return { insights: insights } satisfies QueryInsightsV2026R0; +} diff --git a/src/schemas/v2026R0/queryOrderByV2026R0.ts b/src/schemas/v2026R0/queryOrderByV2026R0.ts new file mode 100644 index 00000000..05d70fc2 --- /dev/null +++ b/src/schemas/v2026R0/queryOrderByV2026R0.ts @@ -0,0 +1,80 @@ +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 QueryOrderByV2026R0DirectionField = 'asc' | 'desc' | string; +export interface QueryOrderByV2026R0 { + /** + * The fully qualified field key to sort by. */ + readonly fieldKey: string; + /** + * The direction in which results are ordered. */ + readonly direction: QueryOrderByV2026R0DirectionField; + readonly rawData?: SerializedData; +} +export function serializeQueryOrderByV2026R0DirectionField( + val: QueryOrderByV2026R0DirectionField, +): SerializedData { + return val; +} +export function deserializeQueryOrderByV2026R0DirectionField( + val: SerializedData, +): QueryOrderByV2026R0DirectionField { + if (val == 'asc') { + return val; + } + if (val == 'desc') { + return val; + } + if (sdIsString(val)) { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize QueryOrderByV2026R0DirectionField", + }); +} +export function serializeQueryOrderByV2026R0( + val: QueryOrderByV2026R0, +): SerializedData { + return { + ['field_key']: val.fieldKey, + ['direction']: serializeQueryOrderByV2026R0DirectionField(val.direction), + }; +} +export function deserializeQueryOrderByV2026R0( + val: SerializedData, +): QueryOrderByV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryOrderByV2026R0"', + }); + } + if (val.field_key == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "field_key" of type "QueryOrderByV2026R0" to be defined', + }); + } + if (!sdIsString(val.field_key)) { + throw new BoxSdkError({ + message: 'Expecting string for "field_key" of type "QueryOrderByV2026R0"', + }); + } + const fieldKey: string = val.field_key; + if (val.direction == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "direction" of type "QueryOrderByV2026R0" to be defined', + }); + } + const direction: QueryOrderByV2026R0DirectionField = + deserializeQueryOrderByV2026R0DirectionField(val.direction); + return { + fieldKey: fieldKey, + direction: direction, + } satisfies QueryOrderByV2026R0; +} diff --git a/src/schemas/v2026R0/queryRequestBodyV2026R0.ts b/src/schemas/v2026R0/queryRequestBodyV2026R0.ts new file mode 100644 index 00000000..53ac13e8 --- /dev/null +++ b/src/schemas/v2026R0/queryRequestBodyV2026R0.ts @@ -0,0 +1,253 @@ +import { serializeQueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0'; +import { deserializeQueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0'; +import { serializeQueryOrderByV2026R0 } from './queryOrderByV2026R0'; +import { deserializeQueryOrderByV2026R0 } from './queryOrderByV2026R0'; +import { QueryAncestorReferenceV2026R0 } from './queryAncestorReferenceV2026R0'; +import { QueryOrderByV2026R0 } from './queryOrderByV2026R0'; +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 QueryRequestBodyV2026R0QueryField { + /** + * A logical expression used to filter the dataset, similar to an SQL + * `WHERE` clause. May include named parameters referenced as + * `:placeholder`. */ + readonly predicate: string; + /** + * A map of placeholder names (without the `:` prefix) to their values. + * Required only when the predicate contains parameter placeholders. The + * type of each value must match the type of the field it is compared to. */ + readonly params?: { + readonly [key: string]: any; + }; + /** + * Restricts results to the specified ancestor entities and their + * recursive descendants. The user must have read access to every listed + * ancestor. */ + readonly ancestors?: readonly QueryAncestorReferenceV2026R0[]; + readonly rawData?: SerializedData; +} +export interface QueryRequestBodyV2026R0 { + /** + * The query definition, including the filtering predicate and its optional + * parameters and ancestor restrictions. */ + readonly query: QueryRequestBodyV2026R0QueryField; + /** + * The sorting criteria for the result set. Entries are applied sequentially + * to define multi-level sorting. */ + readonly orderBy?: readonly QueryOrderByV2026R0[]; + /** + * The maximum number of results to return. Defaults to `50` when not + * provided. */ + readonly limit?: number; + /** + * Controls which additional fields are included in each result entry. Each + * value must be one of: a fully qualified item field key (for example + * `box:item:name`), a metadata template key to hydrate the full template (for + * example `enterprise_12345678:project`), or a specific metadata template + * field key to hydrate a single field from the template (for example + * `enterprise_12345678:project:name`). When omitted, entries include only the + * item type and identifier. */ + readonly fields?: readonly string[]; + /** + * An opaque token returned from a previous response, used to continue + * retrieval. When provided, all other request parameters must exactly match + * those of the original request. */ + readonly marker?: string; + readonly rawData?: SerializedData; +} +export function serializeQueryRequestBodyV2026R0QueryField( + val: QueryRequestBodyV2026R0QueryField, +): SerializedData { + return { + ['predicate']: val.predicate, + ['params']: + val.params == void 0 + ? val.params + : (Object.fromEntries( + Object.entries(val.params).map(([k, v]: [string, any]) => [ + k, + (function (v: any): any { + return v; + })(v), + ]), + ) as { + readonly [key: string]: any; + }), + ['ancestors']: + val.ancestors == void 0 + ? val.ancestors + : (val.ancestors.map(function ( + item: QueryAncestorReferenceV2026R0, + ): SerializedData { + return serializeQueryAncestorReferenceV2026R0(item); + }) as readonly any[]), + }; +} +export function deserializeQueryRequestBodyV2026R0QueryField( + val: SerializedData, +): QueryRequestBodyV2026R0QueryField { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryRequestBodyV2026R0QueryField"', + }); + } + if (val.predicate == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "predicate" of type "QueryRequestBodyV2026R0QueryField" to be defined', + }); + } + if (!sdIsString(val.predicate)) { + throw new BoxSdkError({ + message: + 'Expecting string for "predicate" of type "QueryRequestBodyV2026R0QueryField"', + }); + } + const predicate: string = val.predicate; + if (!(val.params == void 0) && !sdIsMap(val.params)) { + throw new BoxSdkError({ + message: + 'Expecting object for "params" of type "QueryRequestBodyV2026R0QueryField"', + }); + } + const params: + | undefined + | { + readonly [key: string]: any; + } = + val.params == void 0 + ? void 0 + : sdIsMap(val.params) + ? (Object.fromEntries( + Object.entries(val.params).map(([k, v]: [string, any]) => [ + k, + (function (v: any): any { + return v; + })(v), + ]), + ) as { + readonly [key: string]: any; + }) + : {}; + if (!(val.ancestors == void 0) && !sdIsList(val.ancestors)) { + throw new BoxSdkError({ + message: + 'Expecting array for "ancestors" of type "QueryRequestBodyV2026R0QueryField"', + }); + } + const ancestors: undefined | readonly QueryAncestorReferenceV2026R0[] = + val.ancestors == void 0 + ? void 0 + : sdIsList(val.ancestors) + ? (val.ancestors.map(function ( + itm: SerializedData, + ): QueryAncestorReferenceV2026R0 { + return deserializeQueryAncestorReferenceV2026R0(itm); + }) as readonly any[]) + : []; + return { + predicate: predicate, + params: params, + ancestors: ancestors, + } satisfies QueryRequestBodyV2026R0QueryField; +} +export function serializeQueryRequestBodyV2026R0( + val: QueryRequestBodyV2026R0, +): SerializedData { + return { + ['query']: serializeQueryRequestBodyV2026R0QueryField(val.query), + ['order_by']: + val.orderBy == void 0 + ? val.orderBy + : (val.orderBy.map(function ( + item: QueryOrderByV2026R0, + ): SerializedData { + return serializeQueryOrderByV2026R0(item); + }) as readonly any[]), + ['limit']: val.limit, + ['fields']: + val.fields == void 0 + ? val.fields + : (val.fields.map(function (item: string): SerializedData { + return item; + }) as readonly any[]), + ['marker']: val.marker, + }; +} +export function deserializeQueryRequestBodyV2026R0( + val: SerializedData, +): QueryRequestBodyV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryRequestBodyV2026R0"', + }); + } + if (val.query == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "query" of type "QueryRequestBodyV2026R0" to be defined', + }); + } + const query: QueryRequestBodyV2026R0QueryField = + deserializeQueryRequestBodyV2026R0QueryField(val.query); + if (!(val.order_by == void 0) && !sdIsList(val.order_by)) { + throw new BoxSdkError({ + message: + 'Expecting array for "order_by" of type "QueryRequestBodyV2026R0"', + }); + } + const orderBy: undefined | readonly QueryOrderByV2026R0[] = + val.order_by == void 0 + ? void 0 + : sdIsList(val.order_by) + ? (val.order_by.map(function ( + itm: SerializedData, + ): QueryOrderByV2026R0 { + return deserializeQueryOrderByV2026R0(itm); + }) as readonly any[]) + : []; + if (!(val.limit == void 0) && !sdIsNumber(val.limit)) { + throw new BoxSdkError({ + message: 'Expecting number for "limit" of type "QueryRequestBodyV2026R0"', + }); + } + const limit: undefined | number = val.limit == void 0 ? void 0 : val.limit; + if (!(val.fields == void 0) && !sdIsList(val.fields)) { + throw new BoxSdkError({ + message: 'Expecting array for "fields" of type "QueryRequestBodyV2026R0"', + }); + } + const fields: undefined | readonly string[] = + val.fields == void 0 + ? void 0 + : sdIsList(val.fields) + ? (val.fields.map(function (itm: SerializedData): string { + if (!sdIsString(itm)) { + throw new BoxSdkError({ + message: 'Expecting string for "QueryRequestBodyV2026R0"', + }); + } + return itm; + }) as readonly any[]) + : []; + if (!(val.marker == void 0) && !sdIsString(val.marker)) { + throw new BoxSdkError({ + message: + 'Expecting string for "marker" of type "QueryRequestBodyV2026R0"', + }); + } + const marker: undefined | string = val.marker == void 0 ? void 0 : val.marker; + return { + query: query, + orderBy: orderBy, + limit: limit, + fields: fields, + marker: marker, + } satisfies QueryRequestBodyV2026R0; +} diff --git a/src/schemas/v2026R0/queryResultEntryV2026R0.ts b/src/schemas/v2026R0/queryResultEntryV2026R0.ts new file mode 100644 index 00000000..40628ac7 --- /dev/null +++ b/src/schemas/v2026R0/queryResultEntryV2026R0.ts @@ -0,0 +1,87 @@ +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 QueryResultEntryV2026R0 { + /** + * The unique identifier of the matching item. */ + readonly id: string; + /** + * The type of the matching item. */ + readonly type: string; + readonly extraData?: { + readonly [key: string]: any; + }; + readonly rawData?: SerializedData; +} +export function serializeQueryResultEntryV2026R0( + val: QueryResultEntryV2026R0, +): SerializedData { + return { ...{ ['id']: val.id, ['type']: val.type }, ...val.extraData }; +} +export function deserializeQueryResultEntryV2026R0( + val: SerializedData, +): QueryResultEntryV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryResultEntryV2026R0"', + }); + } + if (val.id == void 0) { + throw new BoxSdkError({ + message: 'Expecting "id" of type "QueryResultEntryV2026R0" to be defined', + }); + } + if (!sdIsString(val.id)) { + throw new BoxSdkError({ + message: 'Expecting string for "id" of type "QueryResultEntryV2026R0"', + }); + } + const id: string = val.id; + if (val.type == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "type" of type "QueryResultEntryV2026R0" to be defined', + }); + } + if (!sdIsString(val.type)) { + throw new BoxSdkError({ + message: 'Expecting string for "type" of type "QueryResultEntryV2026R0"', + }); + } + const type: string = val.type; + if (!(val == void 0) && !sdIsMap(val)) { + throw new BoxSdkError({ + message: + 'Expecting object for "extraData" of type "QueryResultEntryV2026R0"', + }); + } + const extraData: + | undefined + | { + readonly [key: string]: any; + } = + val == void 0 + ? void 0 + : sdIsMap(val) + ? (Object.fromEntries( + Object.entries(val).map(([k, v]: [string, any]) => [ + k, + (function (v: any): any { + return v; + })(v), + ]), + ) as { + readonly [key: string]: any; + }) + : {}; + return { + id: id, + type: type, + extraData: extraData, + } satisfies QueryResultEntryV2026R0; +} diff --git a/src/schemas/v2026R0/queryResultsV2026R0.ts b/src/schemas/v2026R0/queryResultsV2026R0.ts new file mode 100644 index 00000000..5fd832c0 --- /dev/null +++ b/src/schemas/v2026R0/queryResultsV2026R0.ts @@ -0,0 +1,87 @@ +import { serializeQueryResultEntryV2026R0 } from './queryResultEntryV2026R0'; +import { deserializeQueryResultEntryV2026R0 } from './queryResultEntryV2026R0'; +import { QueryResultEntryV2026R0 } from './queryResultEntryV2026R0'; +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 QueryResultsV2026R0 { + /** + * The list of items matching the query predicate. */ + readonly entries: readonly QueryResultEntryV2026R0[]; + /** + * The marker for the start of the next page of results. When `null`, there + * are no further results available. */ + readonly nextMarker?: string | null; + /** + * The limit that was used for this request. This will be the same as the limit query + * parameter unless that value exceeded the maximum value allowed. */ + readonly limit: number; + readonly rawData?: SerializedData; +} +export function serializeQueryResultsV2026R0( + val: QueryResultsV2026R0, +): SerializedData { + return { + ['entries']: val.entries.map(function ( + item: QueryResultEntryV2026R0, + ): SerializedData { + return serializeQueryResultEntryV2026R0(item); + }) as readonly any[], + ['next_marker']: val.nextMarker, + ['limit']: val.limit, + }; +} +export function deserializeQueryResultsV2026R0( + val: SerializedData, +): QueryResultsV2026R0 { + if (!sdIsMap(val)) { + throw new BoxSdkError({ + message: 'Expecting a map for "QueryResultsV2026R0"', + }); + } + if (val.entries == void 0) { + throw new BoxSdkError({ + message: + 'Expecting "entries" of type "QueryResultsV2026R0" to be defined', + }); + } + if (!sdIsList(val.entries)) { + throw new BoxSdkError({ + message: 'Expecting array for "entries" of type "QueryResultsV2026R0"', + }); + } + const entries: readonly QueryResultEntryV2026R0[] = sdIsList(val.entries) + ? (val.entries.map(function (itm: SerializedData): QueryResultEntryV2026R0 { + return deserializeQueryResultEntryV2026R0(itm); + }) as readonly any[]) + : []; + if (!(val.next_marker == void 0) && !sdIsString(val.next_marker)) { + throw new BoxSdkError({ + message: + 'Expecting string for "next_marker" of type "QueryResultsV2026R0"', + }); + } + const nextMarker: undefined | string = + val.next_marker == void 0 ? void 0 : val.next_marker; + if (val.limit == void 0) { + throw new BoxSdkError({ + message: 'Expecting "limit" of type "QueryResultsV2026R0" to be defined', + }); + } + if (!sdIsNumber(val.limit)) { + throw new BoxSdkError({ + message: 'Expecting number for "limit" of type "QueryResultsV2026R0"', + }); + } + const limit: number = val.limit; + return { + entries: entries, + nextMarker: nextMarker, + limit: limit, + } satisfies QueryResultsV2026R0; +} diff --git a/src/schemas/webLink.ts b/src/schemas/webLink.ts index b5360c40..e4a306b6 100644 --- a/src/schemas/webLink.ts +++ b/src/schemas/webLink.ts @@ -8,6 +8,8 @@ import { serializeFolderMini } from './folderMini'; import { deserializeFolderMini } from './folderMini'; import { serializeUserMini } from './userMini'; import { deserializeUserMini } from './userMini'; +import { serializeCollection } from './collection'; +import { deserializeCollection } from './collection'; import { serializeDateTime } from '../internal/utils'; import { deserializeDateTime } from '../internal/utils'; import { WebLinkBaseTypeField } from './webLinkBase'; @@ -15,6 +17,7 @@ import { WebLinkBase } from './webLinkBase'; import { WebLinkMini } from './webLinkMini'; import { FolderMini } from './folderMini'; import { UserMini } from './userMini'; +import { Collection } from './collection'; import { BoxSdkError } from '../box/errors'; import { DateTime } from '../internal/utils'; import { SerializedData } from '../serialization/json'; @@ -129,6 +132,8 @@ export interface WebLinkSharedLinkField { readonly rawData?: SerializedData; } export type WebLinkItemStatusField = 'active' | 'trashed' | 'deleted' | string; +export type WebLinkAllowedSharedLinkAccessLevelsField = + 'open' | 'company' | 'collaborators' | string; export class WebLink extends WebLinkMini { readonly parent?: FolderMini; readonly description?: string; @@ -142,6 +147,8 @@ export class WebLink extends WebLinkMini { readonly ownedBy?: UserMini; readonly sharedLink?: WebLinkSharedLinkField; readonly itemStatus?: WebLinkItemStatusField; + readonly collections?: readonly Collection[]; + readonly allowedSharedLinkAccessLevels?: readonly WebLinkAllowedSharedLinkAccessLevelsField[]; constructor(fields: WebLink) { super(fields); if (fields.parent !== undefined) { @@ -180,6 +187,12 @@ export class WebLink extends WebLinkMini { if (fields.itemStatus !== undefined) { this.itemStatus = fields.itemStatus; } + if (fields.collections !== undefined) { + this.collections = fields.collections; + } + if (fields.allowedSharedLinkAccessLevels !== undefined) { + this.allowedSharedLinkAccessLevels = fields.allowedSharedLinkAccessLevels; + } } } export function serializeWebLinkPathCollectionField( @@ -559,6 +572,30 @@ export function deserializeWebLinkItemStatusField( message: "Can't deserialize WebLinkItemStatusField", }); } +export function serializeWebLinkAllowedSharedLinkAccessLevelsField( + val: WebLinkAllowedSharedLinkAccessLevelsField, +): SerializedData { + return val; +} +export function deserializeWebLinkAllowedSharedLinkAccessLevelsField( + val: SerializedData, +): WebLinkAllowedSharedLinkAccessLevelsField { + if (val == 'open') { + return val; + } + if (val == 'company') { + return val; + } + if (val == 'collaborators') { + return val; + } + if (sdIsString(val)) { + return val; + } + throw new BoxSdkError({ + message: "Can't deserialize WebLinkAllowedSharedLinkAccessLevelsField", + }); +} export function serializeWebLink(val: WebLink): SerializedData { const base: any = serializeWebLinkMini(val); if (!sdIsMap(base)) { @@ -606,6 +643,20 @@ export function serializeWebLink(val: WebLink): SerializedData { val.itemStatus == void 0 ? val.itemStatus : serializeWebLinkItemStatusField(val.itemStatus), + ['collections']: + val.collections == void 0 + ? val.collections + : (val.collections.map(function (item: Collection): SerializedData { + return serializeCollection(item); + }) as readonly any[]), + ['allowed_shared_link_access_levels']: + val.allowedSharedLinkAccessLevels == void 0 + ? val.allowedSharedLinkAccessLevels + : (val.allowedSharedLinkAccessLevels.map(function ( + item: WebLinkAllowedSharedLinkAccessLevelsField, + ): SerializedData { + return serializeWebLinkAllowedSharedLinkAccessLevelsField(item); + }) as readonly any[]), }, }; } @@ -668,6 +719,39 @@ export function deserializeWebLink(val: SerializedData): WebLink { val.item_status == void 0 ? void 0 : deserializeWebLinkItemStatusField(val.item_status); + if (!(val.collections == void 0) && !sdIsList(val.collections)) { + throw new BoxSdkError({ + message: 'Expecting array for "collections" of type "WebLink"', + }); + } + const collections: undefined | readonly Collection[] = + val.collections == void 0 + ? void 0 + : sdIsList(val.collections) + ? (val.collections.map(function (itm: SerializedData): Collection { + return deserializeCollection(itm); + }) as readonly any[]) + : []; + if ( + !(val.allowed_shared_link_access_levels == void 0) && + !sdIsList(val.allowed_shared_link_access_levels) + ) { + throw new BoxSdkError({ + message: + 'Expecting array for "allowed_shared_link_access_levels" of type "WebLink"', + }); + } + const allowedSharedLinkAccessLevels: + undefined | readonly WebLinkAllowedSharedLinkAccessLevelsField[] = + val.allowed_shared_link_access_levels == void 0 + ? void 0 + : sdIsList(val.allowed_shared_link_access_levels) + ? (val.allowed_shared_link_access_levels.map(function ( + itm: SerializedData, + ): WebLinkAllowedSharedLinkAccessLevelsField { + return deserializeWebLinkAllowedSharedLinkAccessLevelsField(itm); + }) as readonly any[]) + : []; if (!(val.url == void 0) && !sdIsString(val.url)) { throw new BoxSdkError({ message: 'Expecting string for "url" of type "WebLink"', @@ -723,6 +807,8 @@ export function deserializeWebLink(val: SerializedData): WebLink { ownedBy: ownedBy, sharedLink: sharedLink, itemStatus: itemStatus, + collections: collections, + allowedSharedLinkAccessLevels: allowedSharedLinkAccessLevels, url: url, sequenceId: sequenceId, name: name,