Skip to content

Commit

Permalink
Auto Generated API - 3.0.0 (#864)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhtruong authored Sep 10, 2024
1 parent 6fa39d5 commit 0805235
Show file tree
Hide file tree
Showing 819 changed files with 49,755 additions and 39,512 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.

19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,37 @@

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


## [Unreleased]
### Added
### Dependencies
### Changed
### Deprecated
### Removed
### Fixed
### Security

## [3.0.0]
### Added
- Added missing API functions and modules.
- Added missing request and response types.
### Dependencies
- Bumps `micromatch` from 4.0.7 to 4.0.8
- Bumps `debug` from 4.3.6 to 4.3.7
- Bumps `simple-statistics` from 7.8.4 to 7.8.5
- Bumps `simple-git` from 3.25.0 to 3.26.0
- Bumps `@types/node` from 22.5.0 to 22.5.4
- Bumps `aws4` from 1.13.1 to 1.13.2
### 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
- Support for snake_cased API function aliases have been deprecated to conform to JavaScript naming conventions.
### Removed
- 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.
- Removed support for overriding HTTP methods in API functions.
- Removed support for Node.js 10 through 16. The minimum supported Node.js version is now 18.
### Fixed
### Security

Expand Down
62 changes: 62 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<!-- TOC -->
* [Upgrading The Opensearch JavaScript Client](#upgrading-the-opensearch-javascript-client)
* [Upgrading from 2.x to 3.x](#upgrading-from-2x-to-3x)
* [Breaking Changes](#breaking-changes)
* [Removed camelCase params:](#removed-camelcase-params-)
* [Removed overridden HTTP methods:](#removed-overridden-http-methods-)
* [Changes in Request and Response types:](#changes-in-request-and-response-types-)
* [Deprecations](#deprecations)
<!-- TOC -->

# Upgrading The Opensearch JavaScript Client
## Upgrading from 2.x to 3.x
Starting from 3.x, the API functions and modules in opensearch-js are generated from the [OpenSearch REST API specification](https://github.com/opensearch-project/opensearch-api-specification/). While the vast majority of the API remains the same, there are some breaking changes that may require updating your application 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 now only accepts `filter_path` as a parameter, 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.

In 2.x:
```ts
// Forcing a GET request even though the API function defaults to POST for search request with a body
client.search({ method: 'GET', body: { query: { match: { director: 'miller' } } } });
```

In 3.x:
```ts
// Use the `client.http` namespace to send a custom request to achieve the same effect
client.http.get({ path: '/_search', body: { query: { match: { director: 'miller' } } } });
```


#### 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 0805235

Please sign in to comment.