dbgate-plugin-xml 5.2.0 → 5.2.2-alpha.11

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.
Files changed (2) hide show
  1. package/dist/backend.js +1 -1
  2. package/package.json +1 -1
package/dist/backend.js CHANGED
@@ -1 +1 @@
1
- module.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var i=e[s]={i:s,l:!1,exports:{}};return t[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(s,i,function(e){return t[e]}.bind(null,i));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){t.exports=require("stream")},function(t,e){t.exports=require("fs")},function(t,e,n){const s=n(3),i=n(6);t.exports={packageName:"dbgate-plugin-xml",shellApi:{reader:s,writer:i}}},function(t,e,n){const s=n(1),i=n(0),r=n(4);class o extends i.Transform{constructor({itemElementName:t}){super({objectMode:!0});let e=t;this.push({__isStreamHeader:!0,__isDynamicStructure:!0}),this.rowsWritten=0,this.parser=new r,this.stack=[],this.parser.on("opentag",(t,n)=>{e||1!=this.stack.length||(e=t),this.stack.push({name:t,attrs:n,nodes:{}})}),this.parser.on("text",t=>{this.stack.length>=2&&(this.stack[this.stack.length-2].nodes[this.stack[this.stack.length-1].name]=t),this.stack.length>=1&&(this.stack[this.stack.length-1].nodes.$text=t)}),this.parser.on("cdata",t=>{this.stack.length>=2&&(this.stack[this.stack.length-2].nodes[this.stack[this.stack.length-1].name]=t),this.stack.length>=1&&(this.stack[this.stack.length-1].nodes.$text=t)}),this.parser.on("closetag",(t,n)=>{if(t==e){const t={...this.stack[this.stack.length-1].attrs,...this.stack[this.stack.length-1].nodes};Object.keys(t).length>0&&(this.rowsWritten+=1,this.push(t))}this.stack.splice(-1)})}_transform(t,e,n){this.parser.write(t),n()}}t.exports=async function({fileName:t,encoding:e="utf-8",itemElementName:n}){console.log("Reading file "+t);const i=s.createReadStream(t,e),r=new o({itemElementName:n});return i.pipe(r),r}},function(t,e,n){"use strict";var s,i=n(5),r=(s=i)&&s.__esModule?s:{default:s};t.exports=r.default},function(t,e,n){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};Object.defineProperty(e,"__esModule",{value:!0}),e.EVENTS=void 0;var i=function(){function t(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}return function(e,n,s){return n&&t(e.prototype,n),s&&t(e,s),e}}();var r=function(t){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var t=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==(void 0===e?"undefined":s(e))&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return t.state=o.TEXT,t.buffer="",t.pos=0,t.tagType=a.NONE,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+(void 0===e?"undefined":s(e)));t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),i(e,[{key:"_write",value:function(t,e,n){t="string"!=typeof t?t.toString():t;for(var s=0;s<t.length;s++){var i=t[s],r=this.buffer[this.pos-1];switch(this.buffer+=i,this.pos++,this.state){case o.TEXT:"<"===i&&this._onStartNewTag();break;case o.TAG_NAME:"<"===r&&"?"===i&&this._onStartInstruction(),"<"===r&&"/"===i&&this._onCloseTagStart(),"<"===this.buffer[this.pos-3]&&"!"===r&&"["===i&&this._onCDATAStart(),"<"===this.buffer[this.pos-3]&&"!"===r&&"-"===i&&this._onCommentStart(),">"===i&&("/"===r&&(this.tagType=a.SELF_CLOSING),this._onTagCompleted());break;case o.INSTRUCTION:"?"===r&&">"===i&&this._onEndInstruction();break;case o.CDATA:"]"===this.buffer[this.pos-3]&&"]"===r&&">"===i&&this._onCDATAEnd();break;case o.IGNORE_COMMENT:"-"===this.buffer[this.pos-3]&&"-"===r&&">"===i&&this._onCommentEnd()}}n()}},{key:"_endRecording",value:function(){var t=this.buffer.slice(1,this.pos-1);return this.buffer=this.buffer.slice(-1),this.pos=1,t}},{key:"_onStartNewTag",value:function(){var t=this._endRecording().trim();t&&this.emit(u.TEXT,t),this.state=o.TAG_NAME,this.tagType=a.OPENING}},{key:"_onTagCompleted",value:function(){var t=this._endRecording(),e=this._parseTagString(t),n=e.name,s=e.attributes;null===n&&this.emit(u.ERROR,new Error("Failed to parse name for tag"+t)),this.tagType&&this.tagType==a.OPENING&&this.emit(u.OPEN_TAG,n,s),this.tagType&&this.tagType===a.CLOSING&&this.emit(u.CLOSE_TAG,n,s),this.tagType&&this.tagType===a.SELF_CLOSING&&(0===Object.keys(s).length&&s.constructor===Object&&(s={___selfClosing___:!0}),this.emit(u.OPEN_TAG,n,s),this.emit(u.CLOSE_TAG,n,s)),this.state=o.TEXT,this.tagType=a.NONE}},{key:"_onCloseTagStart",value:function(){this._endRecording(),this.tagType=a.CLOSING}},{key:"_onStartInstruction",value:function(){this._endRecording(),this.state=o.INSTRUCTION}},{key:"_onEndInstruction",value:function(){this.pos-=1;var t=this._endRecording(),e=this._parseTagString(t),n=e.name,s=e.attributes;null===n&&this.emit(u.ERROR,new Error("Failed to parse name for inst"+t)),this.emit(u.INSTRUCTION,n,s),this.state=o.TEXT}},{key:"_onCDATAStart",value:function(){this._endRecording(),this.state=o.CDATA}},{key:"_onCDATAEnd",value:function(){var t=this._endRecording();t=t.slice(t.indexOf("[")+1,t.lastIndexOf("]>")-1),this.state=o.TEXT,this.emit(u.CDATA,t)}},{key:"_onCommentStart",value:function(){this.state=o.IGNORE_COMMENT}},{key:"_onCommentEnd",value:function(){this._endRecording(),this.state=o.TEXT}},{key:"_parseTagString",value:function(t){var e=void 0,n=/^([a-zäöüßÄÖÜA-Z0-9:_\-.\/]+?)(\s|$)/.exec(t);if(n&&n.length>0){e=n[1];for(var s=t.substr(e.length),i=/([a-zäöüßÄÖÜA-Z0-9:_\-.]+?)="([^"]+?)"/g,r=i.exec(s),o={};null!=r;)o[r[1]]=r[2],r=i.exec(s);return"/"===e[e.length-1]&&(e=e.substr(0,e.length-1)),{name:e,attributes:o}}return{name:null,attributes:{}}}}]),e}(n(0).Writable);e.default=r;var o={TEXT:0,TAG_NAME:1,INSTRUCTION:2,IGNORE_COMMENT:4,CDATA:8},a={NONE:0,OPENING:1,CLOSING:2,SELF_CLOSING:3},u=e.EVENTS={ERROR:"error",TEXT:"text",INSTRUCTION:"instruction",OPEN_TAG:"opentag",CLOSE_TAG:"closetag",CDATA:"cdata"}},function(t,e,n){const s=n(1),i=n(0);class r extends i.Transform{constructor({itemElementName:t,rootElementName:e}){super({objectMode:!0}),this.itemElementName=t||"row",this.rootElementName=e||"root",this.startElement(this.rootElementName),this.push("\n")}startElement(t){this.push("<"),this.push(t),this.push(">")}endElement(t){this.push("</"),this.push(t),this.push(">\n")}elementValue(t,e){this.startElement(t),this.push(function(t){return t.replace(/[<>&'"]/g,(function(t){switch(t){case"<":return"&lt;";case">":return"&gt;";case"&":return"&amp;";case"'":return"&apos;";case'"':return"&quot;"}}))}(""+e)),this.endElement(t)}_transform(t,e,n){if(t.__isStreamHeader)n();else{this.startElement(this.itemElementName),this.push("\n");for(const e of Object.keys(t))this.elementValue(e,t[e]);this.endElement(this.itemElementName),n()}}_final(t){this.endElement(this.rootElementName),t()}}t.exports=async function({fileName:t,encoding:e="utf-8",itemElementName:n,rootElementName:i}){console.log("Writing file "+t);const o=new r({itemElementName:n,rootElementName:i}),a=s.createWriteStream(t,e);return o.pipe(a),o.finisher=a,o}}]);
1
+ module.exports=function(t){var e={};function n(s){if(e[s])return e[s].exports;var r=e[s]={i:s,l:!1,exports:{}};return t[s].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,s){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:s})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(s,r,function(e){return t[e]}.bind(null,r));return s},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=2)}([function(t,e){t.exports=require("stream")},function(t,e){t.exports=require("fs")},function(t,e,n){const s=n(3),r=n(6);t.exports={packageName:"dbgate-plugin-xml",shellApi:{reader:s,writer:r}}},function(t,e,n){const s=n(1),r=n(0),i=n(4),{getLogger:o}=global.DBGATE_TOOLS,a=o("xmlReader");class u extends r.Transform{constructor({itemElementName:t}){super({objectMode:!0});let e=t;this.push({__isStreamHeader:!0,__isDynamicStructure:!0}),this.rowsWritten=0,this.parser=new i,this.stack=[],this.parser.on("opentag",(t,n)=>{e||1!=this.stack.length||(e=t),this.stack.push({name:t,attrs:n,nodes:{}})}),this.parser.on("text",t=>{this.stack.length>=2&&(this.stack[this.stack.length-2].nodes[this.stack[this.stack.length-1].name]=t),this.stack.length>=1&&(this.stack[this.stack.length-1].nodes.$text=t)}),this.parser.on("cdata",t=>{this.stack.length>=2&&(this.stack[this.stack.length-2].nodes[this.stack[this.stack.length-1].name]=t),this.stack.length>=1&&(this.stack[this.stack.length-1].nodes.$text=t)}),this.parser.on("closetag",(t,n)=>{if(t==e){const t={...this.stack[this.stack.length-1].attrs,...this.stack[this.stack.length-1].nodes};Object.keys(t).length>0&&(this.rowsWritten+=1,this.push(t))}this.stack.splice(-1)})}_transform(t,e,n){this.parser.write(t),n()}}t.exports=async function({fileName:t,encoding:e="utf-8",itemElementName:n}){a.info("Reading file "+t);const r=s.createReadStream(t,e),i=new u({itemElementName:n});return r.pipe(i),i}},function(t,e,n){"use strict";var s,r=n(5),i=(s=r)&&s.__esModule?s:{default:s};t.exports=i.default},function(t,e,n){"use strict";var s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};Object.defineProperty(e,"__esModule",{value:!0}),e.EVENTS=void 0;var r=function(){function t(t,e){for(var n=0;n<e.length;n++){var s=e[n];s.enumerable=s.enumerable||!1,s.configurable=!0,"value"in s&&(s.writable=!0),Object.defineProperty(t,s.key,s)}}return function(e,n,s){return n&&t(e.prototype,n),s&&t(e,s),e}}();var i=function(t){function e(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e);var t=function(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!==(void 0===e?"undefined":s(e))&&"function"!=typeof e?t:e}(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return t.state=o.TEXT,t.buffer="",t.pos=0,t.tagType=a.NONE,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+(void 0===e?"undefined":s(e)));t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}(e,t),r(e,[{key:"_write",value:function(t,e,n){t="string"!=typeof t?t.toString():t;for(var s=0;s<t.length;s++){var r=t[s],i=this.buffer[this.pos-1];switch(this.buffer+=r,this.pos++,this.state){case o.TEXT:"<"===r&&this._onStartNewTag();break;case o.TAG_NAME:"<"===i&&"?"===r&&this._onStartInstruction(),"<"===i&&"/"===r&&this._onCloseTagStart(),"<"===this.buffer[this.pos-3]&&"!"===i&&"["===r&&this._onCDATAStart(),"<"===this.buffer[this.pos-3]&&"!"===i&&"-"===r&&this._onCommentStart(),">"===r&&("/"===i&&(this.tagType=a.SELF_CLOSING),this._onTagCompleted());break;case o.INSTRUCTION:"?"===i&&">"===r&&this._onEndInstruction();break;case o.CDATA:"]"===this.buffer[this.pos-3]&&"]"===i&&">"===r&&this._onCDATAEnd();break;case o.IGNORE_COMMENT:"-"===this.buffer[this.pos-3]&&"-"===i&&">"===r&&this._onCommentEnd()}}n()}},{key:"_endRecording",value:function(){var t=this.buffer.slice(1,this.pos-1);return this.buffer=this.buffer.slice(-1),this.pos=1,t}},{key:"_onStartNewTag",value:function(){var t=this._endRecording().trim();t&&this.emit(u.TEXT,t),this.state=o.TAG_NAME,this.tagType=a.OPENING}},{key:"_onTagCompleted",value:function(){var t=this._endRecording(),e=this._parseTagString(t),n=e.name,s=e.attributes;null===n&&this.emit(u.ERROR,new Error("Failed to parse name for tag"+t)),this.tagType&&this.tagType==a.OPENING&&this.emit(u.OPEN_TAG,n,s),this.tagType&&this.tagType===a.CLOSING&&this.emit(u.CLOSE_TAG,n,s),this.tagType&&this.tagType===a.SELF_CLOSING&&(0===Object.keys(s).length&&s.constructor===Object&&(s={___selfClosing___:!0}),this.emit(u.OPEN_TAG,n,s),this.emit(u.CLOSE_TAG,n,s)),this.state=o.TEXT,this.tagType=a.NONE}},{key:"_onCloseTagStart",value:function(){this._endRecording(),this.tagType=a.CLOSING}},{key:"_onStartInstruction",value:function(){this._endRecording(),this.state=o.INSTRUCTION}},{key:"_onEndInstruction",value:function(){this.pos-=1;var t=this._endRecording(),e=this._parseTagString(t),n=e.name,s=e.attributes;null===n&&this.emit(u.ERROR,new Error("Failed to parse name for inst"+t)),this.emit(u.INSTRUCTION,n,s),this.state=o.TEXT}},{key:"_onCDATAStart",value:function(){this._endRecording(),this.state=o.CDATA}},{key:"_onCDATAEnd",value:function(){var t=this._endRecording();t=t.slice(t.indexOf("[")+1,t.lastIndexOf("]>")-1),this.state=o.TEXT,this.emit(u.CDATA,t)}},{key:"_onCommentStart",value:function(){this.state=o.IGNORE_COMMENT}},{key:"_onCommentEnd",value:function(){this._endRecording(),this.state=o.TEXT}},{key:"_parseTagString",value:function(t){var e=void 0,n=/^([a-zäöüßÄÖÜA-Z0-9:_\-.\/]+?)(\s|$)/.exec(t);if(n&&n.length>0){e=n[1];for(var s=t.substr(e.length),r=/([a-zäöüßÄÖÜA-Z0-9:_\-.]+?)="([^"]+?)"/g,i=r.exec(s),o={};null!=i;)o[i[1]]=i[2],i=r.exec(s);return"/"===e[e.length-1]&&(e=e.substr(0,e.length-1)),{name:e,attributes:o}}return{name:null,attributes:{}}}}]),e}(n(0).Writable);e.default=i;var o={TEXT:0,TAG_NAME:1,INSTRUCTION:2,IGNORE_COMMENT:4,CDATA:8},a={NONE:0,OPENING:1,CLOSING:2,SELF_CLOSING:3},u=e.EVENTS={ERROR:"error",TEXT:"text",INSTRUCTION:"instruction",OPEN_TAG:"opentag",CLOSE_TAG:"closetag",CDATA:"cdata"}},function(t,e,n){const s=n(1),r=n(0),{getLogger:i}=global.DBGATE_TOOLS,o=i("xmlWriter");class a extends r.Transform{constructor({itemElementName:t,rootElementName:e}){super({objectMode:!0}),this.itemElementName=t||"row",this.rootElementName=e||"root",this.startElement(this.rootElementName),this.push("\n")}startElement(t){this.push("<"),this.push(t),this.push(">")}endElement(t){this.push("</"),this.push(t),this.push(">\n")}elementValue(t,e){this.startElement(t),this.push(function(t){return t.replace(/[<>&'"]/g,(function(t){switch(t){case"<":return"&lt;";case">":return"&gt;";case"&":return"&amp;";case"'":return"&apos;";case'"':return"&quot;"}}))}(""+e)),this.endElement(t)}_transform(t,e,n){if(t.__isStreamHeader)n();else{this.startElement(this.itemElementName),this.push("\n");for(const e of Object.keys(t))this.elementValue(e,t[e]);this.endElement(this.itemElementName),n()}}_final(t){this.endElement(this.rootElementName),t()}}t.exports=async function({fileName:t,encoding:e="utf-8",itemElementName:n,rootElementName:r}){o.info("Writing file "+t);const i=new a({itemElementName:n,rootElementName:r}),u=s.createWriteStream(t,e);return i.pipe(u),i.finisher=u,i}}]);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "dbgate-plugin-xml",
3
3
  "main": "dist/backend.js",
4
- "version": "5.2.0",
4
+ "version": "5.2.2-alpha.11",
5
5
  "homepage": "https://dbgate.org",
6
6
  "description": "XML import/export plugin for DbGate",
7
7
  "repository": {