Skip to content

Add autoExpandLevel flag to EntryModel #130

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"model": {
"autoExpandLevel": -1,
"entries": [
{
"id": 0,
Expand Down Expand Up @@ -113,4 +114,5 @@
},
"statusMessage": "Completed",
"status": "COMPLETED"

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"model": {
"autoExpandLevel": -1,
"entries": [
{
"id": 1234,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"model": {
"autoExpandLevel": -1,
"entries": [
{
"id": 111,
Expand Down
16 changes: 15 additions & 1 deletion tsp-typescript-client/src/models/entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const Entry = createNormalizer<Entry>({
style: {
values: undefined,
},
metadata: undefined,
metadata: undefined
});

/**
Expand Down Expand Up @@ -44,6 +44,7 @@ export interface Entry {
* Metadata
*/
metadata?: { [key: string]: any };

}

/**
Expand All @@ -68,6 +69,7 @@ export interface EntryHeader {
export function EntryModel<T extends Entry>(normalizer: Normalizer<T>): Normalizer<EntryModel<T>> {
return createNormalizer<EntryModel<any>>({
entries: array(normalizer),
autoExpandLevel: assertNumber,
});
}

Expand All @@ -84,4 +86,16 @@ export interface EntryModel<T extends Entry> {
* Array of entry
*/
entries: T[];

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The TSP update has the exact meaning of the field and you can change the description accordingly.

/**
* Optional auto-expand level to be used for the input of the tree. If omitted value -1 is assumed.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the previous version of the PR you described the values and meaning. Please bring them back below this line.

*
* Values:
* - -1 → All subtrees should be expanded
* - 0 → No auto-expand
* - 1 → Top-level elements are expanded, but not their children
* - 2 → Top-level elements and their children are expanded, but not grand-children
*/
autoExpandLevel?: number;

}
5 changes: 4 additions & 1 deletion tsp-typescript-client/src/protocol/tsp-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ describe('HttpTspClient Deserialization', () => {
const genericResponse = response.getModel()!;
const model = genericResponse.model;

expect(model.autoExpandLevel).toEqual(-1);
expect(model.entries).toHaveLength(1);
expect(model.headers).toHaveLength(0);
for (const entry of model.entries) {
Expand Down Expand Up @@ -373,7 +374,8 @@ describe('HttpTspClient Deserialization', () => {
{ name: 'Total', tooltip: '', },
{ name: 'Min Time Range', tooltip: '', dataType: DataType.TIME_RANGE },
{ name: 'Max Time Range', tooltip: '', dataType: DataType.TIME_RANGE }];


expect(model.autoExpandLevel).toEqual(-1);
expect(model.entries).toHaveLength(4);
expect(model.headers).toHaveLength(9);

Expand All @@ -399,6 +401,7 @@ describe('HttpTspClient Deserialization', () => {
const genericResponse = response.getModel()!;
const model = genericResponse.model;

expect(model.autoExpandLevel).toEqual(-1);
expect(model.entries).toHaveLength(1);
expect(model.headers).toHaveLength(4);
for (const entry of model.entries) {
Expand Down