mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 23:26:00 +00:00
renamed dbgate packages, because of npmjs policy
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
# @dbgate/engines
|
||||
# dbgate-engines
|
||||
|
||||
JavaScript library implementing MySQL, MS SQL and PostgreSQL operations
|
||||
|
||||
## Installation
|
||||
|
||||
yarn add @dbgate/engines
|
||||
yarn add dbgate-engines
|
||||
|
||||
@@ -4,15 +4,15 @@ const fp = require('lodash/fp');
|
||||
class DatabaseAnalyser {
|
||||
/**
|
||||
*
|
||||
* @param {import('@dbgate/types').EngineDriver} driver
|
||||
* @param {import('dbgate-types').EngineDriver} driver
|
||||
*/
|
||||
constructor(pool, driver) {
|
||||
this.pool = pool;
|
||||
this.driver = driver;
|
||||
// this.result = DatabaseAnalyser.createEmptyStructure();
|
||||
/** @type {import('@dbgate/types').DatabaseInfo} */
|
||||
/** @type {import('dbgate-types').DatabaseInfo} */
|
||||
this.structure = null;
|
||||
/** import('@dbgate/types').DatabaseModification[]) */
|
||||
/** import('dbgate-types').DatabaseModification[]) */
|
||||
this.modifications = null;
|
||||
this.singleObjectFilter = null;
|
||||
}
|
||||
@@ -21,7 +21,7 @@ class DatabaseAnalyser {
|
||||
return DatabaseAnalyser.createEmptyStructure();
|
||||
}
|
||||
|
||||
/** @returns {Promise<import('@dbgate/types').DatabaseModification[]>} */
|
||||
/** @returns {Promise<import('dbgate-types').DatabaseModification[]>} */
|
||||
async getModifications() {
|
||||
if (this.structure == null) throw new Error('DatabaseAnalyse.getModifications - structure must be filled');
|
||||
|
||||
@@ -82,7 +82,7 @@ class DatabaseAnalyser {
|
||||
// }
|
||||
}
|
||||
|
||||
/** @returns {import('@dbgate/types').DatabaseInfo} */
|
||||
/** @returns {import('dbgate-types').DatabaseInfo} */
|
||||
DatabaseAnalyser.createEmptyStructure = () => ({
|
||||
tables: [],
|
||||
views: [],
|
||||
|
||||
@@ -2,7 +2,7 @@ const _ = require('lodash');
|
||||
const moment = require('moment');
|
||||
|
||||
class SqlDumper {
|
||||
/** @param driver {import('@dbgate/types').EngineDriver} */
|
||||
/** @param driver {import('dbgate-types').EngineDriver} */
|
||||
constructor(driver) {
|
||||
this.s = '';
|
||||
this.driver = driver;
|
||||
@@ -150,7 +150,7 @@ class SqlDumper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param column {import('@dbgate/types').ColumnInfo}
|
||||
* @param column {import('dbgate-types').ColumnInfo}
|
||||
*/
|
||||
columnDefinition(column, { includeDefault = true, includeNullable = true, includeCollate = true } = {}) {
|
||||
if (column.computedExpression) {
|
||||
@@ -176,7 +176,7 @@ class SqlDumper {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param column {import('@dbgate/types').ColumnInfo}
|
||||
* @param column {import('dbgate-types').ColumnInfo}
|
||||
*/
|
||||
columnDefault(column) {
|
||||
if (column.defaultConstraint != null) {
|
||||
@@ -202,7 +202,7 @@ class SqlDumper {
|
||||
}
|
||||
}
|
||||
|
||||
/** @param table {import('@dbgate/types').TableInfo} */
|
||||
/** @param table {import('dbgate-types').TableInfo} */
|
||||
createTable(table) {
|
||||
this.put('^create ^table %f ( &>&n', table);
|
||||
this.putCollection(',&n', table.columns, (col) => {
|
||||
@@ -245,7 +245,7 @@ class SqlDumper {
|
||||
// }
|
||||
}
|
||||
|
||||
/** @param fk {import('@dbgate/types').ForeignKeyInfo} */
|
||||
/** @param fk {import('dbgate-types').ForeignKeyInfo} */
|
||||
createForeignKeyFore(fk) {
|
||||
if (fk.constraintName != null) this.put('^constraint %i ', fk.constraintName);
|
||||
this.put(
|
||||
@@ -258,13 +258,13 @@ class SqlDumper {
|
||||
if (fk.updateAction) this.put(' ^on ^update %k', fk.updateAction);
|
||||
}
|
||||
|
||||
/** @param type {import('@dbgate/types').TransformType} */
|
||||
/** @param type {import('dbgate-types').TransformType} */
|
||||
transform(type, dumpExpr) {
|
||||
dumpExpr();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param table {import('@dbgate/types').NamedObjectInfo}
|
||||
* @param table {import('dbgate-types').NamedObjectInfo}
|
||||
* @param allow {boolean}
|
||||
*/
|
||||
allowIdentityInsert(table, allow) {}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
const { prepareTableForImport } = require('@dbgate/tools');
|
||||
const { prepareTableForImport } = require('dbgate-tools');
|
||||
const _ = require('lodash');
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('@dbgate/types').EngineDriver} driver
|
||||
* @param {import('dbgate-types').EngineDriver} driver
|
||||
*/
|
||||
function createBulkInsertStreamBase(driver, stream, pool, name, options) {
|
||||
const fullNameQuoted = name.schemaName
|
||||
|
||||
2
packages/engines/index.d.ts
vendored
2
packages/engines/index.d.ts
vendored
@@ -1,4 +1,4 @@
|
||||
import types from "@dbgate/types";
|
||||
import types from "dbgate-types";
|
||||
|
||||
declare function getDriver(
|
||||
connection: string | { engine: string }
|
||||
|
||||
@@ -4,7 +4,7 @@ const sql = require('./sql');
|
||||
|
||||
const DatabaseAnalyser = require('../default/DatabaseAnalyser');
|
||||
const { filter } = require('lodash');
|
||||
const { isTypeString, isTypeNumeric } = require('@dbgate/tools');
|
||||
const { isTypeString, isTypeNumeric } = require('dbgate-tools');
|
||||
|
||||
function objectTypeToField(type) {
|
||||
switch (type.trim()) {
|
||||
@@ -187,7 +187,7 @@ class MsSqlAnalyser extends DatabaseAnalyser {
|
||||
// object not modified
|
||||
if (obj && Math.abs(new Date(modifyDate).getTime() - new Date(obj.modifyDate).getTime()) < 1000) return null;
|
||||
|
||||
/** @type {import('@dbgate/types').DatabaseModification} */
|
||||
/** @type {import('dbgate-types').DatabaseModification} */
|
||||
const action = obj
|
||||
? {
|
||||
newName: { schemaName, pureName },
|
||||
|
||||
@@ -16,7 +16,7 @@ class MsSqlDumper extends SqlDumper {
|
||||
this.putCmd('^set ^identity_insert %f %k;&n', table, allow ? 'on' : 'off');
|
||||
}
|
||||
|
||||
/** @param type {import('@dbgate/types').TransformType} */
|
||||
/** @param type {import('dbgate-types').TransformType} */
|
||||
transform(type, dumpExpr) {
|
||||
switch (type) {
|
||||
case 'GROUP:YEAR':
|
||||
|
||||
@@ -2,7 +2,7 @@ const createBulkInsertStreamBase = require('../default/createBulkInsertStreamBas
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {import('@dbgate/types').EngineDriver} driver
|
||||
* @param {import('dbgate-types').EngineDriver} driver
|
||||
*/
|
||||
function createBulkInsertStream(driver, mssql, stream, pool, name, options) {
|
||||
const writable = createBulkInsertStreamBase(driver, stream, pool, name, options);
|
||||
|
||||
@@ -4,7 +4,7 @@ const MsSqlDumper = require('./MsSqlDumper');
|
||||
const createBulkInsertStream = require('./createBulkInsertStream');
|
||||
const driverBase = require('../default/driverBase');
|
||||
|
||||
/** @type {import('@dbgate/types').SqlDialect} */
|
||||
/** @type {import('dbgate-types').SqlDialect} */
|
||||
const dialect = {
|
||||
limitSelect: true,
|
||||
rangeSelect: true,
|
||||
@@ -51,7 +51,7 @@ function extractColumns(columns) {
|
||||
return [res, mapper];
|
||||
}
|
||||
|
||||
/** @type {import('@dbgate/types').EngineDriver} */
|
||||
/** @type {import('dbgate-types').EngineDriver} */
|
||||
const driver = {
|
||||
...driverBase,
|
||||
analyserClass: MsSqlAnalyser,
|
||||
|
||||
@@ -3,7 +3,7 @@ const _ = require('lodash');
|
||||
const sql = require('./sql');
|
||||
|
||||
const DatabaseAnalayser = require('../default/DatabaseAnalyser');
|
||||
const { isTypeString, isTypeNumeric } = require('@dbgate/tools');
|
||||
const { isTypeString, isTypeNumeric } = require('dbgate-tools');
|
||||
const { rangeStep } = require('lodash/fp');
|
||||
|
||||
function getColumnInfo({
|
||||
@@ -191,7 +191,7 @@ class MySqlAnalyser extends DatabaseAnalayser {
|
||||
|
||||
// console.log('MODIFICATION OF ', field, pureName, modifyDate, obj.modifyDate);
|
||||
|
||||
/** @type {import('@dbgate/types').DatabaseModification} */
|
||||
/** @type {import('dbgate-types').DatabaseModification} */
|
||||
const action = obj
|
||||
? {
|
||||
newName: { pureName },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const SqlDumper = require('../default/SqlDumper');
|
||||
|
||||
class MySqlDumper extends SqlDumper {
|
||||
/** @param type {import('@dbgate/types').TransformType} */
|
||||
/** @param type {import('dbgate-types').TransformType} */
|
||||
transform(type, dumpExpr) {
|
||||
switch (type) {
|
||||
case 'GROUP:YEAR':
|
||||
|
||||
@@ -2,7 +2,7 @@ const driverBase = require('../default/driverBase');
|
||||
const MySqlAnalyser = require('./MySqlAnalyser');
|
||||
const MySqlDumper = require('./MySqlDumper');
|
||||
|
||||
/** @type {import('@dbgate/types').SqlDialect} */
|
||||
/** @type {import('dbgate-types').SqlDialect} */
|
||||
const dialect = {
|
||||
rangeSelect: true,
|
||||
stringEscapeChar: '\\',
|
||||
@@ -20,7 +20,7 @@ function extractColumns(fields) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/** @type {import('@dbgate/types').EngineDriver} */
|
||||
/** @type {import('dbgate-types').EngineDriver} */
|
||||
const driver = {
|
||||
...driverBase,
|
||||
analyserClass: MySqlAnalyser,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "@dbgate/engines",
|
||||
"name": "dbgate-engines",
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"typings": "./index.d.ts",
|
||||
@@ -14,13 +14,13 @@
|
||||
"license": "GPL",
|
||||
|
||||
"devDependencies": {
|
||||
"@dbgate/types": "^1.0.0",
|
||||
"dbgate-types": "^1.0.0",
|
||||
"@types/lodash": "^4.14.149",
|
||||
"nodemon": "^2.0.2",
|
||||
"typescript": "^3.7.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"lodash": "^4.17.15",
|
||||
"@dbgate/tools": "^1.0.0"
|
||||
"dbgate-tools": "^1.0.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ const _ = require('lodash');
|
||||
const sql = require('./sql');
|
||||
|
||||
const DatabaseAnalayser = require('../default/DatabaseAnalyser');
|
||||
const { isTypeString, isTypeNumeric } = require('@dbgate/tools');
|
||||
const { isTypeString, isTypeNumeric } = require('dbgate-tools');
|
||||
|
||||
function normalizeTypeName(dataType) {
|
||||
if (dataType == 'character varying') return 'varchar';
|
||||
@@ -127,7 +127,7 @@ class PostgreAnalyser extends DatabaseAnalayser {
|
||||
|
||||
// console.log('MODIFICATION OF ', objectTypeField, schemaName, pureName);
|
||||
|
||||
/** @type {import('@dbgate/types').DatabaseModification} */
|
||||
/** @type {import('dbgate-types').DatabaseModification} */
|
||||
const action = obj
|
||||
? {
|
||||
newName: { schemaName, pureName },
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const SqlDumper = require('../default/SqlDumper');
|
||||
|
||||
class PostgreDumper extends SqlDumper {
|
||||
/** @param type {import('@dbgate/types').TransformType} */
|
||||
/** @param type {import('dbgate-types').TransformType} */
|
||||
transform(type, dumpExpr) {
|
||||
switch (type) {
|
||||
case 'GROUP:YEAR':
|
||||
|
||||
@@ -3,7 +3,7 @@ const driverBase = require('../default/driverBase');
|
||||
const PostgreAnalyser = require('./PostgreAnalyser');
|
||||
const PostgreDumper = require('./PostgreDumper');
|
||||
|
||||
/** @type {import('@dbgate/types').SqlDialect} */
|
||||
/** @type {import('dbgate-types').SqlDialect} */
|
||||
const dialect = {
|
||||
rangeSelect: true,
|
||||
// stringEscapeChar: '\\',
|
||||
@@ -14,7 +14,7 @@ const dialect = {
|
||||
},
|
||||
};
|
||||
|
||||
/** @type {import('@dbgate/types').EngineDriver} */
|
||||
/** @type {import('dbgate-types').EngineDriver} */
|
||||
const driver = {
|
||||
...driverBase,
|
||||
analyserClass: PostgreAnalyser,
|
||||
|
||||
Reference in New Issue
Block a user