@api-client/core 0.19.36 → 0.19.37
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/events/BaseEvents.d.ts +14 -4
- package/build/src/events/BaseEvents.d.ts.map +1 -1
- package/build/src/events/BaseEvents.js +14 -0
- package/build/src/events/BaseEvents.js.map +1 -1
- package/build/src/mocking/lib/Deployment.d.ts +3 -0
- package/build/src/mocking/lib/Deployment.d.ts.map +1 -1
- package/build/src/mocking/lib/Deployment.js +11 -0
- package/build/src/mocking/lib/Deployment.js.map +1 -1
- package/build/src/models/store/Deployment.d.ts +4 -4
- package/build/src/models/store/Deployment.d.ts.map +1 -1
- package/build/src/models/store/Deployment.js +4 -4
- package/build/src/models/store/Deployment.js.map +1 -1
- package/build/src/sdk/AiSdk.js +2 -2
- package/build/src/sdk/AiSdk.js.map +1 -1
- package/build/src/sdk/DeploymentsSdk.d.ts +50 -5
- package/build/src/sdk/DeploymentsSdk.d.ts.map +1 -1
- package/build/src/sdk/DeploymentsSdk.js +31 -11
- package/build/src/sdk/DeploymentsSdk.js.map +1 -1
- package/build/src/sdk/FilesSdk.js +4 -4
- package/build/src/sdk/FilesSdk.js.map +1 -1
- package/build/src/sdk/HistorySdk.js +3 -3
- package/build/src/sdk/HistorySdk.js.map +1 -1
- package/build/src/sdk/OrganizationsSdk.js +4 -4
- package/build/src/sdk/OrganizationsSdk.js.map +1 -1
- package/build/src/sdk/RevisionsSdk.js +1 -1
- package/build/src/sdk/RevisionsSdk.js.map +1 -1
- package/build/src/sdk/RouteBuilder.d.ts +2 -4
- package/build/src/sdk/RouteBuilder.d.ts.map +1 -1
- package/build/src/sdk/RouteBuilder.js +5 -8
- package/build/src/sdk/RouteBuilder.js.map +1 -1
- package/build/src/sdk/SdkBase.d.ts +2 -2
- package/build/src/sdk/SdkBase.d.ts.map +1 -1
- package/build/src/sdk/SdkBase.js +6 -5
- package/build/src/sdk/SdkBase.js.map +1 -1
- package/build/src/sdk/SdkMock.d.ts +17 -4
- package/build/src/sdk/SdkMock.d.ts.map +1 -1
- package/build/src/sdk/SdkMock.js +158 -145
- package/build/src/sdk/SdkMock.js.map +1 -1
- package/build/src/sdk/SharedSdk.js +1 -1
- package/build/src/sdk/SharedSdk.js.map +1 -1
- package/build/src/sdk/TrashSdk.js +1 -1
- package/build/src/sdk/TrashSdk.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/events/BaseEvents.ts +20 -4
- package/src/mocking/lib/Deployment.ts +14 -0
- package/src/models/store/Deployment.ts +4 -4
- package/src/sdk/AiSdk.ts +2 -2
- package/src/sdk/DeploymentsSdk.ts +66 -19
- package/src/sdk/FilesSdk.ts +4 -4
- package/src/sdk/HistorySdk.ts +3 -3
- package/src/sdk/OrganizationsSdk.ts +4 -4
- package/src/sdk/RevisionsSdk.ts +1 -1
- package/src/sdk/RouteBuilder.ts +6 -11
- package/src/sdk/SdkBase.ts +6 -6
- package/src/sdk/SdkMock.ts +177 -154
- package/src/sdk/SharedSdk.ts +1 -1
- package/src/sdk/TrashSdk.ts +1 -1
package/src/sdk/SdkMock.ts
CHANGED
|
@@ -11,7 +11,13 @@ import type { GroupSchema } from '../models/store/Group.js'
|
|
|
11
11
|
import type { UserSchema } from '../models/store/User.js'
|
|
12
12
|
import type { InvitationSchema } from '../models/store/Invitation.js'
|
|
13
13
|
import { type FileSchema, type FileBreadcrumb } from '../models/store/File.js'
|
|
14
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
isAtomicFilter,
|
|
16
|
+
type ContextChangeRecord,
|
|
17
|
+
type ContextListResult,
|
|
18
|
+
type IBulkOperationResult,
|
|
19
|
+
type QueryFilter,
|
|
20
|
+
} from '../events/BaseEvents.js'
|
|
15
21
|
import type { TrashEntry } from '../models/TrashEntry.js'
|
|
16
22
|
import { RouteBuilder } from './RouteBuilder.js'
|
|
17
23
|
import { ModelingMock } from '../mocking/ModelingMock.js'
|
|
@@ -29,7 +35,7 @@ import type { AiSessionSchema, AiSessionApp } from '../models/AiSession.js'
|
|
|
29
35
|
import type { AiMessageSchema } from '../models/AiMessage.js'
|
|
30
36
|
import type { DeploymentSchema } from '../models/store/Deployment.js'
|
|
31
37
|
import { DeploymentEnvironment } from '../models/store/Deployment.js'
|
|
32
|
-
import type { CreateDeploymentPayload } from './DeploymentsSdk.js'
|
|
38
|
+
import type { CreateDeploymentPayload, DeploymentApi, DeploymentLatestEnvironmentsResponse } from './DeploymentsSdk.js'
|
|
33
39
|
|
|
34
40
|
export interface MockResult {
|
|
35
41
|
/**
|
|
@@ -152,49 +158,6 @@ export class SdkMock {
|
|
|
152
158
|
return this.handler
|
|
153
159
|
}
|
|
154
160
|
|
|
155
|
-
protected createCursorOption(init: MockListResult = {}): string | undefined {
|
|
156
|
-
if (init.cursor === false) {
|
|
157
|
-
return undefined
|
|
158
|
-
}
|
|
159
|
-
const hasCursor = init.cursor === true ? true : this.gen.faker.datatype.boolean()
|
|
160
|
-
if (!hasCursor) {
|
|
161
|
-
return undefined
|
|
162
|
-
}
|
|
163
|
-
return this.gen.faker.internet.jwt()
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
protected createDefaultResponse(
|
|
167
|
-
status: number,
|
|
168
|
-
headers?: Record<string, string>,
|
|
169
|
-
body?: (req: SerializedRequest) => string,
|
|
170
|
-
userConfig?: MockResult
|
|
171
|
-
): ResponseGenerator {
|
|
172
|
-
let respond: ResponseGenerator
|
|
173
|
-
if (userConfig?.response) {
|
|
174
|
-
// user config takes precedence
|
|
175
|
-
respond = userConfig.response
|
|
176
|
-
} else {
|
|
177
|
-
respond = {}
|
|
178
|
-
}
|
|
179
|
-
// Set defaults if not provided in user config
|
|
180
|
-
if (!respond.status) {
|
|
181
|
-
respond.status = status
|
|
182
|
-
}
|
|
183
|
-
// only set headers if the user didn't configure the response only.
|
|
184
|
-
// The user may want to remove default headers.
|
|
185
|
-
if (!userConfig || !userConfig.response) {
|
|
186
|
-
respond.headers = headers
|
|
187
|
-
}
|
|
188
|
-
if (!respond.body && userConfig?.forceBody && body) {
|
|
189
|
-
// when body is missing and forceBody is set, generate the body
|
|
190
|
-
respond.body = (req: SerializedRequest) => body(req)
|
|
191
|
-
} else if (body && (!userConfig || !userConfig.response)) {
|
|
192
|
-
// we set the body by default when the user config is missing
|
|
193
|
-
respond.body = (req: SerializedRequest) => body(req)
|
|
194
|
-
}
|
|
195
|
-
return respond
|
|
196
|
-
}
|
|
197
|
-
|
|
198
161
|
/**
|
|
199
162
|
* Organization API mocks.
|
|
200
163
|
*/
|
|
@@ -205,20 +168,12 @@ export class SdkMock {
|
|
|
205
168
|
*/
|
|
206
169
|
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
207
170
|
const { mock } = this
|
|
208
|
-
// const respond = init?.response ?? {
|
|
209
|
-
// status: 200,
|
|
210
|
-
// headers: { 'content-type': 'application/json' },
|
|
211
|
-
// body: JSON.stringify({
|
|
212
|
-
// items: this.gen.organization.organizations(init?.size ?? 5),
|
|
213
|
-
// cursor: this.createCursorOption(init),
|
|
214
|
-
// } as ContextListResult<OrganizationSchema>),
|
|
215
|
-
// }
|
|
216
171
|
const respond = this.createDefaultResponse(
|
|
217
172
|
200,
|
|
218
173
|
{ 'content-type': 'application/json' },
|
|
219
174
|
() =>
|
|
220
175
|
JSON.stringify({
|
|
221
|
-
|
|
176
|
+
data: this.gen.organization.organizations(init?.size ?? 5),
|
|
222
177
|
cursor: this.createCursorOption(init),
|
|
223
178
|
} as ContextListResult<OrganizationSchema>),
|
|
224
179
|
init
|
|
@@ -267,20 +222,12 @@ export class SdkMock {
|
|
|
267
222
|
invitations: {
|
|
268
223
|
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
269
224
|
const { mock } = this
|
|
270
|
-
// const respond = init?.response ?? {
|
|
271
|
-
// status: 200,
|
|
272
|
-
// headers: { 'content-type': 'application/json' },
|
|
273
|
-
// body: JSON.stringify({
|
|
274
|
-
// items: this.gen.invitation.invitations(init?.size ?? 5),
|
|
275
|
-
// cursor: this.createCursorOption(init),
|
|
276
|
-
// } as ContextListResult<InvitationSchema>),
|
|
277
|
-
// }
|
|
278
225
|
const respond = this.createDefaultResponse(
|
|
279
226
|
200,
|
|
280
227
|
{ 'content-type': 'application/json' },
|
|
281
228
|
() => {
|
|
282
229
|
const obj: ContextListResult<InvitationSchema> = {
|
|
283
|
-
|
|
230
|
+
data: this.gen.invitation.invitations(init?.size ?? 5),
|
|
284
231
|
cursor: this.createCursorOption(init),
|
|
285
232
|
}
|
|
286
233
|
return JSON.stringify(obj)
|
|
@@ -451,20 +398,12 @@ export class SdkMock {
|
|
|
451
398
|
users: {
|
|
452
399
|
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
453
400
|
const { mock } = this
|
|
454
|
-
// const respond = init?.response ?? {
|
|
455
|
-
// status: 200,
|
|
456
|
-
// headers: { 'content-type': 'application/json' },
|
|
457
|
-
// body: JSON.stringify({
|
|
458
|
-
// items: this.gen.users.users(init?.size ?? 5),
|
|
459
|
-
// cursor: this.createCursorOption(init),
|
|
460
|
-
// } as ContextListResult<UserSchema>),
|
|
461
|
-
// }
|
|
462
401
|
const respond = this.createDefaultResponse(
|
|
463
402
|
200,
|
|
464
403
|
{ 'content-type': 'application/json' },
|
|
465
404
|
() => {
|
|
466
405
|
const obj: ContextListResult<UserSchema> = {
|
|
467
|
-
|
|
406
|
+
data: this.gen.users.users(init?.size ?? 5),
|
|
468
407
|
cursor: this.createCursorOption(init),
|
|
469
408
|
}
|
|
470
409
|
return JSON.stringify(obj)
|
|
@@ -513,7 +452,7 @@ export class SdkMock {
|
|
|
513
452
|
status: 200,
|
|
514
453
|
headers: { 'content-type': 'application/json' },
|
|
515
454
|
body: JSON.stringify({
|
|
516
|
-
|
|
455
|
+
data: this.gen.users.users(init?.size ?? 5),
|
|
517
456
|
cursor: this.createCursorOption(init),
|
|
518
457
|
} as ContextListResult<UserSchema>),
|
|
519
458
|
}
|
|
@@ -656,20 +595,12 @@ export class SdkMock {
|
|
|
656
595
|
*/
|
|
657
596
|
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
658
597
|
const { mock } = this
|
|
659
|
-
// const respond = init?.response ?? {
|
|
660
|
-
// status: 200,
|
|
661
|
-
// headers: { 'content-type': 'application/json' },
|
|
662
|
-
// body: JSON.stringify({
|
|
663
|
-
// items: this.gen.group.groups(init?.size ?? 5),
|
|
664
|
-
// cursor: this.createCursorOption(init),
|
|
665
|
-
// } as ContextListResult<GroupSchema>),
|
|
666
|
-
// }
|
|
667
598
|
const respond = this.createDefaultResponse(
|
|
668
599
|
200,
|
|
669
600
|
{ 'content-type': 'application/json' },
|
|
670
601
|
() => {
|
|
671
602
|
const obj: ContextListResult<GroupSchema> = {
|
|
672
|
-
|
|
603
|
+
data: this.gen.group.groups(init?.size ?? 5),
|
|
673
604
|
cursor: this.createCursorOption(init),
|
|
674
605
|
}
|
|
675
606
|
return JSON.stringify(obj)
|
|
@@ -834,7 +765,7 @@ export class SdkMock {
|
|
|
834
765
|
{ 'content-type': 'application/json' },
|
|
835
766
|
() => {
|
|
836
767
|
const obj: ContextListResult<AiSessionSchema> = {
|
|
837
|
-
|
|
768
|
+
data: this.gen.ai.sessions('general', init?.size ?? 5),
|
|
838
769
|
cursor: this.createCursorOption(init),
|
|
839
770
|
}
|
|
840
771
|
return JSON.stringify(obj)
|
|
@@ -933,7 +864,7 @@ export class SdkMock {
|
|
|
933
864
|
{ 'content-type': 'application/json' },
|
|
934
865
|
() => {
|
|
935
866
|
const obj: ContextListResult<AiMessageSchema> = {
|
|
936
|
-
|
|
867
|
+
data: this.gen.ai.messages(init?.size ?? 5),
|
|
937
868
|
cursor: this.createCursorOption(init),
|
|
938
869
|
}
|
|
939
870
|
return JSON.stringify(obj)
|
|
@@ -1051,20 +982,12 @@ export class SdkMock {
|
|
|
1051
982
|
*/
|
|
1052
983
|
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1053
984
|
const { mock } = this
|
|
1054
|
-
// const respond = init?.response ?? {
|
|
1055
|
-
// status: 200,
|
|
1056
|
-
// headers: { 'content-type': 'application/json' },
|
|
1057
|
-
// body: JSON.stringify({
|
|
1058
|
-
// items: this.gen.files.files(init?.size ?? 5),
|
|
1059
|
-
// cursor: this.createCursorOption(init),
|
|
1060
|
-
// } as ContextListResult<FileSchema>),
|
|
1061
|
-
// }
|
|
1062
985
|
const respond = this.createDefaultResponse(
|
|
1063
986
|
200,
|
|
1064
987
|
{ 'content-type': 'application/json' },
|
|
1065
988
|
() => {
|
|
1066
989
|
const obj: ContextListResult<FileSchema> = {
|
|
1067
|
-
|
|
990
|
+
data: this.gen.files.files(init?.size ?? 5),
|
|
1068
991
|
cursor: this.createCursorOption(init),
|
|
1069
992
|
}
|
|
1070
993
|
return JSON.stringify(obj)
|
|
@@ -1238,19 +1161,12 @@ export class SdkMock {
|
|
|
1238
1161
|
*/
|
|
1239
1162
|
readBulk: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1240
1163
|
const { mock } = this
|
|
1241
|
-
// const respond = init?.response ?? {
|
|
1242
|
-
// status: 200,
|
|
1243
|
-
// headers: { 'content-type': 'application/json' },
|
|
1244
|
-
// body: JSON.stringify({
|
|
1245
|
-
// items: this.gen.files.files(init?.size ?? 5),
|
|
1246
|
-
// } as IBulkOperationResult<FileSchema>),
|
|
1247
|
-
// }
|
|
1248
1164
|
const respond = this.createDefaultResponse(
|
|
1249
1165
|
200,
|
|
1250
1166
|
{ 'content-type': 'application/json' },
|
|
1251
1167
|
() => {
|
|
1252
1168
|
const obj: IBulkOperationResult<FileSchema> = {
|
|
1253
|
-
|
|
1169
|
+
data: this.gen.files.files(init?.size ?? 5),
|
|
1254
1170
|
}
|
|
1255
1171
|
return JSON.stringify(obj)
|
|
1256
1172
|
},
|
|
@@ -1413,20 +1329,12 @@ export class SdkMock {
|
|
|
1413
1329
|
*/
|
|
1414
1330
|
listUsers: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1415
1331
|
const { mock } = this
|
|
1416
|
-
// const respond = init?.response ?? {
|
|
1417
|
-
// status: 200,
|
|
1418
|
-
// headers: { 'content-type': 'application/json' },
|
|
1419
|
-
// body: JSON.stringify({
|
|
1420
|
-
// items: this.gen.users.users(init?.size ?? 5),
|
|
1421
|
-
// cursor: this.createCursorOption(init),
|
|
1422
|
-
// } as ContextListResult<UserSchema>),
|
|
1423
|
-
// }
|
|
1424
1332
|
const respond = this.createDefaultResponse(
|
|
1425
1333
|
200,
|
|
1426
1334
|
{ 'content-type': 'application/json' },
|
|
1427
1335
|
() => {
|
|
1428
1336
|
const obj: ContextListResult<UserSchema> = {
|
|
1429
|
-
|
|
1337
|
+
data: this.gen.users.users(init?.size ?? 5),
|
|
1430
1338
|
cursor: this.createCursorOption(init),
|
|
1431
1339
|
}
|
|
1432
1340
|
return JSON.stringify(obj)
|
|
@@ -1450,20 +1358,12 @@ export class SdkMock {
|
|
|
1450
1358
|
*/
|
|
1451
1359
|
breadcrumbs: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1452
1360
|
const { mock } = this
|
|
1453
|
-
// const respond = init?.response ?? {
|
|
1454
|
-
// status: 200,
|
|
1455
|
-
// headers: { 'content-type': 'application/json' },
|
|
1456
|
-
// body: JSON.stringify({
|
|
1457
|
-
// items: this.gen.files.fileBreadcrumbs(init?.size ?? 5),
|
|
1458
|
-
// cursor: this.createCursorOption(init),
|
|
1459
|
-
// } as ContextListResult<FileBreadcrumb>),
|
|
1460
|
-
// }
|
|
1461
1361
|
const respond = this.createDefaultResponse(
|
|
1462
1362
|
200,
|
|
1463
1363
|
{ 'content-type': 'application/json' },
|
|
1464
1364
|
() => {
|
|
1465
1365
|
const obj: ContextListResult<FileBreadcrumb> = {
|
|
1466
|
-
|
|
1366
|
+
data: this.gen.files.fileBreadcrumbs(init?.size ?? 5),
|
|
1467
1367
|
cursor: this.createCursorOption(init),
|
|
1468
1368
|
}
|
|
1469
1369
|
return JSON.stringify(obj)
|
|
@@ -1494,20 +1394,12 @@ export class SdkMock {
|
|
|
1494
1394
|
shared = {
|
|
1495
1395
|
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1496
1396
|
const { mock } = this
|
|
1497
|
-
// const respond = init?.response ?? {
|
|
1498
|
-
// status: 200,
|
|
1499
|
-
// headers: { 'content-type': 'application/json' },
|
|
1500
|
-
// body: JSON.stringify({
|
|
1501
|
-
// items: this.gen.files.files(init?.size ?? 5),
|
|
1502
|
-
// cursor: this.createCursorOption(init),
|
|
1503
|
-
// } as ContextListResult<FileSchema>),
|
|
1504
|
-
// }
|
|
1505
1397
|
const respond = this.createDefaultResponse(
|
|
1506
1398
|
200,
|
|
1507
1399
|
{ 'content-type': 'application/json' },
|
|
1508
1400
|
() => {
|
|
1509
1401
|
const obj: ContextListResult<FileSchema> = {
|
|
1510
|
-
|
|
1402
|
+
data: this.gen.files.files(init?.size ?? 5),
|
|
1511
1403
|
cursor: this.createCursorOption(init),
|
|
1512
1404
|
}
|
|
1513
1405
|
return JSON.stringify(obj)
|
|
@@ -1533,20 +1425,12 @@ export class SdkMock {
|
|
|
1533
1425
|
trash = {
|
|
1534
1426
|
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1535
1427
|
const { mock } = this
|
|
1536
|
-
// const respond = init?.response ?? {
|
|
1537
|
-
// status: 200,
|
|
1538
|
-
// headers: { 'content-type': 'application/json' },
|
|
1539
|
-
// body: JSON.stringify({
|
|
1540
|
-
// items: this.gen.trash.trashEntries(init?.size ?? 5),
|
|
1541
|
-
// cursor: this.createCursorOption(init),
|
|
1542
|
-
// } as ContextListResult<TrashEntry>),
|
|
1543
|
-
// }
|
|
1544
1428
|
const respond = this.createDefaultResponse(
|
|
1545
1429
|
200,
|
|
1546
1430
|
{ 'content-type': 'application/json' },
|
|
1547
1431
|
() => {
|
|
1548
1432
|
const obj: ContextListResult<TrashEntry> = {
|
|
1549
|
-
|
|
1433
|
+
data: this.gen.trash.trashEntries(init?.size ?? 5),
|
|
1550
1434
|
cursor: this.createCursorOption(init),
|
|
1551
1435
|
}
|
|
1552
1436
|
return JSON.stringify(obj)
|
|
@@ -1626,9 +1510,58 @@ export class SdkMock {
|
|
|
1626
1510
|
const respond = this.createDefaultResponse(
|
|
1627
1511
|
200,
|
|
1628
1512
|
{ 'content-type': 'application/json' },
|
|
1629
|
-
() => {
|
|
1513
|
+
(req: SerializedRequest) => {
|
|
1514
|
+
const { query } = req
|
|
1515
|
+
const filter = this.decodeFilter(query.filter)
|
|
1516
|
+
const schema: Partial<DeploymentSchema> = {}
|
|
1517
|
+
if (isAtomicFilter(filter)) {
|
|
1518
|
+
if (['apiId', 'api_id'].includes(filter.field)) {
|
|
1519
|
+
if (filter.operator === 'eq') {
|
|
1520
|
+
schema.apiId = filter.value as string
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
if (['apiSlug', 'api_slug'].includes(filter.field)) {
|
|
1524
|
+
if (filter.operator === 'eq') {
|
|
1525
|
+
schema.apiSlug = filter.value as string
|
|
1526
|
+
}
|
|
1527
|
+
}
|
|
1528
|
+
if (['orgId', 'organization'].includes(filter.field)) {
|
|
1529
|
+
if (filter.operator === 'eq') {
|
|
1530
|
+
schema.orgId = filter.value as string
|
|
1531
|
+
}
|
|
1532
|
+
}
|
|
1533
|
+
if (['modelVersion', 'model_version'].includes(filter.field)) {
|
|
1534
|
+
if (filter.operator === 'eq') {
|
|
1535
|
+
schema.modelVersion = filter.value as string
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
if (filter.field === 'version') {
|
|
1539
|
+
if (filter.operator === 'eq') {
|
|
1540
|
+
schema.version = filter.value as string
|
|
1541
|
+
}
|
|
1542
|
+
}
|
|
1543
|
+
if (filter.field === 'env') {
|
|
1544
|
+
if (filter.operator === 'eq') {
|
|
1545
|
+
schema.env = filter.value as DeploymentEnvironment
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
const limit = this.readQueryLimit(req, init)
|
|
1550
|
+
const data = this.gen.deployments.deployments(limit, schema)
|
|
1551
|
+
const { order = 'asc', sort } = req.query
|
|
1552
|
+
if (sort) {
|
|
1553
|
+
data.sort((a, b) => {
|
|
1554
|
+
const aValue = a[sort as keyof DeploymentSchema] ?? 0
|
|
1555
|
+
const bValue = b[sort as keyof DeploymentSchema] ?? 0
|
|
1556
|
+
if (order === 'asc') {
|
|
1557
|
+
return aValue < bValue ? -1 : aValue > bValue ? 1 : 0
|
|
1558
|
+
} else {
|
|
1559
|
+
return aValue > bValue ? -1 : aValue < bValue ? 1 : 0
|
|
1560
|
+
}
|
|
1561
|
+
})
|
|
1562
|
+
}
|
|
1630
1563
|
const obj: ContextListResult<DeploymentSchema> = {
|
|
1631
|
-
|
|
1564
|
+
data,
|
|
1632
1565
|
cursor: this.createCursorOption(init),
|
|
1633
1566
|
}
|
|
1634
1567
|
return JSON.stringify(obj)
|
|
@@ -1716,15 +1649,30 @@ export class SdkMock {
|
|
|
1716
1649
|
)
|
|
1717
1650
|
},
|
|
1718
1651
|
apis: {
|
|
1719
|
-
|
|
1652
|
+
getLatestPerEnvironment: async (
|
|
1653
|
+
init?: MockResult & { prod?: boolean; stage?: boolean; dev?: boolean },
|
|
1654
|
+
options?: InterceptOptions
|
|
1655
|
+
): Promise<void> => {
|
|
1720
1656
|
const { mock } = this
|
|
1721
1657
|
const respond = this.createDefaultResponse(
|
|
1722
1658
|
200,
|
|
1723
1659
|
{ 'content-type': 'application/json' },
|
|
1724
1660
|
() => {
|
|
1725
|
-
const obj:
|
|
1726
|
-
|
|
1727
|
-
|
|
1661
|
+
const obj: DeploymentLatestEnvironmentsResponse = {
|
|
1662
|
+
data: {},
|
|
1663
|
+
}
|
|
1664
|
+
const hasProd = init?.prod ?? this.gen.faker.datatype.boolean()
|
|
1665
|
+
const hasStage = init?.stage ?? this.gen.faker.datatype.boolean()
|
|
1666
|
+
const hasDev = init?.dev ?? this.gen.faker.datatype.boolean()
|
|
1667
|
+
|
|
1668
|
+
if (hasProd) {
|
|
1669
|
+
obj.data.prod = this.gen.deployments.deployment()
|
|
1670
|
+
}
|
|
1671
|
+
if (hasStage) {
|
|
1672
|
+
obj.data.stage = this.gen.deployments.deployment()
|
|
1673
|
+
}
|
|
1674
|
+
if (hasDev) {
|
|
1675
|
+
obj.data.dev = this.gen.deployments.deployment()
|
|
1728
1676
|
}
|
|
1729
1677
|
return JSON.stringify(obj)
|
|
1730
1678
|
},
|
|
@@ -1733,7 +1681,7 @@ export class SdkMock {
|
|
|
1733
1681
|
await mock.add(
|
|
1734
1682
|
{
|
|
1735
1683
|
match: {
|
|
1736
|
-
uri: RouteBuilder.
|
|
1684
|
+
uri: RouteBuilder.deploymentsApisByEnvLatest(':oid', ':fileId'),
|
|
1737
1685
|
methods: ['GET'],
|
|
1738
1686
|
},
|
|
1739
1687
|
respond,
|
|
@@ -1741,15 +1689,14 @@ export class SdkMock {
|
|
|
1741
1689
|
options
|
|
1742
1690
|
)
|
|
1743
1691
|
},
|
|
1744
|
-
|
|
1692
|
+
list: async (init?: MockListResult, options?: InterceptOptions): Promise<void> => {
|
|
1745
1693
|
const { mock } = this
|
|
1746
1694
|
const respond = this.createDefaultResponse(
|
|
1747
1695
|
200,
|
|
1748
1696
|
{ 'content-type': 'application/json' },
|
|
1749
1697
|
() => {
|
|
1750
|
-
const obj: ContextListResult<
|
|
1751
|
-
|
|
1752
|
-
cursor: this.createCursorOption(init),
|
|
1698
|
+
const obj: ContextListResult<DeploymentApi> = {
|
|
1699
|
+
data: this.gen.deployments.deploymentApis(init?.size ?? 5),
|
|
1753
1700
|
}
|
|
1754
1701
|
return JSON.stringify(obj)
|
|
1755
1702
|
},
|
|
@@ -1758,7 +1705,7 @@ export class SdkMock {
|
|
|
1758
1705
|
await mock.add(
|
|
1759
1706
|
{
|
|
1760
1707
|
match: {
|
|
1761
|
-
uri: RouteBuilder.
|
|
1708
|
+
uri: RouteBuilder.deploymentsApis(':oid'),
|
|
1762
1709
|
methods: ['GET'],
|
|
1763
1710
|
},
|
|
1764
1711
|
respond,
|
|
@@ -1780,7 +1727,7 @@ export class SdkMock {
|
|
|
1780
1727
|
{ 'content-type': 'application/json' },
|
|
1781
1728
|
() => {
|
|
1782
1729
|
const obj: ContextListResult<DataCatalogSchemaWithVersion> = {
|
|
1783
|
-
|
|
1730
|
+
data: this.gen.dataCatalog.dataCatalogsWithVersion(init?.size ?? 5),
|
|
1784
1731
|
cursor: this.createCursorOption(init),
|
|
1785
1732
|
}
|
|
1786
1733
|
return JSON.stringify(obj)
|
|
@@ -1806,7 +1753,7 @@ export class SdkMock {
|
|
|
1806
1753
|
{ 'content-type': 'application/json' },
|
|
1807
1754
|
() => {
|
|
1808
1755
|
const obj: ContextListResult<DataCatalogVersionInfo> = {
|
|
1809
|
-
|
|
1756
|
+
data: this.gen.dataCatalog.versionInfos(init?.size ?? 5),
|
|
1810
1757
|
cursor: this.createCursorOption(init),
|
|
1811
1758
|
}
|
|
1812
1759
|
return JSON.stringify(obj)
|
|
@@ -1992,16 +1939,16 @@ export class SdkMock {
|
|
|
1992
1939
|
{ 'content-type': 'application/json' },
|
|
1993
1940
|
(req: SerializedRequest) => {
|
|
1994
1941
|
const requirements = JSON.parse(req.body as string) as { items: ForeignDomainDependency[] }
|
|
1995
|
-
const
|
|
1942
|
+
const data: DataDomainSchema[] = []
|
|
1996
1943
|
for (const item of requirements.items) {
|
|
1997
1944
|
const domain = new DataDomain({
|
|
1998
1945
|
key: item.key,
|
|
1999
1946
|
info: { name: `Domain ${item.key}`, version: item.version },
|
|
2000
1947
|
})
|
|
2001
|
-
|
|
1948
|
+
data.push(domain.toJSON())
|
|
2002
1949
|
}
|
|
2003
1950
|
const obj: ContextListResult<DataDomainSchema> = {
|
|
2004
|
-
|
|
1951
|
+
data,
|
|
2005
1952
|
}
|
|
2006
1953
|
return JSON.stringify(obj)
|
|
2007
1954
|
},
|
|
@@ -2106,4 +2053,80 @@ export class SdkMock {
|
|
|
2106
2053
|
)
|
|
2107
2054
|
},
|
|
2108
2055
|
}
|
|
2056
|
+
|
|
2057
|
+
//
|
|
2058
|
+
// Helpers
|
|
2059
|
+
//
|
|
2060
|
+
|
|
2061
|
+
/**
|
|
2062
|
+
* Decodes the filter parameter from the query string.
|
|
2063
|
+
*
|
|
2064
|
+
* @param filter The filter parameter from the query string.
|
|
2065
|
+
* @returns The decoded filter or undefined if the filter is invalid.
|
|
2066
|
+
*/
|
|
2067
|
+
decodeFilter(filter?: string | string[]): QueryFilter | undefined {
|
|
2068
|
+
if (typeof filter !== 'string' || !filter) {
|
|
2069
|
+
return undefined
|
|
2070
|
+
}
|
|
2071
|
+
try {
|
|
2072
|
+
return JSON.parse(atob(filter)) as QueryFilter
|
|
2073
|
+
} catch {
|
|
2074
|
+
return undefined
|
|
2075
|
+
}
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
readQueryLimit(req: SerializedRequest, init?: MockListResult): number {
|
|
2079
|
+
let limit = init?.size ?? 5
|
|
2080
|
+
if (req.query?.limit) {
|
|
2081
|
+
const l = Array.isArray(req.query.limit) ? req.query.limit[0] : req.query.limit
|
|
2082
|
+
const tmp = parseInt(l, 10)
|
|
2083
|
+
if (Number.isInteger(tmp) && tmp > 0) {
|
|
2084
|
+
limit = tmp
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
return limit
|
|
2088
|
+
}
|
|
2089
|
+
|
|
2090
|
+
protected createCursorOption(init: MockListResult = {}): string | undefined {
|
|
2091
|
+
if (init.cursor === false) {
|
|
2092
|
+
return undefined
|
|
2093
|
+
}
|
|
2094
|
+
const hasCursor = init.cursor === true ? true : this.gen.faker.datatype.boolean()
|
|
2095
|
+
if (!hasCursor) {
|
|
2096
|
+
return undefined
|
|
2097
|
+
}
|
|
2098
|
+
return this.gen.faker.internet.jwt()
|
|
2099
|
+
}
|
|
2100
|
+
|
|
2101
|
+
protected createDefaultResponse(
|
|
2102
|
+
status: number,
|
|
2103
|
+
headers?: Record<string, string>,
|
|
2104
|
+
body?: (req: SerializedRequest) => string,
|
|
2105
|
+
userConfig?: MockResult
|
|
2106
|
+
): ResponseGenerator {
|
|
2107
|
+
let respond: ResponseGenerator
|
|
2108
|
+
if (userConfig?.response) {
|
|
2109
|
+
// user config takes precedence
|
|
2110
|
+
respond = userConfig.response
|
|
2111
|
+
} else {
|
|
2112
|
+
respond = {}
|
|
2113
|
+
}
|
|
2114
|
+
// Set defaults if not provided in user config
|
|
2115
|
+
if (!respond.status) {
|
|
2116
|
+
respond.status = status
|
|
2117
|
+
}
|
|
2118
|
+
// only set headers if the user didn't configure the response only.
|
|
2119
|
+
// The user may want to remove default headers.
|
|
2120
|
+
if (!userConfig || !userConfig.response) {
|
|
2121
|
+
respond.headers = headers
|
|
2122
|
+
}
|
|
2123
|
+
if (!respond.body && userConfig?.forceBody && body) {
|
|
2124
|
+
// when body is missing and forceBody is set, generate the body
|
|
2125
|
+
respond.body = (req: SerializedRequest) => body(req)
|
|
2126
|
+
} else if (body && (!userConfig || !userConfig.response)) {
|
|
2127
|
+
// we set the body by default when the user config is missing
|
|
2128
|
+
respond.body = (req: SerializedRequest) => body(req)
|
|
2129
|
+
}
|
|
2130
|
+
return respond
|
|
2131
|
+
}
|
|
2109
2132
|
}
|
package/src/sdk/SharedSdk.ts
CHANGED
|
@@ -43,7 +43,7 @@ export class SharedSdk extends SdkBase {
|
|
|
43
43
|
} catch {
|
|
44
44
|
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
|
|
45
45
|
}
|
|
46
|
-
if (!Array.isArray(data.
|
|
46
|
+
if (!Array.isArray(data.data)) {
|
|
47
47
|
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
|
|
48
48
|
}
|
|
49
49
|
return data
|
package/src/sdk/TrashSdk.ts
CHANGED
|
@@ -40,7 +40,7 @@ export class TrashSdk extends SdkBase {
|
|
|
40
40
|
} catch {
|
|
41
41
|
throw new Exception(`${E_PREFIX}${E_INVALID_JSON}`, { code: 'E_INVALID_JSON', status: result.status })
|
|
42
42
|
}
|
|
43
|
-
if (!Array.isArray(data.
|
|
43
|
+
if (!Array.isArray(data.data)) {
|
|
44
44
|
throw new Exception(`${E_PREFIX}${E_RESPONSE_UNKNOWN}`, { code: 'E_RESPONSE_UNKNOWN', status: result.status })
|
|
45
45
|
}
|
|
46
46
|
return data
|