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

box / box-typescript-sdk-gen / 12870156465

20 Jan 2025 02:28PM UTC coverage: 42.419%. First build
12870156465

push

github

web-flow
feat: Use extensible enums (box/box-codegen#639) (#487)

3990 of 15999 branches covered (24.94%)

Branch coverage included in aggregate %.

0 of 408 new or added lines in 104 files covered. (0.0%)

14249 of 26998 relevant lines covered (52.78%)

93.02 hits per line

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

13.08
/src/schemas/metadataQuery.generated.ts
1
import { BoxSdkError } from '../box/errors.js';
144✔
2
import { SerializedData } from '../serialization/json.js';
3
import { sdIsEmpty } from '../serialization/json.js';
4
import { sdIsBoolean } from '../serialization/json.js';
5
import { sdIsNumber } from '../serialization/json.js';
144✔
6
import { sdIsString } from '../serialization/json.js';
144✔
7
import { sdIsList } from '../serialization/json.js';
144✔
8
import { sdIsMap } from '../serialization/json.js';
144✔
9
export type MetadataQueryOrderByDirectionField = 'ASC' | 'DESC' | string;
10
export interface MetadataQueryOrderByField {
11
  /**
12
   * The metadata template field to order by.
13
   *
14
   * The `field_key` represents the `key` value of a field from the
15
   * metadata template being searched for. */
16
  readonly fieldKey?: string;
17
  /**
18
   * The direction to order by, either ascending or descending.
19
   *
20
   * The `ordering` direction must be the same for each item in the
21
   * array. */
22
  readonly direction?: MetadataQueryOrderByDirectionField;
23
  readonly rawData?: SerializedData;
24
}
25
export interface MetadataQuery {
26
  /**
27
   * Specifies the template used in the query. Must be in the form
28
   * `scope.templateKey`. Not all templates can be used in this field,
29
   * most notably the built-in, Box-provided classification templates
30
   * can not be used in a query. */
31
  readonly from: string;
32
  /**
33
   * The query to perform. A query is a logical expression that is very similar
34
   * to a SQL `SELECT` statement. Values in the search query can be turned into
35
   * parameters specified in the `query_param` arguments list to prevent having
36
   * to manually insert search values into the query string.
37
   *
38
   * For example, a value of `:amount` would represent the `amount` value in
39
   * `query_params` object. */
40
  readonly query?: string;
41
  /**
42
   * Set of arguments corresponding to the parameters specified in the
43
   * `query`. The type of each parameter used in the `query_params` must match
44
   * the type of the corresponding metadata template field. */
45
  readonly queryParams?: {
46
    readonly [key: string]: any;
47
  };
48
  /**
49
   * The ID of the folder that you are restricting the query to. A
50
   * value of zero will return results from all folders you have access
51
   * to. A non-zero value will only return results found in the folder
52
   * corresponding to the ID or in any of its subfolders. */
53
  readonly ancestorFolderId: string;
54
  /**
55
   * A list of template fields and directions to sort the metadata query
56
   * results by.
57
   *
58
   * The ordering `direction` must be the same for each item in the array. */
59
  readonly orderBy?: readonly MetadataQueryOrderByField[];
60
  /**
61
   * A value between 0 and 100 that indicates the maximum number of results
62
   * to return for a single request. This only specifies a maximum
63
   * boundary and will not guarantee the minimum number of results
64
   * returned. */
65
  readonly limit?: number;
66
  /**
67
   * Marker to use for requesting the next page. */
68
  readonly marker?: string;
69
  /**
70
   * By default, this endpoint returns only the most basic info about the items for
71
   * which the query matches. This attribute can be used to specify a list of
72
   * additional attributes to return for any item, including its metadata.
73
   *
74
   * This attribute takes a list of item fields, metadata template identifiers,
75
   * or metadata template field identifiers.
76
   *
77
   * For example:
78
   *
79
   * * `created_by` will add the details of the user who created the item to
80
   * the response.
81
   * * `metadata.<scope>.<templateKey>` will return the mini-representation
82
   * of the metadata instance identified by the `scope` and `templateKey`.
83
   * * `metadata.<scope>.<templateKey>.<field>` will return all the mini-representation
84
   * of the metadata instance identified by the `scope` and `templateKey` plus
85
   * the field specified by the `field` name. Multiple fields for the same
86
   * `scope` and `templateKey` can be defined. */
87
  readonly fields?: readonly string[];
88
  readonly rawData?: SerializedData;
89
}
90
export function serializeMetadataQueryOrderByDirectionField(
144✔
91
  val: MetadataQueryOrderByDirectionField,
92
): SerializedData {
93
  return val;
×
94
}
95
export function deserializeMetadataQueryOrderByDirectionField(
144✔
96
  val: SerializedData,
97
): MetadataQueryOrderByDirectionField {
98
  if (val == 'ASC') {
×
99
    return val;
×
100
  }
101
  if (val == 'DESC') {
×
102
    return val;
×
103
  }
NEW
104
  if (sdIsString(val)) {
×
NEW
105
    return val;
×
106
  }
107
  throw new BoxSdkError({
×
108
    message: "Can't deserialize MetadataQueryOrderByDirectionField",
109
  });
110
}
111
export function serializeMetadataQueryOrderByField(
144✔
112
  val: MetadataQueryOrderByField,
113
): SerializedData {
114
  return {
×
115
    ['field_key']: val.fieldKey,
116
    ['direction']:
117
      val.direction == void 0
×
118
        ? val.direction
119
        : serializeMetadataQueryOrderByDirectionField(val.direction),
120
  };
121
}
122
export function deserializeMetadataQueryOrderByField(
144✔
123
  val: SerializedData,
124
): MetadataQueryOrderByField {
125
  if (!sdIsMap(val)) {
×
126
    throw new BoxSdkError({
×
127
      message: 'Expecting a map for "MetadataQueryOrderByField"',
128
    });
129
  }
130
  if (!(val.field_key == void 0) && !sdIsString(val.field_key)) {
×
131
    throw new BoxSdkError({
×
132
      message:
133
        'Expecting string for "field_key" of type "MetadataQueryOrderByField"',
134
    });
135
  }
136
  const fieldKey: undefined | string =
137
    val.field_key == void 0 ? void 0 : val.field_key;
×
138
  const direction: undefined | MetadataQueryOrderByDirectionField =
139
    val.direction == void 0
×
140
      ? void 0
141
      : deserializeMetadataQueryOrderByDirectionField(val.direction);
142
  return {
×
143
    fieldKey: fieldKey,
144
    direction: direction,
145
  } satisfies MetadataQueryOrderByField;
146
}
147
export function serializeMetadataQuery(val: MetadataQuery): SerializedData {
144✔
148
  return {
2✔
149
    ['from']: val.from,
150
    ['query']: val.query,
151
    ['query_params']:
152
      val.queryParams == void 0
2!
153
        ? val.queryParams
154
        : (Object.fromEntries(
155
            Object.entries(val.queryParams).map(([k, v]: [string, any]) => [
10✔
156
              k,
157
              (function (v: any): any {
158
                return v;
10✔
159
              })(v),
160
            ]),
161
          ) as {
162
            readonly [key: string]: any;
163
          }),
164
    ['ancestor_folder_id']: val.ancestorFolderId,
165
    ['order_by']:
166
      val.orderBy == void 0
2!
167
        ? val.orderBy
168
        : (val.orderBy.map(function (
169
            item: MetadataQueryOrderByField,
170
          ): SerializedData {
171
            return serializeMetadataQueryOrderByField(item);
×
172
          }) as readonly any[]),
173
    ['limit']: val.limit,
174
    ['marker']: val.marker,
175
    ['fields']:
176
      val.fields == void 0
2!
177
        ? val.fields
178
        : (val.fields.map(function (item: string): SerializedData {
179
            return item;
×
180
          }) as readonly any[]),
181
  };
182
}
183
export function deserializeMetadataQuery(val: SerializedData): MetadataQuery {
144✔
184
  if (!sdIsMap(val)) {
×
185
    throw new BoxSdkError({ message: 'Expecting a map for "MetadataQuery"' });
×
186
  }
187
  if (val.from == void 0) {
×
188
    throw new BoxSdkError({
×
189
      message: 'Expecting "from" of type "MetadataQuery" to be defined',
190
    });
191
  }
192
  if (!sdIsString(val.from)) {
×
193
    throw new BoxSdkError({
×
194
      message: 'Expecting string for "from" of type "MetadataQuery"',
195
    });
196
  }
197
  const from: string = val.from;
×
198
  if (!(val.query == void 0) && !sdIsString(val.query)) {
×
199
    throw new BoxSdkError({
×
200
      message: 'Expecting string for "query" of type "MetadataQuery"',
201
    });
202
  }
203
  const query: undefined | string = val.query == void 0 ? void 0 : val.query;
×
204
  if (!(val.query_params == void 0) && !sdIsMap(val.query_params)) {
×
205
    throw new BoxSdkError({
×
206
      message: 'Expecting object for "query_params" of type "MetadataQuery"',
207
    });
208
  }
209
  const queryParams:
210
    | undefined
211
    | {
212
        readonly [key: string]: any;
213
      } =
214
    val.query_params == void 0
×
215
      ? void 0
216
      : sdIsMap(val.query_params)
×
217
        ? (Object.fromEntries(
218
            Object.entries(val.query_params).map(([k, v]: [string, any]) => [
×
219
              k,
220
              (function (v: any): any {
221
                return v;
×
222
              })(v),
223
            ]),
224
          ) as {
225
            readonly [key: string]: any;
226
          })
227
        : {};
228
  if (val.ancestor_folder_id == void 0) {
×
229
    throw new BoxSdkError({
×
230
      message:
231
        'Expecting "ancestor_folder_id" of type "MetadataQuery" to be defined',
232
    });
233
  }
234
  if (!sdIsString(val.ancestor_folder_id)) {
×
235
    throw new BoxSdkError({
×
236
      message:
237
        'Expecting string for "ancestor_folder_id" of type "MetadataQuery"',
238
    });
239
  }
240
  const ancestorFolderId: string = val.ancestor_folder_id;
×
241
  if (!(val.order_by == void 0) && !sdIsList(val.order_by)) {
×
242
    throw new BoxSdkError({
×
243
      message: 'Expecting array for "order_by" of type "MetadataQuery"',
244
    });
245
  }
246
  const orderBy: undefined | readonly MetadataQueryOrderByField[] =
247
    val.order_by == void 0
×
248
      ? void 0
249
      : sdIsList(val.order_by)
×
250
        ? (val.order_by.map(function (
251
            itm: SerializedData,
252
          ): MetadataQueryOrderByField {
253
            return deserializeMetadataQueryOrderByField(itm);
×
254
          }) as readonly any[])
255
        : [];
256
  if (!(val.limit == void 0) && !sdIsNumber(val.limit)) {
×
257
    throw new BoxSdkError({
×
258
      message: 'Expecting number for "limit" of type "MetadataQuery"',
259
    });
260
  }
261
  const limit: undefined | number = val.limit == void 0 ? void 0 : val.limit;
×
262
  if (!(val.marker == void 0) && !sdIsString(val.marker)) {
×
263
    throw new BoxSdkError({
×
264
      message: 'Expecting string for "marker" of type "MetadataQuery"',
265
    });
266
  }
267
  const marker: undefined | string = val.marker == void 0 ? void 0 : val.marker;
×
268
  if (!(val.fields == void 0) && !sdIsList(val.fields)) {
×
269
    throw new BoxSdkError({
×
270
      message: 'Expecting array for "fields" of type "MetadataQuery"',
271
    });
272
  }
273
  const fields: undefined | readonly string[] =
274
    val.fields == void 0
×
275
      ? void 0
276
      : sdIsList(val.fields)
×
277
        ? (val.fields.map(function (itm: SerializedData): string {
278
            if (!sdIsString(itm)) {
×
279
              throw new BoxSdkError({
×
280
                message: 'Expecting string for "MetadataQuery"',
281
              });
282
            }
283
            return itm;
×
284
          }) as readonly any[])
285
        : [];
286
  return {
×
287
    from: from,
288
    query: query,
289
    queryParams: queryParams,
290
    ancestorFolderId: ancestorFolderId,
291
    orderBy: orderBy,
292
    limit: limit,
293
    marker: marker,
294
    fields: fields,
295
  } satisfies MetadataQuery;
296
}
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