UNPKG

connect-arango

Version:
1 lines 259 kB
"use strict";var require$$0$4=require("querystring"),require$$0$3=require("http"),require$$1=require("https"),require$$2=require("url"),require$$0$2=require("path"),require$$0$5=require("stream"),require$$1$1=require("util"),require$$1$2=require("fs"),require$$0$8=require("crypto"),require$$0$6=require("buffer"),require$$0$7=require("tty"),require$$4=require("net"),require$$1$3=require("events");function _interopDefaultLegacy(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var require$$0__default$2=_interopDefaultLegacy(require$$0$4),require$$0__default$1=_interopDefaultLegacy(require$$0$3),require$$1__default=_interopDefaultLegacy(require$$1),require$$2__default=_interopDefaultLegacy(require$$2),require$$0__default=_interopDefaultLegacy(require$$0$2),require$$0__default$3=_interopDefaultLegacy(require$$0$5),require$$1__default$1=_interopDefaultLegacy(require$$1$1),require$$1__default$2=_interopDefaultLegacy(require$$1$2),require$$0__default$6=_interopDefaultLegacy(require$$0$8),require$$0__default$4=_interopDefaultLegacy(require$$0$6),require$$0__default$5=_interopDefaultLegacy(require$$0$7),require$$4__default=_interopDefaultLegacy(require$$4),require$$1__default$3=_interopDefaultLegacy(require$$1$3),commonjsGlobal="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getAugmentedNamespace(e){if(e.__esModule)return e;var a=Object.defineProperty({},"__esModule",{value:!0});return Object.keys(e).forEach((function(i){var n=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(a,i,n.get?n:{enumerable:!0,get:function(){return e[i]}})})),a}var arangojs={exports:{}},database={},analyzer={},error$1={},error={};function _classCallCheck(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}function _possibleConstructorReturn(e,a){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!a||"object"!=typeof a&&"function"!=typeof a?e:a}function _inherits(e,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function, not "+typeof a);e.prototype=Object.create(a&&a.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),a&&(Object.setPrototypeOf?Object.setPrototypeOf(e,a):e.__proto__=a)}function _extendableBuiltin(e){function a(){e.apply(this,arguments)}return a.prototype=Object.create(e.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),Object.setPrototypeOf?Object.setPrototypeOf(a,e):a.__proto__=e,a}var ExtendableError=function(e){function a(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";_classCallCheck(this,a);var i=_possibleConstructorReturn(this,(a.__proto__||Object.getPrototypeOf(a)).call(this,e));return Object.defineProperty(i,"message",{configurable:!0,enumerable:!1,value:e,writable:!0}),Object.defineProperty(i,"name",{configurable:!0,enumerable:!1,value:i.constructor.name,writable:!0}),Error.hasOwnProperty("captureStackTrace")?(Error.captureStackTrace(i,i.constructor),_possibleConstructorReturn(i)):(Object.defineProperty(i,"stack",{configurable:!0,enumerable:!1,value:new Error(e).stack,writable:!0}),i)}return _inherits(a,_extendableBuiltin(Error)),a}(),es6=Object.freeze({__proto__:null,default:ExtendableError}),require$$0$1=getAugmentedNamespace(es6);Object.defineProperty(error,"__esModule",{value:!0}),error.ExtendableError=void 0;const Es6Error=require$$0$1;error.ExtendableError=Es6Error.default||Es6Error,Object.defineProperty(error$1,"__esModule",{value:!0}),error$1.HttpError=error$1.ArangoError=error$1.isSystemError=error$1.isArangoErrorResponse=error$1.isArangoError=void 0;const error_1$5=error,messages={0:"Network Error",400:"Bad Request",401:"Unauthorized",402:"Payment Required",403:"Forbidden",404:"Not Found",405:"Method Not Allowed",406:"Not Acceptable",407:"Proxy Authentication Required",408:"Request Timeout",409:"Conflict",410:"Gone",411:"Length Required",412:"Precondition Failed",413:"Payload Too Large",414:"Request-URI Too Long",415:"Unsupported Media Type",416:"Requested Range Not Satisfiable",417:"Expectation Failed",418:"I'm a teapot",421:"Misdirected Request",422:"Unprocessable Entity",423:"Locked",424:"Failed Dependency",426:"Upgrade Required",428:"Precondition Required",429:"Too Many Requests",431:"Request Header Fields Too Large",444:"Connection Closed Without Response",451:"Unavailable For Legal Reasons",499:"Client Closed Request",500:"Internal Server Error",501:"Not Implemented",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout",505:"HTTP Version Not Supported",506:"Variant Also Negotiates",507:"Insufficient Storage",508:"Loop Detected",510:"Not Extended",511:"Network Authentication Required",599:"Network Connect Timeout Error"},nativeErrorKeys=["fileName","lineNumber","columnNumber","stack","description","number"];function isArangoError(e){return Boolean(e&&e.isArangoError)}function isArangoErrorResponse(e){return e&&e.hasOwnProperty("error")&&e.hasOwnProperty("code")&&e.hasOwnProperty("errorMessage")&&e.hasOwnProperty("errorNum")}function isSystemError(e){return Object.getPrototypeOf(e)===Error.prototype&&e.hasOwnProperty("code")&&e.hasOwnProperty("errno")&&e.hasOwnProperty("syscall")}error$1.isArangoError=isArangoError,error$1.isArangoErrorResponse=isArangoErrorResponse,error$1.isSystemError=isSystemError;class ArangoError extends error_1$5.ExtendableError{constructor(e){super(),this.name="ArangoError",this.response=e,this.message=e.body.errorMessage,this.errorNum=e.body.errorNum,this.code=e.body.code;const a=new Error(this.message);a.name=this.name;for(const e of nativeErrorKeys)a[e]&&(this[e]=a[e])}get isArangoError(){return!0}toJSON(){return{error:!0,errorMessage:this.message,errorNum:this.errorNum,code:this.code}}}error$1.ArangoError=ArangoError;class HttpError extends error_1$5.ExtendableError{constructor(e){super(),this.name="HttpError",this.response=e,this.code=e.statusCode||500,this.message=messages[this.code]||messages[500];const a=new Error(this.message);a.name=this.name;for(const e of nativeErrorKeys)a[e]&&(this[e]=a[e])}toJSON(){return{error:!0,code:this.code}}}error$1.HttpError=HttpError;var codes={};Object.defineProperty(codes,"__esModule",{value:!0}),codes.GRAPH_NOT_FOUND=codes.DATABASE_NOT_FOUND=codes.VIEW_NOT_FOUND=codes.COLLECTION_NOT_FOUND=codes.DOCUMENT_NOT_FOUND=codes.ANALYZER_NOT_FOUND=codes.TRANSACTION_NOT_FOUND=void 0,codes.TRANSACTION_NOT_FOUND=10,codes.ANALYZER_NOT_FOUND=1202,codes.DOCUMENT_NOT_FOUND=1202,codes.COLLECTION_NOT_FOUND=1203,codes.VIEW_NOT_FOUND=1203,codes.DATABASE_NOT_FOUND=1228,codes.GRAPH_NOT_FOUND=1924,Object.defineProperty(analyzer,"__esModule",{value:!0}),analyzer.Analyzer=analyzer.isArangoAnalyzer=void 0;const error_1$4=error$1,codes_1$3=codes;function isArangoAnalyzer(e){return Boolean(e&&e.isArangoAnalyzer)}analyzer.isArangoAnalyzer=isArangoAnalyzer;class Analyzer{constructor(e,a){this._db=e,this._name=a}get isArangoAnalyzer(){return!0}get name(){return this._name}async exists(){try{return await this.get(),!0}catch(e){if(error_1$4.isArangoError(e)&&e.errorNum===codes_1$3.ANALYZER_NOT_FOUND)return!1;throw e}}get(){return this._db.request({path:`/_api/analyzer/${this.name}`},(e=>e.body))}create(e){return this._db.request({method:"POST",path:"/_api/analyzer",body:{name:this.name,...e}},(e=>e.body))}drop(e=!1){return this._db.request({method:"DELETE",path:`/_api/analyzer/${this.name}`,qs:{force:e}},(e=>e.body))}}analyzer.Analyzer=Analyzer;var aql={},collection={},cursor={},dist={},LinkedList$1={},LinkedListItem$1={};Object.defineProperty(LinkedListItem$1,"__esModule",{value:!0});class LinkedListItem{constructor(e,a){this.value=e,this.unlinkCleanup=a}insertBehind(e){if(e.insertBefore(this),this.behind){let a=e;for(;a.behind;)a=a.behind;this.behind.insertBefore(a),a.insertBehind(this.behind)}this.behind=e}unlink(e=!1){this.before&&(this.before.behind=this.behind),this.behind&&(this.behind.before=this.before),this.unlinkCleanup&&this.unlinkCleanup(this),this.unlinkCleanup=void 0,e&&(this.before=this.behind=void 0)}insertBefore(e){this.before=e,this.unlinkCleanup||(this.unlinkCleanup=e.unlinkCleanup)}}LinkedListItem$1.LinkedListItem=LinkedListItem,Object.defineProperty(LinkedList$1,"__esModule",{value:!0});const LinkedListItem_1=LinkedListItem$1;class LinkedList{constructor(e){if(this.length=0,this.unlinkCleanup=e=>{this.first===e&&(this.first=this.first.behind),this.last===e&&(this.last=this.last.before),this.length--},e){e instanceof LinkedList&&(e=e.values());for(const a of e)this.push(a)}}clear(e=!1){if(e)for(;this.first;)this.first.unlink(!0);this.first=this.last=void 0,this.length=0}every(e,a){a&&(e=e.bind(a));for(const a of this.keys())if(!e(a.value,a,this))return!1;return!0}filter(e,a){a&&(e=e.bind(a));const i=new LinkedList;for(const[a,n]of this)e(n,a,this)&&i.push(n);return i}find(e,a){a&&(e=e.bind(a));for(const[a,i]of this)if(e(i,a,this))return i}findItem(e,a){a&&(e=e.bind(a));for(const[a,i]of this)if(e(i,a,this))return a}forEach(e,a){a&&(e=e.bind(a));for(const[a,i]of this)e(i,a,this)}includes(e,a=0){let i=this.getItemByIndex(a);for(;i;){if(i.value===e)return!0;i=i.behind}return!1}itemOf(e,a=0){let i=this.getItemByIndex(a);for(;i;){if(i.value===e)return i;i=i.behind}}lastItemOf(e,a=-1){let i=this.getItemByIndex(a);for(;i;){if(i.value===e)return i;i=i.before}}map(e,a){a&&(e=e.bind(a));const i=new LinkedList;for(const[a,n]of this)i.push(e(n,a,this));return i}reduce(e,a){let i=this.first;if(!i){if(!a)throw new TypeError("Empty accumulator on empty LinkedList is not allowed.");return a}if(void 0===a){if(a=i.value,!i.behind)return a;i=i.behind}do{a=e(a,i.value,i,this),i=i.behind}while(i);return a}reduceRight(e,a){let i=this.last;if(!i){if(!a)throw new TypeError("Empty accumulator on empty LinkedList is not allowed.");return a}if(void 0===a){if(a=i.value,!i.before)return a;i=i.before}do{a=e(a,i.value,i,this),i=i.before}while(i);return a}some(e,a){a&&(e=e.bind(a));for(const[a,i]of this)if(e(i,a,this))return!0;return!1}join(e){return[...this.values()].join(e)}concat(...e){const a=new LinkedList(this);for(const i of e)i instanceof LinkedList?a.push(...i.values()):a.push(i);return a}pop(){if(!this.last)return;const e=this.last;return e.unlink(),e.value}push(...e){for(const a of e){const e=new LinkedListItem_1.LinkedListItem(a,this.unlinkCleanup);this.first&&this.last?(this.last.insertBehind(e),this.last=e):this.first=this.last=e,this.length++}return this.length}unshift(...e){for(const a of e){const e=new LinkedListItem_1.LinkedListItem(a,this.unlinkCleanup);this.last&&this.first?(e.insertBehind(this.first),this.first=e):this.first=this.last=e,this.length++}return this.length}remove(e){for(const a of this.keys())if(a.value===e)return a.unlink(),!0;return!1}removeAllOccurrences(e){let a=!1;for(const i of this.keys())i.value===e&&(i.unlink(),a=!0);return a}shift(){if(!this.first)return;const e=this.first;return e.unlink(),e.value}*[Symbol.iterator](){let e=this.first;if(e)do{yield[e,e.value],e=e.behind}while(e)}entries(){return this[Symbol.iterator]()}*keys(){let e=this.first;if(e)do{yield e,e=e.behind}while(e)}*values(){let e=this.first;if(e)do{yield e.value,e=e.behind}while(e)}getItemByIndex(e){if(void 0===e)throw new Error("index must be a number!");if(!this.first)return;let a;if(e>0)for(a=this.first;a&&e--;)a=a.behind;else{if(!(e<0))return this.first;for(a=this.last;a&&++e;)a=a.before}return a}}LinkedList$1.LinkedList=LinkedList,function(e){function a(a){for(var i in a)e.hasOwnProperty(i)||(e[i]=a[i])}Object.defineProperty(e,"__esModule",{value:!0}),a(LinkedList$1),a(LinkedListItem$1)}(dist),Object.defineProperty(cursor,"__esModule",{value:!0}),cursor.ArrayCursor=cursor.BatchedArrayCursor=void 0;const x3_linkedlist_1$1=dist;class BatchedArrayCursor{constructor(e,a,i,n){const o=new x3_linkedlist_1$1.LinkedList(a.result.length?[new x3_linkedlist_1$1.LinkedList(a.result)]:[]);this._db=e,this._batches=o,this._id=a.id,this._hasMore=Boolean(a.id&&a.hasMore),this._host=i,this._count=a.count,this._extra=a.extra,this._allowDirtyRead=n,this._itemsCursor=new ArrayCursor(this,{get isEmpty(){return!o.length},more:()=>this._more(),shift:()=>{var e,a;let i=null===(e=o.first)||void 0===e?void 0:e.value;for(;i&&!i.length;)o.shift(),i=null===(a=o.first)||void 0===a?void 0:a.value;if(!i)return;const n=i.shift();return i.length||o.shift(),n}})}async _more(){if(!this.hasMore)return;const e=await this._db.request({method:"PUT",path:`/_api/cursor/${this._id}`,host:this._host,allowDirtyRead:this._allowDirtyRead});this._batches.push(new x3_linkedlist_1$1.LinkedList(e.body.result)),this._hasMore=e.body.hasMore}get items(){return this._itemsCursor}get extra(){return this._extra}get count(){return this._count}get hasMore(){return this._hasMore}get hasNext(){return this.hasMore||Boolean(this._batches.length)}async*[Symbol.asyncIterator](){for(;this.hasNext;)yield this.next()}async loadAll(){for(;this._hasMore;)await this._more()}async all(){return this.map((e=>e))}async next(){for(;!this._batches.length&&this.hasNext;)await this._more();if(!this._batches.length)return;const e=this._batches.shift();if(!e)return;const a=[...e.values()];return e.clear(!0),a}async forEach(e){let a=0;for(;this.hasNext;){const i=e(await this.next(),a,this);if(a++,!1===i)return i;this.hasNext&&await this._more()}return!0}async map(e){let a=0;const i=[];for(;this.hasNext;){const n=await this.next();i.push(e(n,a,this)),a++}return i}async flatMap(e){let a=0;const i=[];for(;this.hasNext;){const n=e(await this.next(),a,this);Array.isArray(n)?i.push(...n):i.push(n),a++}return i}async reduce(e,a){let i=0;if(!this.hasNext)return a;void 0===a&&(a=await this.next(),i+=1);let n=a;for(;this.hasNext;){n=e(n,await this.next(),i,this),i++}return n}async kill(){if(this._batches.length){for(const e of this._batches.values())e.clear();this._batches.clear()}if(this.hasNext)return this._db.request({method:"DELETE",path:`/_api/cursor/${this._id}`},(()=>{this._hasMore=!1}))}}cursor.BatchedArrayCursor=BatchedArrayCursor;class ArrayCursor{constructor(e,a){this._batches=e,this._view=a}get batches(){return this._batches}get extra(){return this.batches.extra}get count(){return this.batches.count}get hasNext(){return this.batches.hasNext}async*[Symbol.asyncIterator](){for(;this.hasNext;)yield this.next()}async all(){return this.batches.flatMap((e=>e))}async next(){for(;this._view.isEmpty&&this.batches.hasMore;)await this._view.more();if(!this._view.isEmpty)return this._view.shift()}async forEach(e){let a=0;for(;this.hasNext;){const i=e(await this.next(),a,this);if(a++,!1===i)return i}return!0}async map(e){let a=0;const i=[];for(;this.hasNext;){const n=await this.next();i.push(e(n,a,this)),a++}return i}async flatMap(e){let a=0;const i=[];for(;this.hasNext;){const n=e(await this.next(),a,this);Array.isArray(n)?i.push(...n):i.push(n),a++}return i}async reduce(e,a){let i=0;if(!this.hasNext)return a;if(void 0===a){a=await this.next(),i+=1}let n=a;for(;this.hasNext;){n=e(n,await this.next(),i,this),i++}return n}async kill(){return this.batches.kill()}}cursor.ArrayCursor=ArrayCursor;var documents={};function _documentHandle(e,a,i=!0){if("string"!=typeof e){if(e._id)return _documentHandle(e._id,a);if(e._key)return _documentHandle(e._key,a);throw new Error("Document handle must be a string or an object with a _key or _id attribute")}if(e.includes("/")){if(i&&!e.startsWith(`${a}/`))throw new Error(`Document ID "${e}" does not match collection name "${a}"`);return e}return`${a}/${e}`}Object.defineProperty(documents,"__esModule",{value:!0}),documents._documentHandle=void 0,documents._documentHandle=_documentHandle;var indexes={};function _indexHandle(e,a){if("string"!=typeof e){if(e.id)return _indexHandle(e.id,a);throw new Error("Index handle must be a string or an object with an id attribute")}if(e.includes("/")){if(!e.startsWith(`${a}/`))throw new Error(`Index ID "${e}" does not match collection name "${a}"`);return e}return`${a}/${e}`}Object.defineProperty(indexes,"__esModule",{value:!0}),indexes._indexHandle=void 0,indexes._indexHandle=_indexHandle,function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Collection=e.CollectionStatus=e.CollectionType=e.collectionToString=e.isArangoCollection=void 0;const a=cursor,i=documents,n=error$1,o=indexes,s=codes;function t(e){return Boolean(e&&e.isArangoCollection)}var r,c;e.isArangoCollection=t,e.collectionToString=function(e){return t(e)?String(e.name):String(e)},(r=e.CollectionType||(e.CollectionType={}))[r.DOCUMENT_COLLECTION=2]="DOCUMENT_COLLECTION",r[r.EDGE_COLLECTION=3]="EDGE_COLLECTION",(c=e.CollectionStatus||(e.CollectionStatus={}))[c.NEWBORN=1]="NEWBORN",c[c.UNLOADED=2]="UNLOADED",c[c.LOADED=3]="LOADED",c[c.UNLOADING=4]="UNLOADING",c[c.DELETED=5]="DELETED",c[c.LOADING=6]="LOADING";e.Collection=class{constructor(e,a){this._name=a,this._db=e}_get(e,a){return this._db.request({path:`/_api/collection/${this._name}/${e}`,qs:a},(e=>e.body))}_put(e,a){return this._db.request({method:"PUT",path:`/_api/collection/${this._name}/${e}`,body:a},(e=>e.body))}get isArangoCollection(){return!0}get name(){return this._name}get(){return this._db.request({path:`/_api/collection/${this._name}`},(e=>e.body))}async exists(){try{return await this.get(),!0}catch(e){if(n.isArangoError(e)&&e.errorNum===s.COLLECTION_NOT_FOUND)return!1;throw e}}create(e){const{waitForSyncReplication:a,enforceReplicationFactor:i,...n}=e||{},o={};return"boolean"==typeof a&&(o.waitForSyncReplication=a?1:0),"boolean"==typeof i&&(o.enforceReplicationFactor=i?1:0),this._db.request({method:"POST",path:"/_api/collection",qs:o,body:{...n,name:this.name}},(e=>e.body))}properties(e){return e?this._put("properties",e):this._get("properties")}count(){return this._get("count")}async recalculateCount(){return(await this._put("recalculateCount")).result}figures(e=!1){return this._db.request({path:`/_api/collection/${this._name}/figures`,qs:{details:e}})}revision(){return this._get("revision")}checksum(e){return this._get("checksum",e)}load(e){return this._put("load","boolean"==typeof e?{count:e}:void 0)}async loadIndexes(){return(await this._put("loadIndexesIntoMemory")).result}unload(){return this._put("unload")}async rename(e){const a=await this._db.renameCollection(this._name,e);return this._name=e,a}async rotate(){return(await this._put("rotate")).result}truncate(){return this._put("truncate")}drop(e){return this._db.request({method:"DELETE",path:`/_api/collection/${this._name}`,qs:e},(e=>e.body))}getResponsibleShard(e){return this._db.request({method:"PUT",path:`/_api/collection/${this.name}/responsibleShard`,body:e},(e=>e.body.shardId))}documentId(e){return i._documentHandle(e,this._name)}async documentExists(e){try{return await this._db.request({method:"HEAD",path:`/_api/document/${i._documentHandle(e,this._name)}`},(()=>!0))}catch(e){if(404===e.code)return!1;throw e}}documents(e,a={}){const{allowDirtyRead:i}=a;return this._db.request({method:"PUT",path:`/_api/document/${this._name}`,qs:{onlyget:!0},allowDirtyRead:i,body:e},(e=>e.body))}async document(e,a={}){"boolean"==typeof a&&(a={graceful:a});const{allowDirtyRead:o,graceful:t=!1}=a,r=this._db.request({path:`/_api/document/${i._documentHandle(e,this._name)}`,allowDirtyRead:o},(e=>e.body));if(!t)return r;try{return await r}catch(e){if(n.isArangoError(e)&&e.errorNum===s.DOCUMENT_NOT_FOUND)return null;throw e}}save(e,a){return this._db.request({method:"POST",path:`/_api/document/${this._name}`,body:e,qs:a},(e=>a&&a.silent?void 0:e.body))}saveAll(e,a){return this._db.request({method:"POST",path:`/_api/document/${this._name}`,body:e,qs:a},(e=>a&&a.silent?void 0:e.body))}replace(e,a,n){return this._db.request({method:"PUT",path:`/_api/document/${i._documentHandle(e,this._name)}`,body:a,qs:n},(e=>n&&n.silent?void 0:e.body))}replaceAll(e,a){return this._db.request({method:"PUT",path:`/_api/document/${this._name}`,body:e,qs:a},(e=>a&&a.silent?void 0:e.body))}update(e,a,n){return this._db.request({method:"PATCH",path:`/_api/document/${i._documentHandle(e,this._name)}`,body:a,qs:n},(e=>n&&n.silent?void 0:e.body))}updateAll(e,a){return this._db.request({method:"PATCH",path:`/_api/document/${this._name}`,body:e,qs:a},(e=>a&&a.silent?void 0:e.body))}remove(e,a){return this._db.request({method:"DELETE",path:`/_api/document/${i._documentHandle(e,this._name)}`,qs:a},(e=>a&&a.silent?void 0:e.body))}removeAll(e,a){return this._db.request({method:"DELETE",path:`/_api/document/${this._name}`,body:e.map((e=>i._documentHandle(e,this._name))),qs:a},(e=>a&&a.silent?void 0:e.body))}import(e,a={}){const i={...a,collection:this._name};if(Array.isArray(e)){i.type=Array.isArray(e[0])?void 0:"documents";e=e.map((e=>JSON.stringify(e))).join("\r\n")+"\r\n"}return this._db.request({method:"POST",path:"/_api/import",body:e,isBinary:!0,qs:i},(e=>e.body))}_edges(e,a){return this._db.request({path:`/_api/edges/${this._name}`,qs:{direction:a,vertex:i._documentHandle(e,this._name,!1)}},(e=>e.body))}edges(e){return this._edges(e)}inEdges(e){return this._edges(e,"in")}outEdges(e){return this._edges(e,"out")}traversal(e,a){return this._db.request({method:"POST",path:"/_api/traversal",body:{...a,startVertex:e,edgeCollection:this._name}},(e=>e.body.result))}list(e="id"){return this._db.request({method:"PUT",path:"/_api/simple/all-keys",body:{type:e,collection:this._name}},(e=>new a.BatchedArrayCursor(this._db,e.body,e.arangojsHostId).items))}all(e){return this._db.request({method:"PUT",path:"/_api/simple/all",body:{...e,collection:this._name}},(e=>new a.BatchedArrayCursor(this._db,e.body,e.arangojsHostId).items))}any(){return this._db.request({method:"PUT",path:"/_api/simple/any",body:{collection:this._name}},(e=>e.body.document))}byExample(e,i){return this._db.request({method:"PUT",path:"/_api/simple/by-example",body:{...i,example:e,collection:this._name}},(e=>new a.BatchedArrayCursor(this._db,e.body,e.arangojsHostId).items))}firstExample(e){return this._db.request({method:"PUT",path:"/_api/simple/first-example",body:{example:e,collection:this._name}},(e=>e.body.document))}removeByExample(e,a){return this._db.request({method:"PUT",path:"/_api/simple/remove-by-example",body:{...a,example:e,collection:this._name}},(e=>e.body))}replaceByExample(e,a,i){return this._db.request({method:"PUT",path:"/_api/simple/replace-by-example",body:{...i,example:e,newValue:a,collection:this._name}},(e=>e.body))}updateByExample(e,a,i){return this._db.request({method:"PUT",path:"/_api/simple/update-by-example",body:{...i,example:e,newValue:a,collection:this._name}},(e=>e.body))}lookupByKeys(e){return this._db.request({method:"PUT",path:"/_api/simple/lookup-by-keys",body:{keys:e,collection:this._name}},(e=>e.body.documents))}removeByKeys(e,a){return this._db.request({method:"PUT",path:"/_api/simple/remove-by-keys",body:{options:a,keys:e,collection:this._name}},(e=>e.body))}indexes(){return this._db.request({path:"/_api/index",qs:{collection:this._name}},(e=>e.body.indexes))}index(e){return this._db.request({path:`/_api/index/${o._indexHandle(e,this._name)}`},(e=>e.body))}ensureIndex(e){return this._db.request({method:"POST",path:"/_api/index",body:e,qs:{collection:this._name}},(e=>e.body))}dropIndex(e){return this._db.request({method:"DELETE",path:`/_api/index/${o._indexHandle(e,this._name)}`},(e=>e.body))}fulltext(e,i,{index:n,...s}={}){return this._db.request({method:"PUT",path:"/_api/simple/fulltext",body:{...s,index:n?o._indexHandle(n,this._name):void 0,attribute:e,query:i,collection:this._name}},(e=>new a.BatchedArrayCursor(this._db,e.body,e.arangojsHostId).items))}}}(collection);var graph={};Object.defineProperty(graph,"__esModule",{value:!0}),graph.Graph=graph.GraphEdgeCollection=graph.GraphVertexCollection=graph.isArangoGraph=void 0;const collection_1$1=collection,documents_1=documents,error_1$3=error$1,codes_1$2=codes;function isArangoGraph(e){return Boolean(e&&e.isArangoGraph)}function mungeGharialResponse(e,a){const{new:i,old:n,[a]:o,...s}=e,t={...s,...o};return void 0!==i&&(t.new=i),void 0!==n&&(t.old=n),t}function coerceEdgeDefinition(e){const a={};return a.collection=collection_1$1.collectionToString(e.collection),a.from=Array.isArray(e.from)?e.from.map(collection_1$1.collectionToString):[collection_1$1.collectionToString(e.from)],a.to=Array.isArray(e.to)?e.to.map(collection_1$1.collectionToString):[collection_1$1.collectionToString(e.to)],a}graph.isArangoGraph=isArangoGraph;class GraphVertexCollection{constructor(e,a,i){this._db=e,this._name=a,this._graph=i,this._collection=e.collection(a)}get isArangoCollection(){return!0}get name(){return this._name}get collection(){return this._collection}get graph(){return this._graph}async vertexExists(e){try{return await this._db.request({method:"HEAD",path:`/_api/gharial/${this.graph.name}/vertex/${documents_1._documentHandle(e,this._name)}`},(()=>!0))}catch(e){if(404===e.code)return!1;throw e}}async vertex(e,a={}){"boolean"==typeof a&&(a={graceful:a});const{allowDirtyRead:i,graceful:n=!1,rev:o,...s}=a,t={};o&&(t["if-match"]=o);const r=this._db.request({path:`/_api/gharial/${this.graph.name}/vertex/${documents_1._documentHandle(e,this._name)}`,headers:t,qs:s,allowDirtyRead:i},(e=>e.body.vertex));if(!n)return r;try{return await r}catch(e){if(error_1$3.isArangoError(e)&&e.errorNum===codes_1$2.DOCUMENT_NOT_FOUND)return null;throw e}}save(e,a){return this._db.request({method:"POST",path:`/_api/gharial/${this.graph.name}/vertex/${this._name}`,body:e,qs:a},(e=>mungeGharialResponse(e.body,"vertex")))}replace(e,a,i={}){"string"==typeof i&&(i={rev:i});const{rev:n,...o}=i,s={};return n&&(s["if-match"]=n),this._db.request({method:"PUT",path:`/_api/gharial/${this.graph.name}/vertex/${documents_1._documentHandle(e,this._name)}`,body:a,qs:o,headers:s},(e=>mungeGharialResponse(e.body,"vertex")))}update(e,a,i={}){"string"==typeof i&&(i={rev:i});const n={},{rev:o,...s}=i;return o&&(n["if-match"]=o),this._db.request({method:"PATCH",path:`/_api/gharial/${this.graph.name}/vertex/${documents_1._documentHandle(e,this._name)}`,body:a,qs:s,headers:n},(e=>mungeGharialResponse(e.body,"vertex")))}remove(e,a={}){"string"==typeof a&&(a={rev:a});const i={},{rev:n,...o}=a;return n&&(i["if-match"]=n),this._db.request({method:"DELETE",path:`/_api/gharial/${this.graph.name}/vertex/${documents_1._documentHandle(e,this._name)}`,qs:o,headers:i},(e=>mungeGharialResponse(e.body,"removed")))}}graph.GraphVertexCollection=GraphVertexCollection;class GraphEdgeCollection{constructor(e,a,i){this._db=e,this._name=a,this._graph=i,this._collection=e.collection(a)}get isArangoCollection(){return!0}get name(){return this._name}get collection(){return this._collection}get graph(){return this._graph}async edgeExists(e){try{return await this._db.request({method:"HEAD",path:`/_api/gharial/${this.graph.name}/edge/${documents_1._documentHandle(e,this._name)}`},(()=>!0))}catch(e){if(404===e.code)return!1;throw e}}async edge(e,a={}){"boolean"==typeof a&&(a={graceful:a});const{allowDirtyRead:i,graceful:n=!1,rev:o,...s}=a,t=this._db.request({path:`/_api/gharial/${this.graph.name}/edge/${documents_1._documentHandle(e,this._name)}`,qs:s,allowDirtyRead:i},(e=>e.body.edge));if(!n)return t;try{return await t}catch(e){if(error_1$3.isArangoError(e)&&e.errorNum===codes_1$2.DOCUMENT_NOT_FOUND)return null;throw e}}save(e,a){return this._db.request({method:"POST",path:`/_api/gharial/${this.graph.name}/edge/${this._name}`,body:e,qs:a},(e=>mungeGharialResponse(e.body,"edge")))}replace(e,a,i={}){"string"==typeof i&&(i={rev:i});const{rev:n,...o}=i,s={};return n&&(s["if-match"]=n),this._db.request({method:"PUT",path:`/_api/gharial/${this.graph.name}/edge/${documents_1._documentHandle(e,this._name)}`,body:a,qs:o,headers:s},(e=>mungeGharialResponse(e.body,"edge")))}update(e,a,i={}){"string"==typeof i&&(i={rev:i});const{rev:n,...o}=i,s={};return n&&(s["if-match"]=n),this._db.request({method:"PATCH",path:`/_api/gharial/${this.graph.name}/edge/${documents_1._documentHandle(e,this._name)}`,body:a,qs:o,headers:s},(e=>mungeGharialResponse(e.body,"edge")))}remove(e,a={}){"string"==typeof a&&(a={rev:a});const{rev:i,...n}=a,o={};return i&&(o["if-match"]=i),this._db.request({method:"DELETE",path:`/_api/gharial/${this.graph.name}/edge/${documents_1._documentHandle(e,this._name)}`,qs:n,headers:o},(e=>mungeGharialResponse(e.body,"removed")))}}graph.GraphEdgeCollection=GraphEdgeCollection;class Graph{constructor(e,a){this._name=a,this._db=e}get isArangoGraph(){return!0}get name(){return this._name}async exists(){try{return await this.get(),!0}catch(e){if(error_1$3.isArangoError(e)&&e.errorNum===codes_1$2.GRAPH_NOT_FOUND)return!1;throw e}}get(){return this._db.request({path:`/_api/gharial/${this._name}`},(e=>e.body.graph))}create(e,a){const{orphanCollections:i,waitForSync:n,isSmart:o,isDisjoint:s,...t}=a||{};return this._db.request({method:"POST",path:"/_api/gharial",body:{orphanCollections:i&&(Array.isArray(i)?i.map(collection_1$1.collectionToString):[collection_1$1.collectionToString(i)]),edgeDefinitions:e.map(coerceEdgeDefinition),isSmart:o,isDisjoint:s,name:this._name,options:t},qs:{waitForSync:n}},(e=>e.body.graph))}drop(e=!1){return this._db.request({method:"DELETE",path:`/_api/gharial/${this._name}`,qs:{dropCollections:e}},(e=>e.body.removed))}vertexCollection(e){return collection_1$1.isArangoCollection(e)&&(e=e.name),new GraphVertexCollection(this._db,e,this)}listVertexCollections(){return this._db.request({path:`/_api/gharial/${this._name}/vertex`},(e=>e.body.collections))}async vertexCollections(){return(await this.listVertexCollections()).map((e=>new GraphVertexCollection(this._db,e,this)))}addVertexCollection(e){return collection_1$1.isArangoCollection(e)&&(e=e.name),this._db.request({method:"POST",path:`/_api/gharial/${this._name}/vertex`,body:{collection:e}},(e=>e.body.graph))}removeVertexCollection(e,a=!1){return collection_1$1.isArangoCollection(e)&&(e=e.name),this._db.request({method:"DELETE",path:`/_api/gharial/${this._name}/vertex/${e}`,qs:{dropCollection:a}},(e=>e.body.graph))}edgeCollection(e){return collection_1$1.isArangoCollection(e)&&(e=e.name),new GraphEdgeCollection(this._db,e,this)}listEdgeCollections(){return this._db.request({path:`/_api/gharial/${this._name}/edge`},(e=>e.body.collections))}async edgeCollections(){return(await this.listEdgeCollections()).map((e=>new GraphEdgeCollection(this._db,e,this)))}addEdgeDefinition(e){return this._db.request({method:"POST",path:`/_api/gharial/${this._name}/edge`,body:coerceEdgeDefinition(e)},(e=>e.body.graph))}replaceEdgeDefinition(e,a){return a||(e=(a=e).collection),collection_1$1.isArangoCollection(e)&&(e=e.name),this._db.request({method:"PUT",path:`/_api/gharial/${this._name}/edge/${e}`,body:coerceEdgeDefinition(a)},(e=>e.body.graph))}removeEdgeDefinition(e,a=!1){return collection_1$1.isArangoCollection(e)&&(e=e.name),this._db.request({method:"DELETE",path:`/_api/gharial/${this._name}/edge/${e}`,qs:{dropCollection:a}},(e=>e.body.graph))}traversal(e,a){return this._db.request({method:"POST",path:"/_api/traversal",body:{...a,startVertex:e,graphName:this._name}},(e=>e.body.result))}}graph.Graph=Graph;var view={};!function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.View=e.isArangoView=e.ViewType=void 0;const a=error$1,i=codes;var n;!function(e){e.ARANGOSEARCH_VIEW="arangosearch"}(n=e.ViewType||(e.ViewType={})),e.isArangoView=function(e){return Boolean(e&&e.isArangoView)};e.View=class{constructor(e,a){this._db=e,this._name=a}get isArangoView(){return!0}get name(){return this._name}get(){return this._db.request({path:`/_api/view/${this.name}`},(e=>e.body))}async exists(){try{return await this.get(),!0}catch(e){if(a.isArangoError(e)&&e.errorNum===i.VIEW_NOT_FOUND)return!1;throw e}}create(e){return this._db.request({method:"POST",path:"/_api/view",body:{type:n.ARANGOSEARCH_VIEW,...e||{},name:this.name}},(e=>e.body))}async rename(e){const a=this._db.renameView(this._name,e);return this._name=e,a}properties(){return this._db.request({path:`/_api/view/${this.name}/properties`},(e=>e.body))}updateProperties(e){return this._db.request({method:"PATCH",path:`/_api/view/${this.name}/properties`,body:e||{}},(e=>e.body))}replaceProperties(e){return this._db.request({method:"PUT",path:`/_api/view/${this.name}/properties`,body:e||{}},(e=>e.body))}drop(){return this._db.request({method:"DELETE",path:`/_api/view/${this.name}`},(e=>e.body.result))}}}(view),function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.aql=e.isAqlLiteral=e.isGeneratedAqlQuery=e.isAqlQuery=void 0;const a=collection,i=graph,n=view;function o(e){return Boolean(e&&"string"==typeof e.query&&e.bindVars)}function s(e){return o(e)&&"function"==typeof e._source}function t(e){return Boolean(e&&"function"==typeof e.toAQL)}function r(e,...o){const r=[...e],c={},p=[];let l=r[0];for(let e=0;e<o.length;e++){const u=o[e];let d=u;if(s(u)){const a=u._source();a.args.length?(l+=a.strings[0],o.splice(e,1,...a.args),r.splice(e,2,r[e]+a.strings[0],...a.strings.slice(1,a.args.length),a.strings[a.args.length]+r[e+1])):(l+=u.query+r[e+1],o.splice(e,1),r.splice(e,2,r[e]+u.query+r[e+1])),e-=1;continue}if(void 0===u){l+=r[e+1];continue}if(t(u)){l+=`${u.toAQL()}${r[e+1]}`;continue}const m=p.indexOf(u),x=-1!==m;let f=`value${x?m:p.length}`;(a.isArangoCollection(u)||i.isArangoGraph(u)||n.isArangoView(u))&&(f=`@${f}`,d=u.name),x||(p.push(u),c[f]=d),l+=`@${f}${r[e+1]}`}return{query:l,bindVars:c,_source:()=>({strings:r,args:o})}}e.isAqlQuery=o,e.isGeneratedAqlQuery=s,e.isAqlLiteral=t,e.aql=r,function(e){e.literal=function(e){return t(e)?e:{toAQL:()=>void 0===e?"":String(e)}},e.join=function(a,i=" "){return a.length?1===a.length?e`${a[0]}`:e(["",...Array(a.length-1).fill(i),""],...a):e``}}(r=e.aql||(e.aql={}))}(aql);var connection={},btoa$1={};function btoa(e){return Buffer.from(e).toString("base64")}Object.defineProperty(btoa$1,"__esModule",{value:!0}),btoa$1.btoa=void 0,btoa$1.btoa=btoa;var normalizeUrl$1={};function normalizeUrl(e){const a=e.match(/^(tcp|ssl|tls)((?::|\+).+)/);a&&(e=("tcp"===a[1]?"http":"https")+a[2]);const i=e.match(/^(?:(http|https)\+)?unix:\/\/(\/.+)/);return i&&(e=`${i[1]||"http"}://unix:${i[2]}`),e}Object.defineProperty(normalizeUrl$1,"__esModule",{value:!0}),normalizeUrl$1.normalizeUrl=void 0,normalizeUrl$1.normalizeUrl=normalizeUrl;var request={},request_node={},joinPath={};Object.defineProperty(joinPath,"__esModule",{value:!0}),joinPath.joinPath=void 0;const path_1=require$$0__default.default;joinPath.joinPath=path_1.posix.join;var omit$1={};function omit(e,a){const i={};for(const n of Object.keys(e))a.includes(n)||(i[n]=e[n]);return i}Object.defineProperty(omit$1,"__esModule",{value:!0}),omit$1.omit=void 0,omit$1.omit=omit,Object.defineProperty(request_node,"__esModule",{value:!0}),request_node.createRequest=request_node.isBrowser=void 0;const http_1=require$$0__default$1.default,https_1=require$$1__default.default,url_1=require$$2__default.default,btoa_1$1=btoa$1,joinPath_1=joinPath,omit_1=omit$1;function createRequest(e,a,i){const n=url_1.parse(e);if(!n.protocol)throw new Error(`Invalid URL (no protocol): ${e}`);const o="https:"===n.protocol;let s;if(e.startsWith(`${n.protocol}//unix:`)){if(!n.pathname)throw new Error(`Unix socket URL must be in the format http://unix:/socket/path, http+unix:///socket/path or unix:///socket/path not ${e}`);const a=n.pathname.indexOf(":");-1===a?(s=n.pathname,delete n.pathname):(s=n.pathname.slice(0,a),n.pathname=n.pathname.slice(a+1),""===n.pathname&&delete n.pathname)}if(s&&!s.replace(/\//g,"").length)throw new Error(`Invalid URL (empty unix socket path): ${e}`);if(!i){const e=omit_1.omit(a,["before","after"]);i=o?new https_1.Agent(e):new http_1.Agent(e)}return Object.assign((function({method:e,url:t,headers:r,body:c,timeout:p},l){let u=n.pathname?t.pathname?joinPath_1.joinPath(n.pathname,t.pathname):n.pathname:t.pathname;const d=t.search?n.search?`${n.search}&${t.search.slice(1)}`:t.search:n.search;d&&(u+=d),c&&!r["content-length"]&&(r["content-length"]=String(Buffer.byteLength(c))),r.authorization||(r.authorization=`Basic ${btoa_1$1.btoa(n.auth||"root:")}`);const m={path:u,method:e,headers:r,agent:i};s?m.socketPath=s:(m.host=n.hostname,m.port=n.port);let x=!1;try{const e=(o?https_1.request:http_1.request)(m,(i=>{const n=[];i.on("data",(e=>n.push(e))),i.on("end",(()=>{const o=i;o.request=e,o.body=Buffer.concat(n),x||(x=!0,a.after&&a.after(null,o),l(null,o))}))}));p&&e.setTimeout(p),e.on("timeout",(()=>{e.abort()})),e.on("error",(i=>{const n=i;n.request=e,x||(x=!0,a.after&&a.after(n),l(n))})),c&&e.write(c),a.before&&a.before(e),e.end()}catch(e){if(x)return;x=!0,setTimeout((()=>{l(e)}),0)}}),{close(){i.destroy()}})}var exports,__createBinding,__exportStar;request_node.isBrowser=!1,request_node.createRequest=createRequest,exports=request,__createBinding=commonjsGlobal&&commonjsGlobal.__createBinding||(Object.create?function(e,a,i,n){void 0===n&&(n=i),Object.defineProperty(e,n,{enumerable:!0,get:function(){return a[i]}})}:function(e,a,i,n){void 0===n&&(n=i),e[n]=a[i]}),__exportStar=commonjsGlobal&&commonjsGlobal.__exportStar||function(e,a){for(var i in e)"default"===i||a.hasOwnProperty(i)||__createBinding(a,e,i)},Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(request_node,exports),Object.defineProperty(connection,"__esModule",{value:!0}),connection.Connection=connection.isArangoConnection=void 0;const querystring_1=require$$0__default$2.default,x3_linkedlist_1=dist,error_1$2=error$1,btoa_1=btoa$1,normalizeUrl_1=normalizeUrl$1,request_1=request,MIME_JSON=/\/(json|javascript)(\W|$)/,LEADER_ENDPOINT_HEADER="x-arango-endpoint";function clean(e){const a={};for(const i of Object.keys(e)){const n=e[i];void 0!==n&&(a[i]=n)}return a}function isBearerAuth(e){return e.hasOwnProperty("token")}function generateStackTrace(){let e=new Error;if(!e.stack)try{throw e}catch(a){e=a}return e}function isArangoConnection(e){return Boolean(e&&e.isArangoConnection)}connection.isArangoConnection=isArangoConnection;class Connection{constructor(e={}){var a,i;this._activeTasks=0,this._arangoVersion=30400,this._queue=new x3_linkedlist_1.LinkedList,this._databases=new Map,this._hosts=[],this._urls=[],this._transactionId=null;const n=e.url?Array.isArray(e.url)?e.url:[e.url]:["http://localhost:8529"],o=3*("ROUND_ROBIN"===e.loadBalancingStrategy?n.length:1);void 0!==e.arangoVersion&&(this._arangoVersion=e.arangoVersion),this._agent=e.agent,this._agentOptions=request_1.isBrowser?{maxSockets:o,...e.agentOptions}:{maxSockets:o,keepAlive:!0,keepAliveMsecs:1e3,scheduling:"lifo",...e.agentOptions},this._maxTasks=this._agentOptions.maxSockets,this._headers={...e.headers},this._loadBalancingStrategy=null!==(a=e.loadBalancingStrategy)&&void 0!==a?a:"NONE",this._useFailOver="ROUND_ROBIN"!==this._loadBalancingStrategy,this._precaptureStackTraces=Boolean(e.precaptureStackTraces),!1===e.maxRetries?(this._shouldRetry=!1,this._maxRetries=0):(this._shouldRetry=!0,this._maxRetries=null!==(i=e.maxRetries)&&void 0!==i?i:0),this.addToHostList(n),e.auth&&(isBearerAuth(e.auth)?this.setBearerAuth(e.auth):this.setBasicAuth(e.auth)),"ONE_RANDOM"===this._loadBalancingStrategy?(this._activeHost=Math.floor(Math.random()*this._hosts.length),this._activeDirtyHost=Math.floor(Math.random()*this._hosts.length)):(this._activeHost=0,this._activeDirtyHost=0)}get isArangoConnection(){return!0}_runQueue(){if(!this._queue.length||this._activeTasks>=this._maxTasks)return;const e=this._queue.shift();let a=this._activeHost;void 0!==e.host?a=e.host:e.allowDirtyRead?(a=this._activeDirtyHost,this._activeDirtyHost=(this._activeDirtyHost+1)%this._hosts.length,e.options.headers["x-arango-allow-dirty-read"]="true"):"ROUND_ROBIN"===this._loadBalancingStrategy&&(this._activeHost=(this._activeHost+1)%this._hosts.length),this._activeTasks+=1;const i=(i,n)=>{if(this._activeTasks-=1,i)!e.allowDirtyRead&&this._hosts.length>1&&this._activeHost===a&&this._useFailOver&&(this._activeHost=(this._activeHost+1)%this._hosts.length),!e.host&&this._shouldRetry&&e.retries<(this._maxRetries||this._hosts.length-1)&&error_1$2.isSystemError(i)&&"connect"===i.syscall&&"ECONNREFUSED"===i.code?(e.retries+=1,this._queue.push(e)):(e.stack&&(i.stack+=e.stack()),e.reject(i));else{const i=n;if(503===i.statusCode&&i.headers[LEADER_ENDPOINT_HEADER]){const n=i.headers[LEADER_ENDPOINT_HEADER],[o]=this.addToHostList(n);e.host=o,this._activeHost===a&&(this._activeHost=o),this._queue.push(e)}else i.arangojsHostId=a,e.resolve(i)}this._runQueue()};try{this._hosts[a](e.options,i)}catch(e){i(e)}}_buildUrl({basePath:e,path:a,qs:i}){const n=`${e||""}${a||""}`;let o;return i&&(o="string"==typeof i?`?${i}`:`?${querystring_1.stringify(clean(i))}`),o?{pathname:n,search:o}:{pathname:n}}setBearerAuth(e){this.setHeader("authorization",`Bearer ${e.token}`)}setBasicAuth(e){this.setHeader("authorization",`Basic ${btoa_1.btoa(`${e.username}:${e.password}`)}`)}database(e,a){if(null!==a)return a?(this._databases.set(e,a),a):this._databases.get(e);this._databases.delete(e)}addToHostList(e){const a=(Array.isArray(e)?e:[e]).map((e=>normalizeUrl_1.normalizeUrl(e))),i=a.filter((e=>-1===this._urls.indexOf(e)));return this._urls.push(...i),this._hosts.push(...i.map((e=>request_1.createRequest(e,this._agentOptions,this._agent)))),a.map((e=>this._urls.indexOf(e)))}setTransactionId(e){this._transactionId=e}clearTransactionId(){this._transactionId=null}setHeader(e,a){null===a?delete this._headers[e]:this._headers[e]=a}close(){for(const e of this._hosts)e.close&&e.close()}async waitForPropagation(e,a=1/0){const i=this._hosts.length,n=[],o=Date.now();let s=0;for(;;){if(n.length===i)return;for(;n.includes(s);)s=(s+1)%i;try{await this.request({...e,host:s})}catch(e){if(o+a<Date.now())throw e;await new Promise((e=>setTimeout(e,1e3)));continue}n.includes(s)||n.push(s)}}request({host:e,method:a="GET",body:i,expectBinary:n=!1,isBinary:o=!1,allowDirtyRead:s=!1,timeout:t=0,headers:r,...c},p){return new Promise(((l,u)=>{let d="text/plain";o?d="application/octet-stream":i&&("object"==typeof i?(i=JSON.stringify(i),d="application/json"):i=String(i));const m={...this._headers,"content-type":d,"x-arango-version":String(this._arangoVersion)};this._transactionId&&(m["x-arango-trx-id"]=this._transactionId);const x={retries:0,host:e,allowDirtyRead:s,options:{url:this._buildUrl(c),headers:{...m,...r},timeout:t,method:a,expectBinary:n,body:i},reject:u,resolve:e=>{const a=e.headers["content-type"];let i;if(e.body.length&&a&&a.match(MIME_JSON))try{i=e.body,i=JSON.parse(i)}catch(a){if(!n)return"string"!=typeof i&&(i=e.body.toString("utf-8")),a.response=e,x.stack&&(a.stack+=x.stack()),void u(a)}else i=e.body&&!n?e.body.toString("utf-8"):e.body;if(error_1$2.isArangoErrorResponse(i)){e.body=i;const a=new error_1$2.ArangoError(e);x.stack&&(a.stack+=x.stack()),u(a)}else if(e.statusCode&&e.statusCode>=400){e.body=i;const a=new error_1$2.HttpError(e);x.stack&&(a.stack+=x.stack()),u(a)}else n||(e.body=i),l(p?p(e):e)}};if(this._precaptureStackTraces)if("function"==typeof Error.captureStackTrace){const e={};Error.captureStackTrace(e),x.stack=()=>`\n${e.stack.split("\n").slice(3).join("\n")}`}else{const e=generateStackTrace();Object.prototype.hasOwnProperty.call(e,"stack")&&(x.stack=()=>`\n${e.stack.split("\n").slice(4).join("\n")}`)}this._queue.push(x),this._runQueue()}))}}connection.Connection=Connection;var multipart={},main$1={exports:{}};const{Readable:Readable$1}=require$$0__default$3.default,{ClientRequest:ClientRequest}=require$$0__default$1.default,{basename:basename$1}=require$$0__default.default,DEFAULT_PREFIX="MultipartBoundary";function isString$4(e){return"string"==typeof e}function isNumber$1(e){return"number"==typeof e}function isBuffer$5(e){return Buffer.isBuffer(e)||e instanceof Uint8Array||e instanceof ArrayBuffer}function isStream$4(e){return"object"==typeof e&&"function"==typeof e.pipe&&!1!==e.readable&&"function"==typeof e._read&&!e.closed&&!e.destroyed}function isHTTPStream$2(e){return e&&e instanceof ClientRequest}function isPromise$1(e){return("object"==typeof e||"function"==typeof e)&&"function"==typeof e.then}function isVinyl$2(e){return e&&!0===e._isVinyl}function toStreamable$1(e){if(isNumber$1(e))return String(e);if(!e||isString$4(e)||isBuffer$5(e)||isStream$4(e)||isPromise$1(e))return e;if(isHTTPStream$2(e))return new Promise(((a,i)=>{e.on("response",a).end(),e.on("error",i)}));const a=(new Readable$1).wrap(e);return e.destroy&&(a.destroy=e.destroy.bind(e)),a}function getFileName$1(e,{name:a,ext:i}){const n=e.filename||e.path;return n?basename$1(n):`${a}.${i}`}function getContentType$1(e,{type:a}){return e.contentType||a}function genBoundary$1(e=DEFAULT_PREFIX){let a=`--${e}`;for(let e=0;e<12;e++)a+=Math.floor(10*Math.random()).toString(16);return a}var helpers={isArray:Array.isArray,isString:isString$4,isNumber:isNumber$1,isBuffer:isBuffer$5,isStream:isStream$4,isHTTPStream:isHTTPStream$2,isPromise:isPromise$1,isVinyl:isVinyl$2,toStreamable:toStreamable$1,getFileName:getFileName$1,getContentType:getContentType$1,genBoundary:genBoundary$1};const{Readable:Readable}=require$$0__default$3.default,{toStreamable:toStreamable,isPromise:isPromise,isBuffer:isBuffer$4,isString:isString$3}=helpers,current=Symbol("current"),queue=Symbol("queue"),forwarding=Symbol("forwarding"),next$2=Symbol("next"),forward=Symbol("forward"),nextStream=Symbol("nextStream");class CombinedStream$1 extends Readable{constructor(){super(),this.destroyed=!1,this._drained=!1,this[forwarding]=!1,this[current]=null,this[queue]=[]}static get symbols(){return{current:current,queue:queue,forwarding:forwarding,next:next$2,forward:forward,nextStream:nextStream}}_append(...e){this[queue].push(...e.map((e=>toStreamable(e))))}_read(){this._drained=!0,this[forward]()}[forward](){if(this[forwarding]||!this._drained||!this[current])return;this[forwarding]=!0;let e=this[current].read();for(;null!==e;)this._drained=this.push(e),e=this[current].read();this[forwarding]=!1}[next$2](){this[current]=null;const e=this[queue].shift();return isPromise(e)?e.then((e=>this[nextStream](toStreamable(e)))).catch((e=>this.destroy(e))):isString$3(e)||isBuffer$4(e)?(this._drained=this.push(e),this[next$2]()):void this[nextStream](e)}[nextStream](e){if(!e)return this.push(null),this.destroy();this[current]=e,this[forward]();const a=()=>this[forward](),i=e=>this.destroy(e),n=()=>{e._readableState.ended||(o(),this.destroy())},o=()=>{this[current]=null,e.removeListener("readable",a),e.removeListener("end",o),e.removeListener("error",i),e.removeListener("close",n),this[next$2]()};e.on("readable",a),e.on("error",i),e.on("close",n),e.on("end",o)}destroy(e){this.destroyed||(this.destroyed=!0,this[current]&&this[current].destroy&&this[current].destroy(),this[queue].map((e=>e.destroy&&e.destroy())),e&&this.emit("error",e),this.emit("close"))}}var combine=CombinedStream$1;const CombinedStream=combine,{isString:isString$2,isNumber:isNumber,isStream:isStream$3,isHTTPStream:isHTTPStream$1,isBuffer:isBuffer$3,isArray:isArray,isVinyl:isVinyl$1,getFileName:getFileName,getContentType:getContentType,genBoundary:genBoundary}=helpers,{next:next$1}=CombinedStream.symbols,CRLF$1="\r\n",length$1=Symbol("length"),started$1=Symbol("started"),ended$1=Symbol("ended"),stack$1=Symbol("stack"),init$1=Symbol("init"),generate$1=Symbol("generate"),defaults={name:"file",ext:"bin",type:"application/octet-stream"};class MultipartLite$1 extends CombinedStream{constructor(e={}){super(),this.opts={...e,defaults:{...defaults,...e.defaults}},this.boundary=this.opts.boundary||genBoundary(this.opts.boundaryPrefix),this.headers={"content-type":`multipart/form-data; boundary="${this.getBoundary()}"`},this[length$1]=0,this[stack$1]=[],this[started$1]=!1,this[ended$1]=!1}[init$1](){if(this[ended$1]||this[started$1])return;this[started$1]=!0;let e=this[stack$1].shift();for(;e;)this[generate$1](...e),e=this[stack$1].shift();this._append(`--${this.getBoundary()}--`,CRLF$1),this[ended$1]=!0,this[next$1]()}[generate$1](e,a,{filename:i,contentType:n}){if(this._append(`--${this.getBoundary()}${CRLF$1}`),this._append(`Content-Disposition: form-data; name="${e}"`),isBuffer$3(a)||isStream$3(a)||isHTTPStream$1(a)||isVinyl$1(a)){isVinyl$1(a)&&(i=i||a.basename,a=a.contents);const e=this.getFileName(i?{filename:i}:a,this.opts.defaults);this._append(`; filename="${e}"${CRLF$1}`);const o=this.getContentType({filename:i||e,contentType:n},this.opts.defaults);this._append(`Content-Type: ${o}${CRLF$1}`)}else this._append(CRLF$1);return this._append(CRLF$1,a,CRLF$1)}static get symbols(){return{...CombinedStream.symbols,length:length$1,started:started$1,ended:ended$1,stack:stack$1,init:init$1,generate:generate$1}}getLength(e){return e&&"function"==typeof e?e(null,this[length$1]):this[length$1]}getBoundary(){return this.boundary}getHeaders(e=!0){return e?{...this.headers,"transfer-encoding":"chunked"}:{...this.headers,"content-length":String(this.getLength())}}append(e,a,i={}){if(!e||!isNumber(e)&&!isString$2(e))throw new TypeError("Field must be specified and must be a string or a number");if(void 0===a)throw new Error("Value can't be undefined");if(isArray(a)){if(a.length){for(let n=0;n<a.length;n++)this.append(e,a[n],i);return this}a=""}return!0!==a&&!1!==a&&null!==a||(a=Number(a)),this[stack$1].push([e,a,i]),this}stream(){return this[init$1](),this}async buffer(){return new Promise(((e,a)=>{this.once("error",a);const i=[];return this.on("data",(e=>{i.push(e)})),this.on("end",(()=>{const a=Buffer.concat(i);return this[length$1]=Buffer.byteLength(a),e(a)})),this[init$1]()}))}}MultipartLite$1.prototype.getFileName=getFileName,MultipartLite$1.prototype.getContentType=getContentType;var main=MultipartLite$1,mimeKind={exports:{}},fileType$1={exports:{}},util$2={stringToBytes:e=>[...e].map((e=>e.charCodeAt(0)))};const uint8ArrayUtf8ByteString=(e,a,i)=>String.fromCharCode(...e.slice(a,i));util$2.readUInt64LE=(e,a=0)=>{let i=e[a],n=1,o=0;for(;++o<8;)n*=256,i+=e[a+o]*n;return i},util$2.tarHeaderChecksumMatches=e=>{if(e.length<512)return!1;let a=256,i=0;for(let n=0;n<148;n++){const o=e[n];a+