Socket
Socket
Sign inDemoInstall

@qdrant/js-client-rest

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@qdrant/js-client-rest - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

dist/cjs/dispatcher.js

16

./dist/cjs/index.js
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,2 +20,2 @@ exports.QdrantClient = void 0;

Object.defineProperty(exports, "QdrantClient", { enumerable: true, get: function () { return qdrant_client_js_1.QdrantClient; } });
// comment
__exportStar(require("./errors.js"), exports);

2

dist/browser/index.min.js

@@ -1,1 +0,1 @@

var t={isNone:function(){return!0},orElse:function(t){return t},orCall:function(t){return t()},orNull:function(){return null},orThrow:function(t){throw void 0===t&&(t="Unexpected null value"),new TypeError(t)},map:function(){return t},get:function(){return t}},e=function(){function t(t){this.value=t}return t.prototype.isNone=function(){return!1},t.prototype.orElse=function(){return this.value},t.prototype.orCall=function(){return this.value},t.prototype.orNull=function(){return this.value},t.prototype.orThrow=function(){return this.value},t.prototype.map=function(t){return o(t(this.value))},t.prototype.get=function(t){return this.map((function(e){return e[t]}))},t}();function o(o){return function(o){return o===t||o instanceof e}(o)?o:null==o?t:function(t){if(null==t)throw new TypeError("some() does not accept null or undefined");return new e(t)}(o)}function n(t){return{clusterStatus:t.path("/cluster").method("get").create(),collectionClusterInfo:t.path("/collections/{collection_name}/cluster").method("get").create(),recoverCurrentPeer:t.path("/cluster/recover").method("post").create(),removePeer:t.path("/cluster/peer/{peer_id}").method("delete").create({force:!0}),updateCollectionCluster:t.path("/collections/{collection_name}/cluster").method("post").create({timeout:!0})}}function r(t){return{collectionClusterInfo:t.path("/collections/{collection_name}/cluster").method("get").create(),createCollection:t.path("/collections/{collection_name}").method("put").create({timeout:!0}),createFieldIndex:t.path("/collections/{collection_name}/index").method("put").create({ordering:!0,wait:!0}),createSnapshot:t.path("/collections/{collection_name}/snapshots").method("post").create({wait:!0}),deleteCollection:t.path("/collections/{collection_name}").method("delete").create({timeout:!0}),deleteFieldIndex:t.path("/collections/{collection_name}/index/{field_name}").method("delete").create({ordering:!0,wait:!0}),deleteSnapshots:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("delete").create({wait:!0}),getCollection:t.path("/collections/{collection_name}").method("get").create(),getCollectionAliases:t.path("/collections/{collection_name}/aliases").method("get").create(),getCollections:t.path("/collections").method("get").create(),getCollectionsAliases:t.path("/aliases").method("get").create(),getSnapshot:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("get").create(),listSnapshots:t.path("/collections/{collection_name}/snapshots").method("get").create(),recoverFromSnapshot:t.path("/collections/{collection_name}/snapshots/recover").method("put").create({wait:!0}),updateAliases:t.path("/collections/aliases").method("post").create({timeout:!0}),updateCollection:t.path("/collections/{collection_name}").method("patch").create({timeout:!0}),updateCollectionCluster:t.path("/collections/{collection_name}/cluster").method("post").create({timeout:!0})}}function s(t){return{clearPayload:t.path("/collections/{collection_name}/points/payload/clear").method("post").create({ordering:!0,wait:!0}),countPoints:t.path("/collections/{collection_name}/points/count").method("post").create(),deletePayload:t.path("/collections/{collection_name}/points/payload/delete").method("post").create({wait:!0,ordering:!0}),deletePoints:t.path("/collections/{collection_name}/points/delete").method("post").create({wait:!0,ordering:!0}),updateVectors:t.path("/collections/{collection_name}/points/vectors").method("put").create({wait:!0,ordering:!0}),deleteVectors:t.path("/collections/{collection_name}/points/vectors/delete").method("post").create({wait:!0,ordering:!0}),getPoint:t.path("/collections/{collection_name}/points/{id}").method("get").create(),getPoints:t.path("/collections/{collection_name}/points").method("post").create({consistency:!0}),overwritePayload:t.path("/collections/{collection_name}/points/payload").method("put").create({wait:!0,ordering:!0}),recommendBatchPoints:t.path("/collections/{collection_name}/points/recommend/batch").method("post").create({consistency:!0}),recommendPoints:t.path("/collections/{collection_name}/points/recommend").method("post").create({consistency:!0}),searchPointGroups:t.path("/collections/{collection_name}/points/search/groups").method("post").create({consistency:!0}),scrollPoints:t.path("/collections/{collection_name}/points/scroll").method("post").create({consistency:!0}),searchBatchPoints:t.path("/collections/{collection_name}/points/search/batch").method("post").create({consistency:!0}),searchPoints:t.path("/collections/{collection_name}/points/search").method("post").create({consistency:!0}),setPayload:t.path("/collections/{collection_name}/points/payload").method("post").create({wait:!0,ordering:!0}),upsertPoints:t.path("/collections/{collection_name}/points").method("put").create({wait:!0,ordering:!0}),recommendPointGroups:t.path("/collections/{collection_name}/points/recommend/groups").method("post").create({consistency:!0})}}function i(t){return{getLocks:t.path("/locks").method("get").create(),metrics:t.path("/metrics").method("get").create(),postLocks:t.path("/locks").method("post").create(),telemetry:t.path("/telemetry").method("get").create()}}function a(t){return{createFullSnapshot:t.path("/snapshots").method("post").create({wait:!0}),createSnapshot:t.path("/collections/{collection_name}/snapshots").method("post").create({wait:!0}),deleteFullSnapshot:t.path("/snapshots/{snapshot_name}").method("delete").create({wait:!0}),deleteSnapshot:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("delete").create({wait:!0}),getFullSnapshot:t.path("/snapshots/{snapshot_name}").method("get").create(),getSnapshot:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("get").create(),listFullSnapshots:t.path("/snapshots").method("get").create(),listSnapshots:t.path("/collections/{collection_name}/snapshots").method("get").create(),recoverFromSnapshot:t.path("/collections/{collection_name}/snapshots/recover").method("put").create({wait:!0})}}class c extends Error{constructor(t){super(t),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}class l extends c{static forResponse(t){const e=`${`${t.status}`} ${t.statusText?`(${t.statusText})`:"(Unrecognized Status Code)"}`.trim(),o=t.data?JSON.stringify(t.data,null,2):null;let n="";o&&(n=o.length<=200?o:o.slice(0,-4)+" ...");return new l(`Unexpected Response: ${e}\n${`Raw response content:\n${n}`}`)}}class p extends c{}class h extends c{}class u extends c{}class d extends Error{constructor(t){super(t.statusText),Object.setPrototypeOf(this,new.target.prototype),this.headers=t.headers,this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.data=t.data}}const m=t=>"post"===t||"put"===t||"patch"===t||"delete"===t;function _(t,e,o){let n={};return m(t)?o.forEach((t=>{n[t]=e[t],delete e[t]})):n={...e},function(t){const e=[],o=(t,e)=>`${encodeURIComponent(t)}=${encodeURIComponent(String(e))}`;return Object.keys(t).forEach((n=>{const r=t[n];null!=r&&(Array.isArray(r)?r.forEach((t=>e.push(o(n,t)))):e.push(o(n,r)))})),e.length>0?`?${e.join("&")}`:""}(n)}function y(t,e){const o=new Headers(null==t?void 0:t.headers),n=new Headers(null==e?void 0:e.headers);for(const t of n.keys()){const e=n.get(t);null!=e&&o.set(t,e)}return{...t,...e,headers:o}}function w(t){var e,o;const n=Object.assign(Array.isArray(t.payload)?[]:{},t.payload),r=function(t,e){return t.replace(/\{([^}]+)\}/g,((t,o)=>{const n=encodeURIComponent(e[o]);return delete e[o],n}))}(t.path,n),s=_(t.method,n,t.queryParams),i=function(t,e){if(!m(t))return;const o=e instanceof FormData?e:JSON.stringify(e);return"delete"===t&&"{}"===o?void 0:o}(t.method,n),a=m(t.method)?function(t,e){const o=new Headers(e);return void 0===t||t instanceof FormData||o.has("Content-Type")||o.append("Content-Type","application/json"),o.has("Accept")||o.append("Accept","application/json"),o}(i,null===(e=t.init)||void 0===e?void 0:e.headers):new Headers(null===(o=t.init)||void 0===o?void 0:o.headers);return{url:t.baseUrl+r+s,init:{...t.init,method:t.method.toUpperCase(),headers:a,body:i}}}async function f(t,e){const o=await fetch(t,e),n=await async function(t){const e=t.headers.get("content-type");if(204===t.status)return;if(e&&-1!==e.indexOf("application/json"))return await t.json();const o=await t.text();try{return JSON.parse(o)}catch(t){return o}}(o),r={headers:o.headers,url:o.url,ok:o.ok,status:o.status,statusText:o.statusText,data:n};if(r.ok)return r;throw new d(r)}function g(){let t="",e={};const o=[],n=function(t,e){const o=async(n,r,s)=>{if(null==t||n===t.length)return e(r,s);const i=t[n];return await i(r,s,((t,e)=>o(n+1,t,e)))};return(t,e)=>o(0,t,e)}(o,f);return{configure:n=>{t=n.baseUrl||"",e=n.init||{},o.splice(0),o.push(...n.use||[])},use:t=>o.push(t),path:o=>({method:r=>({create:s=>function(t){const e=async(o,n)=>{try{return await t(o,n)}catch(t){if(t instanceof d)throw new e.Error(t);throw t}};return e.Error=class extends d{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}getActualType(){return{status:this.status,data:this.data}}},e}(((i,a)=>async function(t){const{url:e,init:o}=w(t);return await t.fetch(e,o)}({baseUrl:t||"",path:o,method:r,queryParams:Object.keys(s||{}),payload:i,init:y(e,a),fetch:n})))})})}}const C={for:()=>g()};function v(t,e){const o=function(t,{headers:e,timeout:o}){const n=[];Number.isFinite(o)&&n.push((async(t,e,n)=>{const r=new AbortController,s=setTimeout((()=>r.abort()),o);try{return await n(t,{...e,signal:r.signal})}catch(t){if(t instanceof Error&&"AbortError"===t.name)throw new h(t.message);throw t}finally{clearTimeout(s)}}));n.push((async(t,e,o)=>{const n=await o(t,e);if(200===n.status||201===n.status)return n;throw l.forResponse(n)}));const r=C.for();return r.configure({baseUrl:t,init:{headers:e},use:n}),r}(t,e);return{cluster:n(o),collections:r(o),points:s(o),service:i(o),snapshots:a(o)}}class A{constructor({url:t,host:e,apiKey:o,https:n,prefix:r,port:s=6333,timeout:i=3e5,...a}={}){if(this._https=n??"string"==typeof o,this._scheme=this._https?"https":"http",this._prefix=r??"",this._prefix.length>0&&!this._prefix.startsWith("/")&&(this._prefix=`/${this._prefix}`),t&&e)throw new p(`Only one of \`url\`, \`host\` params can be set. Url is ${t}, host is ${e}`);if(e&&(e.startsWith("http://")||e.startsWith("https://")||/:\d+$/.test(e)))throw new p("The `host` param is not expected to contain neither protocol (http:// or https://) nor port (:6333).\nTry to use the `url` parameter instead.");if(t){if(!t.startsWith("http://")&&!t.startsWith("https://"))throw new p("The `url` param expected to contain a valid URL starting with a protocol (http:// or https://).");const e=new URL(t);if(this._host=e.hostname,this._port=e.port?Number(e.port):s,this._scheme=e.protocol.replace(":",""),this._prefix.length>0&&"/"!==e.pathname)throw new p(`Prefix can be set either in \`url\` or in \`prefix\`.\nurl is ${t}, prefix is ${e.pathname}`)}else this._port=s,this._host=e??"127.0.0.1";const c=new Headers,l=a.headers??{};Object.keys(l).forEach((t=>{l[t]&&c.set(t,String(l[t]))})),"string"==typeof o&&("http"===this._scheme&&console.warn("Api key is used with unsecure connection."),c.set("api-key",o));const h=this._port?`${this._host}:${this._port}`:this._host;this._restUri=`${this._scheme}://${h}${this._prefix}`;const u={headers:c,timeout:i};this._openApiClient=v(this._restUri,u)}api(t){return this._openApiClient[t]}async searchBatch(t,{searches:e,consistency:n}){return o((await this._openApiClient.points.searchBatchPoints({collection_name:t,consistency:n,searches:e})).data.result).orThrow("Search batch returned empty")}async search(t,{vector:e,limit:n=10,offset:r=0,filter:s,params:i,with_payload:a=!0,with_vector:c=!1,score_threshold:l,consistency:p}){return o((await this._openApiClient.points.searchPoints({collection_name:t,consistency:p,vector:e,limit:n,offset:r,filter:s,params:i,with_payload:a,with_vector:c,score_threshold:l})).data.result).orThrow("Search returned empty")}async recommend_batch(t,{searches:e,consistency:n}){return o((await this._openApiClient.points.recommendBatchPoints({collection_name:t,searches:e,consistency:n})).data.result).orElse([])}async recommend(t,{positive:e,negative:n,filter:r,params:s,limit:i=10,offset:a=0,with_payload:c=!0,with_vector:l=!1,score_threshold:p,using:h,lookup_from:u,consistency:d}){return o((await this._openApiClient.points.recommendPoints({collection_name:t,limit:i,positive:e,negative:n,filter:r,params:s,offset:a,with_payload:c,with_vector:l,score_threshold:p,using:h,lookup_from:u,consistency:d})).data.result).orThrow("Recommend points API returned empty")}async scroll(t,{filter:e,consistency:n,limit:r=10,offset:s,with_payload:i=!0,with_vector:a=!1}={}){return o((await this._openApiClient.points.scrollPoints({collection_name:t,limit:r,offset:s,filter:e,with_payload:i,with_vector:a,consistency:n})).data.result).orThrow("Scroll points API returned empty")}async count(t,{filter:e,exact:n=!0}={}){return o((await this._openApiClient.points.countPoints({collection_name:t,filter:e,exact:n})).data.result).orThrow("Count points returned empty")}async collectionClusterInfo(t){return o((await this._openApiClient.collections.collectionClusterInfo({collection_name:t})).data.result).orThrow("Collection cluster info returned empty")}async updateVectors(t,{wait:e=!0,ordering:n,points:r}){return o((await this._openApiClient.points.updateVectors({collection_name:t,wait:e,ordering:n,points:r})).data.result).orThrow("Update vectors returned empty")}async deleteVectors(t,{wait:e=!0,ordering:n,points:r,filter:s,vector:i}){return o((await this._openApiClient.points.deleteVectors({collection_name:t,wait:e,ordering:n,points:r,filter:s,vector:i})).data.result).orThrow("Delete vectors returned empty")}async searchPointGroups(t,{consistency:e,vector:n,filter:r,params:s,with_payload:i=null,with_vector:a=null,score_threshold:c,group_by:l,group_size:p,limit:h}){return o((await this._openApiClient.points.searchPointGroups({collection_name:t,consistency:e,vector:n,filter:r,params:s,with_payload:i,with_vector:a,score_threshold:c,group_by:l,group_size:p,limit:h})).data.result).orThrow("Search point groups returned empty")}async recommendPointGroups(t,{consistency:e,positive:n,negative:r=[],filter:s,params:i,with_payload:a=null,with_vector:c=null,score_threshold:l,using:p=null,lookup_from:h=null,group_by:u,group_size:d,limit:m}){return o((await this._openApiClient.points.recommendPointGroups({collection_name:t,consistency:e,positive:n,negative:r,filter:s,params:i,with_payload:a,with_vector:c,score_threshold:l,using:p,lookup_from:h,group_by:u,group_size:d,limit:m})).data.result).orThrow("Recommend point groups API returned empty")}async upsert(t,{wait:e=!0,ordering:n,...r}){return o((await this._openApiClient.points.upsertPoints({collection_name:t,wait:e,ordering:n,...r})).data.result).orThrow("Upsert returned empty")}async retrieve(t,{ids:e,with_payload:n=!0,with_vector:r,consistency:s}){return o((await this._openApiClient.points.getPoints({collection_name:t,ids:e,with_payload:n,with_vector:r,consistency:s})).data.result).orThrow("Retrieve API returned empty")}async delete(t,{wait:e,ordering:n,...r}){return o((await this._openApiClient.points.deletePoints({collection_name:t,wait:e,ordering:n,...r})).data.result).orThrow("Delete points returned empty")}async setPayload(t,{payload:e,points:n,filter:r,ordering:s,wait:i=!0}){return o((await this._openApiClient.points.setPayload({collection_name:t,payload:e,points:n,filter:r,wait:i,ordering:s})).data.result).orThrow("Set payload returned empty")}async overwritePayload(t,{ordering:e,payload:n,points:r,filter:s,wait:i=!0}){return o((await this._openApiClient.points.overwritePayload({collection_name:t,payload:n,points:r,filter:s,wait:i,ordering:e})).data.result).orThrow("Overwrite payload returned empty")}async deletePayload(t,{ordering:e,keys:n,points:r,filter:s,wait:i=!0}){return o((await this._openApiClient.points.deletePayload({collection_name:t,keys:n,points:r,filter:s,wait:i,ordering:e})).data.result).orThrow("Delete payload returned empty")}async clearPayload(t,{ordering:e,wait:n=!0,...r}){return o((await this._openApiClient.points.clearPayload({collection_name:t,wait:n,ordering:e,...r})).data.result).orThrow("Clear payload returned empty")}async updateCollectionAliases({actions:t,timeout:e}){return o((await this._openApiClient.collections.updateAliases({actions:t,timeout:e})).data.result).orThrow("Update aliases returned empty")}async getCollectionAliases(t){return o((await this._openApiClient.collections.getCollectionAliases({collection_name:t})).data.result).orThrow("Get collection aliases returned empty")}async getAliases(){return o((await this._openApiClient.collections.getCollectionsAliases({})).data.result).orThrow("Get aliases returned empty")}async getCollections(){return o((await this._openApiClient.collections.getCollections({})).data.result).orThrow("Get collections returned empty")}async getCollection(t){return o((await this._openApiClient.collections.getCollection({collection_name:t})).data.result).orThrow("Get collection returned empty")}async updateCollection(t,e){return o((await this._openApiClient.collections.updateCollection({collection_name:t,...e})).data.result).orThrow("Update collection returned empty")}async deleteCollection(t,e){return o((await this._openApiClient.collections.deleteCollection({collection_name:t,...e})).data.result).orThrow("Delete collection returned empty")}async createCollection(t,{timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u}){return o((await this._openApiClient.collections.createCollection({collection_name:t,timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u})).data.result).orThrow("Create collection returned empty")}async recreateCollection(t,{timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u}){o(await this._openApiClient.collections.deleteCollection({collection_name:t,timeout:e})).get("ok").orThrow("Delete collection returned failed");return o(await this._openApiClient.collections.createCollection({collection_name:t,timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u})).orThrow("Create collection returned empty")}async uploadRecords(){return Promise.reject(new u("uploadRecords()"))}async uploadCollection(){return Promise.reject(new u("uploadCollection()"))}async createPayloadIndex(t,{wait:e,ordering:n,field_name:r,field_schema:s}){return o((await this._openApiClient.collections.createFieldIndex({collection_name:t,field_name:r,field_schema:s,wait:e,ordering:n})).data.result).orThrow("Create field index returned empty")}async deletePayloadIndex(t,e,{wait:n=!0,ordering:r}={}){return o((await this._openApiClient.collections.deleteFieldIndex({collection_name:t,field_name:e,wait:n,ordering:r})).data.result).orThrow("Delete field index returned empty")}async listSnapshots(t){return o((await this._openApiClient.snapshots.listSnapshots({collection_name:t})).data.result).orThrow("List snapshots API returned empty")}async createSnapshot(t,e){return o((await this._openApiClient.snapshots.createSnapshot({collection_name:t,...e})).data.result).orNull()}async deleteSnapshot(t,e,n){return o((await this._openApiClient.snapshots.deleteSnapshot({collection_name:t,snapshot_name:e,...n})).data.result).orThrow("Delete snapshot API returned empty")}async listFullSnapshots(){return o((await this._openApiClient.snapshots.listFullSnapshots({})).data.result).orThrow("List full snapshots API returned empty")}async createFullSnapshot(t){return o((await this._openApiClient.snapshots.createFullSnapshot({...t})).data.result).orThrow("Create full snapshot API returned empty")}async deleteFullSnapshot(t,e){return o((await this._openApiClient.snapshots.deleteFullSnapshot({snapshot_name:t,...e})).data.result).orThrow("Delete full snapshot API returned empty")}async recoverSnapshot(t,{location:e,priority:n}){return o((await this._openApiClient.snapshots.recoverFromSnapshot({collection_name:t,location:e,priority:n})).data.result).orThrow("Recover from snapshot API returned empty")}async lockStorage(t){return o((await this._openApiClient.service.postLocks({write:!0,error_message:t})).data.result).orThrow("Lock storage returned empty")}async unlockStorage(){return o((await this._openApiClient.service.postLocks({write:!1})).data.result).orThrow("Post locks returned empty")}async getLocks(){return o((await this._openApiClient.service.getLocks({})).data.result).orThrow("Get locks returned empty")}}export{A as QdrantClient};
var t={isNone:function(){return!0},orElse:function(t){return t},orCall:function(t){return t()},orNull:function(){return null},orThrow:function(t){throw void 0===t&&(t="Unexpected null value"),new TypeError(t)},map:function(){return t},get:function(){return t}},e=function(){function t(t){this.value=t}return t.prototype.isNone=function(){return!1},t.prototype.orElse=function(){return this.value},t.prototype.orCall=function(){return this.value},t.prototype.orNull=function(){return this.value},t.prototype.orThrow=function(){return this.value},t.prototype.map=function(t){return o(t(this.value))},t.prototype.get=function(t){return this.map((function(e){return e[t]}))},t}();function o(o){return function(o){return o===t||o instanceof e}(o)?o:null==o?t:function(t){if(null==t)throw new TypeError("some() does not accept null or undefined");return new e(t)}(o)}class n extends Error{constructor(t){super(t.statusText),Object.setPrototypeOf(this,new.target.prototype),this.headers=t.headers,this.url=t.url,this.status=t.status,this.statusText=t.statusText,this.data=t.data}}const r=t=>"post"===t||"put"===t||"patch"===t||"delete"===t;function s(t,e,o){let n={};return r(t)?o.forEach((t=>{n[t]=e[t],delete e[t]})):n={...e},function(t){const e=[],o=(t,e)=>`${encodeURIComponent(t)}=${encodeURIComponent(String(e))}`;return Object.keys(t).forEach((n=>{const r=t[n];null!=r&&(Array.isArray(r)?r.forEach((t=>e.push(o(n,t)))):e.push(o(n,r)))})),e.length>0?`?${e.join("&")}`:""}(n)}function i(t,e){const o=new Headers(null==t?void 0:t.headers),n=new Headers(null==e?void 0:e.headers);for(const t of n.keys()){const e=n.get(t);null!=e&&o.set(t,e)}return{...t,...e,headers:o}}function a(t){var e,o;const n=Object.assign(Array.isArray(t.payload)?[]:{},t.payload),i=function(t,e){return t.replace(/\{([^}]+)\}/g,((t,o)=>{const n=encodeURIComponent(e[o]);return delete e[o],n}))}(t.path,n),a=s(t.method,n,t.queryParams),c=function(t,e){if(!r(t))return;const o=e instanceof FormData?e:JSON.stringify(e);return"delete"===t&&"{}"===o?void 0:o}(t.method,n),l=r(t.method)?function(t,e){const o=new Headers(e);return void 0===t||t instanceof FormData||o.has("Content-Type")||o.append("Content-Type","application/json"),o.has("Accept")||o.append("Accept","application/json"),o}(c,null===(e=t.init)||void 0===e?void 0:e.headers):new Headers(null===(o=t.init)||void 0===o?void 0:o.headers);return{url:t.baseUrl+i+a,init:{...t.init,method:t.method.toUpperCase(),headers:l,body:c}}}async function c(t,e){const o=await fetch(t,e),r=await async function(t){const e=t.headers.get("content-type");if(204===t.status)return;if(e&&-1!==e.indexOf("application/json"))return await t.json();const o=await t.text();try{return JSON.parse(o)}catch(t){return o}}(o),s={headers:o.headers,url:o.url,ok:o.ok,status:o.status,statusText:o.statusText,data:r};if(s.ok)return s;throw new n(s)}function l(){let t="",e={};const o=[],r=function(t,e){const o=async(n,r,s)=>{if(null==t||n===t.length)return e(r,s);const i=t[n];return await i(r,s,((t,e)=>o(n+1,t,e)))};return(t,e)=>o(0,t,e)}(o,c);return{configure:n=>{t=n.baseUrl||"",e=n.init||{},o.splice(0),o.push(...n.use||[])},use:t=>o.push(t),path:o=>({method:s=>({create:c=>function(t){const e=async(o,r)=>{try{return await t(o,r)}catch(t){if(t instanceof n)throw new e.Error(t);throw t}};return e.Error=class extends n{constructor(t){super(t),Object.setPrototypeOf(this,new.target.prototype)}getActualType(){return{status:this.status,data:this.data}}},e}(((n,l)=>async function(t){const{url:e,init:o}=a(t);return await t.fetch(e,o)}({baseUrl:t||"",path:o,method:s,queryParams:Object.keys(c||{}),payload:n,init:i(e,l),fetch:r})))})})}}const p={for:()=>l()};function h(t){return{clusterStatus:t.path("/cluster").method("get").create(),collectionClusterInfo:t.path("/collections/{collection_name}/cluster").method("get").create(),recoverCurrentPeer:t.path("/cluster/recover").method("post").create(),removePeer:t.path("/cluster/peer/{peer_id}").method("delete").create({force:!0}),updateCollectionCluster:t.path("/collections/{collection_name}/cluster").method("post").create({timeout:!0})}}function u(t){return{collectionClusterInfo:t.path("/collections/{collection_name}/cluster").method("get").create(),createCollection:t.path("/collections/{collection_name}").method("put").create({timeout:!0}),createFieldIndex:t.path("/collections/{collection_name}/index").method("put").create({ordering:!0,wait:!0}),createSnapshot:t.path("/collections/{collection_name}/snapshots").method("post").create({wait:!0}),deleteCollection:t.path("/collections/{collection_name}").method("delete").create({timeout:!0}),deleteFieldIndex:t.path("/collections/{collection_name}/index/{field_name}").method("delete").create({ordering:!0,wait:!0}),deleteSnapshots:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("delete").create({wait:!0}),getCollection:t.path("/collections/{collection_name}").method("get").create(),getCollectionAliases:t.path("/collections/{collection_name}/aliases").method("get").create(),getCollections:t.path("/collections").method("get").create(),getCollectionsAliases:t.path("/aliases").method("get").create(),getSnapshot:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("get").create(),listSnapshots:t.path("/collections/{collection_name}/snapshots").method("get").create(),recoverFromSnapshot:t.path("/collections/{collection_name}/snapshots/recover").method("put").create({wait:!0}),updateAliases:t.path("/collections/aliases").method("post").create({timeout:!0}),updateCollection:t.path("/collections/{collection_name}").method("patch").create({timeout:!0}),updateCollectionCluster:t.path("/collections/{collection_name}/cluster").method("post").create({timeout:!0})}}function d(t){return{clearPayload:t.path("/collections/{collection_name}/points/payload/clear").method("post").create({ordering:!0,wait:!0}),countPoints:t.path("/collections/{collection_name}/points/count").method("post").create(),deletePayload:t.path("/collections/{collection_name}/points/payload/delete").method("post").create({wait:!0,ordering:!0}),deletePoints:t.path("/collections/{collection_name}/points/delete").method("post").create({wait:!0,ordering:!0}),updateVectors:t.path("/collections/{collection_name}/points/vectors").method("put").create({wait:!0,ordering:!0}),deleteVectors:t.path("/collections/{collection_name}/points/vectors/delete").method("post").create({wait:!0,ordering:!0}),getPoint:t.path("/collections/{collection_name}/points/{id}").method("get").create(),getPoints:t.path("/collections/{collection_name}/points").method("post").create({consistency:!0}),overwritePayload:t.path("/collections/{collection_name}/points/payload").method("put").create({wait:!0,ordering:!0}),recommendBatchPoints:t.path("/collections/{collection_name}/points/recommend/batch").method("post").create({consistency:!0}),recommendPoints:t.path("/collections/{collection_name}/points/recommend").method("post").create({consistency:!0}),searchPointGroups:t.path("/collections/{collection_name}/points/search/groups").method("post").create({consistency:!0}),scrollPoints:t.path("/collections/{collection_name}/points/scroll").method("post").create({consistency:!0}),searchBatchPoints:t.path("/collections/{collection_name}/points/search/batch").method("post").create({consistency:!0}),searchPoints:t.path("/collections/{collection_name}/points/search").method("post").create({consistency:!0}),setPayload:t.path("/collections/{collection_name}/points/payload").method("post").create({wait:!0,ordering:!0}),upsertPoints:t.path("/collections/{collection_name}/points").method("put").create({wait:!0,ordering:!0}),recommendPointGroups:t.path("/collections/{collection_name}/points/recommend/groups").method("post").create({consistency:!0})}}function m(t){return{getLocks:t.path("/locks").method("get").create(),metrics:t.path("/metrics").method("get").create(),postLocks:t.path("/locks").method("post").create(),telemetry:t.path("/telemetry").method("get").create()}}function _(t){return{createFullSnapshot:t.path("/snapshots").method("post").create({wait:!0}),createSnapshot:t.path("/collections/{collection_name}/snapshots").method("post").create({wait:!0}),deleteFullSnapshot:t.path("/snapshots/{snapshot_name}").method("delete").create({wait:!0}),deleteSnapshot:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("delete").create({wait:!0}),getFullSnapshot:t.path("/snapshots/{snapshot_name}").method("get").create(),getSnapshot:t.path("/collections/{collection_name}/snapshots/{snapshot_name}").method("get").create(),listFullSnapshots:t.path("/snapshots").method("get").create(),listSnapshots:t.path("/collections/{collection_name}/snapshots").method("get").create(),recoverFromSnapshot:t.path("/collections/{collection_name}/snapshots/recover").method("put").create({wait:!0})}}class y extends Error{constructor(t){super(t),this.name=this.constructor.name,Object.setPrototypeOf(this,new.target.prototype)}}class w extends y{static forResponse(t){const e=`${`${t.status}`} ${t.statusText?`(${t.statusText})`:"(Unrecognized Status Code)"}`.trim(),o=t.data?JSON.stringify(t.data,null,2):null;let n="";o&&(n=o.length<=200?o:o.slice(0,-4)+" ...");return new w(`Unexpected Response: ${e}\n${`Raw response content:\n${n}`}`)}}class f extends y{}class g extends y{}function C(t,e){const o=function(t,{headers:e,timeout:o,connections:n}){const r=[];Number.isFinite(o)&&r.push((async(t,e,n)=>{const r=new AbortController,s=setTimeout((()=>r.abort()),o);try{return await n(t,Object.assign(e,{signal:r.signal}))}catch(t){if(t instanceof Error&&"AbortError"===t.name)throw new g(t.message);throw t}finally{clearTimeout(s)}}));r.push((async(t,e,o)=>{const n=await o(t,e);if(200===n.status||201===n.status)return n;throw w.forResponse(n)}));const s=p.for();return s.configure({baseUrl:t,init:{headers:e,dispatcher:void 0},use:r}),s}(t,e);return{cluster:h(o),collections:u(o),points:d(o),service:m(o),snapshots:_(o)}}class v{constructor({url:t,host:e,apiKey:o,https:n,prefix:r,port:s=6333,timeout:i=3e5,...a}={}){if(this._https=n??"string"==typeof o,this._scheme=this._https?"https":"http",this._prefix=r??"",this._prefix.length>0&&!this._prefix.startsWith("/")&&(this._prefix=`/${this._prefix}`),t&&e)throw new f(`Only one of \`url\`, \`host\` params can be set. Url is ${t}, host is ${e}`);if(e&&(e.startsWith("http://")||e.startsWith("https://")||/:\d+$/.test(e)))throw new f("The `host` param is not expected to contain neither protocol (http:// or https://) nor port (:6333).\nTry to use the `url` parameter instead.");if(t){if(!t.startsWith("http://")&&!t.startsWith("https://"))throw new f("The `url` param expected to contain a valid URL starting with a protocol (http:// or https://).");const e=new URL(t);if(this._host=e.hostname,this._port=e.port?Number(e.port):s,this._scheme=e.protocol.replace(":",""),this._prefix.length>0&&"/"!==e.pathname)throw new f(`Prefix can be set either in \`url\` or in \`prefix\`.\nurl is ${t}, prefix is ${e.pathname}`)}else this._port=s,this._host=e??"127.0.0.1";const c=new Headers([["user-agent","qdrant-js"]]),l=a.headers??{};Object.keys(l).forEach((t=>{l[t]&&c.set(t,String(l[t]))})),"string"==typeof o&&("http"===this._scheme&&console.warn("Api key is used with unsecure connection."),c.set("api-key",o));const p=this._port?`${this._host}:${this._port}`:this._host;this._restUri=`${this._scheme}://${p}${this._prefix}`;const h=a.maxConnections,u={headers:c,timeout:i,connections:h};this._openApiClient=C(this._restUri,u)}api(t){return this._openApiClient[t]}async searchBatch(t,{searches:e,consistency:n}){return o((await this._openApiClient.points.searchBatchPoints({collection_name:t,consistency:n,searches:e})).data.result).orThrow("Search batch returned empty")}async search(t,{vector:e,limit:n=10,offset:r=0,filter:s,params:i,with_payload:a=!0,with_vector:c=!1,score_threshold:l,consistency:p}){return o((await this._openApiClient.points.searchPoints({collection_name:t,consistency:p,vector:e,limit:n,offset:r,filter:s,params:i,with_payload:a,with_vector:c,score_threshold:l})).data.result).orThrow("Search returned empty")}async recommend_batch(t,{searches:e,consistency:n}){return o((await this._openApiClient.points.recommendBatchPoints({collection_name:t,searches:e,consistency:n})).data.result).orElse([])}async recommend(t,{positive:e,negative:n,filter:r,params:s,limit:i=10,offset:a=0,with_payload:c=!0,with_vector:l=!1,score_threshold:p,using:h,lookup_from:u,consistency:d}){return o((await this._openApiClient.points.recommendPoints({collection_name:t,limit:i,positive:e,negative:n,filter:r,params:s,offset:a,with_payload:c,with_vector:l,score_threshold:p,using:h,lookup_from:u,consistency:d})).data.result).orThrow("Recommend points API returned empty")}async scroll(t,{filter:e,consistency:n,limit:r=10,offset:s,with_payload:i=!0,with_vector:a=!1}={}){return o((await this._openApiClient.points.scrollPoints({collection_name:t,limit:r,offset:s,filter:e,with_payload:i,with_vector:a,consistency:n})).data.result).orThrow("Scroll points API returned empty")}async count(t,{filter:e,exact:n=!0}={}){return o((await this._openApiClient.points.countPoints({collection_name:t,filter:e,exact:n})).data.result).orThrow("Count points returned empty")}async collectionClusterInfo(t){return o((await this._openApiClient.collections.collectionClusterInfo({collection_name:t})).data.result).orThrow("Collection cluster info returned empty")}async updateVectors(t,{wait:e=!0,ordering:n,points:r}){return o((await this._openApiClient.points.updateVectors({collection_name:t,wait:e,ordering:n,points:r})).data.result).orThrow("Update vectors returned empty")}async deleteVectors(t,{wait:e=!0,ordering:n,points:r,filter:s,vector:i}){return o((await this._openApiClient.points.deleteVectors({collection_name:t,wait:e,ordering:n,points:r,filter:s,vector:i})).data.result).orThrow("Delete vectors returned empty")}async searchPointGroups(t,{consistency:e,vector:n,filter:r,params:s,with_payload:i=null,with_vector:a=null,score_threshold:c,group_by:l,group_size:p,limit:h}){return o((await this._openApiClient.points.searchPointGroups({collection_name:t,consistency:e,vector:n,filter:r,params:s,with_payload:i,with_vector:a,score_threshold:c,group_by:l,group_size:p,limit:h})).data.result).orThrow("Search point groups returned empty")}async recommendPointGroups(t,{consistency:e,positive:n,negative:r=[],filter:s,params:i,with_payload:a=null,with_vector:c=null,score_threshold:l,using:p=null,lookup_from:h=null,group_by:u,group_size:d,limit:m}){return o((await this._openApiClient.points.recommendPointGroups({collection_name:t,consistency:e,positive:n,negative:r,filter:s,params:i,with_payload:a,with_vector:c,score_threshold:l,using:p,lookup_from:h,group_by:u,group_size:d,limit:m})).data.result).orThrow("Recommend point groups API returned empty")}async upsert(t,{wait:e=!0,ordering:n,...r}){return o((await this._openApiClient.points.upsertPoints({collection_name:t,wait:e,ordering:n,...r})).data.result).orThrow("Upsert returned empty")}async retrieve(t,{ids:e,with_payload:n=!0,with_vector:r,consistency:s}){return o((await this._openApiClient.points.getPoints({collection_name:t,ids:e,with_payload:n,with_vector:r,consistency:s})).data.result).orThrow("Retrieve API returned empty")}async delete(t,{wait:e,ordering:n,...r}){return o((await this._openApiClient.points.deletePoints({collection_name:t,wait:e,ordering:n,...r})).data.result).orThrow("Delete points returned empty")}async setPayload(t,{payload:e,points:n,filter:r,ordering:s,wait:i=!0}){return o((await this._openApiClient.points.setPayload({collection_name:t,payload:e,points:n,filter:r,wait:i,ordering:s})).data.result).orThrow("Set payload returned empty")}async overwritePayload(t,{ordering:e,payload:n,points:r,filter:s,wait:i=!0}){return o((await this._openApiClient.points.overwritePayload({collection_name:t,payload:n,points:r,filter:s,wait:i,ordering:e})).data.result).orThrow("Overwrite payload returned empty")}async deletePayload(t,{ordering:e,keys:n,points:r,filter:s,wait:i=!0}){return o((await this._openApiClient.points.deletePayload({collection_name:t,keys:n,points:r,filter:s,wait:i,ordering:e})).data.result).orThrow("Delete payload returned empty")}async clearPayload(t,{ordering:e,wait:n=!0,...r}){return o((await this._openApiClient.points.clearPayload({collection_name:t,wait:n,ordering:e,...r})).data.result).orThrow("Clear payload returned empty")}async updateCollectionAliases({actions:t,timeout:e}){return o((await this._openApiClient.collections.updateAliases({actions:t,timeout:e})).data.result).orThrow("Update aliases returned empty")}async getCollectionAliases(t){return o((await this._openApiClient.collections.getCollectionAliases({collection_name:t})).data.result).orThrow("Get collection aliases returned empty")}async getAliases(){return o((await this._openApiClient.collections.getCollectionsAliases({})).data.result).orThrow("Get aliases returned empty")}async getCollections(){return o((await this._openApiClient.collections.getCollections({})).data.result).orThrow("Get collections returned empty")}async getCollection(t){return o((await this._openApiClient.collections.getCollection({collection_name:t})).data.result).orThrow("Get collection returned empty")}async updateCollection(t,e){return o((await this._openApiClient.collections.updateCollection({collection_name:t,...e})).data.result).orThrow("Update collection returned empty")}async deleteCollection(t,e){return o((await this._openApiClient.collections.deleteCollection({collection_name:t,...e})).data.result).orThrow("Delete collection returned empty")}async createCollection(t,{timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u}){return o((await this._openApiClient.collections.createCollection({collection_name:t,timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u})).data.result).orThrow("Create collection returned empty")}async recreateCollection(t,{timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u}){o(await this._openApiClient.collections.deleteCollection({collection_name:t,timeout:e})).get("ok").orThrow("Delete collection returned failed");return o(await this._openApiClient.collections.createCollection({collection_name:t,timeout:e,vectors:n,hnsw_config:r,init_from:s,on_disk_payload:i,optimizers_config:a,quantization_config:c,replication_factor:l,shard_number:p,wal_config:h,write_consistency_factor:u})).orThrow("Create collection returned empty")}async createPayloadIndex(t,e,{wait:n,ordering:r,field_schema:s}){return o((await this._openApiClient.collections.createFieldIndex({collection_name:t,field_name:e,field_schema:s,wait:n,ordering:r})).data.result).orThrow("Create field index returned empty")}async deletePayloadIndex(t,e,{wait:n=!0,ordering:r}={}){return o((await this._openApiClient.collections.deleteFieldIndex({collection_name:t,field_name:e,wait:n,ordering:r})).data.result).orThrow("Delete field index returned empty")}async listSnapshots(t){return o((await this._openApiClient.snapshots.listSnapshots({collection_name:t})).data.result).orThrow("List snapshots API returned empty")}async createSnapshot(t,e){return o((await this._openApiClient.snapshots.createSnapshot({collection_name:t,...e})).data.result).orNull()}async deleteSnapshot(t,e,n){return o((await this._openApiClient.snapshots.deleteSnapshot({collection_name:t,snapshot_name:e,...n})).data.result).orThrow("Delete snapshot API returned empty")}async listFullSnapshots(){return o((await this._openApiClient.snapshots.listFullSnapshots({})).data.result).orThrow("List full snapshots API returned empty")}async createFullSnapshot(t){return o((await this._openApiClient.snapshots.createFullSnapshot(t??{})).data.result).orThrow("Create full snapshot API returned empty")}async deleteFullSnapshot(t,e){return o((await this._openApiClient.snapshots.deleteFullSnapshot({snapshot_name:t,...e})).data.result).orThrow("Delete full snapshot API returned empty")}async recoverSnapshot(t,{location:e,priority:n}){return o((await this._openApiClient.snapshots.recoverFromSnapshot({collection_name:t,location:e,priority:n})).data.result).orThrow("Recover from snapshot API returned empty")}async lockStorage(t){return o((await this._openApiClient.service.postLocks({write:!0,error_message:t})).data.result).orThrow("Lock storage returned empty")}async unlockStorage(){return o((await this._openApiClient.service.postLocks({write:!1})).data.result).orThrow("Post locks returned empty")}async getLocks(){return o((await this._openApiClient.service.getLocks({})).data.result).orThrow("Get locks returned empty")}}export{v as QdrantClient,f as QdrantClientConfigError,g as QdrantClientTimeoutError,w as QdrantClientUnexpectedResponseError};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createClient = exports.createApis = void 0;
const openapi_typescript_fetch_1 = require("@qdrant/openapi-typescript-fetch");
const dispatcher_js_1 = require("./dispatcher.js");
const cluster_api_js_1 = require("./api/cluster-api.js");

@@ -10,3 +12,2 @@ const collections_api_js_1 = require("./api/collections-api.js");

const errors_js_1 = require("./errors.js");
const openapi_typescript_fetch_1 = require("@qdrant/openapi-typescript-fetch");
function createApis(baseUrl, args) {

@@ -23,3 +24,3 @@ const client = createClient(baseUrl, args);

exports.createApis = createApis;
function createClient(baseUrl, { headers, timeout }) {
function createClient(baseUrl, { headers, timeout, connections }) {
const use = [];

@@ -31,3 +32,3 @@ if (Number.isFinite(timeout)) {

try {
return await next(url, { ...init, signal: controller.signal });
return await next(url, Object.assign(init, { signal: controller.signal }));
}

@@ -53,5 +54,17 @@ catch (e) {

const client = openapi_typescript_fetch_1.Fetcher.for();
client.configure({ baseUrl, init: { headers }, use });
// Configure client with 'undici' agent which is used in Node 18+
client.configure({
baseUrl,
init: {
headers,
dispatcher: typeof process !== 'undefined' &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
process.versions?.node
? (0, dispatcher_js_1.createDispatcher)(connections)
: undefined,
},
use,
});
return client;
}
exports.createClient = createClient;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.QdrantClientNotImplementedError = exports.QdrantClientTimeoutError = exports.QdrantClientConfigError = exports.QdrantClientUnexpectedResponseError = void 0;
exports.QdrantClientTimeoutError = exports.QdrantClientConfigError = exports.QdrantClientUnexpectedResponseError = void 0;
const MAX_CONTENT = 200;

@@ -33,4 +33,1 @@ class CustomError extends Error {

exports.QdrantClientTimeoutError = QdrantClientTimeoutError;
class QdrantClientNotImplementedError extends CustomError {
}
exports.QdrantClientNotImplementedError = QdrantClientNotImplementedError;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -6,2 +20,2 @@ exports.QdrantClient = void 0;

Object.defineProperty(exports, "QdrantClient", { enumerable: true, get: function () { return qdrant_client_js_1.QdrantClient; } });
// comment
__exportStar(require("./errors.js"), exports);

@@ -1,3 +0,1 @@

{
"type": "commonjs"
}
{"type":"commonjs"}

@@ -39,3 +39,3 @@ "use strict";

}
const headers = new Headers();
const headers = new Headers([['user-agent', 'qdrant-js']]);
const metadata = args.headers ?? {};

@@ -55,3 +55,4 @@ Object.keys(metadata).forEach((field) => {

this._restUri = `${this._scheme}://${address}${this._prefix}`;
const restArgs = { headers, timeout };
const connections = args.maxConnections;
const restArgs = { headers, timeout, connections };
this._openApiClient = (0, api_client_js_1.createApis)(this._restUri, restArgs);

@@ -62,3 +63,3 @@ }

*
* @param string Name of api
* @param name Name of api
* @returns An instance of a namespaced API, generated from OpenAPI schema.

@@ -72,3 +73,3 @@ */

*
* @param collection_name Name of the collection
* @param collectionName Name of the collection
* @param {object} args -

@@ -115,3 +116,3 @@ * - searches: List of search requests

* - If `PayloadSelector` - use explicit rules
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -136,15 +137,17 @@ * - If `False` - Do not attach vector.

* // Search with filter
* qdrant.search(
* collection_name: "test_collection",
* vector: [1.0, 0.1, 0.2, 0.7],
* filter: {
* must: [
* {
* key: 'color',
* range: {
* color: 'red'
* client.search(
* "test_collection",
* {
* vector: [1.0, 0.1, 0.2, 0.7],
* filter: {
* must: [
* {
* key: 'color',
* range: {
* color: 'red'
* }
* }
* }
* ]
* )
* ]
* )
* }
* )

@@ -222,3 +225,3 @@ * @returns List of found close points with similarity scores.

* - Default: `true`
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -237,3 +240,3 @@ * - If `False` - Do not attach vector.

* If `None` - use default vectors.
* - lookup_from:
* - lookupFrom:
* Defines a location (collection and vector field name), used to lookup vectors for recommendations.

@@ -282,3 +285,3 @@ * If `None` - use current collection will be used.

* - Default: `true`
* with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -288,3 +291,3 @@ * - If `False` - Do not attach vector.

* - Default: `false`
* consistency:
* - consistency:
* Read consistency of the search. Defines how many replicas should be queried before returning the result.

@@ -358,3 +361,3 @@ * Values:

*/
async updateVectors(collection_name, { wait = true, ordering, points }) {
async updateVectors(collection_name, { wait = true, ordering, points, }) {
const response = await this._openApiClient.points.updateVectors({

@@ -516,3 +519,3 @@ collection_name,

* - Default: `true`
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -829,3 +832,3 @@ * - If `False` - Do not attach vector.

* @returns Operation result
* @param collection_name Name of the collection to recreate
* @param collectionName Name of the collection to recreate
* @param {object} args

@@ -882,14 +885,14 @@ * - vectors_config:

* @returns Operation result
* @param collection_name Name of the collection to recreate
* @param collectionName Name of the collection to recreate
* @param {object} args
* - vectors_config:
* - vectorsConfig:
* Configuration of the vector storage. Vector params contains size and distance for the vector storage.
* If dict is passed, service will create a vector storage for each key in the dict.
* If single VectorParams is passed, service will create a single anonymous vector storage.
* - shard_number: Number of shards in collection. Default is 1, minimum is 1.
* - replication_factor:
* - shardNumber: Number of shards in collection. Default is 1, minimum is 1.
* - replicationFactor:
* Replication factor for collection. Default is 1, minimum is 1.
* Defines how many copies of each shard will be created.
* Have effect only in distributed mode.
* - write_consistency_factor:
* - writeConsistencyFactor:
* Write consistency factor for collection. Default is 1, minimum is 1.

@@ -901,3 +904,3 @@ * Defines how many replicas should apply the operation for us to consider it successful.

* Have effect only in distributed mode.
* - on_disk_payload:
* - onDiskPayload:
* If true - point`s payload will not be stored in memory.

@@ -907,7 +910,7 @@ * It will be read from the disk every time it is requested.

* Note: those payload values that are involved in filtering and are indexed - remain in RAM.
* - hnsw_config: Params for HNSW index
* - optimizers_config: Params for optimizer
* - wal_config: Params for Write-Ahead-Log
* - quantization_config: Params for quantization, if None - quantization will be disabled
* - init_from: Use data stored in another collection to initialize this collection
* - hnswConfig: Params for HNSW index
* - optimizersConfig: Params for optimizer
* - walConfig: Params for Write-Ahead-Log
* - quantizationConfig: Params for quantization, if None - quantization will be disabled
* - initFrom: Use data stored in another collection to initialize this collection
* - timeout:

@@ -940,23 +943,9 @@ * Wait for operation commit timeout in seconds.

}
async uploadRecords() {
return Promise.reject(new errors_js_1.QdrantClientNotImplementedError('uploadRecords()'));
}
/**
* Upload vectors and payload to the collection.
* This method will perform automatic batching of the data.
* If you need to perform a single update, use `upsert` method.
* Note: use `upload_records` method if you want to upload multiple vectors with single payload.
* @param collection_name Name of the collection to upload to
*/
async uploadCollection() {
return Promise.reject(new errors_js_1.QdrantClientNotImplementedError('uploadCollection()'));
}
/**
* Creates index for a given payload field.
* Indexed fields allow to perform filtered search operations faster.
* @param collection_name Name of the collection
* @param field_name Name of the payload field
* @param collectionName Name of the collection
* @param {object} args
* - field_name: Name of the payload field.
* - field_schema: Type of data to index.
* - fieldName: Name of the payload field.
* - fieldSchema: Type of data to index.
* - wait: Await for the results to be processed.

@@ -974,3 +963,3 @@ * - If `true`, result will be returned only when all changes are applied

*/
async createPayloadIndex(collection_name, { wait, ordering, field_name, field_schema, }) {
async createPayloadIndex(collection_name, field_name, { wait, ordering, field_schema, }) {
const response = await this._openApiClient.collections.createFieldIndex({

@@ -1052,3 +1041,3 @@ collection_name,

async createFullSnapshot(args) {
const response = await this._openApiClient.snapshots.createFullSnapshot({ ...args });
const response = await this._openApiClient.snapshots.createFullSnapshot(args ?? {});
return (0, maybe_1.maybe)(response.data.result).orThrow('Create full snapshot API returned empty');

@@ -1055,0 +1044,0 @@ }

@@ -0,1 +1,3 @@

import { Fetcher } from '@qdrant/openapi-typescript-fetch';
import { createDispatcher } from './dispatcher.js';
import { createClusterApi } from './api/cluster-api.js';

@@ -7,3 +9,2 @@ import { createCollectionsApi } from './api/collections-api.js';

import { QdrantClientTimeoutError, QdrantClientUnexpectedResponseError } from './errors.js';
import { Fetcher } from '@qdrant/openapi-typescript-fetch';
export function createApis(baseUrl, args) {

@@ -19,3 +20,3 @@ const client = createClient(baseUrl, args);

}
export function createClient(baseUrl, { headers, timeout }) {
export function createClient(baseUrl, { headers, timeout, connections }) {
const use = [];

@@ -27,3 +28,3 @@ if (Number.isFinite(timeout)) {

try {
return await next(url, { ...init, signal: controller.signal });
return await next(url, Object.assign(init, { signal: controller.signal }));
}

@@ -49,4 +50,16 @@ catch (e) {

const client = Fetcher.for();
client.configure({ baseUrl, init: { headers }, use });
// Configure client with 'undici' agent which is used in Node 18+
client.configure({
baseUrl,
init: {
headers,
dispatcher: typeof process !== 'undefined' &&
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
process.versions?.node
? createDispatcher(connections)
: undefined,
},
use,
});
return client;
}

@@ -27,3 +27,1 @@ const MAX_CONTENT = 200;

}
export class QdrantClientNotImplementedError extends CustomError {
}
export { QdrantClient } from './qdrant-client.js';
// comment
export * from './errors.js';
import { maybe } from '@sevinf/maybe';
import { createApis } from './api-client.js';
import { QdrantClientNotImplementedError, QdrantClientConfigError } from './errors.js';
import { QdrantClientConfigError } from './errors.js';
export class QdrantClient {

@@ -36,3 +36,3 @@ constructor({ url, host, apiKey, https, prefix, port = 6333, timeout = 300000, ...args } = {}) {

}
const headers = new Headers();
const headers = new Headers([['user-agent', 'qdrant-js']]);
const metadata = args.headers ?? {};

@@ -52,3 +52,4 @@ Object.keys(metadata).forEach((field) => {

this._restUri = `${this._scheme}://${address}${this._prefix}`;
const restArgs = { headers, timeout };
const connections = args.maxConnections;
const restArgs = { headers, timeout, connections };
this._openApiClient = createApis(this._restUri, restArgs);

@@ -59,3 +60,3 @@ }

*
* @param string Name of api
* @param name Name of api
* @returns An instance of a namespaced API, generated from OpenAPI schema.

@@ -69,3 +70,3 @@ */

*
* @param collection_name Name of the collection
* @param collectionName Name of the collection
* @param {object} args -

@@ -112,3 +113,3 @@ * - searches: List of search requests

* - If `PayloadSelector` - use explicit rules
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -133,15 +134,17 @@ * - If `False` - Do not attach vector.

* // Search with filter
* qdrant.search(
* collection_name: "test_collection",
* vector: [1.0, 0.1, 0.2, 0.7],
* filter: {
* must: [
* {
* key: 'color',
* range: {
* color: 'red'
* client.search(
* "test_collection",
* {
* vector: [1.0, 0.1, 0.2, 0.7],
* filter: {
* must: [
* {
* key: 'color',
* range: {
* color: 'red'
* }
* }
* }
* ]
* )
* ]
* )
* }
* )

@@ -219,3 +222,3 @@ * @returns List of found close points with similarity scores.

* - Default: `true`
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -234,3 +237,3 @@ * - If `False` - Do not attach vector.

* If `None` - use default vectors.
* - lookup_from:
* - lookupFrom:
* Defines a location (collection and vector field name), used to lookup vectors for recommendations.

@@ -279,3 +282,3 @@ * If `None` - use current collection will be used.

* - Default: `true`
* with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -285,3 +288,3 @@ * - If `False` - Do not attach vector.

* - Default: `false`
* consistency:
* - consistency:
* Read consistency of the search. Defines how many replicas should be queried before returning the result.

@@ -355,3 +358,3 @@ * Values:

*/
async updateVectors(collection_name, { wait = true, ordering, points }) {
async updateVectors(collection_name, { wait = true, ordering, points, }) {
const response = await this._openApiClient.points.updateVectors({

@@ -513,3 +516,3 @@ collection_name,

* - Default: `true`
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -826,3 +829,3 @@ * - If `False` - Do not attach vector.

* @returns Operation result
* @param collection_name Name of the collection to recreate
* @param collectionName Name of the collection to recreate
* @param {object} args

@@ -879,14 +882,14 @@ * - vectors_config:

* @returns Operation result
* @param collection_name Name of the collection to recreate
* @param collectionName Name of the collection to recreate
* @param {object} args
* - vectors_config:
* - vectorsConfig:
* Configuration of the vector storage. Vector params contains size and distance for the vector storage.
* If dict is passed, service will create a vector storage for each key in the dict.
* If single VectorParams is passed, service will create a single anonymous vector storage.
* - shard_number: Number of shards in collection. Default is 1, minimum is 1.
* - replication_factor:
* - shardNumber: Number of shards in collection. Default is 1, minimum is 1.
* - replicationFactor:
* Replication factor for collection. Default is 1, minimum is 1.
* Defines how many copies of each shard will be created.
* Have effect only in distributed mode.
* - write_consistency_factor:
* - writeConsistencyFactor:
* Write consistency factor for collection. Default is 1, minimum is 1.

@@ -898,3 +901,3 @@ * Defines how many replicas should apply the operation for us to consider it successful.

* Have effect only in distributed mode.
* - on_disk_payload:
* - onDiskPayload:
* If true - point`s payload will not be stored in memory.

@@ -904,7 +907,7 @@ * It will be read from the disk every time it is requested.

* Note: those payload values that are involved in filtering and are indexed - remain in RAM.
* - hnsw_config: Params for HNSW index
* - optimizers_config: Params for optimizer
* - wal_config: Params for Write-Ahead-Log
* - quantization_config: Params for quantization, if None - quantization will be disabled
* - init_from: Use data stored in another collection to initialize this collection
* - hnswConfig: Params for HNSW index
* - optimizersConfig: Params for optimizer
* - walConfig: Params for Write-Ahead-Log
* - quantizationConfig: Params for quantization, if None - quantization will be disabled
* - initFrom: Use data stored in another collection to initialize this collection
* - timeout:

@@ -937,23 +940,9 @@ * Wait for operation commit timeout in seconds.

}
async uploadRecords() {
return Promise.reject(new QdrantClientNotImplementedError('uploadRecords()'));
}
/**
* Upload vectors and payload to the collection.
* This method will perform automatic batching of the data.
* If you need to perform a single update, use `upsert` method.
* Note: use `upload_records` method if you want to upload multiple vectors with single payload.
* @param collection_name Name of the collection to upload to
*/
async uploadCollection() {
return Promise.reject(new QdrantClientNotImplementedError('uploadCollection()'));
}
/**
* Creates index for a given payload field.
* Indexed fields allow to perform filtered search operations faster.
* @param collection_name Name of the collection
* @param field_name Name of the payload field
* @param collectionName Name of the collection
* @param {object} args
* - field_name: Name of the payload field.
* - field_schema: Type of data to index.
* - fieldName: Name of the payload field.
* - fieldSchema: Type of data to index.
* - wait: Await for the results to be processed.

@@ -971,3 +960,3 @@ * - If `true`, result will be returned only when all changes are applied

*/
async createPayloadIndex(collection_name, { wait, ordering, field_name, field_schema, }) {
async createPayloadIndex(collection_name, field_name, { wait, ordering, field_schema, }) {
const response = await this._openApiClient.collections.createFieldIndex({

@@ -1049,3 +1038,3 @@ collection_name,

async createFullSnapshot(args) {
const response = await this._openApiClient.snapshots.createFullSnapshot({ ...args });
const response = await this._openApiClient.snapshots.createFullSnapshot(args ?? {});
return maybe(response.data.result).orThrow('Create full snapshot API returned empty');

@@ -1052,0 +1041,0 @@ }

@@ -188,5 +188,5 @@ import { Client } from '../api-client.js';

parameters: {
query: {
query?: {
force?: boolean | undefined;
};
} | undefined;
path: {

@@ -232,5 +232,5 @@ peer_id: number;

parameters: {
query: {
query?: {
timeout?: number | undefined;
};
} | undefined;
path: {

@@ -237,0 +237,0 @@ collection_name: string;

@@ -70,5 +70,5 @@ import { Client } from '../api-client.js';

parameters: {
query: {
query?: {
timeout?: number | undefined;
};
} | undefined;
path: {

@@ -215,6 +215,6 @@ collection_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
ordering?: "weak" | "medium" | "strong" | undefined;
};
} | undefined;
path: {

@@ -280,5 +280,5 @@ collection_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
path: {

@@ -339,5 +339,5 @@ collection_name: string;

parameters: {
query: {
query?: {
timeout?: number | undefined;
};
} | undefined;
path: {

@@ -386,6 +386,6 @@ collection_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
ordering?: "weak" | "medium" | "strong" | undefined;
};
} | undefined;
path: {

@@ -438,5 +438,5 @@ collection_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
path: {

@@ -873,5 +873,5 @@ collection_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
path: {

@@ -933,5 +933,5 @@ collection_name: string;

parameters: {
query: {
query?: {
timeout?: number | undefined;
};
} | undefined;
};

@@ -998,5 +998,5 @@ requestBody?: {

parameters: {
query: {
query?: {
timeout?: number | undefined;
};
} | undefined;
path: {

@@ -1062,5 +1062,5 @@ collection_name: string;

parameters: {
query: {
query?: {
timeout?: number | undefined;
};
} | undefined;
path: {

@@ -1067,0 +1067,0 @@ collection_name: string;

@@ -49,5 +49,5 @@ import { Client } from '../api-client.js';

parameters: {
query: {
query?: {
anonymize?: boolean | undefined;
};
} | undefined;
};

@@ -117,5 +117,5 @@ responses: {

parameters: {
query: {
query?: {
anonymize?: boolean | undefined;
};
} | undefined;
};

@@ -122,0 +122,0 @@ responses: {

@@ -8,5 +8,5 @@ import { Client } from '../api-client.js';

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
};

@@ -64,5 +64,5 @@ responses: {

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
path: {

@@ -123,5 +123,5 @@ collection_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
path: {

@@ -178,5 +178,5 @@ snapshot_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
path: {

@@ -404,5 +404,5 @@ collection_name: string;

parameters: {
query: {
query?: {
wait?: boolean | undefined;
};
} | undefined;
path: {

@@ -409,0 +409,0 @@ collection_name: string;

@@ -12,4 +12,2 @@ import { ApiResponse } from '@qdrant/openapi-typescript-fetch';

}
export declare class QdrantClientNotImplementedError extends CustomError {
}
export {};
export { QdrantClient, QdrantClientParams } from './qdrant-client.js';
export type { Schemas } from './types.js';
export { Schemas } from './types.js';
export * from './errors.js';

@@ -10,4 +10,16 @@ import { OpenApiClient } from './api-client.js';

host?: string;
/**
* Local timeout for requests (uses fetch's AbortSignal) - Default 300 seconds
*/
timeout?: number;
/**
* Additional HTTP Headers to send.
*/
headers?: Record<string, number | string | string[] | undefined>;
/**
* The Node.js fetch API (undici) uses HTTP/1.1 under the hood.
* This indicates the maximum number of keep-alive connections
* to open simultaneously while building a request pool in memory.
*/
maxConnections?: number;
};

@@ -20,4 +32,4 @@ export declare class QdrantClient {

private _host;
private _restUri;
private _openApiClient;
private _restUri;
constructor({ url, host, apiKey, https, prefix, port, timeout, ...args }?: QdrantClientParams);

@@ -27,3 +39,3 @@ /**

*
* @param string Name of api
* @param name Name of api
* @returns An instance of a namespaced API, generated from OpenAPI schema.

@@ -35,3 +47,3 @@ */

*
* @param collection_name Name of the collection
* @param collectionName Name of the collection
* @param {object} args -

@@ -83,3 +95,3 @@ * - searches: List of search requests

* - If `PayloadSelector` - use explicit rules
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -104,19 +116,21 @@ * - If `False` - Do not attach vector.

* // Search with filter
* qdrant.search(
* collection_name: "test_collection",
* vector: [1.0, 0.1, 0.2, 0.7],
* filter: {
* must: [
* {
* key: 'color',
* range: {
* color: 'red'
* client.search(
* "test_collection",
* {
* vector: [1.0, 0.1, 0.2, 0.7],
* filter: {
* must: [
* {
* key: 'color',
* range: {
* color: 'red'
* }
* }
* }
* ]
* )
* ]
* )
* }
* )
* @returns List of found close points with similarity scores.
*/
search(collection_name: string, { vector, limit, offset, filter, params, with_payload, with_vector, score_threshold, consistency, }: Omit<SchemaFor<'SearchRequest'>, 'limit'> & Partial<Pick<SchemaFor<'SearchRequest'>, 'limit'>> & {
search(collection_name: string, { vector, limit, offset, filter, params, with_payload, with_vector, score_threshold, consistency, }: Partial<Pick<SchemaFor<'SearchRequest'>, 'limit'>> & Omit<SchemaFor<'SearchRequest'>, 'limit'> & {
consistency?: SchemaFor<'ReadConsistency'>;

@@ -193,3 +207,3 @@ }): Promise<{

* - Default: `true`
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -208,3 +222,3 @@ * - If `False` - Do not attach vector.

* If `None` - use default vectors.
* - lookup_from:
* - lookupFrom:
* Defines a location (collection and vector field name), used to lookup vectors for recommendations.

@@ -248,3 +262,3 @@ * If `None` - use current collection will be used.

* - Default: `true`
* with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -254,3 +268,3 @@ * - If `False` - Do not attach vector.

* - Default: `false`
* consistency:
* - consistency:
* Read consistency of the search. Defines how many replicas should be queried before returning the result.

@@ -337,3 +351,3 @@ * Values:

*/
updateVectors(collection_name: string, { wait, ordering, points }: {
updateVectors(collection_name: string, { wait, ordering, points, }: {
wait?: boolean;

@@ -488,3 +502,3 @@ ordering?: SchemaFor<'WriteOrdering'>;

* - Default: `true`
* - with_vectors:
* - with_vector:
* - If `True` - Attach stored vector to the search result.

@@ -897,3 +911,3 @@ * - If `False` - Do not attach vector.

* @returns Operation result
* @param collection_name Name of the collection to recreate
* @param collectionName Name of the collection to recreate
* @param {object} args

@@ -936,14 +950,14 @@ * - vectors_config:

* @returns Operation result
* @param collection_name Name of the collection to recreate
* @param collectionName Name of the collection to recreate
* @param {object} args
* - vectors_config:
* - vectorsConfig:
* Configuration of the vector storage. Vector params contains size and distance for the vector storage.
* If dict is passed, service will create a vector storage for each key in the dict.
* If single VectorParams is passed, service will create a single anonymous vector storage.
* - shard_number: Number of shards in collection. Default is 1, minimum is 1.
* - replication_factor:
* - shardNumber: Number of shards in collection. Default is 1, minimum is 1.
* - replicationFactor:
* Replication factor for collection. Default is 1, minimum is 1.
* Defines how many copies of each shard will be created.
* Have effect only in distributed mode.
* - write_consistency_factor:
* - writeConsistencyFactor:
* Write consistency factor for collection. Default is 1, minimum is 1.

@@ -955,3 +969,3 @@ * Defines how many replicas should apply the operation for us to consider it successful.

* Have effect only in distributed mode.
* - on_disk_payload:
* - onDiskPayload:
* If true - point`s payload will not be stored in memory.

@@ -961,7 +975,7 @@ * It will be read from the disk every time it is requested.

* Note: those payload values that are involved in filtering and are indexed - remain in RAM.
* - hnsw_config: Params for HNSW index
* - optimizers_config: Params for optimizer
* - wal_config: Params for Write-Ahead-Log
* - quantization_config: Params for quantization, if None - quantization will be disabled
* - init_from: Use data stored in another collection to initialize this collection
* - hnswConfig: Params for HNSW index
* - optimizersConfig: Params for optimizer
* - walConfig: Params for Write-Ahead-Log
* - quantizationConfig: Params for quantization, if None - quantization will be disabled
* - initFrom: Use data stored in another collection to initialize this collection
* - timeout:

@@ -978,19 +992,9 @@ * Wait for operation commit timeout in seconds.

}>>;
uploadRecords(): Promise<never>;
/**
* Upload vectors and payload to the collection.
* This method will perform automatic batching of the data.
* If you need to perform a single update, use `upsert` method.
* Note: use `upload_records` method if you want to upload multiple vectors with single payload.
* @param collection_name Name of the collection to upload to
*/
uploadCollection(): Promise<never>;
/**
* Creates index for a given payload field.
* Indexed fields allow to perform filtered search operations faster.
* @param collection_name Name of the collection
* @param field_name Name of the payload field
* @param collectionName Name of the collection
* @param {object} args
* - field_name: Name of the payload field.
* - field_schema: Type of data to index.
* - fieldName: Name of the payload field.
* - fieldSchema: Type of data to index.
* - wait: Await for the results to be processed.

@@ -1008,6 +1012,6 @@ * - If `true`, result will be returned only when all changes are applied

*/
createPayloadIndex(collection_name: string, { wait, ordering, field_name, field_schema, }: {
createPayloadIndex(collection_name: string, field_name: string, { wait, ordering, field_schema, }: {
wait?: boolean;
ordering?: SchemaFor<'WriteOrdering'>;
} & SchemaFor<'CreateFieldIndex'>): Promise<{
} & Omit<SchemaFor<'CreateFieldIndex'>, 'field_name'>): Promise<{
operation_id: number;

@@ -1014,0 +1018,0 @@ status: "acknowledged" | "completed";

@@ -5,4 +5,5 @@ import { components } from './openapi/generated_schema.js';

timeout: number;
connections?: number;
}
export type SchemaFor<K extends keyof T, T extends object = components['schemas']> = T[K];
export type Schemas = components['schemas'];
{
"name": "@qdrant/js-client-rest",
"version": "1.2.0",
"version": "1.2.1",
"engines": {

@@ -10,3 +10,4 @@ "node": ">=18.0.0",

"type": "git",
"url": "https://github.com/qdrant/qdrant-js"
"url": "https://github.com/qdrant/qdrant-js.git",
"directory": "packages/js-client-rest"
},

@@ -19,14 +20,14 @@ "bugs": {

"type": "module",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"browser": "./dist/browser/index.js",
"types": "./dist/types/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"browser": "./dist/browser/index.js",
"require": "./dist/cjs/index.js",
"browser": "./dist/browser/index.js",
"types": "./dist/types/index.d.ts",
"default": "./dist/esm/index.js"
}
},
"types": "./dist/types/index.d.ts",
"browser": "./dist/browser/index.js",
"main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js",
"files": [

@@ -38,31 +39,18 @@ "dist"

},
"sideEffects": false,
"config": {
"openapi_schema_remote": "https://raw.githubusercontent.com/qdrant/qdrant/master/docs/redoc/master/openapi.json"
},
"lint-staged": {
"*.ts": [
"prettier --list-different",
"eslint"
],
"*.{md,yaml}": "prettier --list-different"
},
"dependencies": {
"@sevinf/maybe": "^0.5.0",
"@qdrant/openapi-typescript-fetch": "^1.2.0"
"@qdrant/openapi-typescript-fetch": "^1.2.1",
"undici": "^5.22.1"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "15.0.2",
"@rollup/plugin-replace": "5.0.2",
"@rollup/plugin-terser": "0.4.0",
"@types/node": "18.15.11",
"@typescript-eslint/eslint-plugin": "5.57.0",
"@typescript-eslint/parser": "5.57.0",
"lint-staged": "13.2.1",
"openapi-typescript": "6.2.0",
"rimraf": "5.0.0",
"rollup": "3.20.2",
"ts-node": "10.9.1",
"ts-prune": "0.10.3",
"typescript": "5.0.2",
"vitest": "0.29.8"
"@rollup/plugin-commonjs": "^24.1.0",
"@rollup/plugin-replace": "^5.0.2",
"@total-typescript/ts-reset": "^0.4.2",
"openapi-typescript": "^6.2.6",
"ts-prune": "^0.10.3",
"vitest": "^0.31.4"
},

@@ -74,8 +62,7 @@ "peerDependencies": {

"build": "pnpm tsc:build && pnpm bundle",
"test": "vitest run",
"test:watch": "vitest watch",
"test:integration": "vitest run --config vite.integration.config.ts",
"pre-check": "pnpm tsc:check && pnpm tsc:deadcode && pnpm lint && pnpm test",
"pre-commit": "pnpm tsc:check && pnpm tsc:deadcode && pnpm lint-staged && pnpm test",
"tsc:deadcode": "ts-prune -e -i 'src/proto|src/openapi|src/index.ts|vite.config.ts|vite.integration.config.ts'",
"test": "vitest",
"test:integration": "vitest run --config vitest.integration.config.ts",
"pre-check": "pnpm tsc:check && pnpm tsc:deadcode && pnpm lint && pnpm test run",
"pre-commit": "pnpm tsc:check && pnpm tsc:deadcode && pnpm lint-staged && pnpm test run",
"tsc:deadcode": "ts-prune -e -i 'src/openapi|src/index.ts|vitest.config.ts|vitest.integration.config.ts'",
"tsc:check": "tsc --noEmit",

@@ -86,5 +73,4 @@ "tsc:build": "pnpm clean && tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json",

"clean": "rimraf ./dist",
"codegen:openapi-typescript": "openapi-typescript $npm_package_config_openapi_schema_remote --output src/openapi/generated_schema.ts",
"qdrant-server": "docker run -d --rm -p 6333:6333 --name qdrant-server qdrant/qdrant:v$npm_package_version"
"codegen:openapi-typescript": "openapi-typescript $npm_package_config_openapi_schema_remote --output src/openapi/generated_schema.ts"
}
}

@@ -23,3 +23,3 @@ # JavaScript Qdrant REST Client

## Instantiate a client
### Instantiate a client

@@ -34,3 +34,3 @@ ```ts

## Make requests
### Make requests

@@ -54,2 +54,39 @@ Using one of the available facade methods:

### Typed Error Handling
A non-ok fetch response throws a generic `ApiError`
But an Openapi document can declare a different response type for each status code, or a default error response type.
These can be accessed via a discriminated union on status, as in code snippet below:
```ts
const findPetsByStatus = fetcher.path('/pet/findByStatus').method('get').create();
const addPet = fetcher.path('/pet').method('post').create();
try {
const collection = await client.getCollection('bom-ada-002');
// ...
} catch (e) {
// check which operation threw the exception
if (e instanceof client.getCollection.Error) {
// get discriminated union error { status, data }
const error = e.getActualType();
// sort case's logic
if (error.status === 400) {
error.data.status.error; // only available for a 4xx responses
} else if (error.status === 500) {
error.data.status.error; // only available for a 500 response
} else {
error.data.result;
// ...
}
}
}
```
## Support
The REST implementation relies on the native [fetch API](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API), which is available in Deno and Node.js (starting on v18.0.0 without experimental flag). The Deno implementation [supports HTTP/2](https://deno.com/blog/every-web-api-in-deno#fetch-request-response-and-headers) whereas Node.js is still lagging on the spec and provide only HTTP 1.1 support (this is due to the fact that under the hood Node.js still relies on [undici](https://github.com/nodejs/undici)).
## Releases

@@ -67,3 +104,3 @@

- `pnpm test`: run unit tests
- `./tests/integration-tests.sh`: starts local docker container and runs integration tests with: `pnpm test:integration`
- `pnpm test:integration`: runs integration tests against a locally running Qdrant docker container
- `pnpm codegen:openapi-typescript`: updates generated TS schema from the latest openapi.json remote

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc