mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-18 02:06:01 +00:00
xml plugin initial import
This commit is contained in:
25
plugins/dbgate-plugin-xml/.gitignore
vendored
Normal file
25
plugins/dbgate-plugin-xml/.gitignore
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||
|
||||
# dependencies
|
||||
node_modules
|
||||
/.pnp
|
||||
.pnp.js
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
build
|
||||
dist
|
||||
lib
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env.local
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
6
plugins/dbgate-plugin-xml/README.md
Normal file
6
plugins/dbgate-plugin-xml/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
[](https://github.com/prettier/prettier)
|
||||
[](https://www.npmjs.com/package/dbgate-plugin-xml)
|
||||
|
||||
# dbgate-plugin-xml
|
||||
|
||||
Use DbGate for install of this plugin
|
||||
28
plugins/dbgate-plugin-xml/icon.svg
Normal file
28
plugins/dbgate-plugin-xml/icon.svg
Normal file
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 56 56" style="enable-background:new 0 0 56 56;" xml:space="preserve">
|
||||
<g>
|
||||
<path style="fill:#E9E9E0;" d="M36.985,0H7.963C7.155,0,6.5,0.655,6.5,1.926V55c0,0.345,0.655,1,1.463,1h40.074
|
||||
c0.808,0,1.463-0.655,1.463-1V12.978c0-0.696-0.093-0.92-0.257-1.085L37.607,0.257C37.442,0.093,37.218,0,36.985,0z"/>
|
||||
<polygon style="fill:#D9D7CA;" points="37.5,0.151 37.5,12 49.349,12 "/>
|
||||
<path style="fill:#F29C1F;" d="M48.037,56H7.963C7.155,56,6.5,55.345,6.5,54.537V39h43v15.537C49.5,55.345,48.845,56,48.037,56z"/>
|
||||
<g>
|
||||
<path style="fill:#FFFFFF;" d="M19.379,48.105L21.936,53h-1.9l-1.6-3.801h-0.137L16.576,53h-1.9l2.557-4.895l-2.721-5.182h1.873
|
||||
l1.777,4.102h0.137l1.928-4.102H22.1L19.379,48.105z"/>
|
||||
<path style="fill:#FFFFFF;" d="M31.998,42.924h1.668V53h-1.668v-6.932l-2.256,5.605h-1.449l-2.27-5.605V53h-1.668V42.924h1.668
|
||||
l2.994,6.891L31.998,42.924z"/>
|
||||
<path style="fill:#FFFFFF;" d="M37.863,42.924v8.832h4.635V53h-6.303V42.924H37.863z"/>
|
||||
</g>
|
||||
<path style="fill:#F29C1F;" d="M15.5,24c-0.256,0-0.512-0.098-0.707-0.293c-0.391-0.391-0.391-1.023,0-1.414l6-6
|
||||
c0.391-0.391,1.023-0.391,1.414,0s0.391,1.023,0,1.414l-6,6C16.012,23.902,15.756,24,15.5,24z"/>
|
||||
<path style="fill:#F29C1F;" d="M21.5,30c-0.256,0-0.512-0.098-0.707-0.293l-6-6c-0.391-0.391-0.391-1.023,0-1.414
|
||||
s1.023-0.391,1.414,0l6,6c0.391,0.391,0.391,1.023,0,1.414C22.012,29.902,21.756,30,21.5,30z"/>
|
||||
<path style="fill:#F29C1F;" d="M33.5,30c-0.256,0-0.512-0.098-0.707-0.293c-0.391-0.391-0.391-1.023,0-1.414l6-6
|
||||
c0.391-0.391,1.023-0.391,1.414,0s0.391,1.023,0,1.414l-6,6C34.012,29.902,33.756,30,33.5,30z"/>
|
||||
<path style="fill:#F29C1F;" d="M39.5,24c-0.256,0-0.512-0.098-0.707-0.293l-6-6c-0.391-0.391-0.391-1.023,0-1.414
|
||||
s1.023-0.391,1.414,0l6,6c0.391,0.391,0.391,1.023,0,1.414C40.012,23.902,39.756,24,39.5,24z"/>
|
||||
<path style="fill:#F29C1F;" d="M24.5,32c-0.11,0-0.223-0.019-0.333-0.058c-0.521-0.184-0.794-0.755-0.61-1.276l6-17
|
||||
c0.185-0.521,0.753-0.795,1.276-0.61c0.521,0.184,0.794,0.755,0.61,1.276l-6,17C25.298,31.744,24.912,32,24.5,32z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.2 KiB |
39
plugins/dbgate-plugin-xml/package.json
Normal file
39
plugins/dbgate-plugin-xml/package.json
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "dbgate-plugin-xml",
|
||||
"main": "dist/backend.js",
|
||||
"version": "1.0.0",
|
||||
"homepage": "https://dbgate.org",
|
||||
"description": "XML import/export plugin for DbGate",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dbgate/dbgate"
|
||||
},
|
||||
"author": "Jan Prochazka",
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"xml",
|
||||
"import",
|
||||
"export",
|
||||
"dbgate",
|
||||
"dbgateplugin"
|
||||
],
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build:frontend": "webpack --config webpack-frontend.config",
|
||||
"build:frontend:watch": "webpack --watch --config webpack-frontend.config",
|
||||
"build:backend": "webpack --config webpack-backend.config.js",
|
||||
"build": "yarn build:frontend && yarn build:backend",
|
||||
"plugin": "yarn build && yarn pack && dbgate-plugin dbgate-plugin-xml",
|
||||
"plugout": "dbgate-plugout dbgate-plugin-xml",
|
||||
"prepublishOnly": "yarn build"
|
||||
},
|
||||
"devDependencies": {
|
||||
"node-xml-stream": "^1.0.2",
|
||||
"dbgate-plugin-tools": "^1.0.4",
|
||||
"dbgate-tools": "^1.0.4",
|
||||
"webpack": "^4.42.0",
|
||||
"webpack-cli": "^3.3.11"
|
||||
}
|
||||
}
|
||||
8
plugins/dbgate-plugin-xml/prettier.config.js
Normal file
8
plugins/dbgate-plugin-xml/prettier.config.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = {
|
||||
trailingComma: 'es5',
|
||||
tabWidth: 2,
|
||||
semi: true,
|
||||
singleQuote: true,
|
||||
arrowParen: 'avoid',
|
||||
printWidth: 120,
|
||||
};
|
||||
10
plugins/dbgate-plugin-xml/src/backend/index.js
Normal file
10
plugins/dbgate-plugin-xml/src/backend/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const reader = require('./reader');
|
||||
const writer = require('./writer');
|
||||
|
||||
module.exports = {
|
||||
packageName: 'dbgate-plugin-xml',
|
||||
shellApi: {
|
||||
reader,
|
||||
writer,
|
||||
},
|
||||
};
|
||||
42
plugins/dbgate-plugin-xml/src/backend/reader.js
Normal file
42
plugins/dbgate-plugin-xml/src/backend/reader.js
Normal file
@@ -0,0 +1,42 @@
|
||||
const fs = require('fs');
|
||||
const stream = require('stream');
|
||||
const NodeXmlStream = require('node-xml-stream');
|
||||
|
||||
class ParseStream extends stream.Transform {
|
||||
constructor({ elementName }) {
|
||||
super({ objectMode: true });
|
||||
this.rowsWritten = 0;
|
||||
this.parser = new NodeXmlStream();
|
||||
this.stack = [];
|
||||
this.parser.on('opentag', (name, attrs) => {
|
||||
this.stack.push({ name, attrs, nodes: {} });
|
||||
});
|
||||
this.parser.on('text', (text) => {
|
||||
if (this.stack.length >= 2) {
|
||||
this.stack[this.stack.length - 2].nodes[this.stack[this.stack.length - 1].name] = text;
|
||||
}
|
||||
});
|
||||
this.parser.on('closetag', (name, attrs) => {
|
||||
if (name == elementName) {
|
||||
this.rowsWritten += 1;
|
||||
this.push({ ...this.stack[this.stack.length - 1].attrs, ...this.stack[this.stack.length - 1].nodes });
|
||||
}
|
||||
this.stack.splice(-1);
|
||||
});
|
||||
}
|
||||
_transform(chunk, encoding, done) {
|
||||
this.parser.write(chunk);
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
async function reader({ fileName, encoding = 'utf-8', elementName }) {
|
||||
console.log(`Reading file ${fileName}`);
|
||||
|
||||
const fileStream = fs.createReadStream(fileName, encoding);
|
||||
const parser = new ParseStream({ elementName });
|
||||
fileStream.pipe(parser);
|
||||
return parser;
|
||||
}
|
||||
|
||||
module.exports = reader;
|
||||
23
plugins/dbgate-plugin-xml/src/backend/writer.js
Normal file
23
plugins/dbgate-plugin-xml/src/backend/writer.js
Normal file
@@ -0,0 +1,23 @@
|
||||
const fs = require('fs');
|
||||
const stream = require('stream');
|
||||
|
||||
class StringifyStream extends stream.Transform {
|
||||
constructor() {
|
||||
super({ objectMode: true });
|
||||
}
|
||||
_transform(chunk, encoding, done) {
|
||||
this.push(JSON.stringify(chunk) + '\n');
|
||||
done();
|
||||
}
|
||||
}
|
||||
|
||||
async function writer({ fileName, encoding = 'utf-8' }) {
|
||||
console.log(`Writing file ${fileName}`);
|
||||
const stringify = new StringifyStream();
|
||||
const fileStream = fs.createWriteStream(fileName, encoding);
|
||||
stringify.pipe(fileStream);
|
||||
stringify['finisher'] = fileStream;
|
||||
return stringify;
|
||||
}
|
||||
|
||||
module.exports = writer;
|
||||
27
plugins/dbgate-plugin-xml/src/frontend/index.js
Normal file
27
plugins/dbgate-plugin-xml/src/frontend/index.js
Normal file
@@ -0,0 +1,27 @@
|
||||
const fileFormat = {
|
||||
packageName: 'dbgate-plugin-xml',
|
||||
// file format identifier
|
||||
storageType: 'xml@dbgate-plugin-xml',
|
||||
// file extension without leading dot
|
||||
extension: 'xml',
|
||||
// human readable file format name
|
||||
name: 'XML file',
|
||||
// function name from backend, which contains reader factory, postfixed by package name
|
||||
readerFunc: 'reader@dbgate-plugin-xml',
|
||||
// function name from backend, which contains writer factory, postfixed by package name
|
||||
writerFunc: 'writer@dbgate-plugin-xml',
|
||||
// optional list of format arguments, which can be edited from UI
|
||||
args: [
|
||||
{
|
||||
type: 'text',
|
||||
name: 'elementName',
|
||||
label: 'Element name',
|
||||
apiName: 'elementName',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
export default {
|
||||
fileFormats: [fileFormat],
|
||||
};
|
||||
|
||||
23
plugins/dbgate-plugin-xml/webpack-backend.config.js
Normal file
23
plugins/dbgate-plugin-xml/webpack-backend.config.js
Normal file
@@ -0,0 +1,23 @@
|
||||
var webpack = require('webpack');
|
||||
var path = require('path');
|
||||
|
||||
var config = {
|
||||
context: __dirname + '/src/backend',
|
||||
|
||||
entry: {
|
||||
app: './index.js',
|
||||
},
|
||||
target: 'node',
|
||||
output: {
|
||||
path: path.resolve(__dirname, 'dist'),
|
||||
filename: 'backend.js',
|
||||
libraryTarget: 'commonjs2',
|
||||
},
|
||||
|
||||
// uncomment for disable minimalization
|
||||
// optimization: {
|
||||
// minimize: false,
|
||||
// },
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
24
plugins/dbgate-plugin-xml/webpack-frontend.config.js
Normal file
24
plugins/dbgate-plugin-xml/webpack-frontend.config.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var webpack = require("webpack");
|
||||
var path = require("path");
|
||||
|
||||
var config = {
|
||||
context: __dirname + "/src/frontend",
|
||||
|
||||
entry: {
|
||||
app: "./index.js",
|
||||
},
|
||||
target: "web",
|
||||
output: {
|
||||
path: path.resolve(__dirname, "dist"),
|
||||
filename: "frontend.js",
|
||||
libraryTarget: "var",
|
||||
library: 'plugin',
|
||||
},
|
||||
|
||||
// uncomment for disable minimalization
|
||||
// optimization: {
|
||||
// minimize: false,
|
||||
// },
|
||||
};
|
||||
|
||||
module.exports = config;
|
||||
3653
plugins/dbgate-plugin-xml/yarn.lock
Normal file
3653
plugins/dbgate-plugin-xml/yarn.lock
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user