Skip to content

Commit fb009e1

Browse files
authored
gRPC client + project setup overhaul (#24)
- Generated gRPC client based on plugins from @bufbuild - REST client accepts maxConnections now using undici.js agent for fetch - Updated OAS definitions and improved generated types - Improved NPM dependency management in monorepo - Improved linting and tooling setup - Added CI check to avoid bumping a version of clients too early
1 parent 5413e88 commit fb009e1

File tree

137 files changed

+19218
-1181
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

137 files changed

+19218
-1181
lines changed

.changeset/kind-days-explain.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@qdrant/js-client-grpc': patch
3+
'@qdrant/js-client-rest': patch
4+
'@qdrant/qdrant-js': patch
5+
---
6+
7+
Added gRPC client

.eslintrc.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"root": true,
3+
"env": {
4+
"node": true
5+
},
6+
"ignorePatterns": ["**/node_modules/**", "scripts/*"],
7+
"parser": "@typescript-eslint/parser",
8+
"parserOptions": {
9+
"project": ["./tsconfig.base.json"]
10+
},
11+
"plugins": ["@typescript-eslint"],
12+
"extends": [
13+
"eslint:recommended",
14+
"plugin:@typescript-eslint/eslint-recommended",
15+
"plugin:@typescript-eslint/recommended-requiring-type-checking",
16+
"plugin:@typescript-eslint/strict"
17+
],
18+
"rules": {
19+
"object-shorthand": "warn",
20+
"arrow-body-style": "warn",
21+
"no-unused-vars": "off",
22+
"@typescript-eslint/no-unused-vars": [
23+
"error",
24+
{
25+
"args": "all",
26+
"argsIgnorePattern": "^_",
27+
"ignoreRestSiblings": true
28+
}
29+
],
30+
"@typescript-eslint/consistent-type-definitions": "off"
31+
}
32+
}

.github/workflows/pull_request.yaml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
steps:
1717
- uses: actions/checkout@v3
1818
with:
19-
fetch-depth: 0
19+
ref: ${{ github.event.pull_request.head.sha }}
2020

2121
- uses: pnpm/action-setup@v2
2222
with:
@@ -36,18 +36,21 @@ jobs:
3636
env:
3737
CI: 1
3838

39-
- name: Open API schema changes
39+
- name: Generated OpenAPI update check
4040
run: |
4141
pnpm --filter "@qdrant/js-client-rest" codegen:openapi-typescript
42-
if ( git diff-index HEAD | grep -q README.md || exit ) then
43-
echo "Generated schema changed. Please update with pnpm -r codegen:openapi-typescript.";
42+
if ( git diff --name-only | grep -q packages/js-client-rest/src/openapi/ || exit ) then
43+
echo "Generated schema changed. Please update with: 'pnpm -r codegen:openapi-typescript'.";
4444
exit 1
4545
fi
4646
shell: bash
4747

48-
- name: Run checks
48+
- name: Project checks
4949
run: pnpm -r pre-check
5050

51-
- name: Open API integration tests
52-
run: cd packages/js-client-rest && ./tests/integration-tests.sh
51+
- name: Integration tests
52+
run: packages/qdrant-js/scripts/integration-tests.sh
5353
shell: bash
54+
env:
55+
QDRANT_URL: ${{ secrets.QDRANT_URL }}
56+
QDRANT_API_KEY: ${{ secrets.QDRANT_API_KEY }}

.prettierignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,2 @@
11
**/node_modules/
2-
**/dist/
3-
**/src/openapi/
4-
**/src/proto/
52
**/pnpm-lock.yaml

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"typescript.tsdk": "node_modules/typescript/lib",
3-
"eslint.workingDirectories": ["packages/js-client-rest", "packages/js-client-grpc"]
3+
"eslint.workingDirectories": ["packages/qdrant-js", "packages/js-client-rest", "packages/js-client-grpc"]
44
}

README.md

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
<p align="center">
32
<img height="100" src="https://github.com/qdrant/qdrant/raw/master/docs/logo.svg" alt="Qdrant">
43
&nbsp;
@@ -9,8 +8,7 @@
98
<b>JavaScript/TypeScript library for the <a href="https://github.com/qdrant/qdrant">Qdrant</a> vector search engine.</b>
109
</p>
1110

12-
13-
<p align=center>
11+
<p align="center">
1412
<a href="https://www.npmjs.com/package/@qdrant/qdrant-js"><img src="https://badge.fury.io/js/@qdrant%2Fqdrant-js.svg" alt="npm version" height="18"></a>
1513
<a href="https://qdrant.github.io/qdrant/redoc/index.html"><img src="https://img.shields.io/badge/Docs-OpenAPI%203.0-success" alt="OpenAPI Docs"></a>
1614
<a href="https://github.com/qdrant/qdrant-client/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-Apache%202.0-success" alt="Apache 2.0 License"></a>
@@ -22,23 +20,22 @@
2220

2321
This repository contains packages of the JS SDK for the [Qdrant](https://github.com/qdrant/qdrant) vector search engine.
2422

25-
There are 3 packages:
26-
27-
* [`@qdrant/qdrant-js`](./packages/qdrant-js) - the main package with the SDK itself.
28-
* [`@qdrant/js-client-rest`](./packages/js-client-rest) - leightweight REST client for Qdrant.
29-
* [`@qdrant/js-client-grpc`](./packages/js-client-grpc) - WIP gRPC client for Qdrant.
23+
There are published 3 packages:
3024

25+
- [`@qdrant/qdrant-js`](./packages/qdrant-js) - the main package with the SDK itself.
26+
- [`@qdrant/js-client-rest`](./packages/js-client-rest) - lightweight REST client for Qdrant.
27+
- [`@qdrant/js-client-grpc`](./packages/js-client-grpc) - gRPC client for Qdrant.
3128

3229
## JS/TS Examples
3330

3431
### Installation
3532

3633
```shell
34+
pnpm i @qdrant/js-client-rest
35+
# or
3736
npm install @qdrant/js-client-rest
3837
# or
3938
yarn add @qdrant/js-client-rest
40-
# or
41-
pnpm i @qdrant/js-client-rest
4239
```
4340

4441
### Usage
@@ -75,19 +72,24 @@ console.log('List of collections:', result.collections);
7572

7673
More examples can be found in the [`examples`](./examples) folder.
7774

75+
## Support
7876

77+
TypeScript types are provided alongside JavaScript sources to be used in:
78+
79+
- Node.js (ESM and CJS) - `>= 18.0.0`
80+
- Deno
81+
- Browser (fetch API)
82+
- Cloudflare Workers (OpenAPI only)
7983

8084
## Releases
8185

8286
Major and minor versions align with Qdrant's engine releases, whilst patch are reserved for fixes regarding the current minor release. Check out [RELEASE.md](./RELEASE.md) for more info on release guidelines.
8387

8488
For release automation we use [`changesets`](https://github.com/changesets/changesets) both for pull requests and pushes to the master branch, and their [Github Action](https://github.com/changesets/action) to automate changeset steps.
8589

86-
## Contributions
87-
88-
In order to contribute there are a couple of things you may need to do.
90+
## Contributing
8991

90-
We make use of [`pnpm`](https://pnpm.io/) instead of `npm` or `yarn` to manage and install packages in this monorepo, make sure it's installed on your local environment.
92+
In order to [contribute](./CONTRIBUTING.md) there are a couple of things you may need to setup. We make use of [`pnpm`](https://pnpm.io/) instead of `npm` or `yarn` to manage and install packages in this monorepo, make sure it's installed on your local environment.
9193

9294
After checking out the repository and desired branch, run `pnpm install` to install all package's dependencies and run the compilation steps. This will work for the monorepo.
9395

RELEASE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ New releases are made from the `master` branch following semver. Major and minor
1313

1414
2. (**AC**) Then open a pull request.
1515

16-
3. (**RC**) verifies the **semver** version commitment and turns it into a bump wtih `pnpm run version` on the root directory. This updates the versions on package.json files and updates the CHANGELOG.md files.
16+
3. (**RC**) verifies the **semver** version commitment and turns it into a bump with `pnpm ci:version` on the root directory. This updates the versions on package.json files and updates the CHANGELOG.md files.
1717

1818
> This last step if skipped could result in an outdated pnpm lock file, and if so, update it manually with: `pnpm install --lockfile-only`.
1919

examples/node-js-basic/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {QdrantClient} from '@qdrant/js-client-rest';
1+
import {QdrantClient} from '@qdrant/qdrant-js';
22

33
async function main() {
44
const collectionName = 'test_collection';
@@ -69,8 +69,8 @@ async function main() {
6969
});
7070

7171
const collectionInfo = await client.getCollection(collectionName);
72-
console.log(collectionInfo.points_count);
73-
// prints: 6
72+
console.log('number of points:', collectionInfo.points_count);
73+
// prints: number of points: 6
7474

7575
const points = await client.retrieve(collectionName, {
7676
ids: [1, 2],
@@ -230,9 +230,7 @@ async function main() {
230230

231231
main()
232232
.then((code) => {
233-
if (code !== 0) {
234-
process.exit(code);
235-
}
233+
process.exit(code);
236234
})
237235
.catch((err) => {
238236
console.error(err);

examples/node-js-basic/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@
1515
"author": "Qdrant Team",
1616
"license": "Apache-2.0",
1717
"dependencies": {
18-
"@qdrant/js-client-rest": "^1.1.3"
18+
"@qdrant/qdrant-js": "^1.2.0"
1919
}
2020
}

package.json

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,38 @@
88
},
99
"packageManager": "[email protected]",
1010
"scripts": {
11-
"prepare": "node ./prepare.cjs && pnpm -r build",
11+
"prepare": "node scripts/prepare.cjs && pnpm -r build",
1212
"ci:version": "pnpm changeset version && pnpm install --no-frozen-lockfile && git add .",
13-
"ci:release": "pnpm changeset publish"
13+
"ci:release": "node scripts/prepublish.mjs && pnpm changeset publish"
14+
},
15+
"lint-staged": {
16+
"*.ts": [
17+
"prettier --list-different",
18+
"eslint"
19+
],
20+
"*.{md,yaml}": "prettier --list-different"
1421
},
1522
"devDependencies": {
16-
"@changesets/changelog-github": "0.4.8",
17-
"@changesets/cli": "2.26.1",
18-
"husky": "8.0.3",
19-
"is-ci": "3.0.1",
20-
"prettier": "2.8.7",
21-
"typescript": "5.0.4"
23+
"@changesets/changelog-github": "^0.4.8",
24+
"@changesets/cli": "^2.26.1",
25+
"@rollup/plugin-node-resolve": "^15.0.2",
26+
"@rollup/plugin-terser": "^0.4.1",
27+
"@types/node": "^20.1.3",
28+
"@typescript-eslint/eslint-plugin": "^5.59.5",
29+
"@typescript-eslint/parser": "^5.59.5",
30+
"eslint": "^8.41.0",
31+
"husky": "^8.0.3",
32+
"is-ci": "^3.0.1",
33+
"lint-staged": "^13.2.2",
34+
"prettier": "^2.8.8",
35+
"rimraf": "^5.0.0",
36+
"rollup": "^3.21.6",
37+
"ts-node": "^10.9.1",
38+
"typescript": "^5.0.4"
2239
},
2340
"pnpm": {
2441
"overrides": {
25-
"[email protected] || 2.x": "^2.2.2"
42+
"@bufbuild/protobuf@^1.2.0": "file:./packages/js-client-grpc/includes/bufbuild-protobuf-1.2.1.tgz"
2643
}
2744
}
2845
}

0 commit comments

Comments
 (0)