api documentation WIP

This commit is contained in:
Jan Prochazka
2024-11-15 16:09:04 +01:00
parent 8cb98cf643
commit f23575c405
6 changed files with 399 additions and 4 deletions

11
packages/api/doctpl.hbs Normal file
View File

@@ -0,0 +1,11 @@
---
layout: docs
title: API documentation
order: 21
docs_left: true
hide_hero: true
---
# API Documentation
{{>main}}

View File

@@ -76,13 +76,15 @@
"start:storage:built": "env-cmd -f env/storage/.env cross-env DEVMODE= BUILTWEBMODE=1 node dist/bundle.js --listen-api",
"start:singleconn": "env-cmd node src/index.js --server localhost --user root --port 3307 --engine mysql@dbgate-plugin-mysql --password test --listen-api",
"ts": "tsc",
"build": "webpack"
"build": "webpack",
"build:doc": "jsdoc2md --template doctpl.hbs ./src/shell/* > ../../../dbgate.github.io/_docs/apidoc.md"
},
"devDependencies": {
"@types/fs-extra": "^9.0.11",
"@types/lodash": "^4.14.149",
"dbgate-types": "^5.0.0-alpha.1",
"env-cmd": "^10.1.0",
"jsdoc-to-markdown": "^9.0.5",
"node-loader": "^1.0.2",
"nodemon": "^2.0.2",
"typescript": "^4.4.3",

View File

@@ -2,6 +2,13 @@ const EnsureStreamHeaderStream = require('../utility/EnsureStreamHeaderStream');
const Stream = require('stream');
const ColumnMapTransformStream = require('../utility/ColumnMapTransformStream');
/**
* Copies reader to writer. Used for import, export tables and transfer data between tables
* @param {readerType} input - reader object
* @param {writerType} output - writer object
* @param {object} options - options
* @returns {Promise}
*/
function copyStream(input, output, options) {
const { columns } = options || {};

View File

@@ -33,6 +33,14 @@ class ParseStream extends stream.Transform {
}
}
/**
* Reader function, which reads JSNOL file or URL. JSONL format - text file, every line is JSON encoded row.
* @param {Object} options
* @param {string} options.fileName - file name or URL
* @param {string} options.encoding - encoding of the file
* @param {number} options.limitRows - maximum number of rows to read
* @returns {Promise<readerType>} - reader object
*/
async function jsonLinesReader({ fileName, encoding = 'utf-8', limitRows = undefined }) {
logger.info(`Reading file ${fileName}`);

View File

@@ -0,0 +1,12 @@
/**
* Reader (input) object for copyStream function
* @typedef {Object} readerType
*
*/
/**
* Wrtiter (output) object for copyStream function
* @typedef {Object} writerType
*
*/