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

box / box-typescript-sdk-gen / 8389777353

22 Mar 2024 11:45AM UTC coverage: 43.751% (+1.7%) from 42.003%
8389777353

Pull #106

github

web-flow
Merge 402656ec3 into 14e115481
Pull Request #106: chore: Update .codegen.json with commit hash of codegen and openapi spec

2296 of 9105 branches covered (25.22%)

Branch coverage included in aggregate %.

388 of 545 new or added lines in 17 files covered. (71.19%)

190 existing lines in 6 files now uncovered.

7257 of 12730 relevant lines covered (57.01%)

68.34 hits per line

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

47.24
/src/managers/workflows.generated.ts
1
import { serializeWorkflows } from '../schemas.generated.js';
2
import { deserializeWorkflows } from '../schemas.generated.js';
136✔
3
import { serializeClientError } from '../schemas.generated.js';
4
import { deserializeClientError } from '../schemas.generated.js';
5
import { serializeOutcome } from '../schemas.generated.js';
136✔
6
import { deserializeOutcome } from '../schemas.generated.js';
136✔
7
import { Workflows } from '../schemas.generated.js';
8
import { ClientError } from '../schemas.generated.js';
9
import { Outcome } from '../schemas.generated.js';
10
import { Authentication } from '../networking/auth.generated.js';
11
import { NetworkSession } from '../networking/network.generated.js';
136✔
12
import { prepareParams } from '../internal/utils.js';
136✔
13
import { toString } from '../internal/utils.js';
136✔
14
import { ByteStream } from '../internal/utils.js';
15
import { CancellationToken } from '../internal/utils.js';
16
import { sdToJson } from '../serialization/json.js';
17
import { FetchOptions } from '../networking/fetch.js';
18
import { FetchResponse } from '../networking/fetch.js';
19
import { fetch } from '../networking/fetch.js';
136✔
20
import { SerializedData } from '../serialization/json.js';
21
import { BoxSdkError } from '../box/errors.js';
136✔
22
import { sdIsEmpty } from '../serialization/json.js';
23
import { sdIsBoolean } from '../serialization/json.js';
24
import { sdIsNumber } from '../serialization/json.js';
25
import { sdIsString } from '../serialization/json.js';
136✔
26
import { sdIsList } from '../serialization/json.js';
136✔
27
import { sdIsMap } from '../serialization/json.js';
28
export interface GetWorkflowsQueryParams {
29
  readonly folderId: string;
30
  readonly triggerType?: string;
31
  readonly limit?: number;
32
  readonly marker?: string;
33
}
34
export class GetWorkflowsHeaders {
136✔
35
  readonly extraHeaders?: {
2✔
36
    readonly [key: string]: undefined | string;
37
  } = {};
38
  constructor(
39
    fields:
40
      | Omit<GetWorkflowsHeaders, 'extraHeaders'>
41
      | Partial<Pick<GetWorkflowsHeaders, 'extraHeaders'>>
42
  ) {
43
    Object.assign(this, fields);
2✔
44
  }
45
}
46
export type StartWorkflowRequestBodyTypeField = 'workflow_parameters';
47
export interface StartWorkflowRequestBodyFlowField {
48
  readonly type?: string;
49
  readonly id?: string;
50
}
51
export type StartWorkflowRequestBodyFilesTypeField = 'file';
52
export interface StartWorkflowRequestBodyFilesField {
53
  readonly type?: StartWorkflowRequestBodyFilesTypeField;
54
  readonly id?: string;
55
}
56
export type StartWorkflowRequestBodyFolderTypeField = 'folder';
57
export interface StartWorkflowRequestBodyFolderField {
58
  readonly type?: StartWorkflowRequestBodyFolderTypeField;
59
  readonly id?: string;
60
}
61
export interface StartWorkflowRequestBody {
62
  readonly type?: StartWorkflowRequestBodyTypeField;
63
  readonly flow: StartWorkflowRequestBodyFlowField;
64
  readonly files: readonly StartWorkflowRequestBodyFilesField[];
65
  readonly folder: StartWorkflowRequestBodyFolderField;
66
  readonly outcomes?: readonly Outcome[];
67
}
68
export class StartWorkflowHeaders {
136✔
69
  readonly extraHeaders?: {
2✔
70
    readonly [key: string]: undefined | string;
71
  } = {};
72
  constructor(
73
    fields:
74
      | Omit<StartWorkflowHeaders, 'extraHeaders'>
75
      | Partial<Pick<StartWorkflowHeaders, 'extraHeaders'>>
76
  ) {
77
    Object.assign(this, fields);
2✔
78
  }
79
}
80
export class WorkflowsManager {
136✔
81
  readonly auth?: Authentication;
82
  readonly networkSession: NetworkSession = new NetworkSession({});
262✔
83
  constructor(
84
    fields:
85
      | Omit<
86
          WorkflowsManager,
87
          'networkSession' | 'getWorkflows' | 'startWorkflow'
88
        >
89
      | Partial<Pick<WorkflowsManager, 'networkSession'>>
90
  ) {
91
    Object.assign(this, fields);
262✔
92
  }
93
  async getWorkflows(
94
    queryParams: GetWorkflowsQueryParams,
2✔
95
    headers: GetWorkflowsHeaders = new GetWorkflowsHeaders({}),
2✔
96
    cancellationToken?: CancellationToken
97
  ): Promise<Workflows> {
98
    const queryParamsMap: {
99
      readonly [key: string]: string;
100
    } = prepareParams({
2✔
101
      ['folder_id']: toString(queryParams.folderId) as string,
102
      ['trigger_type']: toString(queryParams.triggerType) as string,
103
      ['limit']: toString(queryParams.limit) as string,
104
      ['marker']: toString(queryParams.marker) as string,
105
    });
106
    const headersMap: {
107
      readonly [key: string]: string;
108
    } = prepareParams({ ...{}, ...headers.extraHeaders });
2✔
109
    const response: FetchResponse = (await fetch(
2✔
110
      ''.concat(this.networkSession.baseUrls.baseUrl, '/workflows') as string,
111
      {
112
        method: 'GET',
113
        params: queryParamsMap,
114
        headers: headersMap,
115
        responseFormat: 'json',
116
        auth: this.auth,
117
        networkSession: this.networkSession,
118
        cancellationToken: cancellationToken,
119
      } satisfies FetchOptions
120
    )) as FetchResponse;
121
    return deserializeWorkflows(response.data);
2✔
122
  }
123
  async startWorkflow(
124
    workflowId: string,
2✔
125
    requestBody: StartWorkflowRequestBody,
126
    headers: StartWorkflowHeaders = new StartWorkflowHeaders({}),
2✔
127
    cancellationToken?: CancellationToken
128
  ): Promise<undefined> {
129
    const headersMap: {
130
      readonly [key: string]: string;
131
    } = prepareParams({ ...{}, ...headers.extraHeaders });
2✔
132
    const response: FetchResponse = (await fetch(
2✔
133
      ''.concat(
134
        this.networkSession.baseUrls.baseUrl,
135
        '/workflows/',
136
        toString(workflowId) as string,
137
        '/start'
138
      ) as string,
139
      {
140
        method: 'POST',
141
        headers: headersMap,
142
        data: serializeStartWorkflowRequestBody(requestBody),
143
        contentType: 'application/json',
144
        responseFormat: void 0,
145
        auth: this.auth,
146
        networkSession: this.networkSession,
147
        cancellationToken: cancellationToken,
148
      } satisfies FetchOptions
149
    )) as FetchResponse;
150
    return void 0;
2✔
151
  }
152
}
153
export function serializeStartWorkflowRequestBodyTypeField(
136✔
154
  val: any
155
): SerializedData {
156
  return val;
2✔
157
}
158
export function deserializeStartWorkflowRequestBodyTypeField(
136✔
159
  val: any
160
): StartWorkflowRequestBodyTypeField {
161
  if (!sdIsString(val)) {
×
162
    throw new BoxSdkError({
×
163
      message: 'Expecting a string for "StartWorkflowRequestBodyTypeField"',
164
    });
165
  }
166
  if (val == 'workflow_parameters') {
×
167
    return 'workflow_parameters';
×
168
  }
169
  throw new BoxSdkError({
×
170
    message: ''.concat('Invalid value: ', val) as string,
171
  });
172
}
173
export function serializeStartWorkflowRequestBodyFlowField(
136✔
174
  val: any
175
): SerializedData {
176
  return {
2✔
177
    ['type']: val.type == void 0 ? void 0 : val.type,
2!
178
    ['id']: val.id == void 0 ? void 0 : val.id,
2!
179
  };
180
}
181
export function deserializeStartWorkflowRequestBodyFlowField(
136✔
182
  val: any
183
): StartWorkflowRequestBodyFlowField {
184
  const type: undefined | string = val.type == void 0 ? void 0 : val.type;
×
185
  const id: undefined | string = val.id == void 0 ? void 0 : val.id;
×
186
  return { type: type, id: id } satisfies StartWorkflowRequestBodyFlowField;
×
187
}
188
export function serializeStartWorkflowRequestBodyFilesTypeField(
136✔
189
  val: any
190
): SerializedData {
191
  return val;
2✔
192
}
193
export function deserializeStartWorkflowRequestBodyFilesTypeField(
136✔
194
  val: any
195
): StartWorkflowRequestBodyFilesTypeField {
196
  if (!sdIsString(val)) {
×
197
    throw new BoxSdkError({
×
198
      message:
199
        'Expecting a string for "StartWorkflowRequestBodyFilesTypeField"',
200
    });
201
  }
202
  if (val == 'file') {
×
203
    return 'file';
×
204
  }
205
  throw new BoxSdkError({
×
206
    message: ''.concat('Invalid value: ', val) as string,
207
  });
208
}
209
export function serializeStartWorkflowRequestBodyFilesField(
136✔
210
  val: any
211
): SerializedData {
212
  return {
2✔
213
    ['type']:
214
      val.type == void 0
2!
215
        ? void 0
216
        : serializeStartWorkflowRequestBodyFilesTypeField(val.type),
217
    ['id']: val.id == void 0 ? void 0 : val.id,
2!
218
  };
219
}
220
export function deserializeStartWorkflowRequestBodyFilesField(
136✔
221
  val: any
222
): StartWorkflowRequestBodyFilesField {
223
  const type: undefined | StartWorkflowRequestBodyFilesTypeField =
224
    val.type == void 0
×
225
      ? void 0
226
      : deserializeStartWorkflowRequestBodyFilesTypeField(val.type);
227
  const id: undefined | string = val.id == void 0 ? void 0 : val.id;
×
228
  return { type: type, id: id } satisfies StartWorkflowRequestBodyFilesField;
×
229
}
230
export function serializeStartWorkflowRequestBodyFolderTypeField(
136✔
231
  val: any
232
): SerializedData {
233
  return val;
2✔
234
}
235
export function deserializeStartWorkflowRequestBodyFolderTypeField(
136✔
236
  val: any
237
): StartWorkflowRequestBodyFolderTypeField {
238
  if (!sdIsString(val)) {
×
239
    throw new BoxSdkError({
×
240
      message:
241
        'Expecting a string for "StartWorkflowRequestBodyFolderTypeField"',
242
    });
243
  }
244
  if (val == 'folder') {
×
245
    return 'folder';
×
246
  }
247
  throw new BoxSdkError({
×
248
    message: ''.concat('Invalid value: ', val) as string,
249
  });
250
}
251
export function serializeStartWorkflowRequestBodyFolderField(
136✔
252
  val: any
253
): SerializedData {
254
  return {
2✔
255
    ['type']:
256
      val.type == void 0
2!
257
        ? void 0
258
        : serializeStartWorkflowRequestBodyFolderTypeField(val.type),
259
    ['id']: val.id == void 0 ? void 0 : val.id,
2!
260
  };
261
}
262
export function deserializeStartWorkflowRequestBodyFolderField(
136✔
263
  val: any
264
): StartWorkflowRequestBodyFolderField {
265
  const type: undefined | StartWorkflowRequestBodyFolderTypeField =
266
    val.type == void 0
×
267
      ? void 0
268
      : deserializeStartWorkflowRequestBodyFolderTypeField(val.type);
269
  const id: undefined | string = val.id == void 0 ? void 0 : val.id;
×
270
  return { type: type, id: id } satisfies StartWorkflowRequestBodyFolderField;
×
271
}
272
export function serializeStartWorkflowRequestBody(val: any): SerializedData {
136✔
273
  return {
2✔
274
    ['type']:
275
      val.type == void 0
2!
276
        ? void 0
277
        : serializeStartWorkflowRequestBodyTypeField(val.type),
278
    ['flow']: serializeStartWorkflowRequestBodyFlowField(val.flow),
279
    ['files']: val.files.map(function (
280
      item: StartWorkflowRequestBodyFilesField
281
    ): any {
282
      return serializeStartWorkflowRequestBodyFilesField(item);
2✔
283
    }) as readonly any[],
284
    ['folder']: serializeStartWorkflowRequestBodyFolderField(val.folder),
285
    ['outcomes']:
286
      val.outcomes == void 0
2!
287
        ? void 0
288
        : (val.outcomes.map(function (item: Outcome): any {
NEW
289
            return serializeOutcome(item);
×
290
          }) as readonly any[]),
291
  };
292
}
293
export function deserializeStartWorkflowRequestBody(
136✔
294
  val: any
295
): StartWorkflowRequestBody {
296
  const type: undefined | StartWorkflowRequestBodyTypeField =
297
    val.type == void 0
×
298
      ? void 0
299
      : deserializeStartWorkflowRequestBodyTypeField(val.type);
300
  const flow: StartWorkflowRequestBodyFlowField =
301
    deserializeStartWorkflowRequestBodyFlowField(val.flow);
×
302
  const files: readonly StartWorkflowRequestBodyFilesField[] = sdIsList(
×
303
    val.files
304
  )
305
    ? (val.files.map(function (itm: SerializedData): any {
306
        return deserializeStartWorkflowRequestBodyFilesField(itm);
×
307
      }) as readonly any[])
308
    : [];
309
  const folder: StartWorkflowRequestBodyFolderField =
310
    deserializeStartWorkflowRequestBodyFolderField(val.folder);
×
311
  const outcomes: undefined | readonly Outcome[] =
312
    val.outcomes == void 0
×
313
      ? void 0
314
      : sdIsList(val.outcomes)
×
315
      ? (val.outcomes.map(function (itm: SerializedData): any {
NEW
316
          return deserializeOutcome(itm);
×
317
        }) as readonly any[])
318
      : [];
319
  return {
×
320
    type: type,
321
    flow: flow,
322
    files: files,
323
    folder: folder,
324
    outcomes: outcomes,
325
  } satisfies StartWorkflowRequestBody;
326
}
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