weaviate-ts-client
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -1,2 +0,1 @@ | ||
"use strict";var tt=Object.create;var Ce=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var it=Object.getOwnPropertyNames;var st=Object.getPrototypeOf,nt=Object.prototype.hasOwnProperty;var at=(i,t)=>{for(var e in t)Ce(i,e,{get:t[e],enumerable:!0})},Le=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of it(t))!nt.call(i,s)&&s!==e&&Ce(i,s,{get:()=>t[s],enumerable:!(r=rt(t,s))||r.enumerable});return i};var ot=(i,t,e)=>(e=i!=null?tt(st(i)):{},Le(t||!i||!i.__esModule?Ce(e,"default",{value:i,enumerable:!0}):e,i)),ht=i=>Le(Ce({},"__esModule",{value:!0}),i);var At={};at(At,{Aggregator:()=>x,ApiKey:()=>le,AuthAccessTokenCredentials:()=>N,AuthClientCredentials:()=>he,AuthUserPasswordCredentials:()=>oe,BackupCreateStatusGetter:()=>b,BackupCreator:()=>se,BackupRestoreStatusGetter:()=>P,BackupRestorer:()=>ne,Checker:()=>U,ClassCreator:()=>B,ClassDeleter:()=>I,ClassGetter:()=>R,ClassificationsGetter:()=>g,ClassificationsScheduler:()=>z,ConceptsGetter:()=>ie,Creator:()=>F,Deleter:()=>M,Explorer:()=>E,ExtensionCreator:()=>re,Getter:()=>D,GetterById:()=>W,GraphQLGetter:()=>A,LiveChecker:()=>ee,Merger:()=>_,MetaGetter:()=>v,NodesStatusGetter:()=>ae,ObjectsBatchDeleter:()=>X,ObjectsBatcher:()=>Y,OidcAuthenticator:()=>de,OpenidConfigurationGetter:()=>l,PropertyCreator:()=>T,Raw:()=>$,ReadyChecker:()=>te,ReferenceCreator:()=>H,ReferenceDeleter:()=>K,ReferencePayloadBuilder:()=>Q,ReferenceReplacer:()=>J,ReferencesBatcher:()=>Z,SchemaGetter:()=>O,ShardUpdater:()=>L,ShardsUpdater:()=>V,Updater:()=>q,Validator:()=>G,default:()=>jt});module.exports=ht(At);var de=class{constructor(t,e){this.refresh=async t=>{let e=await this.getOpenidConfig(t),r;switch(this.creds.constructor){case oe:r=new $e(this.http,this.creds,e);break;case N:r=new Be(this.http,this.creds,e);break;case he:r=new Ie(this.http,this.creds,e);break;default:throw new Error("unsupported credential type")}return r.refresh().then(s=>{this.accessToken=s.accessToken,this.expiresAt=s.expiresAt,this.refreshToken=s.refreshToken,this.startTokenRefresh(r)})};this.getOpenidConfig=t=>this.http.externalGet(t.href).then(e=>{let r=t.scopes||[];return{clientId:t.clientId,provider:e,scopes:r}});this.startTokenRefresh=t=>{this.creds.silentRefresh&&!this.refreshRunning&&this.refreshTokenProvided()&&(this.refreshInterval=setInterval(async()=>{if(this.expiresAt-Date.now()<=6e4){let e=await t.refresh();this.accessToken=e.accessToken,this.expiresAt=e.expiresAt,this.refreshToken=e.refreshToken}},3e4),this.refreshRunning=!0)};this.stopTokenRefresh=()=>{clearInterval(this.refreshInterval),this.refreshRunning=!1};this.refreshTokenProvided=()=>this.refreshToken&&this.refreshToken!="";this.getAccessToken=()=>this.accessToken;this.getExpiresAt=()=>this.expiresAt;this.http=t,this.creds=e,this.accessToken="",this.refreshToken="",this.expiresAt=0,this.refreshRunning=!1,this.creds instanceof N&&(this.accessToken=this.creds.accessToken,this.expiresAt=this.creds.expiresAt,this.refreshToken=this.creds.refreshToken)}resetExpiresAt(){this.expiresAt=0}},oe=class{constructor(t){this.username=t.username,this.password=t.password,this.scopes=t.scopes,this.silentRefresh=Re(t.silentRefresh)}},$e=class{constructor(t,e,r){this.refresh=()=>(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:be(t.expires_in),refreshToken:t.refresh_token})).catch(t=>Promise.reject(new Error(`failed to refresh access token: ${t}`))));this.validateOpenidConfig=()=>{if(this.openidConfig.provider.grant_types_supported!==void 0&&!this.openidConfig.provider.grant_types_supported.includes("password"))throw new Error("grant_type password not supported");if(this.openidConfig.provider.token_endpoint.includes("https://login.microsoftonline.com"))throw new Error("microsoft/azure recommends to avoid authentication using username and password, so this method is not supported by this client");this.openidConfig.scopes.push("offline_access")};this.requestAccessToken=()=>{let t=this.openidConfig.provider.token_endpoint,e=new URLSearchParams({grant_type:"password",client_id:this.openidConfig.clientId,username:this.creds.username,password:this.creds.password,scope:this.openidConfig.scopes.join(" ")}),r="application/x-www-form-urlencoded;charset=UTF-8";return this.http.externalPost(t,e,r)};this.http=t,this.creds=e,this.openidConfig=r,e.scopes&&this.openidConfig.scopes.push(e.scopes)}},N=class{constructor(t){this.validate=t=>{if(t.expiresIn===void 0)throw new Error("AuthAccessTokenCredentials: expiresIn is required");if(!Number.isInteger(t.expiresIn)||t.expiresIn<=0)throw new Error("AuthAccessTokenCredentials: expiresIn must be int > 0")};this.validate(t),this.accessToken=t.accessToken,this.expiresAt=be(t.expiresIn),this.refreshToken=t.refreshToken,this.silentRefresh=Re(t.silentRefresh)}},Be=class{constructor(t,e,r){this.refresh=()=>this.creds.refreshToken===void 0||this.creds.refreshToken==""?(console.warn("AuthAccessTokenCredentials not provided with refreshToken, cannot refresh"),Promise.resolve({accessToken:this.creds.accessToken,expiresAt:this.creds.expiresAt})):(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:be(t.expires_in),refreshToken:t.refresh_token})).catch(t=>Promise.reject(new Error(`failed to refresh access token: ${t}`))));this.validateOpenidConfig=()=>{if(this.openidConfig.provider.grant_types_supported===void 0||!this.openidConfig.provider.grant_types_supported.includes("refresh_token"))throw new Error("grant_type refresh_token not supported")};this.requestAccessToken=()=>{let t=this.openidConfig.provider.token_endpoint,e=new URLSearchParams({grant_type:"refresh_token",client_id:this.openidConfig.clientId,refresh_token:this.creds.refreshToken}),r="application/x-www-form-urlencoded;charset=UTF-8";return this.http.externalPost(t,e,r)};this.http=t,this.creds=e,this.openidConfig=r}},he=class{constructor(t){this.clientSecret=t.clientSecret,this.scopes=t.scopes,this.silentRefresh=Re(t.silentRefresh)}},Ie=class{constructor(t,e,r){this.refresh=()=>(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:be(t.expires_in),refreshToken:t.refresh_token})).catch(t=>Promise.reject(new Error(`failed to refresh access token: ${t}`))));this.validateOpenidConfig=()=>{this.openidConfig.scopes.length>0||this.openidConfig.provider.token_endpoint.includes("https://login.microsoftonline.com")&&this.openidConfig.scopes.push(this.openidConfig.clientId+"/.default")};this.requestAccessToken=()=>{let t=this.openidConfig.provider.token_endpoint,e=new URLSearchParams({grant_type:"client_credentials",client_id:this.openidConfig.clientId,client_secret:this.creds.clientSecret,scope:this.openidConfig.scopes.join(" ")}),r="application/x-www-form-urlencoded;charset=UTF-8";return this.http.externalPost(t,e,r)};this.http=t,this.creds=e,this.openidConfig=r,e.scopes&&this.openidConfig.scopes.push(e.scopes)}},le=class{constructor(t){this.apiKey=t}};function be(i){return Date.now()+(i-2)*1e3}function Re(i){return i===void 0?!0:i}var l=class{constructor(t){this.do=()=>this.client.getRaw("/.well-known/openid-configuration").then(t=>t.status<400?t.json():t.status==404?Promise.resolve(void 0):Promise.reject(new Error(`unexpected status code: ${t.status}`)));this.client=t}};var d=ot(require("isomorphic-fetch")),ct=i=>{let t=`${i.scheme}://${i.host}/v1`,e=dt(t);return{post:(r,s,a=!0,h="")=>{let c={method:"POST",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(s)};return S(c,h),(0,d.default)(e(r),c).then(y(a))},put:(r,s,a=!0,h="")=>{let c={method:"PUT",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(s)};return S(c,h),(0,d.default)(e(r),c).then(y(a))},patch:(r,s,a="")=>{let h={method:"PATCH",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(s)};return S(h,a),(0,d.default)(e(r),h).then(y(!1))},delete:(r,s,a=!1,h="")=>{let c={method:"DELETE",headers:{...i.headers,"content-type":"application/json"},body:s?JSON.stringify(s):void 0};return S(c,h),(0,d.default)(e(r),c).then(y(a))},head:(r,s,a="")=>{let h={method:"HEAD",headers:{...i.headers,"content-type":"application/json"},body:s?JSON.stringify(s):void 0};return S(h,a),(0,d.default)(e(r),h).then(lt(!1))},get:(r,s=!0,a="")=>{let h={method:"GET",headers:{...i.headers}};return S(h,a),(0,d.default)(e(r),h).then(y(s))},getRaw:(r,s="")=>{let a={method:"GET",headers:{...i.headers}};return S(a,s),(0,d.default)(e(r),a)},externalGet:r=>(0,d.default)(r,{method:"GET",headers:{...i.headers}}).then(y(!0)),externalPost:(r,s,a)=>{(a==null||a=="")&&(a="application/json");let h={body:void 0,method:"POST",headers:{...i.headers,"content-type":a}};return s!=null&&(h.body=s),(0,d.default)(r,h).then(y(!0))}}},dt=i=>t=>i+t,y=i=>t=>{if(t.status>=400)return t.text().then(e=>{let r;try{r=JSON.stringify(JSON.parse(e))}catch{r=e}return Promise.reject(new Error(`usage error (${t.status}): ${r}`))});if(i)return t.json()},lt=i=>t=>t.status==204||t.status==404?t.status==204:y(i);function S(i,t){t!==""&&(i.headers.Authorization=`Bearer ${t}`)}var Ve=ct;var Fe=require("graphql-request"),pt=i=>{let t=i.scheme,e=i.host,r=i.headers;return{query:(s,a,h)=>new Fe.GraphQLClient(`${t}://${e}/v1/graphql`,{headers:{...r,...h}}).request(s,a,h).then(c=>({data:c}))}},Ge=pt;var pe=class{constructor(t){this.post=(t,e,r=!0)=>this.authEnabled?this.login().then(s=>this.http.post(t,e,r,s)):this.http.post(t,e,r);this.put=(t,e,r=!0)=>this.authEnabled?this.login().then(s=>this.http.put(t,e,r,s)):this.http.put(t,e,r);this.patch=(t,e)=>this.authEnabled?this.login().then(r=>this.http.patch(t,e,r)):this.http.patch(t,e);this.delete=(t,e,r=!1)=>this.authEnabled?this.login().then(s=>this.http.delete(t,e,r,s)):this.http.delete(t,e,r);this.head=(t,e)=>this.authEnabled?this.login().then(r=>this.http.head(t,e,r)):this.http.head(t,e);this.get=(t,e=!0)=>this.authEnabled?this.login().then(r=>this.http.get(t,e,r)):this.http.get(t,e);this.query=(t,e)=>this.authEnabled?this.login().then(r=>{let s={Authorization:`Bearer ${r}`};return this.gql.query(t,e,s)}):this.gql.query(t,e);this.login=async()=>{if(this.apiKey)return this.apiKey;if(!this.oidcAuth)return"";let t=await new l(this.http).do();return t===void 0?(console.warn("client is configured for authentication, but server is not"),""):(Date.now()>=this.oidcAuth.getExpiresAt()&&await this.oidcAuth.refresh(t),this.oidcAuth.getAccessToken())};t=this.sanitizeParams(t),this.http=Ve(t),this.gql=Ge(t),this.authEnabled=this.parseAuthParams(t)}parseAuthParams(t){if(t.authClientSecret&&t.apiKey)throw new Error("must provide one of authClientSecret (OIDC) or apiKey, cannot provide both");return t.authClientSecret?(this.oidcAuth=new de(this.http,t.authClientSecret),!0):t.apiKey?(this.apiKey=t.apiKey?.apiKey,!0):!1}sanitizeParams(t){for(;t.host.endsWith("/");)t.host=t.host.slice(0,-1);return t}};var p=class{constructor(t){this.source=t}toString(){if(this.parse(),this.validate(),this.operands)return`{operator:${this.operator},operands:[${this.operands}]}`;{let t=this.marshalValueContent();return`{operator:${this.operator},${this.valueType}:${t},path:${JSON.stringify(this.path)}}`}}marshalValueContent(){return this.valueType=="valueGeoRange"?this.marshalValueGeoRange():JSON.stringify(this.valueContent)}marshalValueGeoRange(){let t=[],e=this.valueContent.geoCoordinates;if(e){let s=[];e.latitude&&(s=[...s,`latitude:${e.latitude}`]),e.longitude&&(s=[...s,`longitude:${e.longitude}`]),t=[...t,`geoCoordinates:{${s.join(",")}}`]}let r=this.valueContent.distance;if(r){let s=[];r.max&&(s=[...s,`max:${r.max}`]),t=[...t,`distance:{${s.join(",")}}`]}return`{${t.join(",")}}`}validate(){if(!this.operator)throw new Error("where filter: operator cannot be empty");if(!this.operands){if(!this.valueType)throw new Error("where filter: value<Type> cannot be empty");if(!this.path)throw new Error("where filter: path cannot be empty")}}parse(){for(let t in this.source)switch(t){case"operator":this.parseOperator(this.source[t]);break;case"operands":this.parseOperands(this.source[t]);break;case"path":this.parsePath(this.source[t]);break;default:if(t.indexOf("value")!=0)throw new Error("where filter: unrecognized key '"+t+"'");this.parseValue(t,this.source[t])}}parseOperator(t){if(typeof t!="string")throw new Error("where filter: operator must be a string");this.operator=t}parsePath(t){if(!Array.isArray(t))throw new Error("where filter: path must be an array");this.path=t}parseValue(t,e){switch(t){case"valueString":case"valueText":case"valueInt":case"valueNumber":case"valueDate":case"valueBoolean":case"valueGeoRange":break;default:throw new Error("where filter: unrecognized value prop '"+t+"'")}this.valueType=t,this.valueContent=e}parseOperands(t){if(!Array.isArray(t))throw new Error("where filter: operands must be an array");this.operands=t.map(e=>new p(e).toString()).join(",")}};var u=class{constructor(t){this.autocorrect=t.autocorrect,this.certainty=t.certainty,this.concepts=t.concepts,this.distance=t.distance,this.moveAwayFrom=t.moveAwayFrom,this.moveTo=t.moveTo}toString(){this.validate();let t=[`concepts:${JSON.stringify(this.concepts)}`];if(this.certainty&&(t=[...t,`certainty:${this.certainty}`]),this.distance&&(t=[...t,`distance:${this.distance}`]),this.moveTo){let e=[];this.moveTo.concepts&&(e=[...e,`concepts:${JSON.stringify(this.moveTo.concepts)}`]),this.moveTo.objects&&(e=[...e,`objects:${this.parseMoveObjects("moveTo",this.moveTo.objects)}`]),this.moveTo.force&&(e=[...e,`force:${this.moveTo.force}`]),t=[...t,`moveTo:{${e.join(",")}}`]}if(this.moveAwayFrom){let e=[];this.moveAwayFrom.concepts&&(e=[...e,`concepts:${JSON.stringify(this.moveAwayFrom.concepts)}`]),this.moveAwayFrom.objects&&(e=[...e,`objects:${this.parseMoveObjects("moveAwayFrom",this.moveAwayFrom.objects)}`]),this.moveAwayFrom.force&&(e=[...e,`force:${this.moveAwayFrom.force}`]),t=[...t,`moveAwayFrom:{${e.join(",")}}`]}return this.autocorrect!==void 0&&(t=[...t,`autocorrect:${this.autocorrect}`]),`{${t.join(",")}}`}validate(){if(this.moveTo){if(!this.moveTo.concepts&&!this.moveTo.objects)throw new Error("nearText filter: moveTo.concepts or moveTo.objects must be present");if(!this.moveTo.force||!this.moveTo.concepts&&!this.moveTo.objects)throw new Error("nearText filter: moveTo must have fields 'concepts' or 'objects' and 'force'")}if(this.moveAwayFrom){if(!this.moveAwayFrom.concepts&&!this.moveAwayFrom.objects)throw new Error("nearText filter: moveAwayFrom.concepts or moveAwayFrom.objects must be present");if(!this.moveAwayFrom.force||!this.moveAwayFrom.concepts&&!this.moveAwayFrom.objects)throw new Error("nearText filter: moveAwayFrom must have fields 'concepts' or 'objects' and 'force'")}}parseMoveObjects(t,e){let r=[];for(let s in e){if(!e[s].id&&!e[s].beacon)throw new Error(`nearText: ${t}.objects[${s}].id or ${t}.objects[${s}].beacon must be present`);let a=[];e[s].id&&a.push(`id:"${e[s].id}"`),e[s].beacon&&a.push(`beacon:"${e[s].beacon}"`),r.push(`{${a.join(",")}}`)}return`[${r.join(",")}]`}};var m=class{constructor(t){this.certainty=t.certainty,this.distance=t.distance,this.vector=t.vector}toString(t=!0){let e=[`vector:${JSON.stringify(this.vector)}`];return this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}};var f=class{constructor(t){this.beacon=t.beacon,this.certainty=t.certainty,this.distance=t.distance,this.id=t.id}toString(t=!0){this.validate();let e=[];return this.id&&(e=[...e,`id:${JSON.stringify(this.id)}`]),this.beacon&&(e=[...e,`beacon:${JSON.stringify(this.beacon)}`]),this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.id&&!this.beacon)throw new Error("nearObject filter: id or beacon needs to be set")}};function ut(i){return Number.isInteger(i)}function qe(i){return ut(i)&&i>=0}var n=class{constructor(t){this.client=t,this._errors=[]}get errors(){return this._errors}addError(t){this._errors=[...this.errors,t]}addErrors(t){this._errors=[...this.errors,...t]}};var x=class extends n{constructor(e){super(e);this.withFields=e=>(this.fields=e,this);this.withClassName=e=>(this.className=e,this);this.withWhere=e=>{try{this.whereString=new p(e).toString()}catch(r){this.addError(r)}return this};this.withNearText=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearTextString=new u(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearObject=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearObjectString=new f(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearVector=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearVectorString=new m(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withObjectLimit=e=>{if(!qe(e))throw new Error("objectLimit must be a non-negative integer");return this.objectLimit=e,this};this.withLimit=e=>(this.limit=e,this);this.withGroupBy=e=>(this.groupBy=e,this);this.validateGroup=()=>{if(this.groupBy&&!Array.isArray(this.groupBy))throw new Error("groupBy must be an array")};this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateGroup(),this.validateIsSet(this.className,"className",".withClassName(className)"),this.validateIsSet(this.fields,"fields",".withFields(fields)")};this.do=()=>{let e="";if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));if(this.whereString||this.nearTextString||this.nearObjectString||this.nearVectorString||this.limit||this.groupBy){let r=[];this.whereString&&(r=[...r,`where:${this.whereString}`]),this.nearTextString&&(r=[...r,`nearText:${this.nearTextString}`]),this.nearObjectString&&(r=[...r,`nearObject:${this.nearObjectString}`]),this.nearVectorString&&(r=[...r,`nearVector:${this.nearVectorString}`]),this.groupBy&&(r=[...r,`groupBy:${JSON.stringify(this.groupBy)}`]),this.limit&&(r=[...r,`limit:${this.limit}`]),this.objectLimit&&(r=[...r,`objectLimit:${this.objectLimit}`]),e=`(${r.join(",")})`}return this.client.query(`{Aggregate{${this.className}${e}{${this.fields}}}}`)};this.includesNearMediaFilter=!1}};var ue=class{constructor(t){this.properties=t.properties,this.query=t.query}toString(){let t=[`query:${JSON.stringify(this.query)}`];return this.properties!==void 0&&(t=[...t,`properties:${JSON.stringify(this.properties)}`]),`{${t.join(",")}}`}};var me=class{constructor(t){this.alpha=t.alpha,this.query=t.query,this.vector=t.vector}toString(){let t=[`query:${JSON.stringify(this.query)}`];return this.alpha!==void 0&&(t=[...t,`alpha:${JSON.stringify(this.alpha)}`]),this.vector!==void 0&&(t=[...t,`vector:${JSON.stringify(this.vector)}`]),`{${t.join(",")}}`}};var k=class{constructor(t){this.certainty=t.certainty,this.distance=t.distance,this.image=t.image}toString(t=!0){this.validate();let e=[];if(this.image){let r=this.image;if(r.startsWith("data:")){let s=";base64,";r=r.substring(r.indexOf(s)+s.length)}e=[...e,`image:${JSON.stringify(r)}`]}return this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.image)throw new Error("nearImage filter: image field must be present")}};var j=class{constructor(t){this.autocorrect=t.autocorrect,this.certainty=t.certainty,this.distance=t.distance,this.properties=t.properties,this.question=t.question,this.rerank=t.rerank}toString(t=!0){this.validate();let e=[];return this.question&&(e=[...e,`question:${JSON.stringify(this.question)}`]),this.properties&&(e=[...e,`properties:${JSON.stringify(this.properties)}`]),this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),this.autocorrect!==void 0&&(e=[...e,`autocorrect:${this.autocorrect}`]),this.rerank!==void 0&&(e=[...e,`rerank:${this.rerank}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.question)throw new Error("ask filter: question needs to be set")}};var fe=class{constructor(t){this.args=t}toString(){let t=[];return this.args.type&&(t=[...t,`type:${this.args.type}`]),this.args.force&&(t=[...t,`force:${this.args.force}`]),`{${t.join(",")}}`}};var ge=class{constructor(t){this.args=t}toString(){let t=[];for(let e of this.args){let r=`{path:${JSON.stringify(e.path)}`;e.order?r=r.concat(`,order:${e.order}}`):r=r.concat("}"),t.push(r)}return t.join(",")}};var Pe=class{constructor(t){this.groupedTask=t.groupedTask,this.singlePrompt=t.singlePrompt}toString(){this.validate();let t="generate(",e=["error"];return this.singlePrompt&&(t+=`singleResult:{prompt:"${this.singlePrompt.replace(/[\n\r]+/g,"")}"}`,e.push("singleResult")),this.groupedTask&&(t+=`groupedResult:{task:"${this.groupedTask.replace(/[\n\r]+/g,"")}"}`,e.push("groupedResult")),t+=`){${e.join(" ")}}`,t}validate(){if(!this.groupedTask&&!this.singlePrompt)throw new Error("must provide at least one of `singlePrompt` or `groupTask`");if(this.groupedTask!==void 0&&this.groupedTask=="")throw new Error("groupedTask must not be empty");if(this.singlePrompt!==void 0&&this.singlePrompt=="")throw new Error("singlePrompt must not be empty")}};var ve=class{constructor(t){this.args=t}toString(){let t=[];return this.args.path&&(t=[...t,`path:${JSON.stringify(this.args.path)}`]),this.args.groups&&(t=[...t,`groups:${this.args.groups}`]),this.args.objectsPerGroup&&(t=[...t,`objectsPerGroup:${this.args.objectsPerGroup}`]),`{${t.join(",")}}`}};var A=class extends n{constructor(e){super(e);this.withFields=e=>(this.fields=e,this);this.withClassName=e=>(this.className=e,this);this.withAfter=e=>(this.after=e,this);this.withGroup=e=>{try{this.groupString=new fe(e).toString()}catch(r){this.addError(r.toString())}return this};this.withWhere=e=>{try{this.whereString=new p(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearText=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");return this.nearTextString=new u(e).toString(),this.includesNearMediaFilter=!0,this};this.withBm25=e=>{try{this.bm25String=new ue(e).toString()}catch(r){this.addError(r.toString())}return this};this.withHybrid=e=>{try{this.hybridString=new me(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearObject=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearObjectString=new f(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withAsk=e=>{try{this.askString=new j(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearImage=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearImageString=new k(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearVector=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearVectorString=new m(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withLimit=e=>(this.limit=e,this);this.withOffset=e=>(this.offset=e,this);this.withSort=e=>(this.sortString=new ge(e).toString(),this);this.withGenerate=e=>(this.generateString=new Pe(e).toString(),this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.withGroupBy=e=>{try{this.groupByString=new ve(e).toString()}catch(r){this.addError(r.toString())}return this};this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.className,"className",".withClassName(className)"),this.validateIsSet(this.fields,"fields",".withFields(fields)")};this.do=()=>{let e="";if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let r=[];return this.whereString&&(r=[...r,`where:${this.whereString}`]),this.nearTextString&&(r=[...r,`nearText:${this.nearTextString}`]),this.nearObjectString&&(r=[...r,`nearObject:${this.nearObjectString}`]),this.askString&&(r=[...r,`ask:${this.askString}`]),this.nearImageString&&(r=[...r,`nearImage:${this.nearImageString}`]),this.nearVectorString&&(r=[...r,`nearVector:${this.nearVectorString}`]),this.bm25String&&(r=[...r,`bm25:${this.bm25String}`]),this.hybridString&&(r=[...r,`hybrid:${this.hybridString}`]),this.groupString&&(r=[...r,`group:${this.groupString}`]),this.limit&&(r=[...r,`limit:${this.limit}`]),this.offset&&(r=[...r,`offset:${this.offset}`]),this.sortString&&(r=[...r,`sort:[${this.sortString}]`]),this.after&&(r=[...r,`after:"${this.after}"`]),this.generateString&&(this.fields?.includes("_additional")?this.fields.replace("_additional{",`_additional{${this.generateString}`):this.fields=this.fields?.concat(` _additional{${this.generateString}}`)),this.consistencyLevel&&(r=[...r,`consistencyLevel:${this.consistencyLevel}`]),this.groupByString&&(r=[...r,`groupBy:${this.groupByString}`]),r.length>0&&(e=`(${r.join(",")})`),this.client.query(`{Get{${this.className}${e}{${this.fields}}}}`)};this.includesNearMediaFilter=!1}};var E=class extends n{constructor(e){super(e);this.withFields=e=>(this.fields=e,this);this.withLimit=e=>(this.limit=e,this);this.withNearText=e=>{try{this.nearTextString=new u(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearObject=e=>{try{this.nearObjectString=new f(e).toString()}catch(r){this.addError(r.toString())}return this};this.withAsk=e=>{try{this.askString=new j(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearImage=e=>{try{this.nearImageString=new k(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearVector=e=>{try{this.nearVectorString=new m(e).toString()}catch(r){this.addError(r.toString())}return this};this.validateGroup=()=>{if(this.group&&!Array.isArray(this.group))throw new Error("groupBy must be an array")};this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.fields,"fields",".withFields(fields)")};this.do=()=>{let e="";if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let r=[];return this.nearTextString&&(r=[...r,`nearText:${this.nearTextString}`]),this.nearObjectString&&(r=[...r,`nearObject:${this.nearObjectString}`]),this.askString&&(r=[...r,`ask:${this.askString}`]),this.nearImageString&&(r=[...r,`nearImage:${this.nearImageString}`]),this.nearVectorString&&(r=[...r,`nearVector:${this.nearVectorString}`]),this.limit&&(r=[...r,`limit:${this.limit}`]),e=`(${r.join(",")})`,this.client.query(`{Explore${e}{${this.fields}}}`)};this.params={}}};var $=class extends n{constructor(e){super(e);this.withQuery=e=>(this.query=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.query,"query",".raw().withQuery(query)")};this.do=()=>{let e="";return this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.query?this.client.query(this.query):Promise.resolve(void 0)}}};var mt=i=>({get:()=>new A(i),aggregate:()=>new x(i),explore:()=>new E(i),raw:()=>new $(i)}),_e=mt;var B=class extends n{constructor(e){super(e);this.withClass=e=>(this.class=e,this);this.validateClass=()=>{(this.class==null||this.class==null)&&this.addError("class object must be set - set with .withClass(class)")};this.do=()=>{if(this.validateClass(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/schema";return this.client.post(e,this.class)}}validate(){this.validateClass()}};function o(i){return typeof i=="string"&&i.length>0}var I=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validate=()=>{this.validateClassName()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/schema/${this.className}`;return this.client.delete(e,void 0,!1)}}};var R=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validate=()=>{this.validateClassName()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/schema/${this.className}`;return this.client.get(e)}}};var T=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.withProperty=e=>(this.property=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validateProperty=()=>{(this.property==null||this.property==null)&&this.addError("property must be set - set with .withProperty(property)")};this.validate=()=>{this.validateClassName(),this.validateProperty()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/schema/${this.className}/properties`;return this.client.post(e,this.property)}}};var O=class extends n{constructor(e){super(e);this.do=()=>{if(this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/schema";return this.client.get(e)}}validate(){}};var ye=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validate=()=>{this.validateClassName()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error(`invalid usage: ${this.errors.join(", ")}`)):Te(this.client,this.className))}};function Te(i,t){let e=`/schema/${t}/shards`;return i.get(e)}var L=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.withShardName=e=>(this.shardName=e,this);this.validateShardName=()=>{o(this.shardName)||this.addError("shardName must be set - set with .withShardName(shardName)")};this.withStatus=e=>(this.status=e,this);this.validateStatus=()=>{o(this.status)||this.addError("status must be set - set with .withStatus(status)")};this.validate=()=>{this.validateClassName(),this.validateShardName(),this.validateStatus()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error(`invalid usage: ${this.errors.join(", ")}`)):Oe(this.client,this.className,this.shardName,this.status))}};function Oe(i,t,e,r){let s=`/schema/${t}/shards/${e}`;return i.put(s,{status:r},!0)}var V=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.withStatus=e=>(this.status=e,this);this.validateStatus=()=>{o(this.status)||this.addError("status must be set - set with .withStatus(status)")};this.validate=()=>{this.validateClassName(),this.validateStatus()};this.updateShards=async()=>{let e=await Promise.all(Array.from({length:this.shards.length},(r,s)=>Oe(this.client,this.className,this.shards[s].name||"",this.status).then(a=>({name:this.shards[s].name,status:a.status})).catch(a=>this.addError(a.toString()))));return this.errors.length>0?Promise.reject(new Error(`failed to update shards: ${this.errors.join(", ")}`)):Promise.resolve(e)};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error(`invalid usage: ${this.errors.join(", ")}`)):Te(this.client,this.className).then(e=>this.shards=e).then(()=>this.updateShards()).then(e=>e).catch(e=>Promise.reject(e)));this.shards=[]}};var ft=i=>({classCreator:()=>new B(i),classDeleter:()=>new I(i),classGetter:()=>new R(i),getter:()=>new O(i),propertyCreator:()=>new T(i),shardsGetter:()=>new ye(i),shardUpdater:()=>new L(i),shardsUpdater:()=>new V(i)}),De=ft;var F=class extends n{constructor(e,r){super(e);this.withVector=e=>(this.vector=e,this);this.withClassName=e=>(this.className=e,this);this.withProperties=e=>(this.properties=e,this);this.withId=e=>(this.id=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.payload=()=>({vector:this.vector,properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildCreate(this.consistencyLevel).then(e=>this.client.post(e,this.payload())));this.objectsPath=r}};var G=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.withProperties=e=>(this.properties=e,this);this.withId=e=>(this.id=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.payload=()=>({properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/objects/validate";return this.client.post(e,this.payload(),!1).then(()=>!0)}}};var q=class extends n{constructor(e,r){super(e);this.withProperties=e=>(this.properties=e,this);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - use withClassName(className)")};this.validateId=()=>{(this.id==null||this.id==null||this.id.length==0)&&this.addError("id must be set - initialize with updater(id)")};this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>({properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName(),this.validateId()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildUpdate(this.id,this.className,this.consistencyLevel).then(e=>this.client.put(e,this.payload())));this.objectsPath=r}};var _=class extends n{constructor(e,r){super(e);this.withProperties=e=>(this.properties=e,this);this.withClassName=e=>(this.className=e,this);this.withId=e=>(this.id=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with withClassName(className)")};this.validateId=()=>{(this.id==null||this.id==null||this.id.length==0)&&this.addError("id must be set - set with withId(id)")};this.payload=()=>({properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName(),this.validateId()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildMerge(this.id,this.className,this.consistencyLevel).then(e=>this.client.patch(e,this.payload())));this.objectsPath=r}};var D=class extends n{constructor(e,r){super(e);this.withClassName=e=>(this.className=e,this);this.withAfter=e=>(this.after=e,this);this.withLimit=e=>(this.limit=e,this);this.extendAdditional=e=>(this.additional=[...this.additional,e],this);this.withAdditional=e=>this.extendAdditional(e);this.withVector=()=>this.extendAdditional("vector");this.do=()=>this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildGet(this.className,this.limit,this.additional,this.after).then(e=>this.client.get(e));this.objectsPath=r,this.additional=[]}validate(){}};var W=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.extendAdditional=e=>(this.additional=[...this.additional,e],this);this.withAdditional=e=>this.extendAdditional(e);this.withVector=()=>this.extendAdditional("vector");this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.withNodeName=e=>(this.nodeName=e,this);this.validateId=()=>{(this.id==null||this.id==null||this.id.length==0)&&this.addError("id must be set - initialize with getterById(id)")};this.validate=()=>{this.validateId()};this.buildPath=()=>this.objectsPath.buildGetOne(this.id,this.className,this.additional,this.consistencyLevel,this.nodeName);this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.buildPath().then(e=>this.client.get(e)));this.objectsPath=r,this.additional=[]}};var M=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateId=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.validate=()=>{this.validateId()};this.do=()=>this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):(this.validate(),this.objectsPath.buildDelete(this.id,this.className,this.consistencyLevel).then(e=>this.client.delete(e,void 0,!1)));this.objectsPath=r}};var U=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateId=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.validate=()=>{this.validateId()};this.do=()=>this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):(this.validate(),this.objectsPath.buildCheck(this.id,this.className).then(e=>this.client.head(e,void 0)));this.objectsPath=r}};var H=class extends n{constructor(e,r,s){super(e);this.withId=e=>(this.id=e,this);this.withReference=e=>(this.reference=e,this);this.withReferenceProperty=e=>(this.refProp=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)"),this.validateIsSet(this.refProp,"referenceProperty",".withReferenceProperty(refProp)")};this.payload=()=>this.reference;this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));if(!this.reference.beacon)throw new Error("reference beacon must be set");return Promise.all([this.referencesPath.build(this.id,this.className,this.refProp,this.consistencyLevel),this.beaconPath.rebuild(this.reference.beacon)]).then(e=>{let r=e[0],s=e[1];return this.client.post(r,{beacon:s},!1)})};this.referencesPath=r,this.beaconPath=s}withClassName(e){return this.className=e,this}};var J=class extends n{constructor(e,r,s){super(e);this.withId=e=>(this.id=e,this);this.withReferences=e=>(this.references=e,this);this.withReferenceProperty=e=>(this.refProp=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)"),this.validateIsSet(this.refProp,"referenceProperty",".withReferenceProperty(refProp)")};this.payload=()=>this.references;this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=Array.isArray(this.references)?Promise.all(this.references.map(r=>this.rebuildReferencePromise(r))):Promise.resolve([]);return Promise.all([this.referencesPath.build(this.id,this.className,this.refProp,this.consistencyLevel),e]).then(r=>{let s=r[0],a=r[1];return this.client.put(s,a,!1)})};this.beaconPath=s,this.referencesPath=r}withClassName(e){return this.className=e,this}rebuildReferencePromise(e){return this.beaconPath.rebuild(e.beacon).then(r=>({beacon:r}))}};var K=class extends n{constructor(e,r,s){super(e);this.withId=e=>(this.id=e,this);this.withReference=e=>(this.reference=e,this);this.withReferenceProperty=e=>(this.refProp=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)"),this.validateIsSet(this.refProp,"referenceProperty",".withReferenceProperty(refProp)")};this.payload=()=>this.reference;this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));if(!this.reference.beacon)throw new Error("reference beacon must be set");return Promise.all([this.referencesPath.build(this.id,this.className,this.refProp,this.consistencyLevel),this.beaconPath.rebuild(this.reference.beacon)]).then(e=>{let r=e[0],s=e[1];return this.client.delete(r,{beacon:s},!1)})};this.referencesPath=r,this.beaconPath=s}withClassName(e){return this.className=e,this}};var Q=class extends n{constructor(e){super(e);this.withId=e=>(this.id=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.payload=()=>{if(this.validate(),this.errors.length>0)throw new Error(this.errors.join(", "));let e="weaviate://localhost";return o(this.className)&&(e=`${e}/${this.className}`),{beacon:`${e}/${this.id}`}}}withClassName(e){return this.className=e,this}do(){return Promise.reject(new Error("Should never be called"))}};var We="/objects",Ne=class{constructor(t){this.dbVersionSupport=t}buildCreate(t){return this.build({consistencyLevel:t},[this.addQueryParams])}buildDelete(t,e,r){return this.build({id:t,className:e,consistencyLevel:r},[this.addClassNameDeprecatedNotSupportedCheck,this.addId,this.addQueryParams])}buildCheck(t,e){return this.build({id:t,className:e},[this.addClassNameDeprecatedNotSupportedCheck,this.addId])}buildGetOne(t,e,r,s,a){return this.build({id:t,className:e,additional:r,consistencyLevel:s,nodeName:a},[this.addClassNameDeprecatedNotSupportedCheck,this.addId,this.addQueryParams])}buildGet(t,e,r,s){return this.build({className:t,limit:e,additional:r,after:s},[this.addQueryParamsForGet])}buildUpdate(t,e,r){return this.build({id:t,className:e,consistencyLevel:r},[this.addClassNameDeprecatedCheck,this.addId,this.addQueryParams])}buildMerge(t,e,r){return this.build({id:t,className:e,consistencyLevel:r},[this.addClassNameDeprecatedCheck,this.addId,this.addQueryParams])}build(t,e){return this.dbVersionSupport.supportsClassNameNamespacedEndpointsPromise().then(r=>{let s=We;return e.forEach(a=>{s=a(t,s,r)}),s})}addClassNameDeprecatedNotSupportedCheck(t,e,r){if(r.supports){if(o(t.className))return`${e}/${t.className}`;r.warns.deprecatedNonClassNameNamespacedEndpointsForObjects()}else r.warns.notSupportedClassNamespacedEndpointsForObjects();return e}addClassNameDeprecatedCheck(t,e,r){if(r.supports){if(o(t.className))return`${e}/${t.className}`;r.warns.deprecatedNonClassNameNamespacedEndpointsForObjects()}return e}addId(t,e){return o(t.id)?`${e}/${t.id}`:e}addQueryParams(t,e){let r=[];return Array.isArray(t.additional)&&t.additional.length>0&&r.push(`include=${t.additional.join(",")}`),o(t.nodeName)&&r.push(`node_name=${t.nodeName}`),o(t.consistencyLevel)&&r.push(`consistency_level=${t.consistencyLevel}`),r.length>0?`${e}?${r.join("&")}`:e}addQueryParamsForGet(t,e,r){let s=[];return Array.isArray(t.additional)&&t.additional.length>0&&s.push(`include=${t.additional.join(",")}`),typeof t.limit=="number"&&t.limit>0&&s.push(`limit=${t.limit}`),o(t.className)&&(r.supports?s.push(`class=${t.className}`):r.warns.notSupportedClassParameterInEndpointsForObjects()),o(t.after)&&s.push(`after=${t.after}`),s.length>0?`${e}?${s.join("&")}`:e}},Se=class{constructor(t){this.dbVersionSupport=t}build(t,e,r,s){return this.dbVersionSupport.supportsClassNameNamespacedEndpointsPromise().then(a=>{let h=We;return a.supports?o(e)?h=`${h}/${e}`:a.warns.deprecatedNonClassNameNamespacedEndpointsForReferences():a.warns.notSupportedClassNamespacedEndpointsForReferences(),o(t)&&(h=`${h}/${t}`),h=`${h}/references`,o(r)&&(h=`${h}/${r}`),o(s)&&(h=`${h}?consistency_level=${s}`),h})}};var gt="weaviate://localhost",ce=class{constructor(t){this.dbVersionSupport=t,this.beaconRegExp=/^weaviate:\/\/localhost(\/([^\\/]+))?(\/([^\\/]+))?[\\/]?$/gi}async rebuild(t){let e=await this.dbVersionSupport.supportsClassNameNamespacedEndpointsPromise(),r=new RegExp(this.beaconRegExp).exec(t);if(!r)return t;let s,a;r[4]!==void 0?(a=r[4],s=r[2]):a=r[2];let h=gt;return e.supports?o(s)?h=`${h}/${s}`:e.warns.deprecatedNonClassNameNamespacedEndpointsForBeacons():e.warns.notSupportedClassNamespacedEndpointsForBeacons(),o(a)&&(h=`${h}/${a}`),h}};var vt=(i,t)=>{let e=new Ne(t),r=new Se(t),s=new ce(t);return{creator:()=>new F(i,e),validator:()=>new G(i),updater:()=>new q(i,e),merger:()=>new _(i,e),getter:()=>new D(i,e),getterById:()=>new W(i,e),deleter:()=>new M(i,e),checker:()=>new U(i,e),referenceCreator:()=>new H(i,r,s),referenceReplacer:()=>new J(i,r,s),referenceDeleter:()=>new K(i,r,s),referencePayloadBuilder:()=>new Q(i)}},Me=vt;var g=class extends n{constructor(e){super(e);this.withId=e=>(this.id=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateId=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.validate=()=>{this.validateId()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/classifications/${this.id}`;return this.client.get(e)}}};var z=class extends n{constructor(e){super(e);this.withType=e=>(this.type=e,this);this.withSettings=e=>(this.settings=e,this);this.withClassName=e=>(this.className=e,this);this.withClassifyProperties=e=>(this.classifyProperties=e,this);this.withBasedOnProperties=e=>(this.basedOnProperties=e,this);this.withWaitForCompletion=()=>(this.waitForCompletion=!0,this);this.withWaitTimeout=e=>(this.waitTimeout=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateClassName=()=>{this.validateIsSet(this.className,"className",".withClassName(className)")};this.validateBasedOnProperties=()=>{this.validateIsSet(this.basedOnProperties,"basedOnProperties",".withBasedOnProperties(basedOnProperties)")};this.validateClassifyProperties=()=>{this.validateIsSet(this.classifyProperties,"classifyProperties",".withClassifyProperties(classifyProperties)")};this.validate=()=>{this.validateClassName(),this.validateClassifyProperties(),this.validateBasedOnProperties()};this.payload=()=>({type:this.type,settings:this.settings,class:this.className,classifyProperties:this.classifyProperties,basedOnProperties:this.basedOnProperties});this.pollForCompletion=e=>new Promise((r,s)=>{let a=setTimeout(()=>{clearInterval(h),clearTimeout(a),s(new Error("classification didn't finish within configured timeout, set larger timeout with .withWaitTimeout(timeout)"))},this.waitTimeout),h=setInterval(()=>{new g(this.client).withId(e).do().then(c=>{c.status==="completed"&&(clearInterval(h),clearTimeout(a),r(c))})},500)});this.do=()=>{if(this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));this.validate();let e="/classifications";return this.client.post(e,this.payload()).then(r=>this.waitForCompletion?this.pollForCompletion(r.id):Promise.resolve(r))};this.waitTimeout=10*60*1e3,this.waitForCompletion=!1}};var yt=i=>({scheduler:()=>new z(i),getter:()=>new g(i)}),Ue=yt;function xe(i){return Je("/batch/objects",i)}function He(i){return Je("/batch/references",i)}function Je(i,t){return t&&t.toString()!=""&&(i=`${i}?${t.toString()}`),i}var Y=class extends n{constructor(e){super(e);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>({objects:this.objects});this.validateObjectCount=()=>{this.objects.length==0&&this.addError("need at least one object to send a request, add one with .withObject(obj)")};this.validate=()=>{this.validateObjectCount()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=new URLSearchParams;this.consistencyLevel&&e.set("consistency_level",this.consistencyLevel);let r=xe(e);return this.client.post(r,this.payload())};this.objects=[]}withObjects(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.objects=[...this.objects,...r],this}withObject(e){return this.withObjects(e)}};var X=class extends n{constructor(e){super(e);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>({match:{class:this.className,where:this.whereFilter},output:this.output,dryRun:this.dryRun});this.validateClassName=()=>{o(this.className)||this.addError("string className must be set - set with .withClassName(className)")};this.validateWhereFilter=()=>{typeof this.whereFilter!="object"&&this.addError("object where must be set - set with .withWhere(whereFilter)")};this.validate=()=>{this.validateClassName(),this.validateWhereFilter()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=new URLSearchParams;this.consistencyLevel&&e.set("consistency_level",this.consistencyLevel);let r=xe(e);return this.client.delete(r,this.payload(),!0)}}withClassName(e){return this.className=e,this}withWhere(e){return this.whereFilter=e,this}withOutput(e){return this.output=e,this}withDryRun(e){return this.dryRun=e,this}};var Z=class extends n{constructor(e,r){super(e);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>this.references;this.validateReferenceCount=()=>{this.references.length==0&&this.addError("need at least one reference to send a request, add one with .withReference(obj)")};this.validate=()=>{this.validateReferenceCount()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=new URLSearchParams;this.consistencyLevel&&e.set("consistency_level",this.consistencyLevel);let r=He(e);return Promise.all(this.references.map(a=>this.rebuildReferencePromise(a))).then(a=>this.client.post(r,a))};this.rebuildReferencePromise=e=>this.beaconPath.rebuild(e.to).then(r=>({from:e.from,to:r}));this.beaconPath=r,this.references=[]}withReferences(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.references=[...this.references,...r],this}withReference(e){return this.withReferences(e)}};var we=class extends n{constructor(e){super(e);this.withFromId=e=>(this.fromId=e,this);this.withToId=e=>(this.toId=e,this);this.withFromClassName=e=>(this.fromClassName=e,this);this.withFromRefProp=e=>(this.fromRefProp=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.fromId,"fromId",".withFromId(id)"),this.validateIsSet(this.toId,"toId",".withToId(id)"),this.validateIsSet(this.fromClassName,"fromClassName",".withFromClassName(className)"),this.validateIsSet(this.fromRefProp,"fromRefProp",".withFromRefProp(refProp)")};this.payload=()=>{if(this.validate(),this.errors.length>0)throw new Error(this.errors.join(", "));let e="weaviate://localhost";return o(this.toClassName)&&(e=`${e}/${this.toClassName}`),{from:`weaviate://localhost/${this.fromClassName}/${this.fromId}/${this.fromRefProp}`,to:`${e}/${this.toId}`}};this.do=()=>Promise.reject(new Error("Should never be called"))}withToClassName(e){return this.toClassName=e,this}};var wt=(i,t)=>{let e=new ce(t);return{objectsBatcher:()=>new Y(i),objectsBatchDeleter:()=>new X(i),referencesBatcher:()=>new Z(i,e),referencePayloadBuilder:()=>new we(i)}},Ke=wt;var ee=class extends n{constructor(e,r){super(e);this.do=()=>this.client.get("/.well-known/live",!1).then(()=>(setTimeout(()=>this.dbVersionProvider.refresh()),Promise.resolve(!0))).catch(()=>Promise.resolve(!1));this.dbVersionProvider=r}validate(){}};var te=class extends n{constructor(e,r){super(e);this.do=()=>this.client.get("/.well-known/ready",!1).then(()=>(setTimeout(()=>this.dbVersionProvider.refresh()),Promise.resolve(!0))).catch(()=>Promise.resolve(!1));this.dbVersionProvider=r}validate(){}};var v=class extends n{constructor(e){super(e);this.do=()=>this.client.get("/meta",!0)}validate(){}};var Ct=(i,t)=>({liveChecker:()=>new ee(i,t),readyChecker:()=>new te(i,t),metaGetter:()=>new v(i),openidConfigurationGetter:()=>new l(i.http)}),Qe=Ct;var re=class extends n{constructor(e){super(e);this.withConcept=e=>(this.concept=e,this);this.withDefinition=e=>(this.definition=e,this);this.withWeight=e=>(this.weight=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.concept,"concept","withConcept(concept)"),this.validateIsSet(this.definition,"definition","withDefinition(definition)"),this.validateIsSet(this.weight?.toString()||"","weight","withWeight(weight)")};this.payload=()=>({concept:this.concept,definition:this.definition,weight:this.weight});this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/modules/text2vec-contextionary/extensions";return this.client.post(e,this.payload())}}};var ie=class extends n{constructor(e){super(e);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.withConcept=e=>(this.concept=e,this);this.validate=()=>{this.validateIsSet(this.concept,"concept","withConcept(concept)")};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/modules/text2vec-contextionary/concepts/${this.concept}`;return this.client.get(e)}}};var bt=i=>({conceptsGetter:()=>new ie(i),extensionCreator:()=>new re(i)}),ze=bt;var ke=class{constructor(t){this.dbVersionProvider=t}supportsClassNameNamespacedEndpointsPromise(){return this.dbVersionProvider.getVersionPromise().then(t=>({version:t,supports:this.supportsClassNameNamespacedEndpoints(t),warns:{deprecatedNonClassNameNamespacedEndpointsForObjects:()=>console.warn(`Usage of objects paths without className is deprecated in Weaviate ${t}. Please provide className parameter`),deprecatedNonClassNameNamespacedEndpointsForReferences:()=>console.warn(`Usage of references paths without className is deprecated in Weaviate ${t}. Please provide className parameter`),deprecatedNonClassNameNamespacedEndpointsForBeacons:()=>console.warn(`Usage of beacons paths without className is deprecated in Weaviate ${t}. Please provide className parameter`),notSupportedClassNamespacedEndpointsForObjects:()=>console.warn(`Usage of objects paths with className is not supported in Weaviate ${t}. className parameter is ignored`),notSupportedClassNamespacedEndpointsForReferences:()=>console.warn(`Usage of references paths with className is not supported in Weaviate ${t}. className parameter is ignored`),notSupportedClassNamespacedEndpointsForBeacons:()=>console.warn(`Usage of beacons paths with className is not supported in Weaviate ${t}. className parameter is ignored`),notSupportedClassParameterInEndpointsForObjects:()=>console.warn(`Usage of objects paths with class query parameter is not supported in Weaviate ${t}. class query parameter is ignored`)}}))}supportsClassNameNamespacedEndpoints(t){if(typeof t=="string"){let e=t.split(".");if(e.length>=2){let r=parseInt(e[0],10),s=parseInt(e[1],10);return r==1&&s>=14||r>=2}}return!1}},Ye="",je=class{constructor(t){this.versionGetter=t,this.emptyVersionPromise=Promise.resolve(Ye),this.versionPromise=void 0}getVersionPromise(){return this.versionPromise?this.versionPromise:this.versionGetter().then(t=>this.assignPromise(t))}refresh(t=!1){return t||!this.versionPromise?(this.versionPromise=void 0,this.versionGetter().then(e=>this.assignPromise(e)).then(()=>Promise.resolve(!0))):Promise.resolve(!1)}assignPromise(t){return t===Ye?this.emptyVersionPromise:(this.versionPromise=Promise.resolve(t),this.versionPromise)}};function Ae(i){if(Array.isArray(i)){let t=[];return i.forEach(e=>{o(e)||t.push("string className invalid - set with .withIncludeClassNames(...classNames)")}),t}return i!=null?["strings classNames invalid - set with .withIncludeClassNames(...classNames)"]:[]}function Ee(i){if(Array.isArray(i)){let t=[];return i.forEach(e=>{o(e)||t.push("string className invalid - set with .withExcludeClassNames(...classNames)")}),t}return i!=null?["strings classNames invalid - set with .withExcludeClassNames(...classNames)"]:[]}function w(i){return o(i)?[]:["string backend must set - set with .withBackend(backend)"]}function C(i){return o(i)?[]:["string backupId must be set - set with .withBackupId(backupId)"]}var Pt=1e3,se=class extends n{constructor(e,r){super(e);this.validate=()=>{this.addErrors([...Ae(this.includeClassNames),...Ee(this.excludeClassNames),...w(this.backend),...C(this.backupId)])};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e={id:this.backupId,config:{},include:this.includeClassNames,exclude:this.excludeClassNames};return this.waitForCompletion?this._createAndWaitForCompletion(e):this._create(e)};this._create=e=>this.client.post(this._path(),e);this._createAndWaitForCompletion=e=>new Promise((r,s)=>{this._create(e).then(a=>{this.statusGetter.withBackend(this.backend).withBackupId(this.backupId);let h=()=>{this.statusGetter.do().then(c=>{c.status=="SUCCESS"||c.status=="FAILED"?r(this._merge(c,a)):setTimeout(h,Pt)}).catch(s)};h()}).catch(s)});this._path=()=>`/backups/${this.backend}`;this._merge=(e,r)=>{let s={};return"id"in e&&(s.id=e.id),"path"in e&&(s.path=e.path),"backend"in e&&(s.backend=e.backend),"status"in e&&(s.status=e.status),"error"in e&&(s.error=e.error),"classes"in r&&(s.classes=r.classes),s};this.statusGetter=r}withIncludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.includeClassNames=r,this}withExcludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.excludeClassNames=r,this}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}withWaitForCompletion(e){return this.waitForCompletion=e,this}};var b=class extends n{constructor(e){super(e);this.validate=()=>{this.addErrors([...w(this.backend),...C(this.backupId)])};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.client.get(this._path()));this._path=()=>`/backups/${this.backend}/${this.backupId}`}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}};var Nt=1e3,ne=class extends n{constructor(e,r){super(e);this.validate=()=>{this.addErrors([...Ae(this.includeClassNames||[]),...Ee(this.excludeClassNames||[]),...w(this.backend),...C(this.backupId)])};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e={config:{},include:this.includeClassNames,exclude:this.excludeClassNames};return this.waitForCompletion?this._restoreAndWaitForCompletion(e):this._restore(e)};this._restore=e=>this.client.post(this._path(),e);this._restoreAndWaitForCompletion=e=>new Promise((r,s)=>{this._restore(e).then(a=>{this.statusGetter.withBackend(this.backend).withBackupId(this.backupId);let h=()=>{this.statusGetter.do().then(c=>{c.status=="SUCCESS"||c.status=="FAILED"?r(this._merge(c,a)):setTimeout(h,Nt)}).catch(s)};h()}).catch(s)});this._path=()=>`/backups/${this.backend}/${this.backupId}/restore`;this._merge=(e,r)=>{let s={};return"id"in e&&(s.id=e.id),"path"in e&&(s.path=e.path),"backend"in e&&(s.backend=e.backend),"status"in e&&(s.status=e.status),"error"in e&&(s.error=e.error),"classes"in r&&(s.classes=r.classes),s};this.statusGetter=r}withIncludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.includeClassNames=r,this}withExcludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.excludeClassNames=r,this}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}withWaitForCompletion(e){return this.waitForCompletion=e,this}};var P=class extends n{constructor(e){super(e);this.validate=()=>{this.addErrors([...w(this.backend),...C(this.backupId)])};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.client.get(this._path()));this._path=()=>`/backups/${this.backend}/${this.backupId}/restore`}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}};var St=i=>({creator:()=>new se(i,new b(i)),createStatusGetter:()=>new b(i),restorer:()=>new ne(i,new P(i)),restoreStatusGetter:()=>new P(i)}),Xe=St;var ae=class extends n{constructor(t){super(t)}validate(){}do(){return this.client.get("/nodes")}};var xt=i=>({nodesStatusGetter:()=>new ae(i)}),Ze=xt;var et={client:function(i){if(!i.host)throw new Error("Missing `host` parameter");if(!i.scheme)throw new Error("Missing `scheme` parameter");i.headers||(i.headers={});let t=new pe(i),e=kt(t),r=new ke(e),s={graphql:_e(t),schema:De(t),data:Me(t,r),classifications:Ue(t),batch:Ke(t,r),misc:Qe(t,e),c11y:ze(t),backup:Xe(t),cluster:Ze(t)};return t.oidcAuth&&(s.oidcAuth=t.oidcAuth),s},ApiKey:le,AuthUserPasswordCredentials:oe,AuthAccessTokenCredentials:N,AuthClientCredentials:he};function kt(i){let t=new v(i),e=()=>t.do().then(s=>s.version).catch(()=>Promise.resolve("")),r=new je(e);return r.refresh(),r}module.exports=et;var jt=et; | ||
//# sourceMappingURL=index.js.map | ||
"use strict";var et=Object.create;var Ce=Object.defineProperty;var tt=Object.getOwnPropertyDescriptor;var rt=Object.getOwnPropertyNames;var it=Object.getPrototypeOf,st=Object.prototype.hasOwnProperty;var nt=(i,t)=>{for(var e in t)Ce(i,e,{get:t[e],enumerable:!0})},Le=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of rt(t))!st.call(i,s)&&s!==e&&Ce(i,s,{get:()=>t[s],enumerable:!(r=tt(t,s))||r.enumerable});return i};var at=(i,t,e)=>(e=i!=null?et(it(i)):{},Le(t||!i||!i.__esModule?Ce(e,"default",{value:i,enumerable:!0}):e,i)),ot=i=>Le(Ce({},"__esModule",{value:!0}),i);var At={};nt(At,{Aggregator:()=>x,ApiKey:()=>le,AuthAccessTokenCredentials:()=>N,AuthClientCredentials:()=>he,AuthUserPasswordCredentials:()=>oe,BackupCreateStatusGetter:()=>b,BackupCreator:()=>se,BackupRestoreStatusGetter:()=>P,BackupRestorer:()=>ne,Checker:()=>U,ClassCreator:()=>B,ClassDeleter:()=>I,ClassGetter:()=>R,ClassificationsGetter:()=>g,ClassificationsScheduler:()=>z,ConceptsGetter:()=>ie,Creator:()=>F,Deleter:()=>M,Explorer:()=>E,ExtensionCreator:()=>re,Getter:()=>D,GetterById:()=>W,GraphQLGetter:()=>A,LiveChecker:()=>ee,Merger:()=>_,MetaGetter:()=>v,NodesStatusGetter:()=>ae,ObjectsBatchDeleter:()=>X,ObjectsBatcher:()=>Y,OidcAuthenticator:()=>de,OpenidConfigurationGetter:()=>l,PropertyCreator:()=>T,Raw:()=>$,ReadyChecker:()=>te,ReferenceCreator:()=>H,ReferenceDeleter:()=>K,ReferencePayloadBuilder:()=>Q,ReferenceReplacer:()=>J,ReferencesBatcher:()=>Z,SchemaGetter:()=>O,ShardUpdater:()=>L,ShardsUpdater:()=>V,Updater:()=>q,Validator:()=>G,default:()=>jt});module.exports=ot(At);var de=class{constructor(t,e){this.refresh=async t=>{let e=await this.getOpenidConfig(t),r;switch(this.creds.constructor){case oe:r=new $e(this.http,this.creds,e);break;case N:r=new Be(this.http,this.creds,e);break;case he:r=new Ie(this.http,this.creds,e);break;default:throw new Error("unsupported credential type")}return r.refresh().then(s=>{this.accessToken=s.accessToken,this.expiresAt=s.expiresAt,this.refreshToken=s.refreshToken,this.startTokenRefresh(r)})};this.getOpenidConfig=t=>this.http.externalGet(t.href).then(e=>{let r=t.scopes||[];return{clientId:t.clientId,provider:e,scopes:r}});this.startTokenRefresh=t=>{this.creds.silentRefresh&&!this.refreshRunning&&this.refreshTokenProvided()&&(this.refreshInterval=setInterval(async()=>{if(this.expiresAt-Date.now()<=6e4){let e=await t.refresh();this.accessToken=e.accessToken,this.expiresAt=e.expiresAt,this.refreshToken=e.refreshToken}},3e4),this.refreshRunning=!0)};this.stopTokenRefresh=()=>{clearInterval(this.refreshInterval),this.refreshRunning=!1};this.refreshTokenProvided=()=>this.refreshToken&&this.refreshToken!="";this.getAccessToken=()=>this.accessToken;this.getExpiresAt=()=>this.expiresAt;this.http=t,this.creds=e,this.accessToken="",this.refreshToken="",this.expiresAt=0,this.refreshRunning=!1,this.creds instanceof N&&(this.accessToken=this.creds.accessToken,this.expiresAt=this.creds.expiresAt,this.refreshToken=this.creds.refreshToken)}resetExpiresAt(){this.expiresAt=0}},oe=class{constructor(t){this.username=t.username,this.password=t.password,this.scopes=t.scopes,this.silentRefresh=Re(t.silentRefresh)}},$e=class{constructor(t,e,r){this.refresh=()=>(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:be(t.expires_in),refreshToken:t.refresh_token})).catch(t=>Promise.reject(new Error(`failed to refresh access token: ${t}`))));this.validateOpenidConfig=()=>{if(this.openidConfig.provider.grant_types_supported!==void 0&&!this.openidConfig.provider.grant_types_supported.includes("password"))throw new Error("grant_type password not supported");if(this.openidConfig.provider.token_endpoint.includes("https://login.microsoftonline.com"))throw new Error("microsoft/azure recommends to avoid authentication using username and password, so this method is not supported by this client");this.openidConfig.scopes.push("offline_access")};this.requestAccessToken=()=>{let t=this.openidConfig.provider.token_endpoint,e=new URLSearchParams({grant_type:"password",client_id:this.openidConfig.clientId,username:this.creds.username,password:this.creds.password,scope:this.openidConfig.scopes.join(" ")}),r="application/x-www-form-urlencoded;charset=UTF-8";return this.http.externalPost(t,e,r)};this.http=t,this.creds=e,this.openidConfig=r,e.scopes&&this.openidConfig.scopes.push(e.scopes)}},N=class{constructor(t){this.validate=t=>{if(t.expiresIn===void 0)throw new Error("AuthAccessTokenCredentials: expiresIn is required");if(!Number.isInteger(t.expiresIn)||t.expiresIn<=0)throw new Error("AuthAccessTokenCredentials: expiresIn must be int > 0")};this.validate(t),this.accessToken=t.accessToken,this.expiresAt=be(t.expiresIn),this.refreshToken=t.refreshToken,this.silentRefresh=Re(t.silentRefresh)}},Be=class{constructor(t,e,r){this.refresh=()=>this.creds.refreshToken===void 0||this.creds.refreshToken==""?(console.warn("AuthAccessTokenCredentials not provided with refreshToken, cannot refresh"),Promise.resolve({accessToken:this.creds.accessToken,expiresAt:this.creds.expiresAt})):(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:be(t.expires_in),refreshToken:t.refresh_token})).catch(t=>Promise.reject(new Error(`failed to refresh access token: ${t}`))));this.validateOpenidConfig=()=>{if(this.openidConfig.provider.grant_types_supported===void 0||!this.openidConfig.provider.grant_types_supported.includes("refresh_token"))throw new Error("grant_type refresh_token not supported")};this.requestAccessToken=()=>{let t=this.openidConfig.provider.token_endpoint,e=new URLSearchParams({grant_type:"refresh_token",client_id:this.openidConfig.clientId,refresh_token:this.creds.refreshToken}),r="application/x-www-form-urlencoded;charset=UTF-8";return this.http.externalPost(t,e,r)};this.http=t,this.creds=e,this.openidConfig=r}},he=class{constructor(t){this.clientSecret=t.clientSecret,this.scopes=t.scopes,this.silentRefresh=Re(t.silentRefresh)}},Ie=class{constructor(t,e,r){this.refresh=()=>(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:be(t.expires_in),refreshToken:t.refresh_token})).catch(t=>Promise.reject(new Error(`failed to refresh access token: ${t}`))));this.validateOpenidConfig=()=>{this.openidConfig.scopes.length>0||this.openidConfig.provider.token_endpoint.includes("https://login.microsoftonline.com")&&this.openidConfig.scopes.push(this.openidConfig.clientId+"/.default")};this.requestAccessToken=()=>{let t=this.openidConfig.provider.token_endpoint,e=new URLSearchParams({grant_type:"client_credentials",client_id:this.openidConfig.clientId,client_secret:this.creds.clientSecret,scope:this.openidConfig.scopes.join(" ")}),r="application/x-www-form-urlencoded;charset=UTF-8";return this.http.externalPost(t,e,r)};this.http=t,this.creds=e,this.openidConfig=r,e.scopes&&this.openidConfig.scopes.push(e.scopes)}},le=class{constructor(t){this.apiKey=t}};function be(i){return Date.now()+(i-2)*1e3}function Re(i){return i===void 0?!0:i}var l=class{constructor(t){this.do=()=>this.client.getRaw("/.well-known/openid-configuration").then(t=>t.status<400?t.json():t.status==404?Promise.resolve(void 0):Promise.reject(new Error(`unexpected status code: ${t.status}`)));this.client=t}};var d=at(require("isomorphic-fetch")),ht=i=>{let t=`${i.scheme}://${i.host}/v1`,e=ct(t);return{post:(r,s,a=!0,h="")=>{let c={method:"POST",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(s)};return S(c,h),(0,d.default)(e(r),c).then(y(a))},put:(r,s,a=!0,h="")=>{let c={method:"PUT",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(s)};return S(c,h),(0,d.default)(e(r),c).then(y(a))},patch:(r,s,a="")=>{let h={method:"PATCH",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(s)};return S(h,a),(0,d.default)(e(r),h).then(y(!1))},delete:(r,s,a=!1,h="")=>{let c={method:"DELETE",headers:{...i.headers,"content-type":"application/json"},body:s?JSON.stringify(s):void 0};return S(c,h),(0,d.default)(e(r),c).then(y(a))},head:(r,s,a="")=>{let h={method:"HEAD",headers:{...i.headers,"content-type":"application/json"},body:s?JSON.stringify(s):void 0};return S(h,a),(0,d.default)(e(r),h).then(dt(!1))},get:(r,s=!0,a="")=>{let h={method:"GET",headers:{...i.headers}};return S(h,a),(0,d.default)(e(r),h).then(y(s))},getRaw:(r,s="")=>{let a={method:"GET",headers:{...i.headers}};return S(a,s),(0,d.default)(e(r),a)},externalGet:r=>(0,d.default)(r,{method:"GET",headers:{...i.headers}}).then(y(!0)),externalPost:(r,s,a)=>{(a==null||a=="")&&(a="application/json");let h={body:void 0,method:"POST",headers:{...i.headers,"content-type":a}};return s!=null&&(h.body=s),(0,d.default)(r,h).then(y(!0))}}},ct=i=>t=>i+t,y=i=>t=>{if(t.status>=400)return t.text().then(e=>{let r;try{r=JSON.stringify(JSON.parse(e))}catch{r=e}return Promise.reject(new Error(`usage error (${t.status}): ${r}`))});if(i)return t.json()},dt=i=>t=>t.status==204||t.status==404?t.status==204:y(i);function S(i,t){t!==""&&(i.headers.Authorization=`Bearer ${t}`)}var Ve=ht;var Fe=require("graphql-request"),lt=i=>{let t=i.scheme,e=i.host,r=i.headers;return{query:(s,a,h)=>new Fe.GraphQLClient(`${t}://${e}/v1/graphql`,{headers:{...r,...h}}).request(s,a,h).then(c=>({data:c}))}},Ge=lt;var pe=class{constructor(t){this.post=(t,e,r=!0)=>this.authEnabled?this.login().then(s=>this.http.post(t,e,r,s)):this.http.post(t,e,r);this.put=(t,e,r=!0)=>this.authEnabled?this.login().then(s=>this.http.put(t,e,r,s)):this.http.put(t,e,r);this.patch=(t,e)=>this.authEnabled?this.login().then(r=>this.http.patch(t,e,r)):this.http.patch(t,e);this.delete=(t,e,r=!1)=>this.authEnabled?this.login().then(s=>this.http.delete(t,e,r,s)):this.http.delete(t,e,r);this.head=(t,e)=>this.authEnabled?this.login().then(r=>this.http.head(t,e,r)):this.http.head(t,e);this.get=(t,e=!0)=>this.authEnabled?this.login().then(r=>this.http.get(t,e,r)):this.http.get(t,e);this.query=(t,e)=>this.authEnabled?this.login().then(r=>{let s={Authorization:`Bearer ${r}`};return this.gql.query(t,e,s)}):this.gql.query(t,e);this.login=async()=>{if(this.apiKey)return this.apiKey;if(!this.oidcAuth)return"";let t=await new l(this.http).do();return t===void 0?(console.warn("client is configured for authentication, but server is not"),""):(Date.now()>=this.oidcAuth.getExpiresAt()&&await this.oidcAuth.refresh(t),this.oidcAuth.getAccessToken())};t=this.sanitizeParams(t),this.http=Ve(t),this.gql=Ge(t),this.authEnabled=this.parseAuthParams(t)}parseAuthParams(t){if(t.authClientSecret&&t.apiKey)throw new Error("must provide one of authClientSecret (OIDC) or apiKey, cannot provide both");return t.authClientSecret?(this.oidcAuth=new de(this.http,t.authClientSecret),!0):t.apiKey?(this.apiKey=t.apiKey?.apiKey,!0):!1}sanitizeParams(t){for(;t.host.endsWith("/");)t.host=t.host.slice(0,-1);return t}};var p=class{constructor(t){this.source=t}toString(){if(this.parse(),this.validate(),this.operands)return`{operator:${this.operator},operands:[${this.operands}]}`;{let t=this.marshalValueContent();return`{operator:${this.operator},${this.valueType}:${t},path:${JSON.stringify(this.path)}}`}}marshalValueContent(){return this.valueType=="valueGeoRange"?this.marshalValueGeoRange():JSON.stringify(this.valueContent)}marshalValueGeoRange(){let t=[],e=this.valueContent.geoCoordinates;if(e){let s=[];e.latitude&&(s=[...s,`latitude:${e.latitude}`]),e.longitude&&(s=[...s,`longitude:${e.longitude}`]),t=[...t,`geoCoordinates:{${s.join(",")}}`]}let r=this.valueContent.distance;if(r){let s=[];r.max&&(s=[...s,`max:${r.max}`]),t=[...t,`distance:{${s.join(",")}}`]}return`{${t.join(",")}}`}validate(){if(!this.operator)throw new Error("where filter: operator cannot be empty");if(!this.operands){if(!this.valueType)throw new Error("where filter: value<Type> cannot be empty");if(!this.path)throw new Error("where filter: path cannot be empty")}}parse(){for(let t in this.source)switch(t){case"operator":this.parseOperator(this.source[t]);break;case"operands":this.parseOperands(this.source[t]);break;case"path":this.parsePath(this.source[t]);break;default:if(t.indexOf("value")!=0)throw new Error("where filter: unrecognized key '"+t+"'");this.parseValue(t,this.source[t])}}parseOperator(t){if(typeof t!="string")throw new Error("where filter: operator must be a string");this.operator=t}parsePath(t){if(!Array.isArray(t))throw new Error("where filter: path must be an array");this.path=t}parseValue(t,e){switch(t){case"valueString":case"valueText":case"valueInt":case"valueNumber":case"valueDate":case"valueBoolean":case"valueGeoRange":break;default:throw new Error("where filter: unrecognized value prop '"+t+"'")}this.valueType=t,this.valueContent=e}parseOperands(t){if(!Array.isArray(t))throw new Error("where filter: operands must be an array");this.operands=t.map(e=>new p(e).toString()).join(",")}};var u=class{constructor(t){this.autocorrect=t.autocorrect,this.certainty=t.certainty,this.concepts=t.concepts,this.distance=t.distance,this.moveAwayFrom=t.moveAwayFrom,this.moveTo=t.moveTo}toString(){this.validate();let t=[`concepts:${JSON.stringify(this.concepts)}`];if(this.certainty&&(t=[...t,`certainty:${this.certainty}`]),this.distance&&(t=[...t,`distance:${this.distance}`]),this.moveTo){let e=[];this.moveTo.concepts&&(e=[...e,`concepts:${JSON.stringify(this.moveTo.concepts)}`]),this.moveTo.objects&&(e=[...e,`objects:${this.parseMoveObjects("moveTo",this.moveTo.objects)}`]),this.moveTo.force&&(e=[...e,`force:${this.moveTo.force}`]),t=[...t,`moveTo:{${e.join(",")}}`]}if(this.moveAwayFrom){let e=[];this.moveAwayFrom.concepts&&(e=[...e,`concepts:${JSON.stringify(this.moveAwayFrom.concepts)}`]),this.moveAwayFrom.objects&&(e=[...e,`objects:${this.parseMoveObjects("moveAwayFrom",this.moveAwayFrom.objects)}`]),this.moveAwayFrom.force&&(e=[...e,`force:${this.moveAwayFrom.force}`]),t=[...t,`moveAwayFrom:{${e.join(",")}}`]}return this.autocorrect!==void 0&&(t=[...t,`autocorrect:${this.autocorrect}`]),`{${t.join(",")}}`}validate(){if(this.moveTo){if(!this.moveTo.concepts&&!this.moveTo.objects)throw new Error("nearText filter: moveTo.concepts or moveTo.objects must be present");if(!this.moveTo.force||!this.moveTo.concepts&&!this.moveTo.objects)throw new Error("nearText filter: moveTo must have fields 'concepts' or 'objects' and 'force'")}if(this.moveAwayFrom){if(!this.moveAwayFrom.concepts&&!this.moveAwayFrom.objects)throw new Error("nearText filter: moveAwayFrom.concepts or moveAwayFrom.objects must be present");if(!this.moveAwayFrom.force||!this.moveAwayFrom.concepts&&!this.moveAwayFrom.objects)throw new Error("nearText filter: moveAwayFrom must have fields 'concepts' or 'objects' and 'force'")}}parseMoveObjects(t,e){let r=[];for(let s in e){if(!e[s].id&&!e[s].beacon)throw new Error(`nearText: ${t}.objects[${s}].id or ${t}.objects[${s}].beacon must be present`);let a=[];e[s].id&&a.push(`id:"${e[s].id}"`),e[s].beacon&&a.push(`beacon:"${e[s].beacon}"`),r.push(`{${a.join(",")}}`)}return`[${r.join(",")}]`}};var m=class{constructor(t){this.certainty=t.certainty,this.distance=t.distance,this.vector=t.vector}toString(t=!0){let e=[`vector:${JSON.stringify(this.vector)}`];return this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}};var f=class{constructor(t){this.beacon=t.beacon,this.certainty=t.certainty,this.distance=t.distance,this.id=t.id}toString(t=!0){this.validate();let e=[];return this.id&&(e=[...e,`id:${JSON.stringify(this.id)}`]),this.beacon&&(e=[...e,`beacon:${JSON.stringify(this.beacon)}`]),this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.id&&!this.beacon)throw new Error("nearObject filter: id or beacon needs to be set")}};function pt(i){return Number.isInteger(i)}function qe(i){return pt(i)&&i>=0}var n=class{constructor(t){this.client=t,this._errors=[]}get errors(){return this._errors}addError(t){this._errors=[...this.errors,t]}addErrors(t){this._errors=[...this.errors,...t]}};var x=class extends n{constructor(e){super(e);this.withFields=e=>(this.fields=e,this);this.withClassName=e=>(this.className=e,this);this.withWhere=e=>{try{this.whereString=new p(e).toString()}catch(r){this.addError(r)}return this};this.withNearText=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearTextString=new u(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearObject=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearObjectString=new f(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearVector=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearVectorString=new m(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withObjectLimit=e=>{if(!qe(e))throw new Error("objectLimit must be a non-negative integer");return this.objectLimit=e,this};this.withLimit=e=>(this.limit=e,this);this.withGroupBy=e=>(this.groupBy=e,this);this.validateGroup=()=>{if(this.groupBy&&!Array.isArray(this.groupBy))throw new Error("groupBy must be an array")};this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateGroup(),this.validateIsSet(this.className,"className",".withClassName(className)"),this.validateIsSet(this.fields,"fields",".withFields(fields)")};this.do=()=>{let e="";if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));if(this.whereString||this.nearTextString||this.nearObjectString||this.nearVectorString||this.limit||this.groupBy){let r=[];this.whereString&&(r=[...r,`where:${this.whereString}`]),this.nearTextString&&(r=[...r,`nearText:${this.nearTextString}`]),this.nearObjectString&&(r=[...r,`nearObject:${this.nearObjectString}`]),this.nearVectorString&&(r=[...r,`nearVector:${this.nearVectorString}`]),this.groupBy&&(r=[...r,`groupBy:${JSON.stringify(this.groupBy)}`]),this.limit&&(r=[...r,`limit:${this.limit}`]),this.objectLimit&&(r=[...r,`objectLimit:${this.objectLimit}`]),e=`(${r.join(",")})`}return this.client.query(`{Aggregate{${this.className}${e}{${this.fields}}}}`)};this.includesNearMediaFilter=!1}};var ue=class{constructor(t){this.properties=t.properties,this.query=t.query}toString(){let t=[`query:${JSON.stringify(this.query)}`];return this.properties!==void 0&&(t=[...t,`properties:${JSON.stringify(this.properties)}`]),`{${t.join(",")}}`}};var me=class{constructor(t){this.alpha=t.alpha,this.query=t.query,this.vector=t.vector}toString(){let t=[`query:${JSON.stringify(this.query)}`];return this.alpha!==void 0&&(t=[...t,`alpha:${JSON.stringify(this.alpha)}`]),this.vector!==void 0&&(t=[...t,`vector:${JSON.stringify(this.vector)}`]),`{${t.join(",")}}`}};var k=class{constructor(t){this.certainty=t.certainty,this.distance=t.distance,this.image=t.image}toString(t=!0){this.validate();let e=[];if(this.image){let r=this.image;if(r.startsWith("data:")){let s=";base64,";r=r.substring(r.indexOf(s)+s.length)}e=[...e,`image:${JSON.stringify(r)}`]}return this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.image)throw new Error("nearImage filter: image field must be present")}};var j=class{constructor(t){this.autocorrect=t.autocorrect,this.certainty=t.certainty,this.distance=t.distance,this.properties=t.properties,this.question=t.question,this.rerank=t.rerank}toString(t=!0){this.validate();let e=[];return this.question&&(e=[...e,`question:${JSON.stringify(this.question)}`]),this.properties&&(e=[...e,`properties:${JSON.stringify(this.properties)}`]),this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),this.autocorrect!==void 0&&(e=[...e,`autocorrect:${this.autocorrect}`]),this.rerank!==void 0&&(e=[...e,`rerank:${this.rerank}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.question)throw new Error("ask filter: question needs to be set")}};var fe=class{constructor(t){this.args=t}toString(){let t=[];return this.args.type&&(t=[...t,`type:${this.args.type}`]),this.args.force&&(t=[...t,`force:${this.args.force}`]),`{${t.join(",")}}`}};var ge=class{constructor(t){this.args=t}toString(){let t=[];for(let e of this.args){let r=`{path:${JSON.stringify(e.path)}`;e.order?r=r.concat(`,order:${e.order}}`):r=r.concat("}"),t.push(r)}return t.join(",")}};var Pe=class{constructor(t){this.groupedTask=t.groupedTask,this.singlePrompt=t.singlePrompt}toString(){this.validate();let t="generate(",e=["error"];return this.singlePrompt&&(t+=`singleResult:{prompt:"${this.singlePrompt.replace(/[\n\r]+/g,"")}"}`,e.push("singleResult")),this.groupedTask&&(t+=`groupedResult:{task:"${this.groupedTask.replace(/[\n\r]+/g,"")}"}`,e.push("groupedResult")),t+=`){${e.join(" ")}}`,t}validate(){if(!this.groupedTask&&!this.singlePrompt)throw new Error("must provide at least one of `singlePrompt` or `groupTask`");if(this.groupedTask!==void 0&&this.groupedTask=="")throw new Error("groupedTask must not be empty");if(this.singlePrompt!==void 0&&this.singlePrompt=="")throw new Error("singlePrompt must not be empty")}};var ve=class{constructor(t){this.args=t}toString(){let t=[];return this.args.path&&(t=[...t,`path:${JSON.stringify(this.args.path)}`]),this.args.groups&&(t=[...t,`groups:${this.args.groups}`]),this.args.objectsPerGroup&&(t=[...t,`objectsPerGroup:${this.args.objectsPerGroup}`]),`{${t.join(",")}}`}};var A=class extends n{constructor(e){super(e);this.withFields=e=>(this.fields=e,this);this.withClassName=e=>(this.className=e,this);this.withAfter=e=>(this.after=e,this);this.withGroup=e=>{try{this.groupString=new fe(e).toString()}catch(r){this.addError(r.toString())}return this};this.withWhere=e=>{try{this.whereString=new p(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearText=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");return this.nearTextString=new u(e).toString(),this.includesNearMediaFilter=!0,this};this.withBm25=e=>{try{this.bm25String=new ue(e).toString()}catch(r){this.addError(r.toString())}return this};this.withHybrid=e=>{try{this.hybridString=new me(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearObject=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearObjectString=new f(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withAsk=e=>{try{this.askString=new j(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearImage=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearImageString=new k(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearVector=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearVectorString=new m(e).toString(),this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withLimit=e=>(this.limit=e,this);this.withOffset=e=>(this.offset=e,this);this.withSort=e=>(this.sortString=new ge(e).toString(),this);this.withGenerate=e=>(this.generateString=new Pe(e).toString(),this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.withGroupBy=e=>{try{this.groupByString=new ve(e).toString()}catch(r){this.addError(r.toString())}return this};this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.className,"className",".withClassName(className)"),this.validateIsSet(this.fields,"fields",".withFields(fields)")};this.do=()=>{let e="";if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let r=[];return this.whereString&&(r=[...r,`where:${this.whereString}`]),this.nearTextString&&(r=[...r,`nearText:${this.nearTextString}`]),this.nearObjectString&&(r=[...r,`nearObject:${this.nearObjectString}`]),this.askString&&(r=[...r,`ask:${this.askString}`]),this.nearImageString&&(r=[...r,`nearImage:${this.nearImageString}`]),this.nearVectorString&&(r=[...r,`nearVector:${this.nearVectorString}`]),this.bm25String&&(r=[...r,`bm25:${this.bm25String}`]),this.hybridString&&(r=[...r,`hybrid:${this.hybridString}`]),this.groupString&&(r=[...r,`group:${this.groupString}`]),this.limit&&(r=[...r,`limit:${this.limit}`]),this.offset&&(r=[...r,`offset:${this.offset}`]),this.sortString&&(r=[...r,`sort:[${this.sortString}]`]),this.after&&(r=[...r,`after:"${this.after}"`]),this.generateString&&(this.fields?.includes("_additional")?this.fields.replace("_additional{",`_additional{${this.generateString}`):this.fields=this.fields?.concat(` _additional{${this.generateString}}`)),this.consistencyLevel&&(r=[...r,`consistencyLevel:${this.consistencyLevel}`]),this.groupByString&&(r=[...r,`groupBy:${this.groupByString}`]),r.length>0&&(e=`(${r.join(",")})`),this.client.query(`{Get{${this.className}${e}{${this.fields}}}}`)};this.includesNearMediaFilter=!1}};var E=class extends n{constructor(e){super(e);this.withFields=e=>(this.fields=e,this);this.withLimit=e=>(this.limit=e,this);this.withNearText=e=>{try{this.nearTextString=new u(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearObject=e=>{try{this.nearObjectString=new f(e).toString()}catch(r){this.addError(r.toString())}return this};this.withAsk=e=>{try{this.askString=new j(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearImage=e=>{try{this.nearImageString=new k(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearVector=e=>{try{this.nearVectorString=new m(e).toString()}catch(r){this.addError(r.toString())}return this};this.validateGroup=()=>{if(this.group&&!Array.isArray(this.group))throw new Error("groupBy must be an array")};this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.fields,"fields",".withFields(fields)")};this.do=()=>{let e="";if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let r=[];return this.nearTextString&&(r=[...r,`nearText:${this.nearTextString}`]),this.nearObjectString&&(r=[...r,`nearObject:${this.nearObjectString}`]),this.askString&&(r=[...r,`ask:${this.askString}`]),this.nearImageString&&(r=[...r,`nearImage:${this.nearImageString}`]),this.nearVectorString&&(r=[...r,`nearVector:${this.nearVectorString}`]),this.limit&&(r=[...r,`limit:${this.limit}`]),e=`(${r.join(",")})`,this.client.query(`{Explore${e}{${this.fields}}}`)};this.params={}}};var $=class extends n{constructor(e){super(e);this.withQuery=e=>(this.query=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.query,"query",".raw().withQuery(query)")};this.do=()=>{let e="";return this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.query?this.client.query(this.query):Promise.resolve(void 0)}}};var ut=i=>({get:()=>new A(i),aggregate:()=>new x(i),explore:()=>new E(i),raw:()=>new $(i)}),_e=ut;var B=class extends n{constructor(e){super(e);this.withClass=e=>(this.class=e,this);this.validateClass=()=>{(this.class==null||this.class==null)&&this.addError("class object must be set - set with .withClass(class)")};this.do=()=>{if(this.validateClass(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/schema";return this.client.post(e,this.class)}}validate(){this.validateClass()}};function o(i){return typeof i=="string"&&i.length>0}var I=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validate=()=>{this.validateClassName()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/schema/${this.className}`;return this.client.delete(e,void 0,!1)}}};var R=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validate=()=>{this.validateClassName()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/schema/${this.className}`;return this.client.get(e)}}};var T=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.withProperty=e=>(this.property=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validateProperty=()=>{(this.property==null||this.property==null)&&this.addError("property must be set - set with .withProperty(property)")};this.validate=()=>{this.validateClassName(),this.validateProperty()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/schema/${this.className}/properties`;return this.client.post(e,this.property)}}};var O=class extends n{constructor(e){super(e);this.do=()=>{if(this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/schema";return this.client.get(e)}}validate(){}};var ye=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.validate=()=>{this.validateClassName()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error(`invalid usage: ${this.errors.join(", ")}`)):Te(this.client,this.className))}};function Te(i,t){let e=`/schema/${t}/shards`;return i.get(e)}var L=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.withShardName=e=>(this.shardName=e,this);this.validateShardName=()=>{o(this.shardName)||this.addError("shardName must be set - set with .withShardName(shardName)")};this.withStatus=e=>(this.status=e,this);this.validateStatus=()=>{o(this.status)||this.addError("status must be set - set with .withStatus(status)")};this.validate=()=>{this.validateClassName(),this.validateShardName(),this.validateStatus()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error(`invalid usage: ${this.errors.join(", ")}`)):Oe(this.client,this.className,this.shardName,this.status))}};function Oe(i,t,e,r){let s=`/schema/${t}/shards/${e}`;return i.put(s,{status:r},!0)}var V=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.withStatus=e=>(this.status=e,this);this.validateStatus=()=>{o(this.status)||this.addError("status must be set - set with .withStatus(status)")};this.validate=()=>{this.validateClassName(),this.validateStatus()};this.updateShards=async()=>{let e=await Promise.all(Array.from({length:this.shards.length},(r,s)=>Oe(this.client,this.className,this.shards[s].name||"",this.status).then(a=>({name:this.shards[s].name,status:a.status})).catch(a=>this.addError(a.toString()))));return this.errors.length>0?Promise.reject(new Error(`failed to update shards: ${this.errors.join(", ")}`)):Promise.resolve(e)};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error(`invalid usage: ${this.errors.join(", ")}`)):Te(this.client,this.className).then(e=>this.shards=e).then(()=>this.updateShards()).then(e=>e).catch(e=>Promise.reject(e)));this.shards=[]}};var mt=i=>({classCreator:()=>new B(i),classDeleter:()=>new I(i),classGetter:()=>new R(i),getter:()=>new O(i),propertyCreator:()=>new T(i),shardsGetter:()=>new ye(i),shardUpdater:()=>new L(i),shardsUpdater:()=>new V(i)}),De=mt;var F=class extends n{constructor(e,r){super(e);this.withVector=e=>(this.vector=e,this);this.withClassName=e=>(this.className=e,this);this.withProperties=e=>(this.properties=e,this);this.withId=e=>(this.id=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.payload=()=>({vector:this.vector,properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildCreate(this.consistencyLevel).then(e=>this.client.post(e,this.payload())));this.objectsPath=r}};var G=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.withProperties=e=>(this.properties=e,this);this.withId=e=>(this.id=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.payload=()=>({properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/objects/validate";return this.client.post(e,this.payload(),!1).then(()=>!0)}}};var q=class extends n{constructor(e,r){super(e);this.withProperties=e=>(this.properties=e,this);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - use withClassName(className)")};this.validateId=()=>{(this.id==null||this.id==null||this.id.length==0)&&this.addError("id must be set - initialize with updater(id)")};this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>({properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName(),this.validateId()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildUpdate(this.id,this.className,this.consistencyLevel).then(e=>this.client.put(e,this.payload())));this.objectsPath=r}};var _=class extends n{constructor(e,r){super(e);this.withProperties=e=>(this.properties=e,this);this.withClassName=e=>(this.className=e,this);this.withId=e=>(this.id=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateClassName=()=>{o(this.className)||this.addError("className must be set - set with withClassName(className)")};this.validateId=()=>{(this.id==null||this.id==null||this.id.length==0)&&this.addError("id must be set - set with withId(id)")};this.payload=()=>({properties:this.properties,class:this.className,id:this.id});this.validate=()=>{this.validateClassName(),this.validateId()};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildMerge(this.id,this.className,this.consistencyLevel).then(e=>this.client.patch(e,this.payload())));this.objectsPath=r}};var D=class extends n{constructor(e,r){super(e);this.withClassName=e=>(this.className=e,this);this.withAfter=e=>(this.after=e,this);this.withLimit=e=>(this.limit=e,this);this.extendAdditional=e=>(this.additional=[...this.additional,e],this);this.withAdditional=e=>this.extendAdditional(e);this.withVector=()=>this.extendAdditional("vector");this.do=()=>this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.objectsPath.buildGet(this.className,this.limit,this.additional,this.after).then(e=>this.client.get(e));this.objectsPath=r,this.additional=[]}validate(){}};var W=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.extendAdditional=e=>(this.additional=[...this.additional,e],this);this.withAdditional=e=>this.extendAdditional(e);this.withVector=()=>this.extendAdditional("vector");this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.withNodeName=e=>(this.nodeName=e,this);this.validateId=()=>{(this.id==null||this.id==null||this.id.length==0)&&this.addError("id must be set - initialize with getterById(id)")};this.validate=()=>{this.validateId()};this.buildPath=()=>this.objectsPath.buildGetOne(this.id,this.className,this.additional,this.consistencyLevel,this.nodeName);this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.buildPath().then(e=>this.client.get(e)));this.objectsPath=r,this.additional=[]}};var M=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateId=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.validate=()=>{this.validateId()};this.do=()=>this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):(this.validate(),this.objectsPath.buildDelete(this.id,this.className,this.consistencyLevel).then(e=>this.client.delete(e,void 0,!1)));this.objectsPath=r}};var U=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateId=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.validate=()=>{this.validateId()};this.do=()=>this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):(this.validate(),this.objectsPath.buildCheck(this.id,this.className).then(e=>this.client.head(e,void 0)));this.objectsPath=r}};var H=class extends n{constructor(e,r,s){super(e);this.withId=e=>(this.id=e,this);this.withReference=e=>(this.reference=e,this);this.withReferenceProperty=e=>(this.refProp=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)"),this.validateIsSet(this.refProp,"referenceProperty",".withReferenceProperty(refProp)")};this.payload=()=>this.reference;this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));if(!this.reference.beacon)throw new Error("reference beacon must be set");return Promise.all([this.referencesPath.build(this.id,this.className,this.refProp,this.consistencyLevel),this.beaconPath.rebuild(this.reference.beacon)]).then(e=>{let r=e[0],s=e[1];return this.client.post(r,{beacon:s},!1)})};this.referencesPath=r,this.beaconPath=s}withClassName(e){return this.className=e,this}};var J=class extends n{constructor(e,r,s){super(e);this.withId=e=>(this.id=e,this);this.withReferences=e=>(this.references=e,this);this.withReferenceProperty=e=>(this.refProp=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)"),this.validateIsSet(this.refProp,"referenceProperty",".withReferenceProperty(refProp)")};this.payload=()=>this.references;this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=Array.isArray(this.references)?Promise.all(this.references.map(r=>this.rebuildReferencePromise(r))):Promise.resolve([]);return Promise.all([this.referencesPath.build(this.id,this.className,this.refProp,this.consistencyLevel),e]).then(r=>{let s=r[0],a=r[1];return this.client.put(s,a,!1)})};this.beaconPath=s,this.referencesPath=r}withClassName(e){return this.className=e,this}rebuildReferencePromise(e){return this.beaconPath.rebuild(e.beacon).then(r=>({beacon:r}))}};var K=class extends n{constructor(e,r,s){super(e);this.withId=e=>(this.id=e,this);this.withReference=e=>(this.reference=e,this);this.withReferenceProperty=e=>(this.refProp=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)"),this.validateIsSet(this.refProp,"referenceProperty",".withReferenceProperty(refProp)")};this.payload=()=>this.reference;this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));if(!this.reference.beacon)throw new Error("reference beacon must be set");return Promise.all([this.referencesPath.build(this.id,this.className,this.refProp,this.consistencyLevel),this.beaconPath.rebuild(this.reference.beacon)]).then(e=>{let r=e[0],s=e[1];return this.client.delete(r,{beacon:s},!1)})};this.referencesPath=r,this.beaconPath=s}withClassName(e){return this.className=e,this}};var Q=class extends n{constructor(e){super(e);this.withId=e=>(this.id=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.payload=()=>{if(this.validate(),this.errors.length>0)throw new Error(this.errors.join(", "));let e="weaviate://localhost";return o(this.className)&&(e=`${e}/${this.className}`),{beacon:`${e}/${this.id}`}}}withClassName(e){return this.className=e,this}do(){return Promise.reject(new Error("Should never be called"))}};var We="/objects",Ne=class{constructor(t){this.dbVersionSupport=t}buildCreate(t){return this.build({consistencyLevel:t},[this.addQueryParams])}buildDelete(t,e,r){return this.build({id:t,className:e,consistencyLevel:r},[this.addClassNameDeprecatedNotSupportedCheck,this.addId,this.addQueryParams])}buildCheck(t,e){return this.build({id:t,className:e},[this.addClassNameDeprecatedNotSupportedCheck,this.addId])}buildGetOne(t,e,r,s,a){return this.build({id:t,className:e,additional:r,consistencyLevel:s,nodeName:a},[this.addClassNameDeprecatedNotSupportedCheck,this.addId,this.addQueryParams])}buildGet(t,e,r,s){return this.build({className:t,limit:e,additional:r,after:s},[this.addQueryParamsForGet])}buildUpdate(t,e,r){return this.build({id:t,className:e,consistencyLevel:r},[this.addClassNameDeprecatedCheck,this.addId,this.addQueryParams])}buildMerge(t,e,r){return this.build({id:t,className:e,consistencyLevel:r},[this.addClassNameDeprecatedCheck,this.addId,this.addQueryParams])}build(t,e){return this.dbVersionSupport.supportsClassNameNamespacedEndpointsPromise().then(r=>{let s=We;return e.forEach(a=>{s=a(t,s,r)}),s})}addClassNameDeprecatedNotSupportedCheck(t,e,r){if(r.supports){if(o(t.className))return`${e}/${t.className}`;r.warns.deprecatedNonClassNameNamespacedEndpointsForObjects()}else r.warns.notSupportedClassNamespacedEndpointsForObjects();return e}addClassNameDeprecatedCheck(t,e,r){if(r.supports){if(o(t.className))return`${e}/${t.className}`;r.warns.deprecatedNonClassNameNamespacedEndpointsForObjects()}return e}addId(t,e){return o(t.id)?`${e}/${t.id}`:e}addQueryParams(t,e){let r=[];return Array.isArray(t.additional)&&t.additional.length>0&&r.push(`include=${t.additional.join(",")}`),o(t.nodeName)&&r.push(`node_name=${t.nodeName}`),o(t.consistencyLevel)&&r.push(`consistency_level=${t.consistencyLevel}`),r.length>0?`${e}?${r.join("&")}`:e}addQueryParamsForGet(t,e,r){let s=[];return Array.isArray(t.additional)&&t.additional.length>0&&s.push(`include=${t.additional.join(",")}`),typeof t.limit=="number"&&t.limit>0&&s.push(`limit=${t.limit}`),o(t.className)&&(r.supports?s.push(`class=${t.className}`):r.warns.notSupportedClassParameterInEndpointsForObjects()),o(t.after)&&s.push(`after=${t.after}`),s.length>0?`${e}?${s.join("&")}`:e}},Se=class{constructor(t){this.dbVersionSupport=t}build(t,e,r,s){return this.dbVersionSupport.supportsClassNameNamespacedEndpointsPromise().then(a=>{let h=We;return a.supports?o(e)?h=`${h}/${e}`:a.warns.deprecatedNonClassNameNamespacedEndpointsForReferences():a.warns.notSupportedClassNamespacedEndpointsForReferences(),o(t)&&(h=`${h}/${t}`),h=`${h}/references`,o(r)&&(h=`${h}/${r}`),o(s)&&(h=`${h}?consistency_level=${s}`),h})}};var ft="weaviate://localhost",ce=class{constructor(t){this.dbVersionSupport=t,this.beaconRegExp=/^weaviate:\/\/localhost(\/([^\\/]+))?(\/([^\\/]+))?[\\/]?$/gi}async rebuild(t){let e=await this.dbVersionSupport.supportsClassNameNamespacedEndpointsPromise(),r=new RegExp(this.beaconRegExp).exec(t);if(!r)return t;let s,a;r[4]!==void 0?(a=r[4],s=r[2]):a=r[2];let h=ft;return e.supports?o(s)?h=`${h}/${s}`:e.warns.deprecatedNonClassNameNamespacedEndpointsForBeacons():e.warns.notSupportedClassNamespacedEndpointsForBeacons(),o(a)&&(h=`${h}/${a}`),h}};var gt=(i,t)=>{let e=new Ne(t),r=new Se(t),s=new ce(t);return{creator:()=>new F(i,e),validator:()=>new G(i),updater:()=>new q(i,e),merger:()=>new _(i,e),getter:()=>new D(i,e),getterById:()=>new W(i,e),deleter:()=>new M(i,e),checker:()=>new U(i,e),referenceCreator:()=>new H(i,r,s),referenceReplacer:()=>new J(i,r,s),referenceDeleter:()=>new K(i,r,s),referencePayloadBuilder:()=>new Q(i)}},Me=gt;var g=class extends n{constructor(e){super(e);this.withId=e=>(this.id=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateId=()=>{this.validateIsSet(this.id,"id",".withId(id)")};this.validate=()=>{this.validateId()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/classifications/${this.id}`;return this.client.get(e)}}};var z=class extends n{constructor(e){super(e);this.withType=e=>(this.type=e,this);this.withSettings=e=>(this.settings=e,this);this.withClassName=e=>(this.className=e,this);this.withClassifyProperties=e=>(this.classifyProperties=e,this);this.withBasedOnProperties=e=>(this.basedOnProperties=e,this);this.withWaitForCompletion=()=>(this.waitForCompletion=!0,this);this.withWaitTimeout=e=>(this.waitTimeout=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validateClassName=()=>{this.validateIsSet(this.className,"className",".withClassName(className)")};this.validateBasedOnProperties=()=>{this.validateIsSet(this.basedOnProperties,"basedOnProperties",".withBasedOnProperties(basedOnProperties)")};this.validateClassifyProperties=()=>{this.validateIsSet(this.classifyProperties,"classifyProperties",".withClassifyProperties(classifyProperties)")};this.validate=()=>{this.validateClassName(),this.validateClassifyProperties(),this.validateBasedOnProperties()};this.payload=()=>({type:this.type,settings:this.settings,class:this.className,classifyProperties:this.classifyProperties,basedOnProperties:this.basedOnProperties});this.pollForCompletion=e=>new Promise((r,s)=>{let a=setTimeout(()=>{clearInterval(h),clearTimeout(a),s(new Error("classification didn't finish within configured timeout, set larger timeout with .withWaitTimeout(timeout)"))},this.waitTimeout),h=setInterval(()=>{new g(this.client).withId(e).do().then(c=>{c.status==="completed"&&(clearInterval(h),clearTimeout(a),r(c))})},500)});this.do=()=>{if(this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));this.validate();let e="/classifications";return this.client.post(e,this.payload()).then(r=>this.waitForCompletion?this.pollForCompletion(r.id):Promise.resolve(r))};this.waitTimeout=10*60*1e3,this.waitForCompletion=!1}};var vt=i=>({scheduler:()=>new z(i),getter:()=>new g(i)}),Ue=vt;function xe(i){return Je("/batch/objects",i)}function He(i){return Je("/batch/references",i)}function Je(i,t){return t&&t.toString()!=""&&(i=`${i}?${t.toString()}`),i}var Y=class extends n{constructor(e){super(e);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>({objects:this.objects});this.validateObjectCount=()=>{this.objects.length==0&&this.addError("need at least one object to send a request, add one with .withObject(obj)")};this.validate=()=>{this.validateObjectCount()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=new URLSearchParams;this.consistencyLevel&&e.set("consistency_level",this.consistencyLevel);let r=xe(e);return this.client.post(r,this.payload())};this.objects=[]}withObjects(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.objects=[...this.objects,...r],this}withObject(e){return this.withObjects(e)}};var X=class extends n{constructor(e){super(e);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>({match:{class:this.className,where:this.whereFilter},output:this.output,dryRun:this.dryRun});this.validateClassName=()=>{o(this.className)||this.addError("string className must be set - set with .withClassName(className)")};this.validateWhereFilter=()=>{typeof this.whereFilter!="object"&&this.addError("object where must be set - set with .withWhere(whereFilter)")};this.validate=()=>{this.validateClassName(),this.validateWhereFilter()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=new URLSearchParams;this.consistencyLevel&&e.set("consistency_level",this.consistencyLevel);let r=xe(e);return this.client.delete(r,this.payload(),!0)}}withClassName(e){return this.className=e,this}withWhere(e){return this.whereFilter=e,this}withOutput(e){return this.output=e,this}withDryRun(e){return this.dryRun=e,this}};var Z=class extends n{constructor(e,r){super(e);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.payload=()=>this.references;this.validateReferenceCount=()=>{this.references.length==0&&this.addError("need at least one reference to send a request, add one with .withReference(obj)")};this.validate=()=>{this.validateReferenceCount()};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=new URLSearchParams;this.consistencyLevel&&e.set("consistency_level",this.consistencyLevel);let r=He(e);return Promise.all(this.references.map(a=>this.rebuildReferencePromise(a))).then(a=>this.client.post(r,a))};this.rebuildReferencePromise=e=>this.beaconPath.rebuild(e.to).then(r=>({from:e.from,to:r}));this.beaconPath=r,this.references=[]}withReferences(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.references=[...this.references,...r],this}withReference(e){return this.withReferences(e)}};var we=class extends n{constructor(e){super(e);this.withFromId=e=>(this.fromId=e,this);this.withToId=e=>(this.toId=e,this);this.withFromClassName=e=>(this.fromClassName=e,this);this.withFromRefProp=e=>(this.fromRefProp=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.fromId,"fromId",".withFromId(id)"),this.validateIsSet(this.toId,"toId",".withToId(id)"),this.validateIsSet(this.fromClassName,"fromClassName",".withFromClassName(className)"),this.validateIsSet(this.fromRefProp,"fromRefProp",".withFromRefProp(refProp)")};this.payload=()=>{if(this.validate(),this.errors.length>0)throw new Error(this.errors.join(", "));let e="weaviate://localhost";return o(this.toClassName)&&(e=`${e}/${this.toClassName}`),{from:`weaviate://localhost/${this.fromClassName}/${this.fromId}/${this.fromRefProp}`,to:`${e}/${this.toId}`}};this.do=()=>Promise.reject(new Error("Should never be called"))}withToClassName(e){return this.toClassName=e,this}};var yt=(i,t)=>{let e=new ce(t);return{objectsBatcher:()=>new Y(i),objectsBatchDeleter:()=>new X(i),referencesBatcher:()=>new Z(i,e),referencePayloadBuilder:()=>new we(i)}},Ke=yt;var ee=class extends n{constructor(e,r){super(e);this.do=()=>this.client.get("/.well-known/live",!1).then(()=>(setTimeout(()=>this.dbVersionProvider.refresh()),Promise.resolve(!0))).catch(()=>Promise.resolve(!1));this.dbVersionProvider=r}validate(){}};var te=class extends n{constructor(e,r){super(e);this.do=()=>this.client.get("/.well-known/ready",!1).then(()=>(setTimeout(()=>this.dbVersionProvider.refresh()),Promise.resolve(!0))).catch(()=>Promise.resolve(!1));this.dbVersionProvider=r}validate(){}};var v=class extends n{constructor(e){super(e);this.do=()=>this.client.get("/meta",!0)}validate(){}};var wt=(i,t)=>({liveChecker:()=>new ee(i,t),readyChecker:()=>new te(i,t),metaGetter:()=>new v(i),openidConfigurationGetter:()=>new l(i.http)}),Qe=wt;var re=class extends n{constructor(e){super(e);this.withConcept=e=>(this.concept=e,this);this.withDefinition=e=>(this.definition=e,this);this.withWeight=e=>(this.weight=e,this);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.validate=()=>{this.validateIsSet(this.concept,"concept","withConcept(concept)"),this.validateIsSet(this.definition,"definition","withDefinition(definition)"),this.validateIsSet(this.weight?.toString()||"","weight","withWeight(weight)")};this.payload=()=>({concept:this.concept,definition:this.definition,weight:this.weight});this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e="/modules/text2vec-contextionary/extensions";return this.client.post(e,this.payload())}}};var ie=class extends n{constructor(e){super(e);this.validateIsSet=(e,r,s)=>{(e==null||e==null||e.length==0)&&this.addError(`${r} must be set - set with ${s}`)};this.withConcept=e=>(this.concept=e,this);this.validate=()=>{this.validateIsSet(this.concept,"concept","withConcept(concept)")};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e=`/modules/text2vec-contextionary/concepts/${this.concept}`;return this.client.get(e)}}};var Ct=i=>({conceptsGetter:()=>new ie(i),extensionCreator:()=>new re(i)}),ze=Ct;var ke=class{constructor(t){this.dbVersionProvider=t}supportsClassNameNamespacedEndpointsPromise(){return this.dbVersionProvider.getVersionPromise().then(t=>({version:t,supports:this.supportsClassNameNamespacedEndpoints(t),warns:{deprecatedNonClassNameNamespacedEndpointsForObjects:()=>console.warn(`Usage of objects paths without className is deprecated in Weaviate ${t}. Please provide className parameter`),deprecatedNonClassNameNamespacedEndpointsForReferences:()=>console.warn(`Usage of references paths without className is deprecated in Weaviate ${t}. Please provide className parameter`),deprecatedNonClassNameNamespacedEndpointsForBeacons:()=>console.warn(`Usage of beacons paths without className is deprecated in Weaviate ${t}. Please provide className parameter`),notSupportedClassNamespacedEndpointsForObjects:()=>console.warn(`Usage of objects paths with className is not supported in Weaviate ${t}. className parameter is ignored`),notSupportedClassNamespacedEndpointsForReferences:()=>console.warn(`Usage of references paths with className is not supported in Weaviate ${t}. className parameter is ignored`),notSupportedClassNamespacedEndpointsForBeacons:()=>console.warn(`Usage of beacons paths with className is not supported in Weaviate ${t}. className parameter is ignored`),notSupportedClassParameterInEndpointsForObjects:()=>console.warn(`Usage of objects paths with class query parameter is not supported in Weaviate ${t}. class query parameter is ignored`)}}))}supportsClassNameNamespacedEndpoints(t){if(typeof t=="string"){let e=t.split(".");if(e.length>=2){let r=parseInt(e[0],10),s=parseInt(e[1],10);return r==1&&s>=14||r>=2}}return!1}},Ye="",je=class{constructor(t){this.versionGetter=t,this.emptyVersionPromise=Promise.resolve(Ye),this.versionPromise=void 0}getVersionPromise(){return this.versionPromise?this.versionPromise:this.versionGetter().then(t=>this.assignPromise(t))}refresh(t=!1){return t||!this.versionPromise?(this.versionPromise=void 0,this.versionGetter().then(e=>this.assignPromise(e)).then(()=>Promise.resolve(!0))):Promise.resolve(!1)}assignPromise(t){return t===Ye?this.emptyVersionPromise:(this.versionPromise=Promise.resolve(t),this.versionPromise)}};function Ae(i){if(Array.isArray(i)){let t=[];return i.forEach(e=>{o(e)||t.push("string className invalid - set with .withIncludeClassNames(...classNames)")}),t}return i!=null?["strings classNames invalid - set with .withIncludeClassNames(...classNames)"]:[]}function Ee(i){if(Array.isArray(i)){let t=[];return i.forEach(e=>{o(e)||t.push("string className invalid - set with .withExcludeClassNames(...classNames)")}),t}return i!=null?["strings classNames invalid - set with .withExcludeClassNames(...classNames)"]:[]}function w(i){return o(i)?[]:["string backend must set - set with .withBackend(backend)"]}function C(i){return o(i)?[]:["string backupId must be set - set with .withBackupId(backupId)"]}var bt=1e3,se=class extends n{constructor(e,r){super(e);this.validate=()=>{this.addErrors([...Ae(this.includeClassNames),...Ee(this.excludeClassNames),...w(this.backend),...C(this.backupId)])};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e={id:this.backupId,config:{},include:this.includeClassNames,exclude:this.excludeClassNames};return this.waitForCompletion?this._createAndWaitForCompletion(e):this._create(e)};this._create=e=>this.client.post(this._path(),e);this._createAndWaitForCompletion=e=>new Promise((r,s)=>{this._create(e).then(a=>{this.statusGetter.withBackend(this.backend).withBackupId(this.backupId);let h=()=>{this.statusGetter.do().then(c=>{c.status=="SUCCESS"||c.status=="FAILED"?r(this._merge(c,a)):setTimeout(h,bt)}).catch(s)};h()}).catch(s)});this._path=()=>`/backups/${this.backend}`;this._merge=(e,r)=>{let s={};return"id"in e&&(s.id=e.id),"path"in e&&(s.path=e.path),"backend"in e&&(s.backend=e.backend),"status"in e&&(s.status=e.status),"error"in e&&(s.error=e.error),"classes"in r&&(s.classes=r.classes),s};this.statusGetter=r}withIncludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.includeClassNames=r,this}withExcludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.excludeClassNames=r,this}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}withWaitForCompletion(e){return this.waitForCompletion=e,this}};var b=class extends n{constructor(e){super(e);this.validate=()=>{this.addErrors([...w(this.backend),...C(this.backupId)])};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.client.get(this._path()));this._path=()=>`/backups/${this.backend}/${this.backupId}`}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}};var Pt=1e3,ne=class extends n{constructor(e,r){super(e);this.validate=()=>{this.addErrors([...Ae(this.includeClassNames||[]),...Ee(this.excludeClassNames||[]),...w(this.backend),...C(this.backupId)])};this.do=()=>{if(this.validate(),this.errors.length>0)return Promise.reject(new Error("invalid usage: "+this.errors.join(", ")));let e={config:{},include:this.includeClassNames,exclude:this.excludeClassNames};return this.waitForCompletion?this._restoreAndWaitForCompletion(e):this._restore(e)};this._restore=e=>this.client.post(this._path(),e);this._restoreAndWaitForCompletion=e=>new Promise((r,s)=>{this._restore(e).then(a=>{this.statusGetter.withBackend(this.backend).withBackupId(this.backupId);let h=()=>{this.statusGetter.do().then(c=>{c.status=="SUCCESS"||c.status=="FAILED"?r(this._merge(c,a)):setTimeout(h,Pt)}).catch(s)};h()}).catch(s)});this._path=()=>`/backups/${this.backend}/${this.backupId}/restore`;this._merge=(e,r)=>{let s={};return"id"in e&&(s.id=e.id),"path"in e&&(s.path=e.path),"backend"in e&&(s.backend=e.backend),"status"in e&&(s.status=e.status),"error"in e&&(s.error=e.error),"classes"in r&&(s.classes=r.classes),s};this.statusGetter=r}withIncludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.includeClassNames=r,this}withExcludeClassNames(...e){let r=e;return e.length&&Array.isArray(e[0])&&(r=e[0]),this.excludeClassNames=r,this}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}withWaitForCompletion(e){return this.waitForCompletion=e,this}};var P=class extends n{constructor(e){super(e);this.validate=()=>{this.addErrors([...w(this.backend),...C(this.backupId)])};this.do=()=>(this.validate(),this.errors.length>0?Promise.reject(new Error("invalid usage: "+this.errors.join(", "))):this.client.get(this._path()));this._path=()=>`/backups/${this.backend}/${this.backupId}/restore`}withBackend(e){return this.backend=e,this}withBackupId(e){return this.backupId=e,this}};var Nt=i=>({creator:()=>new se(i,new b(i)),createStatusGetter:()=>new b(i),restorer:()=>new ne(i,new P(i)),restoreStatusGetter:()=>new P(i)}),Xe=Nt;var ae=class extends n{constructor(t){super(t)}validate(){}do(){return this.client.get("/nodes")}};var St=i=>({nodesStatusGetter:()=>new ae(i)}),Ze=St;var xt={client:function(i){if(!i.host)throw new Error("Missing `host` parameter");if(!i.scheme)throw new Error("Missing `scheme` parameter");i.headers||(i.headers={});let t=new pe(i),e=kt(t),r=new ke(e),s={graphql:_e(t),schema:De(t),data:Me(t,r),classifications:Ue(t),batch:Ke(t,r),misc:Qe(t,e),c11y:ze(t),backup:Xe(t),cluster:Ze(t)};return t.oidcAuth&&(s.oidcAuth=t.oidcAuth),s},ApiKey:le,AuthUserPasswordCredentials:oe,AuthAccessTokenCredentials:N,AuthClientCredentials:he};function kt(i){let t=new v(i),e=()=>t.do().then(s=>s.version).catch(()=>Promise.resolve("")),r=new je(e);return r.refresh(),r}var jt=xt; |
{ | ||
"name": "weaviate-ts-client", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "TypeScript client for Weaviate", | ||
"main": "dist/index.js", | ||
"types": "types/index.d.ts", | ||
"main": "./dist/index.js", | ||
"module": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts", | ||
"exports": { | ||
".": { | ||
"require": "./dist/index.js", | ||
"import": "./dist/index.mjs", | ||
"types": "./dist/index.d.ts" | ||
} | ||
}, | ||
"engines": { | ||
@@ -12,13 +20,13 @@ "node": ">=16.0.0" | ||
"/dist/index.js", | ||
"/dist/index.js.map", | ||
"/types/**/*.d.ts" | ||
"/dist/index.mjs", | ||
"/dist/index.d.ts" | ||
], | ||
"scripts": { | ||
"test": "tsc -noEmit -p tsconfig-test.json && jest --useStderr --runInBand --detectOpenHandles", | ||
"build": "npm run lint && tsc --emitDeclarationOnly && ./build.js", | ||
"build": "npm run lint && tsup src/index.ts --format cjs,esm --dts --clean --platform neutral --minify", | ||
"prepack": "npm run build", | ||
"lint": "eslint --ext .ts,.js .", | ||
"lint:fix": "npm run lint -- --fix", | ||
"format": "prettier --write --no-error-on-unmatched-pattern '**/*.{ts,js}' '!dist/**' '!types/**'", | ||
"format:check": "prettier --check --no-error-on-unmatched-pattern '**/*.{ts,js}' '!dist/**' '!types/**'", | ||
"format": "prettier --write --no-error-on-unmatched-pattern '**/*.{ts,js}' '!dist/**'", | ||
"format:check": "prettier --check --no-error-on-unmatched-pattern '**/*.{ts,js}' '!dist/**'", | ||
"prepare": "husky install" | ||
@@ -56,3 +64,2 @@ }, | ||
"babel-jest": "^29.4.3", | ||
"esbuild": "^0.17.10", | ||
"eslint": "^8.35.0", | ||
@@ -66,2 +73,3 @@ "eslint-config-prettier": "^8.7.0", | ||
"ts-jest": "^29.0.5", | ||
"tsup": "^6.7.0", | ||
"typescript": "^4.9.5" | ||
@@ -68,0 +76,0 @@ }, |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
207329
6
2462
1