Skip to content

Commit 9e4f058

Browse files
fix(case manager): change open api dto for case review (#967)
1 parent acc8807 commit 9e4f058

File tree

4 files changed

+44
-20
lines changed

4 files changed

+44
-20
lines changed

packages/app-builder/src/models/cases.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -574,16 +574,14 @@ export function adaptPivotObject(dto: PivotObjectDto): PivotObject {
574574

575575
export type CaseReview = {
576576
output: string;
577-
sanityCheck: string;
578-
thought: string;
579-
ok: boolean;
580-
};
577+
thought?: string;
578+
} & ({ ok: true; sanityCheck?: undefined } | { ok: false; sanityCheck: string });
581579

582580
export function adaptCaseReview(dto: CaseReviewDto): CaseReview {
583-
return {
584-
output: dto.output,
585-
sanityCheck: dto.sanity_check,
586-
thought: dto.thought,
587-
ok: dto.ok,
588-
};
581+
const baseCaseReview = { output: dto.output, thought: dto.thought } as const;
582+
583+
if (!dto.ok) {
584+
return { ...baseCaseReview, ok: false, sanityCheck: dto.sanity_check };
585+
}
586+
return { ...baseCaseReview, ok: true };
589587
}

packages/marble-api/openapis/marblecore-api/_schemas.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ PivotObjectDto:
131131
$ref: cases.yml#/components/schemas/PivotObjectDto
132132
CaseReviewDto:
133133
$ref: cases.yml#/components/schemas/CaseReviewDto
134+
CaseReviewOkDto:
135+
$ref: cases.yml#/components/schemas/CaseReviewOkDto
136+
CaseReviewNotOkDto:
137+
$ref: cases.yml#/components/schemas/CaseReviewNotOkDto
134138

135139
# SUSPICIOUS ACTIVITY REPORTS
136140

packages/marble-api/openapis/marblecore-api/cases.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1359,18 +1359,35 @@ components:
13591359
- pivot_object_data
13601360
- number_of_decisions
13611361
CaseReviewDto:
1362+
allOf:
1363+
- type: object
1364+
required:
1365+
- output
1366+
properties:
1367+
output:
1368+
type: string
1369+
thought:
1370+
type: string
1371+
- anyOf:
1372+
- $ref: '#/components/schemas/CaseReviewOkDto'
1373+
- $ref: '#/components/schemas/CaseReviewNotOkDto'
1374+
1375+
CaseReviewOkDto:
1376+
type: object
1377+
required:
1378+
- ok
1379+
properties:
1380+
ok:
1381+
type: boolean
1382+
enum: [true]
1383+
CaseReviewNotOkDto:
13621384
type: object
13631385
required:
13641386
- ok
1365-
- output
13661387
- sanity_check
1367-
- thought
13681388
properties:
13691389
ok:
13701390
type: boolean
1371-
output:
1372-
type: string
1391+
enum: [false]
13731392
sanity_check:
13741393
type: string
1375-
thought:
1376-
type: string

packages/marble-api/src/generated/marblecore-api.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -425,12 +425,17 @@ export type PivotObjectDto = {
425425
export type NextCaseIdDto = {
426426
id: string;
427427
};
428-
export type CaseReviewDto = {
429-
ok: boolean;
430-
output: string;
428+
export type CaseReviewOkDto = {
429+
ok: true;
430+
};
431+
export type CaseReviewNotOkDto = {
432+
ok: false;
431433
sanity_check: string;
432-
thought: string;
433434
};
435+
export type CaseReviewDto = {
436+
output: string;
437+
thought?: string;
438+
} & (CaseReviewOkDto | CaseReviewNotOkDto);
434439
export type SuspiciousActivityReportDto = {
435440
id: string;
436441
status: "pending" | "completed";

0 commit comments

Comments
 (0)