@qdrant/js-client-rest
Advanced tools
Comparing version 1.1.3 to 1.1.4
@@ -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}),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}),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})}}function a(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 i(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;const o=Object.assign(Array.isArray(t.payload)?[]:{},t.payload),n=function(t,e){return t.replace(/\{([^}]+)\}/g,((t,o)=>{const n=encodeURIComponent(e[o]);return delete e[o],n}))}(t.path,o),r=_(t.method,o,t.queryParams),s=function(t,e){const o=m(t)?JSON.stringify(e):void 0;return"delete"===t&&"{}"===o?void 0:o}(t.method,o),a=function(t,e){const o=new Headers(e);return void 0===t||o.has("Content-Type")||o.append("Content-Type","application/json"),o.has("Accept")||o.append("Accept","application/json"),o}(s,null===(e=t.init)||void 0===e?void 0:e.headers);return{url:t.baseUrl+n+r,init:{...t.init,method:t.method.toUpperCase(),headers:a,body:s}}}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 a=t[n];return await a(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}(((a,i)=>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:a,init:y(e,i),fetch:n})))})})}}const C={for:()=>g()};function A(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:a(o),snapshots:i(o)}}class v{constructor({url:t,host:e,apiKey:o,https:n,prefix:r,port:s=6333,timeout:a=3e5,...i}={}){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=i.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:a};this._openApiClient=A(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:a,with_payload:i=!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:a,with_payload:i,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:a=10,offset:i=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:a,positive:e,negative:n,filter:r,params:s,offset:i,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,with_payload:s=!0,with_vector:a=!1}={}){return o((await this._openApiClient.points.scrollPoints({collection_name:t,limit:r,filter:e,with_payload:s,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 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:a=!0}){return o((await this._openApiClient.points.setPayload({collection_name:t,payload:e,points:n,filter:r,wait:a,ordering:s})).data.result).orThrow("Set payload returned empty")}async overwritePayload(t,{ordering:e,payload:n,points:r,filter:s,wait:a=!0}){return o((await this._openApiClient.points.overwritePayload({collection_name:t,payload:n,points:r,filter:s,wait:a,ordering:e})).data.result).orThrow("Overwrite payload returned empty")}async deletePayload(t,{ordering:e,keys:n,points:r,filter:s,wait:a=!0}){return o((await this._openApiClient.points.deletePayload({collection_name:t,keys:n,points:r,filter:s,wait:a,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:a,optimizers_config:i,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:a,optimizers_config:i,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:a,optimizers_config:i,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:a,optimizers_config:i,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{v 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)}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}),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}),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})}}function a(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 i(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;const o=Object.assign(Array.isArray(t.payload)?[]:{},t.payload),n=function(t,e){return t.replace(/\{([^}]+)\}/g,((t,o)=>{const n=encodeURIComponent(e[o]);return delete e[o],n}))}(t.path,o),r=_(t.method,o,t.queryParams),s=function(t,e){const o=m(t)?JSON.stringify(e):void 0;return"delete"===t&&"{}"===o?void 0:o}(t.method,o),a=function(t,e){const o=new Headers(e);return void 0===t||o.has("Content-Type")||o.append("Content-Type","application/json"),o.has("Accept")||o.append("Accept","application/json"),o}(s,null===(e=t.init)||void 0===e?void 0:e.headers);return{url:t.baseUrl+n+r,init:{...t.init,method:t.method.toUpperCase(),headers:a,body:s}}}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 a=t[n];return await a(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}(((a,i)=>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:a,init:y(e,i),fetch:n})))})})}}const C={for:()=>g()};function A(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:a(o),snapshots:i(o)}}class v{constructor({url:t,host:e,apiKey:o,https:n,prefix:r,port:s=6333,timeout:a=3e5,...i}={}){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=i.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:a};this._openApiClient=A(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:a,with_payload:i=!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:a,with_payload:i,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:a=10,offset:i=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:a,positive:e,negative:n,filter:r,params:s,offset:i,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:a=!0,with_vector:i=!1}={}){return o((await this._openApiClient.points.scrollPoints({collection_name:t,limit:r,offset:s,filter:e,with_payload:a,with_vector:i,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 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:a=!0}){return o((await this._openApiClient.points.setPayload({collection_name:t,payload:e,points:n,filter:r,wait:a,ordering:s})).data.result).orThrow("Set payload returned empty")}async overwritePayload(t,{ordering:e,payload:n,points:r,filter:s,wait:a=!0}){return o((await this._openApiClient.points.overwritePayload({collection_name:t,payload:n,points:r,filter:s,wait:a,ordering:e})).data.result).orThrow("Overwrite payload returned empty")}async deletePayload(t,{ordering:e,keys:n,points:r,filter:s,wait:a=!0}){return o((await this._openApiClient.points.deletePayload({collection_name:t,keys:n,points:r,filter:s,wait:a,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:a,optimizers_config:i,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:a,optimizers_config:i,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:a,optimizers_config:i,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:a,optimizers_config:i,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{v as QdrantClient}; |
@@ -264,3 +264,3 @@ "use strict"; | ||
* @param {object} args | ||
* - scroll_filter: If provided - only returns points matching filtering conditions | ||
* - filter: If provided - only returns points matching filtering conditions | ||
* - limit: How many points to return | ||
@@ -291,6 +291,7 @@ * - offset: If provided - skip points with ids less than given `offset` | ||
*/ | ||
async scroll(collection_name, { filter, consistency, limit = 10, with_payload = true, with_vector = false, } = {}) { | ||
async scroll(collection_name, { filter, consistency, limit = 10, offset, with_payload = true, with_vector = false, } = {}) { | ||
const response = await this._openApiClient.points.scrollPoints({ | ||
collection_name, | ||
limit, | ||
offset, | ||
filter, | ||
@@ -297,0 +298,0 @@ with_payload, |
@@ -261,3 +261,3 @@ import { maybe } from '@sevinf/maybe'; | ||
* @param {object} args | ||
* - scroll_filter: If provided - only returns points matching filtering conditions | ||
* - filter: If provided - only returns points matching filtering conditions | ||
* - limit: How many points to return | ||
@@ -288,6 +288,7 @@ * - offset: If provided - skip points with ids less than given `offset` | ||
*/ | ||
async scroll(collection_name, { filter, consistency, limit = 10, with_payload = true, with_vector = false, } = {}) { | ||
async scroll(collection_name, { filter, consistency, limit = 10, offset, with_payload = true, with_vector = false, } = {}) { | ||
const response = await this._openApiClient.points.scrollPoints({ | ||
collection_name, | ||
limit, | ||
offset, | ||
filter, | ||
@@ -294,0 +295,0 @@ with_payload, |
@@ -230,3 +230,3 @@ import { OpenApiClient } from './api-client.js'; | ||
* @param {object} args | ||
* - scroll_filter: If provided - only returns points matching filtering conditions | ||
* - filter: If provided - only returns points matching filtering conditions | ||
* - limit: How many points to return | ||
@@ -257,3 +257,3 @@ * - offset: If provided - skip points with ids less than given `offset` | ||
*/ | ||
scroll(collection_name: string, { filter, consistency, limit, with_payload, with_vector, }?: SchemaFor<'ScrollRequest'> & { | ||
scroll(collection_name: string, { filter, consistency, limit, offset, with_payload, with_vector, }?: SchemaFor<'ScrollRequest'> & { | ||
consistency?: SchemaFor<'ReadConsistency'>; | ||
@@ -260,0 +260,0 @@ }): Promise<{ |
{ | ||
"name": "@qdrant/js-client-rest", | ||
"version": "1.1.3", | ||
"version": "1.1.4", | ||
"engines": { | ||
@@ -5,0 +5,0 @@ "node": ">=18.0.0", |
@@ -55,1 +55,12 @@ # JavaScript Qdrant REST Client | ||
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. | ||
## Contributing | ||
These are the most relevant scripts for development: | ||
- `pnpm build`: builds and bundles from TypeScript sources | ||
- `pnpm pre-check`: type-checks sources | ||
- `pnpm pre-commit`: same as pre-check, but for git hooks (husky) | ||
- `pnpm test`: run unit tests | ||
- `./tests/integration-tests.sh`: starts local docker container and runs integration tests with: `pnpm test:integration` | ||
- `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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1032154
21946
66