dbgate-plugin-redis 7.3.1 → 7.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/backend.js CHANGED
@@ -1 +1 @@
1
- (()=>{var t={994:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.firebirdSplitterOptions=e.oracleSplitterOptions=e.redisSplitterOptions=e.noSplitSplitterOptions=e.mongoSplitterOptions=e.sqliteSplitterOptions=e.postgreSplitterOptions=e.mssqlSplitterOptions=e.mysqlSplitterOptions=e.defaultSplitterOptions=void 0,e.defaultSplitterOptions={stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'},allowSemicolon:!0,allowCustomDelimiter:!1,allowCustomSqlTerminator:!1,allowCustomSetTerm:!1,allowGoDelimiter:!1,allowSlashDelimiter:!1,allowDollarDollarString:!1,noSplit:!1,skipSeparatorBeginEnd:!1,keepSemicolonInCommands:!1,doubleDashComments:!0,multilineComments:!0,javaScriptComments:!1,returnRichInfo:!1,splitByLines:!1,splitByEmptyLine:!1,preventSingleLineSplit:!1,adaptiveGoSplit:!1,ignoreComments:!1,copyFromStdin:!1,queryParameterStyle:null},e.mysqlSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowCustomDelimiter:!0,stringsBegins:["'","`",'"'],stringsEnds:{"'":"'","`":"`",'"':'"'},stringEscapes:{"'":"\\","`":"`",'"':"\\"}}),e.mssqlSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowSemicolon:!1,allowGoDelimiter:!0,keepSemicolonInCommands:!0,stringsBegins:["'","["],stringsEnds:{"'":"'","[":"]"},stringEscapes:{"'":"'"}}),e.postgreSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowDollarDollarString:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),e.sqliteSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{skipSeparatorBeginEnd:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),e.mongoSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"\\",'"':"\\"}}),e.noSplitSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{noSplit:!0}),e.redisSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{splitByLines:!0}),e.oracleSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowCustomSqlTerminator:!0,allowSlashDelimiter:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),e.firebirdSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowCustomSetTerm:!0,skipSeparatorBeginEnd:!0,queryParameterStyle:":"})},688:t=>{const{DatabaseAnalyser:e}=global.DBGATE_PACKAGES["dbgate-tools"];t.exports=class extends e{constructor(t,e){super(t,e)}}},831:(t,e,s)=>{const a=s(825),i=s(588),n=s(203),r=s(534),l=s(688),c=s(659),o=s(107),{filterName:p}=global.DBGATE_PACKAGES["dbgate-tools"];let u;function d(t){let e,s=[],a="";for(let i=0;i<t.length;)if(/\s/.test(t[i])){for(;i<t.length&&/\s/.test(t[i]);)i++;s.push(a),a="",e=!1}else if('"'!==t[i])if("'"!==t[i])"\\"!==t[i]?(e=!0,a+=t[i++]):(i++,a+=t[i++]);else{for(i++;i<t.length;){if("'"===t[i]){e=!0;break}"\\"!==t[i]||i++,a+=t[i++]}i++}else{for(i++;i<t.length;){if('"'===t[i]){e=!0;break}"\\"!==t[i]||i++,a+=t[i++]}i++}return e&&s.push(a),s}const y={...r,analyserClass:l,async connect({server:t,port:e,user:s,password:i,database:n,useDatabaseUrl:r,databaseUrl:l,treeKeySeparator:o,ssl:p,skipSetName:d,authType:y,clusterNodes:g,autoDetectNatMap:h}){let m,f=0;if(r)m=new c(l),d||await m.client("SETNAME","dbgate");else if("cluster"===y&&u&&u()){const t={user:s,password:i};let e=[];try{e=JSON.parse(g)}catch{}if(!Array.isArray(e)||0===e.length)throw new Error("Cluster nodes must be a non-empty array of host:port or objects with host and port");const a=h?await async function(t,e){const s={};return await Promise.all(t.map((async t=>{const a=new c({host:"string"==typeof t?new URL(t).hostname:t.host,port:"string"==typeof t?Number(new URL(t).port||6379):t.port,...e,lazyConnect:!1,enableReadyCheck:!1,maxRetriesPerRequest:0});try{const e=(await a.cluster("nodes")).split(/\r?\n/).find((t=>/\bmyself\b/.test(t)));if(!e)return;const i=e.split(" ")[1].split("@")[0],[n,r]=i.split(":"),l=`${n}:${Number(r)}`,c="string"==typeof t?new URL(t).hostname:t.host,o="string"==typeof t?Number(new URL(t).port||6379):t.port;s[l]={host:c,port:o}}catch{}finally{a.disconnect()}}))),s}(e,t):void 0;m=new c.Cluster(e,{redisOptions:t,natMap:a})}else{a.isString(n)&&n.startsWith("db")&&(f=parseInt(n.substring(2))),a.isNumber(n)&&(f=n),p&&(p={...a.omit(p,["rejectUnauthorized","password"]),passphrase:p.password});const r={host:t,port:e,username:s,password:i,db:f,tls:p};d||(r.connectionName="dbgate"),m=new c(r)}return{client:m,treeKeySeparator:o||":"}},async query(t,e){const s=d(e);if(s.length>=1){const e=s[0].toLowerCase(),a=s.slice(1);await t.client.call(e,...a)}return{rows:[],columns:[]}},async stream(t,e,s){const a=d(e);if(a.length<1)return void s.done();const i=a[0].toLowerCase(),n=a.slice(1),r=await t.client.call(i,...n);s.info({message:JSON.stringify(r),time:new Date,severity:"info"}),s.done()},readQuery:async(t,e,s)=>new n.PassThrough({objectMode:!0,highWaterMark:100}),async writeTable(t,e,s){return createBulkInsertStreamBase(this,n,t,e,s)},async info(t){const e=await t.client.info();return a.fromPairs(e.split("\n").filter((t=>t.trim()&&!t.trim().startsWith("#"))).map((t=>t.split(":"))))},async getVersion(t){const e=await this.info(t);return{version:e.redis_version,versionText:`Redis ${e.redis_version}`}},async listDatabases(t){const e=await this.info(t);let s=16;try{const e=await t.client.config("GET","databases");Array.isArray(e)&&e.length>=2&&(s=parseInt(e[1],10)||16)}catch{}return a.range(s).map((t=>({name:`db${t}`,extInfo:e[`db${t}`],sortOrder:t})))},async scanKeys(t,e,s=0,a){const i=e?.match(/[\?\[\{]/)?e:e?`*${e}*`:"*",[n,r]=await t.client.scan(s,"MATCH",i,"COUNT",a??2**32),l=await t.client.dbsize(),c=r.map((t=>({key:t})));return await this.enrichKeyInfo(t,c),{nextCursor:n,keys:c,dbsize:l}},async loadKeys(t,e="",s=null,i=null){const n=(await this.getKeys(t,e?`${e}${t.treeKeySeparator}*`:"*")).filter((t=>p(s,t))),r=a.sortBy(n,"text"),l=this.extractKeysFromLevel(t,e,r),c=i?l.slice(0,i):l;return await this.enrichKeyInfo(t,c),c},async exportKeys(t,e){const s=new o({client:t.client});return new Promise(((t,a)=>{s.export({type:"redis",keyPrefix:e.keyPrefix,callback:(e,s)=>{e?a(e):t(s)}})}))},async getKeys(t,e="*"){const s=t.client.scanStream({match:e,count:1e3}),a=[];return s.on("data",(t=>{for(const e of t)a.push(e)})),new Promise(((t,e)=>{s.on("end",(()=>{t(a)})),s.on("error",(t=>{e(t)}))}))},extractKeysFromLevel(t,e,s){const a=e?`${e}${t.treeKeySeparator}`:"",i=""==e?[]:e.split(t.treeKeySeparator),n={};for(const e of s){if(!e.startsWith(a))continue;const s=e.split(t.treeKeySeparator);if(s.length>i.length){const a=s[i.length];if(s.length==i.length+1)n[a]={text:a,key:e};else{const e="::"+a;n[e]?n[e].count++:n[e]={text:a+t.treeKeySeparator+"*",type:"dir",root:s.slice(0,i.length+1).join(t.treeKeySeparator),count:1}}}}return Object.values(n)},async getKeyCardinality(t,e,s){switch(s){case"list":return t.client.llen(e);case"set":return t.client.scard(e);case"zset":return t.client.zcard(e);case"stream":return t.client.xlen(e);case"hash":return t.client.hlen(e)}},async enrichKeyInfo(t,e){const s=t.client.pipeline();for(const t of e)s.type(t.key);const a=await s.exec();for(let t=0;t<a.length;t++)null==a[t][0]&&(e[t].type=a[t][1]);const i=t.client.pipeline();for(const t of e)switch(t.type){case"list":i.llen(t.key);case"set":i.scard(t.key);case"zset":i.zcard(t.key);case"stream":i.xlen(t.key);case"hash":i.hlen(t.key)}const n=await i.exec();let r=0;for(const t of e)"list"!=t.type&&"set"!=t.type&&"zset"!=t.type&&"stream"!=t.type&&"hash"!=t.type||null==n[r][0]&&(t.count=n[r][1],r++)},async loadKeyInfo(t,e){const s={},a=await t.client.type(e);switch(s.key=e,s.type=a,s.ttl=await t.client.ttl(e),s.count=await this.getKeyCardinality(t,e,a),a){case"string":s.value=await t.client.get(e);break;case"ReJSON-RL":s.type="JSON";try{const a=await t.client.call("JSON.GET",e);s.value=JSON.stringify(JSON.parse(a),null,2)}catch(t){s.value=""}}return s},async deleteBranch(t,e){const s=await this.getKeys(t,e),n=a.chunk(s,10);await i.eachLimit(n,10,(async e=>await t.client.del(...e)))},async callMethod(t,e,s){return"mdel"===e?await this.deleteBranch(t,s[0]):await t.client[e](...s)},async loadKeyTableRange(t,e,s,i){switch(await t.client.type(e)){case"list":{const a=await t.client.lrange(e,s,s+i);return{cursor:a.length>i?s+i:0,items:a.map((t=>({value:t}))).slice(0,i)}}case"set":{const a=await t.client.sscan(e,s,"COUNT",i);return{cursor:parseInt(a[0]),items:a[1].map((t=>({value:t})))}}case"zset":{const n=await t.client.zscan(e,s,"COUNT",i);return{cursor:parseInt(n[0]),items:a.chunk(n[1],2).map((t=>({member:t[0],score:t[1]})))}}case"hash":{const n=await t.client.hscan(e,s,"COUNT",i),r=a.chunk(n[1],2),l=await Promise.all(r.map((async([s,a])=>{try{const i=await t.client.call("HTTL",e,"FIELDS",1,s);return{key:s,value:a,ttl:i&&void 0!==i[0]?i[0]:null}}catch(t){return{key:s,value:a}}})));return{cursor:parseInt(n[0]),items:l}}case"stream":{const n=await t.client.xrange(e,0==s?"-":s,"+","COUNT",i);let r=0;if(n.length>0){const t=n[n.length-1][0].split("-");r=`${t[0]}-${parseInt(t[1]+1)}`}return{cursor:r,items:n.map((([t,e])=>({id:t,value:JSON.stringify(a.fromPairs(a.chunk(e,2)),void 0,2)})))}}}return null},close:async t=>t.client.quit(),getAuthTypes:()=>u&&u()?[{name:"node",title:"Single Redis node"},{name:"cluster",title:"Redis Cluster"}]:null,async invokeMethodCallList(t,e){const s=t.client.pipeline();for(const t of e.calls)s.call(t.method,...t.args);await s.exec()}};y.initialize=t=>{u=t.isProApp},t.exports=y},237:(t,e,s)=>{const a=s(831);t.exports={packageName:"dbgate-plugin-redis",drivers:[a],initialize(t){a.initialize(t)}}},197:t=>{const{SqlDumper:e}=global.DBGATE_PACKAGES["dbgate-tools"];t.exports=class extends e{}},534:(t,e,s)=>{const{driverBase:a}=global.DBGATE_PACKAGES["dbgate-tools"],{redisChangeSetToRedisCommands:i}=global.DBGATE_PACKAGES["dbgate-datalib"],{redisSplitterOptions:n}=s(994),r={...a,dumperClass:s(197),dialect:{limitSelect:!0,rangeSelect:!0,offsetFetchRangeSyntax:!0,stringEscapeChar:"'",fallbackDataType:"nvarchar(max)",quoteIdentifier:t=>`[${t}]`},engine:"redis@dbgate-plugin-redis",title:"Redis",defaultPort:6379,editorMode:"text",authTypeFirst:!0,databaseEngineTypes:["keyvalue"],supportedCreateDatabase:!1,getQuerySplitterOptions:()=>n,databaseUrlPlaceholder:"e.g. redis://:authpassword@127.0.0.1:6380/4",authTypeLabel:"Connection mode",defaultAuthTypeName:"node",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path fill="#b71c1c" d="M45,29.316c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,29.316,3,29.832,3,30.469v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,32.882,45,32.83,45,32.775V29.316z"/><path fill="#e53935" d="M20.616,39.158c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,39.792,22.048,39.798,20.616,39.158z"/><path fill="#b71c1c" d="M45,21.675c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,21.675,3,22.192,3,22.829v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,25.242,45,25.19,45,25.135V21.675z"/><path fill="#e53935" d="M20.616,31.517c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,32.152,22.048,32.158,20.616,31.517z"/><path fill="#b71c1c" d="M45,14.035c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,14.035,3,14.551,3,15.188v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,17.601,45,17.549,45,17.494V14.035z"/><path fill="#e53935" d="M20.616,23.877c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,24.512,22.048,24.517,20.616,23.877z"/><path fill="#fff" d="M18.748,14.741c-0.002,1.042-2.762,2.057-5.093,2.086c-2.419,0.03-5.273-0.993-5.282-2.051\tc-0.009-1.061,2.842-2.161,5.311-2.135C16.017,12.665,18.751,13.703,18.748,14.741z"/><path fill="#fff" d="M17.038,18.471c2.393,1.022,4.785,2.045,7.178,3.067c1.054-1.56,2.108-3.12,3.162-4.68\tC23.931,17.396,20.485,17.934,17.038,18.471z"/><path fill="#fff" d="M21.86,9.775c-1.101,0.401-2.203,0.801-3.304,1.202c1.507,0.132,3.015,0.264,4.522,0.395\tc0.48,0.796,0.959,1.592,1.439,2.387c0.295-0.722,0.59-1.444,0.885-2.166c1.286-0.1,2.572-0.2,3.858-0.3\tc-0.997-0.419-1.994-0.839-2.991-1.259c0.254-0.608,0.508-1.216,0.762-1.825c-0.97,0.29-1.939,0.58-2.909,0.87\tc-1.07-0.422-2.14-0.843-3.21-1.265C21.228,8.468,21.544,9.122,21.86,9.775z"/><path fill="#b71c1c" d="M27.267,14.619c2.271-0.906,4.543-1.813,6.814-2.719c1.962,0.834,3.924,1.668,5.886,2.502\tc-2.202,0.876-4.403,1.752-6.605,2.629C31.331,16.226,29.299,15.423,27.267,14.619z"/><path fill="#a01c1c" d="M34.082,11.963c-0.005,1.596-0.01,3.191-0.015,4.787c1.967-0.783,3.934-1.565,5.901-2.348\tC38.006,13.589,36.044,12.776,34.082,11.963z"/></svg>',showConnectionField:(t,e)=>"useDatabaseUrl"==t?"cluster"!=e.authType:"authType"==t?!e.useDatabaseUrl:e.useDatabaseUrl?["databaseUrl","isReadOnly","treeKeySeparator"].includes(t):"cluster"==e.authType?["user","password","isReadOnly","treeKeySeparator","clusterNodes","autoDetectNatMap"].includes(t):["server","port","user","password","isReadOnly","treeKeySeparator"].includes(t),getAdvancedConnectionFields:()=>[{type:"checkbox",name:"skipSetName",label:"Skip SETNAME instruction"}],getKeyValueMethodCallList:t=>i(t)};t.exports=r},588:t=>{"use strict";t.exports=require("async")},659:t=>{"use strict";t.exports=require("ioredis")},825:t=>{"use strict";t.exports=require("lodash")},107:t=>{"use strict";t.exports=require("node-redis-dump2")},203:t=>{"use strict";t.exports=require("stream")}},e={},s=function s(a){var i=e[a];if(void 0!==i)return i.exports;var n=e[a]={exports:{}};return t[a](n,n.exports,s),n.exports}(237);module.exports=s})();
1
+ (()=>{var e,t,n={994:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firebirdSplitterOptions=t.oracleSplitterOptions=t.redisSplitterOptions=t.noSplitSplitterOptions=t.mongoSplitterOptions=t.sqliteSplitterOptions=t.postgreSplitterOptions=t.mssqlSplitterOptions=t.mysqlSplitterOptions=t.defaultSplitterOptions=void 0,t.defaultSplitterOptions={stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'},allowSemicolon:!0,allowCustomDelimiter:!1,allowCustomSqlTerminator:!1,allowCustomSetTerm:!1,allowGoDelimiter:!1,allowSlashDelimiter:!1,allowDollarDollarString:!1,noSplit:!1,skipSeparatorBeginEnd:!1,keepSemicolonInCommands:!1,doubleDashComments:!0,multilineComments:!0,javaScriptComments:!1,returnRichInfo:!1,splitByLines:!1,splitByEmptyLine:!1,preventSingleLineSplit:!1,adaptiveGoSplit:!1,ignoreComments:!1,copyFromStdin:!1,queryParameterStyle:null},t.mysqlSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowCustomDelimiter:!0,stringsBegins:["'","`",'"'],stringsEnds:{"'":"'","`":"`",'"':'"'},stringEscapes:{"'":"\\","`":"`",'"':"\\"}}),t.mssqlSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowSemicolon:!1,allowGoDelimiter:!0,keepSemicolonInCommands:!0,stringsBegins:["'","["],stringsEnds:{"'":"'","[":"]"},stringEscapes:{"'":"'"}}),t.postgreSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowDollarDollarString:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),t.sqliteSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{skipSeparatorBeginEnd:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),t.mongoSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"\\",'"':"\\"}}),t.noSplitSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{noSplit:!0}),t.redisSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{splitByLines:!0}),t.oracleSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowCustomSqlTerminator:!0,allowSlashDelimiter:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),t.firebirdSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowCustomSetTerm:!0,skipSeparatorBeginEnd:!0,queryParameterStyle:":"})},688:e=>{const{DatabaseAnalyser:t}=global.DBGATE_PACKAGES["dbgate-tools"];e.exports=class extends t{constructor(e,t){super(e,t)}}},831:(e,t,n)=>{const s=n(825),r=n(588),a=n(203),i=n(534),o=n(688),c=n(659),l=n(896),u=n(982),{URL:d}=n(16),{finished:f}=n(786),{BufferDumpWriter:p,dumpRedis:h,restoreRedisDump:m}=n(244),{fromIoredis:y}=n(869),{createDumpProgressReporter:g,createRestoreProgressReporter:w,formatRedisRestoreError:b,formatRestoreCommandError:E,getRedisDumpOptions:S,getRedisRestoreOptions:v,parseDatabaseIndex:x}=n(256),{filterName:k}=global.DBGATE_PACKAGES["dbgate-tools"];let R;const C={lazyConnect:!0,enableOfflineQueue:!1,autoResendUnfulfilledCommands:!1,maxRetriesPerRequest:0,retryStrategy:()=>null};function T(e){let t,n=[],s="";for(let r=0;r<e.length;)if(/\s/.test(e[r])){for(;r<e.length&&/\s/.test(e[r]);)r++;n.push(s),s="",t=!1}else if('"'!==e[r])if("'"!==e[r])"\\"!==e[r]?(t=!0,s+=e[r++]):(r++,s+=e[r++]);else{for(r++;r<e.length;){if("'"===e[r]){t=!0;break}"\\"!==e[r]||r++,s+=e[r++]}r++}else{for(r++;r<e.length;){if('"'===e[r]){t=!0;break}"\\"!==e[r]||r++,s+=e[r++]}r++}return t&&n.push(s),n}async function O(e,t){const n=x(t);void 0!==n&&(e.client.condition?.select??e.client.options?.db??0)!==n&&await e.client.select(n)}const D={...i,analyserClass:o,async backupDatabase(e,t,n){const{outputFile:s,database:r,options:a={}}=t,i=S(a),o=`${s}.${u.randomBytes(6).toString("hex")}.part`;let c=null,d=null,p=null,m=null;const w=new AbortController,b=()=>w.abort();n.signal?.addEventListener("abort",b,{once:!0}),n.signal?.aborted&&b();try{c=await this.connect({...e,database:r,forDumper:!0}),await O(c,r),p=y(c.client),d=l.createWriteStream(o),d.on("error",(e=>{m=e,b()}));const t=await h(p,i,d,g(n),w.signal);if(t.cancelled)throw new Error("DBGM-00000 Redis backup cancelled");d.end(),await f(d),await l.promises.rename(o,s);for(const e of t.warnings)n.info({message:e.message,severity:e.severity});n.info({message:`Wrote ${t.keysExported.toLocaleString("en-US")} keys in ${t.commandsWritten.toLocaleString("en-US")} commands and ${t.bytesWritten.toLocaleString("en-US")} bytes`,severity:"info"})}catch(e){throw d&&(d.destroy(),await f(d).catch((()=>{}))),await l.promises.rm(o,{force:!0}).catch((()=>{})),m||e}finally{n.signal?.removeEventListener("abort",b),p?.detach(),c&&await this.close(c).catch((()=>{}))}},async restoreDatabase(e,t,n){const{inputFile:s,database:r,options:a={}}=t,i=v(r,a,t.restrictToDatabase);let o=null,c=null,u=null;try{o=await this.connect({...e,database:r,forDumper:!0}),await O(o,r),u=y(o.client),c=l.createReadStream(s,{highWaterMark:65536});const t=a.stopOnError??!0,d=w(n),f=await m({connection:u,source:c,signal:n.signal,options:i,progress:d});for(const e of f.warnings)n.info({message:e.message,severity:"warning"});if(f.cancelled)throw new Error("DBGM-00000 Redis restore cancelled");if(f.errors.length>0){for(const e of f.errors)d.reportedCommandIndexes.has(e.commandIndex)||n.info({message:E(e),severity:"error"});const e=f.errors.length;throw new Error(`DBGM-00000 Redis restore ${t?"stopped at":"finished with"} ${e} error${1==e?"":"s"}: ${E(f.errors[0])}`)}n.info({message:`Restored ${f.commandsExecuted.toLocaleString("en-US")} Redis commands (${f.bytesConsumed.toLocaleString("en-US")} bytes read)`,severity:"info"})}catch(e){const t=b(e);if(t)throw new Error(t,{cause:e});throw e}finally{c?.destroy(),u?.detach(),o&&await this.close(o).catch((()=>{}))}},async connect({server:e,port:t,user:n,password:r,database:a,useDatabaseUrl:i,databaseUrl:o,treeKeySeparator:l,ssl:u,skipSetName:f,authType:p,clusterNodes:h,autoDetectNatMap:m,forDumper:y=!1}){let g,w=0;const b=y?C:{};if(y&&!i&&"cluster"===p)throw new Error("DBGM-00000 Redis backup and restore do not support cluster connections");if(i){if(y){const e=new d(o);for(const t of Object.keys(b))e.searchParams.delete(t);o=e.toString()}g=new c(o,b)}else if("cluster"===p&&R&&R()){const e={user:n,password:r};let t=[];try{t=JSON.parse(h)}catch{}if(!Array.isArray(t)||0===t.length)throw new Error("Cluster nodes must be a non-empty array of host:port or objects with host and port");const s=m?await async function(e,t){const n={};return await Promise.all(e.map((async e=>{const s=new c({host:"string"==typeof e?new d(e).hostname:e.host,port:"string"==typeof e?Number(new d(e).port||6379):e.port,...t,lazyConnect:!1,enableReadyCheck:!1,maxRetriesPerRequest:0});try{const t=(await s.cluster("nodes")).split(/\r?\n/).find((e=>/\bmyself\b/.test(e)));if(!t)return;const r=t.split(" ")[1].split("@")[0],[a,i]=r.split(":"),o=`${a}:${Number(i)}`,c="string"==typeof e?new d(e).hostname:e.host,l="string"==typeof e?Number(new d(e).port||6379):e.port;n[o]={host:c,port:l}}catch{}finally{s.disconnect()}}))),n}(t,e):void 0;g=new c.Cluster(t,{redisOptions:e,natMap:s})}else{s.isString(a)&&a.startsWith("db")&&(w=parseInt(a.substring(2))),s.isNumber(a)&&(w=a),u&&(u={...s.omit(u,["rejectUnauthorized","password"]),passphrase:u.password});const i={host:e,port:t,username:n,password:r,db:w,tls:u,...b};f||(i.connectionName="dbgate"),g=new c(i)}try{y&&await g.connect(),i&&!f&&await g.client("SETNAME","dbgate")}catch(e){throw g.disconnect(),e}return{client:g,treeKeySeparator:l||":"}},async query(e,t){const n=T(t);if(n.length>=1){const t=n[0].toLowerCase(),s=n.slice(1);await e.client.call(t,...s)}return{rows:[],columns:[]}},async stream(e,t,n){const s=T(t);if(s.length<1)return void n.done();const r=s[0].toLowerCase(),a=s.slice(1),i=await e.client.call(r,...a);n.info({message:JSON.stringify(i),time:new Date,severity:"info"}),n.done()},readQuery:async(e,t,n)=>new a.PassThrough({objectMode:!0,highWaterMark:100}),async writeTable(e,t,n){return createBulkInsertStreamBase(this,a,e,t,n)},async info(e){const t=await e.client.info();return s.fromPairs(t.split("\n").filter((e=>e.trim()&&!e.trim().startsWith("#"))).map((e=>e.split(":"))))},async getVersion(e){const t=await this.info(e);return{version:t.redis_version,versionText:`Redis ${t.redis_version}`}},async listDatabases(e){const t=await this.info(e);let n=16;try{const t=await e.client.config("GET","databases");Array.isArray(t)&&t.length>=2&&(n=parseInt(t[1],10)||16)}catch{}return s.range(n).map((e=>({name:`db${e}`,extInfo:t[`db${e}`],sortOrder:e})))},async scanKeys(e,t,n=0,s){const r=t?.match(/[\?\[\{]/)?t:t?`*${t}*`:"*",[a,i]=await e.client.scan(n,"MATCH",r,"COUNT",s??2**32),o=await e.client.dbsize(),c=i.map((e=>({key:e})));return await this.enrichKeyInfo(e,c),{nextCursor:a,keys:c,dbsize:o}},async loadKeys(e,t="",n=null,r=null){const a=(await this.getKeys(e,t?`${t}${e.treeKeySeparator}*`:"*")).filter((e=>k(n,e))),i=s.sortBy(a,"text"),o=this.extractKeysFromLevel(e,t,i),c=r?o.slice(0,r):o;return await this.enrichKeyInfo(e,c),c},async exportKeys(e,t={}){if(e.client instanceof c.Cluster)throw new Error("DBGM-00000 Redis script generation does not support cluster connections");const n=e.client.duplicate({...C,db:e.client.condition?.select??e.client.options.db??0});let s=null;try{await n.connect(),s=y(n);const e=new p;return await h(s,{...S(),...t.keyPrefix?{selection:{match:`${t.keyPrefix}*`}}:{}},e),e.toString()}finally{s?.detach(),await n.quit().catch((()=>n.disconnect()))}},async getKeys(e,t="*"){const n=e.client.scanStream({match:t,count:1e3}),s=[];return n.on("data",(e=>{for(const t of e)s.push(t)})),new Promise(((e,t)=>{n.on("end",(()=>{e(s)})),n.on("error",(e=>{t(e)}))}))},extractKeysFromLevel(e,t,n){const s=t?`${t}${e.treeKeySeparator}`:"",r=""==t?[]:t.split(e.treeKeySeparator),a={};for(const t of n){if(!t.startsWith(s))continue;const n=t.split(e.treeKeySeparator);if(n.length>r.length){const s=n[r.length];if(n.length==r.length+1)a[s]={text:s,key:t};else{const t="::"+s;a[t]?a[t].count++:a[t]={text:s+e.treeKeySeparator+"*",type:"dir",root:n.slice(0,r.length+1).join(e.treeKeySeparator),count:1}}}}return Object.values(a)},async getKeyCardinality(e,t,n){switch(n){case"list":return e.client.llen(t);case"set":return e.client.scard(t);case"zset":return e.client.zcard(t);case"stream":return e.client.xlen(t);case"hash":return e.client.hlen(t)}},async enrichKeyInfo(e,t){const n=e.client.pipeline();for(const e of t)n.type(e.key);const s=await n.exec();for(let e=0;e<s.length;e++)null==s[e][0]&&(t[e].type=s[e][1]);const r=e.client.pipeline();for(const e of t)switch(e.type){case"list":r.llen(e.key);case"set":r.scard(e.key);case"zset":r.zcard(e.key);case"stream":r.xlen(e.key);case"hash":r.hlen(e.key)}const a=await r.exec();let i=0;for(const e of t)"list"!=e.type&&"set"!=e.type&&"zset"!=e.type&&"stream"!=e.type&&"hash"!=e.type||null==a[i][0]&&(e.count=a[i][1],i++)},async loadKeyInfo(e,t){const n={},s=await e.client.type(t);switch(n.key=t,n.type=s,n.ttl=await e.client.ttl(t),n.count=await this.getKeyCardinality(e,t,s),s){case"string":n.value=await e.client.get(t);break;case"ReJSON-RL":n.type="JSON";try{const s=await e.client.call("JSON.GET",t);n.value=JSON.stringify(JSON.parse(s),null,2)}catch(e){n.value=""}}return n},async deleteBranch(e,t){const n=await this.getKeys(e,t),a=s.chunk(n,10);await r.eachLimit(a,10,(async t=>await e.client.del(...t)))},async callMethod(e,t,n){return"mdel"===t?await this.deleteBranch(e,n[0]):await e.client[t](...n)},async loadKeyTableRange(e,t,n,r){switch(await e.client.type(t)){case"list":{const s=await e.client.lrange(t,n,n+r);return{cursor:s.length>r?n+r:0,items:s.map((e=>({value:e}))).slice(0,r)}}case"set":{const s=await e.client.sscan(t,n,"COUNT",r);return{cursor:parseInt(s[0]),items:s[1].map((e=>({value:e})))}}case"zset":{const a=await e.client.zscan(t,n,"COUNT",r);return{cursor:parseInt(a[0]),items:s.chunk(a[1],2).map((e=>({member:e[0],score:e[1]})))}}case"hash":{const a=await e.client.hscan(t,n,"COUNT",r),i=s.chunk(a[1],2),o=await Promise.all(i.map((async([n,s])=>{try{const r=await e.client.call("HTTL",t,"FIELDS",1,n);return{key:n,value:s,ttl:r&&void 0!==r[0]?r[0]:null}}catch(e){return{key:n,value:s}}})));return{cursor:parseInt(a[0]),items:o}}case"stream":{const a=await e.client.xrange(t,0==n?"-":n,"+","COUNT",r);let i=0;if(a.length>0){const e=a[a.length-1][0].split("-");i=`${e[0]}-${parseInt(e[1]+1)}`}return{cursor:i,items:a.map((([e,t])=>({id:e,value:JSON.stringify(s.fromPairs(s.chunk(t,2)),void 0,2)})))}}}return null},close:async e=>e.client.quit(),getAuthTypes:()=>R&&R()?[{name:"node",title:"Single Redis node"},{name:"cluster",title:"Redis Cluster"}]:null,async invokeMethodCallList(e,t){const n=e.client.pipeline();for(const e of t.calls)n.call(e.method,...e.args);await n.exec()}};D.initialize=e=>{R=e.isProApp},e.exports=D},237:(e,t,n)=>{const s=n(831);e.exports={packageName:"dbgate-plugin-redis",drivers:[s],initialize(e){s.initialize(e)}}},256:(e,t,n)=>{const{RedisDumpParseError:s}=n(244);function r(e){if("number"==typeof e)return e;if("string"==typeof e){const t=/^db(\d+)$/.exec(e);if(t)return parseInt(t[1],10)}}function a(e){switch(e.phase){case"connecting":return"Starting Redis backup";case"detecting-version":return"Detecting Redis server version";case"scanning":return`Scanning db${e.database}${void 0===e.keysEstimated?"":` (${e.keysEstimated.toLocaleString("en-US")} keys)`}`;case"exporting-keys":return e.keyName?`Exporting key ${e.keyName}`:`Exported ${(e.totalKeysExported||0).toLocaleString("en-US")} keys, ${(e.bytesWritten||0).toLocaleString("en-US")} bytes`;case"finalizing":return`Finalizing Redis dump (${(e.bytesWritten||0).toLocaleString("en-US")} bytes)`;default:return null}}function i(e){const t=e.location;return[`Command ${e.commandIndex+1} failed`,t?.line?`at line ${t.line}`:t&&`at byte ${t.offset}`,"refused"==e.kind&&"(refused)",e.serverError?.prefix&&`Redis ${e.serverError.prefix}:`,e.serverError?.message||e.message,e.commandPreview&&`Command: ${e.commandPreview}`].filter(Boolean).join(" ")}e.exports={createDumpProgressReporter:function(e){let t=0;return n=>{const s=Date.now();if("exporting-keys"==n.phase&&!n.keyName){if(s-t<750)return;t=s}const r=a(n);r&&e.info({message:r,severity:"info"})}},createRestoreProgressReporter:function(e){const t=new Set;let n=0;const s=s=>{if(s.error)return t.add(s.error.commandIndex),void e.info({message:i(s.error),severity:"error"});if("connecting"==s.phase)return void e.info({message:"Starting Redis restore",severity:"info"});if("finalizing"==s.phase)return void e.info({message:"Finalizing Redis restore",severity:"info"});const r=Date.now();"executing"==s.phase&&r-n>=750&&(n=r,e.info({message:`Executed ${(s.commandsProcessed||0).toLocaleString("en-US")} commands (${(s.bytesConsumed||0).toLocaleString("en-US")} bytes read)`,severity:"info"}))};return s.reportedCommandIndexes=t,s},formatDumpProgress:a,formatRedisRestoreError:function(e){if(e instanceof s){const t=e.location;return`DBGM-00000 ${e.message}${t?.line?` (line ${t.line})`:t?` (byte ${t.offset})`:""}`}return null},formatRestoreCommandError:i,getRedisDumpOptions:function(e={}){const t="resp"==e.format?"resp":"text",n=e.keyPattern?.trim();return{format:t,databases:e.allDatabases?"all":"current",...n&&"*"!=n?{selection:{match:n}}:{},strategy:"payload"==e.strategy?"payload":"commands",expiration:["relative","none"].includes(e.expiration)?e.expiration:"absolute",replace:!1!==e.replace,streamGroups:!1!==e.streamGroups,header:!0}},getRedisRestoreOptions:function(e,t={},n=!1){const s={stopOnError:t.stopOnError??!0};if(!n)return s;const a=r(e);if(!Number.isSafeInteger(a)||a<0)throw new Error("DBGM-00000 A valid target database is required for restricted Redis restore");return{...s,database:a,databaseMapping:()=>a}},parseDatabaseIndex:r}},197:e=>{const{SqlDumper:t}=global.DBGATE_PACKAGES["dbgate-tools"];e.exports=class extends t{}},534:(e,t,n)=>{const{driverBase:s,__t:r}=global.DBGATE_PACKAGES["dbgate-tools"],{redisChangeSetToRedisCommands:a}=global.DBGATE_PACKAGES["dbgate-datalib"],{redisSplitterOptions:i}=n(994),o={...s,dumperClass:n(197),dialect:{limitSelect:!0,rangeSelect:!0,offsetFetchRangeSyntax:!0,stringEscapeChar:"'",fallbackDataType:"nvarchar(max)",quoteIdentifier:e=>`[${e}]`},engine:"redis@dbgate-plugin-redis",title:"Redis",defaultPort:6379,editorMode:"text",authTypeFirst:!0,databaseEngineTypes:["keyvalue"],supportedCreateDatabase:!1,getQuerySplitterOptions:()=>i,databaseUrlPlaceholder:"e.g. redis://:authpassword@127.0.0.1:6380/4",authTypeLabel:"Connection mode",defaultAuthTypeName:"node",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path fill="#b71c1c" d="M45,29.316c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,29.316,3,29.832,3,30.469v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,32.882,45,32.83,45,32.775V29.316z"/><path fill="#e53935" d="M20.616,39.158c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,39.792,22.048,39.798,20.616,39.158z"/><path fill="#b71c1c" d="M45,21.675c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,21.675,3,22.192,3,22.829v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,25.242,45,25.19,45,25.135V21.675z"/><path fill="#e53935" d="M20.616,31.517c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,32.152,22.048,32.158,20.616,31.517z"/><path fill="#b71c1c" d="M45,14.035c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,14.035,3,14.551,3,15.188v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,17.601,45,17.549,45,17.494V14.035z"/><path fill="#e53935" d="M20.616,23.877c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,24.512,22.048,24.517,20.616,23.877z"/><path fill="#fff" d="M18.748,14.741c-0.002,1.042-2.762,2.057-5.093,2.086c-2.419,0.03-5.273-0.993-5.282-2.051\tc-0.009-1.061,2.842-2.161,5.311-2.135C16.017,12.665,18.751,13.703,18.748,14.741z"/><path fill="#fff" d="M17.038,18.471c2.393,1.022,4.785,2.045,7.178,3.067c1.054-1.56,2.108-3.12,3.162-4.68\tC23.931,17.396,20.485,17.934,17.038,18.471z"/><path fill="#fff" d="M21.86,9.775c-1.101,0.401-2.203,0.801-3.304,1.202c1.507,0.132,3.015,0.264,4.522,0.395\tc0.48,0.796,0.959,1.592,1.439,2.387c0.295-0.722,0.59-1.444,0.885-2.166c1.286-0.1,2.572-0.2,3.858-0.3\tc-0.997-0.419-1.994-0.839-2.991-1.259c0.254-0.608,0.508-1.216,0.762-1.825c-0.97,0.29-1.939,0.58-2.909,0.87\tc-1.07-0.422-2.14-0.843-3.21-1.265C21.228,8.468,21.544,9.122,21.86,9.775z"/><path fill="#b71c1c" d="M27.267,14.619c2.271-0.906,4.543-1.813,6.814-2.719c1.962,0.834,3.924,1.668,5.886,2.502\tc-2.202,0.876-4.403,1.752-6.605,2.629C31.331,16.226,29.299,15.423,27.267,14.619z"/><path fill="#a01c1c" d="M34.082,11.963c-0.005,1.596-0.01,3.191-0.015,4.787c1.967-0.783,3.934-1.565,5.901-2.348\tC38.006,13.589,36.044,12.776,34.082,11.963z"/></svg>',showConnectionField:(e,t)=>"useDatabaseUrl"==e?"cluster"!=t.authType:"authType"==e?!t.useDatabaseUrl:t.useDatabaseUrl?["databaseUrl","isReadOnly","treeKeySeparator"].includes(e):"cluster"==t.authType?["user","password","isReadOnly","treeKeySeparator","clusterNodes","autoDetectNatMap"].includes(e):["server","port","user","password","isReadOnly","treeKeySeparator"].includes(e),getAdvancedConnectionFields:()=>[{type:"checkbox",name:"skipSetName",label:"Skip SETNAME instruction"}],getKeyValueMethodCallList:e=>a(e),supportsNodejsBackup:!0,supportsNodejsRestore:!0,nodejsBackupTool:"dbgate-redis-dumper",nodejsRestoreTool:"dbgate-redis-dumper",restoreFileExtensions:["sql","redis","resp"],supportsNodejsDumperForConnection:e=>"cluster"!=e?.authType,getBackupFileExtension:e=>"resp"==e?.format?"resp":"redis",getNativeOperationFormArgs:e=>"backup"==e?[{type:"select",label:r("redisDriver.backupTool",{defaultMessage:"Backup tool"}),name:"backupTool",default:"dbgate-redis-dumper",testId:"BackupDatabaseTab_backupTool",options:[{name:"dbgate-redis-dumper",value:"dbgate-redis-dumper"}]},{type:"select",label:r("redisDriver.format",{defaultMessage:"Output format"}),name:"format",default:"text",testId:"BackupDatabaseTab_format",options:[{name:"Redis commands (redis-cli < file)",value:"text"},{name:"RESP protocol (redis-cli --pipe < file)",value:"resp"}]},{type:"text",label:r("redisDriver.keyPattern",{defaultMessage:"Key pattern (e.g. user:*)"}),name:"keyPattern",testId:"BackupDatabaseTab_keyPattern",default:""},{type:"select",label:r("redisDriver.expiration",{defaultMessage:"Key expiration"}),name:"expiration",default:"absolute",options:[{name:"Keep absolute expiry time",value:"absolute"},{name:"Keep remaining time to live",value:"relative"},{name:"Drop expiration (keys never expire)",value:"none"}]},{type:"select",label:r("redisDriver.strategy",{defaultMessage:"Value encoding"}),name:"strategy",default:"commands",options:[{name:"Commands (portable across versions)",value:"commands"},{name:"DUMP payloads (exact, same or newer server only)",value:"payload"}]},{type:"checkbox",label:r("redisDriver.replace",{defaultMessage:"Replace existing keys on restore"}),name:"replace",default:!0},{type:"checkbox",label:r("redisDriver.streamGroups",{defaultMessage:"Include stream consumer groups and pending entries"}),name:"streamGroups",default:!0},{type:"checkbox",label:r("redisDriver.allDatabases",{defaultMessage:"All databases (restores each into its original database)"}),name:"allDatabases",default:!1}]:"restore"==e?[{type:"select",label:r("redisDriver.restoreTool",{defaultMessage:"Restore tool"}),name:"restoreTool",default:"dbgate-redis-dumper",testId:"RestoreDatabaseTab_restoreTool",options:[{name:"dbgate-redis-dumper",value:"dbgate-redis-dumper"}]}]:null};e.exports=o},588:e=>{"use strict";e.exports=require("async")},659:e=>{"use strict";e.exports=require("ioredis")},825:e=>{"use strict";e.exports=require("lodash")},181:e=>{"use strict";e.exports=require("buffer")},982:e=>{"use strict";e.exports=require("crypto")},896:e=>{"use strict";e.exports=require("fs")},203:e=>{"use strict";e.exports=require("stream")},786:e=>{"use strict";e.exports=require("stream/promises")},16:e=>{"use strict";e.exports=require("url")},244:(e,t,n)=>{"use strict";var s,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=Object.prototype.hasOwnProperty,c={};function l(e){return"function"==typeof e.acquire}function u(e){if(Buffer.isBuffer(e))return e;if("number"==typeof e){if(!Number.isFinite(e))throw new TypeError(`Cannot send non-finite number ${e} as a Redis argument`);return Buffer.from(String(e),"latin1")}return Buffer.from(e,"utf8")}function d(e){return Buffer.isBuffer(e)?e.length:"number"==typeof e?String(e).length:Buffer.byteLength(e,"utf8")}function f(e){const t=e[0];return void 0===t?"":u(t).toString("latin1").toUpperCase()}function p(e,t){const n=e[t];return void 0===n?void 0:u(n).toString("latin1")}((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(c,{BufferDumpWriter:()=>be,CommandChunker:()=>xe,CommandParser:()=>st,DiagnosticCollector:()=>_,FEATURE_VERSIONS:()=>$e,KeyExporter:()=>Le,MINIMUM_SUPPORTED_VERSION:()=>P,OperationCancelledError:()=>m,PACKAGE_NAME:()=>G,PACKAGE_VERSION:()=>K,PLACEHOLDER_GROUP:()=>De,REDIS_CORE_KEY_TYPES:()=>X,RESTORE_COMMANDS:()=>de,RedisDumpParseError:()=>tt,RedisDumperError:()=>h,RequirementTracker:()=>Ke,ServerClock:()=>Re,SplitArgsError:()=>Ve,StreamDumpWriter:()=>we,acquireRedisConnection:()=>T,analyzeRedisDump:()=>ut,argumentByteLength:()=>d,argumentText:()=>p,callMany:()=>O,capabilitiesFor:()=>z,checkCommandAllowed:()=>pe,checkTargetCompatibility:()=>Xe,commandName:()=>f,compareVersions:()=>L,describeKey:()=>I,detectDumpFormat:()=>dt,detectSelectedDatabase:()=>D,detectServerVersion:()=>q,dumpRedis:()=>mt,encodeCommand:()=>ue,encodeRespCommand:()=>Z,encodeTextArgument:()=>ie,encodeTextCommand:()=>le,errorMessage:()=>w,exportStream:()=>Pe,featuresOfCommand:()=>je,isAbortError:()=>g,isCoreKeyType:()=>F,isRedisConnectionSource:()=>l,isRedisDump:()=>ft,keyMatchesSelection:()=>Y,matchGlob:()=>H,nextStreamId:()=>Oe,parseInfo:()=>B,parseKeyspace:()=>N,parseRedisCommands:()=>rt,parseStreamId:()=>Te,payloadRdbVersion:()=>Ge,preflightRestore:()=>Fe,previewCommand:()=>ye,rdbVersionFor:()=>j,readSource:()=>We,redactCommand:()=>me,replyToArray:()=>k,replyToBuffer:()=>E,replyToBufferArray:()=>R,replyToInteger:()=>x,replyToMap:()=>C,replyToNullableBuffer:()=>S,replyToString:()=>v,resolveKeyExportOptions:()=>ve,restoreRedisDump:()=>lt,scanKeys:()=>Ee,selectDatabase:()=>A,splitArgs:()=>Ze,streamRedisCommands:()=>at,throwIfAborted:()=>y,toBuffer:()=>u,typeMatchesSelection:()=>J,variadic:()=>ke,versionAtLeast:()=>$,versionFromInfo:()=>U}),e.exports=(s=c,((e,t,n,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let n of i(t))o.call(e,n)||undefined===n||r(e,n,{get:()=>t[n],enumerable:!(s=a(t,n))||s.enumerable});return e})(r({},"__esModule",{value:!0}),s));var h=class extends Error{code;constructor(e,t,n){super(t,n),this.name="RedisDumperError",this.code=e}},m=class extends h{constructor(e="The operation was cancelled"){super("operation-cancelled",e),this.name="OperationCancelledError"}};function y(e){if(e?.aborted)throw new m}function g(e){return e instanceof DOMException&&"AbortError"===e.name||e instanceof Error&&"OperationCancelledError"===e.name}function w(e){return e instanceof Error?e.message:String(e)}function b(e,t){const n=null===t?"nil":Array.isArray(t)?"array":typeof t;return new h("unexpected-reply",`Expected ${e} reply from the server, got ${n}`)}function E(e){if(Buffer.isBuffer(e))return e;if("string"==typeof e)return Buffer.from(e,"utf8");if("number"==typeof e)return Buffer.from(String(e),"latin1");throw b("a string",e)}function S(e){return null===e?null:E(e)}function v(e){return E(e).toString("utf8")}function x(e){if("number"==typeof e)return e;if(Buffer.isBuffer(e)||"string"==typeof e){const t=e.toString();if(/^-?\d+$/.test(t))return Number(t)}throw b("an integer",e)}function k(e){if(Array.isArray(e))return e;throw b("an array",e)}function R(e){return k(e).map(E)}function C(e){const t=k(e),n=new Map;for(let e=0;e+1<t.length;e+=2)n.set(v(t[e]),t[e+1]);return n}async function T(e,t){return l(e)?e.acquire(t):{connection:e,dedicated:!1,release:async()=>{}}}async function O(e,t,n){if(0===t.length)return[];if(y(n),e.pipeline){const s=await e.pipeline(t,n);if(s.length!==t.length)throw new Error(`Adapter pipeline returned ${s.length} replies for ${t.length} commands`);return s}const s=[];for(const r of t){y(n);try{s.push({ok:!0,reply:await e.call(r,n)})}catch(e){s.push({ok:!1,error:e})}}return s}async function D(e,t){if("number"==typeof e.selectedDatabase)return e.selectedDatabase;try{const n=v(await e.call(["CLIENT","INFO"],t)),s=/(?:^|\s)db=(\d+)(?:\s|$)/.exec(n);return s?Number(s[1]):void 0}catch{return}}async function A(e,t,n){await e.call(["SELECT",t],n)}function I(e,t=120){const n=u(e).toString("utf8");return n.length>t?`${n.slice(0,t)}…`:n}var P="5.0.0";function B(e){const t=new Map;for(const n of e.split("\n")){const e=n.trim();if(""===e||e.startsWith("#"))continue;const s=e.indexOf(":");s>0&&t.set(e.slice(0,s),e.slice(s+1))}return t}function N(e){const t=new Map;for(const[n,s]of B(e)){const e=/^db(\d+)$/.exec(n),r=/(?:^|,)keys=(\d+)/.exec(s);e&&r&&t.set(Number(e[1]),Number(r[1]))}return t}function M(e){const[t=0,n=0,s=0]=e.split(".").map((e=>Number.parseInt(e,10))).map((e=>Number.isFinite(e)?e:0));return[t,n,s]}function L(e,t){const n=M(e),s=M(t);for(let e=0;e<3;e++){const t=n[e]-s[e];if(0!==t)return t<0?-1:1}return 0}function $(e,t){return L(e,t)>=0}function U(e){const t=e.get("redis_version"),n=e.get("valkey_version"),s=void 0!==n||"valkey"===e.get("server_name")?"valkey":"redis",r=("valkey"===s?n:t)??t;if(!r)throw new h("version-undetectable","The server did not report redis_version in INFO server");const[a,i,o]=M(r);return{flavor:s,version:r,major:a,minor:i,patch:o,redisCompatibleVersion:t??r,mode:e.get("redis_mode")??"standalone"}}async function q(e,t){return U(B(v(await e.call(["INFO","server"],t))))}function z(e){const t=e.redisCompatibleVersion;return{scanType:$(t,"6.0.0"),pexpireTime:$(t,"7.0.0"),clientInfo:$(t,"6.2.0"),xgroupCreateConsumer:$(t,"6.2.0"),streamCounters:$(t,"7.0.0"),hashFieldExpiration:"valkey"===e.flavor?$(e.version,"9.0.0"):$(e.version,"7.4.0")}}function j(e){if("valkey"===e.flavor)return e.major>=7&&e.major<9?11:void 0;if(5===e.major||6===e.major)return 9;if(7===e.major){if(0===e.minor)return 10;if(2===e.minor)return 11;if(e.minor>=4)return 12}return 8===e.major?12:void 0}var G="dbgate-redis-dumper",K="0.1.0",X=["string","hash","list","set","zset","stream"];function F(e){return X.includes(e)}var _=class{items=[];firstIndexByCode=new Map;countByIndex=new Map;add(e){this.items.push(e)}addOnce(e){const t=this.firstIndexByCode.get(e.code);void 0===t?(this.firstIndexByCode.set(e.code,this.items.length),this.items.push(e)):this.countByIndex.set(t,(this.countByIndex.get(t)??1)+1)}toArray(){return this.items.map(((e,t)=>{const n=this.countByIndex.get(t);return n?{...e,message:`${e.message} (${n} occurrences)`}:e}))}};function H(e,t){return V("string"==typeof e?Buffer.from(e,"utf8"):e,0,"string"==typeof t?Buffer.from(t,"utf8"):t,0,0)}var W=1e3;function V(e,t,n,s,r){if(r>W)return!1;for(;t<e.length&&s<n.length;){const a=e[t];if(42===a){for(;t+1<e.length&&42===e[t+1];)t++;if(t+1===e.length)return!0;for(let a=s;a<n.length;a++)if(V(e,t+1,n,a,r+1))return!0;return!1}if(63!==a)if(91!==a){if(92===a&&t+1<e.length&&t++,e[t]!==n[s])return!1;s++,t++}else{const r=94===e[++t];r&&t++;let a=!1;const i=n[s];for(;;){if(t>=e.length){t--;break}const n=e[t];if(92===n&&t+1<e.length)e[++t]===i&&(a=!0);else{if(93===n)break;if(t+2<e.length&&45===e[t+1]){let s=n,r=e[t+2];s>r&&([s,r]=[r,s]),t+=2,i>=s&&i<=r&&(a=!0)}else n===i&&(a=!0)}t++}if(r&&(a=!a),!a)return!1;s++,t++}else s++,t++}for(;t<e.length&&42===e[t];)t++;return t===e.length&&s===n.length}function Y(e,t){return!(t&&(t.keys&&void 0!==t.match&&!H(t.match,e)||t.include&&t.include.length>0&&!t.include.some((t=>H(t,e)))||t.exclude?.some((t=>H(t,e)))))}function J(e,t){return!t?.types||0===t.types.length||t.types.includes(e)}function Z(e){const t=[Buffer.from(`*${e.length}\r\n`,"latin1")];for(const n of e){const e=u(n);t.push(Buffer.from(`$${e.length}\r\n`,"latin1"),e,Q)}return Buffer.concat(t)}var Q=Buffer.from("\r\n","latin1"),ee=n(181),te=92,ne=34,se=39,re="0123456789abcdef";function ae(e){return e>32&&e<127&&e!==ne&&e!==se&&e!==te}function ie(e,t={}){const n=u(e);if(function(e){if(0===e.length)return!1;for(const t of e)if(!ae(t))return!1;return!0}(n))return n;const s=!t.escapeNonAscii&&(0,ee.isUtf8)(n),r=Buffer.allocUnsafe(4*n.length+2);let a=0;r[a++]=ne;for(const e of n){switch(e){case te:r[a++]=te,r[a++]=te;continue;case ne:r[a++]=te,r[a++]=ne;continue;case 10:r[a++]=te,r[a++]=110;continue;case 13:r[a++]=te,r[a++]=114;continue;case 9:r[a++]=te,r[a++]=116;continue}e>=32&&e<127||s&&e>=128?r[a++]=e:(r[a++]=te,r[a++]=120,r[a++]=re.charCodeAt(e>>4),r[a++]=re.charCodeAt(15&e))}return r[a++]=ne,r.subarray(0,a)}var oe=Buffer.from(" ","latin1"),ce=Buffer.from("\n","latin1");function le(e,t={}){const n=[];for(const[s,r]of e.entries())s>0&&n.push(oe),n.push(ie(r,t));return n.push(ce),Buffer.concat(n)}function ue(e,t,n={}){return"resp"===t?Z(e):le(e,n)}var de=new Set(["SELECT","ECHO","PING","MULTI","EXEC","DISCARD","DEL","UNLINK","EXPIRE","PEXPIRE","EXPIREAT","PEXPIREAT","PERSIST","RESTORE","SET","SETEX","PSETEX","SETNX","MSET","MSETNX","APPEND","SETRANGE","SETBIT","INCR","INCRBY","INCRBYFLOAT","DECR","DECRBY","PFADD","PFMERGE","HSET","HMSET","HSETNX","HINCRBY","HINCRBYFLOAT","HEXPIRE","HPEXPIRE","HEXPIREAT","HPEXPIREAT","HPERSIST","RPUSH","LPUSH","RPUSHX","LPUSHX","LINSERT","LSET","SADD","ZADD","ZINCRBY","GEOADD","XADD","XSETID","XGROUP","XCLAIM","XDEL","XTRIM"]),fe=new Set(["CREATE","CREATECONSUMER","DESTROY","DELCONSUMER","SETID"]);function pe(e,t){if("any"===t)return;const n=f(e);return"restore"!==t?t.some((e=>e.toUpperCase()===n))?void 0:`${n} is not in allowedCommands`:de.has(n)?"XGROUP"!==n||fe.has(p(e,1)?.toUpperCase()??"")?void 0:`XGROUP ${p(e,1)??""} is not a data command; pass allowedCommands to permit it`:`${n} is not a data command; pass allowedCommands to permit it`}var he="<redacted>";function me(e){const t=f(e),n=[...e],s=t=>p(e,t)?.toUpperCase()??"";if("AUTH"===t)for(let e=1;e<n.length;e++)n[e]=he;else if("HELLO"===t||"MIGRATE"===t){for(let e=1;e<n.length;e++)if("AUTH"===s(e)){const s="HELLO"===t?2:1;for(let t=1;t<=s&&e+t<n.length;t++)n[e+t]=he}else if("AUTH2"===s(e))for(let t=1;t<=2&&e+t<n.length;t++)n[e+t]=he}else if("CONFIG"===t&&"SET"===s(1))for(let t=2;t+1<n.length;t+=2)/^(requirepass|masterauth|masteruser)$/i.test(p(e,t)??"")&&(n[t+1]=he);else if("ACL"===t&&"SETUSER"===s(1))for(let t=3;t<n.length;t++)/^[>#<!]/.test(p(e,t)??"")&&(n[t]=he);return n}function ye(e,t=200){const n=le(me(e)).toString("utf8").trimEnd();return n.length>t?`${n.slice(0,t)}…`:n}function ge(e){if(e?.aborted)throw new DOMException("The operation was aborted.","AbortError")}var we=class{stream;bytes=0;writeError=null;constructor(e){this.stream=e}get bytesWritten(){return this.bytes}async write(e,t){if(0===e.length)return;if(this.writeError)throw this.writeError;ge(t);const n=Buffer.isBuffer(e);this.bytes+=n?e.length:Buffer.byteLength(e,"utf8");const s=e=>{e&&!this.writeError&&(this.writeError=e)};if(!1===(n?this.stream.write(e,s):this.stream.write(e,"utf8",s))&&await new Promise(((e,n)=>{const s=()=>{this.stream.removeListener("drain",r),this.stream.removeListener("error",a),t?.removeEventListener("abort",i)},r=()=>{s(),e()},a=e=>{s(),n(e)},i=()=>{s(),n(new DOMException("The operation was aborted.","AbortError"))};this.stream.once("drain",r),this.stream.once("error",a),t?.addEventListener("abort",i,{once:!0})})),this.writeError)throw this.writeError;ge(t)}},be=class{chunks=[];bytes=0;get bytesWritten(){return this.bytes}async write(e,t){if(t?.aborted)throw new DOMException("The operation was aborted.","AbortError");const n=Buffer.isBuffer(e)?e:Buffer.from(e,"utf8");this.chunks.push(n),this.bytes+=n.length}toBuffer(){return Buffer.concat(this.chunks)}toString(){return this.toBuffer().toString("utf8")}};async function*Ee(e,t,n){const{selection:s,count:r,signal:a}=n,i=!1===n.deduplicate?null:new Set,o=e=>{if(!Y(e,s))return!1;if(i){const t=e.toString("latin1");if(i.has(t))return!1;i.add(t)}return!0};if(s?.keys){for(let e=0;e<s.keys.length;e+=r){y(a);const t=s.keys.slice(e,e+r).map(u).filter(o);t.length>0&&(yield t)}return}const c=[];void 0!==s?.match&&c.push("MATCH",s.match),c.push("COUNT",r),1===s?.types?.length&&t.scanType&&c.push("TYPE",s.types[0]);let l="0";do{y(a);const t=k(await e.call(["SCAN",l,...c],a));l=v(t[0]??null);const n=R(t[1]??[]).filter(o);n.length>0&&(yield n)}while("0"!==l)}function Se(e,t,n){if(void 0===e)return t;if(!Number.isInteger(e)||e<1)throw new RangeError(`${n} must be a positive integer, got ${e}`);return e}function ve(e={}){return{strategy:e.strategy??"commands",unknownTypes:e.unknownTypes??"payload",expiration:e.expiration??"absolute",replace:e.replace??!0,batchSize:Se(e.batchSize,128,"batchSize"),maxCommandBytes:Se(e.maxCommandBytes,1048576,"maxCommandBytes"),scanCount:Se(e.scanCount,1e3,"scanCount"),hashFieldExpiration:e.hashFieldExpiration??!0,streamGroups:e.streamGroups??!0}}var xe=class{constructor(e,t,n,s){this.emit=e,this.build=t,this.maxElements=n,this.maxBytes=s}emit;build;maxElements;maxBytes;elements=[];bytes=0;flushedCount=0;get commandsWritten(){return this.flushedCount}async add(e){this.elements.push(e);for(const t of e)this.bytes+=d(t);(this.elements.length>=this.maxElements||this.bytes>=this.maxBytes)&&await this.flush()}async flush(){if(0===this.elements.length)return;const e=this.elements;this.elements=[],this.bytes=0,this.flushedCount++,await this.emit(this.build(e))}};function ke(e){return t=>{const n=[...e];for(const e of t)n.push(...e);return n}}var Re=class e{constructor(e){this.offsetMs=e}offsetMs;static async measure(t,n){const s=Date.now(),r=k(await t.call(["TIME"],n)),a=Date.now(),i=x(r[0]??null),o=x(r[1]??null),c=1e3*i+Math.floor(o/1e3);return new e(c-Math.round((s+a)/2))}static local(){return new e(0)}now(){return Date.now()+this.offsetMs}},Ce=(1n<<64n)-1n;function Te(e){const t=/^(\d+)-(\d+)$/.exec(e);if(!t)throw new RangeError(`Not a stream entry id: ${JSON.stringify(e)}`);return{ms:BigInt(t[1]),seq:BigInt(t[2])}}function Oe(e){const{ms:t,seq:n}=Te(e);return n===Ce?`${t+1n}-0`:`${t}-${n+1n}`}var De="__dbgate_redis_dumper_mkstream__";function Ae(e){return null==e?void 0:v(e)}function Ie(e){return null==e?void 0:x(e)}async function Pe(e,t){const{connection:n,options:s,emit:r,signal:a}=e;let i;try{i=C(await n.call(["XINFO","STREAM",t],a))}catch(e){if(/no such key/i.test(e instanceof Error?e.message:String(e)))return!1;throw e}const o=Ae(i.get("last-generated-id"))??"0-0",c=Ie(i.get("entries-added")),l=Ae(i.get("max-deleted-entry-id"));s.replace&&await r(["DEL",t]);let u=0,d="-";for(;;){y(a);const e=k(await n.call(["XRANGE",t,d,"+","COUNT",s.batchSize],a));for(const n of e){const[e,s]=k(n),a=E(e??null),i=R(s??[]);await r(["XADD",t,a,...i]),u++,d=Oe(a.toString("latin1"))}if(e.length<s.batchSize)break}0===u&&("0-0"===o?(await r(["XGROUP","CREATE",t,De,"0","MKSTREAM"]),await r(["XGROUP","DESTROY",t,De])):await r(["XADD",t,"MAXLEN","0",o,"x",""]));const f=["XSETID",t,o];return e.capabilities.streamCounters&&void 0!==c&&l&&f.push("ENTRIESADDED",c,"MAXDELETEDID",l),await r(f),s.streamGroups&&await async function(e,t){const{connection:n,options:s,emit:r,signal:a,clock:i}=e,o=k(await n.call(["XINFO","GROUPS",t],a)).map(C);for(const c of o){y(a);const o=E(c.get("name")??null),l=Ae(c.get("last-delivered-id"))??"0-0",u=Ie(c.get("entries-read")),d=["XGROUP","CREATE",t,o,l];e.capabilities.streamCounters&&void 0!==u&&d.push("ENTRIESREAD",u),await r(d);const f=k(await n.call(["XINFO","CONSUMERS",t,o],a)).map(C);for(const e of f)await r(["XGROUP","CREATECONSUMER",t,o,E(e.get("name")??null)]);f.length>0&&e.diagnostics.addOnce({severity:"info",code:"stream-consumer-activity-reset",message:"Stream consumers are recreated, but a consumer's seen-time and active-time cannot be set by any command: they restart from the moment of restore",database:e.database,key:I(t)});let p="-";for(;;){y(a);const e=k(await n.call(["XPENDING",t,o,p,"+",s.batchSize],a)),c=i.now();for(const n of e){const[e,a,i,l]=k(n),u=E(e??null),d=x(i??null),f=x(l??null),h="absolute"===s.expiration?["TIME",c-d]:["IDLE",d];await r(["XCLAIM",t,o,E(a??null),"0",u,...h,"RETRYCOUNT",f,"FORCE","JUSTID"]),p=Oe(u.toString("latin1"))}if(e.length<s.batchSize)break}}}(e,t),!0}var Be={string:"STRLEN",hash:"HLEN",list:"LLEN",set:"SCARD",zset:"ZCARD"};function Ne(e){return/^WRONGTYPE\b/.test(w(e))}function Me(e){if(!e)throw new Error("Missing pipeline reply");if(!e.ok)throw e.error;return e.reply}var Le=class{constructor(e){this.context=e}context;async exportPage(e){const{signal:t}=this.context;y(t);const n=await this.readTypesAndExpiries(e);this.plan(n),await this.readSizes(n),await this.prefetch(n);let s=0,r=0;for(const e of n)y(t),await this.write(e)?s++:r++;return{keysExported:s,keysSkipped:r}}vanished(e){this.context.diagnostics.addOnce({severity:"info",code:"key-vanished",message:"A key was deleted or expired while the dump was reading it, and is not in the dump",database:this.context.database,key:I(e.key)})}changed(e,t){this.context.diagnostics.add({severity:"warning",code:"key-changed-during-dump",message:`A key was modified while the dump was reading it (${t}); it is not in the dump`,database:this.context.database,key:I(e.key)})}async readTypesAndExpiries(e){const{connection:t,capabilities:n,clock:s,signal:r}=this.context,a=n.pexpireTime?"PEXPIRETIME":"PTTL",i=[];for(const t of e)i.push(["TYPE",t],[a,t]);const o=await O(t,i,r),c=s.now();return e.map(((e,t)=>{const s=v(Me(o[2*t])),r=x(Me(o[2*t+1])),a={key:e,type:s,expiry:null,plan:{kind:"skip"}};return"none"===s||-2===r?(this.vanished(a),a.type="none"):r>=0&&(a.expiry=n.pexpireTime?{absoluteMs:r,remainingMs:r-c}:{absoluteMs:c+r,remainingMs:r}),a}))}plan(e){const{options:t,selection:n}=this.context;for(const s of e){const{type:e}=s;"none"!==e&&J(e,n)?"payload"===t.strategy?s.plan={kind:"payload"}:"stream"===e?s.plan={kind:"stream"}:F(e)?s.plan={kind:"small",type:e}:"payload"===t.unknownTypes?(this.context.diagnostics.addOnce({severity:"warning",code:"module-type-as-payload",message:`Keys of module type "${e}" cannot be rebuilt with commands and are written as RESTORE payloads, which only restore onto a server with the same module and the same or a newer RDB version`,database:this.context.database,key:I(s.key)}),s.plan={kind:"payload"}):(this.context.diagnostics.addOnce({severity:"warning",code:"unsupported-key-type",message:`Keys of module type "${e}" are not in the dump (unknownTypes: 'skip')`,database:this.context.database,key:I(s.key)}),s.plan={kind:"skip"}):s.plan={kind:"skip"}}}async readSizes(e){const{connection:t,options:n,signal:s}=this.context,r=e.filter((e=>"small"===e.plan.kind)),a=await O(t,r.map((e=>{const t=e.plan.type;return[Be[t],e.key]})),s);r.forEach(((e,t)=>{const s=e.plan.type,r=a[t];if(!r?.ok){if(Ne(r?.error))return this.changed(e,"its type changed"),void(e.plan={kind:"skip"});throw r?.error}const i=x(r.reply),o="string"===s?n.maxCommandBytes:n.batchSize;"string"!==s&&0===i?(this.vanished(e),e.plan={kind:"skip"}):i>o&&(e.plan={kind:"large",type:s,size:i})}))}async prefetch(e){const{connection:t,capabilities:n,options:s,signal:r}=this.context,a=e.filter((e=>"small"===e.plan.kind||"payload"===e.plan.kind)),i=await O(t,a.map((e=>{const t=e.plan;if("payload"===t.kind)return["DUMP",e.key];switch(t.type){case"string":return["GET",e.key];case"hash":return["HGETALL",e.key];case"list":return["LRANGE",e.key,0,-1];case"set":return["SMEMBERS",e.key];default:return["ZRANGE",e.key,0,-1,"WITHSCORES"]}})),r);if(a.forEach(((e,t)=>{const n=i[t];if(!n?.ok){if(Ne(n?.error))return this.changed(e,"its type changed"),void(e.plan={kind:"skip"});throw n?.error}const s=e.plan;"payload"===s.kind?s.payload=S(n.reply):"small"===s.kind&&(s.value=n.reply)})),!n.hashFieldExpiration||!s.hashFieldExpiration)return;const o=e.filter((e=>"small"===e.plan.kind&&"hash"===e.plan.type&&Array.isArray(e.plan.value)&&e.plan.value.length>0)),c=await O(t,o.map((e=>{const t=e.plan.value.filter(((e,t)=>t%2==0));return["HPEXPIRETIME",e.key,"FIELDS",t.length,...t]})),r);o.forEach(((e,t)=>{const n=c[t];n?.ok&&(e.fieldExpiries=k(n.reply).map(x))}))}async write(e){const t=e.plan;switch(t.kind){case"skip":return!1;case"payload":return this.writePayload(e,t.payload??null);case"stream":return this.context.onLargeKey?.(e.key),await Pe(this.context,e.key)?(await this.writeExpiry(e),!0):(this.vanished(e),!1);case"small":return this.writeSmall(e,t.type,t.value??null);case"large":return this.context.onLargeKey?.(e.key),this.writeLarge(e,t.type,t.size)}}async writeExpiry(e){const{expiry:t}=e,{options:n,emit:s}=this.context;t&&"none"!==n.expiration&&("absolute"===n.expiration?await s(["PEXPIREAT",e.key,t.absoluteMs]):await s(["PEXPIRE",e.key,Math.max(1,t.remainingMs)]))}async writePayload(e,t){if(null===t)return this.vanished(e),!1;const{options:n,emit:s}=this.context,r=["RESTORE",e.key];return e.expiry&&"none"!==n.expiration?"absolute"===n.expiration?r.push(e.expiry.absoluteMs,t):r.push(Math.max(1,e.expiry.remainingMs),t):r.push(0,t),n.replace&&r.push("REPLACE"),e.expiry&&"absolute"===n.expiration&&r.push("ABSTTL"),await s(r),!0}chunker(e){const{emit:t,options:n}=this.context;return new xe(t,ke(e),n.batchSize,n.maxCommandBytes)}async writeSmall(e,t,n){const{emit:s,options:r}=this.context,{key:a}=e;if("string"===t)return null===n?(this.vanished(e),!1):(await s(["SET",a,E(n)]),await this.writeExpiry(e),!0);const i=null===n?[]:R(n);if(0===i.length)return this.vanished(e),!1;switch(r.replace&&await s(["DEL",a]),t){case"hash":{const t=this.chunker(["HSET",a]);for(let e=0;e+1<i.length;e+=2)await t.add([i[e],i[e+1]]);await t.flush();const n=i.filter(((e,t)=>t%2==0));await this.writeFieldExpiries(a,n,e.fieldExpiries);break}case"list":{const e=this.chunker(["RPUSH",a]);for(const t of i)await e.add([t]);await e.flush();break}case"set":{const e=this.chunker(["SADD",a]);for(const t of i)await e.add([t]);await e.flush();break}case"zset":{const e=this.chunker(["ZADD",a]);for(let t=0;t+1<i.length;t+=2)await e.add([i[t+1],i[t]]);await e.flush();break}}return await this.writeExpiry(e),!0}async writeFieldExpiries(e,t,n){const{options:s,emit:r,clock:a}=this.context;if(!n||"none"===s.expiration)return;const i=new Map;t.forEach(((e,t)=>{const s=n[t];if(void 0!==s&&s>=0){const t=i.get(s)??[];t.push(e),i.set(s,t)}}));const o=a.now();for(const[t,n]of i){const a="relative"===s.expiration,i=a?Math.max(1,t-o):t,c=new xe(r,(t=>[a?"HPEXPIRE":"HPEXPIREAT",e,i,"FIELDS",t.length,...t.flat()]),s.batchSize,s.maxCommandBytes);for(const e of n)await c.add([e]);await c.flush()}}async writeLarge(e,t,n){const{connection:s,options:r,emit:a,signal:i}=this.context,{key:o}=e;if("string"===t){let t=0;for(;t<n;){y(i);const e=Math.min(n,t+r.maxCommandBytes)-1,c=E(await s.call(["GETRANGE",o,t,e],i));if(0===c.length)break;await a([0===t?"SET":"APPEND",o,c]),t+=c.length}const c=x(await s.call(["STRLEN",o],i));return t!==n||c!==n?(t>0&&await a(["DEL",o]),this.changed(e,`its length changed from ${n} to ${c} bytes`),!1):(await this.writeExpiry(e),!0)}r.replace&&await a(["DEL",o]);try{switch(t){case"list":await this.streamList(o);break;case"hash":await this.streamScan(o,"HSCAN",["HSET",o],(e=>e),!0);break;case"set":await this.streamScan(o,"SSCAN",["SADD",o],(e=>e),!1);break;case"zset":await this.streamScan(o,"ZSCAN",["ZADD",o],(([e,t])=>[t,e]),!0)}}catch(t){if(!Ne(t))throw t;return await a(["DEL",o]),this.changed(e,"its type changed"),!1}const c=v(await s.call(["TYPE",o],i));return c!==t?(await a(["DEL",o]),"none"===c?this.vanished(e):this.changed(e,"its type changed"),!1):(await this.writeExpiry(e),!0)}async streamList(e){const{connection:t,options:n,signal:s}=this.context,r=this.chunker(["RPUSH",e]);for(let a=0;;a+=n.batchSize){y(s);const i=R(await t.call(["LRANGE",e,a,a+n.batchSize-1],s));for(const e of i)await r.add([e]);if(i.length<n.batchSize)break}await r.flush()}async streamScan(e,t,n,s,r){const{connection:a,options:i,capabilities:o,signal:c}=this.context,l=this.chunker(n),u="HSCAN"===t&&o.hashFieldExpiration&&i.hashFieldExpiration;let d="0";do{y(c);const n=k(await a.call([t,e,d,"COUNT",i.batchSize],c));d=v(n[0]??null);const o=R(n[1]??[]),f=[];if(r)for(let e=0;e+1<o.length;e+=2){const t=[o[e],o[e+1]];f.push(t[0]),await l.add(s(t))}else for(const e of o)await l.add([e]);if(u&&f.length>0){await l.flush();const t=k(await a.call(["HPEXPIRETIME",e,"FIELDS",f.length,...f],c)).map(x);await this.writeFieldExpiries(e,f,t)}}while("0"!==d);await l.flush()}},$e={"multi-field-hset":{redis:"4.0.0",valkey:"7.2.0"},streams:{redis:"5.0.0",valkey:"7.2.0"},"restore-absttl":{redis:"5.0.0",valkey:"7.2.0"},"xgroup-createconsumer":{redis:"6.2.0",valkey:"7.2.0"},"stream-counters":{redis:"7.0.0",valkey:"7.2.0"},"hash-field-expiration":{redis:"7.4.0",valkey:"9.0.0"},"restore-payload":{redis:"2.6.0",valkey:"7.2.0"}},Ue=new Set(["XADD","XGROUP","XSETID","XCLAIM"]),qe=new Set(["HPEXPIREAT","HEXPIREAT","HPEXPIRE","HEXPIRE","HPERSIST"]);function ze(e,t,n){for(let s=n;s<e.length;s++)if(p(e,s)?.toUpperCase()===t)return!0;return!1}function je(e){const t=f(e),n=[];if("HSET"===t&&e.length>4&&n.push("multi-field-hset"),Ue.has(t)&&n.push("streams"),qe.has(t)&&n.push("hash-field-expiration"),"XGROUP"===t){const t=p(e,1)?.toUpperCase();"CREATECONSUMER"===t&&n.push("xgroup-createconsumer"),"CREATE"===t&&ze(e,"ENTRIESREAD",5)&&n.push("stream-counters")}return"XSETID"===t&&(ze(e,"ENTRIESADDED",3)||ze(e,"MAXDELETEDID",3))&&n.push("stream-counters"),"RESTORE"===t&&(n.push("restore-payload"),ze(e,"ABSTTL",4)&&n.push("restore-absttl")),n}function Ge(e){if(!(e.length<11))return e.readUInt16LE(e.length-10)}var Ke=class{features=new Set;databases=[];rdbVersion;note(e){const t=f(e);for(const t of je(e))this.features.add(t);if("RESTORE"===t&&void 0!==e[3]){const t=Ge(u(e[3]));void 0!==t&&(void 0===this.rdbVersion||t>this.rdbVersion)&&(this.rdbVersion=t)}if("SELECT"===t){const t=Number(p(e,1));Number.isInteger(t)&&!this.databases.includes(t)&&this.databases.push(t)}}toRequirements(){const e=[...this.features].sort();let t="2.6.0";for(const n of e){const e=$e[n].redis;$(t,e)||(t=e)}return{features:e,minimumRedisVersion:t,...void 0===this.rdbVersion?{}:{payloadRdbVersion:this.rdbVersion},databases:[...this.databases]}}};function Xe(e,t){const n=[],s=`${"valkey"===t.flavor?"Valkey":"Redis"} ${t.version}`;for(const r of e.features){if("restore-payload"===r)continue;const e=$e[r],a="valkey"===t.flavor?e.valkey:e.redis;void 0!==a&&$(t.version,a)||n.push({feature:r,status:"unsupported",message:`${s} does not support ${r} (needs Redis ${e.redis}${e.valkey?` or Valkey ${e.valkey}`:""})`})}if(void 0!==e.payloadRdbVersion){const r=j(t);void 0===r?n.push({feature:"restore-payload",status:"unverified",message:`The dump contains RDB version ${e.payloadRdbVersion} payloads; which RDB versions ${s} accepts is not known to this package`}):e.payloadRdbVersion>r&&n.push({feature:"restore-payload",status:"unsupported",message:`The dump contains RDB version ${e.payloadRdbVersion} payloads, but ${s} loads RDB version ${r} at most`})}return n}async function Fe(e){const t=await T(e.connection,e.signal);try{const{connection:n}=t,s=await q(n,e.signal),r=Xe(e.requirements,s),a=N(v(await n.call(["INFO","keyspace"],e.signal))),i=e.requirements.databases,o=[...a.entries()].filter((([e,t])=>t>0&&(0===i.length||i.includes(e)))).map((([e,t])=>({database:e,keys:t})));return{server:s,compatible:!r.some((e=>"unsupported"===e.status)),issues:r,nonEmptyDatabases:o}}finally{await t.release()}}var _e=n(203);function He(e){return"string"==typeof e?Buffer.from(e,"utf8"):Buffer.isBuffer(e)?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)}async function*We(e){if("string"==typeof e||e instanceof Uint8Array)yield He(e);else if(e instanceof _e.Readable||Symbol.asyncIterator in e)for await(const t of e)yield He(t);else for(const t of e)yield He(t)}var Ve=class extends Error{constructor(e,t){super(e),this.column=t,this.name="SplitArgsError"}column};function Ye(e){return 32===e||9===e||10===e||11===e||12===e||13===e}function Je(e){return void 0===e?-1:e>=48&&e<=57?e-48:e>=97&&e<=102?e-97+10:e>=65&&e<=70?e-65+10:-1}function Ze(e){const t=e.indexOf(0),n=-1===t?e.length:t,s=[],r=Buffer.allocUnsafe(n);let a=0;for(;;){for(;a<n&&Ye(e[a]);)a++;if(a>=n)return s;let t=0,i=!1,o=!1,c=!1;for(;!c;){const s=a<n?e[a]:void 0,l=a+1<n?e[a+1]:void 0;if(i)if(92===s&&120===l&&a+3<n&&Je(e[a+2])>=0&&Je(e[a+3])>=0)r[t++]=16*Je(e[a+2])+Je(e[a+3]),a+=3;else if(92===s&&void 0!==l)a++,r[t++]=Qe.get(l)??l;else if(34===s){if(void 0!==l&&!Ye(l))throw new Ve("A closing quote must be followed by a space",a);c=!0}else{if(void 0===s)throw new Ve("Unbalanced double quote",a);r[t++]=s}else if(o)if(92===s&&39===l)a++,r[t++]=39;else if(39===s){if(void 0!==l&&!Ye(l))throw new Ve("A closing quote must be followed by a space",a);c=!0}else{if(void 0===s)throw new Ve("Unbalanced single quote",a);r[t++]=s}else void 0===s||32===s||10===s||13===s||9===s?c=!0:34===s?i=!0:39===s?o=!0:r[t++]=s;a<n&&a++}s.push(Buffer.from(r.subarray(0,t)))}}var Qe=new Map([[110,10],[114,13],[116,9],[98,8],[97,7]]),et=class{chunks=[];head=0;size=0;get length(){return this.size}push(e){e.length>0&&(this.chunks.push(e),this.size+=e.length)}byteAt(e){if(e<0||e>=this.size)return;let t=e+this.head;for(const e of this.chunks){if(t<e.length)return e[t];t-=e.length}}indexOf(e,t=0){let n=0,s=!0;for(const r of this.chunks){const a=s?this.head:0,i=r.length-a;if(s=!1,t>=n+i){n+=i;continue}const o=r.indexOf(e,a+Math.max(0,t-n));if(-1!==o)return n+(o-a);n+=i}return-1}take(e){if(e>this.size)throw new RangeError(`Cannot take ${e} bytes from a queue of ${this.size}`);const t=this.chunks[0];if(t&&t.length-this.head>=e){const n=t.subarray(this.head,this.head+e);return this.skip(e),n}const n=Buffer.allocUnsafe(e);let s=0;for(;s<e;){const t=this.chunks[0],r=Math.min(t.length-this.head,e-s);t.copy(n,s,this.head,this.head+r),s+=r,this.skip(r)}return n}skip(e){let t=e;for(this.size-=e;t>0;){const e=this.chunks[0].length-this.head;if(t<e)return void(this.head+=t);t-=e,this.chunks.shift(),this.head=0}}},tt=class extends h{constructor(e,t){super("parse-error",e),this.location=t,this.name="RedisDumpParseError"}location};function nt(e){return 32===e||9===e||10===e||13===e||11===e||12===e}var st=class{queue=new et;format;maxCommandBytes;reportInvalid;consumed=0;line=1;searched=0;index=0;finished=!1;unterminated=!1;constructor(e={}){this.format="auto"===e.format||void 0===e.format?void 0:e.format,this.maxCommandBytes=e.maxCommandBytes??1073741824,this.reportInvalid="report"===e.invalidLines}get detectedFormat(){return this.format}get endedWithoutNewline(){return this.unterminated}get bytesConsumed(){return this.consumed}push(e){return this.queue.push(e),this.drain(!1)}end(){return this.drain(!0)}drain(e){const t=[];for(;!this.finished&&(void 0!==this.format||this.detect(e));){const n="resp"===this.format?this.nextResp(e):this.nextText(e);if(void 0===n)break;t.push(...n)}if(e&&!this.finished&&this.queue.length>0)throw new tt("The dump ends in the middle of a command",{offset:this.consumed,line:this.line});return t}detect(e){for(let e=0;e<this.queue.length;e++){const t=this.queue.byteAt(e);if(!nt(t))return this.format=42===t?"resp":"text",!0}return!!e&&(this.format="text",!0)}tooLarge(e){return new tt(`A command of ${e} bytes exceeds maxCommandBytes (${this.maxCommandBytes})`,{offset:this.consumed,line:this.line})}takeLine(e){const t=this.queue.indexOf(10,this.searched);if(-1===t){if(this.searched=this.queue.length,this.searched>this.maxCommandBytes)throw this.tooLarge(this.searched);if(!e||0===this.queue.length)return;const t=this.queue.take(this.queue.length);return this.consumed+=t.length,this.unterminated=!0,this.searched=0,t}const n=this.queue.take(t);return this.queue.skip(1),this.consumed+=t+1,this.searched=0,n}splitLine(e,t){try{return Ze(e)}catch(e){if(!(e instanceof Ve))throw e;const n=`${e.message} (column ${e.column+1})`;if(this.reportInvalid)return{argv:[],index:this.index++,location:t,invalid:n};throw new tt(n,t)}}nextText(e){for(;;){const t={offset:this.consumed,line:this.line},n=this.takeLine(e);if(void 0===n)return;this.line++;const s=this.splitLine(n,t);if(!Array.isArray(s))return[s];if(0===s.length)continue;const r=s[0].toString("latin1").toLowerCase();if(1===s.length&&("quit"===r||"exit"===r))return this.finished=!0,[];let a=1,i=s;s.length>1&&/^[1-9]\d{0,5}$/.test(r)&&(a=Number(r),i=s.slice(1));const o=[];for(let e=0;e<a;e++)o.push({argv:i,index:this.index++,location:t});return o}}nextResp(e){let t=0;for(;t<this.queue.length&&nt(this.queue.byteAt(t));)t++;if(t>0){for(let e=0;e<t;e++)10===this.queue.byteAt(e)&&this.line++;this.queue.skip(t),this.consumed+=t,this.searched=0}if(0===this.queue.length)return;if(42!==this.queue.byteAt(0))return this.nextText(e);const n={offset:this.consumed,line:this.line};let s=0;const r=e=>{if(s>=this.queue.length)return;if(this.queue.byteAt(s)!==e)throw new tt(`Expected '${String.fromCharCode(e)}' in RESP input, found byte 0x${(this.queue.byteAt(s)??0).toString(16)}`,{offset:this.consumed+s});const t=this.queue.indexOf(10,s);if(-1===t){if(this.queue.length-s>32)throw new tt("Malformed RESP length header",{offset:this.consumed+s});return}let n="";for(let e=s+1;e<t;e++)n+=String.fromCharCode(this.queue.byteAt(e));if(n.endsWith("\r")&&(n=n.slice(0,-1)),!/^\d+$/.test(n))throw new tt(`Malformed RESP length ${JSON.stringify(n)}`,{offset:this.consumed+s});return s=t+1,Number(n)},a=r(42);if(void 0===a)return;const i=[];let o=0;for(let e=0;e<a;e++){const e=r(36);if(void 0===e)return;if(o+=e,o>this.maxCommandBytes)throw this.tooLarge(o);const t=s;if(this.queue.length<t+e+2)return;if(13!==this.queue.byteAt(t+e)||10!==this.queue.byteAt(t+e+1))throw new tt("A RESP bulk string is not followed by CRLF",{offset:this.consumed+t+e});i.push(e),s=t+e+2}const c=[],l=()=>{const e=this.queue.indexOf(10);this.queue.skip(e+1),this.consumed+=e+1};l();for(const e of i)l(),c.push(this.queue.take(e)),this.queue.skip(2),this.consumed+=e+2;return this.searched=0,0===c.length?[]:[{argv:c,index:this.index++,location:n}]}};function rt(e,t={}){const n=new st(t);return[...n.push("string"==typeof e?Buffer.from(e,"utf8"):e),...n.end()]}async function*at(e,t={},n=new st(t)){for await(const t of We(e))yield*n.push(t);yield*n.end()}var it=64,ot=4194304;function ct(e){let t=0;for(const n of e)t+=n.length;return t}async function lt(e){const{options:t={},signal:n,progress:s}=e;y(n);const r=t.stopOnError??!0,a=t.pipelineSize??it;if(!Number.isInteger(a)||a<1)throw new RangeError(`pipelineSize must be a positive integer, got ${a}`);const i=t.allowedCommands??"restore",o=t.restoreSessionState??!0,c=e=>{const n=t.databaseMapping;return n?"function"==typeof n?n(e):n[e]??e:e};s?.({phase:"connecting"});const l=await T(e.connection,n),{connection:u}=l,d=[],h=[],m=[],b=new st({...t,invalidLines:"report"});let E,S,v=0,x=!1,k=!1,R=!1,C=!1;const I=e=>{E=e,R=!0,m.includes(e)||m.push(e)},P=(e,t)=>{d.push(t),s?.({phase:"executing",commandsProcessed:v+d.length,bytesConsumed:b.bytesConsumed,error:{commandIndex:e.index,location:{offset:e.location.offset,...e.location.line?{line:e.location.line}:{}},commandPreview:t.commandPreview,message:t.message}}),r&&(k=!0)};let B=[],N=0;const M=async()=>{if(0===B.length)return;const e=B;B=[],N=0;const t=await O(u,e.map((e=>e.command)),n);e.forEach(((e,n)=>{const s=t[n],r=f(e.command);if(s?.ok)return v++,void("SELECT"===r?I(Number(p(e.command,1))):"MULTI"===r?C=!0:"EXEC"!==r&&"DISCARD"!==r||(C=!1));"EXEC"!==r&&"DISCARD"!==r||(C=!1);const a=function(e,t){const n=e.describeError?.(t);if(n)return n;const s=w(t),r=/^([A-Z][A-Z_]+)\s/.exec(s)?.[1];return r?{prefix:r,message:s}:void 0}(u,s?.error);P(e.parsed,{commandIndex:e.parsed.index,location:e.parsed.location,commandPreview:ye(e.command),message:w(s?.error),kind:"server",...a?{serverError:a}:{}})})),s?.({phase:"executing",commandsProcessed:v+d.length,bytesConsumed:b.bytesConsumed,...void 0===E?{}:{database:E}})};try{S=await D(u,n),E=S,void 0!==t.database&&(await A(u,t.database,n),I(t.database));for await(const s of at(e.source,t,b)){if(y(n),void 0!==s.invalid){if(await M(),P(s,{commandIndex:s.index,location:s.location,commandPreview:"",message:`Invalid argument(s): ${s.invalid}`,kind:"parse"}),k)break;continue}let e=s.argv;const t=f(e),r=pe(e,i);if(r){if(await M(),P(s,{commandIndex:s.index,location:s.location,commandPreview:ye(e),message:r,kind:"refused"}),k)break}else{if("SELECT"===t){const t=Number(p(e,1));Number.isInteger(t)&&t>=0&&(e=["SELECT",c(t)])}if(B.push({parsed:s,command:e}),N+=ct(s.argv),(B.length>=a||N>=ot)&&(await M(),k))break}}k||await M(),b.endedWithoutNewline&&h.push({code:"missing-final-newline",message:"The last line of the dump has no newline. It was executed, as redis-cli would, but a dump that was cut off also looks like this: check that the file is complete"})}catch(e){if(!g(e))throw e;x=!0}finally{s?.({phase:"finalizing",commandsProcessed:v+d.length}),o&&(C&&(await u.call(["DISCARD"]).catch((()=>{})),h.push({code:"transaction-discarded",message:"The restore stopped inside MULTI; the open transaction was discarded"})),R&&E!==S&&(void 0===S?h.push({code:"selected-database-unknown",message:`Could not tell which database the connection had selected before the restore; it is left on database ${E}`}):await A(u,S).catch((()=>{})))),await l.release()}return{commandsExecuted:v,commandsFailed:d.length,bytesConsumed:b.bytesConsumed,format:b.detectedFormat??"text",databases:m,errors:d,warnings:h,cancelled:x}}async function ut(e,t={}){const n=new st(t),s=new Ke,r={};let a=0;for await(const i of at(e,t,n)){s.note(i.argv);const e=f(i.argv);r[e]=(r[e]??0)+1,a++}return{format:n.detectedFormat??"text",commands:a,bytes:n.bytesConsumed,commandCounts:r,refusedByDefault:Object.keys(r).filter((e=>!de.has(e))).sort(),requirements:s.toRequirements()}}function dt(e){const t="string"==typeof e?Buffer.from(e,"utf8"):e;for(const e of t)if(32!==e&&9!==e&&10!==e&&13!==e)return 42===e?"resp":"text"}function ft(e){const t="string"==typeof e?Buffer.from(e,"utf8"):e,n=new st;try{const e=n.push(t).slice(0,5);return e.length>0&&e.every((e=>de.has(f(e.argv))))}catch(e){if(e instanceof tt)return!1;throw e}}var pt=n(203),ht=65536;async function mt(e,t,n,s,r){y(r);const a=ve(t),i=t.format??"text",o=t.databases??"current";!function(e){if(Array.isArray(e))for(const t of e)if(!Number.isInteger(t)||t<0)throw new RangeError(`Database numbers must be non-negative integers, got ${t}`)}(o);const c=function(e){return e instanceof pt.Writable?new we(e):e}(n),l=new _,u=new Ke;let d=[],f=0,p=0;const m=async()=>{if(0===d.length)return;const e=1===d.length?d[0]:Buffer.concat(d);d=[],f=0,await c.write(e,r)},w=async e=>{u.note(e);const n=ue(e,i,t.text);d.push(n),f+=n.length,p++,f>=ht&&await m()},b=()=>c.bytesWritten+f;s?.({phase:"connecting"});const E=await T(e,r),{connection:S}=E,x=[];let k,R,C=0,O=0,B=!1,M=!1;const L=e=>({bytesWritten:c.bytesWritten,commandsWritten:p,keysExported:C,keysSkipped:O,databases:x,warnings:l.toArray(),cancelled:B,requirements:u.toRequirements(),server:e});try{if(s?.({phase:"detecting-version"}),R=await q(S,r),"cluster"===R.mode)throw new h("cluster-unsupported","The server runs in cluster mode. Dump each primary node separately, through a connection to that node");if("sentinel"===R.mode)throw new h("sentinel-unsupported","The connection points at a Sentinel, which holds no data; connect to the primary it reports instead");if(!$(R.redisCompatibleVersion,P))throw new h("unsupported-version",`Redis ${R.version} is older than ${P}, the oldest version this package dumps`);const e=z(R),n=await Re.measure(S,r);k=await D(S,r);const c=await async function(e,t){return N(v(await e.call(["INFO","keyspace"],t)))}(S,r);let u,d;"current"===o?(u=[k??0],d=!1):"all"===o?(u=[...c.keys()].sort(((e,t)=>e-t)),d=!0):(u=o,d=!0),d&&void 0===k&&l.add({severity:"warning",code:"selected-database-unknown",message:"Could not tell which database the connection had selected (the adapter does not report it and CLIENT INFO needs Redis 6.2); it is left on the last database dumped"}),t.header&&await w(["ECHO",`${G} ${K} format=${i} source=${R.flavor}/${R.version} created=${(new Date).toISOString()}`]);for(const i of u){y(r),d&&(await A(S,i,r),M=!0,await w(["SELECT",i]));const o=c.get(i)??0;s?.({phase:"scanning",database:i,keysEstimated:o,totalKeysExported:C,bytesWritten:b()});const u=new Le({connection:S,capabilities:e,options:a,emit:w,diagnostics:l,clock:n,database:i,...t.selection?{selection:t.selection}:{},...r?{signal:r}:{},onLargeKey:e=>s?.({phase:"exporting-keys",database:i,keyName:I(e),totalKeysExported:C,commandsWritten:p,bytesWritten:b()})});let f=0,h=0;for await(const n of Ee(S,e,{count:a.scanCount,...t.selection?{selection:t.selection}:{},...void 0===t.deduplicateKeys?{}:{deduplicate:t.deduplicateKeys},...r?{signal:r}:{}})){const e=await u.exportPage(n);f+=e.keysExported,h+=e.keysSkipped,C+=e.keysExported,O+=e.keysSkipped,s?.({phase:"exporting-keys",database:i,keysExported:f,keysEstimated:o,totalKeysExported:C,commandsWritten:p,bytesWritten:b()})}x.push({database:i,keysExported:f,keysSkipped:h})}return s?.({phase:"finalizing",totalKeysExported:C,bytesWritten:b()}),await m(),L(R)}catch(e){if(!g(e)||void 0===R)throw e;return B=!0,L(R)}finally{M&&void 0!==k&&await A(S,k).catch((()=>{})),await E.release()}}},869:(e,t,n)=>{"use strict";Object.create;var s,r=Object.defineProperty,a=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,o=(Object.getPrototypeOf,Object.prototype.hasOwnProperty),c={};function l(e){if(Buffer.isBuffer(e))return e;if("number"==typeof e){if(!Number.isFinite(e))throw new TypeError(`Cannot send non-finite number ${e} as a Redis argument`);return Buffer.from(String(e),"latin1")}return Buffer.from(e,"utf8")}((e,t)=>{for(var n in t)r(e,n,{get:t[n],enumerable:!0})})(c,{IoredisConnectionAdapter:()=>y,connectIoredis:()=>E,describeIoredisError:()=>p,duplicateIoredis:()=>b,fromIoredis:()=>g}),e.exports=(s=c,((e,t,n,s)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let c of i(t))o.call(e,c)||c===n||r(e,c,{get:()=>t[c],enumerable:!(s=a(t,c))||s.enumerable});return e})(r({},"__esModule",{value:!0}),s));var u=class extends Error{code;constructor(e,t,n){super(t,n),this.name="RedisDumperError",this.code=e}},d=class extends u{constructor(e="The operation was cancelled"){super("operation-cancelled",e),this.name="OperationCancelledError"}};function f(e){if(e?.aborted)throw new d}function p(e){if(!(e instanceof Error))return;const t=/^([A-Z][A-Z_]+)\s/.exec(e.message)?.[1];return t?{prefix:t,message:e.message}:{message:e.message}}function h(e){const[t,...n]=e;if(void 0===t)throw new u("empty-command","Cannot send an empty command");return{name:l(t).toString("latin1"),args:n.map(l)}}function m(e,t){return t?(f(t),new Promise(((n,s)=>{const r=()=>s(new d);t.addEventListener("abort",r,{once:!0}),e.then((e=>{t.removeEventListener("abort",r),n(e)}),(e=>{t.removeEventListener("abort",r),s(e)}))}))):e}var y=class{constructor(e){this.client=e;const t=e;this.database=t.condition?.select??t.options.db??0,e.on("close",this.onClose)}client;closes=0;database;onClose=()=>{this.closes++};get selectedDatabase(){return this.database}detach(){this.client.off("close",this.onClose)}assertUsable(){if(this.closes>0)throw new u("connection-lost","The Redis connection was lost during the operation; ioredis reconnects on its own database, so the operation cannot safely continue")}noteSuccess(e){"SELECT"===function(e){const t=e[0];return void 0===t?"":l(t).toString("latin1").toUpperCase()}(e)&&void 0!==e[1]&&(this.database=Number(l(e[1]).toString("latin1")))}async call(e,t){this.assertUsable();const{name:n,args:s}=h(e),r=await m(this.client.callBuffer(n,s),t);return this.assertUsable(),this.noteSuccess(e),r}async pipeline(e,t){this.assertUsable();const n=this.client.pipeline();for(const t of e){const{name:e,args:s}=h(t);n.callBuffer(e,s)}const s=await m(n.exec(),t)??[];return this.assertUsable(),s.map((([t,n],s)=>t?{ok:!1,error:t}:(this.noteSuccess(e[s]),{ok:!0,reply:n})))}describeError(e){return p(e)}};function g(e){return new y(e)}var w={lazyConnect:!0,enableOfflineQueue:!1,autoResendUnfulfilledCommands:!1,maxRetriesPerRequest:0,retryStrategy:()=>null};function b(e){return{async acquire(t){f(t);const n=e.duplicate(w);await n.connect();const s=new y(n);let r=!1;return{connection:s,dedicated:!0,async release(){r||(r=!0,s.detach(),await n.quit().catch((()=>n.disconnect())))}}}}}async function E(e){const{Redis:t}=await Promise.resolve().then(n.t.bind(n,659,23)),s="string"==typeof e?new t(e,w):new t({...w,...e});try{await s.connect()}catch(e){throw s.disconnect(),new u("connect-failed",function(e){return e instanceof Error?e.message:String(e)}(e),{cause:e})}const r=new y(s);return{connection:r,client:s,async close(){r.detach(),await s.quit().catch((()=>s.disconnect()))}}}}},s={};function r(e){var t=s[e];if(void 0!==t)return t.exports;var a=s[e]={exports:{}};return n[e](a,a.exports,r),a.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(n,s){if(1&s&&(n=this(n)),8&s)return n;if("object"==typeof n&&n){if(4&s&&n.__esModule)return n;if(16&s&&"function"==typeof n.then)return n}var a=Object.create(null);r.r(a);var i={};e=e||[null,t({}),t([]),t(t)];for(var o=2&s&&n;"object"==typeof o&&!~e.indexOf(o);o=t(o))Object.getOwnPropertyNames(o).forEach((e=>i[e]=()=>n[e]));return i.default=()=>n,r.d(a,i),a},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a=r(237);module.exports=a})();
package/dist/frontend.js CHANGED
@@ -1 +1 @@
1
- var plugin;(()=>{var t={994:(t,e)=>{"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.firebirdSplitterOptions=e.oracleSplitterOptions=e.redisSplitterOptions=e.noSplitSplitterOptions=e.mongoSplitterOptions=e.sqliteSplitterOptions=e.postgreSplitterOptions=e.mssqlSplitterOptions=e.mysqlSplitterOptions=e.defaultSplitterOptions=void 0,e.defaultSplitterOptions={stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'},allowSemicolon:!0,allowCustomDelimiter:!1,allowCustomSqlTerminator:!1,allowCustomSetTerm:!1,allowGoDelimiter:!1,allowSlashDelimiter:!1,allowDollarDollarString:!1,noSplit:!1,skipSeparatorBeginEnd:!1,keepSemicolonInCommands:!1,doubleDashComments:!0,multilineComments:!0,javaScriptComments:!1,returnRichInfo:!1,splitByLines:!1,splitByEmptyLine:!1,preventSingleLineSplit:!1,adaptiveGoSplit:!1,ignoreComments:!1,copyFromStdin:!1,queryParameterStyle:null},e.mysqlSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowCustomDelimiter:!0,stringsBegins:["'","`",'"'],stringsEnds:{"'":"'","`":"`",'"':'"'},stringEscapes:{"'":"\\","`":"`",'"':"\\"}}),e.mssqlSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowSemicolon:!1,allowGoDelimiter:!0,keepSemicolonInCommands:!0,stringsBegins:["'","["],stringsEnds:{"'":"'","[":"]"},stringEscapes:{"'":"'"}}),e.postgreSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowDollarDollarString:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),e.sqliteSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{skipSeparatorBeginEnd:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),e.mongoSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"\\",'"':"\\"}}),e.noSplitSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{noSplit:!0}),e.redisSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{splitByLines:!0}),e.oracleSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowCustomSqlTerminator:!0,allowSlashDelimiter:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),e.firebirdSplitterOptions=Object.assign(Object.assign({},e.defaultSplitterOptions),{allowCustomSetTerm:!0,skipSeparatorBeginEnd:!0,queryParameterStyle:":"})},56:(t,e,s)=>{const{SqlDumper:i}=s.g.DBGATE_PACKAGES["dbgate-tools"];t.exports=class extends i{}},831:(t,e,s)=>{const{driverBase:i}=s.g.DBGATE_PACKAGES["dbgate-tools"],{redisChangeSetToRedisCommands:l}=s.g.DBGATE_PACKAGES["dbgate-datalib"],{redisSplitterOptions:r}=s(994),n={...i,dumperClass:s(56),dialect:{limitSelect:!0,rangeSelect:!0,offsetFetchRangeSyntax:!0,stringEscapeChar:"'",fallbackDataType:"nvarchar(max)",quoteIdentifier:t=>`[${t}]`},engine:"redis@dbgate-plugin-redis",title:"Redis",defaultPort:6379,editorMode:"text",authTypeFirst:!0,databaseEngineTypes:["keyvalue"],supportedCreateDatabase:!1,getQuerySplitterOptions:()=>r,databaseUrlPlaceholder:"e.g. redis://:authpassword@127.0.0.1:6380/4",authTypeLabel:"Connection mode",defaultAuthTypeName:"node",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path fill="#b71c1c" d="M45,29.316c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,29.316,3,29.832,3,30.469v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,32.882,45,32.83,45,32.775V29.316z"/><path fill="#e53935" d="M20.616,39.158c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,39.792,22.048,39.798,20.616,39.158z"/><path fill="#b71c1c" d="M45,21.675c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,21.675,3,22.192,3,22.829v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,25.242,45,25.19,45,25.135V21.675z"/><path fill="#e53935" d="M20.616,31.517c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,32.152,22.048,32.158,20.616,31.517z"/><path fill="#b71c1c" d="M45,14.035c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,14.035,3,14.551,3,15.188v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,17.601,45,17.549,45,17.494V14.035z"/><path fill="#e53935" d="M20.616,23.877c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,24.512,22.048,24.517,20.616,23.877z"/><path fill="#fff" d="M18.748,14.741c-0.002,1.042-2.762,2.057-5.093,2.086c-2.419,0.03-5.273-0.993-5.282-2.051\tc-0.009-1.061,2.842-2.161,5.311-2.135C16.017,12.665,18.751,13.703,18.748,14.741z"/><path fill="#fff" d="M17.038,18.471c2.393,1.022,4.785,2.045,7.178,3.067c1.054-1.56,2.108-3.12,3.162-4.68\tC23.931,17.396,20.485,17.934,17.038,18.471z"/><path fill="#fff" d="M21.86,9.775c-1.101,0.401-2.203,0.801-3.304,1.202c1.507,0.132,3.015,0.264,4.522,0.395\tc0.48,0.796,0.959,1.592,1.439,2.387c0.295-0.722,0.59-1.444,0.885-2.166c1.286-0.1,2.572-0.2,3.858-0.3\tc-0.997-0.419-1.994-0.839-2.991-1.259c0.254-0.608,0.508-1.216,0.762-1.825c-0.97,0.29-1.939,0.58-2.909,0.87\tc-1.07-0.422-2.14-0.843-3.21-1.265C21.228,8.468,21.544,9.122,21.86,9.775z"/><path fill="#b71c1c" d="M27.267,14.619c2.271-0.906,4.543-1.813,6.814-2.719c1.962,0.834,3.924,1.668,5.886,2.502\tc-2.202,0.876-4.403,1.752-6.605,2.629C31.331,16.226,29.299,15.423,27.267,14.619z"/><path fill="#a01c1c" d="M34.082,11.963c-0.005,1.596-0.01,3.191-0.015,4.787c1.967-0.783,3.934-1.565,5.901-2.348\tC38.006,13.589,36.044,12.776,34.082,11.963z"/></svg>',showConnectionField:(t,e)=>"useDatabaseUrl"==t?"cluster"!=e.authType:"authType"==t?!e.useDatabaseUrl:e.useDatabaseUrl?["databaseUrl","isReadOnly","treeKeySeparator"].includes(t):"cluster"==e.authType?["user","password","isReadOnly","treeKeySeparator","clusterNodes","autoDetectNatMap"].includes(t):["server","port","user","password","isReadOnly","treeKeySeparator"].includes(t),getAdvancedConnectionFields:()=>[{type:"checkbox",name:"skipSetName",label:"Skip SETNAME instruction"}],getKeyValueMethodCallList:t=>l(t)};t.exports=n}},e={};function s(i){var l=e[i];if(void 0!==l)return l.exports;var r=e[i]={exports:{}};return t[i](r,r.exports,s),r.exports}s.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return s.d(e,{a:e}),e},s.d=(t,e)=>{for(var i in e)s.o(e,i)&&!s.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),s.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),s.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};(()=>{"use strict";s.r(i),s.d(i,{default:()=>e});var t=s(831);const e={packageName:"dbgate-plugin-redis",drivers:[s.n(t)()]}})(),plugin=i})();
1
+ var plugin;(()=>{var e={994:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.firebirdSplitterOptions=t.oracleSplitterOptions=t.redisSplitterOptions=t.noSplitSplitterOptions=t.mongoSplitterOptions=t.sqliteSplitterOptions=t.postgreSplitterOptions=t.mssqlSplitterOptions=t.mysqlSplitterOptions=t.defaultSplitterOptions=void 0,t.defaultSplitterOptions={stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'},allowSemicolon:!0,allowCustomDelimiter:!1,allowCustomSqlTerminator:!1,allowCustomSetTerm:!1,allowGoDelimiter:!1,allowSlashDelimiter:!1,allowDollarDollarString:!1,noSplit:!1,skipSeparatorBeginEnd:!1,keepSemicolonInCommands:!1,doubleDashComments:!0,multilineComments:!0,javaScriptComments:!1,returnRichInfo:!1,splitByLines:!1,splitByEmptyLine:!1,preventSingleLineSplit:!1,adaptiveGoSplit:!1,ignoreComments:!1,copyFromStdin:!1,queryParameterStyle:null},t.mysqlSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowCustomDelimiter:!0,stringsBegins:["'","`",'"'],stringsEnds:{"'":"'","`":"`",'"':'"'},stringEscapes:{"'":"\\","`":"`",'"':"\\"}}),t.mssqlSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowSemicolon:!1,allowGoDelimiter:!0,keepSemicolonInCommands:!0,stringsBegins:["'","["],stringsEnds:{"'":"'","[":"]"},stringEscapes:{"'":"'"}}),t.postgreSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowDollarDollarString:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),t.sqliteSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{skipSeparatorBeginEnd:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),t.mongoSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"\\",'"':"\\"}}),t.noSplitSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{noSplit:!0}),t.redisSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{splitByLines:!0}),t.oracleSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowCustomSqlTerminator:!0,allowSlashDelimiter:!0,stringsBegins:["'",'"'],stringsEnds:{"'":"'",'"':'"'},stringEscapes:{"'":"'",'"':'"'}}),t.firebirdSplitterOptions=Object.assign(Object.assign({},t.defaultSplitterOptions),{allowCustomSetTerm:!0,skipSeparatorBeginEnd:!0,queryParameterStyle:":"})},56:(e,t,s)=>{const{SqlDumper:a}=s.g.DBGATE_PACKAGES["dbgate-tools"];e.exports=class extends a{}},831:(e,t,s)=>{const{driverBase:a,__t:i}=s.g.DBGATE_PACKAGES["dbgate-tools"],{redisChangeSetToRedisCommands:r}=s.g.DBGATE_PACKAGES["dbgate-datalib"],{redisSplitterOptions:l}=s(994),o={...a,dumperClass:s(56),dialect:{limitSelect:!0,rangeSelect:!0,offsetFetchRangeSyntax:!0,stringEscapeChar:"'",fallbackDataType:"nvarchar(max)",quoteIdentifier:e=>`[${e}]`},engine:"redis@dbgate-plugin-redis",title:"Redis",defaultPort:6379,editorMode:"text",authTypeFirst:!0,databaseEngineTypes:["keyvalue"],supportedCreateDatabase:!1,getQuerySplitterOptions:()=>l,databaseUrlPlaceholder:"e.g. redis://:authpassword@127.0.0.1:6380/4",authTypeLabel:"Connection mode",defaultAuthTypeName:"node",icon:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 48 48" width="48px" height="48px"><path fill="#b71c1c" d="M45,29.316c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,29.316,3,29.832,3,30.469v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,32.882,45,32.83,45,32.775V29.316z"/><path fill="#e53935" d="M20.616,39.158c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,39.792,22.048,39.798,20.616,39.158z"/><path fill="#b71c1c" d="M45,21.675c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,21.675,3,22.192,3,22.829v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,25.242,45,25.19,45,25.135V21.675z"/><path fill="#e53935" d="M20.616,31.517c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,32.152,22.048,32.158,20.616,31.517z"/><path fill="#b71c1c" d="M45,14.035c0-0.637-1.686-1.153-3.769-1.153c-1.812,0-3.32,0.391-3.683,0.911\tc-3.586-1.694-7.173-3.388-10.759-5.083c-1.248-0.59-2.673-0.584-3.918,0.014c-3.818,1.837-7.636,3.674-11.454,5.511\tc-0.864-0.126-1.907-0.201-3.032-0.201C5.408,14.035,3,14.551,3,15.188v3.46c0,0.033,0.033,0.064,0.045,0.096\tc-0.146,0.555,0.07,1.205,0.649,1.478c5.641,2.665,11.281,5.329,16.922,7.994c1.432,0.677,3.068,0.671,4.496-0.016\tc6.442-3.1,12.884-6.199,19.327-9.299c0.484-0.233,0.651-0.786,0.509-1.247C44.971,17.601,45,17.549,45,17.494V14.035z"/><path fill="#e53935" d="M20.616,23.877c-5.641-2.522-11.281-5.044-16.922-7.566c-0.922-0.412-0.926-1.727-0.007-2.146\tc6.395-2.912,12.789-5.824,19.184-8.736c1.244-0.567,2.67-0.572,3.918-0.014c5.881,2.63,11.763,5.259,17.644,7.889\tc0.754,0.337,0.758,1.414,0.006,1.756c-6.442,2.934-12.884,5.868-19.327,8.801C23.684,24.512,22.048,24.517,20.616,23.877z"/><path fill="#fff" d="M18.748,14.741c-0.002,1.042-2.762,2.057-5.093,2.086c-2.419,0.03-5.273-0.993-5.282-2.051\tc-0.009-1.061,2.842-2.161,5.311-2.135C16.017,12.665,18.751,13.703,18.748,14.741z"/><path fill="#fff" d="M17.038,18.471c2.393,1.022,4.785,2.045,7.178,3.067c1.054-1.56,2.108-3.12,3.162-4.68\tC23.931,17.396,20.485,17.934,17.038,18.471z"/><path fill="#fff" d="M21.86,9.775c-1.101,0.401-2.203,0.801-3.304,1.202c1.507,0.132,3.015,0.264,4.522,0.395\tc0.48,0.796,0.959,1.592,1.439,2.387c0.295-0.722,0.59-1.444,0.885-2.166c1.286-0.1,2.572-0.2,3.858-0.3\tc-0.997-0.419-1.994-0.839-2.991-1.259c0.254-0.608,0.508-1.216,0.762-1.825c-0.97,0.29-1.939,0.58-2.909,0.87\tc-1.07-0.422-2.14-0.843-3.21-1.265C21.228,8.468,21.544,9.122,21.86,9.775z"/><path fill="#b71c1c" d="M27.267,14.619c2.271-0.906,4.543-1.813,6.814-2.719c1.962,0.834,3.924,1.668,5.886,2.502\tc-2.202,0.876-4.403,1.752-6.605,2.629C31.331,16.226,29.299,15.423,27.267,14.619z"/><path fill="#a01c1c" d="M34.082,11.963c-0.005,1.596-0.01,3.191-0.015,4.787c1.967-0.783,3.934-1.565,5.901-2.348\tC38.006,13.589,36.044,12.776,34.082,11.963z"/></svg>',showConnectionField:(e,t)=>"useDatabaseUrl"==e?"cluster"!=t.authType:"authType"==e?!t.useDatabaseUrl:t.useDatabaseUrl?["databaseUrl","isReadOnly","treeKeySeparator"].includes(e):"cluster"==t.authType?["user","password","isReadOnly","treeKeySeparator","clusterNodes","autoDetectNatMap"].includes(e):["server","port","user","password","isReadOnly","treeKeySeparator"].includes(e),getAdvancedConnectionFields:()=>[{type:"checkbox",name:"skipSetName",label:"Skip SETNAME instruction"}],getKeyValueMethodCallList:e=>r(e),supportsNodejsBackup:!0,supportsNodejsRestore:!0,nodejsBackupTool:"dbgate-redis-dumper",nodejsRestoreTool:"dbgate-redis-dumper",restoreFileExtensions:["sql","redis","resp"],supportsNodejsDumperForConnection:e=>"cluster"!=e?.authType,getBackupFileExtension:e=>"resp"==e?.format?"resp":"redis",getNativeOperationFormArgs:e=>"backup"==e?[{type:"select",label:i("redisDriver.backupTool",{defaultMessage:"Backup tool"}),name:"backupTool",default:"dbgate-redis-dumper",testId:"BackupDatabaseTab_backupTool",options:[{name:"dbgate-redis-dumper",value:"dbgate-redis-dumper"}]},{type:"select",label:i("redisDriver.format",{defaultMessage:"Output format"}),name:"format",default:"text",testId:"BackupDatabaseTab_format",options:[{name:"Redis commands (redis-cli < file)",value:"text"},{name:"RESP protocol (redis-cli --pipe < file)",value:"resp"}]},{type:"text",label:i("redisDriver.keyPattern",{defaultMessage:"Key pattern (e.g. user:*)"}),name:"keyPattern",testId:"BackupDatabaseTab_keyPattern",default:""},{type:"select",label:i("redisDriver.expiration",{defaultMessage:"Key expiration"}),name:"expiration",default:"absolute",options:[{name:"Keep absolute expiry time",value:"absolute"},{name:"Keep remaining time to live",value:"relative"},{name:"Drop expiration (keys never expire)",value:"none"}]},{type:"select",label:i("redisDriver.strategy",{defaultMessage:"Value encoding"}),name:"strategy",default:"commands",options:[{name:"Commands (portable across versions)",value:"commands"},{name:"DUMP payloads (exact, same or newer server only)",value:"payload"}]},{type:"checkbox",label:i("redisDriver.replace",{defaultMessage:"Replace existing keys on restore"}),name:"replace",default:!0},{type:"checkbox",label:i("redisDriver.streamGroups",{defaultMessage:"Include stream consumer groups and pending entries"}),name:"streamGroups",default:!0},{type:"checkbox",label:i("redisDriver.allDatabases",{defaultMessage:"All databases (restores each into its original database)"}),name:"allDatabases",default:!1}]:"restore"==e?[{type:"select",label:i("redisDriver.restoreTool",{defaultMessage:"Restore tool"}),name:"restoreTool",default:"dbgate-redis-dumper",testId:"RestoreDatabaseTab_restoreTool",options:[{name:"dbgate-redis-dumper",value:"dbgate-redis-dumper"}]}]:null};e.exports=o}},t={};function s(a){var i=t[a];if(void 0!==i)return i.exports;var r=t[a]={exports:{}};return e[a](r,r.exports,s),r.exports}s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var a in t)s.o(t,a)&&!s.o(e,a)&&Object.defineProperty(e,a,{enumerable:!0,get:t[a]})},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var a={};(()=>{"use strict";s.r(a),s.d(a,{default:()=>t});var e=s(831);const t={packageName:"dbgate-plugin-redis",drivers:[s.n(e)()]}})(),plugin=a})();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dbgate-plugin-redis",
3
3
  "main": "dist/backend.js",
4
- "version": "7.3.1",
4
+ "version": "7.3.2",
5
5
  "license": "GPL-3.0",
6
6
  "description": "Redis connector plugin for DbGate",
7
7
  "homepage": "https://www.dbgate.io",
@@ -35,10 +35,10 @@
35
35
  },
36
36
  "dependencies": {
37
37
  "dbgate-query-splitter": "^4.12.0",
38
- "dbgate-tools": "7.3.1",
38
+ "dbgate-tools": "7.3.2",
39
39
  "lodash": "^4.17.21",
40
40
  "async": "^3.2.3",
41
- "ioredis": "^5.4.1",
42
- "node-redis-dump2": "^0.5.0"
41
+ "dbgate-redis-dumper": "^0.1.0",
42
+ "ioredis": "^5.4.1"
43
43
  }
44
44
  }