@api-client/core 0.18.39 → 0.18.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/RELEASE_SETUP.md +4 -2
- package/build/src/sdk/SdkMock.d.ts +49 -45
- package/build/src/sdk/SdkMock.d.ts.map +1 -1
- package/build/src/sdk/SdkMock.js +94 -90
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +6 -6
- package/package.json +3 -2
- package/src/sdk/SdkMock.ts +428 -295
- package/TESTING_READY.md +0 -114
package/src/sdk/SdkMock.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ResponseGenerator,
|
|
3
|
+
setupWorker,
|
|
4
|
+
type MockHandler,
|
|
5
|
+
type SetupWorkerOptions,
|
|
6
|
+
type InterceptOptions,
|
|
7
|
+
} from '@jarrodek/amw'
|
|
2
8
|
import type { IOrganization } from '../models/store/Organization.js'
|
|
3
9
|
import type { GroupSchema } from '../models/store/Group.js'
|
|
4
10
|
import type { IUser } from '../models/store/User.js'
|
|
@@ -90,6 +96,10 @@ export interface MockListResult extends MockResult {
|
|
|
90
96
|
* // Stop and remove the Service Worker
|
|
91
97
|
* await mocker.teardown();
|
|
92
98
|
* ```
|
|
99
|
+
*
|
|
100
|
+
* @TODO: Add a in-memory state store so that mocks can maintain state across requests.
|
|
101
|
+
* This way, operations like create, update, delete can affect subsequent list/read calls
|
|
102
|
+
* and we can mimic the API behavior more closely.
|
|
93
103
|
*/
|
|
94
104
|
export class SdkMock {
|
|
95
105
|
handler?: MockHandler
|
|
@@ -177,7 +187,7 @@ export class SdkMock {
|
|
|
177
187
|
* Adds an intercept to mock the `organizations.list()` method.
|
|
178
188
|
* @param options Optional response configuration
|
|
179
189
|
*/
|
|
180
|
-
list: async (init?: MockListResult): Promise<void> => {
|
|
190
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
181
191
|
const { mock } = this
|
|
182
192
|
// const respond = init?.response ?? {
|
|
183
193
|
// status: 200,
|
|
@@ -197,20 +207,23 @@ export class SdkMock {
|
|
|
197
207
|
} as ContextListResult<IOrganization>),
|
|
198
208
|
init
|
|
199
209
|
)
|
|
200
|
-
await mock.add(
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
210
|
+
await mock.add(
|
|
211
|
+
{
|
|
212
|
+
match: {
|
|
213
|
+
uri: RouteBuilder.organizations(),
|
|
214
|
+
methods: ['GET'],
|
|
215
|
+
},
|
|
216
|
+
respond,
|
|
204
217
|
},
|
|
205
|
-
|
|
206
|
-
|
|
218
|
+
options
|
|
219
|
+
)
|
|
207
220
|
},
|
|
208
221
|
|
|
209
222
|
/**
|
|
210
223
|
* Adds an intercept to mock the `organizations.create()` method.
|
|
211
224
|
* @param options Optional response configuration
|
|
212
225
|
*/
|
|
213
|
-
create: async (init?: MockResult): Promise<void> => {
|
|
226
|
+
create: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
214
227
|
const { mock } = this
|
|
215
228
|
// const respond = init?.response ?? {
|
|
216
229
|
// status: 200,
|
|
@@ -223,17 +236,20 @@ export class SdkMock {
|
|
|
223
236
|
() => JSON.stringify(this.gen.organization.organization()),
|
|
224
237
|
init
|
|
225
238
|
)
|
|
226
|
-
await mock.add(
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
239
|
+
await mock.add(
|
|
240
|
+
{
|
|
241
|
+
match: {
|
|
242
|
+
uri: RouteBuilder.organizations(),
|
|
243
|
+
methods: ['POST'],
|
|
244
|
+
},
|
|
245
|
+
respond,
|
|
230
246
|
},
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
options
|
|
248
|
+
)
|
|
233
249
|
},
|
|
234
250
|
|
|
235
251
|
invitations: {
|
|
236
|
-
list: async (init?: MockListResult): Promise<void> => {
|
|
252
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
237
253
|
const { mock } = this
|
|
238
254
|
// const respond = init?.response ?? {
|
|
239
255
|
// status: 200,
|
|
@@ -255,15 +271,18 @@ export class SdkMock {
|
|
|
255
271
|
},
|
|
256
272
|
init
|
|
257
273
|
)
|
|
258
|
-
await mock.add(
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
274
|
+
await mock.add(
|
|
275
|
+
{
|
|
276
|
+
match: {
|
|
277
|
+
uri: RouteBuilder.invitations(':oid'),
|
|
278
|
+
methods: ['GET'],
|
|
279
|
+
},
|
|
280
|
+
respond,
|
|
262
281
|
},
|
|
263
|
-
|
|
264
|
-
|
|
282
|
+
options
|
|
283
|
+
)
|
|
265
284
|
},
|
|
266
|
-
create: async (init?: MockResult): Promise<void> => {
|
|
285
|
+
create: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
267
286
|
const { mock } = this
|
|
268
287
|
// const respond = init?.response ?? {
|
|
269
288
|
// status: 200,
|
|
@@ -276,15 +295,18 @@ export class SdkMock {
|
|
|
276
295
|
() => JSON.stringify(this.gen.invitation.invitation()),
|
|
277
296
|
init
|
|
278
297
|
)
|
|
279
|
-
await mock.add(
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
298
|
+
await mock.add(
|
|
299
|
+
{
|
|
300
|
+
match: {
|
|
301
|
+
uri: RouteBuilder.invitations(':oid'),
|
|
302
|
+
methods: ['POST'],
|
|
303
|
+
},
|
|
304
|
+
respond,
|
|
283
305
|
},
|
|
284
|
-
|
|
285
|
-
|
|
306
|
+
options
|
|
307
|
+
)
|
|
286
308
|
},
|
|
287
|
-
findByToken: async (init?: MockResult): Promise<void> => {
|
|
309
|
+
findByToken: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
288
310
|
const { mock } = this
|
|
289
311
|
// const respond = init?.response ?? {
|
|
290
312
|
// status: 200,
|
|
@@ -298,15 +320,18 @@ export class SdkMock {
|
|
|
298
320
|
init
|
|
299
321
|
)
|
|
300
322
|
|
|
301
|
-
await mock.add(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
323
|
+
await mock.add(
|
|
324
|
+
{
|
|
325
|
+
match: {
|
|
326
|
+
uri: RouteBuilder.findInvitation(),
|
|
327
|
+
methods: ['GET'],
|
|
328
|
+
},
|
|
329
|
+
respond,
|
|
305
330
|
},
|
|
306
|
-
|
|
307
|
-
|
|
331
|
+
options
|
|
332
|
+
)
|
|
308
333
|
},
|
|
309
|
-
decline: async (init?: MockResult): Promise<void> => {
|
|
334
|
+
decline: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
310
335
|
const { mock } = this
|
|
311
336
|
// const respond = init?.response ?? {
|
|
312
337
|
// status: 200,
|
|
@@ -320,15 +345,18 @@ export class SdkMock {
|
|
|
320
345
|
init
|
|
321
346
|
)
|
|
322
347
|
|
|
323
|
-
await mock.add(
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
348
|
+
await mock.add(
|
|
349
|
+
{
|
|
350
|
+
match: {
|
|
351
|
+
uri: RouteBuilder.declineInvitation(':oid', ':id'),
|
|
352
|
+
methods: ['POST'],
|
|
353
|
+
},
|
|
354
|
+
respond,
|
|
327
355
|
},
|
|
328
|
-
|
|
329
|
-
|
|
356
|
+
options
|
|
357
|
+
)
|
|
330
358
|
},
|
|
331
|
-
delete: async (init?: MockResult): Promise<void> => {
|
|
359
|
+
delete: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
332
360
|
const { mock } = this
|
|
333
361
|
// const respond = init?.response ?? {
|
|
334
362
|
// status: 200,
|
|
@@ -342,15 +370,18 @@ export class SdkMock {
|
|
|
342
370
|
init
|
|
343
371
|
)
|
|
344
372
|
|
|
345
|
-
await mock.add(
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
373
|
+
await mock.add(
|
|
374
|
+
{
|
|
375
|
+
match: {
|
|
376
|
+
uri: RouteBuilder.invitation(':oid', ':id'),
|
|
377
|
+
methods: ['DELETE'],
|
|
378
|
+
},
|
|
379
|
+
respond,
|
|
349
380
|
},
|
|
350
|
-
|
|
351
|
-
|
|
381
|
+
options
|
|
382
|
+
)
|
|
352
383
|
},
|
|
353
|
-
patch: async (init?: MockResult): Promise<void> => {
|
|
384
|
+
patch: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
354
385
|
const { mock } = this
|
|
355
386
|
// const respond = init?.response ?? {
|
|
356
387
|
// status: 200,
|
|
@@ -363,15 +394,18 @@ export class SdkMock {
|
|
|
363
394
|
() => JSON.stringify(this.gen.invitation.invitation()),
|
|
364
395
|
init
|
|
365
396
|
)
|
|
366
|
-
await mock.add(
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
397
|
+
await mock.add(
|
|
398
|
+
{
|
|
399
|
+
match: {
|
|
400
|
+
uri: RouteBuilder.invitation(':oid', ':id'),
|
|
401
|
+
methods: ['PATCH'],
|
|
402
|
+
},
|
|
403
|
+
respond,
|
|
370
404
|
},
|
|
371
|
-
|
|
372
|
-
|
|
405
|
+
options
|
|
406
|
+
)
|
|
373
407
|
},
|
|
374
|
-
resend: async (init?: MockResult): Promise<void> => {
|
|
408
|
+
resend: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
375
409
|
const { mock } = this
|
|
376
410
|
// const respond = init?.response ?? {
|
|
377
411
|
// status: 200,
|
|
@@ -385,18 +419,21 @@ export class SdkMock {
|
|
|
385
419
|
init
|
|
386
420
|
)
|
|
387
421
|
|
|
388
|
-
await mock.add(
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
422
|
+
await mock.add(
|
|
423
|
+
{
|
|
424
|
+
match: {
|
|
425
|
+
uri: RouteBuilder.resendInvitation(':oid', ':id'),
|
|
426
|
+
methods: ['PUT'],
|
|
427
|
+
},
|
|
428
|
+
respond,
|
|
392
429
|
},
|
|
393
|
-
|
|
394
|
-
|
|
430
|
+
options
|
|
431
|
+
)
|
|
395
432
|
},
|
|
396
433
|
},
|
|
397
434
|
|
|
398
435
|
users: {
|
|
399
|
-
list: async (init?: MockListResult): Promise<void> => {
|
|
436
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
400
437
|
const { mock } = this
|
|
401
438
|
// const respond = init?.response ?? {
|
|
402
439
|
// status: 200,
|
|
@@ -418,15 +455,18 @@ export class SdkMock {
|
|
|
418
455
|
},
|
|
419
456
|
init
|
|
420
457
|
)
|
|
421
|
-
await mock.add(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
458
|
+
await mock.add(
|
|
459
|
+
{
|
|
460
|
+
match: {
|
|
461
|
+
uri: RouteBuilder.organizationUsers(':oid'),
|
|
462
|
+
methods: ['GET'],
|
|
463
|
+
},
|
|
464
|
+
respond,
|
|
425
465
|
},
|
|
426
|
-
|
|
427
|
-
|
|
466
|
+
options
|
|
467
|
+
)
|
|
428
468
|
},
|
|
429
|
-
read: async (init?: MockResult): Promise<void> => {
|
|
469
|
+
read: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
430
470
|
const { mock } = this
|
|
431
471
|
// const respond = init?.response ?? {
|
|
432
472
|
// status: 200,
|
|
@@ -439,15 +479,18 @@ export class SdkMock {
|
|
|
439
479
|
() => JSON.stringify(this.gen.user.user()),
|
|
440
480
|
init
|
|
441
481
|
)
|
|
442
|
-
await mock.add(
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
482
|
+
await mock.add(
|
|
483
|
+
{
|
|
484
|
+
match: {
|
|
485
|
+
uri: RouteBuilder.organizationUser(':oid', ':id'),
|
|
486
|
+
methods: ['GET'],
|
|
487
|
+
},
|
|
488
|
+
respond,
|
|
446
489
|
},
|
|
447
|
-
|
|
448
|
-
|
|
490
|
+
options
|
|
491
|
+
)
|
|
449
492
|
},
|
|
450
|
-
readBatch: async (init?: MockListResult): Promise<void> => {
|
|
493
|
+
readBatch: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
451
494
|
const { mock } = this
|
|
452
495
|
const path = RouteBuilder.organizationUserBatch(':oid')
|
|
453
496
|
const respond = init?.response ?? {
|
|
@@ -458,15 +501,18 @@ export class SdkMock {
|
|
|
458
501
|
cursor: this.createCursorOption(init),
|
|
459
502
|
} as ContextListResult<IUser>),
|
|
460
503
|
}
|
|
461
|
-
await mock.add(
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
504
|
+
await mock.add(
|
|
505
|
+
{
|
|
506
|
+
match: {
|
|
507
|
+
uri: path,
|
|
508
|
+
methods: ['POST'],
|
|
509
|
+
},
|
|
510
|
+
respond,
|
|
465
511
|
},
|
|
466
|
-
|
|
467
|
-
|
|
512
|
+
options
|
|
513
|
+
)
|
|
468
514
|
},
|
|
469
|
-
activate: async (init?: MockResult): Promise<void> => {
|
|
515
|
+
activate: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
470
516
|
const { mock } = this
|
|
471
517
|
// const respond = init?.response ?? {
|
|
472
518
|
// status: 200,
|
|
@@ -479,15 +525,18 @@ export class SdkMock {
|
|
|
479
525
|
() => JSON.stringify(this.gen.user.user()),
|
|
480
526
|
init
|
|
481
527
|
)
|
|
482
|
-
await mock.add(
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
528
|
+
await mock.add(
|
|
529
|
+
{
|
|
530
|
+
match: {
|
|
531
|
+
uri: RouteBuilder.organizationUserActivate(':oid', ':id'),
|
|
532
|
+
methods: ['POST'],
|
|
533
|
+
},
|
|
534
|
+
respond,
|
|
486
535
|
},
|
|
487
|
-
|
|
488
|
-
|
|
536
|
+
options
|
|
537
|
+
)
|
|
489
538
|
},
|
|
490
|
-
deactivate: async (init?: MockResult): Promise<void> => {
|
|
539
|
+
deactivate: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
491
540
|
const { mock } = this
|
|
492
541
|
// const respond = init?.response ?? {
|
|
493
542
|
// status: 200,
|
|
@@ -500,27 +549,33 @@ export class SdkMock {
|
|
|
500
549
|
() => JSON.stringify(this.gen.user.user()),
|
|
501
550
|
init
|
|
502
551
|
)
|
|
503
|
-
await mock.add(
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
552
|
+
await mock.add(
|
|
553
|
+
{
|
|
554
|
+
match: {
|
|
555
|
+
uri: RouteBuilder.organizationUserDeactivate(':oid', ':id'),
|
|
556
|
+
methods: ['POST'],
|
|
557
|
+
},
|
|
558
|
+
respond,
|
|
507
559
|
},
|
|
508
|
-
|
|
509
|
-
|
|
560
|
+
options
|
|
561
|
+
)
|
|
510
562
|
},
|
|
511
|
-
delete: async (init?: MockResult): Promise<void> => {
|
|
563
|
+
delete: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
512
564
|
const { mock } = this
|
|
513
565
|
// const respond = init?.response ?? {
|
|
514
566
|
// status: 204,
|
|
515
567
|
// }
|
|
516
568
|
const respond = this.createDefaultResponse(204, undefined, undefined, init)
|
|
517
|
-
await mock.add(
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
569
|
+
await mock.add(
|
|
570
|
+
{
|
|
571
|
+
match: {
|
|
572
|
+
uri: RouteBuilder.organizationUser(':oid', ':id'),
|
|
573
|
+
methods: ['DELETE'],
|
|
574
|
+
},
|
|
575
|
+
respond,
|
|
521
576
|
},
|
|
522
|
-
|
|
523
|
-
|
|
577
|
+
options
|
|
578
|
+
)
|
|
524
579
|
},
|
|
525
580
|
},
|
|
526
581
|
}
|
|
@@ -533,7 +588,7 @@ export class SdkMock {
|
|
|
533
588
|
* Mocks the `groups.list()` method.
|
|
534
589
|
* @param options Optional response customization.
|
|
535
590
|
*/
|
|
536
|
-
list: async (init?: MockListResult): Promise<void> => {
|
|
591
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
537
592
|
const { mock } = this
|
|
538
593
|
// const respond = init?.response ?? {
|
|
539
594
|
// status: 200,
|
|
@@ -555,20 +610,23 @@ export class SdkMock {
|
|
|
555
610
|
},
|
|
556
611
|
init
|
|
557
612
|
)
|
|
558
|
-
await mock.add(
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
613
|
+
await mock.add(
|
|
614
|
+
{
|
|
615
|
+
match: {
|
|
616
|
+
uri: RouteBuilder.groups(':oid'),
|
|
617
|
+
methods: ['GET'],
|
|
618
|
+
},
|
|
619
|
+
respond,
|
|
562
620
|
},
|
|
563
|
-
|
|
564
|
-
|
|
621
|
+
options
|
|
622
|
+
)
|
|
565
623
|
},
|
|
566
624
|
|
|
567
625
|
/**
|
|
568
626
|
* Mocks the `groups.create()` method.
|
|
569
627
|
* @param options Optional response customization.
|
|
570
628
|
*/
|
|
571
|
-
create: async (init?: MockResult): Promise<void> => {
|
|
629
|
+
create: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
572
630
|
const { mock } = this
|
|
573
631
|
// const respond = init?.response ?? {
|
|
574
632
|
// status: 201,
|
|
@@ -581,20 +639,23 @@ export class SdkMock {
|
|
|
581
639
|
() => JSON.stringify(this.gen.group.group()),
|
|
582
640
|
init
|
|
583
641
|
)
|
|
584
|
-
await mock.add(
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
642
|
+
await mock.add(
|
|
643
|
+
{
|
|
644
|
+
match: {
|
|
645
|
+
uri: RouteBuilder.groups(':oid'),
|
|
646
|
+
methods: ['POST'],
|
|
647
|
+
},
|
|
648
|
+
respond,
|
|
588
649
|
},
|
|
589
|
-
|
|
590
|
-
|
|
650
|
+
options
|
|
651
|
+
)
|
|
591
652
|
},
|
|
592
653
|
|
|
593
654
|
/**
|
|
594
655
|
* Mocks the `groups.update()` method.
|
|
595
656
|
* @param options Optional response customization.
|
|
596
657
|
*/
|
|
597
|
-
update: async (init?: MockResult): Promise<void> => {
|
|
658
|
+
update: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
598
659
|
const { mock } = this
|
|
599
660
|
// const respond = init?.response ?? {
|
|
600
661
|
// status: 200,
|
|
@@ -607,38 +668,44 @@ export class SdkMock {
|
|
|
607
668
|
() => JSON.stringify(this.gen.group.group()),
|
|
608
669
|
init
|
|
609
670
|
)
|
|
610
|
-
await mock.add(
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
671
|
+
await mock.add(
|
|
672
|
+
{
|
|
673
|
+
match: {
|
|
674
|
+
uri: RouteBuilder.group(':oid', ':key'),
|
|
675
|
+
methods: ['PATCH'],
|
|
676
|
+
},
|
|
677
|
+
respond,
|
|
614
678
|
},
|
|
615
|
-
|
|
616
|
-
|
|
679
|
+
options
|
|
680
|
+
)
|
|
617
681
|
},
|
|
618
682
|
|
|
619
683
|
/**
|
|
620
684
|
* Mocks the `groups.delete()` method.
|
|
621
685
|
* @param options Optional response customization.
|
|
622
686
|
*/
|
|
623
|
-
delete: async (init?: MockResult): Promise<void> => {
|
|
687
|
+
delete: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
624
688
|
const { mock } = this
|
|
625
689
|
// const respond = init?.response ?? {
|
|
626
690
|
// status: 204,
|
|
627
691
|
// }
|
|
628
692
|
const respond = this.createDefaultResponse(204, undefined, undefined, init)
|
|
629
|
-
await mock.add(
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
693
|
+
await mock.add(
|
|
694
|
+
{
|
|
695
|
+
match: {
|
|
696
|
+
uri: RouteBuilder.group(':oid', ':key'),
|
|
697
|
+
methods: ['DELETE'],
|
|
698
|
+
},
|
|
699
|
+
respond,
|
|
633
700
|
},
|
|
634
|
-
|
|
635
|
-
|
|
701
|
+
options
|
|
702
|
+
)
|
|
636
703
|
},
|
|
637
704
|
|
|
638
705
|
/**
|
|
639
706
|
* Mocks the `groups.addUsers()` method.
|
|
640
707
|
*/
|
|
641
|
-
addUsers: async (init?: MockResult): Promise<void> => {
|
|
708
|
+
addUsers: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
642
709
|
const { mock } = this
|
|
643
710
|
// const respond = init?.response ?? {
|
|
644
711
|
// status: 200,
|
|
@@ -651,19 +718,22 @@ export class SdkMock {
|
|
|
651
718
|
() => JSON.stringify(this.gen.group.group()),
|
|
652
719
|
init
|
|
653
720
|
)
|
|
654
|
-
await mock.add(
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
721
|
+
await mock.add(
|
|
722
|
+
{
|
|
723
|
+
match: {
|
|
724
|
+
uri: RouteBuilder.groupUsers(':oid', ':key'),
|
|
725
|
+
methods: ['POST'],
|
|
726
|
+
},
|
|
727
|
+
respond,
|
|
658
728
|
},
|
|
659
|
-
|
|
660
|
-
|
|
729
|
+
options
|
|
730
|
+
)
|
|
661
731
|
},
|
|
662
732
|
|
|
663
733
|
/**
|
|
664
734
|
* Mocks the `groups.removeUsers()` method.
|
|
665
735
|
*/
|
|
666
|
-
removeUsers: async (init?: MockResult): Promise<void> => {
|
|
736
|
+
removeUsers: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
667
737
|
const { mock } = this
|
|
668
738
|
// const respond = init?.response ?? {
|
|
669
739
|
// status: 200,
|
|
@@ -676,13 +746,16 @@ export class SdkMock {
|
|
|
676
746
|
() => JSON.stringify(this.gen.group.group()),
|
|
677
747
|
init
|
|
678
748
|
)
|
|
679
|
-
await mock.add(
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
749
|
+
await mock.add(
|
|
750
|
+
{
|
|
751
|
+
match: {
|
|
752
|
+
uri: RouteBuilder.groupUsers(':oid', ':key'),
|
|
753
|
+
methods: ['DELETE'],
|
|
754
|
+
},
|
|
755
|
+
respond,
|
|
683
756
|
},
|
|
684
|
-
|
|
685
|
-
|
|
757
|
+
options
|
|
758
|
+
)
|
|
686
759
|
},
|
|
687
760
|
}
|
|
688
761
|
|
|
@@ -694,7 +767,7 @@ export class SdkMock {
|
|
|
694
767
|
* Mocks the `user.me()` method.
|
|
695
768
|
* @param options Optional response customization.
|
|
696
769
|
*/
|
|
697
|
-
me: async (init?: MockResult): Promise<void> => {
|
|
770
|
+
me: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
698
771
|
const { mock } = this
|
|
699
772
|
// const respond = init?.response ?? {
|
|
700
773
|
// status: 200,
|
|
@@ -707,13 +780,16 @@ export class SdkMock {
|
|
|
707
780
|
() => JSON.stringify(this.gen.user.user()),
|
|
708
781
|
init
|
|
709
782
|
)
|
|
710
|
-
await mock.add(
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
783
|
+
await mock.add(
|
|
784
|
+
{
|
|
785
|
+
match: {
|
|
786
|
+
uri: RouteBuilder.usersMe(),
|
|
787
|
+
methods: ['GET'],
|
|
788
|
+
},
|
|
789
|
+
respond,
|
|
714
790
|
},
|
|
715
|
-
|
|
716
|
-
|
|
791
|
+
options
|
|
792
|
+
)
|
|
717
793
|
},
|
|
718
794
|
}
|
|
719
795
|
|
|
@@ -724,7 +800,7 @@ export class SdkMock {
|
|
|
724
800
|
/**
|
|
725
801
|
* Mocks the `file.list()` method.
|
|
726
802
|
*/
|
|
727
|
-
list: async (init?: MockListResult): Promise<void> => {
|
|
803
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
728
804
|
const { mock } = this
|
|
729
805
|
// const respond = init?.response ?? {
|
|
730
806
|
// status: 200,
|
|
@@ -746,19 +822,22 @@ export class SdkMock {
|
|
|
746
822
|
},
|
|
747
823
|
init
|
|
748
824
|
)
|
|
749
|
-
await mock.add(
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
825
|
+
await mock.add(
|
|
826
|
+
{
|
|
827
|
+
match: {
|
|
828
|
+
uri: RouteBuilder.files(':oid'),
|
|
829
|
+
methods: ['GET'],
|
|
830
|
+
},
|
|
831
|
+
respond,
|
|
753
832
|
},
|
|
754
|
-
|
|
755
|
-
|
|
833
|
+
options
|
|
834
|
+
)
|
|
756
835
|
},
|
|
757
836
|
|
|
758
837
|
/**
|
|
759
838
|
* Mocks the `file.createMeta()` method.
|
|
760
839
|
*/
|
|
761
|
-
createMeta: async (init?: MockResult): Promise<void> => {
|
|
840
|
+
createMeta: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
762
841
|
const { mock } = this
|
|
763
842
|
// const respond = init?.response ?? {
|
|
764
843
|
// status: 201,
|
|
@@ -771,48 +850,54 @@ export class SdkMock {
|
|
|
771
850
|
() => JSON.stringify(this.gen.file.file()),
|
|
772
851
|
init
|
|
773
852
|
)
|
|
774
|
-
await mock.add(
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
853
|
+
await mock.add(
|
|
854
|
+
{
|
|
855
|
+
match: {
|
|
856
|
+
uri: RouteBuilder.files(':oid'),
|
|
857
|
+
methods: ['POST'],
|
|
858
|
+
},
|
|
859
|
+
respond,
|
|
778
860
|
},
|
|
779
|
-
|
|
780
|
-
|
|
861
|
+
options
|
|
862
|
+
)
|
|
781
863
|
},
|
|
782
864
|
|
|
783
865
|
/**
|
|
784
866
|
* Mocks the `file.createMedia()` method.
|
|
785
867
|
*/
|
|
786
|
-
createMedia: async (init?: MockResult): Promise<void> => {
|
|
868
|
+
createMedia: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
787
869
|
const { mock } = this
|
|
788
870
|
// const respond = init?.response ?? {
|
|
789
871
|
// status: 200,
|
|
790
872
|
// }
|
|
791
873
|
const respond = this.createDefaultResponse(200, undefined, undefined, init)
|
|
792
|
-
await mock.add(
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
874
|
+
await mock.add(
|
|
875
|
+
{
|
|
876
|
+
match: {
|
|
877
|
+
uri: RouteBuilder.fileMedia(':oid', ':id'),
|
|
878
|
+
methods: ['PUT'],
|
|
879
|
+
},
|
|
880
|
+
respond,
|
|
796
881
|
},
|
|
797
|
-
|
|
798
|
-
|
|
882
|
+
options
|
|
883
|
+
)
|
|
799
884
|
},
|
|
800
885
|
|
|
801
886
|
/**
|
|
802
887
|
* Mocks the `file.create()` method.
|
|
803
888
|
*/
|
|
804
|
-
create: async (init?: MockResult): Promise<void> => {
|
|
805
|
-
await this.file.createMeta(init)
|
|
889
|
+
create: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
890
|
+
await this.file.createMeta(init, options)
|
|
806
891
|
// When SDK's file.create() is called, it responds with
|
|
807
892
|
// what the result of file.createMeta() would be.
|
|
808
893
|
// Because of that, we don't need to configure the media request.
|
|
809
|
-
await this.file.createMedia()
|
|
894
|
+
await this.file.createMedia(undefined, options)
|
|
810
895
|
},
|
|
811
896
|
|
|
812
897
|
/**
|
|
813
898
|
* Mocks the `file.createFolder()` method.
|
|
814
899
|
*/
|
|
815
|
-
createFolder: async (init?: MockResult): Promise<void> => {
|
|
900
|
+
createFolder: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
816
901
|
const { mock } = this
|
|
817
902
|
// const respond = init?.response ?? {
|
|
818
903
|
// status: 201,
|
|
@@ -825,19 +910,22 @@ export class SdkMock {
|
|
|
825
910
|
() => JSON.stringify(this.gen.file.folder()),
|
|
826
911
|
init
|
|
827
912
|
)
|
|
828
|
-
await mock.add(
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
913
|
+
await mock.add(
|
|
914
|
+
{
|
|
915
|
+
match: {
|
|
916
|
+
uri: RouteBuilder.files(':oid'),
|
|
917
|
+
methods: ['POST'],
|
|
918
|
+
},
|
|
919
|
+
respond,
|
|
832
920
|
},
|
|
833
|
-
|
|
834
|
-
|
|
921
|
+
options
|
|
922
|
+
)
|
|
835
923
|
},
|
|
836
924
|
|
|
837
925
|
/**
|
|
838
926
|
* Mocks the `file.read()` method.
|
|
839
927
|
*/
|
|
840
|
-
read: async (init?: MockResult): Promise<void> => {
|
|
928
|
+
read: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
841
929
|
const { mock } = this
|
|
842
930
|
// const respond = init?.response ?? {
|
|
843
931
|
// status: 200,
|
|
@@ -850,19 +938,22 @@ export class SdkMock {
|
|
|
850
938
|
() => JSON.stringify(this.gen.file.file()),
|
|
851
939
|
init
|
|
852
940
|
)
|
|
853
|
-
await mock.add(
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
941
|
+
await mock.add(
|
|
942
|
+
{
|
|
943
|
+
match: {
|
|
944
|
+
uri: RouteBuilder.file(':oid', ':id'),
|
|
945
|
+
methods: ['GET'],
|
|
946
|
+
},
|
|
947
|
+
respond,
|
|
857
948
|
},
|
|
858
|
-
|
|
859
|
-
|
|
949
|
+
options
|
|
950
|
+
)
|
|
860
951
|
},
|
|
861
952
|
|
|
862
953
|
/**
|
|
863
954
|
* Mocks the `file.readMedia()` method.
|
|
864
955
|
*/
|
|
865
|
-
readMedia: async (init?: MockResult): Promise<void> => {
|
|
956
|
+
readMedia: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
866
957
|
const { mock } = this
|
|
867
958
|
// const respond = init?.response ?? {
|
|
868
959
|
// status: 200,
|
|
@@ -881,19 +972,22 @@ export class SdkMock {
|
|
|
881
972
|
() => JSON.stringify({ data: this.gen.faker.lorem.sentences() }),
|
|
882
973
|
init
|
|
883
974
|
)
|
|
884
|
-
await mock.add(
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
975
|
+
await mock.add(
|
|
976
|
+
{
|
|
977
|
+
match: {
|
|
978
|
+
uri: RouteBuilder.fileMedia(':oid', ':id'),
|
|
979
|
+
methods: ['GET'],
|
|
980
|
+
},
|
|
981
|
+
respond,
|
|
888
982
|
},
|
|
889
|
-
|
|
890
|
-
|
|
983
|
+
options
|
|
984
|
+
)
|
|
891
985
|
},
|
|
892
986
|
|
|
893
987
|
/**
|
|
894
988
|
* Mocks the `file.readBulk()` method.
|
|
895
989
|
*/
|
|
896
|
-
readBulk: async (init?: MockListResult): Promise<void> => {
|
|
990
|
+
readBulk: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
897
991
|
const { mock } = this
|
|
898
992
|
// const respond = init?.response ?? {
|
|
899
993
|
// status: 200,
|
|
@@ -913,19 +1007,22 @@ export class SdkMock {
|
|
|
913
1007
|
},
|
|
914
1008
|
init
|
|
915
1009
|
)
|
|
916
|
-
await mock.add(
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
1010
|
+
await mock.add(
|
|
1011
|
+
{
|
|
1012
|
+
match: {
|
|
1013
|
+
uri: RouteBuilder.filesBatch(':oid'),
|
|
1014
|
+
methods: ['POST'],
|
|
1015
|
+
},
|
|
1016
|
+
respond,
|
|
920
1017
|
},
|
|
921
|
-
|
|
922
|
-
|
|
1018
|
+
options
|
|
1019
|
+
)
|
|
923
1020
|
},
|
|
924
1021
|
|
|
925
1022
|
/**
|
|
926
1023
|
* Mocks the `file.patch()` method.
|
|
927
1024
|
*/
|
|
928
|
-
patch: async (init?: MockResult): Promise<void> => {
|
|
1025
|
+
patch: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
929
1026
|
const { mock } = this
|
|
930
1027
|
// const respond = init?.response ?? {
|
|
931
1028
|
// status: 200,
|
|
@@ -938,19 +1035,22 @@ export class SdkMock {
|
|
|
938
1035
|
() => JSON.stringify(this.gen.file.file()),
|
|
939
1036
|
init
|
|
940
1037
|
)
|
|
941
|
-
await mock.add(
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
1038
|
+
await mock.add(
|
|
1039
|
+
{
|
|
1040
|
+
match: {
|
|
1041
|
+
uri: RouteBuilder.file(':oid', ':id'),
|
|
1042
|
+
methods: ['PATCH'],
|
|
1043
|
+
},
|
|
1044
|
+
respond,
|
|
945
1045
|
},
|
|
946
|
-
|
|
947
|
-
|
|
1046
|
+
options
|
|
1047
|
+
)
|
|
948
1048
|
},
|
|
949
1049
|
|
|
950
1050
|
/**
|
|
951
1051
|
* Mocks the `file.patchMedia()` method.
|
|
952
1052
|
*/
|
|
953
|
-
patchMedia: async (init?: MockResult): Promise<void> => {
|
|
1053
|
+
patchMedia: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
954
1054
|
const { mock } = this
|
|
955
1055
|
// const respond = init?.response ?? {
|
|
956
1056
|
// status: 200,
|
|
@@ -963,55 +1063,64 @@ export class SdkMock {
|
|
|
963
1063
|
() => JSON.stringify(this.gen.patch.mediaPatchRevision()),
|
|
964
1064
|
init
|
|
965
1065
|
)
|
|
966
|
-
await mock.add(
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
1066
|
+
await mock.add(
|
|
1067
|
+
{
|
|
1068
|
+
match: {
|
|
1069
|
+
uri: RouteBuilder.fileMedia(':oid', ':id'),
|
|
1070
|
+
methods: ['PATCH'],
|
|
1071
|
+
},
|
|
1072
|
+
respond,
|
|
970
1073
|
},
|
|
971
|
-
|
|
972
|
-
|
|
1074
|
+
options
|
|
1075
|
+
)
|
|
973
1076
|
},
|
|
974
1077
|
|
|
975
1078
|
/**
|
|
976
1079
|
* Mocks the `file.delete()` method.
|
|
977
1080
|
*/
|
|
978
|
-
delete: async (init?: MockResult): Promise<void> => {
|
|
1081
|
+
delete: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
979
1082
|
const { mock } = this
|
|
980
1083
|
// const respond = init?.response ?? {
|
|
981
1084
|
// status: 204,
|
|
982
1085
|
// }
|
|
983
1086
|
const respond = this.createDefaultResponse(204, undefined, undefined, init)
|
|
984
|
-
await mock.add(
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
1087
|
+
await mock.add(
|
|
1088
|
+
{
|
|
1089
|
+
match: {
|
|
1090
|
+
uri: RouteBuilder.file(':oid', ':id'),
|
|
1091
|
+
methods: ['DELETE'],
|
|
1092
|
+
},
|
|
1093
|
+
respond,
|
|
988
1094
|
},
|
|
989
|
-
|
|
990
|
-
|
|
1095
|
+
options
|
|
1096
|
+
)
|
|
991
1097
|
},
|
|
992
1098
|
|
|
993
1099
|
/**
|
|
994
1100
|
* Mocks the `file.deleteBulk()` method.
|
|
995
1101
|
*/
|
|
996
|
-
deleteBulk: async (init?: MockResult): Promise<void> => {
|
|
1102
|
+
deleteBulk: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
997
1103
|
const { mock } = this
|
|
998
1104
|
// const respond = init?.response ?? {
|
|
999
1105
|
// status: 204,
|
|
1000
1106
|
// }
|
|
1001
1107
|
const respond = this.createDefaultResponse(204, undefined, undefined, init)
|
|
1002
|
-
await mock.add(
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1108
|
+
await mock.add(
|
|
1109
|
+
{
|
|
1110
|
+
match: {
|
|
1111
|
+
uri: RouteBuilder.files(':oid'),
|
|
1112
|
+
methods: ['DELETE'],
|
|
1113
|
+
},
|
|
1114
|
+
respond,
|
|
1006
1115
|
},
|
|
1007
|
-
|
|
1008
|
-
|
|
1116
|
+
options
|
|
1117
|
+
)
|
|
1009
1118
|
},
|
|
1010
1119
|
|
|
1011
1120
|
/**
|
|
1012
1121
|
* Mocks the `file.patchUsers()` method.
|
|
1013
1122
|
*/
|
|
1014
|
-
patchUsers: async (init?: MockResult): Promise<void> => {
|
|
1123
|
+
patchUsers: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
1015
1124
|
const { mock } = this
|
|
1016
1125
|
// const respond = init?.response ?? {
|
|
1017
1126
|
// status: 200,
|
|
@@ -1024,33 +1133,36 @@ export class SdkMock {
|
|
|
1024
1133
|
() => JSON.stringify(this.gen.file.file()),
|
|
1025
1134
|
init
|
|
1026
1135
|
)
|
|
1027
|
-
await mock.add(
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1136
|
+
await mock.add(
|
|
1137
|
+
{
|
|
1138
|
+
match: {
|
|
1139
|
+
uri: RouteBuilder.filesAccess(':oid', ':id'),
|
|
1140
|
+
methods: ['PATCH'],
|
|
1141
|
+
},
|
|
1142
|
+
respond,
|
|
1031
1143
|
},
|
|
1032
|
-
|
|
1033
|
-
|
|
1144
|
+
options
|
|
1145
|
+
)
|
|
1034
1146
|
},
|
|
1035
1147
|
|
|
1036
1148
|
/**
|
|
1037
1149
|
* Mocks the `file.addUser()` method.
|
|
1038
1150
|
*/
|
|
1039
|
-
addUser: async (init?: MockResult): Promise<void> => {
|
|
1040
|
-
await this.file.patchUsers(init)
|
|
1151
|
+
addUser: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
1152
|
+
await this.file.patchUsers(init, options)
|
|
1041
1153
|
},
|
|
1042
1154
|
|
|
1043
1155
|
/**
|
|
1044
1156
|
* Mocks the `file.removeUser()` method.
|
|
1045
1157
|
*/
|
|
1046
|
-
removeUser: async (init?: MockResult): Promise<void> => {
|
|
1047
|
-
await this.file.patchUsers(init)
|
|
1158
|
+
removeUser: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
1159
|
+
await this.file.patchUsers(init, options)
|
|
1048
1160
|
},
|
|
1049
1161
|
|
|
1050
1162
|
/**
|
|
1051
1163
|
* Mocks the `file.listUsers()` method.
|
|
1052
1164
|
*/
|
|
1053
|
-
listUsers: async (init?: MockListResult): Promise<void> => {
|
|
1165
|
+
listUsers: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1054
1166
|
const { mock } = this
|
|
1055
1167
|
// const respond = init?.response ?? {
|
|
1056
1168
|
// status: 200,
|
|
@@ -1072,19 +1184,22 @@ export class SdkMock {
|
|
|
1072
1184
|
},
|
|
1073
1185
|
init
|
|
1074
1186
|
)
|
|
1075
|
-
await mock.add(
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1187
|
+
await mock.add(
|
|
1188
|
+
{
|
|
1189
|
+
match: {
|
|
1190
|
+
uri: RouteBuilder.fileUsers(':oid', ':id'),
|
|
1191
|
+
methods: ['GET'],
|
|
1192
|
+
},
|
|
1193
|
+
respond,
|
|
1079
1194
|
},
|
|
1080
|
-
|
|
1081
|
-
|
|
1195
|
+
options
|
|
1196
|
+
)
|
|
1082
1197
|
},
|
|
1083
1198
|
|
|
1084
1199
|
/**
|
|
1085
1200
|
* Mocks the `file.breadcrumbs()` method.
|
|
1086
1201
|
*/
|
|
1087
|
-
breadcrumbs: async (init?: MockListResult): Promise<void> => {
|
|
1202
|
+
breadcrumbs: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1088
1203
|
const { mock } = this
|
|
1089
1204
|
// const respond = init?.response ?? {
|
|
1090
1205
|
// status: 200,
|
|
@@ -1106,13 +1221,16 @@ export class SdkMock {
|
|
|
1106
1221
|
},
|
|
1107
1222
|
init
|
|
1108
1223
|
)
|
|
1109
|
-
await mock.add(
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1224
|
+
await mock.add(
|
|
1225
|
+
{
|
|
1226
|
+
match: {
|
|
1227
|
+
uri: RouteBuilder.fileBreadcrumbs(':oid', ':id'),
|
|
1228
|
+
methods: ['GET'],
|
|
1229
|
+
},
|
|
1230
|
+
respond,
|
|
1113
1231
|
},
|
|
1114
|
-
|
|
1115
|
-
|
|
1232
|
+
options
|
|
1233
|
+
)
|
|
1116
1234
|
},
|
|
1117
1235
|
}
|
|
1118
1236
|
|
|
@@ -1120,7 +1238,7 @@ export class SdkMock {
|
|
|
1120
1238
|
* Shared API mocks.
|
|
1121
1239
|
*/
|
|
1122
1240
|
shared = {
|
|
1123
|
-
list: async (init?: MockListResult): Promise<void> => {
|
|
1241
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1124
1242
|
const { mock } = this
|
|
1125
1243
|
// const respond = init?.response ?? {
|
|
1126
1244
|
// status: 200,
|
|
@@ -1142,13 +1260,16 @@ export class SdkMock {
|
|
|
1142
1260
|
},
|
|
1143
1261
|
init
|
|
1144
1262
|
)
|
|
1145
|
-
await mock.add(
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1263
|
+
await mock.add(
|
|
1264
|
+
{
|
|
1265
|
+
match: {
|
|
1266
|
+
uri: RouteBuilder.shared(':oid'),
|
|
1267
|
+
methods: ['GET'],
|
|
1268
|
+
},
|
|
1269
|
+
respond,
|
|
1149
1270
|
},
|
|
1150
|
-
|
|
1151
|
-
|
|
1271
|
+
options
|
|
1272
|
+
)
|
|
1152
1273
|
},
|
|
1153
1274
|
}
|
|
1154
1275
|
|
|
@@ -1156,7 +1277,7 @@ export class SdkMock {
|
|
|
1156
1277
|
* Trash API mocks.
|
|
1157
1278
|
*/
|
|
1158
1279
|
trash = {
|
|
1159
|
-
list: async (init?: MockListResult): Promise<void> => {
|
|
1280
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1160
1281
|
const { mock } = this
|
|
1161
1282
|
// const respond = init?.response ?? {
|
|
1162
1283
|
// status: 200,
|
|
@@ -1178,55 +1299,67 @@ export class SdkMock {
|
|
|
1178
1299
|
},
|
|
1179
1300
|
init
|
|
1180
1301
|
)
|
|
1181
|
-
await mock.add(
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1302
|
+
await mock.add(
|
|
1303
|
+
{
|
|
1304
|
+
match: {
|
|
1305
|
+
uri: RouteBuilder.trash(':oid'),
|
|
1306
|
+
methods: ['GET'],
|
|
1307
|
+
},
|
|
1308
|
+
respond,
|
|
1185
1309
|
},
|
|
1186
|
-
|
|
1187
|
-
|
|
1310
|
+
options
|
|
1311
|
+
)
|
|
1188
1312
|
},
|
|
1189
|
-
delete: async (init?: MockResult): Promise<void> => {
|
|
1313
|
+
delete: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
1190
1314
|
const { mock } = this
|
|
1191
1315
|
// const respond = init?.response ?? {
|
|
1192
1316
|
// status: 204,
|
|
1193
1317
|
// }
|
|
1194
1318
|
const respond = this.createDefaultResponse(204, undefined, undefined, init)
|
|
1195
|
-
await mock.add(
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1319
|
+
await mock.add(
|
|
1320
|
+
{
|
|
1321
|
+
match: {
|
|
1322
|
+
uri: RouteBuilder.trashBatchDelete(':oid'),
|
|
1323
|
+
methods: ['DELETE'],
|
|
1324
|
+
},
|
|
1325
|
+
respond,
|
|
1199
1326
|
},
|
|
1200
|
-
|
|
1201
|
-
|
|
1327
|
+
options
|
|
1328
|
+
)
|
|
1202
1329
|
},
|
|
1203
|
-
restore: async (init?: MockResult): Promise<void> => {
|
|
1330
|
+
restore: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
1204
1331
|
const { mock } = this
|
|
1205
1332
|
// const respond = init?.response ?? {
|
|
1206
1333
|
// status: 204,
|
|
1207
1334
|
// }
|
|
1208
1335
|
const respond = this.createDefaultResponse(204, undefined, undefined, init)
|
|
1209
|
-
await mock.add(
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1336
|
+
await mock.add(
|
|
1337
|
+
{
|
|
1338
|
+
match: {
|
|
1339
|
+
uri: RouteBuilder.trashBatchRestore(':oid'),
|
|
1340
|
+
methods: ['POST'],
|
|
1341
|
+
},
|
|
1342
|
+
respond,
|
|
1213
1343
|
},
|
|
1214
|
-
|
|
1215
|
-
|
|
1344
|
+
options
|
|
1345
|
+
)
|
|
1216
1346
|
},
|
|
1217
|
-
empty: async (init?: MockResult): Promise<void> => {
|
|
1347
|
+
empty: async (init?: MockResult, options?: InterceptOptions): Promise<void> => {
|
|
1218
1348
|
const { mock } = this
|
|
1219
1349
|
// const respond = init?.response ?? {
|
|
1220
1350
|
// status: 204,
|
|
1221
1351
|
// }
|
|
1222
1352
|
const respond = this.createDefaultResponse(204, undefined, undefined, init)
|
|
1223
|
-
await mock.add(
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1353
|
+
await mock.add(
|
|
1354
|
+
{
|
|
1355
|
+
match: {
|
|
1356
|
+
uri: RouteBuilder.trashEmpty(':oid'),
|
|
1357
|
+
methods: ['DELETE'],
|
|
1358
|
+
},
|
|
1359
|
+
respond,
|
|
1227
1360
|
},
|
|
1228
|
-
|
|
1229
|
-
|
|
1361
|
+
options
|
|
1362
|
+
)
|
|
1230
1363
|
},
|
|
1231
1364
|
}
|
|
1232
1365
|
}
|