@api-client/core 0.20.9 → 0.20.10
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/build/src/mocking/ModelingMock.d.ts +26 -0
- package/build/src/mocking/ModelingMock.d.ts.map +1 -1
- package/build/src/mocking/ModelingMock.js +48 -0
- package/build/src/mocking/ModelingMock.js.map +1 -1
- package/build/src/sdk/SdkMock.d.ts +0 -3
- package/build/src/sdk/SdkMock.d.ts.map +1 -1
- package/build/src/sdk/SdkMock.js +60 -86
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/mocking/ModelingMock.ts +54 -0
- package/src/sdk/SdkMock.ts +60 -95
package/package.json
CHANGED
|
@@ -10,6 +10,9 @@ import { DataCatalog } from './lib/DataCatalog.js'
|
|
|
10
10
|
import { Permission } from './lib/Permission.js'
|
|
11
11
|
import { Ai } from './lib/Ai.js'
|
|
12
12
|
import { Deployment } from './lib/Deployment.js'
|
|
13
|
+
import type { MockListResult } from '../sdk/SdkMock.js'
|
|
14
|
+
import { ResourceResponse } from '../sdk/SdkBase.js'
|
|
15
|
+
import { ContextListResult } from '../events/BaseEvents.js'
|
|
13
16
|
|
|
14
17
|
export class ModelingMock {
|
|
15
18
|
faker: Faker = faker
|
|
@@ -24,4 +27,55 @@ export class ModelingMock {
|
|
|
24
27
|
permission = new Permission()
|
|
25
28
|
ai = new Ai()
|
|
26
29
|
deployments = new Deployment()
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Wraps a single resource in a standard API resource response structure and serializes it to a JSON string.
|
|
33
|
+
*
|
|
34
|
+
* @param resource - The resource object to wrap.
|
|
35
|
+
* @returns A JSON string representation of the wrapped resource.
|
|
36
|
+
*/
|
|
37
|
+
public wrapResource<T extends object>(resource: T): string {
|
|
38
|
+
const wrapper: ResourceResponse<T> = {
|
|
39
|
+
data: resource,
|
|
40
|
+
}
|
|
41
|
+
return JSON.stringify(wrapper)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Wraps a list of items in a standard API list response structure, including an optional pagination cursor,
|
|
46
|
+
* and serializes it to a JSON string.
|
|
47
|
+
*
|
|
48
|
+
* @param items - The array of items to wrap.
|
|
49
|
+
* @param init - Optional configuration for the mock list result, such as cursor settings.
|
|
50
|
+
* @returns A JSON string representation of the wrapped list.
|
|
51
|
+
*/
|
|
52
|
+
public wrapList<T extends object>(items: (T | undefined)[], init?: MockListResult): string {
|
|
53
|
+
const obj: ContextListResult<T | undefined> = {
|
|
54
|
+
data: items,
|
|
55
|
+
cursor: this.createCursorOption(init),
|
|
56
|
+
}
|
|
57
|
+
return JSON.stringify(obj)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Generates or determines the pagination cursor based on the provided mock initialization options.
|
|
62
|
+
* If a cursor is explicitly provided, it is returned. If explicitly disabled, it returns undefined.
|
|
63
|
+
* Otherwise, it randomly generates a mock JWT string to simulate a cursor.
|
|
64
|
+
*
|
|
65
|
+
* @param init - Configuration object detailing cursor behavior.
|
|
66
|
+
* @returns The cursor string or undefined if no cursor should be present.
|
|
67
|
+
*/
|
|
68
|
+
protected createCursorOption(init: MockListResult = {}): string | undefined {
|
|
69
|
+
if (init.cursor === false) {
|
|
70
|
+
return undefined
|
|
71
|
+
}
|
|
72
|
+
if (typeof init.cursor === 'string') {
|
|
73
|
+
return init.cursor
|
|
74
|
+
}
|
|
75
|
+
const hasCursor = init.cursor === true ? true : this.faker.datatype.boolean()
|
|
76
|
+
if (!hasCursor) {
|
|
77
|
+
return undefined
|
|
78
|
+
}
|
|
79
|
+
return this.faker.internet.jwt()
|
|
80
|
+
}
|
|
27
81
|
}
|
package/src/sdk/SdkMock.ts
CHANGED
|
@@ -6,12 +6,7 @@ import {
|
|
|
6
6
|
type InterceptOptions,
|
|
7
7
|
type SerializedRequest,
|
|
8
8
|
} from '@jarrodek/amw'
|
|
9
|
-
import {
|
|
10
|
-
isAtomicFilter,
|
|
11
|
-
type ContextChangeRecord,
|
|
12
|
-
type ContextListResult,
|
|
13
|
-
type QueryFilter,
|
|
14
|
-
} from '../events/BaseEvents.js'
|
|
9
|
+
import { isAtomicFilter, type ContextChangeRecord, type QueryFilter } from '../events/BaseEvents.js'
|
|
15
10
|
import { RouteBuilder } from './RouteBuilder.js'
|
|
16
11
|
import { ModelingMock } from '../mocking/ModelingMock.js'
|
|
17
12
|
import type { DataCatalogSchema, DataCatalogStatus } from '../models/DataCatalog.js'
|
|
@@ -23,7 +18,6 @@ import type { AiSessionApp } from '../models/AiSession.js'
|
|
|
23
18
|
import type { DeploymentSchema } from '../models/store/Deployment.js'
|
|
24
19
|
import { DeploymentEnvironment, DeploymentStatus } from '../models/store/Deployment.js'
|
|
25
20
|
import type { CreateDeploymentPayload, DeploymentLatestEnvironments } from './DeploymentsSdk.js'
|
|
26
|
-
import { ResourceResponse } from './SdkBase.js'
|
|
27
21
|
|
|
28
22
|
export interface MockResult {
|
|
29
23
|
/**
|
|
@@ -160,7 +154,7 @@ export class SdkMock {
|
|
|
160
154
|
const respond = this.createDefaultResponse(
|
|
161
155
|
200,
|
|
162
156
|
{ 'content-type': 'application/json' },
|
|
163
|
-
() => this.wrapList(this.gen.organization.organizations(init?.size ?? 5), init),
|
|
157
|
+
() => this.gen.wrapList(this.gen.organization.organizations(init?.size ?? 5), init),
|
|
164
158
|
init
|
|
165
159
|
)
|
|
166
160
|
await mock.add(
|
|
@@ -184,7 +178,7 @@ export class SdkMock {
|
|
|
184
178
|
const respond = this.createDefaultResponse(
|
|
185
179
|
200,
|
|
186
180
|
{ 'content-type': 'application/json' },
|
|
187
|
-
() => this.wrapResource(this.gen.organization.organization()),
|
|
181
|
+
() => this.gen.wrapResource(this.gen.organization.organization()),
|
|
188
182
|
init
|
|
189
183
|
)
|
|
190
184
|
await mock.add(
|
|
@@ -205,7 +199,7 @@ export class SdkMock {
|
|
|
205
199
|
const respond = this.createDefaultResponse(
|
|
206
200
|
200,
|
|
207
201
|
{ 'content-type': 'application/json' },
|
|
208
|
-
() => this.wrapList(this.gen.invitation.invitations(init?.size ?? 5), init),
|
|
202
|
+
() => this.gen.wrapList(this.gen.invitation.invitations(init?.size ?? 5), init),
|
|
209
203
|
init
|
|
210
204
|
)
|
|
211
205
|
await mock.add(
|
|
@@ -224,7 +218,7 @@ export class SdkMock {
|
|
|
224
218
|
const respond = this.createDefaultResponse(
|
|
225
219
|
200,
|
|
226
220
|
{ 'content-type': 'application/json' },
|
|
227
|
-
() => this.wrapResource(this.gen.invitation.invitation()),
|
|
221
|
+
() => this.gen.wrapResource(this.gen.invitation.invitation()),
|
|
228
222
|
init
|
|
229
223
|
)
|
|
230
224
|
await mock.add(
|
|
@@ -243,7 +237,7 @@ export class SdkMock {
|
|
|
243
237
|
const respond = this.createDefaultResponse(
|
|
244
238
|
200,
|
|
245
239
|
{ 'content-type': 'application/json' },
|
|
246
|
-
() => this.wrapResource(this.gen.invitation.invitation()),
|
|
240
|
+
() => this.gen.wrapResource(this.gen.invitation.invitation()),
|
|
247
241
|
init
|
|
248
242
|
)
|
|
249
243
|
|
|
@@ -263,7 +257,7 @@ export class SdkMock {
|
|
|
263
257
|
const respond = this.createDefaultResponse(
|
|
264
258
|
200,
|
|
265
259
|
{ 'content-type': 'application/json' },
|
|
266
|
-
() => this.wrapResource(this.gen.invitation.invitation()),
|
|
260
|
+
() => this.gen.wrapResource(this.gen.invitation.invitation()),
|
|
267
261
|
init
|
|
268
262
|
)
|
|
269
263
|
|
|
@@ -283,7 +277,7 @@ export class SdkMock {
|
|
|
283
277
|
const respond = this.createDefaultResponse(
|
|
284
278
|
200,
|
|
285
279
|
{ 'content-type': 'application/json' },
|
|
286
|
-
() => this.wrapResource(this.gen.invitation.invitation()),
|
|
280
|
+
() => this.gen.wrapResource(this.gen.invitation.invitation()),
|
|
287
281
|
init
|
|
288
282
|
)
|
|
289
283
|
|
|
@@ -303,7 +297,7 @@ export class SdkMock {
|
|
|
303
297
|
const respond = this.createDefaultResponse(
|
|
304
298
|
200,
|
|
305
299
|
{ 'content-type': 'application/json' },
|
|
306
|
-
() => this.wrapResource(this.gen.invitation.invitation()),
|
|
300
|
+
() => this.gen.wrapResource(this.gen.invitation.invitation()),
|
|
307
301
|
init
|
|
308
302
|
)
|
|
309
303
|
await mock.add(
|
|
@@ -322,7 +316,7 @@ export class SdkMock {
|
|
|
322
316
|
const respond = this.createDefaultResponse(
|
|
323
317
|
200,
|
|
324
318
|
{ 'content-type': 'application/json' },
|
|
325
|
-
() => this.wrapResource(this.gen.invitation.invitation()),
|
|
319
|
+
() => this.gen.wrapResource(this.gen.invitation.invitation()),
|
|
326
320
|
init
|
|
327
321
|
)
|
|
328
322
|
|
|
@@ -345,7 +339,7 @@ export class SdkMock {
|
|
|
345
339
|
const respond = this.createDefaultResponse(
|
|
346
340
|
200,
|
|
347
341
|
{ 'content-type': 'application/json' },
|
|
348
|
-
() => this.wrapList(this.gen.users.users(init?.size ?? 5), init),
|
|
342
|
+
() => this.gen.wrapList(this.gen.users.users(init?.size ?? 5), init),
|
|
349
343
|
init
|
|
350
344
|
)
|
|
351
345
|
await mock.add(
|
|
@@ -364,7 +358,7 @@ export class SdkMock {
|
|
|
364
358
|
const respond = this.createDefaultResponse(
|
|
365
359
|
200,
|
|
366
360
|
{ 'content-type': 'application/json' },
|
|
367
|
-
() => this.wrapResource(this.gen.users.user()),
|
|
361
|
+
() => this.gen.wrapResource(this.gen.users.user()),
|
|
368
362
|
init
|
|
369
363
|
)
|
|
370
364
|
await mock.add(
|
|
@@ -384,7 +378,7 @@ export class SdkMock {
|
|
|
384
378
|
const respond = this.createDefaultResponse(
|
|
385
379
|
200,
|
|
386
380
|
{ 'content-type': 'application/json' },
|
|
387
|
-
() => this.wrapList(this.gen.users.users(init?.size ?? 5), init),
|
|
381
|
+
() => this.gen.wrapList(this.gen.users.users(init?.size ?? 5), init),
|
|
388
382
|
init
|
|
389
383
|
)
|
|
390
384
|
await mock.add(
|
|
@@ -403,7 +397,7 @@ export class SdkMock {
|
|
|
403
397
|
const respond = this.createDefaultResponse(
|
|
404
398
|
200,
|
|
405
399
|
{ 'content-type': 'application/json' },
|
|
406
|
-
() => this.wrapResource(this.gen.users.user()),
|
|
400
|
+
() => this.gen.wrapResource(this.gen.users.user()),
|
|
407
401
|
init
|
|
408
402
|
)
|
|
409
403
|
await mock.add(
|
|
@@ -422,7 +416,7 @@ export class SdkMock {
|
|
|
422
416
|
const respond = this.createDefaultResponse(
|
|
423
417
|
200,
|
|
424
418
|
{ 'content-type': 'application/json' },
|
|
425
|
-
() => this.wrapResource(this.gen.users.user()),
|
|
419
|
+
() => this.gen.wrapResource(this.gen.users.user()),
|
|
426
420
|
init
|
|
427
421
|
)
|
|
428
422
|
await mock.add(
|
|
@@ -462,7 +456,7 @@ export class SdkMock {
|
|
|
462
456
|
const respond = this.createDefaultResponse(
|
|
463
457
|
200,
|
|
464
458
|
{ 'content-type': 'application/json' },
|
|
465
|
-
() => this.wrapResource(this.gen.organization.organizationSlugValidateResponse()),
|
|
459
|
+
() => this.gen.wrapResource(this.gen.organization.organizationSlugValidateResponse()),
|
|
466
460
|
init
|
|
467
461
|
)
|
|
468
462
|
await mock.add(
|
|
@@ -486,7 +480,7 @@ export class SdkMock {
|
|
|
486
480
|
const respond = this.createDefaultResponse(
|
|
487
481
|
200,
|
|
488
482
|
{ 'content-type': 'application/json' },
|
|
489
|
-
() => this.wrapResource(this.gen.organization.organizationSlugGenerateResponse()),
|
|
483
|
+
() => this.gen.wrapResource(this.gen.organization.organizationSlugGenerateResponse()),
|
|
490
484
|
init
|
|
491
485
|
)
|
|
492
486
|
await mock.add(
|
|
@@ -516,7 +510,7 @@ export class SdkMock {
|
|
|
516
510
|
const respond = this.createDefaultResponse(
|
|
517
511
|
200,
|
|
518
512
|
{ 'content-type': 'application/json' },
|
|
519
|
-
() => this.wrapList(this.gen.group.groups(init?.size ?? 5), init),
|
|
513
|
+
() => this.gen.wrapList(this.gen.group.groups(init?.size ?? 5), init),
|
|
520
514
|
init
|
|
521
515
|
)
|
|
522
516
|
await mock.add(
|
|
@@ -540,7 +534,7 @@ export class SdkMock {
|
|
|
540
534
|
const respond = this.createDefaultResponse(
|
|
541
535
|
201,
|
|
542
536
|
{ 'content-type': 'application/json' },
|
|
543
|
-
() => this.wrapResource(this.gen.group.group()),
|
|
537
|
+
() => this.gen.wrapResource(this.gen.group.group()),
|
|
544
538
|
init
|
|
545
539
|
)
|
|
546
540
|
await mock.add(
|
|
@@ -564,7 +558,7 @@ export class SdkMock {
|
|
|
564
558
|
const respond = this.createDefaultResponse(
|
|
565
559
|
200,
|
|
566
560
|
{ 'content-type': 'application/json' },
|
|
567
|
-
() => this.wrapResource(this.gen.group.group()),
|
|
561
|
+
() => this.gen.wrapResource(this.gen.group.group()),
|
|
568
562
|
init
|
|
569
563
|
)
|
|
570
564
|
await mock.add(
|
|
@@ -606,7 +600,7 @@ export class SdkMock {
|
|
|
606
600
|
const respond = this.createDefaultResponse(
|
|
607
601
|
200,
|
|
608
602
|
{ 'content-type': 'application/json' },
|
|
609
|
-
() => this.wrapResource(this.gen.group.group()),
|
|
603
|
+
() => this.gen.wrapResource(this.gen.group.group()),
|
|
610
604
|
init
|
|
611
605
|
)
|
|
612
606
|
await mock.add(
|
|
@@ -629,7 +623,7 @@ export class SdkMock {
|
|
|
629
623
|
const respond = this.createDefaultResponse(
|
|
630
624
|
200,
|
|
631
625
|
{ 'content-type': 'application/json' },
|
|
632
|
-
() => this.wrapResource(this.gen.group.group()),
|
|
626
|
+
() => this.gen.wrapResource(this.gen.group.group()),
|
|
633
627
|
init
|
|
634
628
|
)
|
|
635
629
|
await mock.add(
|
|
@@ -652,7 +646,7 @@ export class SdkMock {
|
|
|
652
646
|
const respond = this.createDefaultResponse(
|
|
653
647
|
200,
|
|
654
648
|
{ 'content-type': 'application/json' },
|
|
655
|
-
() => this.wrapList(this.gen.ai.sessions('general', init?.size ?? 5), init),
|
|
649
|
+
() => this.gen.wrapList(this.gen.ai.sessions('general', init?.size ?? 5), init),
|
|
656
650
|
init
|
|
657
651
|
)
|
|
658
652
|
await mock.add(
|
|
@@ -671,7 +665,7 @@ export class SdkMock {
|
|
|
671
665
|
const respond = this.createDefaultResponse(
|
|
672
666
|
201,
|
|
673
667
|
{ 'content-type': 'application/json' },
|
|
674
|
-
() => this.wrapResource(this.gen.ai.session()),
|
|
668
|
+
() => this.gen.wrapResource(this.gen.ai.session()),
|
|
675
669
|
init
|
|
676
670
|
)
|
|
677
671
|
await mock.add(
|
|
@@ -690,7 +684,7 @@ export class SdkMock {
|
|
|
690
684
|
const respond = this.createDefaultResponse(
|
|
691
685
|
200,
|
|
692
686
|
{ 'content-type': 'application/json' },
|
|
693
|
-
() => this.wrapResource(this.gen.ai.session()),
|
|
687
|
+
() => this.gen.wrapResource(this.gen.ai.session()),
|
|
694
688
|
init
|
|
695
689
|
)
|
|
696
690
|
await mock.add(
|
|
@@ -709,7 +703,7 @@ export class SdkMock {
|
|
|
709
703
|
const respond = this.createDefaultResponse(
|
|
710
704
|
200,
|
|
711
705
|
{ 'content-type': 'application/json' },
|
|
712
|
-
() => this.wrapResource(this.gen.ai.session()),
|
|
706
|
+
() => this.gen.wrapResource(this.gen.ai.session()),
|
|
713
707
|
init
|
|
714
708
|
)
|
|
715
709
|
await mock.add(
|
|
@@ -745,7 +739,7 @@ export class SdkMock {
|
|
|
745
739
|
const respond = this.createDefaultResponse(
|
|
746
740
|
200,
|
|
747
741
|
{ 'content-type': 'application/json' },
|
|
748
|
-
() => this.wrapList(this.gen.ai.messages(init?.size ?? 5), init),
|
|
742
|
+
() => this.gen.wrapList(this.gen.ai.messages(init?.size ?? 5), init),
|
|
749
743
|
init
|
|
750
744
|
)
|
|
751
745
|
await mock.add(
|
|
@@ -764,7 +758,7 @@ export class SdkMock {
|
|
|
764
758
|
const respond = this.createDefaultResponse(
|
|
765
759
|
200,
|
|
766
760
|
{ 'content-type': 'application/json' },
|
|
767
|
-
() => this.wrapResource(this.gen.ai.message()),
|
|
761
|
+
() => this.gen.wrapResource(this.gen.ai.message()),
|
|
768
762
|
init
|
|
769
763
|
)
|
|
770
764
|
await mock.add(
|
|
@@ -829,7 +823,7 @@ export class SdkMock {
|
|
|
829
823
|
const respond = this.createDefaultResponse(
|
|
830
824
|
200,
|
|
831
825
|
{ 'content-type': 'application/json' },
|
|
832
|
-
() => this.wrapResource(this.gen.users.user()),
|
|
826
|
+
() => this.gen.wrapResource(this.gen.users.user()),
|
|
833
827
|
init
|
|
834
828
|
)
|
|
835
829
|
await mock.add(
|
|
@@ -857,7 +851,7 @@ export class SdkMock {
|
|
|
857
851
|
const respond = this.createDefaultResponse(
|
|
858
852
|
200,
|
|
859
853
|
{ 'content-type': 'application/json' },
|
|
860
|
-
() => this.wrapList(this.gen.files.files(init?.size ?? 5), init),
|
|
854
|
+
() => this.gen.wrapList(this.gen.files.files(init?.size ?? 5), init),
|
|
861
855
|
init
|
|
862
856
|
)
|
|
863
857
|
await mock.add(
|
|
@@ -880,7 +874,7 @@ export class SdkMock {
|
|
|
880
874
|
const respond = this.createDefaultResponse(
|
|
881
875
|
201,
|
|
882
876
|
{ 'content-type': 'application/json' },
|
|
883
|
-
() => this.wrapResource(this.gen.files.file()),
|
|
877
|
+
() => this.gen.wrapResource(this.gen.files.file()),
|
|
884
878
|
init
|
|
885
879
|
)
|
|
886
880
|
await mock.add(
|
|
@@ -932,7 +926,7 @@ export class SdkMock {
|
|
|
932
926
|
const respond = this.createDefaultResponse(
|
|
933
927
|
201,
|
|
934
928
|
{ 'content-type': 'application/json' },
|
|
935
|
-
() => this.wrapResource(this.gen.files.folder()),
|
|
929
|
+
() => this.gen.wrapResource(this.gen.files.folder()),
|
|
936
930
|
init
|
|
937
931
|
)
|
|
938
932
|
await mock.add(
|
|
@@ -955,7 +949,7 @@ export class SdkMock {
|
|
|
955
949
|
const respond = this.createDefaultResponse(
|
|
956
950
|
200,
|
|
957
951
|
{ 'content-type': 'application/json' },
|
|
958
|
-
() => this.wrapResource(this.gen.files.file()),
|
|
952
|
+
() => this.gen.wrapResource(this.gen.files.file()),
|
|
959
953
|
init
|
|
960
954
|
)
|
|
961
955
|
await mock.add(
|
|
@@ -981,7 +975,7 @@ export class SdkMock {
|
|
|
981
975
|
'content-type': 'application/json',
|
|
982
976
|
'x-version': `${this.gen.faker.number.int({ min: 1, max: 100 })}`,
|
|
983
977
|
},
|
|
984
|
-
() => this.wrapResource({ data: this.gen.faker.lorem.sentences() }),
|
|
978
|
+
() => this.gen.wrapResource({ data: this.gen.faker.lorem.sentences() }),
|
|
985
979
|
init
|
|
986
980
|
)
|
|
987
981
|
await mock.add(
|
|
@@ -1004,7 +998,7 @@ export class SdkMock {
|
|
|
1004
998
|
const respond = this.createDefaultResponse(
|
|
1005
999
|
200,
|
|
1006
1000
|
{ 'content-type': 'application/json' },
|
|
1007
|
-
() => this.wrapList(this.gen.files.files(init?.size ?? 5), { cursor: false }),
|
|
1001
|
+
() => this.gen.wrapList(this.gen.files.files(init?.size ?? 5), { cursor: false }),
|
|
1008
1002
|
init
|
|
1009
1003
|
)
|
|
1010
1004
|
await mock.add(
|
|
@@ -1027,7 +1021,7 @@ export class SdkMock {
|
|
|
1027
1021
|
const respond = this.createDefaultResponse(
|
|
1028
1022
|
200,
|
|
1029
1023
|
{ 'content-type': 'application/json' },
|
|
1030
|
-
() => this.wrapResource(this.gen.files.file()),
|
|
1024
|
+
() => this.gen.wrapResource(this.gen.files.file()),
|
|
1031
1025
|
init
|
|
1032
1026
|
)
|
|
1033
1027
|
await mock.add(
|
|
@@ -1050,7 +1044,7 @@ export class SdkMock {
|
|
|
1050
1044
|
const respond = this.createDefaultResponse(
|
|
1051
1045
|
200,
|
|
1052
1046
|
{ 'content-type': 'application/json' },
|
|
1053
|
-
() => this.wrapResource(this.gen.patch.mediaPatchRevision()),
|
|
1047
|
+
() => this.gen.wrapResource(this.gen.patch.mediaPatchRevision()),
|
|
1054
1048
|
init
|
|
1055
1049
|
)
|
|
1056
1050
|
await mock.add(
|
|
@@ -1109,7 +1103,7 @@ export class SdkMock {
|
|
|
1109
1103
|
const respond = this.createDefaultResponse(
|
|
1110
1104
|
200,
|
|
1111
1105
|
{ 'content-type': 'application/json' },
|
|
1112
|
-
() => this.wrapResource(this.gen.files.file()),
|
|
1106
|
+
() => this.gen.wrapResource(this.gen.files.file()),
|
|
1113
1107
|
init
|
|
1114
1108
|
)
|
|
1115
1109
|
await mock.add(
|
|
@@ -1146,7 +1140,7 @@ export class SdkMock {
|
|
|
1146
1140
|
const respond = this.createDefaultResponse(
|
|
1147
1141
|
200,
|
|
1148
1142
|
{ 'content-type': 'application/json' },
|
|
1149
|
-
() => this.wrapList(this.gen.users.users(init?.size ?? 5), init),
|
|
1143
|
+
() => this.gen.wrapList(this.gen.users.users(init?.size ?? 5), init),
|
|
1150
1144
|
init
|
|
1151
1145
|
)
|
|
1152
1146
|
await mock.add(
|
|
@@ -1169,7 +1163,7 @@ export class SdkMock {
|
|
|
1169
1163
|
const respond = this.createDefaultResponse(
|
|
1170
1164
|
200,
|
|
1171
1165
|
{ 'content-type': 'application/json' },
|
|
1172
|
-
() => this.wrapList(this.gen.files.fileBreadcrumbs(init?.size ?? 5), init),
|
|
1166
|
+
() => this.gen.wrapList(this.gen.files.fileBreadcrumbs(init?.size ?? 5), init),
|
|
1173
1167
|
init
|
|
1174
1168
|
)
|
|
1175
1169
|
await mock.add(
|
|
@@ -1199,7 +1193,7 @@ export class SdkMock {
|
|
|
1199
1193
|
const respond = this.createDefaultResponse(
|
|
1200
1194
|
200,
|
|
1201
1195
|
{ 'content-type': 'application/json' },
|
|
1202
|
-
() => this.wrapList(this.gen.files.files(init?.size ?? 5), init),
|
|
1196
|
+
() => this.gen.wrapList(this.gen.files.files(init?.size ?? 5), init),
|
|
1203
1197
|
init
|
|
1204
1198
|
)
|
|
1205
1199
|
await mock.add(
|
|
@@ -1224,7 +1218,7 @@ export class SdkMock {
|
|
|
1224
1218
|
const respond = this.createDefaultResponse(
|
|
1225
1219
|
200,
|
|
1226
1220
|
{ 'content-type': 'application/json' },
|
|
1227
|
-
() => this.wrapList(this.gen.trash.trashEntries(init?.size ?? 5), init),
|
|
1221
|
+
() => this.gen.wrapList(this.gen.trash.trashEntries(init?.size ?? 5), init),
|
|
1228
1222
|
init
|
|
1229
1223
|
)
|
|
1230
1224
|
await mock.add(
|
|
@@ -1341,7 +1335,7 @@ export class SdkMock {
|
|
|
1341
1335
|
}
|
|
1342
1336
|
})
|
|
1343
1337
|
}
|
|
1344
|
-
return this.wrapList(data, init)
|
|
1338
|
+
return this.gen.wrapList(data, init)
|
|
1345
1339
|
},
|
|
1346
1340
|
init
|
|
1347
1341
|
)
|
|
@@ -1371,7 +1365,7 @@ export class SdkMock {
|
|
|
1371
1365
|
env: payload.env,
|
|
1372
1366
|
...(payload.env === DeploymentEnvironment.PROD ? { version: payload.version } : {}),
|
|
1373
1367
|
})
|
|
1374
|
-
return this.wrapResource(obj)
|
|
1368
|
+
return this.gen.wrapResource(obj)
|
|
1375
1369
|
},
|
|
1376
1370
|
init
|
|
1377
1371
|
)
|
|
@@ -1396,7 +1390,7 @@ export class SdkMock {
|
|
|
1396
1390
|
key: req.params.id,
|
|
1397
1391
|
orgId: req.params.oid,
|
|
1398
1392
|
})
|
|
1399
|
-
return this.wrapResource(obj)
|
|
1393
|
+
return this.gen.wrapResource(obj)
|
|
1400
1394
|
},
|
|
1401
1395
|
init
|
|
1402
1396
|
)
|
|
@@ -1422,7 +1416,7 @@ export class SdkMock {
|
|
|
1422
1416
|
orgId: req.params.oid,
|
|
1423
1417
|
status: DeploymentStatus.Inactive,
|
|
1424
1418
|
})
|
|
1425
|
-
return this.wrapResource(obj)
|
|
1419
|
+
return this.gen.wrapResource(obj)
|
|
1426
1420
|
},
|
|
1427
1421
|
init
|
|
1428
1422
|
)
|
|
@@ -1461,7 +1455,7 @@ export class SdkMock {
|
|
|
1461
1455
|
if (hasDev) {
|
|
1462
1456
|
obj.dev = this.gen.deployments.deployment()
|
|
1463
1457
|
}
|
|
1464
|
-
return this.wrapResource(obj)
|
|
1458
|
+
return this.gen.wrapResource(obj)
|
|
1465
1459
|
},
|
|
1466
1460
|
init
|
|
1467
1461
|
)
|
|
@@ -1481,7 +1475,7 @@ export class SdkMock {
|
|
|
1481
1475
|
const respond = this.createDefaultResponse(
|
|
1482
1476
|
200,
|
|
1483
1477
|
{ 'content-type': 'application/json' },
|
|
1484
|
-
() => this.wrapList(this.gen.deployments.deploymentApis(init?.size ?? 5), { cursor: false }),
|
|
1478
|
+
() => this.gen.wrapList(this.gen.deployments.deploymentApis(init?.size ?? 5), { cursor: false }),
|
|
1485
1479
|
init
|
|
1486
1480
|
)
|
|
1487
1481
|
await mock.add(
|
|
@@ -1507,7 +1501,7 @@ export class SdkMock {
|
|
|
1507
1501
|
const respond = this.createDefaultResponse(
|
|
1508
1502
|
200,
|
|
1509
1503
|
{ 'content-type': 'application/json' },
|
|
1510
|
-
() => this.wrapList(this.gen.dataCatalog.dataCatalogsWithVersion(init?.size ?? 5), init),
|
|
1504
|
+
() => this.gen.wrapList(this.gen.dataCatalog.dataCatalogsWithVersion(init?.size ?? 5), init),
|
|
1511
1505
|
init
|
|
1512
1506
|
)
|
|
1513
1507
|
await mock.add(
|
|
@@ -1527,7 +1521,7 @@ export class SdkMock {
|
|
|
1527
1521
|
const respond = this.createDefaultResponse(
|
|
1528
1522
|
200,
|
|
1529
1523
|
{ 'content-type': 'application/json' },
|
|
1530
|
-
() => this.wrapList(this.gen.dataCatalog.versionInfos(init?.size ?? 5), init),
|
|
1524
|
+
() => this.gen.wrapList(this.gen.dataCatalog.versionInfos(init?.size ?? 5), init),
|
|
1531
1525
|
init
|
|
1532
1526
|
)
|
|
1533
1527
|
await mock.add(
|
|
@@ -1554,7 +1548,7 @@ export class SdkMock {
|
|
|
1554
1548
|
item: obj,
|
|
1555
1549
|
kind: obj.kind,
|
|
1556
1550
|
}
|
|
1557
|
-
return this.wrapResource(result)
|
|
1551
|
+
return this.gen.wrapResource(result)
|
|
1558
1552
|
},
|
|
1559
1553
|
init
|
|
1560
1554
|
)
|
|
@@ -1577,7 +1571,7 @@ export class SdkMock {
|
|
|
1577
1571
|
{ 'content-type': 'application/json' },
|
|
1578
1572
|
(req: SerializedRequest) => {
|
|
1579
1573
|
const obj = this.gen.dataCatalog.dataCatalog({ key: req.params.id })
|
|
1580
|
-
return this.wrapResource(obj)
|
|
1574
|
+
return this.gen.wrapResource(obj)
|
|
1581
1575
|
},
|
|
1582
1576
|
init
|
|
1583
1577
|
)
|
|
@@ -1605,7 +1599,7 @@ export class SdkMock {
|
|
|
1605
1599
|
item: obj,
|
|
1606
1600
|
kind: obj.kind,
|
|
1607
1601
|
}
|
|
1608
|
-
return this.wrapResource(result)
|
|
1602
|
+
return this.gen.wrapResource(result)
|
|
1609
1603
|
},
|
|
1610
1604
|
init
|
|
1611
1605
|
)
|
|
@@ -1633,7 +1627,7 @@ export class SdkMock {
|
|
|
1633
1627
|
item: obj,
|
|
1634
1628
|
kind: obj.kind,
|
|
1635
1629
|
}
|
|
1636
|
-
return this.wrapResource(result)
|
|
1630
|
+
return this.gen.wrapResource(result)
|
|
1637
1631
|
},
|
|
1638
1632
|
init
|
|
1639
1633
|
)
|
|
@@ -1663,7 +1657,7 @@ export class SdkMock {
|
|
|
1663
1657
|
item: body,
|
|
1664
1658
|
kind: body.kind,
|
|
1665
1659
|
}
|
|
1666
|
-
return this.wrapResource(result)
|
|
1660
|
+
return this.gen.wrapResource(result)
|
|
1667
1661
|
},
|
|
1668
1662
|
init
|
|
1669
1663
|
)
|
|
@@ -1686,7 +1680,7 @@ export class SdkMock {
|
|
|
1686
1680
|
{ 'content-type': 'application/json' },
|
|
1687
1681
|
(req: SerializedRequest) => {
|
|
1688
1682
|
const obj = this.gen.dataCatalog.dataCatalogVersion({ key: req.params.vid, catalogKey: req.params.id })
|
|
1689
|
-
return this.wrapResource(obj)
|
|
1683
|
+
return this.gen.wrapResource(obj)
|
|
1690
1684
|
},
|
|
1691
1685
|
init
|
|
1692
1686
|
)
|
|
@@ -1717,7 +1711,7 @@ export class SdkMock {
|
|
|
1717
1711
|
})
|
|
1718
1712
|
data.push(domain.toJSON())
|
|
1719
1713
|
}
|
|
1720
|
-
return this.wrapList(data, { cursor: false })
|
|
1714
|
+
return this.gen.wrapList(data, { cursor: false })
|
|
1721
1715
|
},
|
|
1722
1716
|
init
|
|
1723
1717
|
)
|
|
@@ -1750,7 +1744,7 @@ export class SdkMock {
|
|
|
1750
1744
|
item: obj,
|
|
1751
1745
|
kind: obj.kind,
|
|
1752
1746
|
}
|
|
1753
|
-
return this.wrapResource(result)
|
|
1747
|
+
return this.gen.wrapResource(result)
|
|
1754
1748
|
},
|
|
1755
1749
|
init
|
|
1756
1750
|
)
|
|
@@ -1780,7 +1774,7 @@ export class SdkMock {
|
|
|
1780
1774
|
item: obj,
|
|
1781
1775
|
kind: obj.kind,
|
|
1782
1776
|
}
|
|
1783
|
-
return this.wrapResource(result)
|
|
1777
|
+
return this.gen.wrapResource(result)
|
|
1784
1778
|
},
|
|
1785
1779
|
init
|
|
1786
1780
|
)
|
|
@@ -1804,7 +1798,7 @@ export class SdkMock {
|
|
|
1804
1798
|
() => {
|
|
1805
1799
|
const obj = this.gen.dataCatalog.dataCatalog() as DataCatalogStatus
|
|
1806
1800
|
obj.versions = this.gen.dataCatalog.versionInfos(1)
|
|
1807
|
-
return this.wrapResource(obj)
|
|
1801
|
+
return this.gen.wrapResource(obj)
|
|
1808
1802
|
},
|
|
1809
1803
|
init
|
|
1810
1804
|
)
|
|
@@ -1854,20 +1848,6 @@ export class SdkMock {
|
|
|
1854
1848
|
return limit
|
|
1855
1849
|
}
|
|
1856
1850
|
|
|
1857
|
-
protected createCursorOption(init: MockListResult = {}): string | undefined {
|
|
1858
|
-
if (init.cursor === false) {
|
|
1859
|
-
return undefined
|
|
1860
|
-
}
|
|
1861
|
-
if (typeof init.cursor === 'string') {
|
|
1862
|
-
return init.cursor
|
|
1863
|
-
}
|
|
1864
|
-
const hasCursor = init.cursor === true ? true : this.gen.faker.datatype.boolean()
|
|
1865
|
-
if (!hasCursor) {
|
|
1866
|
-
return undefined
|
|
1867
|
-
}
|
|
1868
|
-
return this.gen.faker.internet.jwt()
|
|
1869
|
-
}
|
|
1870
|
-
|
|
1871
1851
|
protected createDefaultResponse(
|
|
1872
1852
|
status: number,
|
|
1873
1853
|
headers?: Record<string, string>,
|
|
@@ -1899,19 +1879,4 @@ export class SdkMock {
|
|
|
1899
1879
|
}
|
|
1900
1880
|
return respond
|
|
1901
1881
|
}
|
|
1902
|
-
|
|
1903
|
-
public wrapResource<T extends object>(resource: T): string {
|
|
1904
|
-
const wrapper: ResourceResponse<T> = {
|
|
1905
|
-
data: resource,
|
|
1906
|
-
}
|
|
1907
|
-
return JSON.stringify(wrapper)
|
|
1908
|
-
}
|
|
1909
|
-
|
|
1910
|
-
public wrapList<T extends object>(items: (T | undefined)[], init?: MockListResult): string {
|
|
1911
|
-
const obj: ContextListResult<T | undefined> = {
|
|
1912
|
-
data: items,
|
|
1913
|
-
cursor: this.createCursorOption(init),
|
|
1914
|
-
}
|
|
1915
|
-
return JSON.stringify(obj)
|
|
1916
|
-
}
|
|
1917
1882
|
}
|