Skip to content
This repository was archived by the owner on May 13, 2024. It is now read-only.

Commit ade327e

Browse files
chore: adding stream_types object and tag to forgetAll api
1 parent 31a2e83 commit ade327e

File tree

8 files changed

+218
-3
lines changed

8 files changed

+218
-3
lines changed

src/features/Apiexplorer/Schema/RecursiveContent/RecursiveProperties/index.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
11
import React from 'react';
22
import SchemaDescription from '../SchemaDescription';
33
import SchemaObjectContent from '../SchemaObjectContent';
4+
import StreamTypesObject from '../StreamTypesObject';
45

56
type TRecursiveProperties = {
67
is_open: boolean;
78
properties: any;
89
value: any;
10+
jsonSchema?: any;
911
};
1012

11-
const RecursiveProperties = ({ is_open, properties, value }: TRecursiveProperties) => {
13+
const RecursiveProperties = ({ is_open, properties, value, jsonSchema }: TRecursiveProperties) => {
1214
const keys = properties && Object.keys(properties);
1315
if (!is_open) {
16+
//if object is not open then ret null
1417
return null;
1518
}
19+
20+
if ('oneOf' in value) {
21+
return <StreamTypesObject definitions={jsonSchema.definitions} />;
22+
}
23+
// this will be true when we are not inside properties obj? !!!!!!
1624
if (!keys) {
1725
return (
1826
<React.Fragment>
@@ -28,7 +36,18 @@ const RecursiveProperties = ({ is_open, properties, value }: TRecursivePropertie
2836
{index === 0 && value?.items?.description && (
2937
<SchemaDescription description={value.items.description} />
3038
)}
31-
<SchemaObjectContent key={key} key_value={key} properties={properties} />
39+
{/* check if its forgetAll Request not response */}
40+
{key === 'forget_all' && 'oneOf' in value[key] ? (
41+
<SchemaObjectContent
42+
key={key}
43+
key_value={key}
44+
properties={properties}
45+
jsonSchema={jsonSchema}
46+
is_stream_types={true}
47+
/>
48+
) : (
49+
<SchemaObjectContent key={key} key_value={key} properties={properties} />
50+
)}
3251
</React.Fragment>
3352
);
3453
})}

src/features/Apiexplorer/Schema/RecursiveContent/SchemaBodyHeader/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ type TSchemaBodyHeader = {
1212
setIsOpenObject: (boolean) => void;
1313
examples: string[];
1414
enum;
15+
is_stream_types?: boolean;
1516
};
1617

1718
const SchemaBodyHeader = ({
@@ -24,6 +25,7 @@ const SchemaBodyHeader = ({
2425
title,
2526
is_open_object,
2627
setIsOpenObject,
28+
is_stream_types,
2729
}: TSchemaBodyHeader) => {
2830
let typeClassName;
2931
switch (type) {
@@ -116,6 +118,17 @@ const SchemaBodyHeader = ({
116118
) : (
117119
<></>
118120
)}
121+
122+
{is_stream_types && (
123+
<React.Fragment>
124+
<div className={styles.schemaObjectContent}>
125+
<span className={styles.enumLabel}>{'one of'}</span>
126+
<button onClick={() => setIsOpenObject(!is_open_object)}>{'stream_types'}</button>
127+
<span className={`${styles.enumType} ${styles.array}`}>{'array'}</span>
128+
</div>
129+
</React.Fragment>
130+
)}
131+
119132
{pattern && (
120133
<div className={styles.schemaRegexContainer}>
121134
<div className={styles.schemaBodyPattern}>{pattern}</div>

src/features/Apiexplorer/Schema/RecursiveContent/SchemaObjectContent/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,17 @@ const ReactJson = React.lazy(() => import('react-json-view'));
1010
type TSchemaObjectContent = {
1111
key_value: string;
1212
properties: any;
13+
jsonSchema?: any;
14+
is_stream_types?: boolean;
1315
};
1416

15-
export default function SchemaObjectContent({ key_value, properties }: TSchemaObjectContent) {
17+
//json schema also here full obj
18+
export default function SchemaObjectContent({
19+
key_value,
20+
properties,
21+
jsonSchema,
22+
is_stream_types = false,
23+
}: TSchemaObjectContent) {
1624
const [is_open_object, setIsOpenObject] = useState<boolean>(false);
1725
const [is_code_open, setIsCodeOpen] = useState<boolean>(false);
1826
const {
@@ -52,6 +60,7 @@ export default function SchemaObjectContent({ key_value, properties }: TSchemaOb
5260
title={title}
5361
is_open_object={is_open_object}
5462
setIsOpenObject={setIsOpenObject}
63+
is_stream_types={is_stream_types}
5564
/>
5665
{/* Description */}
5766
<SchemaDescription description={description} />
@@ -68,6 +77,7 @@ export default function SchemaObjectContent({ key_value, properties }: TSchemaOb
6877
is_open={is_open_object}
6978
properties={value.properties || value?.items?.properties}
7079
value={value}
80+
jsonSchema={jsonSchema}
7181
/>
7282
)}
7383
</div>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import styles from '../../Schema.module.scss';
3+
4+
type TStreamTypesBody = {
5+
type: string;
6+
_enum: Array<
7+
| 'balance'
8+
| 'candles'
9+
| 'cashier_payments'
10+
| 'p2p_advert'
11+
| 'p2p_advertiser'
12+
| 'p2p_order'
13+
| 'proposal'
14+
| 'proposal_open_contract'
15+
| 'ticks'
16+
| 'transaction'
17+
| 'trading_platform_asset_listing'
18+
| 'website_status'
19+
| 'p2p_settings'
20+
| 'crypto_estimations'
21+
>;
22+
};
23+
24+
const StreamTypesBody = ({ type, _enum }: TStreamTypesBody) => {
25+
return (
26+
<div className={styles.streamTypesBody}>
27+
<div className={styles.streamTypesObject}>
28+
<span className={styles.enumLabel}>enum</span>
29+
<span className={`${styles.enumType} ${styles.string}`}>{type}</span>
30+
{_enum.map((enum_name: string, i: number) => (
31+
<div className={`${styles.schemaCode} ${styles.schemaEnums}`} key={i}>
32+
{enum_name}
33+
</div>
34+
))}
35+
</div>
36+
</div>
37+
);
38+
};
39+
40+
export default StreamTypesBody;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import SchemaTitle from '../../SchemaTitle';
3+
import styles from '../../Schema.module.scss';
4+
5+
type TStreamTypesHeader = {
6+
description: string;
7+
};
8+
9+
const StreamTypesHeader = ({ description }: TStreamTypesHeader) => {
10+
return (
11+
<div className={styles.streamTypesHeader}>
12+
<SchemaTitle className={styles.streamTypesTitle}>{'stream_types'}</SchemaTitle>
13+
<div className={styles.streamTypesDescription}>
14+
<div>{description}</div>
15+
</div>
16+
</div>
17+
);
18+
};
19+
20+
export default StreamTypesHeader;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import React from 'react';
2+
import StreamTypesHeader from './StreamTypesHeader';
3+
import StreamTypesBody from './StreamTypesBody';
4+
import styles from '../../Schema.module.scss';
5+
6+
type TStreamTypesObject = {
7+
definitions: {
8+
stream_types: {
9+
description: string;
10+
type: string;
11+
enum: Array<
12+
| 'balance'
13+
| 'candles'
14+
| 'cashier_payments'
15+
| 'p2p_advert'
16+
| 'p2p_advertiser'
17+
| 'p2p_order'
18+
| 'proposal'
19+
| 'proposal_open_contract'
20+
| 'ticks'
21+
| 'transaction'
22+
| 'trading_platform_asset_listing'
23+
| 'website_status'
24+
| 'p2p_settings'
25+
| 'crypto_estimations'
26+
>;
27+
};
28+
};
29+
};
30+
31+
const StreamTypesObject = ({ definitions }: TStreamTypesObject) => {
32+
return (
33+
<div className={styles.streamTypesContainer}>
34+
<StreamTypesHeader description={definitions.stream_types.description} />
35+
<StreamTypesBody type={definitions.stream_types.type} _enum={definitions.stream_types.enum} />
36+
</div>
37+
);
38+
};
39+
40+
export default StreamTypesObject;

src/features/Apiexplorer/Schema/Schema.module.scss

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
display: flex;
3535
flex-direction: row;
3636
position: relative;
37+
gap: rem(0.8);
3738

3839
p {
3940
color: var(--ifm-color-white);
@@ -301,3 +302,74 @@
301302
.reactJsonView {
302303
margin-bottom: rem(2.4);
303304
}
305+
306+
.streamTypesContainer {
307+
border-radius: 6px;
308+
margin-top: rem(1);
309+
margin-bottom: rem(2.4);
310+
311+
.streamTypesBody {
312+
background-color: rgba(219, 219, 219, 0.05);
313+
display: flex;
314+
padding: rem(1);
315+
316+
.streamTypesObject {
317+
display: flex;
318+
flex-wrap: wrap;
319+
gap: rem(0.8);
320+
align-items: center;
321+
322+
.enumLabel {
323+
font-size: rem(1.4);
324+
line-height: rem(1.4);
325+
color: var(--ifm-color-emphasis-200);
326+
}
327+
328+
.enumType {
329+
font-size: rem(1.4);
330+
&.string {
331+
color: var(--schema-string);
332+
}
333+
}
334+
335+
.enumLabel,
336+
.enumType {
337+
display: flex;
338+
justify-content: center;
339+
align-items: center;
340+
}
341+
342+
.schemaEnums {
343+
width: fit-content;
344+
height: fit-content;
345+
font-size: rem(1.4);
346+
line-height: rem(1.4);
347+
color: var(--ifm-color-success-light);
348+
border: none;
349+
padding: rem(0.6) rem(0.8);
350+
border-radius: 4px;
351+
background-color: rgba(0, 255, 104, 0.16);
352+
}
353+
}
354+
}
355+
356+
.streamTypesHeader {
357+
padding: rem(1);
358+
border: none;
359+
background: #151717;
360+
361+
.streamTypesTitle {
362+
font-size: rem(1.6);
363+
color: var(--ifm-color-white);
364+
font-weight: bold;
365+
}
366+
.streamTypesDescription {
367+
display: flex;
368+
padding: rem(0.5) 0;
369+
gap: rem(2);
370+
justify-content: space-between;
371+
color: var(--ifm-color-white);
372+
font-size: rem(1.4);
373+
}
374+
}
375+
}

src/features/Apiexplorer/Schema/SchemaProperties/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ const SchemaProperties = ({ jsonSchema }: TJsonSchemaType) => {
3232
is_open
3333
properties={jsonSchema.properties}
3434
value={jsonSchema.properties}
35+
jsonSchema={jsonSchema}
3536
/>
3637
)}
3738
</React.Fragment>

0 commit comments

Comments
 (0)