From 0c671570b2c21ad0dc0bd718ae13e14ccba78947 Mon Sep 17 00:00:00 2001 From: box-sdk-build Date: Thu, 2 Apr 2026 03:52:12 -0700 Subject: [PATCH] feat: Support union of primitives (box/box-codegen#932) --- .codegen.json | 2 +- package-lock.json | 30 +++++----- src/managers/retentionPolicies.ts | 94 ++++++++++++++++++++++++------- 3 files changed, 90 insertions(+), 36 deletions(-) diff --git a/.codegen.json b/.codegen.json index a5bd8423a..b083491e5 100644 --- a/.codegen.json +++ b/.codegen.json @@ -1 +1 @@ -{ "engineHash": "8a22201", "specHash": "f8e0d99", "version": "10.6.0" } +{ "engineHash": "37c0986", "specHash": "f8e0d99", "version": "10.6.0" } diff --git a/package-lock.json b/package-lock.json index ba8f90a24..ebe7ca248 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2766,9 +2766,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.330", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.330.tgz", - "integrity": "sha512-jFNydB5kFtYUobh4IkWUnXeyDbjf/r9gcUEXe1xcrcUxIGfTdzPXA+ld6zBRbwvgIGVzDll/LTIiDztEtckSnA==", + "version": "1.5.331", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.331.tgz", + "integrity": "sha512-IbxXrsTlD3hRodkLnbxAPP4OuJYdWCeM3IOdT+CpcMoIwIoDfCmRpEtSPfwBXxVkg9xmBeY7Lz2Eo2TDn/HC3Q==", "dev": true, "license": "ISC" }, @@ -4878,9 +4878,9 @@ "license": "MIT" }, "node_modules/node-releases": { - "version": "2.0.36", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.36.tgz", - "integrity": "sha512-TdC8FSgHz8Mwtw9g5L4gR/Sh9XhSP/0DEkQxfEFXOpiul5IiHgHan2VhYYb6agDSfp4KuvltmGApc8HMgUrIkA==", + "version": "2.0.37", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.37.tgz", + "integrity": "sha512-1h5gKZCF+pO/o3Iqt5Jp7wc9rH3eJJ0+nh/CIoiRwjRxde/hAHyLPXYN4V3CqKAbiZPSeJFSWHmJsbkicta0Eg==", "dev": true, "license": "MIT" }, @@ -5932,19 +5932,19 @@ "license": "MIT" }, "node_modules/ts-jest": { - "version": "29.4.6", - "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.6.tgz", - "integrity": "sha512-fSpWtOO/1AjSNQguk43hb/JCo16oJDnMJf3CdEGNkqsEX3t0KX96xvyX1D7PfLCpVoKu4MfVrqUkFyblYoY4lA==", + "version": "29.4.9", + "resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.4.9.tgz", + "integrity": "sha512-LTb9496gYPMCqjeDLdPrKuXtncudeV1yRZnF4Wo5l3SFi0RYEnYRNgMrFIdg+FHvfzjCyQk1cLncWVqiSX+EvQ==", "dev": true, "license": "MIT", "dependencies": { "bs-logger": "^0.2.6", "fast-json-stable-stringify": "^2.1.0", - "handlebars": "^4.7.8", + "handlebars": "^4.7.9", "json5": "^2.2.3", "lodash.memoize": "^4.1.2", "make-error": "^1.3.6", - "semver": "^7.7.3", + "semver": "^7.7.4", "type-fest": "^4.41.0", "yargs-parser": "^21.1.1" }, @@ -5961,7 +5961,7 @@ "babel-jest": "^29.0.0 || ^30.0.0", "jest": "^29.0.0 || ^30.0.0", "jest-util": "^29.0.0 || ^30.0.0", - "typescript": ">=4.3 <6" + "typescript": ">=4.3 <7" }, "peerDependenciesMeta": { "@babel/core": { @@ -6011,9 +6011,9 @@ } }, "node_modules/ts-loader": { - "version": "9.5.4", - "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.5.4.tgz", - "integrity": "sha512-nCz0rEwunlTZiy6rXFByQU1kVVpCIgUpc/psFiKVrUwrizdnIbRFu8w7bxhUF0X613DYwT4XzrZHpVyMe758hQ==", + "version": "9.5.7", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.5.7.tgz", + "integrity": "sha512-/ZNrKgA3K3PtpMYOC71EeMWIloGw3IYEa5/t1cyz2r5/PyUwTXGzYJvcD3kfUvmhlfpz1rhV8B2O6IVTQ0avsg==", "dev": true, "license": "MIT", "dependencies": { diff --git a/src/managers/retentionPolicies.ts b/src/managers/retentionPolicies.ts index 5c4f4fc19..6c9d3ba6b 100644 --- a/src/managers/retentionPolicies.ts +++ b/src/managers/retentionPolicies.ts @@ -216,6 +216,9 @@ export type CreateRetentionPolicyRequestBodyDispositionActionField = | 'permanently_delete' | 'remove_retention' | string; +export type CreateRetentionPolicyRequestBodyRetentionLengthField = + | string + | number; export type CreateRetentionPolicyRequestBodyRetentionTypeField = | 'modifiable' | 'non_modifiable' @@ -249,7 +252,7 @@ export interface CreateRetentionPolicyRequestBody { * content. If the policy has a `policy_type` of * `indefinite`, the `retention_length` will also be * `indefinite`. */ - readonly retentionLength?: string; + readonly retentionLength?: CreateRetentionPolicyRequestBodyRetentionLengthField; /** * Specifies the retention type: * @@ -338,6 +341,9 @@ export interface GetRetentionPolicyByIdHeadersInput { readonly [key: string]: undefined | string; }; } +export type UpdateRetentionPolicyByIdRequestBodyRetentionLengthField = + | string + | number; export interface UpdateRetentionPolicyByIdRequestBody { /** * The name for the retention policy. */ @@ -383,7 +389,7 @@ export interface UpdateRetentionPolicyByIdRequestBody { * content. If the policy has a `policy_type` of * `indefinite`, the `retention_length` will also be * `indefinite`. */ - readonly retentionLength?: string; + readonly retentionLength?: UpdateRetentionPolicyByIdRequestBodyRetentionLengthField; /** * Used to retire a retention policy. * @@ -774,6 +780,25 @@ export function deserializeCreateRetentionPolicyRequestBodyDispositionActionFiel "Can't deserialize CreateRetentionPolicyRequestBodyDispositionActionField", }); } +export function serializeCreateRetentionPolicyRequestBodyRetentionLengthField( + val: any, +): SerializedData { + return val; +} +export function deserializeCreateRetentionPolicyRequestBodyRetentionLengthField( + val: SerializedData, +): CreateRetentionPolicyRequestBodyRetentionLengthField { + if (sdIsString(val)) { + return val; + } + if (sdIsNumber(val)) { + return val; + } + throw new BoxSdkError({ + message: + "Can't deserialize CreateRetentionPolicyRequestBodyRetentionLengthField", + }); +} export function serializeCreateRetentionPolicyRequestBodyRetentionTypeField( val: CreateRetentionPolicyRequestBodyRetentionTypeField, ): SerializedData { @@ -809,7 +834,12 @@ export function serializeCreateRetentionPolicyRequestBody( serializeCreateRetentionPolicyRequestBodyDispositionActionField( val.dispositionAction, ), - ['retention_length']: val.retentionLength, + ['retention_length']: + val.retentionLength == void 0 + ? val.retentionLength + : serializeCreateRetentionPolicyRequestBodyRetentionLengthField( + val.retentionLength, + ), ['retention_type']: val.retentionType == void 0 ? val.retentionType @@ -875,14 +905,14 @@ export function deserializeCreateRetentionPolicyRequestBody( deserializeCreateRetentionPolicyRequestBodyDispositionActionField( val.disposition_action, ); - if (!(val.retention_length == void 0) && !sdIsString(val.retention_length)) { - throw new BoxSdkError({ - message: - 'Expecting string for "retention_length" of type "CreateRetentionPolicyRequestBody"', - }); - } - const retentionLength: undefined | string = - val.retention_length == void 0 ? void 0 : val.retention_length; + const retentionLength: + | undefined + | CreateRetentionPolicyRequestBodyRetentionLengthField = + val.retention_length == void 0 + ? void 0 + : deserializeCreateRetentionPolicyRequestBodyRetentionLengthField( + val.retention_length, + ); const retentionType: | undefined | CreateRetentionPolicyRequestBodyRetentionTypeField = @@ -946,6 +976,25 @@ export function deserializeCreateRetentionPolicyRequestBody( customNotificationRecipients: customNotificationRecipients, } satisfies CreateRetentionPolicyRequestBody; } +export function serializeUpdateRetentionPolicyByIdRequestBodyRetentionLengthField( + val: any, +): SerializedData { + return val; +} +export function deserializeUpdateRetentionPolicyByIdRequestBodyRetentionLengthField( + val: SerializedData, +): UpdateRetentionPolicyByIdRequestBodyRetentionLengthField { + if (sdIsString(val)) { + return val; + } + if (sdIsNumber(val)) { + return val; + } + throw new BoxSdkError({ + message: + "Can't deserialize UpdateRetentionPolicyByIdRequestBodyRetentionLengthField", + }); +} export function serializeUpdateRetentionPolicyByIdRequestBody( val: UpdateRetentionPolicyByIdRequestBody, ): SerializedData { @@ -954,7 +1003,12 @@ export function serializeUpdateRetentionPolicyByIdRequestBody( ['description']: val.description, ['disposition_action']: val.dispositionAction, ['retention_type']: val.retentionType, - ['retention_length']: val.retentionLength, + ['retention_length']: + val.retentionLength == void 0 + ? val.retentionLength + : serializeUpdateRetentionPolicyByIdRequestBodyRetentionLengthField( + val.retentionLength, + ), ['status']: val.status, ['can_owner_extend_retention']: val.canOwnerExtendRetention, ['are_owners_notified']: val.areOwnersNotified, @@ -1011,14 +1065,14 @@ export function deserializeUpdateRetentionPolicyByIdRequestBody( } const retentionType: undefined | string = val.retention_type == void 0 ? void 0 : val.retention_type; - if (!(val.retention_length == void 0) && !sdIsString(val.retention_length)) { - throw new BoxSdkError({ - message: - 'Expecting string for "retention_length" of type "UpdateRetentionPolicyByIdRequestBody"', - }); - } - const retentionLength: undefined | string = - val.retention_length == void 0 ? void 0 : val.retention_length; + const retentionLength: + | undefined + | UpdateRetentionPolicyByIdRequestBodyRetentionLengthField = + val.retention_length == void 0 + ? void 0 + : deserializeUpdateRetentionPolicyByIdRequestBodyRetentionLengthField( + val.retention_length, + ); if (!(val.status == void 0) && !sdIsString(val.status)) { throw new BoxSdkError({ message: