dbgate-plugin-xml 4.6.1

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/README.md ADDED
@@ -0,0 +1,6 @@
1
+ [![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)
2
+ [![NPM version](https://img.shields.io/npm/v/dbgate-plugin-xml.svg)](https://www.npmjs.com/package/dbgate-plugin-xml)
3
+
4
+ # dbgate-plugin-xml
5
+
6
+ Use DbGate for install of this plugin
@@ -0,0 +1 @@
1
+ module.exports=function(t){var e={};function n(r){if(e[r])return e[r].exports;var s=e[r]={i:r,l:!1,exports:{}};return t[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var s in t)n.d(r,s,function(e){return t[e]}.bind(null,s));return r},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 r=n(3),s=n(6);t.exports={packageName:"dbgate-plugin-xml",shellApi:{reader:r,writer:s}}},function(t,e,n){const r=n(1),s=n(0),i=n(4);class o extends s.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.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 s=r.createReadStream(t,e),i=new o({itemElementName:n});return s.pipe(i),i}},function(t,e,n){"use strict";var r,s=n(5),i=(r=s)&&r.__esModule?r:{default:r};t.exports=i.default},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.EVENTS=void 0;var r=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,s=!1,i=void 0;try{for(var o,a=t[Symbol.iterator]();!(r=(o=a.next()).done)&&(n.push(o.value),!e||n.length!==e);r=!0);}catch(t){s=!0,i=t}finally{try{!r&&a.return&&a.return()}finally{if(s)throw i}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},s=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),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"!=typeof 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.isCloseTag=!1,t}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof 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),s(e,[{key:"_write",value:function(t,e,n){t="string"!=typeof t?t.toString():t;for(var r=0;r<t.length;r++){var s=t[r],i=this.buffer[this.pos-1];switch(this.buffer+=s,this.pos++,this.state){case o.TEXT:"<"===s&&this._onStartNewTag();break;case o.TAG_NAME:"<"===i&&"?"===s&&this._onStartInstruction(),"<"===i&&"/"===s&&this._onCloseTagStart(),"<"===this.buffer[this.pos-3]&&"!"===i&&"["===s&&this._onCDATAStart(),"<"===this.buffer[this.pos-3]&&"!"===i&&"-"===s&&this._onCommentStart(),">"===s&&this._onTagCompleted();break;case o.INSTRUCTION:"?"===i&&">"===s&&this._onEndInstruction();break;case o.CDATA:"]"===i&&"]"===s&&this._onCDATAEnd();break;case o.IGNORE_COMMENT:"-"===this.buffer[this.pos-3]&&"-"===i&&">"===s&&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(a.TEXT,t),this.state=o.TAG_NAME}},{key:"_onTagCompleted",value:function(){var t=this._endRecording(),e=this._parseTagString(t),n=e.name,r=e.attributes;this.isCloseTag?this.emit(a.CLOSE_TAG,n,r):this.emit(a.OPEN_TAG,n,r),this.isCloseTag=!1,this.state=o.TEXT}},{key:"_onCloseTagStart",value:function(){this._endRecording(),this.isCloseTag=!0}},{key:"_onStartInstruction",value:function(){this._endRecording(),this.state=o.INSTRUCTION}},{key:"_onEndInstruction",value:function(){this.pos-=2;var t=this._endRecording(),e=this._parseTagString(t),n=e.name,r=e.attributes;this.emit(a.INSTRUCTION,n,r),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("]")),this.state=o.TEXT,this.emit(a.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,n=t.split(/\s+(?=[\w:]+=)/g),s=(e=n,Array.isArray(e)?e:Array.from(e)),i=s[0],o=s.slice(1),a={};return o.forEach((function(t){var e=t.split("="),n=r(e,2),s=n[0],i=n[1];a[s]=i.trim().replace(/"|'/g,"")})),{name:i,attributes:a}}}]),e}(n(0).Writable);e.default=i;var o={TEXT:0,TAG_NAME:1,INSTRUCTION:2,IGNORE_COMMENT:4,CDATA:8},a=e.EVENTS={TEXT:"text",INSTRUCTION:"instruction",OPEN_TAG:"opentag",CLOSE_TAG:"closetag",CDATA:"cdata"}},function(t,e,n){const r=n(1),s=n(0);class i extends s.Transform{constructor({itemElementName:t,rootElementName:e}){super({objectMode:!0}),this.itemElementName=t,this.rootElementName=e,this.startElement(this.rootElementName)}startElement(t){this.push("<"),this.push(t),this.push(">\n")}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){this.startElement(this.itemElementName);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:s}){console.log(`Writing file ${t}`);const o=new i({itemElementName:n,rootElementName:s}),a=r.createWriteStream(t,e);return o.pipe(a),o.finisher=a,o}}]);
@@ -0,0 +1 @@
1
+ var plugin=function(e){var t={};function n(r){if(t[r])return t[r].exports;var a=t[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,n),a.l=!0,a.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)n.d(r,a,function(t){return e[t]}.bind(null,a));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);t.default={fileFormats:[{packageName:"dbgate-plugin-xml",storageType:"xml@dbgate-plugin-xml",extension:"xml",name:"XML file",readerFunc:"reader@dbgate-plugin-xml",writerFunc:"writer@dbgate-plugin-xml",args:[{type:"text",name:"rootElementName",label:"Root element name",apiName:"rootElementName",direction:"target"},{type:"text",name:"itemElementName",label:"Item element name",apiName:"itemElementName"}]}]}}]);
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "dbgate-plugin-xml",
3
+ "main": "dist/backend.js",
4
+ "version": "4.6.1",
5
+ "homepage": "https://dbgate.org",
6
+ "description": "XML import/export plugin for DbGate",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/dbgate/dbgate"
10
+ },
11
+ "author": "Jan Prochazka",
12
+ "license": "MIT",
13
+ "keywords": [
14
+ "xml",
15
+ "import",
16
+ "export",
17
+ "dbgate",
18
+ "dbgateplugin"
19
+ ],
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build:frontend": "webpack --config webpack-frontend.config",
25
+ "build:frontend:watch": "webpack --watch --config webpack-frontend.config",
26
+ "build:backend": "webpack --config webpack-backend.config.js",
27
+ "build": "yarn build:frontend && yarn build:backend",
28
+ "plugin": "yarn build && yarn pack && dbgate-plugin dbgate-plugin-xml",
29
+ "copydist": "yarn build && yarn pack && dbgate-copydist ../dist/dbgate-plugin-xml",
30
+ "plugout": "dbgate-plugout dbgate-plugin-xml",
31
+ "prepublishOnly": "yarn build"
32
+ },
33
+ "devDependencies": {
34
+ "node-xml-stream": "^1.0.2",
35
+ "dbgate-plugin-tools": "^1.0.7",
36
+ "webpack": "^4.42.0",
37
+ "webpack-cli": "^3.3.11"
38
+ }
39
+ }