Skip to content

Commit

Permalink
Merge branch 'opensearch-project:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
timursaurus authored Jul 14, 2023
2 parents 2f2aea2 + 08069bc commit eeed81a
Show file tree
Hide file tree
Showing 17 changed files with 527 additions and 17 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,32 @@ jobs:
contents: write
pull-requests: write
name: Backport
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
if: >
github.event.pull_request.merged
&& (
github.event.action == 'closed'
|| (
github.event.action == 'labeled'
&& contains(github.event.label.name, 'backport')
)
)
steps:
- name: GitHub App token
id: github_app_token
uses: tibdex/github-app-token@v1.5.0
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
# opensearch-trigger-bot installation ID
installation_id: 22958780

- name: Backport
uses: VachaShah/backport@v1.1.4
uses: VachaShah/backport@v2.2.0
with:
github_token: ${{ steps.github_app_token.outputs.token }}
branch_name: backport/backport-${{ github.event.number }}
head_template: backport/backport-<%= number %>-to-<%= base %>
files_to_skip: "CHANGELOG.md"
labels_template: "<%= JSON.stringify([...labels, 'autocut']) %>"
failure_labels: "failed backport"
13 changes: 12 additions & 1 deletion .github/workflows/bundler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,21 @@ jobs:
make cluster.clean cluster.opensearch.build cluster.opensearch.start
- name: Use Node.js 14.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 14.x

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
shell: bash
run: |
export NPM_VERSION=$(npm -v)
export IS_NPM_SUITABLE=$(node -p "parseInt(process.env.NPM_ROOT, 10) >= 7")
if [ "$IS_NPM_SUITABLE" == "false" ]; then
echo "NPM needs upgrading!"
npm i npm@7 -g
fi
- name: Install
run: |
npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
make cluster.clean cluster.opensearch.build cluster.opensearch.start
- name: Use Node.js 16.x
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: 16.x

Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,21 @@ jobs:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
shell: bash
run: |
export NPM_VERSION=$(npm -v)
export IS_NPM_SUITABLE=$(node -p "parseInt(process.env.NPM_ROOT, 10) >= 7")
if [ "$IS_NPM_SUITABLE" == "false" ]; then
echo "NPM needs upgrading!"
npm i npm@7 -g
fi
- name: Install
run: |
npm install
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gh_pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
name: Update gh-pages with docs
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v1
- uses: actions/setup-node@v3
with:
ruby-version: 16.x
- name: Install Tools
Expand Down
30 changes: 26 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -34,10 +34,21 @@ jobs:
make cluster.clean cluster.opensearch.build cluster.opensearch.start
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
shell: bash
run: |
export NPM_VERSION=$(npm -v)
export IS_NPM_SUITABLE=$(node -p "parseInt(process.env.NPM_ROOT, 10) >= 7")
if [ "$IS_NPM_SUITABLE" == "false" ]; then
echo "NPM needs upgrading!"
npm i npm@7 -g
fi
- name: Install
run: |
npm install
Expand All @@ -52,7 +63,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand All @@ -70,10 +81,21 @@ jobs:
make cluster.clean cluster.opensearch.build cluster.opensearch.start
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
shell: bash
run: |
export NPM_VERSION=$(npm -v)
export IS_NPM_SUITABLE=$(node -p "parseInt(process.env.NPM_ROOT, 10) >= 7")
if [ "$IS_NPM_SUITABLE" == "false" ]; then
echo "NPM needs upgrading!"
npm i npm@7 -g
fi
- name: Install
run: |
npm install
Expand Down
13 changes: 12 additions & 1 deletion .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,21 @@ jobs:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
shell: bash
run: |
export NPM_VERSION=$(npm -v)
export IS_NPM_SUITABLE=$(node -p "parseInt(process.env.NPM_ROOT, 10) >= 7")
if [ "$IS_NPM_SUITABLE" == "false" ]; then
echo "NPM needs upgrading!"
npm i npm@7 -g
fi
- name: Install
run: |
npm install
Expand Down
15 changes: 13 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,28 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x, 16.x]
node-version: [10.x, 12.x, 14.x, 16.x, 18.x]
os: [ubuntu-latest, windows-latest, macOS-latest]

steps:
- uses: actions/checkout@v2

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
shell: bash
run: |
export NPM_VERSION=$(npm -v)
export IS_NPM_SUITABLE=$(node -p "parseInt(process.env.NPM_ROOT, 10) >= 7")
if [ "$IS_NPM_SUITABLE" == "false" ]; then
echo "NPM needs upgrading!"
npm i npm@7 -g
fi
- name: Install
run: |
npm install
Expand Down
15 changes: 14 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [Unreleased]
### Added
### Dependencies
### Changed
- Make handling of long numerals an option that is disabled by default ([#557](https://github.com/opensearch-project/opensearch-js/pull/557))
### Deprecated
### Removed
### Fixed
### Security

## [2.3.0]

### Added
- Add serialization and deserialization of numerals larger than `Number.MAX_SAFE_INTEGER` ([#544](https://github.com/opensearch-project/opensearch-js/pull/544))
### Dependencies
- Bumps `prettier` from 2.8.7 to 2.8.8
- Bumps `ora` from 6.1.2 to 6.3.1
Expand All @@ -19,6 +30,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bumps `proxy` from 1.0.2 to 2.1.1
### Changed
- Implemented Docker Image caching for `integration-unreleased` workflow ([#387](https://github.com/opensearch-project/opensearch-js/issues/387))
- Add upgrading NPM to all workflows running older Node.js versions ([#545](https://github.com/opensearch-project/opensearch-js/issues/545))
- Upgrade and secure the backport workflow ([#547](https://github.com/opensearch-project/opensearch-js/issues/547))
### Deprecated
### Removed
### Fixed
Expand Down Expand Up @@ -154,4 +167,4 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
[2.1.0]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.1.0
[2.2.0]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.2.0
[2.2.1]: https://github.com/opensearch-project/opensearch-js/releases/tag/2.2.1
[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.2.1...HEAD
[Unreleased]: https://github.com/opensearch-project/opensearch-js/compare/2.2.1...HEAD
16 changes: 16 additions & 0 deletions USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [Authenticate with Amazon OpenSearch Service](#authenticate-with-amazon-opensearch-service)
- [Using AWS V2 SDK](#using-aws-v2-sdk)
- [Using AWS V3 SDK](#using-aws-v3-sdk)
- [Enable Handling of Long Numerals](#enable-handling-of-long-numerals)
- [Create an Index](#create-an-index)
- [Add a Document to the Index](#add-a-document-to-the-index)
- [Search for the Document](#search-for-the-document)
Expand Down Expand Up @@ -107,6 +108,21 @@ const client = new Client({
});
```

### Enable Handling of Long Numerals

JavaScript can safely work with integers from -(2<sup>53</sup> - 1) to 2<sup>53</sup> - 1. However,
serialized JSON texts from other languages can potentially have numeric values beyond that range and the native
serialization and deserialization methods of JavaScript's JSON, incapable of parsing them with precision; these
values get rounded to fit the IEEE-754 representation.

The `Client` can be configured to appropriately deserialize long numerals as `BigInt` values and vice versa:

```javascript
const client = new Client({
enableLongNumeralSupport: true,
});
```

## Create an Index

```javascript
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class Client extends OpenSearchAPI {
proxy: null,
enableMetaHeader: true,
disablePrototypePoisoningProtection: false,
enableLongNumeralSupport: false,
},
opts
);
Expand All @@ -151,6 +152,7 @@ class Client extends OpenSearchAPI {
this[kEventEmitter] = new EventEmitter();
this.serializer = new options.Serializer({
disablePrototypePoisoningProtection: options.disablePrototypePoisoningProtection,
enableLongNumeralSupport: options.enableLongNumeralSupport,
});
this.connectionPool = new options.ConnectionPool({
pingTimeout: options.pingTimeout,
Expand Down
1 change: 1 addition & 0 deletions lib/Serializer.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

export interface SerializerOptions {
disablePrototypePoisoningProtection: boolean | 'proto' | 'constructor';
enableLongNumeralSupport: boolean;
}

export default class Serializer {
Expand Down
Loading

0 comments on commit eeed81a

Please sign in to comment.