Skip to content
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

[Console] Convert lib/mappings to TypeScript #4008

Merged
merged 23 commits into from
Jul 5, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f5faee9
Convert mappings.js to TypeScript
curq May 11, 2023
a7e1367
Convert mappings.test.js to TypeScript
curq May 11, 2023
9b16a0a
Update CHANGELOG.md
curq May 11, 2023
51f2d9f
Merge branch 'main' into console-mappings-ts
kavilla May 16, 2023
204491c
Merge branch 'main' into console-mappings-ts
abbyhu2000 May 16, 2023
010629f
Merge branch 'main' into console-mappings-ts
curq May 17, 2023
253aa8c
Add test for getTypes with multi-index mode
curq May 25, 2023
617e02e
Merge branch 'main' into console-mappings-ts
curq May 25, 2023
894fdea
Merge branch 'console-mappings-ts' of github.com:curq/OpenSearch-Dash…
curq May 25, 2023
4251173
Merge branch 'opensearch-project:main' into console-mappings-ts
curq May 26, 2023
499ac53
type update
curq May 26, 2023
0d6ab00
Merge branch 'main' into console-mappings-ts
ashwin-pc May 31, 2023
a77d615
Merge branch 'main' into console-mappings-ts
curq Jun 14, 2023
8daf1bc
update typing
curq Jun 14, 2023
df73ecc
Merge branch 'main' into console-mappings-ts
ananzh Jun 20, 2023
f4b9de8
Merge branch 'opensearch-project:main' into console-mappings-ts
curq Jun 21, 2023
a854556
CHANGELOG fix
curq Jun 21, 2023
3571a7d
Changelog update
curq Jun 21, 2023
d8c81ba
Merge branch 'main' into console-mappings-ts
joshuarrrr Jun 22, 2023
0ea3fdb
Merge branch 'main' into console-mappings-ts
joshuarrrr Jun 26, 2023
fc52bb3
Update Changelog
curq Jun 26, 2023
ccdee60
Merge branch 'main' into console-mappings-ts
ananzh Jun 28, 2023
e776e9b
Merge branch 'main' into console-mappings-ts
ananzh Jun 29, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Console] Replace jQuery.ajax with core.http when calling OSD APIs in console ([#3080](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3080))
- [I18n] Fix Listr type errors and error handlers ([#3629](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3629))
- [Multiple DataSource] Present the authentication type choices in a drop-down ([#3693](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3693))
- [Console] Convert lib/mappings to TypeScript ([#4008](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4008))
- [Console] Remove unused ul element and its custom styling ([#3993](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3993))
Copy link
Member

Choose a reason for hiding this comment

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

I think there is some conflicts here. Seems some mess up with other commits. could you remove these three lines that are not ur PRs?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

- Fix EUI/OUI type errors ([#3798](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3798))
- Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* under the License.
*/

import { Field } from '../mappings';
import '../../../application/models/sense_editor/sense_editor.test.mocks';
import * as mappings from '../mappings';

Expand All @@ -39,7 +40,7 @@ describe('Mappings', () => {
mappings.clear();
});

function fc(f1, f2) {
function fc(f1: Field, f2: Field) {
if (f1.name < f2.name) {
return -1;
}
Expand All @@ -49,8 +50,8 @@ describe('Mappings', () => {
return 0;
}

function f(name, type) {
return { name: name, type: type || 'string' };
function f(name: string, type?: string) {
return { name, type: type || 'string' };
}

test('Multi fields 1.0 style', function () {
Expand Down Expand Up @@ -256,10 +257,37 @@ describe('Mappings', () => {
'test_index2',
]);
expect(mappings.getIndices(false).sort()).toEqual(['test_index1', 'test_index2']);
expect(mappings.expandAliases(['alias1', 'test_index2']).sort()).toEqual([
expect((mappings.expandAliases(['alias1', 'test_index2']) as string[]).sort()).toEqual([
'test_index1',
'test_index2',
]);
expect(mappings.expandAliases('alias2')).toEqual('test_index2');
});

test('Multi types', function () {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: I think there are also some missing tests on other functions like retrieveAutoCompleteInfo. Not sure if you could help to add some unit tests here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I tried to add unit tests, but after looking through it, retrieveAutoCompleteInfo and other retrieve functions do api calls to running opensearch server, so I'm not sure if we can test it in unit tests. I think this one should be handled by functional tests

mappings.loadMappings({
index: {
properties: {
name1: {
type: 'object',
path: 'just_name',
properties: {
first1: { type: 'string' },
last1: { type: 'string', index_name: 'i_last_1' },
},
},
name2: {
type: 'object',
path: 'full',
properties: {
first2: { type: 'string' },
last2: { type: 'string', index_name: 'i_last_2' },
},
},
},
},
});

expect(mappings.getTypes()).toEqual(['properties']);
});
});
Loading