Skip to content

Commit

Permalink
Merge branch 'main' into feature/discover-pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
kishor82 committed Jan 10, 2024
2 parents 24937e6 + a4ae399 commit 25e54fe
Show file tree
Hide file tree
Showing 64 changed files with 519 additions and 292 deletions.
3 changes: 1 addition & 2 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ target
# plugin overrides
/src/core/lib/osd_internal_native_observable
/src/legacy/plugin_discovery/plugin_pack/__tests__/fixtures/plugins/broken
/src/plugins/data/common/opensearch_query/kuery/ast/_generated_/**
/src/plugins/vis_type_timeline/public/_generated_/**
/src/plugins/**/_generated_/**

# package overrides
/packages/opensearch-eslint-config-opensearch-dashboards
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### Deprecations

- Rename `withLongNumerals` to `withLongNumeralsSupport` in `HttpFetchOptions` [#5592](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5592)

### 🛡 Security

- [WS-2021-0638] Bump mocha from `7.2.0` to `10.1.0` ([#2711](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2711))
- Add support for TLS v1.3 ([#5133](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5133))
- [CVE-2023-45133] Bump all babel dependencies from `7.16.x` to `7.22.9` to fix upstream vulnerability ([#5428](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5428))
- [CVE-2023-45857] Bump `axios` from `0.27.2` to `1.6.1` ([#5470](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5470))
- [CVE-2023-26159] Bump `follow-redirects` from `1.15.2` to `1.15.4` ([#5669](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5669))

### 📈 Features/Enhancements

Expand All @@ -22,6 +25,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [Workspace] Add core workspace service module to enable the implementation of workspace features within OSD plugins ([#5092](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5092))
- [Workspace] Setup workspace skeleton and implement basic CRUD API ([#5075](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5075))
- [Decouple] Add new cross compatibility check core service which export functionality for plugins to verify if their OpenSearch plugin counterpart is installed on the cluster or has incompatible version to configure the plugin behavior([#4710](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4710))
- [Discover] Add long numerals support [#5592](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5592)
- [Discover] Display inner properties in the left navigation bar [#5429](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5429)
- [Discover] Added customizable pagination options based on Discover UI settings [#5610](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5610)
- [Chrome] Introduce registerCollapsibleNavHeader to allow plugins to customize the rendering of nav menu header ([#5244](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5244))
Expand All @@ -43,6 +47,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- [BUG][Discover] Fix what is displayed in `selected fields` when removing columns from canvas [#5537](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5537)
- [BUG][Discover] Fix advanced setting `discover:modifyColumnsOnSwitch` ([#5508](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5508))
- [Discover] Fix missing index pattern field from breaking Discover [#5626](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5626)
- [BUG] Remove duplicate sample data as id 90943e30-9a47-11e8-b64d-95841ca0b247 ([5668](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5668))

### 🚞 Infrastructure

Expand All @@ -68,14 +73,17 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Replace `node-sass` with `sass-embedded` ([#5338](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5338))
- Bump `chromedriver` from `107.0.3` to `119.0.1` ([#5465](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5465))
- Bump `typescript` resolution from `4.0.2` to `4.6.4` ([#5470](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5470))
- Bump `OUI` to `1.4.0` ([#5637](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5637))
- Add @SuZhou-Joe as a maintainer ([#5594](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5594))
- Move @seanneumann to emeritus maintainer ([#5634](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5634))
- Remove `ui-select` dev dependency ([#5660](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5660))

### 🪛 Refactoring

- [Console] Remove unused ul element and its custom styling ([#3993](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/3993))
- Remove unused Sass in `tile_map` plugin ([#4110](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/4110))
- [Home] Remove unused tutorials ([#5212](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5212))
- [UiSharedDeps] Standardize theme JSON imports to be light/dark-mode aware ([#5662](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/5662))

### 🔩 Tests

Expand Down Expand Up @@ -956,4 +964,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

### 🔩 Tests

- Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322))
- Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322))
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"**/async": "^3.2.3",
"**/d3-color": "^3.1.0",
"**/elasticsearch/agentkeepalive": "^4.5.0",
"**/follow-redirects": "^1.15.4",
"**/glob-parent": "^6.0.0",
"**/hoist-non-react-statics": "^3.3.2",
"**/json-schema": "^0.4.0",
Expand Down Expand Up @@ -127,9 +128,9 @@
"dependencies": {
"@aws-crypto/client-node": "^3.1.1",
"@elastic/datemath": "5.0.3",
"@elastic/eui": "npm:@opensearch-project/oui@1.4.0-alpha.2",
"@elastic/eui": "npm:@opensearch-project/oui@1.4.0",
"@elastic/good": "^9.0.1-kibana3",
"@elastic/numeral": "^2.5.0",
"@elastic/numeral": "npm:@amoo-miki/numeral@2.6.0",
"@elastic/request-crypto": "2.0.0",
"@elastic/safer-lodash-set": "0.0.0",
"@hapi/accept": "^5.0.2",
Expand Down Expand Up @@ -455,7 +456,6 @@
"tough-cookie": "^4.1.3",
"tree-kill": "^1.2.2",
"typescript": "4.0.2",
"ui-select": "0.19.8",
"vega": "^5.23.0",
"vega-interpreter": "npm:@amoo-miki/vega-forced-csp-compliant-interpreter@1.0.6",
"vega-lite": "^5.6.0",
Expand Down
1 change: 1 addition & 0 deletions packages/osd-std/src/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export const parse = (
if (
numeralsAreNumbers &&
typeof val === 'number' &&
isFinite(val) &&
(val < Number.MAX_SAFE_INTEGER || val > Number.MAX_SAFE_INTEGER)
) {
numeralsAreNumbers = false;
Expand Down
2 changes: 1 addition & 1 deletion packages/osd-ui-framework/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"enzyme-adapter-react-16": "^1.9.1"
},
"devDependencies": {
"@elastic/eui": "npm:@opensearch-project/oui@1.4.0-alpha.2",
"@elastic/eui": "npm:@opensearch-project/oui@1.4.0",
"@osd/babel-preset": "1.0.0",
"@osd/optimizer": "1.0.0",
"comment-stripper": "^0.0.4",
Expand Down
5 changes: 3 additions & 2 deletions packages/osd-ui-shared-deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
},
"dependencies": {
"@elastic/charts": "31.1.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.4.0-alpha.2",
"@elastic/numeral": "^2.5.0",
"@elastic/eui": "npm:@opensearch-project/oui@1.4.0",
"@elastic/numeral": "npm:@amoo-miki/numeral@2.6.0",
"@opensearch/datemath": "5.0.3",
"@osd/i18n": "1.0.0",
"@osd/monaco": "1.0.0",
Expand Down Expand Up @@ -52,3 +52,4 @@
"webpack": "npm:@amoo-miki/webpack@4.46.0-rc.2"
}
}

13 changes: 13 additions & 0 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ const run = async () => {
},
])
);
promises.push(
patchFile('node_modules/rison-node/js/rison.js', [
{
from: 'return Number(s)',
to:
'return isFinite(s) && (s > Number.MAX_SAFE_INTEGER || s < Number.MIN_SAFE_INTEGER) ? BigInt(s) : Number(s)',
},
{
from: 's = {',
to: 's = {\n bigint: x => x.toString(),',
},
])
);

await Promise.all(promises);
};
Expand Down
8 changes: 6 additions & 2 deletions src/core/public/http/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,9 @@ describe('Fetch', () => {
},
});

await expect(fetchInstance.fetch('/my/path', { withLongNumerals: true })).resolves.toEqual({
await expect(
fetchInstance.fetch('/my/path', { withLongNumeralsSupport: true })
).resolves.toEqual({
'long-max': longPositive,
'long-min': longNegative,
});
Expand All @@ -854,7 +856,9 @@ describe('Fetch', () => {
},
});

await expect(fetchInstance.fetch('/my/path', { withLongNumerals: true })).resolves.toEqual({
await expect(
fetchInstance.fetch('/my/path', { withLongNumeralsSupport: true })
).resolves.toEqual({
'long-max': longPositive,
'long-min': longNegative,
});
Expand Down
12 changes: 10 additions & 2 deletions src/core/public/http/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,12 +190,20 @@ export class Fetch {
if (NDJSON_CONTENT.test(contentType)) {
body = await response.blob();
} else if (JSON_CONTENT.test(contentType)) {
body = fetchOptions.withLongNumerals ? parse(await response.text()) : await response.json();
// ToDo: [3.x] Remove withLongNumerals
body =
fetchOptions.withLongNumeralsSupport || fetchOptions.withLongNumerals
? parse(await response.text())
: await response.json();
} else {
const text = await response.text();

try {
body = fetchOptions.withLongNumerals ? parse(text) : JSON.parse(text);
// ToDo: [3.x] Remove withLongNumerals
body =
fetchOptions.withLongNumeralsSupport || fetchOptions.withLongNumerals
? parse(text)
: JSON.parse(text);
} catch (err) {
body = text;
}
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/http/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ export interface HttpFetchOptions extends HttpRequestInit {
* When `true`, if the response has a JSON mime type, the {@link HttpResponse} will use an alternate JSON parser
* that converts long numerals to BigInts. Defaults to `false`.
*/
withLongNumeralsSupport?: boolean;

/** @deprecated use {@link withLongNumeralsSupport} instead */
withLongNumerals?: boolean;
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion src/core/public/ui_settings/ui_settings_client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,13 @@ import { UiSettingsClient } from './ui_settings_client';
let done$: Subject<unknown>;

function setup(options: { defaults?: any; initialSettings?: any } = {}) {
const { defaults = { dateFormat: { value: 'Browser' } }, initialSettings = {} } = options;
const {
defaults = {
dateFormat: { value: 'Browser' },
aLongNumeral: { value: `${BigInt(Number.MAX_SAFE_INTEGER) + 11n}`, type: 'number' },
},
initialSettings = {},
} = options;

const batchSet = jest.fn(() => ({
settings: {},
Expand All @@ -62,6 +68,7 @@ describe('#get', () => {
it('gives access to uiSettings values', () => {
const { client } = setup();
expect(client.get('dateFormat')).toMatchSnapshot();
expect(client.get('aLongNumeral')).toBe(BigInt(Number.MAX_SAFE_INTEGER) + 11n);
});

it('supports the default value overload', () => {
Expand All @@ -82,13 +89,19 @@ describe('#get', () => {
const { client } = setup();
// if you are hitting this error, then a test is setting this client value globally and not unsetting it!
expect(client.isDefault('dateFormat')).toBe(true);
expect(client.isDefault('aLongNumeral')).toBe(true);

const defaultDateFormat = client.get('dateFormat');
const defaultLongNumeral = client.get('aLongNumeral');

expect(client.get('dateFormat', 'xyz')).toBe('xyz');
expect(client.get('aLongNumeral', 1n)).toBe(1n);

// shouldn't change other usages
expect(client.get('dateFormat')).toBe(defaultDateFormat);
expect(client.get('dataFormat', defaultDateFormat)).toBe(defaultDateFormat);
expect(client.get('aLongNumeral')).toBe(defaultLongNumeral);
expect(client.get('aLongNumeral', defaultLongNumeral)).toBe(defaultLongNumeral);
});

it("throws on unknown properties that don't have a value yet.", () => {
Expand Down
10 changes: 5 additions & 5 deletions src/core/public/ui_settings/ui_settings_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ You can use \`IUiSettingsClient.get("${key}", defaultValue)\`, which will just r
return JSON.parse(value);
}

if (type === 'number') {
return parseFloat(value);
}

return value;
return type === 'number' && typeof value !== 'bigint'
? isFinite(value) && (value > Number.MAX_SAFE_INTEGER || value < Number.MIN_SAFE_INTEGER)
? BigInt(value)
: parseFloat(value)
: value;
}

get$<T = any>(key: string, defaultOverride?: T) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/http/router/response.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ export interface HttpResponseOptions {
body?: HttpResponsePayload;
/** HTTP Headers with additional information about response */
headers?: ResponseHeaders;
/** Indicates if alternate serialization should be employed */
withLongNumeralsSupport?: boolean;
}

/**
Expand Down
12 changes: 11 additions & 1 deletion src/core/server/http/router/response_adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
import typeDetect from 'type-detect';
import Boom from '@hapi/boom';
import * as stream from 'stream';
import { stringify } from '@osd/std';

import {
HttpResponsePayload,
Expand Down Expand Up @@ -108,9 +109,18 @@ export class HapiResponseAdapter {
opensearchDashboardsResponse: OpenSearchDashboardsResponse<HttpResponsePayload>
) {
const response = this.responseToolkit
.response(opensearchDashboardsResponse.payload)
.response(
opensearchDashboardsResponse.options.withLongNumeralsSupport
? stringify(opensearchDashboardsResponse.payload)
: opensearchDashboardsResponse.payload
)
.code(opensearchDashboardsResponse.status);
setHeaders(response, opensearchDashboardsResponse.options.headers);
if (opensearchDashboardsResponse.options.withLongNumeralsSupport) {
setHeaders(response, {
'content-type': 'application/json',
});
}
return response;
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/console/public/lib/opensearch/opensearch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export async function send(
body: data,
prependBasePath: true,
asResponse: true,
withLongNumerals: true,
withLongNumeralsSupport: true,
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const setup = (
};

const wrap: HtmlContextTypeConvert = (value, options) => {
return `<span ng-non-bindable>${recurse(value, options)}</span>`;
return `<span>${recurse(value, options)}</span>`;
};

return wrap;
Expand Down
Loading

0 comments on commit 25e54fe

Please sign in to comment.