UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

607 lines 27.6 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.BoxClient = void 0; const authorization_1 = require("./managers/authorization.js"); const files_1 = require("./managers/files.js"); const trashedFiles_1 = require("./managers/trashedFiles.js"); const appItemAssociations_1 = require("./managers/appItemAssociations.js"); const downloads_1 = require("./managers/downloads.js"); const uploads_1 = require("./managers/uploads.js"); const chunkedUploads_1 = require("./managers/chunkedUploads.js"); const listCollaborations_1 = require("./managers/listCollaborations.js"); const comments_1 = require("./managers/comments.js"); const tasks_1 = require("./managers/tasks.js"); const fileVersions_1 = require("./managers/fileVersions.js"); const fileMetadata_1 = require("./managers/fileMetadata.js"); const fileClassifications_1 = require("./managers/fileClassifications.js"); const skills_1 = require("./managers/skills.js"); const fileWatermarks_1 = require("./managers/fileWatermarks.js"); const fileRequests_1 = require("./managers/fileRequests.js"); const folders_1 = require("./managers/folders.js"); const trashedFolders_1 = require("./managers/trashedFolders.js"); const folderMetadata_1 = require("./managers/folderMetadata.js"); const folderClassifications_1 = require("./managers/folderClassifications.js"); const trashedItems_1 = require("./managers/trashedItems.js"); const folderWatermarks_1 = require("./managers/folderWatermarks.js"); const folderLocks_1 = require("./managers/folderLocks.js"); const metadataTemplates_1 = require("./managers/metadataTemplates.js"); const classifications_1 = require("./managers/classifications.js"); const metadataCascadePolicies_1 = require("./managers/metadataCascadePolicies.js"); const search_1 = require("./managers/search.js"); const userCollaborations_1 = require("./managers/userCollaborations.js"); const taskAssignments_1 = require("./managers/taskAssignments.js"); const sharedLinksFiles_1 = require("./managers/sharedLinksFiles.js"); const sharedLinksFolders_1 = require("./managers/sharedLinksFolders.js"); const webLinks_1 = require("./managers/webLinks.js"); const trashedWebLinks_1 = require("./managers/trashedWebLinks.js"); const sharedLinksWebLinks_1 = require("./managers/sharedLinksWebLinks.js"); const sharedLinksAppItems_1 = require("./managers/sharedLinksAppItems.js"); const users_1 = require("./managers/users.js"); const sessionTermination_1 = require("./managers/sessionTermination.js"); const avatars_1 = require("./managers/avatars.js"); const transfer_1 = require("./managers/transfer.js"); const emailAliases_1 = require("./managers/emailAliases.js"); const memberships_1 = require("./managers/memberships.js"); const invites_1 = require("./managers/invites.js"); const groups_1 = require("./managers/groups.js"); const webhooks_1 = require("./managers/webhooks.js"); const events_1 = require("./managers/events.js"); const collections_1 = require("./managers/collections.js"); const recentItems_1 = require("./managers/recentItems.js"); const retentionPolicies_1 = require("./managers/retentionPolicies.js"); const retentionPolicyAssignments_1 = require("./managers/retentionPolicyAssignments.js"); const legalHoldPolicies_1 = require("./managers/legalHoldPolicies.js"); const legalHoldPolicyAssignments_1 = require("./managers/legalHoldPolicyAssignments.js"); const fileVersionRetentions_1 = require("./managers/fileVersionRetentions.js"); const fileVersionLegalHolds_1 = require("./managers/fileVersionLegalHolds.js"); const shieldInformationBarriers_1 = require("./managers/shieldInformationBarriers.js"); const shieldInformationBarrierReports_1 = require("./managers/shieldInformationBarrierReports.js"); const shieldInformationBarrierSegments_1 = require("./managers/shieldInformationBarrierSegments.js"); const shieldInformationBarrierSegmentMembers_1 = require("./managers/shieldInformationBarrierSegmentMembers.js"); const shieldInformationBarrierSegmentRestrictions_1 = require("./managers/shieldInformationBarrierSegmentRestrictions.js"); const devicePinners_1 = require("./managers/devicePinners.js"); const termsOfServices_1 = require("./managers/termsOfServices.js"); const termsOfServiceUserStatuses_1 = require("./managers/termsOfServiceUserStatuses.js"); const collaborationAllowlistEntries_1 = require("./managers/collaborationAllowlistEntries.js"); const collaborationAllowlistExemptTargets_1 = require("./managers/collaborationAllowlistExemptTargets.js"); const storagePolicies_1 = require("./managers/storagePolicies.js"); const storagePolicyAssignments_1 = require("./managers/storagePolicyAssignments.js"); const zipDownloads_1 = require("./managers/zipDownloads.js"); const signRequests_1 = require("./managers/signRequests.js"); const workflows_1 = require("./managers/workflows.js"); const signTemplates_1 = require("./managers/signTemplates.js"); const integrationMappings_1 = require("./managers/integrationMappings.js"); const ai_1 = require("./managers/ai.js"); const aiStudio_1 = require("./managers/aiStudio.js"); const metadataTaxonomies_1 = require("./managers/metadataTaxonomies.js"); const docgenTemplate_1 = require("./managers/docgenTemplate.js"); const docgen_1 = require("./managers/docgen.js"); const enterpriseConfigurations_1 = require("./managers/enterpriseConfigurations.js"); const hubs_1 = require("./managers/hubs.js"); const hubCollaborations_1 = require("./managers/hubCollaborations.js"); const hubItems_1 = require("./managers/hubItems.js"); const hubDocument_1 = require("./managers/hubDocument.js"); const shieldLists_1 = require("./managers/shieldLists.js"); const archives_1 = require("./managers/archives.js"); const externalUsers_1 = require("./managers/externalUsers.js"); const automateWorkflows_1 = require("./managers/automateWorkflows.js"); const notes_1 = require("./managers/notes.js"); const query_1 = require("./managers/query.js"); const network_1 = require("./networking/network.js"); const fetchOptions_1 = require("./networking/fetchOptions.js"); const baseUrls_1 = require("./networking/baseUrls.js"); class BoxClient { constructor(fields) { this.networkSession = new network_1.NetworkSession({ baseUrls: new baseUrls_1.BaseUrls({}), }); if (fields.auth !== undefined) { this.auth = fields.auth; } if (fields.networkSession !== undefined) { this.networkSession = fields.networkSession; } this.authorization = new authorization_1.AuthorizationManager({ auth: this.auth, networkSession: this.networkSession, }); this.files = new files_1.FilesManager({ auth: this.auth, networkSession: this.networkSession, }); this.trashedFiles = new trashedFiles_1.TrashedFilesManager({ auth: this.auth, networkSession: this.networkSession, }); this.appItemAssociations = new appItemAssociations_1.AppItemAssociationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.downloads = new downloads_1.DownloadsManager({ auth: this.auth, networkSession: this.networkSession, }); this.uploads = new uploads_1.UploadsManager({ auth: this.auth, networkSession: this.networkSession, }); this.chunkedUploads = new chunkedUploads_1.ChunkedUploadsManager({ auth: this.auth, networkSession: this.networkSession, }); this.listCollaborations = new listCollaborations_1.ListCollaborationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.comments = new comments_1.CommentsManager({ auth: this.auth, networkSession: this.networkSession, }); this.tasks = new tasks_1.TasksManager({ auth: this.auth, networkSession: this.networkSession, }); this.fileVersions = new fileVersions_1.FileVersionsManager({ auth: this.auth, networkSession: this.networkSession, }); this.fileMetadata = new fileMetadata_1.FileMetadataManager({ auth: this.auth, networkSession: this.networkSession, }); this.fileClassifications = new fileClassifications_1.FileClassificationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.skills = new skills_1.SkillsManager({ auth: this.auth, networkSession: this.networkSession, }); this.fileWatermarks = new fileWatermarks_1.FileWatermarksManager({ auth: this.auth, networkSession: this.networkSession, }); this.fileRequests = new fileRequests_1.FileRequestsManager({ auth: this.auth, networkSession: this.networkSession, }); this.folders = new folders_1.FoldersManager({ auth: this.auth, networkSession: this.networkSession, }); this.trashedFolders = new trashedFolders_1.TrashedFoldersManager({ auth: this.auth, networkSession: this.networkSession, }); this.folderMetadata = new folderMetadata_1.FolderMetadataManager({ auth: this.auth, networkSession: this.networkSession, }); this.folderClassifications = new folderClassifications_1.FolderClassificationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.trashedItems = new trashedItems_1.TrashedItemsManager({ auth: this.auth, networkSession: this.networkSession, }); this.folderWatermarks = new folderWatermarks_1.FolderWatermarksManager({ auth: this.auth, networkSession: this.networkSession, }); this.folderLocks = new folderLocks_1.FolderLocksManager({ auth: this.auth, networkSession: this.networkSession, }); this.metadataTemplates = new metadataTemplates_1.MetadataTemplatesManager({ auth: this.auth, networkSession: this.networkSession, }); this.classifications = new classifications_1.ClassificationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.metadataCascadePolicies = new metadataCascadePolicies_1.MetadataCascadePoliciesManager({ auth: this.auth, networkSession: this.networkSession, }); this.search = new search_1.SearchManager({ auth: this.auth, networkSession: this.networkSession, }); this.userCollaborations = new userCollaborations_1.UserCollaborationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.taskAssignments = new taskAssignments_1.TaskAssignmentsManager({ auth: this.auth, networkSession: this.networkSession, }); this.sharedLinksFiles = new sharedLinksFiles_1.SharedLinksFilesManager({ auth: this.auth, networkSession: this.networkSession, }); this.sharedLinksFolders = new sharedLinksFolders_1.SharedLinksFoldersManager({ auth: this.auth, networkSession: this.networkSession, }); this.webLinks = new webLinks_1.WebLinksManager({ auth: this.auth, networkSession: this.networkSession, }); this.trashedWebLinks = new trashedWebLinks_1.TrashedWebLinksManager({ auth: this.auth, networkSession: this.networkSession, }); this.sharedLinksWebLinks = new sharedLinksWebLinks_1.SharedLinksWebLinksManager({ auth: this.auth, networkSession: this.networkSession, }); this.sharedLinksAppItems = new sharedLinksAppItems_1.SharedLinksAppItemsManager({ auth: this.auth, networkSession: this.networkSession, }); this.users = new users_1.UsersManager({ auth: this.auth, networkSession: this.networkSession, }); this.sessionTermination = new sessionTermination_1.SessionTerminationManager({ auth: this.auth, networkSession: this.networkSession, }); this.avatars = new avatars_1.AvatarsManager({ auth: this.auth, networkSession: this.networkSession, }); this.transfer = new transfer_1.TransferManager({ auth: this.auth, networkSession: this.networkSession, }); this.emailAliases = new emailAliases_1.EmailAliasesManager({ auth: this.auth, networkSession: this.networkSession, }); this.memberships = new memberships_1.MembershipsManager({ auth: this.auth, networkSession: this.networkSession, }); this.invites = new invites_1.InvitesManager({ auth: this.auth, networkSession: this.networkSession, }); this.groups = new groups_1.GroupsManager({ auth: this.auth, networkSession: this.networkSession, }); this.webhooks = new webhooks_1.WebhooksManager({ auth: this.auth, networkSession: this.networkSession, }); this.events = new events_1.EventsManager({ auth: this.auth, networkSession: this.networkSession, }); this.collections = new collections_1.CollectionsManager({ auth: this.auth, networkSession: this.networkSession, }); this.recentItems = new recentItems_1.RecentItemsManager({ auth: this.auth, networkSession: this.networkSession, }); this.retentionPolicies = new retentionPolicies_1.RetentionPoliciesManager({ auth: this.auth, networkSession: this.networkSession, }); this.retentionPolicyAssignments = new retentionPolicyAssignments_1.RetentionPolicyAssignmentsManager({ auth: this.auth, networkSession: this.networkSession, }); this.legalHoldPolicies = new legalHoldPolicies_1.LegalHoldPoliciesManager({ auth: this.auth, networkSession: this.networkSession, }); this.legalHoldPolicyAssignments = new legalHoldPolicyAssignments_1.LegalHoldPolicyAssignmentsManager({ auth: this.auth, networkSession: this.networkSession, }); this.fileVersionRetentions = new fileVersionRetentions_1.FileVersionRetentionsManager({ auth: this.auth, networkSession: this.networkSession, }); this.fileVersionLegalHolds = new fileVersionLegalHolds_1.FileVersionLegalHoldsManager({ auth: this.auth, networkSession: this.networkSession, }); this.shieldInformationBarriers = new shieldInformationBarriers_1.ShieldInformationBarriersManager({ auth: this.auth, networkSession: this.networkSession, }); this.shieldInformationBarrierReports = new shieldInformationBarrierReports_1.ShieldInformationBarrierReportsManager({ auth: this.auth, networkSession: this.networkSession, }); this.shieldInformationBarrierSegments = new shieldInformationBarrierSegments_1.ShieldInformationBarrierSegmentsManager({ auth: this.auth, networkSession: this.networkSession, }); this.shieldInformationBarrierSegmentMembers = new shieldInformationBarrierSegmentMembers_1.ShieldInformationBarrierSegmentMembersManager({ auth: this.auth, networkSession: this.networkSession, }); this.shieldInformationBarrierSegmentRestrictions = new shieldInformationBarrierSegmentRestrictions_1.ShieldInformationBarrierSegmentRestrictionsManager({ auth: this.auth, networkSession: this.networkSession, }); this.devicePinners = new devicePinners_1.DevicePinnersManager({ auth: this.auth, networkSession: this.networkSession, }); this.termsOfServices = new termsOfServices_1.TermsOfServicesManager({ auth: this.auth, networkSession: this.networkSession, }); this.termsOfServiceUserStatuses = new termsOfServiceUserStatuses_1.TermsOfServiceUserStatusesManager({ auth: this.auth, networkSession: this.networkSession, }); this.collaborationAllowlistEntries = new collaborationAllowlistEntries_1.CollaborationAllowlistEntriesManager({ auth: this.auth, networkSession: this.networkSession, }); this.collaborationAllowlistExemptTargets = new collaborationAllowlistExemptTargets_1.CollaborationAllowlistExemptTargetsManager({ auth: this.auth, networkSession: this.networkSession, }); this.storagePolicies = new storagePolicies_1.StoragePoliciesManager({ auth: this.auth, networkSession: this.networkSession, }); this.storagePolicyAssignments = new storagePolicyAssignments_1.StoragePolicyAssignmentsManager({ auth: this.auth, networkSession: this.networkSession, }); this.zipDownloads = new zipDownloads_1.ZipDownloadsManager({ auth: this.auth, networkSession: this.networkSession, }); this.signRequests = new signRequests_1.SignRequestsManager({ auth: this.auth, networkSession: this.networkSession, }); this.workflows = new workflows_1.WorkflowsManager({ auth: this.auth, networkSession: this.networkSession, }); this.signTemplates = new signTemplates_1.SignTemplatesManager({ auth: this.auth, networkSession: this.networkSession, }); this.integrationMappings = new integrationMappings_1.IntegrationMappingsManager({ auth: this.auth, networkSession: this.networkSession, }); this.ai = new ai_1.AiManager({ auth: this.auth, networkSession: this.networkSession, }); this.aiStudio = new aiStudio_1.AiStudioManager({ auth: this.auth, networkSession: this.networkSession, }); this.metadataTaxonomies = new metadataTaxonomies_1.MetadataTaxonomiesManager({ auth: this.auth, networkSession: this.networkSession, }); this.docgenTemplate = new docgenTemplate_1.DocgenTemplateManager({ auth: this.auth, networkSession: this.networkSession, }); this.docgen = new docgen_1.DocgenManager({ auth: this.auth, networkSession: this.networkSession, }); this.enterpriseConfigurations = new enterpriseConfigurations_1.EnterpriseConfigurationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.hubs = new hubs_1.HubsManager({ auth: this.auth, networkSession: this.networkSession, }); this.hubCollaborations = new hubCollaborations_1.HubCollaborationsManager({ auth: this.auth, networkSession: this.networkSession, }); this.hubItems = new hubItems_1.HubItemsManager({ auth: this.auth, networkSession: this.networkSession, }); this.hubDocument = new hubDocument_1.HubDocumentManager({ auth: this.auth, networkSession: this.networkSession, }); this.shieldLists = new shieldLists_1.ShieldListsManager({ auth: this.auth, networkSession: this.networkSession, }); this.archives = new archives_1.ArchivesManager({ auth: this.auth, networkSession: this.networkSession, }); this.externalUsers = new externalUsers_1.ExternalUsersManager({ auth: this.auth, networkSession: this.networkSession, }); this.automateWorkflows = new automateWorkflows_1.AutomateWorkflowsManager({ auth: this.auth, networkSession: this.networkSession, }); this.notes = new notes_1.NotesManager({ auth: this.auth, networkSession: this.networkSession, }); this.query = new query_1.QueryManager({ auth: this.auth, networkSession: this.networkSession, }); } /** * Make a custom http request using the client authentication and network session. * @param {FetchOptionsInput} fetchOptionsInput Options to be passed to the fetch call * @returns {Promise<FetchResponse>} */ makeRequest(fetchOptionsInput) { return __awaiter(this, void 0, void 0, function* () { const fetchOptions = new fetchOptions_1.FetchOptions({ url: fetchOptionsInput.url, method: fetchOptionsInput.method, params: fetchOptionsInput.params, headers: fetchOptionsInput.headers, data: fetchOptionsInput.data, fileStream: fetchOptionsInput.fileStream, multipartData: fetchOptionsInput.multipartData, contentType: fetchOptionsInput.contentType, responseFormat: fetchOptionsInput.responseFormat, auth: fetchOptionsInput.auth, networkSession: fetchOptionsInput.networkSession, cancellationToken: fetchOptionsInput.cancellationToken, followRedirects: fetchOptionsInput.followRedirects, }); const auth = fetchOptions.auth == void 0 ? this.auth : fetchOptions.auth; const networkSession = fetchOptions.networkSession == void 0 ? this.networkSession : fetchOptions.networkSession; const enrichedFetchOptions = new fetchOptions_1.FetchOptions({ auth: auth, networkSession: networkSession, url: fetchOptions.url, method: fetchOptions.method, params: fetchOptions.params, headers: fetchOptions.headers, data: fetchOptions.data, fileStream: fetchOptions.fileStream, multipartData: fetchOptions.multipartData, contentType: fetchOptions.contentType, responseFormat: fetchOptions.responseFormat, followRedirects: fetchOptions.followRedirects, }); return yield networkSession.networkClient.fetch(enrichedFetchOptions); }); } /** * Create a new client to impersonate user with the provided ID. All calls made with the new client will be made in context of the impersonated user, leaving the original client unmodified. * @param {string} userId ID of an user to impersonate * @returns {BoxClient} */ withAsUserHeader(userId) { return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withAdditionalHeaders({ ['As-User']: userId, }), }); } /** * Create a new client with suppressed notifications. Calls made with the new client will not trigger email or webhook notifications * @returns {BoxClient} */ withSuppressedNotifications() { return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withAdditionalHeaders({ ['Box-Notifications']: 'off', }), }); } /** * Create a new client with a custom set of headers that will be included in every API call * @param {{ readonly [key: string]: string; }} extraHeaders Custom set of headers that will be included in every API call * @returns {BoxClient} */ withExtraHeaders(extraHeaders = {}) { return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withAdditionalHeaders(extraHeaders), }); } /** * Create a new client with a custom set of base urls that will be used for every API call * @param {BaseUrlsInput} baseUrlsInput Custom set of base urls that will be used for every API call * @returns {BoxClient} */ withCustomBaseUrls(baseUrlsInput) { const baseUrls = new baseUrls_1.BaseUrls({ baseUrl: baseUrlsInput.baseUrl, uploadUrl: baseUrlsInput.uploadUrl, oauth2Url: baseUrlsInput.oauth2Url, }); return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withCustomBaseUrls(baseUrls), }); } /** * Create a new client with a custom proxy that will be used for every API call * @param {ProxyConfig} config * @returns {BoxClient} */ withProxy(config) { return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withProxy(config), }); } /** * Create a new client with custom timeouts that will be used for every API call * @param {TimeoutConfig} config Timeout configuration. * @returns {BoxClient} */ withTimeouts(config) { return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withTimeoutConfig(config), }); } /** * Create a new client with a custom set of agent options that will be used for every API call * @param {AgentOptions} agentOptions Custom set of agent options that will be used for every API call * @returns {BoxClient} */ withCustomAgentOptions(agentOptions) { return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withCustomAgentOptions(agentOptions), }); } /** * Create a new client with a custom set of interceptors that will be used for every API call * @param {readonly Interceptor[]} interceptors Custom set of interceptors that will be used for every API call * @returns {BoxClient} */ withInterceptors(interceptors) { return new BoxClient({ auth: this.auth, networkSession: this.networkSession.withInterceptors(interceptors), }); } } exports.BoxClient = BoxClient; //# sourceMappingURL=client.js.map