@api-client/core 0.18.39 → 0.18.41
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/oauth-popup.html +33 -0
- package/build/src/mocking/ModelingMock.d.ts +2 -0
- package/build/src/mocking/ModelingMock.d.ts.map +1 -1
- package/build/src/mocking/ModelingMock.js +2 -0
- package/build/src/mocking/ModelingMock.js.map +1 -1
- package/build/src/mocking/lib/DataCatalog.d.ts +53 -0
- package/build/src/mocking/lib/DataCatalog.d.ts.map +1 -0
- package/build/src/mocking/lib/DataCatalog.js +129 -0
- package/build/src/mocking/lib/DataCatalog.js.map +1 -0
- package/build/src/models/DataCatalog.d.ts +14 -0
- package/build/src/models/DataCatalog.d.ts.map +1 -1
- package/build/src/models/DataCatalog.js.map +1 -1
- package/build/src/sdk/DataCatalogSdk.d.ts +6 -6
- package/build/src/sdk/DataCatalogSdk.d.ts.map +1 -1
- package/build/src/sdk/DataCatalogSdk.js +6 -2
- package/build/src/sdk/DataCatalogSdk.js.map +1 -1
- package/build/src/sdk/SdkMock.d.ts +67 -46
- package/build/src/sdk/SdkMock.d.ts.map +1 -1
- package/build/src/sdk/SdkMock.js +327 -92
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/data/models/example-generator-api.json +12 -12
- package/package.json +5 -4
- package/src/mocking/ModelingMock.ts +2 -0
- package/src/mocking/lib/DataCatalog.ts +166 -0
- package/src/models/DataCatalog.ts +14 -0
- package/src/sdk/DataCatalogSdk.ts +9 -7
- package/src/sdk/SdkMock.ts +781 -299
- package/tests/unit/mocking/current/DataCatalog.spec.ts +449 -0
- package/TESTING_READY.md +0 -114
package/build/src/sdk/SdkMock.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { setupWorker } from '@jarrodek/amw';
|
|
1
|
+
import { setupWorker, } from '@jarrodek/amw';
|
|
2
2
|
import { RouteBuilder } from './RouteBuilder.js';
|
|
3
3
|
import { ModelingMock } from '../mocking/ModelingMock.js';
|
|
4
|
+
import { DataDomain } from '../modeling/DataDomain.js';
|
|
5
|
+
import { nanoid } from '../nanoid.js';
|
|
4
6
|
/**
|
|
5
7
|
* SDK mocking utility for testing. Uses Service Workers to intercept HTTP requests
|
|
6
8
|
* and provide mock responses for API calls.
|
|
@@ -56,6 +58,10 @@ import { ModelingMock } from '../mocking/ModelingMock.js';
|
|
|
56
58
|
* // Stop and remove the Service Worker
|
|
57
59
|
* await mocker.teardown();
|
|
58
60
|
* ```
|
|
61
|
+
*
|
|
62
|
+
* @TODO: Add a in-memory state store so that mocks can maintain state across requests.
|
|
63
|
+
* This way, operations like create, update, delete can affect subsequent list/read calls
|
|
64
|
+
* and we can mimic the API behavior more closely.
|
|
59
65
|
*/
|
|
60
66
|
export class SdkMock {
|
|
61
67
|
options;
|
|
@@ -119,11 +125,11 @@ export class SdkMock {
|
|
|
119
125
|
}
|
|
120
126
|
if (!respond.body && userConfig?.forceBody && body) {
|
|
121
127
|
// when body is missing and forceBody is set, generate the body
|
|
122
|
-
respond.body = body();
|
|
128
|
+
respond.body = (req) => body(req);
|
|
123
129
|
}
|
|
124
130
|
else if (body && (!userConfig || !userConfig.response)) {
|
|
125
131
|
// we set the body by default when the user config is missing
|
|
126
|
-
respond.body = body();
|
|
132
|
+
respond.body = (req) => body(req);
|
|
127
133
|
}
|
|
128
134
|
return respond;
|
|
129
135
|
}
|
|
@@ -135,7 +141,7 @@ export class SdkMock {
|
|
|
135
141
|
* Adds an intercept to mock the `organizations.list()` method.
|
|
136
142
|
* @param options Optional response configuration
|
|
137
143
|
*/
|
|
138
|
-
list: async (init) => {
|
|
144
|
+
list: async (init, options) => {
|
|
139
145
|
const { mock } = this;
|
|
140
146
|
// const respond = init?.response ?? {
|
|
141
147
|
// status: 200,
|
|
@@ -155,13 +161,13 @@ export class SdkMock {
|
|
|
155
161
|
methods: ['GET'],
|
|
156
162
|
},
|
|
157
163
|
respond,
|
|
158
|
-
});
|
|
164
|
+
}, options);
|
|
159
165
|
},
|
|
160
166
|
/**
|
|
161
167
|
* Adds an intercept to mock the `organizations.create()` method.
|
|
162
168
|
* @param options Optional response configuration
|
|
163
169
|
*/
|
|
164
|
-
create: async (init) => {
|
|
170
|
+
create: async (init, options) => {
|
|
165
171
|
const { mock } = this;
|
|
166
172
|
// const respond = init?.response ?? {
|
|
167
173
|
// status: 200,
|
|
@@ -175,10 +181,10 @@ export class SdkMock {
|
|
|
175
181
|
methods: ['POST'],
|
|
176
182
|
},
|
|
177
183
|
respond,
|
|
178
|
-
});
|
|
184
|
+
}, options);
|
|
179
185
|
},
|
|
180
186
|
invitations: {
|
|
181
|
-
list: async (init) => {
|
|
187
|
+
list: async (init, options) => {
|
|
182
188
|
const { mock } = this;
|
|
183
189
|
// const respond = init?.response ?? {
|
|
184
190
|
// status: 200,
|
|
@@ -201,9 +207,9 @@ export class SdkMock {
|
|
|
201
207
|
methods: ['GET'],
|
|
202
208
|
},
|
|
203
209
|
respond,
|
|
204
|
-
});
|
|
210
|
+
}, options);
|
|
205
211
|
},
|
|
206
|
-
create: async (init) => {
|
|
212
|
+
create: async (init, options) => {
|
|
207
213
|
const { mock } = this;
|
|
208
214
|
// const respond = init?.response ?? {
|
|
209
215
|
// status: 200,
|
|
@@ -217,9 +223,9 @@ export class SdkMock {
|
|
|
217
223
|
methods: ['POST'],
|
|
218
224
|
},
|
|
219
225
|
respond,
|
|
220
|
-
});
|
|
226
|
+
}, options);
|
|
221
227
|
},
|
|
222
|
-
findByToken: async (init) => {
|
|
228
|
+
findByToken: async (init, options) => {
|
|
223
229
|
const { mock } = this;
|
|
224
230
|
// const respond = init?.response ?? {
|
|
225
231
|
// status: 200,
|
|
@@ -233,9 +239,9 @@ export class SdkMock {
|
|
|
233
239
|
methods: ['GET'],
|
|
234
240
|
},
|
|
235
241
|
respond,
|
|
236
|
-
});
|
|
242
|
+
}, options);
|
|
237
243
|
},
|
|
238
|
-
decline: async (init) => {
|
|
244
|
+
decline: async (init, options) => {
|
|
239
245
|
const { mock } = this;
|
|
240
246
|
// const respond = init?.response ?? {
|
|
241
247
|
// status: 200,
|
|
@@ -249,9 +255,9 @@ export class SdkMock {
|
|
|
249
255
|
methods: ['POST'],
|
|
250
256
|
},
|
|
251
257
|
respond,
|
|
252
|
-
});
|
|
258
|
+
}, options);
|
|
253
259
|
},
|
|
254
|
-
delete: async (init) => {
|
|
260
|
+
delete: async (init, options) => {
|
|
255
261
|
const { mock } = this;
|
|
256
262
|
// const respond = init?.response ?? {
|
|
257
263
|
// status: 200,
|
|
@@ -265,9 +271,9 @@ export class SdkMock {
|
|
|
265
271
|
methods: ['DELETE'],
|
|
266
272
|
},
|
|
267
273
|
respond,
|
|
268
|
-
});
|
|
274
|
+
}, options);
|
|
269
275
|
},
|
|
270
|
-
patch: async (init) => {
|
|
276
|
+
patch: async (init, options) => {
|
|
271
277
|
const { mock } = this;
|
|
272
278
|
// const respond = init?.response ?? {
|
|
273
279
|
// status: 200,
|
|
@@ -281,9 +287,9 @@ export class SdkMock {
|
|
|
281
287
|
methods: ['PATCH'],
|
|
282
288
|
},
|
|
283
289
|
respond,
|
|
284
|
-
});
|
|
290
|
+
}, options);
|
|
285
291
|
},
|
|
286
|
-
resend: async (init) => {
|
|
292
|
+
resend: async (init, options) => {
|
|
287
293
|
const { mock } = this;
|
|
288
294
|
// const respond = init?.response ?? {
|
|
289
295
|
// status: 200,
|
|
@@ -297,11 +303,11 @@ export class SdkMock {
|
|
|
297
303
|
methods: ['PUT'],
|
|
298
304
|
},
|
|
299
305
|
respond,
|
|
300
|
-
});
|
|
306
|
+
}, options);
|
|
301
307
|
},
|
|
302
308
|
},
|
|
303
309
|
users: {
|
|
304
|
-
list: async (init) => {
|
|
310
|
+
list: async (init, options) => {
|
|
305
311
|
const { mock } = this;
|
|
306
312
|
// const respond = init?.response ?? {
|
|
307
313
|
// status: 200,
|
|
@@ -324,9 +330,9 @@ export class SdkMock {
|
|
|
324
330
|
methods: ['GET'],
|
|
325
331
|
},
|
|
326
332
|
respond,
|
|
327
|
-
});
|
|
333
|
+
}, options);
|
|
328
334
|
},
|
|
329
|
-
read: async (init) => {
|
|
335
|
+
read: async (init, options) => {
|
|
330
336
|
const { mock } = this;
|
|
331
337
|
// const respond = init?.response ?? {
|
|
332
338
|
// status: 200,
|
|
@@ -340,9 +346,9 @@ export class SdkMock {
|
|
|
340
346
|
methods: ['GET'],
|
|
341
347
|
},
|
|
342
348
|
respond,
|
|
343
|
-
});
|
|
349
|
+
}, options);
|
|
344
350
|
},
|
|
345
|
-
readBatch: async (init) => {
|
|
351
|
+
readBatch: async (init, options) => {
|
|
346
352
|
const { mock } = this;
|
|
347
353
|
const path = RouteBuilder.organizationUserBatch(':oid');
|
|
348
354
|
const respond = init?.response ?? {
|
|
@@ -359,9 +365,9 @@ export class SdkMock {
|
|
|
359
365
|
methods: ['POST'],
|
|
360
366
|
},
|
|
361
367
|
respond,
|
|
362
|
-
});
|
|
368
|
+
}, options);
|
|
363
369
|
},
|
|
364
|
-
activate: async (init) => {
|
|
370
|
+
activate: async (init, options) => {
|
|
365
371
|
const { mock } = this;
|
|
366
372
|
// const respond = init?.response ?? {
|
|
367
373
|
// status: 200,
|
|
@@ -375,9 +381,9 @@ export class SdkMock {
|
|
|
375
381
|
methods: ['POST'],
|
|
376
382
|
},
|
|
377
383
|
respond,
|
|
378
|
-
});
|
|
384
|
+
}, options);
|
|
379
385
|
},
|
|
380
|
-
deactivate: async (init) => {
|
|
386
|
+
deactivate: async (init, options) => {
|
|
381
387
|
const { mock } = this;
|
|
382
388
|
// const respond = init?.response ?? {
|
|
383
389
|
// status: 200,
|
|
@@ -391,9 +397,9 @@ export class SdkMock {
|
|
|
391
397
|
methods: ['POST'],
|
|
392
398
|
},
|
|
393
399
|
respond,
|
|
394
|
-
});
|
|
400
|
+
}, options);
|
|
395
401
|
},
|
|
396
|
-
delete: async (init) => {
|
|
402
|
+
delete: async (init, options) => {
|
|
397
403
|
const { mock } = this;
|
|
398
404
|
// const respond = init?.response ?? {
|
|
399
405
|
// status: 204,
|
|
@@ -405,7 +411,7 @@ export class SdkMock {
|
|
|
405
411
|
methods: ['DELETE'],
|
|
406
412
|
},
|
|
407
413
|
respond,
|
|
408
|
-
});
|
|
414
|
+
}, options);
|
|
409
415
|
},
|
|
410
416
|
},
|
|
411
417
|
};
|
|
@@ -417,7 +423,7 @@ export class SdkMock {
|
|
|
417
423
|
* Mocks the `groups.list()` method.
|
|
418
424
|
* @param options Optional response customization.
|
|
419
425
|
*/
|
|
420
|
-
list: async (init) => {
|
|
426
|
+
list: async (init, options) => {
|
|
421
427
|
const { mock } = this;
|
|
422
428
|
// const respond = init?.response ?? {
|
|
423
429
|
// status: 200,
|
|
@@ -440,13 +446,13 @@ export class SdkMock {
|
|
|
440
446
|
methods: ['GET'],
|
|
441
447
|
},
|
|
442
448
|
respond,
|
|
443
|
-
});
|
|
449
|
+
}, options);
|
|
444
450
|
},
|
|
445
451
|
/**
|
|
446
452
|
* Mocks the `groups.create()` method.
|
|
447
453
|
* @param options Optional response customization.
|
|
448
454
|
*/
|
|
449
|
-
create: async (init) => {
|
|
455
|
+
create: async (init, options) => {
|
|
450
456
|
const { mock } = this;
|
|
451
457
|
// const respond = init?.response ?? {
|
|
452
458
|
// status: 201,
|
|
@@ -460,13 +466,13 @@ export class SdkMock {
|
|
|
460
466
|
methods: ['POST'],
|
|
461
467
|
},
|
|
462
468
|
respond,
|
|
463
|
-
});
|
|
469
|
+
}, options);
|
|
464
470
|
},
|
|
465
471
|
/**
|
|
466
472
|
* Mocks the `groups.update()` method.
|
|
467
473
|
* @param options Optional response customization.
|
|
468
474
|
*/
|
|
469
|
-
update: async (init) => {
|
|
475
|
+
update: async (init, options) => {
|
|
470
476
|
const { mock } = this;
|
|
471
477
|
// const respond = init?.response ?? {
|
|
472
478
|
// status: 200,
|
|
@@ -480,13 +486,13 @@ export class SdkMock {
|
|
|
480
486
|
methods: ['PATCH'],
|
|
481
487
|
},
|
|
482
488
|
respond,
|
|
483
|
-
});
|
|
489
|
+
}, options);
|
|
484
490
|
},
|
|
485
491
|
/**
|
|
486
492
|
* Mocks the `groups.delete()` method.
|
|
487
493
|
* @param options Optional response customization.
|
|
488
494
|
*/
|
|
489
|
-
delete: async (init) => {
|
|
495
|
+
delete: async (init, options) => {
|
|
490
496
|
const { mock } = this;
|
|
491
497
|
// const respond = init?.response ?? {
|
|
492
498
|
// status: 204,
|
|
@@ -498,12 +504,12 @@ export class SdkMock {
|
|
|
498
504
|
methods: ['DELETE'],
|
|
499
505
|
},
|
|
500
506
|
respond,
|
|
501
|
-
});
|
|
507
|
+
}, options);
|
|
502
508
|
},
|
|
503
509
|
/**
|
|
504
510
|
* Mocks the `groups.addUsers()` method.
|
|
505
511
|
*/
|
|
506
|
-
addUsers: async (init) => {
|
|
512
|
+
addUsers: async (init, options) => {
|
|
507
513
|
const { mock } = this;
|
|
508
514
|
// const respond = init?.response ?? {
|
|
509
515
|
// status: 200,
|
|
@@ -517,12 +523,12 @@ export class SdkMock {
|
|
|
517
523
|
methods: ['POST'],
|
|
518
524
|
},
|
|
519
525
|
respond,
|
|
520
|
-
});
|
|
526
|
+
}, options);
|
|
521
527
|
},
|
|
522
528
|
/**
|
|
523
529
|
* Mocks the `groups.removeUsers()` method.
|
|
524
530
|
*/
|
|
525
|
-
removeUsers: async (init) => {
|
|
531
|
+
removeUsers: async (init, options) => {
|
|
526
532
|
const { mock } = this;
|
|
527
533
|
// const respond = init?.response ?? {
|
|
528
534
|
// status: 200,
|
|
@@ -536,7 +542,7 @@ export class SdkMock {
|
|
|
536
542
|
methods: ['DELETE'],
|
|
537
543
|
},
|
|
538
544
|
respond,
|
|
539
|
-
});
|
|
545
|
+
}, options);
|
|
540
546
|
},
|
|
541
547
|
};
|
|
542
548
|
/**
|
|
@@ -547,7 +553,7 @@ export class SdkMock {
|
|
|
547
553
|
* Mocks the `user.me()` method.
|
|
548
554
|
* @param options Optional response customization.
|
|
549
555
|
*/
|
|
550
|
-
me: async (init) => {
|
|
556
|
+
me: async (init, options) => {
|
|
551
557
|
const { mock } = this;
|
|
552
558
|
// const respond = init?.response ?? {
|
|
553
559
|
// status: 200,
|
|
@@ -561,7 +567,7 @@ export class SdkMock {
|
|
|
561
567
|
methods: ['GET'],
|
|
562
568
|
},
|
|
563
569
|
respond,
|
|
564
|
-
});
|
|
570
|
+
}, options);
|
|
565
571
|
},
|
|
566
572
|
};
|
|
567
573
|
/**
|
|
@@ -571,7 +577,7 @@ export class SdkMock {
|
|
|
571
577
|
/**
|
|
572
578
|
* Mocks the `file.list()` method.
|
|
573
579
|
*/
|
|
574
|
-
list: async (init) => {
|
|
580
|
+
list: async (init, options) => {
|
|
575
581
|
const { mock } = this;
|
|
576
582
|
// const respond = init?.response ?? {
|
|
577
583
|
// status: 200,
|
|
@@ -594,12 +600,12 @@ export class SdkMock {
|
|
|
594
600
|
methods: ['GET'],
|
|
595
601
|
},
|
|
596
602
|
respond,
|
|
597
|
-
});
|
|
603
|
+
}, options);
|
|
598
604
|
},
|
|
599
605
|
/**
|
|
600
606
|
* Mocks the `file.createMeta()` method.
|
|
601
607
|
*/
|
|
602
|
-
createMeta: async (init) => {
|
|
608
|
+
createMeta: async (init, options) => {
|
|
603
609
|
const { mock } = this;
|
|
604
610
|
// const respond = init?.response ?? {
|
|
605
611
|
// status: 201,
|
|
@@ -613,12 +619,12 @@ export class SdkMock {
|
|
|
613
619
|
methods: ['POST'],
|
|
614
620
|
},
|
|
615
621
|
respond,
|
|
616
|
-
});
|
|
622
|
+
}, options);
|
|
617
623
|
},
|
|
618
624
|
/**
|
|
619
625
|
* Mocks the `file.createMedia()` method.
|
|
620
626
|
*/
|
|
621
|
-
createMedia: async (init) => {
|
|
627
|
+
createMedia: async (init, options) => {
|
|
622
628
|
const { mock } = this;
|
|
623
629
|
// const respond = init?.response ?? {
|
|
624
630
|
// status: 200,
|
|
@@ -630,22 +636,22 @@ export class SdkMock {
|
|
|
630
636
|
methods: ['PUT'],
|
|
631
637
|
},
|
|
632
638
|
respond,
|
|
633
|
-
});
|
|
639
|
+
}, options);
|
|
634
640
|
},
|
|
635
641
|
/**
|
|
636
642
|
* Mocks the `file.create()` method.
|
|
637
643
|
*/
|
|
638
|
-
create: async (init) => {
|
|
639
|
-
await this.file.createMeta(init);
|
|
644
|
+
create: async (init, options) => {
|
|
645
|
+
await this.file.createMeta(init, options);
|
|
640
646
|
// When SDK's file.create() is called, it responds with
|
|
641
647
|
// what the result of file.createMeta() would be.
|
|
642
648
|
// Because of that, we don't need to configure the media request.
|
|
643
|
-
await this.file.createMedia();
|
|
649
|
+
await this.file.createMedia(undefined, options);
|
|
644
650
|
},
|
|
645
651
|
/**
|
|
646
652
|
* Mocks the `file.createFolder()` method.
|
|
647
653
|
*/
|
|
648
|
-
createFolder: async (init) => {
|
|
654
|
+
createFolder: async (init, options) => {
|
|
649
655
|
const { mock } = this;
|
|
650
656
|
// const respond = init?.response ?? {
|
|
651
657
|
// status: 201,
|
|
@@ -659,12 +665,12 @@ export class SdkMock {
|
|
|
659
665
|
methods: ['POST'],
|
|
660
666
|
},
|
|
661
667
|
respond,
|
|
662
|
-
});
|
|
668
|
+
}, options);
|
|
663
669
|
},
|
|
664
670
|
/**
|
|
665
671
|
* Mocks the `file.read()` method.
|
|
666
672
|
*/
|
|
667
|
-
read: async (init) => {
|
|
673
|
+
read: async (init, options) => {
|
|
668
674
|
const { mock } = this;
|
|
669
675
|
// const respond = init?.response ?? {
|
|
670
676
|
// status: 200,
|
|
@@ -678,12 +684,12 @@ export class SdkMock {
|
|
|
678
684
|
methods: ['GET'],
|
|
679
685
|
},
|
|
680
686
|
respond,
|
|
681
|
-
});
|
|
687
|
+
}, options);
|
|
682
688
|
},
|
|
683
689
|
/**
|
|
684
690
|
* Mocks the `file.readMedia()` method.
|
|
685
691
|
*/
|
|
686
|
-
readMedia: async (init) => {
|
|
692
|
+
readMedia: async (init, options) => {
|
|
687
693
|
const { mock } = this;
|
|
688
694
|
// const respond = init?.response ?? {
|
|
689
695
|
// status: 200,
|
|
@@ -703,12 +709,12 @@ export class SdkMock {
|
|
|
703
709
|
methods: ['GET'],
|
|
704
710
|
},
|
|
705
711
|
respond,
|
|
706
|
-
});
|
|
712
|
+
}, options);
|
|
707
713
|
},
|
|
708
714
|
/**
|
|
709
715
|
* Mocks the `file.readBulk()` method.
|
|
710
716
|
*/
|
|
711
|
-
readBulk: async (init) => {
|
|
717
|
+
readBulk: async (init, options) => {
|
|
712
718
|
const { mock } = this;
|
|
713
719
|
// const respond = init?.response ?? {
|
|
714
720
|
// status: 200,
|
|
@@ -729,12 +735,12 @@ export class SdkMock {
|
|
|
729
735
|
methods: ['POST'],
|
|
730
736
|
},
|
|
731
737
|
respond,
|
|
732
|
-
});
|
|
738
|
+
}, options);
|
|
733
739
|
},
|
|
734
740
|
/**
|
|
735
741
|
* Mocks the `file.patch()` method.
|
|
736
742
|
*/
|
|
737
|
-
patch: async (init) => {
|
|
743
|
+
patch: async (init, options) => {
|
|
738
744
|
const { mock } = this;
|
|
739
745
|
// const respond = init?.response ?? {
|
|
740
746
|
// status: 200,
|
|
@@ -748,12 +754,12 @@ export class SdkMock {
|
|
|
748
754
|
methods: ['PATCH'],
|
|
749
755
|
},
|
|
750
756
|
respond,
|
|
751
|
-
});
|
|
757
|
+
}, options);
|
|
752
758
|
},
|
|
753
759
|
/**
|
|
754
760
|
* Mocks the `file.patchMedia()` method.
|
|
755
761
|
*/
|
|
756
|
-
patchMedia: async (init) => {
|
|
762
|
+
patchMedia: async (init, options) => {
|
|
757
763
|
const { mock } = this;
|
|
758
764
|
// const respond = init?.response ?? {
|
|
759
765
|
// status: 200,
|
|
@@ -767,12 +773,12 @@ export class SdkMock {
|
|
|
767
773
|
methods: ['PATCH'],
|
|
768
774
|
},
|
|
769
775
|
respond,
|
|
770
|
-
});
|
|
776
|
+
}, options);
|
|
771
777
|
},
|
|
772
778
|
/**
|
|
773
779
|
* Mocks the `file.delete()` method.
|
|
774
780
|
*/
|
|
775
|
-
delete: async (init) => {
|
|
781
|
+
delete: async (init, options) => {
|
|
776
782
|
const { mock } = this;
|
|
777
783
|
// const respond = init?.response ?? {
|
|
778
784
|
// status: 204,
|
|
@@ -784,12 +790,12 @@ export class SdkMock {
|
|
|
784
790
|
methods: ['DELETE'],
|
|
785
791
|
},
|
|
786
792
|
respond,
|
|
787
|
-
});
|
|
793
|
+
}, options);
|
|
788
794
|
},
|
|
789
795
|
/**
|
|
790
796
|
* Mocks the `file.deleteBulk()` method.
|
|
791
797
|
*/
|
|
792
|
-
deleteBulk: async (init) => {
|
|
798
|
+
deleteBulk: async (init, options) => {
|
|
793
799
|
const { mock } = this;
|
|
794
800
|
// const respond = init?.response ?? {
|
|
795
801
|
// status: 204,
|
|
@@ -801,12 +807,12 @@ export class SdkMock {
|
|
|
801
807
|
methods: ['DELETE'],
|
|
802
808
|
},
|
|
803
809
|
respond,
|
|
804
|
-
});
|
|
810
|
+
}, options);
|
|
805
811
|
},
|
|
806
812
|
/**
|
|
807
813
|
* Mocks the `file.patchUsers()` method.
|
|
808
814
|
*/
|
|
809
|
-
patchUsers: async (init) => {
|
|
815
|
+
patchUsers: async (init, options) => {
|
|
810
816
|
const { mock } = this;
|
|
811
817
|
// const respond = init?.response ?? {
|
|
812
818
|
// status: 200,
|
|
@@ -820,24 +826,24 @@ export class SdkMock {
|
|
|
820
826
|
methods: ['PATCH'],
|
|
821
827
|
},
|
|
822
828
|
respond,
|
|
823
|
-
});
|
|
829
|
+
}, options);
|
|
824
830
|
},
|
|
825
831
|
/**
|
|
826
832
|
* Mocks the `file.addUser()` method.
|
|
827
833
|
*/
|
|
828
|
-
addUser: async (init) => {
|
|
829
|
-
await this.file.patchUsers(init);
|
|
834
|
+
addUser: async (init, options) => {
|
|
835
|
+
await this.file.patchUsers(init, options);
|
|
830
836
|
},
|
|
831
837
|
/**
|
|
832
838
|
* Mocks the `file.removeUser()` method.
|
|
833
839
|
*/
|
|
834
|
-
removeUser: async (init) => {
|
|
835
|
-
await this.file.patchUsers(init);
|
|
840
|
+
removeUser: async (init, options) => {
|
|
841
|
+
await this.file.patchUsers(init, options);
|
|
836
842
|
},
|
|
837
843
|
/**
|
|
838
844
|
* Mocks the `file.listUsers()` method.
|
|
839
845
|
*/
|
|
840
|
-
listUsers: async (init) => {
|
|
846
|
+
listUsers: async (init, options) => {
|
|
841
847
|
const { mock } = this;
|
|
842
848
|
// const respond = init?.response ?? {
|
|
843
849
|
// status: 200,
|
|
@@ -860,12 +866,12 @@ export class SdkMock {
|
|
|
860
866
|
methods: ['GET'],
|
|
861
867
|
},
|
|
862
868
|
respond,
|
|
863
|
-
});
|
|
869
|
+
}, options);
|
|
864
870
|
},
|
|
865
871
|
/**
|
|
866
872
|
* Mocks the `file.breadcrumbs()` method.
|
|
867
873
|
*/
|
|
868
|
-
breadcrumbs: async (init) => {
|
|
874
|
+
breadcrumbs: async (init, options) => {
|
|
869
875
|
const { mock } = this;
|
|
870
876
|
// const respond = init?.response ?? {
|
|
871
877
|
// status: 200,
|
|
@@ -888,14 +894,14 @@ export class SdkMock {
|
|
|
888
894
|
methods: ['GET'],
|
|
889
895
|
},
|
|
890
896
|
respond,
|
|
891
|
-
});
|
|
897
|
+
}, options);
|
|
892
898
|
},
|
|
893
899
|
};
|
|
894
900
|
/**
|
|
895
901
|
* Shared API mocks.
|
|
896
902
|
*/
|
|
897
903
|
shared = {
|
|
898
|
-
list: async (init) => {
|
|
904
|
+
list: async (init, options) => {
|
|
899
905
|
const { mock } = this;
|
|
900
906
|
// const respond = init?.response ?? {
|
|
901
907
|
// status: 200,
|
|
@@ -918,14 +924,14 @@ export class SdkMock {
|
|
|
918
924
|
methods: ['GET'],
|
|
919
925
|
},
|
|
920
926
|
respond,
|
|
921
|
-
});
|
|
927
|
+
}, options);
|
|
922
928
|
},
|
|
923
929
|
};
|
|
924
930
|
/**
|
|
925
931
|
* Trash API mocks.
|
|
926
932
|
*/
|
|
927
933
|
trash = {
|
|
928
|
-
list: async (init) => {
|
|
934
|
+
list: async (init, options) => {
|
|
929
935
|
const { mock } = this;
|
|
930
936
|
// const respond = init?.response ?? {
|
|
931
937
|
// status: 200,
|
|
@@ -948,9 +954,9 @@ export class SdkMock {
|
|
|
948
954
|
methods: ['GET'],
|
|
949
955
|
},
|
|
950
956
|
respond,
|
|
951
|
-
});
|
|
957
|
+
}, options);
|
|
952
958
|
},
|
|
953
|
-
delete: async (init) => {
|
|
959
|
+
delete: async (init, options) => {
|
|
954
960
|
const { mock } = this;
|
|
955
961
|
// const respond = init?.response ?? {
|
|
956
962
|
// status: 204,
|
|
@@ -962,9 +968,9 @@ export class SdkMock {
|
|
|
962
968
|
methods: ['DELETE'],
|
|
963
969
|
},
|
|
964
970
|
respond,
|
|
965
|
-
});
|
|
971
|
+
}, options);
|
|
966
972
|
},
|
|
967
|
-
restore: async (init) => {
|
|
973
|
+
restore: async (init, options) => {
|
|
968
974
|
const { mock } = this;
|
|
969
975
|
// const respond = init?.response ?? {
|
|
970
976
|
// status: 204,
|
|
@@ -976,9 +982,9 @@ export class SdkMock {
|
|
|
976
982
|
methods: ['POST'],
|
|
977
983
|
},
|
|
978
984
|
respond,
|
|
979
|
-
});
|
|
985
|
+
}, options);
|
|
980
986
|
},
|
|
981
|
-
empty: async (init) => {
|
|
987
|
+
empty: async (init, options) => {
|
|
982
988
|
const { mock } = this;
|
|
983
989
|
// const respond = init?.response ?? {
|
|
984
990
|
// status: 204,
|
|
@@ -990,7 +996,236 @@ export class SdkMock {
|
|
|
990
996
|
methods: ['DELETE'],
|
|
991
997
|
},
|
|
992
998
|
respond,
|
|
993
|
-
});
|
|
999
|
+
}, options);
|
|
1000
|
+
},
|
|
1001
|
+
};
|
|
1002
|
+
/**
|
|
1003
|
+
* Trash Data Catalog mocks.
|
|
1004
|
+
*/
|
|
1005
|
+
dataCatalog = {
|
|
1006
|
+
list: async (init, options) => {
|
|
1007
|
+
const { mock } = this;
|
|
1008
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, () => {
|
|
1009
|
+
const obj = {
|
|
1010
|
+
items: this.gen.dataCatalog.dataCatalogsWithVersion(init?.size ?? 5),
|
|
1011
|
+
cursor: this.createCursorOption(init),
|
|
1012
|
+
};
|
|
1013
|
+
return JSON.stringify(obj);
|
|
1014
|
+
}, init);
|
|
1015
|
+
await mock.add({
|
|
1016
|
+
match: {
|
|
1017
|
+
uri: RouteBuilder.dataCatalog(),
|
|
1018
|
+
methods: ['GET'],
|
|
1019
|
+
},
|
|
1020
|
+
respond,
|
|
1021
|
+
}, options);
|
|
1022
|
+
},
|
|
1023
|
+
listVersions: async (init, options) => {
|
|
1024
|
+
const { mock } = this;
|
|
1025
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, () => {
|
|
1026
|
+
const obj = {
|
|
1027
|
+
items: this.gen.dataCatalog.versionInfos(init?.size ?? 5),
|
|
1028
|
+
cursor: this.createCursorOption(init),
|
|
1029
|
+
};
|
|
1030
|
+
return JSON.stringify(obj);
|
|
1031
|
+
}, init);
|
|
1032
|
+
await mock.add({
|
|
1033
|
+
match: {
|
|
1034
|
+
uri: RouteBuilder.dataCatalogEntryVersions(':id'),
|
|
1035
|
+
methods: ['GET'],
|
|
1036
|
+
},
|
|
1037
|
+
respond,
|
|
1038
|
+
}, options);
|
|
1039
|
+
},
|
|
1040
|
+
publish: async (init, options) => {
|
|
1041
|
+
const { mock } = this;
|
|
1042
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, () => {
|
|
1043
|
+
const obj = this.gen.dataCatalog.dataCatalog();
|
|
1044
|
+
const result = {
|
|
1045
|
+
key: obj.key,
|
|
1046
|
+
item: obj,
|
|
1047
|
+
kind: obj.kind,
|
|
1048
|
+
};
|
|
1049
|
+
return JSON.stringify(result);
|
|
1050
|
+
}, init);
|
|
1051
|
+
await mock.add({
|
|
1052
|
+
match: {
|
|
1053
|
+
uri: RouteBuilder.dataCatalog(),
|
|
1054
|
+
methods: ['POST'],
|
|
1055
|
+
},
|
|
1056
|
+
respond,
|
|
1057
|
+
}, options);
|
|
1058
|
+
},
|
|
1059
|
+
read: async (init, options) => {
|
|
1060
|
+
const { mock } = this;
|
|
1061
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1062
|
+
const obj = this.gen.dataCatalog.dataCatalog({ key: req.params.id });
|
|
1063
|
+
return JSON.stringify(obj);
|
|
1064
|
+
}, init);
|
|
1065
|
+
await mock.add({
|
|
1066
|
+
match: {
|
|
1067
|
+
uri: RouteBuilder.dataCatalogEntry(':id'),
|
|
1068
|
+
methods: ['GET'],
|
|
1069
|
+
},
|
|
1070
|
+
respond,
|
|
1071
|
+
}, options);
|
|
1072
|
+
},
|
|
1073
|
+
deprecate: async (init, options) => {
|
|
1074
|
+
const { mock } = this;
|
|
1075
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1076
|
+
const obj = this.gen.dataCatalog.dataCatalog({ key: req.params.id });
|
|
1077
|
+
const result = {
|
|
1078
|
+
key: obj.key,
|
|
1079
|
+
item: obj,
|
|
1080
|
+
kind: obj.kind,
|
|
1081
|
+
};
|
|
1082
|
+
return JSON.stringify(result);
|
|
1083
|
+
}, init);
|
|
1084
|
+
await mock.add({
|
|
1085
|
+
match: {
|
|
1086
|
+
uri: RouteBuilder.dataCatalogDeprecate(':id'),
|
|
1087
|
+
methods: ['PUT'],
|
|
1088
|
+
},
|
|
1089
|
+
respond,
|
|
1090
|
+
}, options);
|
|
1091
|
+
},
|
|
1092
|
+
unpublish: async (init, options) => {
|
|
1093
|
+
const { mock } = this;
|
|
1094
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1095
|
+
const obj = this.gen.dataCatalog.dataCatalog({ key: req.params.id });
|
|
1096
|
+
const result = {
|
|
1097
|
+
key: obj.key,
|
|
1098
|
+
item: obj,
|
|
1099
|
+
kind: obj.kind,
|
|
1100
|
+
};
|
|
1101
|
+
return JSON.stringify(result);
|
|
1102
|
+
}, init);
|
|
1103
|
+
await mock.add({
|
|
1104
|
+
match: {
|
|
1105
|
+
uri: RouteBuilder.dataCatalogUnpublish(':id'),
|
|
1106
|
+
methods: ['PUT'],
|
|
1107
|
+
},
|
|
1108
|
+
respond,
|
|
1109
|
+
}, options);
|
|
1110
|
+
},
|
|
1111
|
+
publishVersion: async (init, options) => {
|
|
1112
|
+
const { mock } = this;
|
|
1113
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1114
|
+
const raw = req.body;
|
|
1115
|
+
const body = JSON.parse(raw);
|
|
1116
|
+
const result = {
|
|
1117
|
+
key: body.key,
|
|
1118
|
+
item: body,
|
|
1119
|
+
kind: body.kind,
|
|
1120
|
+
};
|
|
1121
|
+
return JSON.stringify(result);
|
|
1122
|
+
}, init);
|
|
1123
|
+
await mock.add({
|
|
1124
|
+
match: {
|
|
1125
|
+
uri: RouteBuilder.dataCatalogEntryVersions(':id'),
|
|
1126
|
+
methods: ['POST'],
|
|
1127
|
+
},
|
|
1128
|
+
respond,
|
|
1129
|
+
}, options);
|
|
1130
|
+
},
|
|
1131
|
+
readVersion: async (init, options) => {
|
|
1132
|
+
const { mock } = this;
|
|
1133
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1134
|
+
const obj = this.gen.dataCatalog.dataCatalogVersion({ key: req.params.vid, catalogKey: req.params.id });
|
|
1135
|
+
return JSON.stringify(obj);
|
|
1136
|
+
}, init);
|
|
1137
|
+
await mock.add({
|
|
1138
|
+
match: {
|
|
1139
|
+
uri: RouteBuilder.dataCatalogVersion(':id', ':vid'),
|
|
1140
|
+
methods: ['GET'],
|
|
1141
|
+
},
|
|
1142
|
+
respond,
|
|
1143
|
+
}, options);
|
|
1144
|
+
},
|
|
1145
|
+
listDependencies: async (init, options) => {
|
|
1146
|
+
const { mock } = this;
|
|
1147
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1148
|
+
const requirements = JSON.parse(req.body);
|
|
1149
|
+
const items = [];
|
|
1150
|
+
for (const item of requirements.items) {
|
|
1151
|
+
const domain = new DataDomain({
|
|
1152
|
+
key: item.key,
|
|
1153
|
+
info: { name: `Domain ${item.key}`, version: item.version },
|
|
1154
|
+
});
|
|
1155
|
+
items.push(domain.toJSON());
|
|
1156
|
+
}
|
|
1157
|
+
const obj = {
|
|
1158
|
+
items: items,
|
|
1159
|
+
};
|
|
1160
|
+
return JSON.stringify(obj);
|
|
1161
|
+
}, init);
|
|
1162
|
+
await mock.add({
|
|
1163
|
+
match: {
|
|
1164
|
+
uri: RouteBuilder.dataCatalogDependencies(),
|
|
1165
|
+
methods: ['POST'],
|
|
1166
|
+
},
|
|
1167
|
+
respond,
|
|
1168
|
+
}, options);
|
|
1169
|
+
},
|
|
1170
|
+
deprecateVersion: async (init, options) => {
|
|
1171
|
+
const { mock } = this;
|
|
1172
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1173
|
+
const obj = this.gen.dataCatalog.dataCatalogVersion({ key: req.params.vid, catalogKey: req.params.id });
|
|
1174
|
+
obj.deprecated = true;
|
|
1175
|
+
obj.deprecatedAt = this.gen.faker.date.past().getTime();
|
|
1176
|
+
obj.deprecatedBy = nanoid();
|
|
1177
|
+
const info = JSON.parse(req.body);
|
|
1178
|
+
obj.deprecationReason = info.reason;
|
|
1179
|
+
const result = {
|
|
1180
|
+
key: obj.key,
|
|
1181
|
+
item: obj,
|
|
1182
|
+
kind: obj.kind,
|
|
1183
|
+
};
|
|
1184
|
+
return JSON.stringify(result);
|
|
1185
|
+
}, init);
|
|
1186
|
+
await mock.add({
|
|
1187
|
+
match: {
|
|
1188
|
+
uri: RouteBuilder.dataCatalogVersionDeprecate(':id', ':vid'),
|
|
1189
|
+
methods: ['PUT'],
|
|
1190
|
+
},
|
|
1191
|
+
respond,
|
|
1192
|
+
}, options);
|
|
1193
|
+
},
|
|
1194
|
+
unpublishVersion: async (init, options) => {
|
|
1195
|
+
const { mock } = this;
|
|
1196
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, (req) => {
|
|
1197
|
+
const obj = this.gen.dataCatalog.dataCatalogVersion({ key: req.params.vid, catalogKey: req.params.id });
|
|
1198
|
+
obj.unpublishedAt = this.gen.faker.date.past().getTime();
|
|
1199
|
+
obj.scope = 'private';
|
|
1200
|
+
const result = {
|
|
1201
|
+
key: obj.key,
|
|
1202
|
+
item: obj,
|
|
1203
|
+
kind: obj.kind,
|
|
1204
|
+
};
|
|
1205
|
+
return JSON.stringify(result);
|
|
1206
|
+
}, init);
|
|
1207
|
+
await mock.add({
|
|
1208
|
+
match: {
|
|
1209
|
+
uri: RouteBuilder.dataCatalogVersionUnpublish(':id', ':vid'),
|
|
1210
|
+
methods: ['PUT'],
|
|
1211
|
+
},
|
|
1212
|
+
respond,
|
|
1213
|
+
}, options);
|
|
1214
|
+
},
|
|
1215
|
+
checkPublicationStatus: async (init, options) => {
|
|
1216
|
+
const { mock } = this;
|
|
1217
|
+
const respond = this.createDefaultResponse(200, { 'content-type': 'application/json' }, () => {
|
|
1218
|
+
const obj = this.gen.dataCatalog.dataCatalog();
|
|
1219
|
+
obj.versions = this.gen.dataCatalog.versionInfos(1);
|
|
1220
|
+
return JSON.stringify(obj);
|
|
1221
|
+
}, init);
|
|
1222
|
+
await mock.add({
|
|
1223
|
+
match: {
|
|
1224
|
+
uri: RouteBuilder.dataCatalogStatus(':id'),
|
|
1225
|
+
methods: ['GET'],
|
|
1226
|
+
},
|
|
1227
|
+
respond,
|
|
1228
|
+
}, options);
|
|
994
1229
|
},
|
|
995
1230
|
};
|
|
996
1231
|
}
|