• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-node-sdk / 23775261474

30 Mar 2026 03:53PM UTC coverage: 40.41% (-0.05%) from 40.46%
23775261474

push

github

web-flow
fix: Correct search content type 'tags' to match API (box/box-openapi#591) (#1382)

4649 of 20247 branches covered (22.96%)

Branch coverage included in aggregate %.

0 of 4 new or added lines in 2 files covered. (0.0%)

45 existing lines in 8 files now uncovered.

17178 of 33767 relevant lines covered (50.87%)

157.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

55.93
/src/managers/trashedItems.ts
1
import { serializeItems } from '../schemas/items';
2
import { deserializeItems } from '../schemas/items';
237✔
3
import { serializeClientError } from '../schemas/clientError';
4
import { deserializeClientError } from '../schemas/clientError';
5
import { ResponseFormat } from '../networking/fetchOptions';
6
import { Items } from '../schemas/items';
7
import { ClientError } from '../schemas/clientError';
8
import { BoxSdkError } from '../box/errors';
237✔
9
import { Authentication } from '../networking/auth';
10
import { NetworkSession } from '../networking/network';
237✔
11
import { FetchOptions } from '../networking/fetchOptions';
237✔
12
import { FetchResponse } from '../networking/fetchResponse';
13
import { prepareParams } from '../internal/utils';
237✔
14
import { toString } from '../internal/utils';
237✔
15
import { ByteStream } from '../internal/utils';
16
import { CancellationToken } from '../internal/utils';
17
import { sdToJson } from '../serialization/json';
18
import { SerializedData } from '../serialization/json';
19
import { sdIsEmpty } from '../serialization/json';
20
import { sdIsBoolean } from '../serialization/json';
21
import { sdIsNumber } from '../serialization/json';
22
import { sdIsString } from '../serialization/json';
237✔
23
import { sdIsList } from '../serialization/json';
24
import { sdIsMap } from '../serialization/json';
25
export type GetTrashedItemsQueryParamsDirectionField = 'ASC' | 'DESC' | string;
26
export type GetTrashedItemsQueryParamsSortField =
27
  | 'name'
28
  | 'date'
29
  | 'size'
30
  | string;
31
export interface GetTrashedItemsQueryParams {
32
  /**
33
   * A comma-separated list of attributes to include in the
34
   * response. This can be used to request fields that are
35
   * not normally returned in a standard response.
36
   *
37
   * Be aware that specifying this parameter will have the
38
   * effect that none of the standard fields are returned in
39
   * the response unless explicitly specified, instead only
40
   * fields for the mini representation are returned, additional
41
   * to the fields requested. */
42
  readonly fields?: readonly string[];
43
  /**
44
   * The maximum number of items to return per page. */
45
  readonly limit?: number;
46
  /**
47
   * The offset of the item at which to begin the response.
48
   *
49
   * Queries with offset parameter value
50
   * exceeding 10000 will be rejected
51
   * with a 400 response. */
52
  readonly offset?: number;
53
  /**
54
   * Specifies whether to use marker-based pagination instead of
55
   * offset-based pagination. Only one pagination method can
56
   * be used at a time.
57
   *
58
   * By setting this value to true, the API will return a `marker` field
59
   * that can be passed as a parameter to this endpoint to get the next
60
   * page of the response. */
61
  readonly usemarker?: boolean;
62
  /**
63
   * Defines the position marker at which to begin returning results. This is
64
   * used when paginating using marker-based pagination.
65
   *
66
   * This requires `usemarker` to be set to `true`. */
67
  readonly marker?: string;
68
  /**
69
   * The direction to sort results in. This can be either in alphabetical ascending
70
   * (`ASC`) or descending (`DESC`) order. */
71
  readonly direction?: GetTrashedItemsQueryParamsDirectionField;
72
  /**
73
   * Defines the **second** attribute by which items
74
   * are sorted.
75
   *
76
   * Items are always sorted by their `type` first, with
77
   * folders listed before files, and files listed
78
   * before web links.
79
   *
80
   * This parameter is not supported when using marker-based pagination. */
81
  readonly sort?: GetTrashedItemsQueryParamsSortField;
82
}
83
export class GetTrashedItemsHeaders {
237✔
84
  /**
85
   * Extra headers that will be included in the HTTP request. */
86
  readonly extraHeaders?: {
6✔
87
    readonly [key: string]: undefined | string;
88
  } = {};
89
  constructor(
90
    fields: Omit<GetTrashedItemsHeaders, 'extraHeaders'> &
91
      Partial<Pick<GetTrashedItemsHeaders, 'extraHeaders'>>,
92
  ) {
93
    if (fields.extraHeaders !== undefined) {
6✔
94
      this.extraHeaders = fields.extraHeaders;
3✔
95
    }
96
  }
97
}
98
export interface GetTrashedItemsHeadersInput {
99
  /**
100
   * Extra headers that will be included in the HTTP request. */
101
  readonly extraHeaders?: {
102
    readonly [key: string]: undefined | string;
103
  };
104
}
105
export class TrashedItemsManager {
237✔
106
  readonly auth?: Authentication;
107
  readonly networkSession: NetworkSession = new NetworkSession({});
510✔
108
  constructor(
109
    fields: Omit<TrashedItemsManager, 'networkSession' | 'getTrashedItems'> &
110
      Partial<Pick<TrashedItemsManager, 'networkSession'>>,
111
  ) {
112
    if (fields.auth !== undefined) {
510✔
113
      this.auth = fields.auth;
510✔
114
    }
115
    if (fields.networkSession !== undefined) {
510✔
116
      this.networkSession = fields.networkSession;
510✔
117
    }
118
  }
119
  /**
120
   * Retrieves the files and folders that have been moved
121
   * to the trash.
122
   *
123
   * Any attribute in the full files or folders objects can be passed
124
   * in with the `fields` parameter to retrieve those specific
125
   * attributes that are not returned by default.
126
   *
127
   * This endpoint defaults to use offset-based pagination, yet also supports
128
   * marker-based pagination using the `marker` parameter.
129
   *
130
   * The number of entries returned may be less than `total_count`. For example, if a user deletes items from a shared folder and is later removed as a collaborator, those deleted items will no longer appear in this endpoint’s results, even though they are still included in `total_count`.
131
   * @param {GetTrashedItemsQueryParams} queryParams Query parameters of getTrashedItems method
132
   * @param {GetTrashedItemsHeadersInput} headersInput Headers of getTrashedItems method
133
   * @param {CancellationToken} cancellationToken Token used for request cancellation.
134
   * @returns {Promise<Items>}
135
   */
136
  async getTrashedItems(
137
    queryParams: GetTrashedItemsQueryParams = {} satisfies GetTrashedItemsQueryParams,
3✔
138
    headersInput: GetTrashedItemsHeadersInput = new GetTrashedItemsHeaders({}),
3✔
139
    cancellationToken?: CancellationToken,
140
  ): Promise<Items> {
141
    const headers: GetTrashedItemsHeaders = new GetTrashedItemsHeaders({
3✔
142
      extraHeaders: headersInput.extraHeaders,
143
    });
144
    const queryParamsMap: {
145
      readonly [key: string]: string;
146
    } = prepareParams({
3✔
147
      ['fields']: queryParams.fields
3!
148
        ? queryParams.fields.map(toString).join(',')
149
        : undefined,
150
      ['limit']: toString(queryParams.limit) as string,
151
      ['offset']: toString(queryParams.offset) as string,
152
      ['usemarker']: toString(queryParams.usemarker) as string,
153
      ['marker']: toString(queryParams.marker) as string,
154
      ['direction']: toString(queryParams.direction) as string,
155
      ['sort']: toString(queryParams.sort) as string,
156
    });
157
    const headersMap: {
158
      readonly [key: string]: string;
159
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
160
    const response: FetchResponse =
161
      await this.networkSession.networkClient.fetch(
3✔
162
        new FetchOptions({
163
          url: ''.concat(
164
            this.networkSession.baseUrls.baseUrl,
165
            '/2.0/folders/trash/items',
166
          ) as string,
167
          method: 'GET',
168
          params: queryParamsMap,
169
          headers: headersMap,
170
          responseFormat: 'json' as ResponseFormat,
171
          auth: this.auth,
172
          networkSession: this.networkSession,
173
          cancellationToken: cancellationToken,
174
        }),
175
      );
176
    return {
3✔
177
      ...deserializeItems(response.data!),
178
      rawData: response.data!,
179
    };
180
  }
181
}
182
export interface TrashedItemsManagerInput {
183
  readonly auth?: Authentication;
184
  readonly networkSession?: NetworkSession;
185
}
186
export function serializeGetTrashedItemsQueryParamsDirectionField(
237✔
187
  val: GetTrashedItemsQueryParamsDirectionField,
188
): SerializedData {
UNCOV
189
  return val;
×
190
}
191
export function deserializeGetTrashedItemsQueryParamsDirectionField(
237✔
192
  val: SerializedData,
193
): GetTrashedItemsQueryParamsDirectionField {
UNCOV
194
  if (val == 'ASC') {
×
195
    return val;
×
196
  }
UNCOV
197
  if (val == 'DESC') {
×
198
    return val;
×
199
  }
UNCOV
200
  if (sdIsString(val)) {
×
201
    return val;
×
202
  }
UNCOV
203
  throw new BoxSdkError({
×
204
    message: "Can't deserialize GetTrashedItemsQueryParamsDirectionField",
205
  });
206
}
207
export function serializeGetTrashedItemsQueryParamsSortField(
237✔
208
  val: GetTrashedItemsQueryParamsSortField,
209
): SerializedData {
UNCOV
210
  return val;
×
211
}
212
export function deserializeGetTrashedItemsQueryParamsSortField(
237✔
213
  val: SerializedData,
214
): GetTrashedItemsQueryParamsSortField {
UNCOV
215
  if (val == 'name') {
×
216
    return val;
×
217
  }
UNCOV
218
  if (val == 'date') {
×
219
    return val;
×
220
  }
UNCOV
221
  if (val == 'size') {
×
222
    return val;
×
223
  }
UNCOV
224
  if (sdIsString(val)) {
×
225
    return val;
×
226
  }
UNCOV
227
  throw new BoxSdkError({
×
228
    message: "Can't deserialize GetTrashedItemsQueryParamsSortField",
229
  });
230
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc