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

box / box-typescript-sdk-gen / 11616599821

31 Oct 2024 05:11PM UTC coverage: 41.667% (-0.06%) from 41.724%
11616599821

Pull #393

github

web-flow
Merge 7c00c545e into 6ec417e6f
Pull Request #393: test: Expanding test in search manager (box/box-codegen#593)

4050 of 16840 branches covered (24.05%)

Branch coverage included in aggregate %.

2 of 2 new or added lines in 1 file covered. (100.0%)

17 existing lines in 5 files now uncovered.

13362 of 24948 relevant lines covered (53.56%)

77.88 hits per line

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

28.47
/src/schemas/searchResults.generated.ts
1
import { serializeFileFullOrFolderFullOrWebLink } from './fileFullOrFolderFullOrWebLink.generated.js';
140✔
2
import { deserializeFileFullOrFolderFullOrWebLink } from './fileFullOrFolderFullOrWebLink.generated.js';
140✔
3
import { FileFullOrFolderFullOrWebLink } from './fileFullOrFolderFullOrWebLink.generated.js';
4
import { BoxSdkError } from '../box/errors.js';
140✔
5
import { SerializedData } from '../serialization/json.js';
6
import { sdIsEmpty } from '../serialization/json.js';
7
import { sdIsBoolean } from '../serialization/json.js';
8
import { sdIsNumber } from '../serialization/json.js';
140✔
9
import { sdIsString } from '../serialization/json.js';
10
import { sdIsList } from '../serialization/json.js';
140✔
11
import { sdIsMap } from '../serialization/json.js';
140✔
12
export type SearchResultsTypeField = 'search_results_items';
13
export class SearchResults {
140✔
14
  /**
15
   * One greater than the offset of the last entry in the search results.
16
   * The total number of entries in the collection may be less than
17
   * `total_count`. */
18
  readonly totalCount?: number;
19
  /**
20
   * The limit that was used for this search. This will be the same as the
21
   * `limit` query parameter unless that value exceeded the maximum value
22
   * allowed. */
23
  readonly limit?: number;
24
  /**
25
   * The 0-based offset of the first entry in this set. This will be the same
26
   * as the `offset` query parameter used. */
27
  readonly offset?: number;
28
  /**
29
   * Specifies the response as search result items without shared links */
30
  readonly type: SearchResultsTypeField =
×
31
    'search_results_items' as SearchResultsTypeField;
32
  /**
33
   * The search results for the query provided. */
34
  readonly entries?: readonly FileFullOrFolderFullOrWebLink[];
35
  readonly rawData?: SerializedData;
36
  constructor(
37
    fields: Omit<SearchResults, 'type'> & Partial<Pick<SearchResults, 'type'>>
38
  ) {
39
    if (fields.totalCount) {
×
40
      this.totalCount = fields.totalCount;
×
41
    }
42
    if (fields.limit) {
×
43
      this.limit = fields.limit;
×
44
    }
45
    if (fields.offset) {
×
46
      this.offset = fields.offset;
×
47
    }
48
    if (fields.type) {
×
49
      this.type = fields.type;
×
50
    }
51
    if (fields.entries) {
×
52
      this.entries = fields.entries;
×
53
    }
54
    if (fields.rawData) {
×
55
      this.rawData = fields.rawData;
×
56
    }
57
  }
58
}
59
export interface SearchResultsInput {
60
  /**
61
   * One greater than the offset of the last entry in the search results.
62
   * The total number of entries in the collection may be less than
63
   * `total_count`. */
64
  readonly totalCount?: number;
65
  /**
66
   * The limit that was used for this search. This will be the same as the
67
   * `limit` query parameter unless that value exceeded the maximum value
68
   * allowed. */
69
  readonly limit?: number;
70
  /**
71
   * The 0-based offset of the first entry in this set. This will be the same
72
   * as the `offset` query parameter used. */
73
  readonly offset?: number;
74
  /**
75
   * Specifies the response as search result items without shared links */
76
  readonly type?: SearchResultsTypeField;
77
  /**
78
   * The search results for the query provided. */
79
  readonly entries?: readonly FileFullOrFolderFullOrWebLink[];
80
  readonly rawData?: SerializedData;
81
}
82
export function serializeSearchResultsTypeField(
140✔
83
  val: SearchResultsTypeField
84
): SerializedData {
85
  return val;
×
86
}
87
export function deserializeSearchResultsTypeField(
140✔
88
  val: SerializedData
89
): SearchResultsTypeField {
90
  if (val == 'search_results_items') {
4✔
91
    return val;
4✔
92
  }
93
  throw new BoxSdkError({
×
94
    message: "Can't deserialize SearchResultsTypeField",
95
  });
96
}
97
export function serializeSearchResults(val: SearchResults): SerializedData {
140✔
98
  return {
×
99
    ['total_count']: val.totalCount == void 0 ? void 0 : val.totalCount,
×
100
    ['limit']: val.limit == void 0 ? void 0 : val.limit,
×
101
    ['offset']: val.offset == void 0 ? void 0 : val.offset,
×
102
    ['type']: serializeSearchResultsTypeField(val.type),
103
    ['entries']:
104
      val.entries == void 0
×
105
        ? void 0
106
        : (val.entries.map(function (
107
            item: FileFullOrFolderFullOrWebLink
108
          ): SerializedData {
109
            return serializeFileFullOrFolderFullOrWebLink(item);
×
110
          }) as readonly any[]),
111
  };
112
}
113
export function deserializeSearchResults(val: SerializedData): SearchResults {
140✔
114
  if (!sdIsMap(val)) {
4!
115
    throw new BoxSdkError({ message: 'Expecting a map for "SearchResults"' });
×
116
  }
117
  if (!(val.total_count == void 0) && !sdIsNumber(val.total_count)) {
4!
118
    throw new BoxSdkError({
×
119
      message: 'Expecting number for "total_count" of type "SearchResults"',
120
    });
121
  }
122
  const totalCount: undefined | number =
123
    val.total_count == void 0 ? void 0 : val.total_count;
4!
124
  if (!(val.limit == void 0) && !sdIsNumber(val.limit)) {
4!
125
    throw new BoxSdkError({
×
126
      message: 'Expecting number for "limit" of type "SearchResults"',
127
    });
128
  }
129
  const limit: undefined | number = val.limit == void 0 ? void 0 : val.limit;
4!
130
  if (!(val.offset == void 0) && !sdIsNumber(val.offset)) {
4!
131
    throw new BoxSdkError({
×
132
      message: 'Expecting number for "offset" of type "SearchResults"',
133
    });
134
  }
135
  const offset: undefined | number = val.offset == void 0 ? void 0 : val.offset;
4!
136
  if (val.type == void 0) {
4!
137
    throw new BoxSdkError({
×
138
      message: 'Expecting "type" of type "SearchResults" to be defined',
139
    });
140
  }
141
  const type: SearchResultsTypeField = deserializeSearchResultsTypeField(
4✔
142
    val.type
143
  );
144
  if (!(val.entries == void 0) && !sdIsList(val.entries)) {
4!
145
    throw new BoxSdkError({
×
146
      message: 'Expecting array for "entries" of type "SearchResults"',
147
    });
148
  }
149
  const entries: undefined | readonly FileFullOrFolderFullOrWebLink[] =
150
    val.entries == void 0
4!
151
      ? void 0
152
      : sdIsList(val.entries)
4!
153
      ? (val.entries.map(function (
154
          itm: SerializedData
155
        ): FileFullOrFolderFullOrWebLink {
UNCOV
156
          return deserializeFileFullOrFolderFullOrWebLink(itm);
×
157
        }) as readonly any[])
158
      : [];
159
  return {
4✔
160
    totalCount: totalCount,
161
    limit: limit,
162
    offset: offset,
163
    type: type,
164
    entries: entries,
165
  } satisfies SearchResults;
166
}
167
export function serializeSearchResultsInput(
140✔
168
  val: SearchResultsInput
169
): SerializedData {
170
  return {
×
171
    ['total_count']: val.totalCount == void 0 ? void 0 : val.totalCount,
×
172
    ['limit']: val.limit == void 0 ? void 0 : val.limit,
×
173
    ['offset']: val.offset == void 0 ? void 0 : val.offset,
×
174
    ['type']:
175
      val.type == void 0 ? void 0 : serializeSearchResultsTypeField(val.type),
×
176
    ['entries']:
177
      val.entries == void 0
×
178
        ? void 0
179
        : (val.entries.map(function (
180
            item: FileFullOrFolderFullOrWebLink
181
          ): SerializedData {
182
            return serializeFileFullOrFolderFullOrWebLink(item);
×
183
          }) as readonly any[]),
184
  };
185
}
186
export function deserializeSearchResultsInput(
140✔
187
  val: SerializedData
188
): SearchResultsInput {
189
  if (!sdIsMap(val)) {
×
190
    throw new BoxSdkError({
×
191
      message: 'Expecting a map for "SearchResultsInput"',
192
    });
193
  }
194
  if (!(val.total_count == void 0) && !sdIsNumber(val.total_count)) {
×
195
    throw new BoxSdkError({
×
196
      message:
197
        'Expecting number for "total_count" of type "SearchResultsInput"',
198
    });
199
  }
200
  const totalCount: undefined | number =
201
    val.total_count == void 0 ? void 0 : val.total_count;
×
202
  if (!(val.limit == void 0) && !sdIsNumber(val.limit)) {
×
203
    throw new BoxSdkError({
×
204
      message: 'Expecting number for "limit" of type "SearchResultsInput"',
205
    });
206
  }
207
  const limit: undefined | number = val.limit == void 0 ? void 0 : val.limit;
×
208
  if (!(val.offset == void 0) && !sdIsNumber(val.offset)) {
×
209
    throw new BoxSdkError({
×
210
      message: 'Expecting number for "offset" of type "SearchResultsInput"',
211
    });
212
  }
213
  const offset: undefined | number = val.offset == void 0 ? void 0 : val.offset;
×
214
  const type: undefined | SearchResultsTypeField =
215
    val.type == void 0 ? void 0 : deserializeSearchResultsTypeField(val.type);
×
216
  if (!(val.entries == void 0) && !sdIsList(val.entries)) {
×
217
    throw new BoxSdkError({
×
218
      message: 'Expecting array for "entries" of type "SearchResultsInput"',
219
    });
220
  }
221
  const entries: undefined | readonly FileFullOrFolderFullOrWebLink[] =
222
    val.entries == void 0
×
223
      ? void 0
224
      : sdIsList(val.entries)
×
225
      ? (val.entries.map(function (
226
          itm: SerializedData
227
        ): FileFullOrFolderFullOrWebLink {
228
          return deserializeFileFullOrFolderFullOrWebLink(itm);
×
229
        }) as readonly any[])
230
      : [];
231
  return {
×
232
    totalCount: totalCount,
233
    limit: limit,
234
    offset: offset,
235
    type: type,
236
    entries: entries,
237
  } satisfies SearchResultsInput;
238
}
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

© 2025 Coveralls, Inc