weaviate-ts-client
Version:
TypeScript client for Weaviate
1 lines • 73.1 kB
JavaScript
var Ae=class{constructor(t,e){this.refresh=async t=>{let e=await this.getOpenidConfig(t),r;switch(this.creds.constructor){case me:r=new Fe(this.http,this.creds,e);break;case j:r=new Le(this.http,this.creds,e);break;case fe:r=new Ge(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 j&&(this.accessToken=this.creds.accessToken,this.expiresAt=this.creds.expiresAt,this.refreshToken=this.creds.refreshToken)}resetExpiresAt(){this.expiresAt=0}},me=class{constructor(t){this.username=t.username,this.password=t.password,this.scopes=t.scopes,this.silentRefresh=De(t.silentRefresh)}},Fe=class{constructor(t,e,r){this.refresh=()=>(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:Te(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)}},j=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=Te(t.expiresIn),this.refreshToken=t.refreshToken,this.silentRefresh=De(t.silentRefresh)}},Le=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:Te(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}},fe=class{constructor(t){this.clientSecret=t.clientSecret,this.scopes=t.scopes,this.silentRefresh=De(t.silentRefresh)}},Ge=class{constructor(t,e,r){this.refresh=()=>(this.validateOpenidConfig(),this.requestAccessToken().then(t=>({accessToken:t.access_token,expiresAt:Te(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)}},ke=class{constructor(t){this.apiKey=t}};function Te(i){return Date.now()+(i-2)*1e3}function De(i){return i===void 0?!0:i}var g=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 lt=i=>{let t="/v1",e=`${i.host}${t}`,r=pt(e);return{post:(s,o,h=!0,c="")=>{let d={method:"POST",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(o)};return x(d,c),fetch(r(s),d).then(v(h))},put:(s,o,h=!0,c="")=>{let d={method:"PUT",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(o)};return x(d,c),fetch(r(s),d).then(v(h))},patch:(s,o,h="")=>{let c={method:"PATCH",headers:{...i.headers,"content-type":"application/json"},body:JSON.stringify(o)};return x(c,h),fetch(r(s),c).then(v(!1))},delete:(s,o,h=!1,c="")=>{let d={method:"DELETE",headers:{...i.headers,"content-type":"application/json"},body:o?JSON.stringify(o):void 0};return x(d,c),fetch(r(s),d).then(v(h))},head:(s,o,h="")=>{let c={method:"HEAD",headers:{...i.headers,"content-type":"application/json"},body:o?JSON.stringify(o):void 0};return x(c,h),fetch(r(s),c).then(ut(!1))},get:(s,o=!0,h="")=>{let c={method:"GET",headers:{...i.headers}};return x(c,h),fetch(r(s),c).then(v(o))},getRaw:(s,o="")=>{let h={method:"GET",headers:{...i.headers}};return x(h,o),fetch(r(s),h)},externalGet:s=>fetch(s,{method:"GET",headers:{...i.headers}}).then(v(!0)),externalPost:(s,o,h)=>{(h==null||h=="")&&(h="application/json");let c={body:void 0,method:"POST",headers:{...i.headers,"content-type":h}};return o!=null&&(c.body=o),fetch(s,c).then(v(!0))}}},pt=i=>t=>i+t,v=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()},ut=i=>t=>t.status==200||t.status==204||t.status==404?t.status==200||t.status==204:v(i)(t);function x(i,t){t!==""&&(i.headers.Authorization=`Bearer ${t}`)}var Je=lt;import{GraphQLClient as mt}from"graphql-request";var ft=i=>{let t=i.headers,e="/v1/graphql",r=`${i.host}${e}`;return{query:(s,o,h)=>new mt(r,{headers:{...t,...h},fetch}).request(s,o,h).then(c=>({data:c}))}},He=ft;var ge=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 g(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.host=t.host,this.http=Je(t),this.gql=He(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 Ae(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);let e=/^(https?|ftp|file)(?::\/\/)/,r=t.host.match(e);if(t.scheme){if(r&&r[1]!==`${t.scheme}`)throw new Error(`The host contains a different protocol than specified in the scheme (scheme: ${t.scheme} != host: ${r[1]})`);r||(t.host=`${t.scheme}://${t.host}`)}else if(!r)throw new Error("The host must start with a recognized protocol (e.g., http or https) if no scheme is provided.");return t}};var l=class{constructor(t){this.source=t}toString(){if(this.parse(),this.validate(),this.operands)return`{operator:${this.operator},operands:[${this.operands}]}`;{let t=this.getValueType(),e=this.marshalValueContent();return`{operator:${this.operator},${t}:${e},path:${JSON.stringify(this.path)}}`}}marshalValueContent(){return this.valueType=="valueGeoRange"?this.marshalValueGeoRange():JSON.stringify(this.valueContent)}getValueType(){switch(this.valueType){case"valueStringArray":return"valueString";case"valueTextArray":return"valueText";case"valueIntArray":return"valueInt";case"valueNumberArray":return"valueNumber";case"valueDateArray":return"valueDate";case"valueBooleanArray":return"valueBoolean";default:return this.valueType}}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"valueStringArray":case"valueTextArray":case"valueIntArray":case"valueNumberArray":case"valueDateArray":case"valueBooleanArray":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 l(e).toString()).join(",")}};var p=class{constructor(t){this.certainty=t.certainty,this.distance=t.distance,this.media=t.media,this.type=t.type,this.targetVectors=t.targetVectors}toString(t=!0){let e=[];if(this.media.startsWith("data:")){let r=";base64,";this.media=this.media.substring(this.media.indexOf(r)+r.length)}return e=[...e,`${this.type.toLowerCase()}:${JSON.stringify(this.media)}`],this.certainty&&(e=[...e,`certainty:${this.certainty}`]),this.distance&&(e=[...e,`distance:${this.distance}`]),this.targetVectors&&this.targetVectors.length>0&&(e=[...e,`targetVectors:${JSON.stringify(this.targetVectors)}`]),t?`{${e.join(",")}}`:`${e.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,this.targetVectors=t.targetVectors}toString(){this.validate();let t=[`concepts:${JSON.stringify(this.concepts)}`];return this.certainty&&(t=[...t,`certainty:${this.certainty}`]),this.distance&&(t=[...t,`distance:${this.distance}`]),this.targetVectors&&this.targetVectors.length>0&&(t=[...t,`targetVectors:${JSON.stringify(this.targetVectors)}`]),this.moveTo&&(t=[...t,ve("moveTo",this.moveTo)]),this.moveAwayFrom&&(t=[...t,ve("moveAwayFrom",this.moveAwayFrom)]),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'")}}};function gt(i,t){let e=[];for(let r in t){if(!t[r].id&&!t[r].beacon)throw new Error(`nearText: ${i}.objects[${r}].id or ${i}.objects[${r}].beacon must be present`);let s=[];t[r].id&&s.push(`id:"${t[r].id}"`),t[r].beacon&&s.push(`beacon:"${t[r].beacon}"`),e.push(`{${s.join(",")}}`)}return`[${e.join(",")}]`}function ve(i,t){let e=[];return t.concepts&&(e=[...e,`concepts:${JSON.stringify(t.concepts)}`]),t.objects&&(e=[...e,`objects:${gt(i,t.objects)}`]),t.force&&(e=[...e,`force:${t.force}`]),`${i}:{${e.join(",")}}`}var m=class{constructor(t){this.certainty=t.certainty,this.distance=t.distance,this.vector=t.vector,this.targetVectors=t.targetVectors}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}`]),this.targetVectors&&this.targetVectors.length>0&&(e=[...e,`targetVectors:${JSON.stringify(this.targetVectors)}`]),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,this.targetVectors=t.targetVectors}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}`]),this.targetVectors&&this.targetVectors.length>0&&(e=[...e,`targetVectors:${JSON.stringify(this.targetVectors)}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.id&&!this.beacon)throw new Error("nearObject filter: id or beacon needs to be set")}};function vt(i){return Number.isInteger(i)}function Ke(i){return vt(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 $=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 l(e).toString()}catch(r){this.addError(r)}return this};this.withNearMedia=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearMediaString=new p(e).toString(),this.nearMediaType=e.type,this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearImage=e=>this.withNearMedia({...e,media:e.image,type:"Image"});this.withNearAudio=e=>this.withNearMedia({...e,media:e.audio,type:"Audio"});this.withNearVideo=e=>this.withNearMedia({...e,media:e.video,type:"Video"});this.withNearDepth=e=>this.withNearMedia({...e,media:e.depth,type:"Depth"});this.withNearIMU=e=>this.withNearMedia({...e,media:e.imu,type:"IMU"});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(!Ke(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.withTenant=e=>(this.tenant=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||this.tenant){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.nearMediaString&&(r=[...r,`${this.nearMediaType}:${this.nearMediaString}`]),this.groupBy&&(r=[...r,`groupBy:${JSON.stringify(this.groupBy)}`]),this.limit&&(r=[...r,`limit:${this.limit}`]),this.objectLimit&&(r=[...r,`objectLimit:${this.objectLimit}`]),this.tenant&&(r=[...r,`tenant:"${this.tenant}"`]),e=`(${r.join(",")})`}return this.client.query(`{Aggregate{${this.className}${e}{${this.fields}}}}`)};this.includesNearMediaFilter=!1}};var ye=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 _e=(e=>(e.rankedFusion="rankedFusion",e.relativeScoreFusion="relativeScoreFusion",e))(_e||{}),qe=class{constructor(t){this.nearText=t.nearText,this.nearVector=t.nearVector}toString(){let t=[];if(this.nearText!==void 0){let e=[`concepts:${JSON.stringify(this.nearText.concepts)}`];this.nearText.certainty&&(e=[...e,`certainty:${this.nearText.certainty}`]),this.nearText.distance&&(e=[...e,`distance:${this.nearText.distance}`]),this.nearText.moveTo&&(e=[...e,ve("moveTo",this.nearText.moveTo)]),this.nearText.moveAwayFrom&&(e=[...e,ve("moveAwayFrom",this.nearText.moveAwayFrom)]),t=[...t,`nearText:{${e.join(",")}}`]}if(this.nearVector!==void 0){let e=[`vector:${JSON.stringify(this.nearVector.vector)}`];this.nearVector.certainty&&(e=[...e,`certainty:${this.nearVector.certainty}`]),this.nearVector.distance&&(e=[...e,`distance:${this.nearVector.distance}`]),this.nearVector.targetVectors&&this.nearVector.targetVectors.length>0&&(e=[...e,`targetVectors:${JSON.stringify(this.nearVector.targetVectors)}`]),t=[...t,`nearVector:{${e.join(",")}}`]}return`{${t.join(",")}}`}},we=class{constructor(t){this.alpha=t.alpha,this.query=t.query,this.vector=t.vector,this.properties=t.properties,this.targetVectors=t.targetVectors,this.fusionType=t.fusionType,this.searches=t.searches?.map(e=>new qe(e))}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)}`]),this.properties&&this.properties.length>0&&(t=[...t,`properties:${JSON.stringify(this.properties)}`]),this.targetVectors&&this.targetVectors.length>0&&(t=[...t,`targetVectors:${JSON.stringify(this.targetVectors)}`]),this.fusionType!==void 0&&(t=[...t,`fusionType:${this.fusionType}`]),this.searches!==void 0&&(t=[...t,`searches:[${this.searches.map(e=>e.toString()).join(",")}]`]),`{${t.join(",")}}`}};var S=class{constructor(t){this.certainty=t.certainty,this.distance=t.distance,this.image=t.image,this.targetVectors=t.targetVectors}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}`]),this.targetVectors&&this.targetVectors.length>0&&(e=[...e,`targetVectors:${JSON.stringify(this.targetVectors)}`]),t?`{${e.join(",")}}`:`${e.join(",")}`}validate(){if(!this.image)throw new Error("nearImage filter: image field must be present")}};var A=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 be=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 Ce=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 je=class{constructor(t){this.groupedTask=t.groupedTask,this.groupedProperties=t.groupedProperties,this.singlePrompt=t.singlePrompt}toString(){this.validate();let t="generate(",e=["error"];if(this.singlePrompt&&(t+=`singleResult:{prompt:"${this.singlePrompt.replace(/[\n\r]+/g,"")}"}`,e.push("singleResult")),this.groupedTask||this.groupedProperties!==void 0&&this.groupedProperties.length>0){let r=[];this.groupedTask&&r.push(`task:"${this.groupedTask.replace(/[\n\r]+/g,"")}"`),this.groupedProperties!==void 0&&this.groupedProperties.length>0&&r.push(`properties:${JSON.stringify(this.groupedProperties)}`),t+=`groupedResult:{${r.join(",")}}`,e.push("groupedResult")}return 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 Ne=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 B=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 be(e).toString()}catch(r){this.addError(r.toString())}return this};this.withWhere=e=>{try{this.whereString=new l(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 ye(e).toString()}catch(r){this.addError(r.toString())}return this};this.withHybrid=e=>{try{this.hybridString=new we(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 A(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearMedia=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearMediaString=new p(e).toString(),this.nearMediaType=e.type,this.includesNearMediaFilter=!0}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.nearMediaString=new S(e).toString(),this.nearMediaType="Image",this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearAudio=e=>this.withNearMedia({...e,type:"Audio",media:e.audio});this.withNearVideo=e=>this.withNearMedia({...e,type:"Video",media:e.video});this.withNearThermal=e=>this.withNearMedia({...e,type:"Thermal",media:e.thermal});this.withNearDepth=e=>this.withNearMedia({...e,type:"Depth",media:e.depth});this.withNearIMU=e=>this.withNearMedia({...e,type:"IMU",media:e.imu});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.withAutocut=e=>(this.autocut=e,this);this.withSort=e=>(this.sortString=new Ce(e).toString(),this);this.withGenerate=e=>(this.generateString=new je(e).toString(),this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.withGroupBy=e=>{try{this.groupByString=new Ne(e).toString()}catch(r){this.addError(r.toString())}return this};this.withTenant=e=>(this.tenant=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.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.nearMediaString&&(r=[...r,`near${this.nearMediaType}:${this.nearMediaString}`]),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.autocut&&(r=[...r,`autocut:${this.autocut}`]),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}`]),this.tenant&&(r=[...r,`tenant:"${this.tenant}"`]),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=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearTextString=new u(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()}catch(r){this.addError(r.toString())}return this};this.withAsk=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.askString=new A(e).toString()}catch(r){this.addError(r.toString())}return this};this.withNearMedia=e=>{if(this.includesNearMediaFilter)throw new Error("cannot use multiple near<Media> filters in a single query");try{this.nearMediaString=new p(e).toString(),this.nearMediaType=e.type,this.includesNearMediaFilter=!0}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.nearMediaString=new S(e).toString(),this.nearMediaType="Image",this.includesNearMediaFilter=!0}catch(r){this.addError(r.toString())}return this};this.withNearAudio=e=>this.withNearMedia({...e,media:e.audio,type:"Audio"});this.withNearVideo=e=>this.withNearMedia({...e,media:e.video,type:"Video"});this.withNearDepth=e=>this.withNearMedia({...e,media:e.depth,type:"Depth"});this.withNearThermal=e=>this.withNearMedia({...e,media:e.thermal,type:"Thermal"});this.withNearIMU=e=>this.withNearMedia({...e,media:e.imu,type:"IMU"});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()}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.nearMediaString&&(r=[...r,`${this.nearMediaType}:${this.nearMediaString}`]),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={},this.includesNearMediaFilter=!1}};var I=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 yt=i=>({get:()=>new B(i),aggregate:()=>new $(i),explore:()=>new E(i),raw:()=>new I(i)}),Qe=yt;var V=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 a(i){return typeof i=="string"&&i.length>0}var y=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{a(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 Pe=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{a(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";return this.client.get(e).then(r=>r.classes?.some(s=>s.class===this.className))}}};var R=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{a(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 O=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.withProperty=e=>(this.property=e,this);this.validateClassName=()=>{a(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 w=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 xe=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{a(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(", ")}`)):We(this.client,this.className))}};function We(i,t){let e=`/schema/${t}/shards`;return i.get(e)}var M=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{a(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.withShardName=e=>(this.shardName=e,this);this.validateShardName=()=>{a(this.shardName)||this.addError("shardName must be set - set with .withShardName(shardName)")};this.withStatus=e=>(this.status=e,this);this.validateStatus=()=>{a(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(", ")}`)):Ue(this.client,this.className,this.shardName,this.status))}};function Ue(i,t,e,r){let s=`/schema/${t}/shards/${e}`;return i.put(s,{status:r},!0)}var F=class extends n{constructor(e){super(e);this.withClassName=e=>(this.className=e,this);this.validateClassName=()=>{a(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.withStatus=e=>(this.status=e,this);this.validateStatus=()=>{a(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)=>Ue(this.client,this.className,this.shards[s].name||"",this.status).then(o=>({name:this.shards[s].name,status:o.status})).catch(o=>this.addError(o.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(", ")}`)):We(this.client,this.className).then(e=>this.shards=e).then(()=>this.updateShards()).then(e=>e).catch(e=>Promise.reject(e)));this.shards=[]}};var L=class extends n{constructor(e,r,s){super(e);this.validate=()=>{};this.do=()=>this.client.post(`/schema/${this.className}/tenants`,this.tenants);this.className=r,this.tenants=s}};var G=class extends n{constructor(e,r){super(e);this.validate=()=>{};this.do=()=>this.client.get(`/schema/${this.className}/tenants`);this.className=r}};var D=class extends n{constructor(e,r,s){super(e);this.validate=()=>{};this.do=()=>this.client.put(`/schema/${this.className}/tenants`,this.tenants);this.className=r,this.tenants=s}};var q=class extends n{constructor(e,r,s){super(e);this.validate=()=>{};this.do=()=>this.client.delete(`/schema/${this.className}/tenants`,this.tenants,!1);this.className=r,this.tenants=s}};var Ye=async i=>{let e=await new w(i).do();await Promise.all(e.classes?e.classes.map(r=>new y(i).withClassName(r.class).do()):[])};var _=class extends n{constructor(e,r,s){super(e);this.validate=()=>{};this.do=()=>this.client.head(`/schema/${this.className}/tenants/${this.tenant}`,void 0);this.className=r,this.tenant=s}};var wt=i=>({classCreator:()=>new V(i),classDeleter:()=>new y(i),classGetter:()=>new R(i),exists:t=>new Pe(i).withClassName(t).do(),getter:()=>new w(i),propertyCreator:()=>new O(i),deleteAll:()=>Ye(i),shardsGetter:()=>new xe(i),shardUpdater:()=>new M(i),shardsUpdater:()=>new F(i),tenantsCreator:(t,e)=>new L(i,t,e),tenantsGetter:t=>new G(i,t),tenantsUpdater:(t,e)=>new D(i,t,e),tenantsDeleter:(t,e)=>new q(i,t,e),tenantsExists:(t,e)=>new _(i,t,e)}),Xe=wt;var W=class extends n{constructor(e,r){super(e);this.withVector=e=>(this.vector=e,this);this.withVectors=e=>(this.vectors=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.withTenant=e=>(this.tenant=e,this);this.validateClassName=()=>{a(this.className)||this.addError("className must be set - set with .withClassName(className)")};this.payload=()=>({tenant:this.tenant,vector:this.vector,properties:this.properties,class:this.className,id:this.id,vectors:this.vectors});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 U=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=()=>{a(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 J=class extends n{constructor(e,r){super(e);this.withVector=e=>(this.vector=e,this);this.withVectors=e=>(this.vectors=e,this);this.withProperties=e=>(this.properties=e,this);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.withTenant=e=>(this.tenant=e,this);this.validateClassName=()=>{a(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=()=>({tenant:this.tenant,properties:this.properties,class:this.className,id:this.id,vector:this.vector,vectors:this.vectors});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 H=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.withTenant=e=>(this.tenant=e,this);this.validateClassName=()=>{a(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=()=>({tenant:this.tenant,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 K=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.withTenant=e=>(this.tenant=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,this.tenant).then(e=>this.client.get(e));this.objectsPath=r,this.additional=[]}validate(){}};var z=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.withTenant=e=>(this.tenant=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.tenant);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 Q=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.withTenant=e=>(this.tenant=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,this.tenant).then(e=>this.client.delete(e,void 0,!1)));this.objectsPath=r}};var Y=class extends n{constructor(e,r){super(e);this.withId=e=>(this.id=e,this);this.withClassName=e=>(this.className=e,this);this.withTenant=e=>(this.tenant=e,this);this.withConsistencyLevel=e=>(this.consistencyLevel=e,this);this.buildPath=()=>this.objectsPath.buildCheck(this.id,this.className,this.consistencyLevel,this.tenant);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.buildPath().then(e=>this.client.head(e,void 0)));this.objectsPath=r}};var X=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.withTenant=e=>(this.tenant=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.tenant),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 Z=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.withTenant=e=>(this.tenant=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,this.tenant),e]).then(r=>{let s=r[0],o=r[1];return this.client.put(s,o,!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 ee=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.withTenant=e=>(this.tenant=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.tenant),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 te=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(",