Skip to content

Commit

Permalink
Auto Generated API - 3.0.0
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <theotr@amazon.com>
  • Loading branch information
nhtruong committed Sep 6, 2024
1 parent 7e38b3b commit c4f510b
Show file tree
Hide file tree
Showing 898 changed files with 51,207 additions and 40,468 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bundler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Use Node.js 14.x
uses: actions/setup-node@v3
with:
node-version: 14.x
node-version: 18.x

# NPM started understanding yarn.lock file starting from v7
- name: Update NPM
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
- name: Use Node.js 16.x
uses: actions/setup-node@v3
with:
node-version: 16.x
node-version: 18.x

- name: Install
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
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 @@ -11,7 +11,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
ruby-version: 16.x
node-version: 18.x
- name: Install Tools
run: |
sudo apt install -y jq
Expand Down
11 changes: 5 additions & 6 deletions .github/workflows/integration-unreleased.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ jobs:
fail-fast: false
matrix:
entry:
- { node_version: '16.x', opensearch_ref: '1.x', jdk_version: '11' }
- { node_version: '16.x', opensearch_ref: '2.0', jdk_version: '17' }
- { node_version: '16.x', opensearch_ref: '2.x', jdk_version: '17' }
- { node_version: '16.x', opensearch_ref: 'main', jdk_version: '17' }
- { node_version: '18.x', opensearch_ref: '1.x', jdk_version: '11' }
- { node_version: '18.x', opensearch_ref: '2.0', jdk_version: '17' }
- { node_version: '18.x', opensearch_ref: '2.x', jdk_version: '17' }
- { node_version: '18.x', opensearch_ref: 'main', jdk_version: '17' }
steps:
- name: Checkout OpenSearch
uses: actions/checkout@v3
Expand All @@ -36,7 +36,6 @@ jobs:
working-directory: opensearch
run: echo key=`git log -1 --format='%H'` >> $GITHUB_OUTPUT


- name: Restore cached build
id: cache-restore
uses: actions/cache/restore@v3
Expand Down Expand Up @@ -108,4 +107,4 @@ jobs:
with:
name: opensearch-logs-${{ matrix.entry.opensearch_ref }}-js-${{ matrix.entry.node_version }}
path: |
opensearch/distribution/archives/linux-tar/build/distributions/**/logs/*
opensearch/distribution/archives/linux-tar/build/distributions/**/logs/*
4 changes: 2 additions & 2 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:

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

env:
SECURE_INTEGRATION: false
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:

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

env:
SECURE_INTEGRATION: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/license.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
node-version: [12.x]
node-version: [18.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

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

steps:
Expand Down
5 changes: 0 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@ jspm_packages
#Jetbrains editor folder
.idea

# opensearch repo or binary files
opensearch*
!opensearch_dashboards*
!opensearchDashboards*

# documentation
docs/

Expand Down
77 changes: 0 additions & 77 deletions .npmignore

This file was deleted.

15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,21 @@

Inspired by [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)

## [3.0.0]
### Added
### Dependencies
### Changed
- All API functions are now generated from the OpenSearch API specification.
- API request and response types are now generated from the OpenSearch API specification.
- Overhauled API codebase and break it into smaller, more manageable files for better readability and maintainability.
### Deprecated
### Removed
- *BREAKING* Removed support for API param aliases. That is, the API functions now only accept params with the exact names specified in the OpenSearch API specification.
- *BREAKING* Removed support for snake_cased API function names. All API functions are now camelCased only to conform to JavaScript naming conventions.
- *BREAKING* Removed support for Node.js 10 through 16. The minimum supported Node.js version is now 18.
### Fixed
### Security

## [Unreleased]
### Added
### Dependencies
Expand Down
37 changes: 37 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Upgrading Opensearch JavaScript Client
## Upgrading from 2.x to 3.x
Starting from 3.x, the API functions and modules of the Opensearch JavaScript are generated from the OpenSearch REST API specification. While the vast majority of the API remains the same, there are some changes that you should be aware of when upgrading from 2.x to 3.x.
### Breaking Changes

- **Removed camelCase params**: Every API function now only accepts parameters matching the OpenSearch API Spec, which are also what the OpenSearch server expects. In previous versions, some API functions would convert camelCase parameters to snake_case before sending them to the server. This is no longer the case. For example, the `client.search()` function now only accepts `filter_path`, and passing `filterPath` will result in an error from the server.


- **Removed overridden HTTP methods**: The 3.x client no longer allows overriding the HTTP method for API functions. In previous versions, some API functions let you pass `method` as a parameter to the API functions to override the default HTTP method. Now, `method` will be considered a querystring param, and using it will likely result in an error. If you need to send a custom request, you should use the `client.http` namespace.


- **Changes in Request and Response types**: The biggest improvement in 3.x is the addition of all the request and response types for each API function. This means that you can now see the exact shape of the request and response objects for each API function. This is especially useful for TypeScript users, as it provides a better developer experience. However, previously handwritten request and response types have been replaced by those generated from the spec, so you may need to update your code to match the new types:

In 2.x:
```ts
import { Client, type opensearchtypes, type RequestParams } from '@opensearch-project/opensearch';

const client = new Client({ node: 'http://localhost:9200' });

const searchRequest: RequestParams.Search = { body: { query: { match: { director: 'miller' } } } };
const searchResponse = (await client.search(searchBody)).body as opensearchtypes.SearchResponse;
```

In 3.x:
```ts
import { Client, type API } from '@opensearch-project/opensearch';

const client = new Client({ node: 'http://localhost:9200' });

const searchRequest: API.Search_Request = { body: { query: { match: { director: 'miller' } } } };
const searchResponse = (await client.search(searchBody)).body;
// Note that the response type is now inferred, and you don't need to cast with `as API.Search_ResponseBody`
```

### Deprecations

- **snake_case API modules and functions**: In 3.x, all API modules and functions are now in camelCase, comforming to the naming convention of Javascript. The snake_case aliases are still available but are deprecated and will be removed in a future version.
Loading

0 comments on commit c4f510b

Please sign in to comment.