Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement BigInt support for REST client #62

Merged
merged 3 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
node-version: [21]
Rendez marked this conversation as resolved.
Show resolved Hide resolved
os:
- ubuntu-latest
- windows-latest
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
node-version: [21]
steps:
- uses: actions/checkout@v3

Expand Down
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
loglevel = warn
save-exact = true
engine-strict = true
engine-strict = false
Rendez marked this conversation as resolved.
Show resolved Hide resolved
node-version=18.0.0
strict-peer-dependencies = true
auto-install-peers = true
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"node": ">=18.0.0",
"pnpm": ">=8"
},
"packageManager": "pnpm@8.3.0",
generall marked this conversation as resolved.
Show resolved Hide resolved
"packageManager": "pnpm@8.15.3",
"scripts": {
"prepare": "node scripts/prepare.cjs && pnpm -r build",
"ci:version": "pnpm changeset version && pnpm install --no-frozen-lockfile && git add .",
Expand Down
29 changes: 28 additions & 1 deletion packages/js-client-grpc/tests/integration/qdrant-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('QdrantClient', () => {
/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
const client = new QdrantClient();
const collectionName = 'test_collection';
const bigInt = BigInt(String(Number.MAX_SAFE_INTEGER + 2));
IvanPleshkov marked this conversation as resolved.
Show resolved Hide resolved

test('signal abort: timeout', async () => {
const client = new QdrantClient({timeout: 0});
Expand Down Expand Up @@ -217,6 +218,14 @@ describe('QdrantClient', () => {
},
},
},
{
id: {
pointIdOptions: {case: 'num', value: bigInt},
},
vectors: {
vectorsOptions: {case: 'vector', value: {data: [0.18, 0.01, 0.85, 0.8]}},
},
},
{
id: {
pointIdOptions: {case: 'uuid', value: '98a9a4b1-4ef2-46fb-8315-a97d874fe1d7'},
Expand Down Expand Up @@ -315,6 +324,24 @@ describe('QdrantClient', () => {
});
});

test('retrieve point by uint64 id (BigInt)', async () => {
const points = (
await client.api('points').get({
collectionName,
ids: [
{
pointIdOptions: {case: 'num', value: bigInt},
},
],
})
).result;
expect(points[0].toJson()).toMatchObject({
id: {
num: bigInt.toString(),
},
});
});

test('retrieve points', async () => {
const points = (
await client.api('points').get({
Expand All @@ -335,7 +362,7 @@ describe('QdrantClient', () => {
test('retrieve all points', async () => {
const result = (await client.api('collections').get({collectionName})).result!;
expect(result.toJson(), 'check failed - 6 points expected').toMatchObject({
vectorsCount: '6',
vectorsCount: '7',
generall marked this conversation as resolved.
Show resolved Hide resolved
});
});

Expand Down
8 changes: 4 additions & 4 deletions packages/js-client-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@
"openapi_schema_remote": "https://raw.githubusercontent.com/qdrant/qdrant/master/docs/redoc/master/openapi.json"
},
"dependencies": {
"@sevinf/maybe": "^0.5.0",
"@qdrant/openapi-typescript-fetch": "^1.2.1",
"undici": "^5.26.2"
"@sevinf/maybe": "0.5.0",
"@qdrant/openapi-typescript-fetch": "1.2.4",
"undici": "5.28.3"
},
"devDependencies": {
"@rollup/plugin-commonjs": "^24.1.0",
Expand All @@ -66,6 +66,6 @@
"vitest": "^0.31.4"
},
"peerDependencies": {
"typescript": ">=4.1"
"typescript": ">=4.7"
}
}
21 changes: 20 additions & 1 deletion packages/js-client-rest/tests/integration/qdrant-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ describe('QdrantClient', () => {
const DIM = 100;
const client = new QdrantClient();
const collectionName = 'test_collection';
const bigInt = BigInt(String(Number.MAX_SAFE_INTEGER + 2)) as unknown as number;
IvanPleshkov marked this conversation as resolved.
Show resolved Hide resolved
const maxSafeInteger = Number.MAX_SAFE_INTEGER;

test('Qdrant service check', async () => {
const {data} = await client.api('service').telemetry({});
Expand Down Expand Up @@ -93,6 +95,8 @@ describe('QdrantClient', () => {
{id: 2, vector: [0.19, 0.81, 0.75, 0.11], payload: {city: ['Berlin', 'London']}},
{id: 3, vector: [0.36, 0.55, 0.47, 0.94], payload: {city: ['Berlin', 'Moscow']}},
{id: 4, vector: [0.18, 0.01, 0.85, 0.8], payload: {city: ['London', 'Moscow']}},
{id: bigInt, vector: [0.19, 0.81, 0.75, 0.11]},
{id: maxSafeInteger, vector: [0.19, 0.81, 0.75, 0.11]},
{id: '98a9a4b1-4ef2-46fb-8315-a97d874fe1d7', vector: [0.24, 0.18, 0.22, 0.44], payload: {count: [0]}},
{id: 'f0e09527-b096-42a8-94e9-ea94d342b925', vector: [0.35, 0.08, 0.11, 0.44]},
],
Expand All @@ -109,6 +113,21 @@ describe('QdrantClient', () => {
});
});

test('retrieve point by uint64 id (BigInt)', async () => {
let result = (await client.api('points').getPoint({collection_name: collectionName, id: bigInt})).data.result!;
expect(result).toMatchObject<typeof result>({
id: bigInt,
vector: [0.19, 0.81, 0.75, 0.11],
});

result = (await client.api('points').getPoint({collection_name: collectionName, id: maxSafeInteger})).data
.result!;
expect(result).toMatchObject<typeof result>({
id: maxSafeInteger,
vector: [0.19, 0.81, 0.75, 0.11],
});
});

test('retrieve points', async () => {
const result = await client.retrieve(collectionName, {ids: [1, 2]});
expect(result).toHaveLength(2);
Expand All @@ -117,7 +136,7 @@ describe('QdrantClient', () => {
test('retrieve all points', async () => {
const result = await client.getCollection(collectionName);
expect(result, 'check failed - 6 points expected').toMatchObject<Pick<typeof result, 'vectors_count'>>({
vectors_count: 6,
vectors_count: 8,
});
});

Expand Down
1 change: 1 addition & 0 deletions packages/js-client-rest/tests/unit/api-client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ describe('apiClient', () => {
ok: true,
status,
json: () => new Promise((resolve) => resolve({error_message: 'response error'})),
text: () => new Promise((resolve) => resolve(JSON.stringify({error_message: 'response error'}))),
});
let originalFetch: typeof global.fetch;

Expand Down
28 changes: 16 additions & 12 deletions pnpm-lock.yaml

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

Loading